f2fs: set SBI_NEED_FSCK flag when inconsistent node block found
authorWeichao Guo <guoweichao@oppo.com>
Sat, 18 Sep 2021 12:46:36 +0000 (20:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:19:08 +0000 (09:19 +0100)
[ Upstream commit 6663b138ded1a59e630c9e605e42aa7fde490cdc ]

Inconsistent node block will cause a file fail to open or read,
which could make the user process crashes or stucks. Let's mark
SBI_NEED_FSCK flag to trigger a fix at next fsck time. After
unlinking the corrupted file, the user process could regenerate
a new one and work correctly.

Signed-off-by: Weichao Guo <guoweichao@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/node.c

index 597a145c08ef5155de88a736cc28503b67ec9b13..7e625806bd4a2f33b383579487fa37f7a7bfef7f 100644 (file)
@@ -1389,6 +1389,7 @@ page_hit:
                          nid, nid_of_node(page), ino_of_node(page),
                          ofs_of_node(page), cpver_of_node(page),
                          next_blkaddr_of_node(page));
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
                err = -EINVAL;
 out_err:
                ClearPageUptodate(page);