fsck.f2fs: fix sit types seamlessly
PATCH 1/3 fsck.f2fs: fix sit types seamlessly
SIT types can be wrong when active_logs are 2 or 4. So, let's fix this implicitly.
--- fsck/fsck.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
fsck/fsck.c +5 -9
@@ -1023,6 +1023,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) {unsigned int i =0 ;int ret =0 ; +int force =0 ;u32 nr_unref_nid =0 ;struct f2fs_fsck *fsck =F2FS_FSCK (sbi);struct hard_link_node *node =NULL ;
@@ -1129,14 +1130,9 @@ int fsck_verify(struct f2fs_sb_info *sbi) config.bug_on =1 ; } -printf ("[FSCK] SIT types " ); -if (check_sit_types (sbi) ==0 ) { -printf (" [Ok..]\n" ); - }else { -printf (" [Fail]\n" ); - ret =EXIT_ERR_CODE ; - config.bug_on =1 ; - } +printf ("[FSCK] fixing SIT types\n" ); +if (check_sit_types (sbi) !=0 ) + force =1 ;printf ("[FSCK] other corrupted bugs " );if (config.bug_on ==0 ) {
@@ -1147,7 +1143,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }/* fix global metadata */ -if (config.bug_on && config.fix_on) { +if (force || (config.bug_on && config.fix_on)) {fix_nat_entries (sbi);rewrite_sit_area_bitmap (sbi);fix_checkpoint (sbi);
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet
PATCH 2/3 dump.f2fs: show checkpoint flag
This patch is to show the checkpoint flag.
With this flag, we can guess the last status of the partition. And, this can be used by xfstests.
--- fsck/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fsck/main.c +18 -0
@@ -157,6 +157,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)static void do_dump (struct f2fs_sb_info *sbi) {struct dump_option *opt = (struct dump_option *)config.private; +struct f2fs_checkpoint *ckpt =F2FS_CKPT (sbi); +u32 flag =le32_to_cpu (ckpt->ckpt_flags);fsck_init (sbi);
@@ -172,6 +174,22 @@ static void do_dump(struct f2fs_sb_info *sbi)dump_info_from_blkaddr (sbi, opt->blk_addr); goto cleanup; } + +MSG (0 ,"Info: checkpoint state = %x : " , flag); +if (flag &CP_FSCK_FLAG ) +MSG (0 ,"%s" ," fsck" ); +if (flag &CP_ERROR_FLAG ) +MSG (0 ,"%s" ," error" ); +if (flag &CP_COMPACT_SUM_FLAG ) +MSG (0 ,"%s" ," compacted_summary" ); +if (flag &CP_ORPHAN_PRESENT_FLAG ) +MSG (0 ,"%s" ," orphan_inodes" ); +if (flag &CP_UMOUNT_FLAG ) +MSG (0 ,"%s" ," unmount" ); +else +MSG (0 ,"%s" ," sudden-power-off" ); +MSG (0 ,"\n" ); +dump_node (sbi, opt->nid); cleanup:fsck_free (sbi);
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet
PATCH 3/3 fsck.f2fs: readahead node blocks to speed up
In reply to Jaegeuk KimThis patch adds readahead system call to speed up node block reads.
--- fsck/fsck.c | 34 +++++++++++++++++++++++++++++++++- include/f2fs_fs.h | 1 + lib/libf2fs_io.c | 14 ++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-)
fsck/fsck.c +33 -1
@@ -451,6 +451,19 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, goto check; } +/* readahead node blocks */ +for (idx =0 ; idx <5 ; idx++) { +u32 nid =le32_to_cpu (node_blk->i.i_nid[idx]); + +if (nid !=0 ) { +struct node_info ni; + +get_node_info (sbi, nid, &ni); +if (IS_VALID_BLK_ADDR (sbi, ni.blk_addr)) +dev_reada_block (ni.blk_addr); + } + } +/* 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 ) {
@@ -651,12 +664,31 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt,int dentries =0 ;u32 blk_cnt;u8 *name; -u32 hash_code; +u32 hash_code, ino;u16 name_len;;int ret =0 ;int fixed =0 ;int i; +/* readahead inode blocks */ +for (i =0 ; i < max;) { +if (test_bit (i, bitmap) ==0 ) { + i++; +continue ; + } + ino =le32_to_cpu (dentry[i].ino); + +if (IS_VALID_NID (sbi, ino)) { +struct node_info ni; + +get_node_info (sbi, ino, &ni); +if (IS_VALID_BLK_ADDR (sbi, ni.blk_addr)) +dev_reada_block (ni.blk_addr); + } + name_len =le16_to_cpu (dentry[i].name_len); + i += (name_len +F2FS_SLOT_LEN -1 ) /F2FS_SLOT_LEN ; + } +for (i =0 ; i < max;) {if (test_bit (i, bitmap) ==0 ) { i++;
include/f2fs_fs.h +1 -0
@@ -780,6 +780,7 @@ extern int dev_fill(void *, __u64, size_t);extern int dev_read_block (void *,__u64 );extern int dev_read_blocks (void *,__u64 ,__u32 ); +extern int dev_reada_block (__u64 );extern int dev_read_version (void *,__u64 ,size_t );extern void get_kernel_version (__u8 *);
lib/libf2fs_io.c +14 -0
@@ -46,6 +46,15 @@ int dev_read(void *buf, __u64 offset, size_t len)return 0 ; } +int dev_readahead (__u64 offset,size_t len) +{ +#ifdef POSIX_FADV_WILLNEED +return posix_fadvise (config.fd, offset, len,POSIX_FADV_WILLNEED ); +#else +return 0 ; +#endif +} +int dev_write (void *buf,__u64 offset,size_t len) {if (lseek64 (config.fd, (off64_t )offset,SEEK_SET ) <0 )
@@ -91,6 +100,11 @@ int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks)return dev_read (buf, addr *F2FS_BLKSIZE , nr_blks *F2FS_BLKSIZE ); } +int dev_reada_block (__u64 blk_addr) +{ +return dev_readahead (blk_addr *F2FS_BLKSIZE ,F2FS_BLKSIZE ); +} +void f2fs_finalize_device (struct f2fs_configuration *c) {/*
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet
Re: [PATCH 2/3 v2] dump.f2fs: show checkpoint flag
In reply to Jaegeuk KimChange log from v1:
o add FASTBOOT_FLAG
Quoted 1 line
From
b57708aecf07a7caa8fcce02f65735a11e987154Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Wed, 14 Jan 2015 16:18:15 -0800
Subject: [PATCH] dump.f2fs: show checkpoint flag
This patch is to show the checkpoint flag.
With this flag, we can guess the last status of the partition. And, this can be used by xfstests.
--- fsck/main.c | 20 ++++++++++++++++++++ include/f2fs_fs.h | 1 + 2 files changed, 21 insertions(+)
fsck/main.c +20 -0
@@ -157,6 +157,8 @@ static void do_fsck(struct f2fs_sb_info *sbi)static void do_dump (struct f2fs_sb_info *sbi) {struct dump_option *opt = (struct dump_option *)config.private; +struct f2fs_checkpoint *ckpt =F2FS_CKPT (sbi); +u32 flag =le32_to_cpu (ckpt->ckpt_flags);fsck_init (sbi);
@@ -172,6 +174,24 @@ static void do_dump(struct f2fs_sb_info *sbi)dump_info_from_blkaddr (sbi, opt->blk_addr); goto cleanup; } + +MSG (0 ,"Info: checkpoint state = %x : " , flag); +if (flag &CP_FSCK_FLAG ) +MSG (0 ,"%s" ," fsck" ); +if (flag &CP_ERROR_FLAG ) +MSG (0 ,"%s" ," error" ); +if (flag &CP_COMPACT_SUM_FLAG ) +MSG (0 ,"%s" ," compacted_summary" ); +if (flag &CP_ORPHAN_PRESENT_FLAG ) +MSG (0 ,"%s" ," orphan_inodes" ); +if (flag &CP_FASTBOOT_FLAG ) +MSG (0 ,"%s" ," fastboot" ); +if (flag &CP_UMOUNT_FLAG ) +MSG (0 ,"%s" ," unmount" ); +else +MSG (0 ,"%s" ," sudden-power-off" ); +MSG (0 ,"\n" ); +dump_node (sbi, opt->nid); cleanup:fsck_free (sbi);
include/f2fs_fs.h +1 -0
@@ -358,6 +358,7 @@ struct f2fs_super_block {/* * For checkpoint */ +#define CP_FASTBOOT_FLAG 0x00000020#define CP_FSCK_FLAG 0x00000010#define CP_ERROR_FLAG 0x00000008#define CP_COMPACT_SUM_FLAG 0x00000004
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/