f2fs_dentry_hash: avoid casting unsigned char to singed char
PATCH 1/17 f2fs_dentry_hash: avoid casting unsigned char to singed char
This can hurt when calculating hash value, resulting in false alarm.
--- fsck/fsck.c | 5 +++-- include/f2fs_fs.h | 2 +- lib/libf2fs.c | 31 ++++++++++++------------------- 3 files changed, 16 insertions(+), 22 deletions(-)
fsck/fsck.c +3 -2
@@ -542,11 +542,12 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,continue ; } - name_len =le32_to_cpu (de_blk->dentry[i].name_len); + name_len =le16_to_cpu (de_blk->dentry[i].name_len); name =calloc (name_len +1 ,1 );memcpy (name, de_blk->filename[i], name_len); + hash_code =f2fs_dentry_hash ((const unsigned char *)name, + name_len); - hash_code =f2fs_dentry_hash ((const char *)name, name_len);ASSERT (le32_to_cpu (de_blk->dentry[i].hash_code) == hash_code); ftype = de_blk->dentry[i].file_type;
include/f2fs_fs.h +1 -1
@@ -679,7 +679,7 @@ extern int dev_fill(void *, __u64, size_t);extern int dev_read_block (void *,__u64 );extern int dev_read_blocks (void *,__u64 ,__u32 ); -f2fs_hash_t f2fs_dentry_hash (const char *,int ); +f2fs_hash_t f2fs_dentry_hash (const unsigned char *,int );extern struct f2fs_configuration config;
lib/libf2fs.c +12 -19
@@ -235,7 +235,8 @@ static void TEA_transform(unsigned int buf[4], unsigned int const in[]) } -static void str2hashbuf (const char *msg,int len,unsigned int *buf,int num) +static void str2hashbuf (const unsigned char *msg,int len, +unsigned int *buf,int num) {unsigned pad, val;int i;
@@ -269,24 +270,17 @@ static void str2hashbuf(const char *msg, int len, unsigned int *buf, int num)* @param len name lenth * @return return on success hash value, errno on failure */ -f2fs_hash_t f2fs_dentry_hash (const char *name,int len) +f2fs_hash_t f2fs_dentry_hash (const unsigned char *name,int len) {__u32 hash;f2fs_hash_t f2fs_hash; -const char *p; +const unsigned char *p;__u32 in[8 ], buf[4 ];/* special hash codes for special dentries */ -if (name[0 ] =='.' ) { -if (name[1 ] =='\0' ) { - f2fs_hash =F2FS_DOT_HASH ; - goto exit; - } -if (name[1 ] =='.' && name[2 ] =='\0' ) { - f2fs_hash =F2FS_DDOT_HASH ; - goto exit; - } - } +if ((len <=2 ) && (name[0 ] =='.' ) && + (name[1 ] =='.' || name[1 ] =='\0' )) +return 0 ;/* Initialize the default seed for the hash checksum functions */ buf[0 ] =0x67452301 ;
@@ -295,18 +289,17 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int len) buf[3 ] =0x10325476 ; p = name; -while (len >0 ) { +while (1 ) {str2hashbuf (p, len, in,4 );TEA_transform (buf, in); - len -=16 ; p +=16 ; +if (len <=16 ) +break ; + len -=16 ; } hash = buf[0 ]; - f2fs_hash = hash; -exit: - f2fs_hash &= ~F2FS_HASH_COL_BIT ; - + f2fs_hash =cpu_to_le32 (hash & ~F2FS_HASH_COL_BIT );return f2fs_hash; }
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 2/17 fsck.f2fs: retry to fix corrupted image
This patch adds a facility to retry conducting fsck.
--- fsck/fsck.c | 9 +++- fsck/main.c | 141 +++++++++++++++++++++++++++++++++++------------------- include/f2fs_fs.h | 5 ++ 3 files changed, 104 insertions(+), 51 deletions(-)
fsck/fsck.c +8 -1
@@ -761,6 +761,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) node->nid, node->links); node = node->next; } + config.bug_on =1 ; }printf ("[FSCK] Unreachable nat entries " );
@@ -769,6 +770,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf (" [Fail] [0x%x]\n" , nr_unref_nid); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; }printf ("[FSCK] SIT valid block bitmap checking " );
@@ -777,6 +779,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf ("[Fail]\n" ); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; }printf ("[FSCK] Hard link checking for regular file " );
@@ -785,6 +788,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf (" [Fail] [0x%x]\n" , fsck->chk.multi_hard_link_files); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; }printf ("[FSCK] valid_block_count matching with CP " );
@@ -793,6 +797,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf (" [Fail] [0x%x]\n" , (u32 )fsck->chk.valid_blk_cnt); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; }printf ("[FSCK] valid_node_count matcing with CP (de lookup) " );
@@ -801,6 +806,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf (" [Fail] [0x%x]\n" , fsck->chk.valid_node_cnt); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; }printf ("[FSCK] valid_node_count matcing with CP (nat lookup) " );
@@ -809,6 +815,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf (" [Fail] [0x%x]\n" , fsck->chk.valid_nat_entry_cnt); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; }printf ("[FSCK] valid_inode_count matched with CP " );
@@ -817,8 +824,8 @@ int fsck_verify(struct f2fs_sb_info *sbi) }else {printf (" [Fail] [0x%x]\n" , fsck->chk.valid_inode_cnt); ret =EXIT_ERR_CODE ; + config.bug_on =1 ; } -return ret; }
fsck/main.c +91 -50
204 lines not on this page · raw message
include/f2fs_fs.h +5 -0
@@ -60,6 +60,7 @@ typedef unsigned long pgoff_t;printf ("\nAssertion failed!\n" ); \ printf("[%s:%4d] " #exp, __func__, __LINE__); \ printf("\n --> "fmt, ##__VA_ARGS__); \ + config.bug_on = 1; \ exit(-1); \ } \ } while (0);
@@ -69,6 +70,7 @@ typedef unsigned long pgoff_t;if (!(exp)) { \printf ("\nAssertion failed!\n" ); \ printf("[%s:%4d] " #exp"\n", __func__, __LINE__);\ + config.bug_on =1 ; \exit (-1 ); \ } \ }while (0 );
@@ -180,6 +182,9 @@ struct f2fs_configuration {int trim;int func;void *private; +int fix_on; +int fix_cnt; +int bug_on; } __attribute__((packed));#ifdef CONFIG_64BIT
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 3/17 fsck.f2fs: clean up codes
In reply to Jaegeuk KimFix wrong coding style.
--- fsck/dump.c | 2 +- fsck/f2fs.h | 12 +-- fsck/fsck.c | 294 +++++++++++++++++++++++++----------------------------- fsck/fsck.h | 105 +++++++------------ include/f2fs_fs.h | 83 ++++++++------- 5 files changed, 217 insertions(+), 279 deletions(-)
fsck/dump.c +1 -1
@@ -141,7 +141,7 @@ static void dump_node_blk(struct f2fs_sb_info *sbi, int ntype,struct node_info ni;struct f2fs_node *node_blk;int i, ret; -u32 idx, skip; +u32 idx, skip =0 ;switch (ntype) {case TYPE_DIRECT_NODE :
fsck/f2fs.h +6 -6
@@ -301,12 +301,12 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type) (segno / SIT_ENTRY_PER_BLOCK)#define TOTAL_SEGS (sbi) (SM_I(sbi)->main_segments) -#define IS_VALID_NID (sbi, nid) \ - do { \ - ASSERT(nid <= (NAT_ENTRY_PER_BLOCK * \ - F2FS_RAW_SUPER(sbi)->segment_count_nat \ - << (sbi->log_blocks_per_seg - 1))); \ - } while (0); +static inline bool IS_VALID_NID (struct f2fs_sb_info *sbi,u32 nid) +{ +return (nid <= (NAT_ENTRY_PER_BLOCK * +F2FS_RAW_SUPER (sbi)->segment_count_nat + << (sbi->log_blocks_per_seg -1 ))); +}#define IS_VALID_BLK_ADDR (sbi, addr) \ do { \
fsck/fsck.c +136 -158
547 lines not on this page · raw message
fsck/fsck.h +35 -70
116 lines not on this page · raw message
include/f2fs_fs.h +39 -44
137 lines not on this page · raw message
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 4/17 fsck.f2fs: handle IS_VALID_BLK_ADDR
In reply to Jaegeuk Kim--- fsck/f2fs.h | 21 +++++++++++---------- fsck/fsck.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 13 deletions(-)
fsck/f2fs.h +11 -10
@@ -308,16 +308,17 @@ static inline bool IS_VALID_NID(struct f2fs_sb_info *sbi, u32 nid) << (sbi->log_blocks_per_seg - 1))); } -#define IS_VALID_BLK_ADDR (sbi, addr) \ - do { \ - if (addr >= F2FS_RAW_SUPER(sbi)->block_count || \ - addr < SM_I(sbi)->main_blkaddr) \ - { \ - DBG(0, "block addr [0x%x]\n", addr); \ - ASSERT(addr < F2FS_RAW_SUPER(sbi)->block_count); \ - ASSERT(addr >= SM_I(sbi)->main_blkaddr); \ - } \ - } while (0); +static inline bool IS_VALID_BLK_ADDR (struct f2fs_sb_info *sbi,u32 addr) +{ +if (addr >=F2FS_RAW_SUPER (sbi)->block_count || + addr <SM_I (sbi)->main_blkaddr) { +DBG (0 ,"block addr [0x%x]\n" , addr); +ASSERT (addr <F2FS_RAW_SUPER (sbi)->block_count); +ASSERT (addr >=SM_I (sbi)->main_blkaddr); +return 0 ; + } +return 1 ; +}static inline u64 BLKOFF_FROM_MAIN (struct f2fs_sb_info *sbi,u64 blk_addr) {
fsck/fsck.c +11 -3
@@ -189,8 +189,10 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,struct f2fs_node *node_blk =NULL ;int ret =0 ; -if (!IS_VALID_NID (sbi, nid)) +if (!IS_VALID_NID (sbi, nid)) {ASSERT_MSG ("nid is not valid. [0x%x]" , nid); +return 0 ; + }if (ftype !=F2FS_FT_ORPHAN ||f2fs_test_bit (nid, fsck->nat_area_bitmap) !=0x0 )
@@ -213,7 +215,10 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,return 0 ; } -IS_VALID_BLK_ADDR (sbi, ni.blk_addr); +if (!IS_VALID_BLK_ADDR (sbi, ni.blk_addr)) { +ASSERT_MSG ("blkaddres is not valid. [0x%x]" , ni.blk_addr); +return 0 ; + }is_valid_ssa_node_blk (sbi, nid, ni.blk_addr);
@@ -596,7 +601,10 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,return 0 ; } -IS_VALID_BLK_ADDR (sbi, blk_addr); +if (!IS_VALID_BLK_ADDR (sbi, blk_addr)) { +ASSERT_MSG ("blkaddres is not valid. [0x%x]" , blk_addr); +return 0 ; + }is_valid_ssa_data_blk (sbi, blk_addr, parent_nid, idx_in_node, ver);
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 5/17 fsck.f2fs: remove return value of get_node_info
In reply to Jaegeuk KimWe don't need to get the return value.
--- fsck/dump.c | 23 +++++++++-------------- fsck/fsck.c | 5 ++--- fsck/fsck.h | 4 ++-- fsck/mount.c | 23 +++++++---------------- 4 files changed, 20 insertions(+), 35 deletions(-)
fsck/dump.c +9 -14
@@ -140,8 +140,8 @@ static void dump_node_blk(struct f2fs_sb_info *sbi, int ntype, {struct node_info ni;struct f2fs_node *node_blk; -int i, ret;u32 idx, skip =0 ; +int i;switch (ntype) {case TYPE_DIRECT_NODE :
@@ -162,8 +162,7 @@ static void dump_node_blk(struct f2fs_sb_info *sbi, int ntype,return ; } - ret =get_node_info (sbi, nid, &ni); -ASSERT (ret >=0 ); +get_node_info (sbi, nid, &ni); node_blk =calloc (BLOCK_SZ ,1 );dev_read_block (node_blk, ni.blk_addr);
@@ -267,14 +266,12 @@ void dump_file(struct f2fs_sb_info *sbi, struct node_info *ni, } } -int dump_node (struct f2fs_sb_info *sbi,nid_t nid) +void dump_node (struct f2fs_sb_info *sbi,nid_t nid) {struct node_info ni;struct f2fs_node *node_blk; -int ret; - ret =get_node_info (sbi, nid, &ni); -ASSERT (ret >=0 ); +get_node_info (sbi, nid, &ni); node_blk =calloc (BLOCK_SZ ,1 );dev_read_block (node_blk, ni.blk_addr);
@@ -284,9 +281,8 @@ int dump_node(struct f2fs_sb_info *sbi, nid_t nid)DBG (1 ,"nat_entry.version [0x%x]\n" , ni.version);DBG (1 ,"nat_entry.ino [0x%x]\n" , ni.ino); -if (ni.blk_addr ==0x0 ) { +if (ni.blk_addr ==0x0 )MSG (0 ,"Invalid nat entry\n\n" ); - }DBG (1 ,"node_blk.footer.ino [0x%x]\n" ,le32_to_cpu (node_blk->footer.ino));DBG (1 ,"node_blk.footer.nid [0x%x]\n" ,le32_to_cpu (node_blk->footer.nid));
@@ -300,7 +296,6 @@ int dump_node(struct f2fs_sb_info *sbi, nid_t nid) }free (node_blk); -return 0 ; }int dump_inode_from_blkaddr (struct f2fs_sb_info *sbi,u32 blk_addr)
@@ -314,8 +309,7 @@ int dump_inode_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr) type =get_sum_entry (sbi, blk_addr, &sum_entry); nid =le32_to_cpu (sum_entry.nid); - ret =get_node_info (sbi, nid, &ni); -ASSERT (ret >=0 ); +get_node_info (sbi, nid, &ni);DBG (1 ,"Note: blkaddr = main_blkaddr + segno * 512 + offset\n" );DBG (1 ,"Block_addr [0x%x]\n" , blk_addr);
@@ -331,7 +325,8 @@ int dump_inode_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr) node_blk =calloc (BLOCK_SZ ,1 ); read_node_blk: -dev_read_block (node_blk, blk_addr); + ret =dev_read_block (node_blk, blk_addr); +ASSERT (ret >=0 ); ino =le32_to_cpu (node_blk->footer.ino); nid =le32_to_cpu (node_blk->footer.nid);
@@ -339,7 +334,7 @@ read_node_blk:if (ino == nid) {print_node_info (node_blk); }else { - ret =get_node_info (sbi, ino, &ni); +get_node_info (sbi, ino, &ni); goto read_node_blk; }
fsck/fsck.c +2 -3
@@ -200,8 +200,7 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,else ASSERT_MSG ("nid duplicated [0x%x]\n" , nid); - ret =get_node_info (sbi, nid, &ni); -ASSERT (ret >=0 ); +get_node_info (sbi, nid, &ni);/* Is it reserved block? * if block addresss was 0xffff,ffff,ffff,ffff
@@ -682,7 +681,7 @@ int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino, fsck->chk.valid_blk_cnt++; fsck->chk.valid_node_cnt++; -ASSERT (get_node_info (sbi, x_nid, &ni) >=0 ); +get_node_info (sbi, x_nid, &ni);if (f2fs_test_main_bitmap (sbi, ni.blk_addr) !=0 ) { ASSERT_MSG("Duplicated node block for x_attr. "
fsck/fsck.h +2 -2
@@ -99,7 +99,7 @@ extern struct seg_entry *get_seg_entry(struct f2fs_sb_info *, unsigned int);extern int get_sum_block (struct f2fs_sb_info *,unsigned int ,struct f2fs_summary_block *);extern int get_sum_entry (struct f2fs_sb_info *,u32 ,struct f2fs_summary *); -extern int get_node_info (struct f2fs_sb_info *,nid_t ,struct node_info *); +extern void get_node_info (struct f2fs_sb_info *,nid_t ,struct node_info *);extern void build_nat_area_bitmap (struct f2fs_sb_info *);extern int build_sit_area_bitmap (struct f2fs_sb_info *);extern int fsck_init (struct f2fs_sb_info *);
@@ -120,7 +120,7 @@ struct dump_option {extern void sit_dump (struct f2fs_sb_info *,int ,int );extern void ssa_dump (struct f2fs_sb_info *,int ,int ); -extern int dump_node (struct f2fs_sb_info *,nid_t ); +extern void dump_node (struct f2fs_sb_info *,nid_t );extern int dump_inode_from_blkaddr (struct f2fs_sb_info *,u32 );#endif /* _FSCK_H_ */
fsck/mount.c +7 -16
@@ -801,9 +801,9 @@ int get_sum_entry(struct f2fs_sb_info *sbi, u32 blk_addr, struct f2fs_summary *sreturn ret; } -int get_nat_entry (struct f2fs_sb_info *sbi,nid_t nid,struct f2fs_nat_entry *raw_nat) +static void get_nat_entry (struct f2fs_sb_info *sbi,nid_t nid, +struct f2fs_nat_entry *raw_nat) { -struct f2fs_fsck *fsck =F2FS_FSCK (sbi);struct f2fs_nm_info *nm_i =NM_I (sbi);struct f2fs_nat_block *nat_block;pgoff_t block_off;
@@ -811,13 +811,8 @@ int get_nat_entry(struct f2fs_sb_info *sbi, nid_t nid, struct f2fs_nat_entry *raint seg_off, entry_off;int ret; -if ((nid /NAT_ENTRY_PER_BLOCK ) > fsck->nr_nat_entries) { -DBG (0 ,"nid is over max nid\n" ); -return -EINVAL ; - } -if (lookup_nat_in_journal (sbi, nid, raw_nat) >=0 ) -return 0 ; +return ; nat_block = (struct f2fs_nat_block *)calloc (BLOCK_SZ ,1 );
@@ -835,21 +830,17 @@ int get_nat_entry(struct f2fs_sb_info *sbi, nid_t nid, struct f2fs_nat_entry *ra ret =dev_read_block (nat_block, block_addr);ASSERT (ret >=0 ); -memcpy (raw_nat, &nat_block->entries[entry_off],sizeof (struct f2fs_nat_entry )); +memcpy (raw_nat, &nat_block->entries[entry_off], +sizeof (struct f2fs_nat_entry ));free (nat_block); - -return 0 ; } -int get_node_info (struct f2fs_sb_info *sbi,nid_t nid,struct node_info *ni) +void get_node_info (struct f2fs_sb_info *sbi,nid_t nid,struct node_info *ni) {struct f2fs_nat_entry raw_nat; -int ret; - - ret =get_nat_entry (sbi, nid, &raw_nat); +get_nat_entry (sbi, nid, &raw_nat); ni->nid = nid;node_info_from_raw_nat (ni, &raw_nat); -return ret; }void build_sit_entries (struct f2fs_sb_info *sbi)
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 6/17 fsck.f2fs: handle error cases
In reply to Jaegeuk KimDo sanity check first and then update metadata.
--- fsck/fsck.c | 344 +++++++++++++++++++++++++++++------------------------- fsck/fsck.h | 11 +- fsck/main.c | 40 ++----- fsck/mount.c | 3 +- include/f2fs_fs.h | 4 + 5 files changed, 205 insertions(+), 197 deletions(-)
fsck/fsck.c +182 -162
@@ -80,10 +80,8 @@ static int find_and_dec_hard_link_list(struct f2fs_sb_info *sbi, u32 nid)struct f2fs_fsck *fsck =F2FS_FSCK (sbi);struct hard_link_node *node =NULL , *prev =NULL ; -if (fsck->hard_link_list_head ==NULL ) { -ASSERT (0 ); -return -1 ; - } +if (fsck->hard_link_list_head ==NULL ) +return -EINVAL ; node = fsck->hard_link_list_head;
@@ -92,10 +90,8 @@ static int find_and_dec_hard_link_list(struct f2fs_sb_info *sbi, u32 nid) node = node->next; } -if (node ==NULL || (nid != node->nid)) { -ASSERT (0 ); -return -1 ; - } +if (node ==NULL || (nid != node->nid)) +return -EINVAL ;/* Decrease link count */ node->links = node->links -1 ;
@@ -108,9 +104,7 @@ static int find_and_dec_hard_link_list(struct f2fs_sb_info *sbi, u32 nid) prev->next = node->next;free (node); } -return 0 ; - } static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid,
@@ -138,14 +132,16 @@ static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid, le32_to_cpu(sum_entry.nid));DBG (0 ,"--> node block's nid [0x%x]\n" , nid);ASSERT_MSG ("Invalid node seg summary\n" ); +return -EINVAL ; } +return 0 ; }else if (ret ==SEG_TYPE_CUR_NODE ) {/* current node segment has no ssa */ +return 0 ; }else {ASSERT_MSG ("Invalid return value of 'get_sum_entry'" ); } - -return 1 ; +return -EINVAL ; } static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
@@ -177,114 +173,145 @@ static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,return 1 ; } -int fsck_chk_node_blk (struct f2fs_sb_info *sbi, -struct f2fs_inode *inode, -u32 nid, -enum FILE_TYPE ftype, -enum NODE_TYPE ntype, -u32 *blk_cnt) +static int sanity_check_nid (struct f2fs_sb_info *sbi,u32 nid, +struct f2fs_node *node_blk, +enum FILE_TYPE ftype,enum NODE_TYPE ntype, +struct node_info *ni) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi); -struct node_info ni; -struct f2fs_node *node_blk =NULL ; -int ret =0 ; +int ret;if (!IS_VALID_NID (sbi, nid)) {ASSERT_MSG ("nid is not valid. [0x%x]" , nid); -return 0 ; +return -EINVAL ; } -if (ftype !=F2FS_FT_ORPHAN || -f2fs_test_bit (nid, fsck->nat_area_bitmap) !=0x0 ) -f2fs_clear_bit (nid, fsck->nat_area_bitmap); -else -ASSERT_MSG ("nid duplicated [0x%x]\n" , nid); +get_node_info (sbi, nid, ni); +if (ni->blk_addr ==NEW_ADDR ) { +ASSERT_MSG ("nid is NEW_ADDR. [0x%x]" , nid); +return -EINVAL ; + } -get_node_info (sbi, nid, &ni); +if (!IS_VALID_BLK_ADDR (sbi, ni->blk_addr)) { +ASSERT_MSG ("blkaddres is not valid. [0x%x]" , ni->blk_addr); +return -EINVAL ; + } -/* Is it reserved block? -* if block addresss was 0xffff,ffff,ffff,ffff -* it means that block was already allocated, but not stored in disk -*/ -if (ni.blk_addr ==NEW_ADDR ) { - fsck->chk.valid_blk_cnt++; - fsck->chk.valid_node_cnt++; -if (ntype ==TYPE_INODE ) - fsck->chk.valid_inode_cnt++; -return 0 ; +if (is_valid_ssa_node_blk (sbi, nid, ni->blk_addr)) { +ASSERT_MSG ("summary node block is not valid. [0x%x]" , nid); +return -EINVAL ; } -if (!IS_VALID_BLK_ADDR (sbi, ni.blk_addr)) { -ASSERT_MSG ("blkaddres is not valid. [0x%x]" , ni.blk_addr); -return 0 ; + ret =dev_read_block (node_blk, ni->blk_addr); +ASSERT (ret >=0 ); + +if (ntype ==TYPE_INODE && + node_blk->footer.nid != node_blk->footer.ino) { +ASSERT_MSG ("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]" , + nid,le32_to_cpu (node_blk->footer.nid), +le32_to_cpu (node_blk->footer.ino)); +return -EINVAL ; + } +if (ntype !=TYPE_INODE && + node_blk->footer.nid == node_blk->footer.ino) { +ASSERT_MSG ("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]" , + nid,le32_to_cpu (node_blk->footer.nid), +le32_to_cpu (node_blk->footer.ino)); +return -EINVAL ; + } + +if (le32_to_cpu (node_blk->footer.nid) != nid) { +ASSERT_MSG ("nid[0x%x] blk_addr[0x%x] footer.nid[0x%x]" , + nid, ni->blk_addr, +le32_to_cpu (node_blk->footer.nid)); +return -EINVAL ; + } + +if (ntype ==TYPE_XATTR ) { +u32 flag =le32_to_cpu (node_blk->footer.flag); + +if ((flag >>OFFSET_BIT_SHIFT ) !=XATTR_NODE_OFFSET ) { +ASSERT_MSG ("xnid[0x%x] has wrong ofs:[0x%x]" , + nid, flag); +return -EINVAL ; + } + } + +if ((ntype ==TYPE_INODE && ftype ==F2FS_FT_DIR ) || + (ntype ==TYPE_XATTR && ftype ==F2FS_FT_XATTR )) { +/* not included '.' & '..' */ +if (f2fs_test_main_bitmap (sbi, ni->blk_addr) !=0 ) { +ASSERT_MSG ("Duplicated node blk. nid[0x%x][0x%x]\n" , + nid, ni->blk_addr); +return -EINVAL ; + } } -is_valid_ssa_node_blk (sbi, nid, ni.blk_addr); +/* workaround to fix later */ +if (ftype !=F2FS_FT_ORPHAN || +f2fs_test_bit (nid, fsck->nat_area_bitmap) !=0 ) +f2fs_clear_bit (nid, fsck->nat_area_bitmap); +else +ASSERT_MSG ("orphan or xattr nid is duplicated [0x%x]\n" , + nid); -if (f2fs_test_sit_bitmap (sbi, ni.blk_addr) ==0 ) -ASSERT_MSG ("SIT bitmap is 0x0. blk_addr[0x%x]" , ni.blk_addr); +if (f2fs_test_sit_bitmap (sbi, ni->blk_addr) ==0 ) +ASSERT_MSG ("SIT bitmap is 0x0. blk_addr[0x%x]" , + ni->blk_addr); -if (f2fs_test_main_bitmap (sbi, ni.blk_addr) ==0 ) { +if (f2fs_test_main_bitmap (sbi, ni->blk_addr) ==0 ) { fsck->chk.valid_blk_cnt++; fsck->chk.valid_node_cnt++; } +return 0 ; +} + +int fsck_chk_node_blk (struct f2fs_sb_info *sbi,struct f2fs_inode *inode, +u32 nid,enum FILE_TYPE ftype,enum NODE_TYPE ntype, +u32 *blk_cnt) +{ +struct node_info ni; +struct f2fs_node *node_blk =NULL ; node_blk = (struct f2fs_node *)calloc (BLOCK_SZ ,1 );ASSERT (node_blk !=NULL ); - ret =dev_read_block (node_blk, ni.blk_addr); -ASSERT (ret >=0 ); - -if (nid !=le32_to_cpu (node_blk->footer.nid)) -ASSERT_MSG ("nid[0x%x] blk_addr[0x%x] footer.nid[0x%x]" , - nid, ni.blk_addr,le32_to_cpu (node_blk->footer.nid)); +if (sanity_check_nid (sbi, nid, node_blk, ftype, ntype, &ni)) + goto err;if (ntype ==TYPE_INODE ) { - ret =fsck_chk_inode_blk (sbi, - nid, - ftype, - node_blk, - blk_cnt, - &ni); +fsck_chk_inode_blk (sbi, nid, ftype, node_blk, blk_cnt, &ni); }else { -/* it's not inode */ -ASSERT (node_blk->footer.nid != node_blk->footer.ino); - -if (f2fs_test_main_bitmap (sbi, ni.blk_addr) !=0 ) -ASSERT_MSG ("Duplicated node blk. nid[0x%x][0x%x]\n" , - nid, ni.blk_addr); -f2fs_set_main_bitmap (sbi, ni.blk_addr);switch (ntype) {case TYPE_DIRECT_NODE : - ret =fsck_chk_dnode_blk (sbi, inode, nid, ftype, - node_blk, blk_cnt, &ni); +fsck_chk_dnode_blk (sbi, inode, nid, ftype, node_blk, + blk_cnt, &ni);break ;case TYPE_INDIRECT_NODE : - ret =fsck_chk_idnode_blk (sbi, inode, ftype, node_blk, +fsck_chk_idnode_blk (sbi, inode, ftype, node_blk, blk_cnt);break ;case TYPE_DOUBLE_INDIRECT_NODE : - ret =fsck_chk_didnode_blk (sbi, inode, ftype, node_blk, +fsck_chk_didnode_blk (sbi, inode, ftype, node_blk, blk_cnt);break ;default :ASSERT (0 ); } } -ASSERT (ret >=0 ); -free (node_blk);return 0 ; +err: +free (node_blk); +return -EINVAL ; } -int fsck_chk_inode_blk (struct f2fs_sb_info *sbi, -u32 nid, -enum FILE_TYPE ftype, -struct f2fs_node *node_blk, -u32 *blk_cnt, -struct node_info *ni) +/* start with valid nid and blkaddr */ +void fsck_chk_inode_blk (struct f2fs_sb_info *sbi,u32 nid, +enum FILE_TYPE ftype,struct f2fs_node *node_blk, +u32 *blk_cnt,struct node_info *ni) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);u32 child_cnt =0 , child_files =0 ;
@@ -292,31 +319,13 @@ int fsck_chk_inode_blk(struct f2fs_sb_info *sbi,u32 i_links =le32_to_cpu (node_blk->i.i_links);u64 i_blocks =le64_to_cpu (node_blk->i.i_blocks);unsigned int idx =0 ; -int ret =0 ; - -ASSERT (node_blk->footer.nid == node_blk->footer.ino); -ASSERT (le32_to_cpu (node_blk->footer.nid) == nid); +int ret;if (f2fs_test_main_bitmap (sbi, ni->blk_addr) ==0 ) fsck->chk.valid_inode_cnt++; -/* Orphan node. i_links should be 0 */ -if (ftype ==F2FS_FT_ORPHAN ) { -ASSERT (i_links ==0 ); - }else { -ASSERT (i_links >0 ); - } -if (ftype ==F2FS_FT_DIR ) { - -/* not included '.' & '..' */ -if (f2fs_test_main_bitmap (sbi, ni->blk_addr) !=0 ) { -DBG (0 ,"Duplicated inode blk. ino[0x%x][0x%x]\n" , - nid, ni->blk_addr); -ASSERT (0 ); - }f2fs_set_main_bitmap (sbi, ni->blk_addr); - }else {if (f2fs_test_main_bitmap (sbi, ni->blk_addr) ==0 ) {f2fs_set_main_bitmap (sbi, ni->blk_addr);
@@ -326,21 +335,15 @@ int fsck_chk_inode_blk(struct f2fs_sb_info *sbi, fsck->chk.multi_hard_link_files++; } }else { -if (i_links <=1 ) { -DBG (0 ,"Error. Node ID [0x%x]." -" There are one more hard links." -" But i_links is [0x%x]\n" , +DBG (3 ,"[0x%x] has hard links [0x%x]\n" , nid, i_links); +if (find_and_dec_hard_link_list (sbi, nid)) { +ASSERT_MSG ("[0x%x] needs more i_links=0x%x" , nid, i_links); -ASSERT (0 ); +if (config.fix_cnt) +printf ("TODO: i_links++\n" ); } - -DBG (3 ,"ino[0x%x] has hard links [0x%x]\n" , - nid, i_links); - ret =find_and_dec_hard_link_list (sbi, nid); -ASSERT (ret >=0 ); -/* No need to go deep into the node */ - goto out; +return ; } }
@@ -358,13 +361,13 @@ int fsck_chk_inode_blk(struct f2fs_sb_info *sbi,/* check data blocks in inode */ for (idx =0 ; idx <ADDRS_PER_INODE (&node_blk->i); idx++) {if (le32_to_cpu (node_blk->i.i_addr[idx]) !=0 ) { - *blk_cnt = *blk_cnt +1 ; ret =fsck_chk_data_blk (sbi,le32_to_cpu (node_blk->i.i_addr[idx]), &child_cnt, &child_files, (i_blocks == *blk_cnt), ftype, nid, idx, ni->version); -ASSERT (ret >=0 ); +if (!ret) + *blk_cnt = *blk_cnt +1 ; } }
@@ -380,11 +383,13 @@ int fsck_chk_inode_blk(struct f2fs_sb_info *sbi,ASSERT (0 );if (le32_to_cpu (node_blk->i.i_nid[idx]) !=0 ) { - *blk_cnt = *blk_cnt +1 ; ret =fsck_chk_node_blk (sbi, &node_blk->i,le32_to_cpu (node_blk->i.i_nid[idx]), ftype, ntype, blk_cnt); -ASSERT (ret >=0 ); +if (!ret) + *blk_cnt = *blk_cnt +1 ; +else if (config.fix_cnt) +printf ("TODO delete i_nid[idx] = 0;\n" ); } } check:
@@ -400,35 +405,46 @@ check: node_blk->i.i_name, (u32)i_blocks);if ((ftype ==F2FS_FT_DIR && i_links != child_cnt) || - (i_blocks != *blk_cnt)) { -print_node_info (node_blk); + (i_blocks != *blk_cnt)) { +if (!config.fix_cnt) +print_node_info (node_blk); + +/* node_blk, ni.blkaddr, child_cnt, *blk_cnt */ +if (config.fix_cnt) +printf ("TODO fix_inode_block\n" ); +else +print_node_info (node_blk);DBG (1 ,"blk cnt [0x%x]\n" , *blk_cnt);DBG (1 ,"child cnt [0x%x]\n" , child_cnt); } - -ASSERT (i_blocks == *blk_cnt); -if (ftype ==F2FS_FT_DIR ) -ASSERT (i_links == child_cnt); -out: -return 0 ; +if (i_blocks != *blk_cnt) +ASSERT_MSG ("ino: 0x%x has i_blocks: %lu, but has %u blocks" , + nid, i_blocks, *blk_cnt); +if (ftype ==F2FS_FT_DIR && i_links != child_cnt) +ASSERT_MSG ("ino: 0x%x has i_links: %u but real links: %u" , + nid, i_links, child_cnt); +if (ftype ==F2FS_FT_ORPHAN && i_links) +ASSERT_MSG ("ino: 0x%x is orphan inode, but has i_links: %u" , + nid, i_links); }int fsck_chk_dnode_blk (struct f2fs_sb_info *sbi,struct f2fs_inode *inode,u32 nid,enum FILE_TYPE ftype,struct f2fs_node *node_blk,u32 *blk_cnt,struct node_info *ni) { -int idx; +int idx, ret;u32 child_cnt =0 , child_files =0 ;for (idx =0 ; idx <ADDRS_PER_BLOCK ; idx++) {if (le32_to_cpu (node_blk->dn.addr[idx]) ==0x0 )continue ; - *blk_cnt = *blk_cnt +1 ; -fsck_chk_data_blk (sbi, + ret =fsck_chk_data_blk (sbi,le32_to_cpu (node_blk->dn.addr[idx]), &child_cnt, &child_files,le64_to_cpu (inode->i_blocks) == *blk_cnt, ftype, nid, idx, ni->version); +if (!ret) + *blk_cnt = *blk_cnt +1 ; }return 0 ; }
@@ -436,14 +452,19 @@ int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,int fsck_chk_idnode_blk (struct f2fs_sb_info *sbi,struct f2fs_inode *inode,enum FILE_TYPE ftype,struct f2fs_node *node_blk,u32 *blk_cnt) { +int ret;int i =0 ;for (i =0 ; i <NIDS_PER_BLOCK ; i++) {if (le32_to_cpu (node_blk->in.nid[i]) ==0x0 )continue ; - *blk_cnt = *blk_cnt +1 ; -fsck_chk_node_blk (sbi, inode,le32_to_cpu (node_blk->in.nid[i]), + ret =fsck_chk_node_blk (sbi, inode, +le32_to_cpu (node_blk->in.nid[i]), ftype,TYPE_DIRECT_NODE , blk_cnt); +if (!ret) + *blk_cnt = *blk_cnt +1 ; +else if (ret == -EINVAL ) +printf ("delete in.nid[i] = 0;\n" ); }return 0 ; }
@@ -452,14 +473,18 @@ int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, enum FILE_TYPE ftype, struct f2fs_node *node_blk, u32 *blk_cnt) { int i = 0; +int ret =0 ;for (i =0 ; i <NIDS_PER_BLOCK ; i++) {if (le32_to_cpu (node_blk->in.nid[i]) ==0x0 )continue ; - *blk_cnt = *blk_cnt +1 ; -fsck_chk_node_blk (sbi, inode, + ret =fsck_chk_node_blk (sbi, inode,le32_to_cpu (node_blk->in.nid[i]), ftype,TYPE_INDIRECT_NODE , blk_cnt); +if (!ret) + *blk_cnt = *blk_cnt +1 ; +else if (ret == -EINVAL ) +printf ("delete in.nid[i] = 0;\n" ); }return 0 ; }
@@ -570,7 +595,8 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,TYPE_INODE , &blk_cnt); -ASSERT (ret >=0 ); +if (ret) +printf ("TODO: delete dentry\n" ); i += (name_len +F2FS_SLOT_LEN -1 ) /F2FS_SLOT_LEN ; dentries++;
@@ -618,35 +644,34 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, fsck->chk.valid_blk_cnt++; -if (ftype ==F2FS_FT_DIR ) { -fsck_chk_dentry_blk (sbi, blk_addr, child_cnt, +if (ftype ==F2FS_FT_DIR ) +return fsck_chk_dentry_blk (sbi, blk_addr, child_cnt, child_files, last_blk); - } -return 0 ; } -int fsck_chk_orphan_node (struct f2fs_sb_info *sbi) +void fsck_chk_orphan_node (struct f2fs_sb_info *sbi) { -int ret =0 ;u32 blk_cnt =0 ; -block_t start_blk, orphan_blkaddr, i, j;struct f2fs_orphan_block *orphan_blk;struct f2fs_checkpoint *ckpt =F2FS_CKPT (sbi);if (!is_set_ckpt_flags (ckpt,CP_ORPHAN_PRESENT_FLAG )) -return 0 ; +return ; + +if (config.fix_cnt) +return ; start_blk =__start_cp_addr (sbi) +1 +le32_to_cpu (F2FS_RAW_SUPER (sbi)->cp_payload); - orphan_blkaddr =__start_sum_addr (sbi) -1 ; - orphan_blk =calloc (BLOCK_SZ ,1 );for (i =0 ; i < orphan_blkaddr; i++) { -dev_read_block (orphan_blk, start_blk + i); +int ret =dev_read_block (orphan_blk, start_blk + i); + +ASSERT (ret >=0 );for (j =0 ; j <le32_to_cpu (orphan_blk->entry_count); j++) {nid_t ino =le32_to_cpu (orphan_blk->ino[j]);
@@ -654,47 +679,42 @@ int fsck_chk_orphan_node(struct f2fs_sb_info *sbi) blk_cnt =1 ; ret =fsck_chk_node_blk (sbi,NULL , ino,F2FS_FT_ORPHAN ,TYPE_INODE , &blk_cnt); -ASSERT (ret >=0 ); +if (ret == -EINVAL ) +printf ("TODO: nothing?\n" ); }memset (orphan_blk,0 ,BLOCK_SZ ); }free (orphan_blk); -return 0 ; } -int fsck_chk_xattr_blk (struct f2fs_sb_info *sbi,u32 ino, -u32 x_nid,u32 *blk_cnt) +void fsck_chk_xattr_blk (struct f2fs_sb_info *sbi,u32 ino, +u32 x_nid,u32 *blk_cnt) { -struct f2fs_fsck *fsck =F2FS_FSCK (sbi); +struct f2fs_node *node_blk =NULL ;struct node_info ni;if (x_nid ==0x0 ) -return 0 ; +return ; -if (f2fs_test_bit (x_nid, fsck->nat_area_bitmap) !=0x0 ) { -f2fs_clear_bit (x_nid, fsck->nat_area_bitmap); - }else { -ASSERT_MSG ("xattr_nid duplicated [0x%x]\n" , x_nid); + node_blk = (struct f2fs_node *)calloc (BLOCK_SZ ,1 ); +ASSERT (node_blk !=NULL ); + +/* Sanity check */ +if (sanity_check_nid (sbi, x_nid, node_blk, +F2FS_FT_XATTR ,TYPE_XATTR , &ni)) { +/* TODO: drop xattr node */ +printf ("drop xattr node\n" ); + goto out; } *blk_cnt = *blk_cnt +1 ; - fsck->chk.valid_blk_cnt++; - fsck->chk.valid_node_cnt++; - -get_node_info (sbi, x_nid, &ni); - -if (f2fs_test_main_bitmap (sbi, ni.blk_addr) !=0 ) { -ASSERT_MSG ("Duplicated node block for x_attr. " -"x_nid[0x%x] block addr[0x%x]\n" , - x_nid, ni.blk_addr); - }f2fs_set_main_bitmap (sbi, ni.blk_addr); -DBG (2 ,"ino[0x%x] x_nid[0x%x]\n" , ino, x_nid); -return 0 ; +out: +free (node_blk); } -int fsck_init (struct f2fs_sb_info *sbi) +void fsck_init (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);struct f2fs_sm_info *sm_i =SM_I (sbi);
@@ -718,7 +738,7 @@ int fsck_init(struct f2fs_sb_info *sbi)build_sit_area_bitmap (sbi); tree_mark =calloc (tree_mark_size,1 ); -return 0 ; +ASSERT (tree_mark !=NULL ); }int fsck_verify (struct f2fs_sb_info *sbi)
fsck/fsck.h +6 -5
@@ -59,7 +59,8 @@ enum NODE_TYPE {TYPE_INODE =37 ,TYPE_DIRECT_NODE =43 ,TYPE_INDIRECT_NODE =53 , -TYPE_DOUBLE_INDIRECT_NODE =67 +TYPE_DOUBLE_INDIRECT_NODE =67 , +TYPE_XATTR =77 }; struct hard_link_node {
@@ -76,11 +77,11 @@ enum seg_type { SEG_TYPE_MAX, }; -extern int fsck_chk_xattr_blk (struct f2fs_sb_info *,u32 ,u32 ,u32 *); -extern int fsck_chk_orphan_node (struct f2fs_sb_info *); +extern void fsck_chk_xattr_blk (struct f2fs_sb_info *,u32 ,u32 ,u32 *); +extern void fsck_chk_orphan_node (struct f2fs_sb_info *);extern int fsck_chk_node_blk (struct f2fs_sb_info *,struct f2fs_inode *,u32 ,enum FILE_TYPE ,enum NODE_TYPE ,u32 *); -extern int fsck_chk_inode_blk (struct f2fs_sb_info *,u32 ,enum FILE_TYPE , +extern void fsck_chk_inode_blk (struct f2fs_sb_info *,u32 ,enum FILE_TYPE ,struct f2fs_node *,u32 *,struct node_info *); extern int fsck_chk_dnode_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32, enum FILE_TYPE, struct f2fs_node *, u32 *,
@@ -102,7 +103,7 @@ extern int get_sum_entry(struct f2fs_sb_info *, u32, struct f2fs_summary *);extern void get_node_info (struct f2fs_sb_info *,nid_t ,struct node_info *);extern void build_nat_area_bitmap (struct f2fs_sb_info *);extern int build_sit_area_bitmap (struct f2fs_sb_info *); -extern int fsck_init (struct f2fs_sb_info *); +extern void fsck_init (struct f2fs_sb_info *);extern int fsck_verify (struct f2fs_sb_info *);extern void fsck_free (struct f2fs_sb_info *);extern int f2fs_do_mount (struct f2fs_sb_info *);
fsck/main.c +11 -29
@@ -131,44 +131,29 @@ void f2fs_parse_options(int argc, char *argv[]) config.device_name = argv[optind]; } -int do_fsck (struct f2fs_sb_info *sbi) +static void do_fsck (struct f2fs_sb_info *sbi) {u32 blk_cnt; -int ret; config.bug_on =0 ; - ret =fsck_init (sbi); -if (ret <0 ) -return ret; +fsck_init (sbi);fsck_chk_orphan_node (sbi);/* Traverse all block recursively from root inode */ blk_cnt =1 ; - ret =fsck_chk_node_blk (sbi, -NULL , - sbi->root_ino_num, -F2FS_FT_DIR , -TYPE_INODE , - &blk_cnt); -if (ret <0 ) - goto out1; - - ret =fsck_verify (sbi); -out1: +fsck_chk_node_blk (sbi,NULL , sbi->root_ino_num, +F2FS_FT_DIR ,TYPE_INODE , &blk_cnt); +fsck_verify (sbi);fsck_free (sbi); -return ret; } -int do_dump (struct f2fs_sb_info *sbi) +static void do_dump (struct f2fs_sb_info *sbi) {struct dump_option *opt = (struct dump_option *)config.private; -int ret; - ret =fsck_init (sbi); -if (ret <0 ) -return ret; +fsck_init (sbi);if (opt->end_sit ==-1 ) opt->end_sit =SM_I (sbi)->main_segments;
@@ -182,15 +167,12 @@ int do_dump(struct f2fs_sb_info *sbi)dump_inode_from_blkaddr (sbi, opt->blk_addr); goto cleanup; } -dump_node (sbi, opt->nid); - cleanup:fsck_free (sbi); -return 0 ; } -int main (int argc,char **argv) +int main (int argc,char **argv) {struct f2fs_sb_info *sbi;int ret =0 ;
@@ -215,10 +197,10 @@ fsck_again:switch (config.func) {case FSCK : - ret =do_fsck (sbi); +do_fsck (sbi);break ;case DUMP : - ret =do_dump (sbi); +do_dump (sbi);break ; }
@@ -248,5 +230,5 @@ retry:f2fs_finalize_device (&config);printf ("\nDone.\n" ); -return ret; +return 0 ; }
fsck/mount.c +2 -1
@@ -1020,7 +1020,8 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi)struct node_info ni; ni.nid = nid + i; -if ((nid + i) ==F2FS_NODE_INO (sbi) || (nid + i) ==F2FS_META_INO (sbi)) { +if ((nid + i) ==F2FS_NODE_INO (sbi) || + (nid + i) ==F2FS_META_INO (sbi)) {ASSERT (nat_block->entries[i].block_addr !=0x0 );continue ; }
include/f2fs_fs.h +4 -0
@@ -413,6 +413,9 @@ enum {OFFSET_BIT_SHIFT }; +#define XATTR_NODE_OFFSET ((((unsigned int)-1) << OFFSET_BIT_SHIFT) \ + >> OFFSET_BIT_SHIFT) +struct node_footer {__le32 nid;/* node id */ __le32 ino;/* inode nunmber */
@@ -640,6 +643,7 @@ enum FILE_TYPE {F2FS_FT_MAX ,/* added for fsck */ F2FS_FT_ORPHAN , + F2FS_FT_XATTR, };/* from f2fs/segment.h */
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 7/17 fsck.f2fs: cleanup mount.c
In reply to Jaegeuk Kim--- fsck/mount.c | 116 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 46 deletions(-)
fsck/mount.c +70 -46
@@ -53,7 +53,7 @@ void print_inode_info(struct f2fs_inode *inode)for (i =4 ; i <ADDRS_PER_INODE (inode); i++) {if (inode->i_addr[i] !=0x0 ) { -printf ("i_addr[0x%x] points data block\r\t\t\t\t[0x%4x]\n" , +printf ("i_addr[0x%x] points data block\r\t\t[0x%4x]\n" , i, inode->i_addr[i]);break ; }
@@ -79,9 +79,11 @@ void print_node_info(struct f2fs_node *node_block) }else {int i;u32 *dump_blk = (u32 *)node_block; -DBG (0 ,"Node ID [0x%x:%u] is direct node or indirect node.\n" , nid, nid); +DBG (0 ,"Node ID [0x%x:%u] is direct node or indirect node.\n" , + nid, nid);for (i =0 ; i <=10 ; i++) -MSG (0 ,"[%d]\t\t\t[0x%8x : %d]\n" , i, dump_blk[i], dump_blk[i]); +MSG (0 ,"[%d]\t\t\t[0x%8x : %d]\n" , + i, dump_blk[i], dump_blk[i]); } }
@@ -211,7 +213,8 @@ int sanity_check_raw_super(struct f2fs_super_block *raw_super)return -1 ; } -if (F2FS_LOG_SECTORS_PER_BLOCK !=le32_to_cpu (raw_super->log_sectors_per_block)) { +if (F2FS_LOG_SECTORS_PER_BLOCK != +le32_to_cpu (raw_super->log_sectors_per_block)) {return -1 ; }
@@ -230,7 +233,7 @@ int validate_super_block(struct f2fs_sb_info *sbi, int block)return 0 ;free (sbi->raw_super); -MSG (0 ,"\tCan't find a valid F2FS filesystem in %d superblock\n" , block); +MSG (0 ,"\tCan't find a valid F2FS superblock at 0x%x\n" , block);return -EINVAL ; }
@@ -258,7 +261,8 @@ int init_sb_info(struct f2fs_sb_info *sbi)return 0 ; } -void *validate_checkpoint (struct f2fs_sb_info *sbi,block_t cp_addr,unsigned long long *version) +void *validate_checkpoint (struct f2fs_sb_info *sbi,block_t cp_addr, +unsigned long long *version) {void *cp_page_1, *cp_page_2;struct f2fs_checkpoint *cp_block;
@@ -360,7 +364,8 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi) cp_blk_no =le32_to_cpu (raw_sb->cp_blkaddr);if (cur_page == cp2) - cp_blk_no +=1 <<le32_to_cpu (raw_sb->log_blocks_per_seg); + cp_blk_no +=1 << +le32_to_cpu (raw_sb->log_blocks_per_seg);/* copy sit bitmap */ for (i =1 ; i < cp_blks; i++) {unsigned char *ckpt = (unsigned char *)sbi->ckpt;
@@ -515,7 +520,8 @@ int read_compacted_summaries(struct f2fs_sb_info *sbi)memcpy (&curseg->sum_blk->n_nats, kaddr,SUM_JOURNAL_SIZE ); curseg =CURSEG_I (sbi,CURSEG_COLD_DATA ); -memcpy (&curseg->sum_blk->n_sits, kaddr +SUM_JOURNAL_SIZE ,SUM_JOURNAL_SIZE ); +memcpy (&curseg->sum_blk->n_sits, kaddr +SUM_JOURNAL_SIZE , +SUM_JOURNAL_SIZE ); offset =2 *SUM_JOURNAL_SIZE ;for (i =CURSEG_HOT_DATA ; i <=CURSEG_COLD_DATA ; i++) {
@@ -538,7 +544,8 @@ int read_compacted_summaries(struct f2fs_sb_info *sbi) s = (struct f2fs_summary *)(kaddr + offset); curseg->sum_blk->entries[j] = *s; offset +=SUMMARY_SIZE ; -if (offset +SUMMARY_SIZE <=PAGE_CACHE_SIZE -SUM_FOOTER_SIZE ) +if (offset +SUMMARY_SIZE <= +PAGE_CACHE_SIZE -SUM_FOOTER_SIZE )continue ;memset (kaddr,0 ,PAGE_SIZE );dev_read_block (kaddr, start++);
@@ -597,18 +604,22 @@ int read_normal_summaries(struct f2fs_sb_info *sbi, int type)if (IS_DATASEG (type)) { segno =le32_to_cpu (ckpt->cur_data_segno[type]); - blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type -CURSEG_HOT_DATA ]); + blk_off =le16_to_cpu (ckpt->cur_data_blkoff[type - +CURSEG_HOT_DATA ]);if (is_set_ckpt_flags (ckpt,CP_UMOUNT_FLAG )) blk_addr =sum_blk_addr (sbi,NR_CURSEG_TYPE , type);else blk_addr =sum_blk_addr (sbi,NR_CURSEG_DATA_TYPE , type); }else { - segno =le32_to_cpu (ckpt->cur_node_segno[type -CURSEG_HOT_NODE ]); - blk_off =le16_to_cpu (ckpt->cur_node_blkoff[type -CURSEG_HOT_NODE ]); + segno =le32_to_cpu (ckpt->cur_node_segno[type - +CURSEG_HOT_NODE ]); + blk_off =le16_to_cpu (ckpt->cur_node_blkoff[type - +CURSEG_HOT_NODE ]);if (is_set_ckpt_flags (ckpt,CP_UMOUNT_FLAG )) - blk_addr =sum_blk_addr (sbi,NR_CURSEG_NODE_TYPE , type -CURSEG_HOT_NODE ); + blk_addr =sum_blk_addr (sbi,NR_CURSEG_NODE_TYPE , + type -CURSEG_HOT_NODE );else blk_addr =GET_SUM_BLKADDR (sbi, segno); }
@@ -688,7 +699,8 @@ inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)ASSERT (segno <= end_segno); } -struct f2fs_sit_block *get_current_sit_page (struct f2fs_sb_info *sbi,unsigned int segno) +struct f2fs_sit_block *get_current_sit_page (struct f2fs_sb_info *sbi, +unsigned int segno) {struct sit_info *sit_i =SIT_I (sbi);unsigned int offset =SIT_BLOCK_OFFSET (sit_i, segno);
@@ -746,7 +758,8 @@ struct seg_entry *get_seg_entry(struct f2fs_sb_info *sbi,return &sit_i->sentries[segno]; } -int get_sum_block (struct f2fs_sb_info *sbi,unsigned int segno,struct f2fs_summary_block *sum_blk) +int get_sum_block (struct f2fs_sb_info *sbi,unsigned int segno, +struct f2fs_summary_block *sum_blk) {struct f2fs_checkpoint *ckpt =F2FS_CKPT (sbi);struct curseg_info *curseg;
@@ -758,7 +771,8 @@ int get_sum_block(struct f2fs_sb_info *sbi, unsigned int segno, struct f2fs_summif (segno == ckpt->cur_node_segno[type]) { curseg =CURSEG_I (sbi,CURSEG_HOT_NODE + type);memcpy (sum_blk, curseg->sum_blk,BLOCK_SZ ); -return SEG_TYPE_CUR_NODE ;/* current node seg was not stored */ +/* current node seg was not stored */ +return SEG_TYPE_CUR_NODE ; } }
@@ -767,8 +781,10 @@ int get_sum_block(struct f2fs_sb_info *sbi, unsigned int segno, struct f2fs_summ curseg =CURSEG_I (sbi, type);memcpy (sum_blk, curseg->sum_blk,BLOCK_SZ );ASSERT (!IS_SUM_NODE_SEG (sum_blk->footer)); -DBG (2 ,"segno [0x%x] is current data seg[0x%x]\n" , segno, type); -return SEG_TYPE_CUR_DATA ;/* current data seg was not stored */ +DBG (2 ,"segno [0x%x] is current data seg[0x%x]\n" , + segno, type); +/* current data seg was not stored */ +return SEG_TYPE_CUR_DATA ; } }
@@ -782,7 +798,8 @@ int get_sum_block(struct f2fs_sb_info *sbi, unsigned int segno, struct f2fs_summ } -int get_sum_entry (struct f2fs_sb_info *sbi,u32 blk_addr,struct f2fs_summary *sum_entry) +int get_sum_entry (struct f2fs_sb_info *sbi,u32 blk_addr, +struct f2fs_summary *sum_entry) {struct f2fs_summary_block *sum_blk;u32 segno, offset;
@@ -795,8 +812,8 @@ int get_sum_entry(struct f2fs_sb_info *sbi, u32 blk_addr, struct f2fs_summary *s ret =get_sum_block (sbi, segno, sum_blk); -memcpy (sum_entry, &(sum_blk->entries[offset]),sizeof (struct f2fs_summary )); - +memcpy (sum_entry, &(sum_blk->entries[offset]), +sizeof (struct f2fs_summary ));free (sum_blk);return ret; }
@@ -955,12 +972,14 @@ int build_sit_area_bitmap(struct f2fs_sb_info *sbi) fsck->chk.sit_valid_blocks = sum_vblocks; fsck->chk.sit_free_segs = free_segs; -DBG (1 ,"Blocks [0x%x : %d] Free Segs [0x%x : %d]\n\n" , sum_vblocks, sum_vblocks, +DBG (1 ,"Blocks [0x%x : %d] Free Segs [0x%x : %d]\n\n" , + sum_vblocks, sum_vblocks, free_segs, free_segs);return 0 ; } -int lookup_nat_in_journal (struct f2fs_sb_info *sbi,u32 nid,struct f2fs_nat_entry *raw_nat) +int lookup_nat_in_journal (struct f2fs_sb_info *sbi,u32 nid, +struct f2fs_nat_entry *raw_nat) {struct curseg_info *curseg =CURSEG_I (sbi,CURSEG_HOT_DATA );struct f2fs_summary_block *sum = curseg->sum_blk;
@@ -968,7 +987,8 @@ int lookup_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid, struct f2fs_nat_entfor (i =0 ; i <nats_in_cursum (sum); i++) {if (le32_to_cpu (nid_in_journal (sum, i)) == nid) { -memcpy (raw_nat, &nat_in_journal (sum, i),sizeof (struct f2fs_nat_entry )); +memcpy (raw_nat, &nat_in_journal (sum, i), +sizeof (struct f2fs_nat_entry ));DBG (3 ,"==> Found nid [0x%x] in nat cache\n" , nid);return i; }
@@ -994,7 +1014,8 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi) nat_block = (struct f2fs_nat_block *)calloc (BLOCK_SZ ,1 );/* Alloc & build nat entry bitmap */ - nr_nat_blks = (le32_to_cpu (raw_sb->segment_count_nat) /2 ) << sbi->log_blocks_per_seg; + nr_nat_blks = (le32_to_cpu (raw_sb->segment_count_nat) /2 ) << + sbi->log_blocks_per_seg; fsck->nr_nat_entries = nr_nat_blks *NAT_ENTRY_PER_BLOCK ; fsck->nat_area_bitmap_sz = (fsck->nr_nat_entries +7 ) /8 ;
@@ -1005,8 +1026,8 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi) seg_off = block_off >> sbi->log_blocks_per_seg; block_addr = (pgoff_t)(nm_i->nat_blkaddr + - (seg_off << sbi->log_blocks_per_seg <<1 ) + - (block_off & ((1 << sbi->log_blocks_per_seg) -1 ))); + (seg_off << sbi->log_blocks_per_seg <<1 ) + + (block_off & ((1 << sbi->log_blocks_per_seg) -1 )));if (f2fs_test_bit (block_off, nm_i->nat_bitmap)) block_addr += sbi->blocks_per_seg;
@@ -1026,34 +1047,35 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi)continue ; } -if (lookup_nat_in_journal (sbi, nid + i, &raw_nat) >=0 ) { +if (lookup_nat_in_journal (sbi, nid + i, + &raw_nat) >=0 ) {node_info_from_raw_nat (&ni, &raw_nat);if (ni.blk_addr !=0x0 ) { -f2fs_set_bit (nid + i, fsck->nat_area_bitmap); +f2fs_set_bit (nid + i, + fsck->nat_area_bitmap); fsck->chk.valid_nat_entry_cnt++; -DBG (3 ,"nid[0x%x] in nat cache\n" , nid + i); +DBG (3 ,"nid[0x%x] in nat cache\n" , + nid + i); } }else { -node_info_from_raw_nat (&ni, &nat_block->entries[i]); -if (ni.blk_addr !=0 ) { -ASSERT (nid + i !=0x0 ); - -DBG (3 ,"nid[0x%8x] in nat entry [0x%16x] [0x%8x]\n" , - nid + i, - ni.blk_addr, - ni.ino); - -f2fs_set_bit (nid + i, fsck->nat_area_bitmap); - fsck->chk.valid_nat_entry_cnt++; - } +node_info_from_raw_nat (&ni, + &nat_block->entries[i]); +if (ni.blk_addr ==0 ) +continue ; +ASSERT (nid + i !=0x0 ); + +DBG (3 ,"nid[0x%8x] addr[0x%16x] ino[0x%8x]\n" , + nid + i, ni.blk_addr, ni.ino); +f2fs_set_bit (nid + i, fsck->nat_area_bitmap); + fsck->chk.valid_nat_entry_cnt++; } } }free (nat_block);DBG (1 ,"valid nat entries (block_addr != 0x0) [0x%8x : %u]\n" , - fsck->chk.valid_nat_entry_cnt, fsck->chk.valid_nat_entry_cnt); - + fsck->chk.valid_nat_entry_cnt, + fsck->chk.valid_nat_entry_cnt); }int f2fs_do_mount (struct f2fs_sb_info *sbi)
@@ -1085,9 +1107,11 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi)print_ckpt_info (sbi); sbi->total_valid_node_count =le32_to_cpu (sbi->ckpt->valid_node_count); - sbi->total_valid_inode_count =le32_to_cpu (sbi->ckpt->valid_inode_count); + sbi->total_valid_inode_count = +le32_to_cpu (sbi->ckpt->valid_inode_count); sbi->user_block_count =le64_to_cpu (sbi->ckpt->user_block_count); - sbi->total_valid_block_count =le64_to_cpu (sbi->ckpt->valid_block_count); + sbi->total_valid_block_count = +le64_to_cpu (sbi->ckpt->valid_block_count); sbi->last_valid_block_count = sbi->total_valid_block_count; sbi->alloc_valid_block_count =0 ;
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 8/17 fsck.f2fs: give a chance to recover sit entries
In reply to Jaegeuk KimThis patch skips initial verfication on SIT entries, which checks the number of valid blocks from its bitmap.
--- fsck/fsck.c | 2 +- fsck/fsck.h | 2 +- fsck/mount.c | 39 +++++++++++++-------------------------- 3 files changed, 15 insertions(+), 28 deletions(-)
fsck/fsck.c +1 -1
@@ -634,7 +634,7 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,is_valid_ssa_data_blk (sbi, blk_addr, parent_nid, idx_in_node, ver);if (f2fs_test_sit_bitmap (sbi, blk_addr) ==0 ) -ASSERT_MSG ("SIT bitmap is 0x0. blk_addr[0x%x]\n" , blk_addr); +ASSERT_MSG ("SIT bitmap is 0x0. blk_addr[0x%x]" , blk_addr);if (f2fs_test_main_bitmap (sbi, blk_addr) !=0 ) ASSERT_MSG("Duplicated data [0x%x]. pnid[0x%x] idx[0x%x]",
fsck/fsck.h +1 -1
@@ -102,7 +102,7 @@ extern int get_sum_block(struct f2fs_sb_info *, unsigned int,extern int get_sum_entry (struct f2fs_sb_info *,u32 ,struct f2fs_summary *);extern void get_node_info (struct f2fs_sb_info *,nid_t ,struct node_info *);extern void build_nat_area_bitmap (struct f2fs_sb_info *); -extern int build_sit_area_bitmap (struct f2fs_sb_info *); +extern void build_sit_area_bitmap (struct f2fs_sb_info *);extern void fsck_init (struct f2fs_sb_info *);extern int fsck_verify (struct f2fs_sb_info *);extern void fsck_free (struct f2fs_sb_info *);
fsck/mount.c +13 -26
@@ -726,18 +726,22 @@ void check_block_count(struct f2fs_sb_info *sbi,int valid_blocks =0 ;unsigned int i; -/* check segment usage */ -ASSERT (GET_SIT_VBLOCKS (raw_sit) <= sbi->blocks_per_seg); +if (GET_SIT_VBLOCKS (raw_sit) > sbi->blocks_per_seg) +ASSERT_MSG ("Invalid SIT vblocks: segno=0x%x, %u" , + segno,GET_SIT_VBLOCKS (raw_sit));/* check boundary of a given segment number */ -ASSERT (segno <= end_segno); +if (segno > end_segno) +ASSERT_MSG ("Invalid SEGNO: 0x%x" , segno);/* check bitmap with valid block count */ -for (i =0 ; i < sbi->blocks_per_seg; i++) -if (f2fs_test_bit (i, (char *)raw_sit->valid_map)) - valid_blocks++; -ASSERT (GET_SIT_VBLOCKS (raw_sit) == valid_blocks); +for (i =0 ; i <SIT_VBLOCK_MAP_SIZE ; i++) + valid_blocks +=get_bits_in_byte (raw_sit->valid_map[i]); + +if (GET_SIT_VBLOCKS (raw_sit) != valid_blocks) +ASSERT_MSG ("Wrong SIT valid blocks: segno=0x%x, %u vs. %u" , + segno,GET_SIT_VBLOCKS (raw_sit), valid_blocks); } void seg_info_from_raw_sit(struct seg_entry *se,
@@ -918,18 +922,14 @@ int build_segment_manager(struct f2fs_sb_info *sbi)return 0 ; } -int build_sit_area_bitmap (struct f2fs_sb_info *sbi) +void build_sit_area_bitmap (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);struct f2fs_sm_info *sm_i =SM_I (sbi);unsigned int segno =0 ; -int j =0 ;char *ptr =NULL ; -u32 sum_vblocks =0 ;u32 free_segs =0 ; -u32 vblocks =0 ; -struct seg_entry *se; fsck->sit_area_bitmap_sz = sm_i->main_segments *SIT_VBLOCK_MAP_SIZE ;
@@ -938,20 +938,13 @@ int build_sit_area_bitmap(struct f2fs_sb_info *sbi)ASSERT (fsck->sit_area_bitmap_sz == fsck->main_area_bitmap_sz); -for (segno =0 ; segno < sm_i->main_segments; segno++) { +for (segno =0 ; segno <TOTAL_SEGS (sbi); segno++) { se =get_seg_entry (sbi, segno);memcpy (ptr, se->cur_valid_map,SIT_VBLOCK_MAP_SIZE ); ptr +=SIT_VBLOCK_MAP_SIZE ; - vblocks =0 ; -for (j =0 ; j <SIT_VBLOCK_MAP_SIZE ; j++) { - vblocks +=get_bits_in_byte (se->cur_valid_map[j]); - } -ASSERT (vblocks == se->valid_blocks); -if (se->valid_blocks ==0x0 ) { - if (sbi->ckpt->cur_node_segno[0] == segno || sbi->ckpt->cur_data_segno[0] == segno || sbi->ckpt->cur_node_segno[1] == segno ||
@@ -962,20 +955,16 @@ int build_sit_area_bitmap(struct f2fs_sb_info *sbi) }else { free_segs++; } - }else { -ASSERT (se->valid_blocks <=512 ); sum_vblocks += se->valid_blocks; } } - fsck->chk.sit_valid_blocks = sum_vblocks; fsck->chk.sit_free_segs = free_segs;DBG (1 ,"Blocks [0x%x : %d] Free Segs [0x%x : %d]\n\n" , sum_vblocks, sum_vblocks, free_segs, free_segs); -return 0 ; } int lookup_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid,
@@ -1003,14 +992,12 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi)struct f2fs_nm_info *nm_i =NM_I (sbi);struct f2fs_nat_block *nat_block;u32 nid, nr_nat_blks; -pgoff_t block_off;pgoff_t block_addr;int seg_off;int ret;unsigned int i; - nat_block = (struct f2fs_nat_block *)calloc (BLOCK_SZ ,1 );/* Alloc & build nat entry bitmap */
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 9/17 fsck.f2fs: fix inode block inconsistency
In reply to Jaegeuk KimThis patch is to fix inode block inconsistency such as iblocks and ilinks.
--- fsck/fsck.c | 61 +++++++++++++++++++++++++++++++++---------------------- include/f2fs_fs.h | 1 + lib/libf2fs_io.c | 5 +++++ 3 files changed, 43 insertions(+), 24 deletions(-)
fsck/fsck.c +37 -24
@@ -319,6 +319,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,u32 i_links =le32_to_cpu (node_blk->i.i_links);u64 i_blocks =le64_to_cpu (node_blk->i.i_blocks);unsigned int idx =0 ; +int need_fix =0 ;int ret;if (f2fs_test_main_bitmap (sbi, ni->blk_addr) ==0 )
@@ -339,8 +340,11 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,if (find_and_dec_hard_link_list (sbi, nid)) {ASSERT_MSG ("[0x%x] needs more i_links=0x%x" , nid, i_links); -if (config.fix_cnt) -printf ("TODO: i_links++\n" ); +if (config.fix_cnt) { + node_blk->i.i_links = +cpu_to_le32 (i_links +1 ); + need_fix =1 ; + } }/* No need to go deep into the node */ return ;
@@ -366,8 +370,12 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, &child_cnt, &child_files, (i_blocks == *blk_cnt), ftype, nid, idx, ni->version); -if (!ret) +if (!ret) { *blk_cnt = *blk_cnt +1 ; + }else if (config.fix_cnt) { + node_blk->i.i_addr[idx] =0 ; + need_fix =1 ; + } } }
@@ -386,10 +394,12 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, ret =fsck_chk_node_blk (sbi, &node_blk->i,le32_to_cpu (node_blk->i.i_nid[idx]), ftype, ntype, blk_cnt); -if (!ret) +if (!ret) { *blk_cnt = *blk_cnt +1 ; -else if (config.fix_cnt) -printf ("TODO delete i_nid[idx] = 0;\n" ); + }else if (config.fix_cnt) { + node_blk->i.i_nid[idx] =0 ; + need_fix =1 ; + } } } check:
@@ -404,28 +414,31 @@ check:le32_to_cpu (node_blk->footer.ino), node_blk->i.i_name, (u32)i_blocks); -if ((ftype ==F2FS_FT_DIR && i_links != child_cnt) || - (i_blocks != *blk_cnt)) { -if (!config.fix_cnt) -print_node_info (node_blk); - -/* node_blk, ni.blkaddr, child_cnt, *blk_cnt */ -if (config.fix_cnt) -printf ("TODO fix_inode_block\n" ); -else -print_node_info (node_blk); -DBG (1 ,"blk cnt [0x%x]\n" , *blk_cnt); -DBG (1 ,"child cnt [0x%x]\n" , child_cnt); - } -if (i_blocks != *blk_cnt) + +if (i_blocks != *blk_cnt) {ASSERT_MSG ("ino: 0x%x has i_blocks: %lu, but has %u blocks" , - nid, i_blocks, *blk_cnt); -if (ftype ==F2FS_FT_DIR && i_links != child_cnt) + nid, i_blocks, *blk_cnt); +if (config.fix_cnt) { + node_blk->i.i_blocks =cpu_to_le64 (*blk_cnt); + need_fix =1 ; + } + } +if (ftype ==F2FS_FT_DIR && i_links != child_cnt) {ASSERT_MSG ("ino: 0x%x has i_links: %u but real links: %u" , - nid, i_links, child_cnt); + nid, i_links, child_cnt); +if (config.fix_cnt) { + node_blk->i.i_links =cpu_to_le32 (child_cnt); + need_fix =1 ; + } + } +if (ftype ==F2FS_FT_ORPHAN && i_links)ASSERT_MSG ("ino: 0x%x is orphan inode, but has i_links: %u" , - nid, i_links); + nid, i_links); +if (need_fix) { + ret =dev_write_block (node_blk, ni->blk_addr); +ASSERT (ret >=0 ); + } } int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
include/f2fs_fs.h +1 -0
@@ -676,6 +676,7 @@ extern void f2fs_finalize_device(struct f2fs_configuration *);extern int dev_read (void *,__u64 ,size_t );extern int dev_write (void *,__u64 ,size_t ); +extern int dev_write_block (void *,__u64 );extern int dev_write_dump (void *,__u64 ,size_t );/* All bytes in the buffer must be 0 use dev_fill(). */ extern int dev_fill (void *,__u64 ,size_t );
lib/libf2fs_io.c +5 -0
@@ -46,6 +46,11 @@ int dev_write(void *buf, __u64 offset, size_t len)return 0 ; } +int dev_write_block (void *buf,__u64 blk_addr) +{ +return dev_write (buf, blk_addr *F2FS_BLKSIZE ,F2FS_BLKSIZE ); +} +int dev_write_dump (void *buf,__u64 offset,size_t len) {if (lseek64 (config.dump_fd, (off64_t )offset,SEEK_SET ) <0 )
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 10/17 fsck.f2fs: add fixing messeages
In reply to Jaegeuk Kim--- fsck/fsck.c | 9 +++++++++ include/f2fs_fs.h | 6 ++++++ 2 files changed, 15 insertions(+)
fsck/fsck.c +9 -0
@@ -344,6 +344,9 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, node_blk->i.i_links =cpu_to_le32 (i_links +1 ); need_fix =1 ; +FIX_MSG ("File: 0x%x " +"i_links= 0x%x -> 0x%x" , + nid, i_links, i_links +1 ); } }/* No need to go deep into the node */
@@ -375,6 +378,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, }else if (config.fix_cnt) { node_blk->i.i_addr[idx] =0 ; need_fix =1 ; +FIX_MSG ("[0x%x] i_addr[%d] = 0" , nid, idx); } } }
@@ -399,6 +403,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, }else if (config.fix_cnt) { node_blk->i.i_nid[idx] =0 ; need_fix =1 ; +FIX_MSG ("[0x%x] i_nid[%d] = 0" , nid, idx); } } }
@@ -421,6 +426,8 @@ check:if (config.fix_cnt) { node_blk->i.i_blocks =cpu_to_le64 (*blk_cnt); need_fix =1 ; +FIX_MSG ("[0x%x] i_blocks=0x%lx -> 0x%x" , + nid, i_blocks, *blk_cnt); } }if (ftype ==F2FS_FT_DIR && i_links != child_cnt) {
@@ -429,6 +436,8 @@ check:if (config.fix_cnt) { node_blk->i.i_links =cpu_to_le32 (child_cnt); need_fix =1 ; +FIX_MSG ("Dir: 0x%x i_links= 0x%x -> 0x%x" , + nid, i_links, child_cnt); } }
include/f2fs_fs.h +6 -0
@@ -54,6 +54,12 @@ typedef unsigned long pgoff_t;/* * Debugging interfaces */ +#define FIX_MSG (fmt, ...) \ + do { \ + printf("[FIX] (%s:%4d) ", __func__, __LINE__); \ + printf(" --> "fmt"\n", ##__VA_ARGS__); \ + } while (0) +#define ASSERT_MSG (fmt, ...) \ do { \ printf("[ASSERT] (%s:%4d) ", __func__, __LINE__); \
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 11/17 fsck.f2fs: remove dentry if its inode block is corrupted
In reply to Jaegeuk Kim--- fsck/fsck.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fsck/fsck.c +15 -2
@@ -617,8 +617,21 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,TYPE_INODE , &blk_cnt); -if (ret) -printf ("TODO: delete dentry\n" ); +if (ret && config.fix_cnt) { +int j; +int slots = (name_len +F2FS_SLOT_LEN -1 ) / +F2FS_SLOT_LEN ; +for (j =0 ; j < slots; j++) +clear_bit (i + j, + (unsigned long *)de_blk->dentry_bitmap); +FIX_MSG ("Unlink [0x%x] - %s len[0x%x], type[0x%x]" , +le32_to_cpu (de_blk->dentry[i].ino), + name, name_len, + de_blk->dentry[i].file_type); + i += slots; +free (name); +continue ; + } i += (name_len +F2FS_SLOT_LEN -1 ) /F2FS_SLOT_LEN ; dentries++;
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 12/17 fsck.f2fs: corrupted orphan inode will be removed
In reply to Jaegeuk Kim--- fsck/fsck.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fsck/fsck.c +1 -3
@@ -712,10 +712,8 @@ void fsck_chk_orphan_node(struct f2fs_sb_info *sbi)nid_t ino =le32_to_cpu (orphan_blk->ino[j]);DBG (1 ,"[%3d] ino [0x%x]\n" , i, ino); blk_cnt =1 ; - ret =fsck_chk_node_blk (sbi,NULL , ino, +fsck_chk_node_blk (sbi,NULL , ino,F2FS_FT_ORPHAN ,TYPE_INODE , &blk_cnt); -if (ret == -EINVAL ) -printf ("TODO: nothing?\n" ); }memset (orphan_blk,0 ,BLOCK_SZ ); }
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 13/17 fsck.f2fs: remove corrupted xattr block
In reply to Jaegeuk Kim--- fsck/fsck.c | 65 ++++++++++++++++++++++++++++++++++--------------------------- fsck/fsck.h | 1 - 2 files changed, 36 insertions(+), 30 deletions(-)
fsck/fsck.c +36 -29
@@ -266,6 +266,34 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,return 0 ; } +static int fsck_chk_xattr_blk (struct f2fs_sb_info *sbi,u32 ino, +u32 x_nid,u32 *blk_cnt) +{ +struct f2fs_node *node_blk =NULL ; +struct node_info ni; +int ret =0 ; + +if (x_nid ==0x0 ) +return 0 ; + + node_blk = (struct f2fs_node *)calloc (BLOCK_SZ ,1 ); +ASSERT (node_blk !=NULL ); + +/* Sanity check */ +if (sanity_check_nid (sbi, x_nid, node_blk, +F2FS_FT_XATTR ,TYPE_XATTR , &ni)) { + ret = -EINVAL ; + goto out; + } + + *blk_cnt = *blk_cnt +1 ; +f2fs_set_main_bitmap (sbi, ni.blk_addr); +DBG (2 ,"ino[0x%x] x_nid[0x%x]\n" , ino, x_nid); +out: +free (node_blk); +return ret; +} +int fsck_chk_node_blk (struct f2fs_sb_info *sbi,struct f2fs_inode *inode,u32 nid,enum FILE_TYPE ftype,enum NODE_TYPE ntype,u32 *blk_cnt)
@@ -354,8 +382,14 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, } } -fsck_chk_xattr_blk (sbi, nid, -le32_to_cpu (node_blk->i.i_xattr_nid), blk_cnt); +if (fsck_chk_xattr_blk (sbi, nid, +le32_to_cpu (node_blk->i.i_xattr_nid), blk_cnt) && + config.fix_cnt) { + node_blk->i.i_xattr_nid =0 ; + need_fix =1 ; +FIX_MSG ("Remove xattr block: 0x%x, x_nid = 0x%x" , + nid,le32_to_cpu (node_blk->i.i_xattr_nid)); + }if (ftype ==F2FS_FT_CHRDEV || ftype ==F2FS_FT_BLKDEV || ftype ==F2FS_FT_FIFO || ftype ==F2FS_FT_SOCK )
@@ -720,33 +754,6 @@ void fsck_chk_orphan_node(struct f2fs_sb_info *sbi)free (orphan_blk); } -void fsck_chk_xattr_blk (struct f2fs_sb_info *sbi,u32 ino, -u32 x_nid,u32 *blk_cnt) -{ -struct f2fs_node *node_blk =NULL ; -struct node_info ni; - -if (x_nid ==0x0 ) -return ; - - node_blk = (struct f2fs_node *)calloc (BLOCK_SZ ,1 ); -ASSERT (node_blk !=NULL ); - -/* Sanity check */ -if (sanity_check_nid (sbi, x_nid, node_blk, -F2FS_FT_XATTR ,TYPE_XATTR , &ni)) { -/* TODO: drop xattr node */ -printf ("drop xattr node\n" ); - goto out; - } - - *blk_cnt = *blk_cnt +1 ; -f2fs_set_main_bitmap (sbi, ni.blk_addr); -DBG (2 ,"ino[0x%x] x_nid[0x%x]\n" , ino, x_nid); -out: -free (node_blk); -} -void fsck_init (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);
fsck/fsck.h +0 -1
@@ -77,7 +77,6 @@ enum seg_type { SEG_TYPE_MAX, }; -extern void fsck_chk_xattr_blk (struct f2fs_sb_info *,u32 ,u32 ,u32 *);extern void fsck_chk_orphan_node (struct f2fs_sb_info *);extern int fsck_chk_node_blk (struct f2fs_sb_info *,struct f2fs_inode *,u32 ,enum FILE_TYPE ,enum NODE_TYPE ,u32 *);
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 14/17 fsck.f2fs: handle correctly segment summary entries
In reply to Jaegeuk Kim--- fsck/fsck.c | 58 ++++++++++++++++-------------- fsck/mount.c | 113 ++++++++++++++++++++++++++--------------------------------- 2 files changed, 80 insertions(+), 91 deletions(-)
fsck/fsck.c +31 -27
@@ -114,34 +114,28 @@ static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid,struct f2fs_summary sum_entry; ret =get_sum_entry (sbi, blk_addr, &sum_entry); -ASSERT (ret >=0 ); -if (ret ==SEG_TYPE_DATA || ret ==SEG_TYPE_CUR_DATA ) { -ASSERT_MSG ("Summary footer is not for node segment\n" ); - }else if (ret ==SEG_TYPE_NODE ) { -if (le32_to_cpu (sum_entry.nid) != nid) { -DBG (0 ,"nid [0x%x]\n" , nid); -DBG (0 ,"target blk_addr [0x%x]\n" , blk_addr); -DBG (0 ,"summary blk_addr [0x%x]\n" , +if (ret !=SEG_TYPE_NODE && ret !=SEG_TYPE_CUR_NODE ) { +ASSERT_MSG ("Summary footer is not for node segment" ); +return -EINVAL ; + } + +if (le32_to_cpu (sum_entry.nid) != nid) { +DBG (0 ,"nid [0x%x]\n" , nid); +DBG (0 ,"target blk_addr [0x%x]\n" , blk_addr); +DBG (0 ,"summary blk_addr [0x%x]\n" ,GET_SUM_BLKADDR (sbi, -GET_SEGNO (sbi, blk_addr))); -DBG (0 ,"seg no / offset [0x%x / 0x%x]\n" , +GET_SEGNO (sbi, blk_addr))); +DBG (0 ,"seg no / offset [0x%x / 0x%x]\n" ,GET_SEGNO (sbi, blk_addr), -OFFSET_IN_SEG (sbi, blk_addr)); -DBG (0 ,"summary_entry.nid [0x%x]\n" , +OFFSET_IN_SEG (sbi, blk_addr)); +DBG (0 ,"summary_entry.nid [0x%x]\n" ,le32_to_cpu (sum_entry.nid)); -DBG (0 ,"--> node block's nid [0x%x]\n" , nid); -ASSERT_MSG ("Invalid node seg summary\n" ); -return -EINVAL ; - } -return 0 ; - }else if (ret ==SEG_TYPE_CUR_NODE ) { -/* current node segment has no ssa */ -return 0 ; - }else { -ASSERT_MSG ("Invalid return value of 'get_sum_entry'" ); +DBG (0 ,"--> node block's nid [0x%x]\n" , nid); +ASSERT_MSG ("Invalid node seg summary\n" ); +return -EINVAL ; } -return -EINVAL ; +return 0 ; } static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
@@ -151,7 +145,11 @@ static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,struct f2fs_summary sum_entry; ret =get_sum_entry (sbi, blk_addr, &sum_entry); -ASSERT (ret ==SEG_TYPE_DATA || ret ==SEG_TYPE_CUR_DATA ); + +if (ret !=SEG_TYPE_DATA && ret !=SEG_TYPE_CUR_DATA ) { +ASSERT_MSG ("Summary footer is not for data segment" ); +return -EINVAL ; + } if (le32_to_cpu(sum_entry.nid) != parent_nid || sum_entry.version != version ||
@@ -169,8 +167,9 @@ static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,DBG (0 ,"Target data block addr [0x%x]\n" , blk_addr);ASSERT_MSG ("Invalid data seg summary\n" ); +return -EINVAL ; } -return 1 ; +return 0 ; } static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
@@ -697,10 +696,15 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,if (!IS_VALID_BLK_ADDR (sbi, blk_addr)) {ASSERT_MSG ("blkaddres is not valid. [0x%x]" , blk_addr); -return 0 ; +return -EINVAL ; } -is_valid_ssa_data_blk (sbi, blk_addr, parent_nid, idx_in_node, ver); +if (is_valid_ssa_data_blk (sbi, blk_addr, parent_nid, + idx_in_node, ver)) { +ASSERT_MSG ("summary data block is not valid. [0x%x]" , + parent_nid); +return -EINVAL ; + }if (f2fs_test_sit_bitmap (sbi, blk_addr) ==0 )ASSERT_MSG ("SIT bitmap is 0x0. blk_addr[0x%x]" , blk_addr);
fsck/mount.c +49 -64
229 lines not on this page · raw message
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 15/17 fsck.f2fs: fix checkpoint
In reply to Jaegeuk Kim- fix nat entries
- fix sit entries
- fix checkpoint
--- fsck/f2fs.h | 1 + fsck/fsck.c | 84 ++++++++++++++++++++++++++++++++++ fsck/fsck.h | 3 ++ fsck/mount.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 227 insertions(+), 5 deletions(-)
fsck/f2fs.h +1 -0
@@ -126,6 +126,7 @@ struct f2fs_sb_info {struct f2fs_nm_info *nm_info;struct f2fs_sm_info *sm_info;struct f2fs_checkpoint *ckpt; +int cur_cp;struct list_head orphan_inode_list;unsigned int n_orphans;
fsck/fsck.c +84 -0
96 lines not on this page · raw message
fsck/fsck.h +3 -0
@@ -31,6 +31,7 @@ struct f2fs_fsck {u32 multi_hard_link_files;u64 sit_valid_blocks;u32 sit_free_segs; +u32 free_segs; } chk;struct hard_link_node *hard_link_list_head;
@@ -100,6 +101,8 @@ extern int get_sum_block(struct f2fs_sb_info *, unsigned int, struct f2fs_summary_block *);extern int get_sum_entry (struct f2fs_sb_info *,u32 ,struct f2fs_summary *);extern void get_node_info (struct f2fs_sb_info *,nid_t ,struct node_info *); +extern void nullify_nat_entry (struct f2fs_sb_info *,u32 ); +extern void rewrite_sit_area_bitmap (struct f2fs_sb_info *);extern void build_nat_area_bitmap (struct f2fs_sb_info *);extern void build_sit_area_bitmap (struct f2fs_sb_info *);extern void fsck_init (struct f2fs_sb_info *);
fsck/mount.c +139 -5
226 lines not on this page · raw message
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 16/17 fsck.f2fs: check next block is free or not
In reply to Jaegeuk KimIf block allocation is made to the next block offset, we should drop that block.
--- fsck/f2fs.h | 19 +++++++++++++++++-- fsck/fsck.c | 27 +++++++++++++++++++++++++++ fsck/mount.c | 46 +++++++++++++++++++++------------------------- 3 files changed, 65 insertions(+), 27 deletions(-)
fsck/f2fs.h +17 -2
@@ -266,10 +266,15 @@ static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)#define GET_SEGNO_FROM_SEG0 (sbi, blk_addr) \ (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> sbi->log_blocks_per_seg) -#define FREE_I_START_SEGNO (sbi) GET_SEGNO_FROM_SEG0(sbi, SM_I(sbi)->main_blkaddr) +#define GET_BLKOFF_FROM_SEG0 (sbi, blk_addr) \ + (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & (sbi->blocks_per_seg - 1)) + +#define FREE_I_START_SEGNO (sbi) \ + GET_SEGNO_FROM_SEG0(sbi, SM_I(sbi)->main_blkaddr)#define GET_R2L_SEGNO (sbi, segno) (segno + FREE_I_START_SEGNO(sbi)) -#define START_BLOCK (sbi, segno) (SM_I(sbi)->main_blkaddr + (segno << sbi->log_blocks_per_seg)) +#define START_BLOCK (sbi, segno) (SM_I(sbi)->main_blkaddr + \ + (segno << sbi->log_blocks_per_seg))static inline struct curseg_info *CURSEG_I (struct f2fs_sb_info *sbi,int type) {
@@ -311,6 +316,8 @@ static inline bool IS_VALID_NID(struct f2fs_sb_info *sbi, u32 nid)static inline bool IS_VALID_BLK_ADDR (struct f2fs_sb_info *sbi,u32 addr) { +int i; +if (addr >=F2FS_RAW_SUPER (sbi)->block_count || addr <SM_I (sbi)->main_blkaddr) {DBG (0 ,"block addr [0x%x]\n" , addr);
@@ -318,6 +325,14 @@ static inline bool IS_VALID_BLK_ADDR(struct f2fs_sb_info *sbi, u32 addr)ASSERT (addr >=SM_I (sbi)->main_blkaddr);return 0 ; } + +for (i =0 ; i <NO_CHECK_TYPE ; i++) { +struct curseg_info *curseg =CURSEG_I (sbi, i); + +if (START_BLOCK (sbi, curseg->segno) + + curseg->next_blkoff == addr) +return 0 ; + }return 1 ; }
fsck/fsck.c +27 -0
@@ -843,6 +843,24 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)ASSERT (ret >=0 ); } +int check_curseg_offset (struct f2fs_sb_info *sbi) +{ +int i; + +for (i =0 ; i <NO_CHECK_TYPE ; i++) { +struct curseg_info *curseg =CURSEG_I (sbi, i); +struct seg_entry *se; + + se =get_seg_entry (sbi, curseg->segno); +if (f2fs_test_bit (curseg->next_blkoff, + (const char *)se->cur_valid_map) ==1 ) { +ASSERT_MSG ("Next block offset is not free, type:%d" , i); +return -EINVAL ; + } + } +return 0 ; +} +int fsck_verify (struct f2fs_sb_info *sbi) {unsigned int i =0 ;
@@ -944,6 +962,15 @@ int fsck_verify(struct f2fs_sb_info *sbi) config.bug_on =1 ; } +printf ("[FSCK] next block offset is free " ); +if (check_curseg_offset (sbi) ==0 ) { +printf (" [Ok..]\n" ); + }else { +printf (" [Fail]\n" ); + ret =EXIT_ERR_CODE ; + config.bug_on =1 ; + } +printf ("[FSCK] other corrupted bugs " );if (config.bug_on ==0 ) {printf (" [Ok..]\n" );
fsck/mount.c +21 -25
107 lines not on this page · raw message
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
PATCH 17/17 fsck.f2fs: remove list.h
In reply to Jaegeuk KimJust use list_head only.
--- fsck/f2fs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fsck/f2fs.h +4 -1
@@ -26,7 +26,6 @@#include <sys/mount.h> #include <assert.h> -#include <list.h> #include <f2fs_fs.h> #define EXIT_ERR_CODE (-1)
@@ -34,6 +33,10 @@ typecheck(unsigned long long, b) && \ ((long long)((a) - (b)) > 0)) +struct list_head { +struct list_head *next, *prev; +}; +enum {NAT_BITMAP ,SIT_BITMAP
Signature · 7 lines
1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/