[PATCH] fsck.f2fs: fix null buffer error with dev_fill

Daeho Jeong posted 1 patch 6 months, 3 weeks ago
fsck/fsck.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
[PATCH] fsck.f2fs: fix null buffer error with dev_fill
Posted by Daeho Jeong 6 months, 3 weeks ago
From: Daeho Jeong <daehojeong@google.com>

Make fsck use dev_fill_block() with zeroed buffer instead of dev_fill().

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

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 893eea7..4d05e1b 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -3526,15 +3526,22 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
 
 	ret = f2fs_finish_zone(wpd->dev_index, blkz);
 	if (ret) {
+		u8 buffer[F2FS_BLKSIZE] = {};
+		u64 blk_addr = wp_block;
 		u64 fill_sects = blk_zone_length(blkz) -
 			(blk_zone_wp_sector(blkz) - blk_zone_sector(blkz));
+		size_t len = fill_sects >> log_sectors_per_block;
 		struct seg_entry *se = get_seg_entry(sbi, wp_segno);
+		enum rw_hint whint = f2fs_io_type_to_rw_hint(se->type);
+
 		printf("[FSCK] Finishing zone failed: %s\n", dev->path);
-		ret = dev_fill(NULL, wp_block * F2FS_BLKSIZE,
-			(fill_sects >> log_sectors_per_block) * F2FS_BLKSIZE,
-			f2fs_io_type_to_rw_hint(se->type));
-		if (ret)
-			printf("[FSCK] Fill up zone failed: %s\n", dev->path);
+		while (len--) {
+			ret = dev_fill_block(buffer, blk_addr++, whint);
+			if (ret) {
+				printf("[FSCK] Fill up zone failed: %s\n", dev->path);
+				break;
+			}
+		}
 	}
 
 	if (!ret)
-- 
2.49.0.1143.g0be31eac6b-goog
Re: [f2fs-dev] [PATCH] fsck.f2fs: fix null buffer error with dev_fill
Posted by Chao Yu 6 months, 3 weeks ago
On 5/22/25 03:41, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> Make fsck use dev_fill_block() with zeroed buffer instead of dev_fill().
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,