fsck.f2fs: clear qf_ino if quota node is removed
PATCH 1/1 fsck.f2fs: clear qf_ino if quota node is removed
If a quota node is corrupted, it may be removed. Then its qf_ino should also be removed.
--- fsck/fsck.c | 19 +++++++++++++++++-- fsck/fsck.h | 1 + fsck/mount.c | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-)
fsck/fsck.c +17 -2
@@ -1675,8 +1675,13 @@ int fsck_chk_quota_node(struct f2fs_sb_info *sbi) } ret =fsck_chk_node_blk (sbi,NULL , ino,F2FS_FT_REG_FILE ,TYPE_INODE , &blk_cnt,NULL ); -if (ret) -ASSERT_MSG ("[0x%x] wrong orphan inode" , ino); +if (ret) { +/* sanity_check_nid failed, node should be removed */ +ASSERT_MSG ("[0x%x] wrong quota inode" , ino); + sb->qf_ino[qtype] =0 ; +if (c.fix_on) +F2FS_FSCK (sbi)->chk.fix_sb =1 ; + } }return ret; }
@@ -2004,6 +2009,15 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)write_nat_bits (sbi, sb, cp, sbi->cur_cp); } +static void fix_superblock (struct f2fs_sb_info *sbi) +{ +if (!F2FS_FSCK (sbi)->chk.fix_sb) +return ; + +write_superblock (F2FS_RAW_SUPER (sbi)); +F2FS_FSCK (sbi)->chk.fix_sb =0 ; +} +int check_curseg_offset (struct f2fs_sb_info *sbi) {int i;
@@ -2584,6 +2598,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)flush_curseg_sit_entries (sbi); }fix_checkpoint (sbi); +fix_superblock (sbi); }else if (is_set_ckpt_flags (cp,CP_FSCK_FLAG )) {write_checkpoint (sbi); }
fsck/fsck.h +1 -0
@@ -69,6 +69,7 @@ struct f2fs_fsck {u32 multi_hard_link_files;u64 sit_valid_blocks;u32 sit_free_segs; +int fix_sb; } chk;struct hard_link_node *hard_link_list_head;
fsck/mount.c +1 -1
@@ -2165,7 +2165,7 @@ void write_superblock(struct f2fs_super_block *new_sb)ASSERT (ret >=0 ); }free (buf); -DBG (0 ,"Info: Done to rebuild superblock\n" ); +MSG (0 ,"Info: Done to rebuild superblock\n" ); }void build_nat_area_bitmap (struct f2fs_sb_info *sbi)
Signature · 6 lines
2.17.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 2 lines · Sheng Yong
If a quota node is corrupted, it may be removed. Then its
qf_inoshould also be removed.
Yes, I agree that is simplest way by just removing quota sysfiles and trying to rebuild them entirely by rescanning.
Refer to below discussion, could you consider to try to rebuild them directly?
https://patchwork.kernel.org/patch/10189407/
Thanks,
Quoted 70 lines
Signed-off-by Sheng Yong <[email protected]>--- fsck/fsck.c | 19 +++++++++++++++++-- fsck/fsck.h | 1 + fsck/mount.c | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-)fsck/fsck.c +17
-2@@ -1675,8 +1675,13 @@ int fsck_chk_quota_node(struct f2fs_sb_info *sbi) } ret =fsck_chk_node_blk (sbi,NULL , ino,F2FS_FT_REG_FILE ,TYPE_INODE , &blk_cnt,NULL ); -if (ret) -ASSERT_MSG ("[0x%x] wrong orphan inode" , ino); +if (ret) { +/* sanity_check_nid failed, node should be removed */ +ASSERT_MSG ("[0x%x] wrong quota inode" , ino); + sb->qf_ino[qtype] =0 ; +if (c.fix_on) +F2FS_FSCK (sbi)->chk.fix_sb =1 ; + } }return ret; }@@ -2004,6 +2009,15 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)write_nat_bits (sbi, sb, cp, sbi->cur_cp); } +static void fix_superblock (struct f2fs_sb_info *sbi) +{ +if (!F2FS_FSCK (sbi)->chk.fix_sb) +return ; + +write_superblock (F2FS_RAW_SUPER (sbi)); +F2FS_FSCK (sbi)->chk.fix_sb =0 ; +} +int check_curseg_offset (struct f2fs_sb_info *sbi) {int i;@@ -2584,6 +2598,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)flush_curseg_sit_entries (sbi); }fix_checkpoint (sbi); +fix_superblock (sbi); }else if (is_set_ckpt_flags (cp,CP_FSCK_FLAG )) {write_checkpoint (sbi); }fsck/fsck.h +1
-0@@ -69,6 +69,7 @@ struct f2fs_fsck {u32 multi_hard_link_files;u64 sit_valid_blocks;u32 sit_free_segs; +int fix_sb; } chk;struct hard_link_node *hard_link_list_head;fsck/mount.c +0
-0
fsck/mount.c void write_superblock(struct f2fs_super_block *new_sb) · line 2171
Quoted 8 lines
fsck/mount.c +1
-1@@ -2165,7 +2165,7 @@ void write_superblock(struct f2fs_super_block *new_sb)ASSERT (ret >=0 ); }free (buf); -DBG (0 ,"Info: Done to rebuild superblock\n" ); +MSG (0 ,"Info: Done to rebuild superblock\n" ); }void build_nat_area_bitmap (struct f2fs_sb_info *sbi)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot