linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] f2fs-tools: remove false failure alarm when fixing quota
@ 2021-10-27 23:46 Daeho Jeong
  2021-10-27 23:46 ` [f2fs-dev] [PATCH 2/2] f2fs-tools: separate other bugs in fsck_verify Daeho Jeong
  0 siblings, 1 reply; 2+ messages in thread
From: Daeho Jeong @ 2021-10-27 23:46 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

Even though fsck fixed quota issues, fsck returns failure status and
makes the user code misunderstand like errors are still there.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fsck/fsck.c       | 6 ++++--
 include/f2fs_fs.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 110c1ec..bc11e07 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -2025,7 +2025,7 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)
 			f2fs_filesize_update(sbi, ino, 0);
 			ret = quota_write_inode(sbi, qtype);
 			if (!ret) {
-				c.bug_on = 1;
+				c.quota_fixed = true;
 				DBG(1, "OK\n");
 			} else {
 				ASSERT_MSG("Unable to write quota file");
@@ -2197,6 +2197,8 @@ void fsck_init(struct f2fs_sb_info *sbi)
 	ASSERT(fsck->dentry != NULL);
 	memcpy(fsck->dentry->name, "/", 1);
 	fsck->dentry_end = fsck->dentry;
+
+	c.quota_fixed = false;
 }
 
 static void fix_hard_links(struct f2fs_sb_info *sbi)
@@ -3330,7 +3332,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 	if (force || (c.fix_on && f2fs_dev_is_writable())) {
 		struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
 
-		if (force || c.bug_on || c.bug_nat_bits) {
+		if (force || c.bug_on || c.bug_nat_bits || c.quota_fixed) {
 			/* flush nats to write_nit_bits below */
 			flush_journal_entries(sbi);
 			fix_hard_links(sbi);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 69260a6..9f918ba 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -491,6 +491,7 @@ struct f2fs_configuration {
 	int defset;
 	int bug_on;
 	int bug_nat_bits;
+	bool quota_fixed;
 	int alloc_failed;
 	int auto_fix;
 	int layout;
-- 
2.33.0.1079.g6e70778dc9-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [f2fs-dev] [PATCH 2/2] f2fs-tools: separate other bugs in fsck_verify
  2021-10-27 23:46 [f2fs-dev] [PATCH 1/2] f2fs-tools: remove false failure alarm when fixing quota Daeho Jeong
@ 2021-10-27 23:46 ` Daeho Jeong
  0 siblings, 0 replies; 2+ messages in thread
From: Daeho Jeong @ 2021-10-27 23:46 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

When we check other corrupted bugs in fsck, we use bug_on. So, if major
bugs are already detected in fsck_verify(), fsck will false alarm that
there are other bugs, even if there are no other bugs. So, let's fix this.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fsck/fsck.c | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index bc11e07..0619519 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -3162,6 +3162,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 	u32 nr_unref_nid = 0;
 	struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
 	struct hard_link_node *node = NULL;
+	bool verify_failed = false;
 
 	if (c.show_file_map)
 		return 0;
@@ -3175,7 +3176,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		} else {
 			printf(" [Fail] [0x%x]\n",
 			       fsck->chk.wp_inconsistent_zones);
-			c.bug_on = 1;
+			verify_failed = true;
 		}
 
 		if (fsck->chk.wp_fixed && c.fix_on)
@@ -3221,8 +3222,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", nr_unref_nid);
 	} else {
 		printf(" [Fail] [0x%x]\n", nr_unref_nid);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] SIT valid block bitmap checking                ");
@@ -3231,8 +3231,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf("[Ok..]\n");
 	} else {
 		printf("[Fail]\n");
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] Hard link checking for regular file           ");
@@ -3240,8 +3239,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", fsck->chk.multi_hard_link_files);
 	} else {
 		printf(" [Fail] [0x%x]\n", fsck->chk.multi_hard_link_files);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] valid_block_count matching with CP            ");
@@ -3249,8 +3247,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", (u32)fsck->chk.valid_blk_cnt);
 	} else {
 		printf(" [Fail] [0x%x]\n", (u32)fsck->chk.valid_blk_cnt);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] valid_node_count matching with CP (de lookup) ");
@@ -3258,8 +3255,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", fsck->chk.valid_node_cnt);
 	} else {
 		printf(" [Fail] [0x%x]\n", fsck->chk.valid_node_cnt);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] valid_node_count matching with CP (nat lookup)");
@@ -3267,8 +3263,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", fsck->chk.valid_nat_entry_cnt);
 	} else {
 		printf(" [Fail] [0x%x]\n", fsck->chk.valid_nat_entry_cnt);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] valid_inode_count matched with CP             ");
@@ -3276,8 +3271,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", fsck->chk.valid_inode_cnt);
 	} else {
 		printf(" [Fail] [0x%x]\n", fsck->chk.valid_inode_cnt);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] free segment_count matched with CP            ");
@@ -3286,8 +3280,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..] [0x%x]\n", fsck->chk.sit_free_segs);
 	} else {
 		printf(" [Fail] [0x%x]\n", fsck->chk.sit_free_segs);
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] next block offset is free                     ");
@@ -3295,8 +3288,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		printf(" [Ok..]\n");
 	} else {
 		printf(" [Fail]\n");
-		ret = EXIT_ERR_CODE;
-		c.bug_on = 1;
+		verify_failed = true;
 	}
 
 	printf("[FSCK] fixing SIT types\n");
@@ -3311,6 +3303,11 @@ int fsck_verify(struct f2fs_sb_info *sbi)
 		ret = EXIT_ERR_CODE;
 	}
 
+	if (verify_failed) {
+		ret = EXIT_ERR_CODE;
+		c.bug_on = 1;
+	}
+
 #ifndef WITH_ANDROID
 	if (nr_unref_nid && !c.ro) {
 		char ans[255] = {0};
-- 
2.33.0.1079.g6e70778dc9-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-28  0:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 23:46 [f2fs-dev] [PATCH 1/2] f2fs-tools: remove false failure alarm when fixing quota Daeho Jeong
2021-10-27 23:46 ` [f2fs-dev] [PATCH 2/2] f2fs-tools: separate other bugs in fsck_verify Daeho Jeong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).