linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix error path of __f2fs_build_free_nids
@ 2023-10-13 10:58 Zhiguo Niu
  2023-10-16  7:37 ` Chao Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Zhiguo Niu @ 2023-10-13 10:58 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: zhiguo.niu, niuzhiguo84, linux-kernel, linux-f2fs-devel

SBI_NEED_FSCK should be set for fsck has a chance to
repair in case of scan_nat_page fail in run time.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
 fs/f2fs/node.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index ee2e1dd..d9e6087 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2499,12 +2499,15 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
 				ret = PTR_ERR(page);
 			} else {
 				ret = scan_nat_page(sbi, page, nid);
+				if (ret && !mount) {
+					set_sbi_flag(sbi, SBI_NEED_FSCK);
+					f2fs_err(sbi, "NAT is corrupt, run fsck to fix it");
+				}
 				f2fs_put_page(page, 1);
 			}
 
 			if (ret) {
 				f2fs_up_read(&nm_i->nat_tree_lock);
-				f2fs_err(sbi, "NAT is corrupt, run fsck to fix it");
 				return ret;
 			}
 		}
-- 
1.9.1



_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2023-10-16  9:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 10:58 [f2fs-dev] [PATCH] f2fs: fix error path of __f2fs_build_free_nids Zhiguo Niu
2023-10-16  7:37 ` Chao Yu
2023-10-16  9:02   ` Zhiguo Niu
2023-10-16  9:06     ` Chao Yu
2023-10-16  9:16       ` Zhiguo Niu
2023-10-16  9:17     ` Chao Yu

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).