mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix to check return value of inc_valid_block_count()
@ 2023-04-05 14:45 Chao Yu
  2023-04-13 23:40 ` [f2fs-dev] " patchwork-bot+f2fs
  0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2023-04-05 14:45 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, Daeho Jeong

In __replace_atomic_write_block(), we missed to check return value
of inc_valid_block_count(), for extreme testcase that f2fs image is
run out of space, it may cause inconsistent status in between SIT
table and total valid block count.

Cc: Daeho Jeong <daehojeong@google.com>
Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/segment.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index fc0734e4fb92..17203e8b865a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -246,10 +246,16 @@ static int __replace_atomic_write_block(struct inode *inode, pgoff_t index,
 	} else {
 		blkcnt_t count = 1;
 
+		err = inc_valid_block_count(sbi, inode, &count);
+		if (err) {
+			f2fs_put_dnode(&dn);
+			return err;
+		}
+
 		*old_addr = dn.data_blkaddr;
 		f2fs_truncate_data_blocks_range(&dn, 1);
 		dec_valid_block_count(sbi, F2FS_I(inode)->cow_inode, count);
-		inc_valid_block_count(sbi, inode, &count);
+
 		f2fs_replace_block(sbi, &dn, dn.data_blkaddr, new_addr,
 					ni.version, true, false);
 	}
-- 
2.36.1


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

* Re: [f2fs-dev] [PATCH] f2fs: fix to check return value of inc_valid_block_count()
  2023-04-05 14:45 [PATCH] f2fs: fix to check return value of inc_valid_block_count() Chao Yu
@ 2023-04-13 23:40 ` patchwork-bot+f2fs
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+f2fs @ 2023-04-13 23:40 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, daehojeong, linux-kernel, linux-f2fs-devel

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Wed,  5 Apr 2023 22:45:36 +0800 you wrote:
> In __replace_atomic_write_block(), we missed to check return value
> of inc_valid_block_count(), for extreme testcase that f2fs image is
> run out of space, it may cause inconsistent status in between SIT
> table and total valid block count.
> 
> Cc: Daeho Jeong <daehojeong@google.com>
> Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
> Signed-off-by: Chao Yu <chao@kernel.org>
> 
> [...]

Here is the summary with links:
  - [f2fs-dev] f2fs: fix to check return value of inc_valid_block_count()
    https://git.kernel.org/jaegeuk/f2fs/c/935fc6fa6466

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-04-13 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05 14:45 [PATCH] f2fs: fix to check return value of inc_valid_block_count() Chao Yu
2023-04-13 23:40 ` [f2fs-dev] " patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®