Skip to contentSkip to conversation

fsck.f2fs: enable fix_on when CP_RESIZEFS_FLAG is set in auto-fix mode

PATCH In review Daeho Jeong 2 participants 3 messages Oct 1 – Oct 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsck.f2fs: enable fix_on when CP_RESIZEFS_FLAG is set in auto-fix mode

From: Daeho Jeong <[email protected]>

Commit 9a31cefa2966 ("fsck.f2fs: allow fsck to fix issues with online resize due to SPO") added logic in sanity_check_ckpt() to recalculate and fix user_block_count when CP_RESIZEFS_FLAG is set after a sudden power-off during online resize.

However, sanity_check_ckpt() calls f2fs_should_proceed() and checks c.fix_on before repairing user_block_count, while f2fs_should_proceed() did not check CP_RESIZEFS_FLAG when setting c.fix_on in auto_fix (-a) or preen (-p) mode. As a result, running 'fsck.f2fs -a' after an SPO during online shrink leaves c.fix_on unset and fails to repair the checkpoint.

Check CP_RESIZEFS_FLAG in f2fs_should_proceed() so that auto-fix and preen modes properly enable c.fix_on and recover the filesystem.

Fixes 9a31cefa2966 ("fsck.f2fs: allow fsck to fix issues with online resize due to SPO")
---
 fsck/mount.c | 1 +
 1 file changed, 1 insertion(+)
fsck/mount.c +1 -0
index 2fd8e1c..8479ed1 100644
@@ -1515,6 +1515,7 @@ static int f2fs_should_proceed(struct f2fs_super_block *sb, u32 flag)
 	if (!c.fix_on && (c.auto_fix || c.preen_mode)) {
 		if (flag & CP_FSCK_FLAG ||
 			flag & CP_DISABLED_FLAG ||
+			flag & CP_RESIZEFS_FLAG ||
 			flag & CP_QUOTA_NEED_FSCK_FLAG ||
 			c.invalid_sb & SB_NEED_FIX ||
 			(exist_qf_ino(sb) && (flag & CP_ERROR_FLAG))) {
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
#1 lore raw
Quoted 28 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

Commit 9a31cefa2966 ("fsck.f2fs: allow fsck to fix issues with online resize due to SPO") added logic in sanity_check_ckpt() to recalculate and fix user_block_count when CP_RESIZEFS_FLAG is set after a sudden power-off during online resize.

However, sanity_check_ckpt() calls f2fs_should_proceed() and checks c.fix_on before repairing user_block_count, while f2fs_should_proceed() did not check CP_RESIZEFS_FLAG when setting c.fix_on in auto_fix (-a) or preen (-p) mode. As a result, running 'fsck.f2fs -a' after an SPO during online shrink leaves c.fix_on unset and fails to repair the checkpoint.

Check CP_RESIZEFS_FLAG in f2fs_should_proceed() so that auto-fix and preen modes properly enable c.fix_on and recover the filesystem.

Fixes 9a31cefa2966 ("fsck.f2fs: allow fsck to fix issues with online resize due to SPO")
---
 fsck/mount.c | 1 +
 1 file changed, 1 insertion(+)
fsck/mount.c +0 -0
index 2fd8e1c..8479ed1 100644

fsck/mount.c static int f2fs_should_proceed(struct f2fs_super_block *sb, u32 flag)

Quoted 8 lines
fsck/mount.c +1 -1
@@ -1515,6 +1515,7 @@ static int f2fs_should_proceed(struct f2fs_super_block *sb, u32 flag)
        if (!c.fix_on && (c.auto_fix || c.preen_mode)) {
                if (flag & CP_FSCK_FLAG ||
                        flag & CP_DISABLED_FLAG ||
+                       flag & CP_RESIZEFS_FLAG ||
                        flag & CP_QUOTA_NEED_FSCK_FLAG ||
                        c.invalid_sb & SB_NEED_FIX ||
                        (exist_qf_ino(sb) && (flag & CP_ERROR_FLAG))) {
--

Kindly ping this.

Thanks,

Quoted 2 lines

2.56.0.rc1.315.gc6ed9934b7-goog

Reviewed-by on v1 1/1
#2 lore raw
In reply to Daeho Jeong
Quoted 13 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

Commit 9a31cefa2966 ("fsck.f2fs: allow fsck to fix issues with online resize due to SPO") added logic in sanity_check_ckpt() to recalculate and fix user_block_count when CP_RESIZEFS_FLAG is set after a sudden power-off during online resize.

However, sanity_check_ckpt() calls f2fs_should_proceed() and checks c.fix_on before repairing user_block_count, while f2fs_should_proceed() did not check CP_RESIZEFS_FLAG when setting c.fix_on in auto_fix (-a) or preen (-p) mode. As a result, running 'fsck.f2fs -a' after an SPO during online shrink leaves c.fix_on unset and fails to repair the checkpoint.

Quoted 5 lines

Check CP_RESIZEFS_FLAG in f2fs_should_proceed() so that auto-fix and preen modes properly enable c.fix_on and recover the filesystem.

Fixes 9a31cefa2966 ("fsck.f2fs: allow fsck to fix issues with online resize due to SPO")

Thanks,