Skip to contentSkip to conversation

fsck.f2fs: do not repair quota file in dry-run mode

PATCH New Chao Yu via Linux-f2fs-devel 1 participant 1 message Aug 31

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsck.f2fs: do not repair quota file in dry-run mode

From: Chao Yu <[email protected]>

Info: Dry run
Info: MKFS version
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: checkpoint stop reason: shutdown(16)
Info: Device[0] : /dev/vdd blkaddr = 0--ffffff
Info: Device[1] : /dev/vdb blkaddr = 1000000--11fffff
Info: Device[2] : /dev/vdc blkaddr = 1200000--14fffff
Info: Host-managed zoned block device:
32 zones, 134217728u zone size(bytes), 0 randomly writeable zones 32768 blocks per zone
Info: Device[3] : /dev/nullb0 blkaddr = 1500000--15fffff
Info: Segments per section = 64
Info: Sections per zone = 1
Info: total FS sectors = 184549376 (90112 MB)
Info: CKPT version = 25fc6ba
Info: Casefold: linear_lookup [enable]
Info: checkpoint state = 844 : quota_need_fsck crc compacted_summary sudden-power-off

[FIX] (move_one_curseg_info:3235)  --> Move curseg[0] 4f7 -> 12c0 after 28000
[FIX] (move_one_curseg_info:3235)  --> Move curseg[1] 1284 -> 1300 after 28000
[FIX] (move_one_curseg_info:3235)  --> Move curseg[2] b2 -> 1340 after 28000
[FIX] (move_one_curseg_info:3235)  --> Move curseg[3] ed -> 1380 after 28000
[FIX] (move_one_curseg_info:3235)  --> Move curseg[4] cf7 -> 13c0 after 28000
[FIX] (move_one_curseg_info:3235)  --> Move curseg[5] 140 -> 1400 after 28000
[ASSERT] (is_valid_ssa_node_blk: 197)  --> Summary footer indicates a node segment: 0xcf7
[ASSERT] (is_valid_ssa_node_blk: 224)  --> Set node summary 0xcf7 -> [0x4] [0x1c6ec5]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x0]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x1]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x2]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x5]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x29]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x34]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x46]
[ASSERT] (is_valid_ssa_data_blk: 359)  --> Set data summary 0x4f7 -> [0x4] [0x0] [0x9e]

In dry-run mode, physical disk writes are skipped by dev_write(). If fsck_chk_quota_files() attempts to rebuild quota files, subsequent reads on newly allocated blocks will fetch stale, unwritten disk data, triggering assertion failures or false corruptions.

Skip updating quota files when dry-run mode is enabled, and report inconsistent quota files as informational messages without flagging unrepairable filesystem corruptions.

---
 fsck/fsck.c  | 7 +++++--
 fsck/mount.c | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
fsck/fsck.c +5 -2
index 6872b00..e47f7be 100644
@@ -2411,7 +2411,7 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)
 		}
 
 		/* Something is wrong */
-		if (c.fix_on) {
+		if (c.fix_on && !c.dry_run) {
 			DBG(0, "Fixing Quota file ([%3d] ino [0x%x])\n",
 							qtype, ino);
 			fsck_disconnect_file(sbi, ino, true);
@@ -2424,6 +2424,9 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)
 			} else {
 				ASSERT_MSG("Unable to write quota file");
 			}
+		} else if (c.dry_run) {
+			MSG(0, "Info: Quota file is inconsistent (dry-run, repair skipped)\n");
+			ret = 0;
 		} else {
 			ASSERT_MSG("Quota file is missing or invalid"
 					" quota file content found.");
@@ -3709,7 +3712,7 @@ void fsck_chk_and_fix_write_pointers(struct f2fs_sb_info *sbi)
 	if (c.zoned_model != F2FS_ZONED_HM)
 		return;
 
-	if (c.fix_on) {
+	if (c.fix_on && !c.dry_run) {
 		flush_nat_journal_entries(sbi);
 		flush_sit_journal_entries(sbi);
 
fsck/mount.c +1 -1
index 26f213e..a202f3d 100644
@@ -4222,7 +4222,7 @@ out:
 	print_ckpt_info(sbi);
 
 	if (c.quota_fix) {
-		if (get_cp(ckpt_flags) & CP_QUOTA_NEED_FSCK_FLAG)
+		if ((get_cp(ckpt_flags) & CP_QUOTA_NEED_FSCK_FLAG) && !c.dry_run)
 			c.fix_on = 1;
 	}
 	if (c.layout)
Signature · 8 lines
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel