Skip to contentSkip to conversation

fsck.f2fs: don't call dev_fill w/ null buffer

PATCH In review Jaegeuk Kim 3 participants 5 messages Aug 8, 2024 – Aug 14, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsck.f2fs: don't call dev_fill w/ null buffer

It'll crach fsck.f2fs. Even, let's keep the write pointers and just finish it.

---
 fsck/fsck.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
fsck/fsck.c +8 -12
index a18bee9d0c3b..5fe8ad4ef327 100644
@@ -3299,8 +3299,9 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
 					"segment 0x%x", zone_segno);
 				ret = f2fs_reset_zone(wpd->dev_index, blkz);
 				if (ret) {
-					printf("[FSCK] Write pointer reset "
-					       "failed: %s\n", dev->path);
+					ASSERT_MSG("Write pointer reset "
+					       "failed: %s, err=%d\n",
+					       dev->path, ret);
 					return ret;
 				}
 				fsck->chk.wp_fixed = 1;
@@ -3326,18 +3327,13 @@ 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) {
-		u64 fill_sects = blk_zone_length(blkz) -
-			(blk_zone_wp_sector(blkz) - blk_zone_sector(blkz));
-		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);
-		if (ret)
-			printf("[FSCK] Fill up zone failed: %s\n", dev->path);
+		ASSERT_MSG("Finishing zone failed: %s, err=%d\n",
+			dev->path, ret);
+		return ret;
 	}
 
-	if (!ret)
-		fsck->chk.wp_fixed = 1;
-	return ret;
+	fsck->chk.wp_fixed = 1;
+	return 0;
 }
 
 static void fix_wp_sit_alignment(struct f2fs_sb_info *sbi)
Signature · 8 lines
2.46.0.76.ge559c4bf1a-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 25 lines · Jaegeuk Kim

It'll crach fsck.f2fs. Even, let's keep the write pointers and just finish it.

---
 fsck/fsck.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
fsck/fsck.c +3 -2
index a18bee9d0c3b..5fe8ad4ef327 100644
@@ -3299,8 +3299,9 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
                                        "segment 0x%x", zone_segno);
                                ret = f2fs_reset_zone(wpd->dev_index, blkz);
                                if (ret) {
-                                       printf("[FSCK] Write pointer reset "
-                                              "failed: %s\n", dev->path);
+                                       ASSERT_MSG("Write pointer reset "
+                                              "failed: %s, err=%d\n",
+                                              dev->path, ret);
                                        return ret;
                                }
                                fsck->chk.wp_fixed = 1;

fsck/fsck.c static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque) · line 3333

Quoted 8 lines
fsck/fsck.c +0 -5
@@ -3326,18 +3327,13 @@ 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) {
-               u64 fill_sects = blk_zone_length(blkz) -
-                       (blk_zone_wp_sector(blkz) - blk_zone_sector(blkz));
-               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);

This was for zoned devices that don't support the FINISH command. If NULL buf is the problem, how about using zero value filled buffer?

Quoted 20 lines
fsck/fsck.c +5 -6
-               if (ret)
-                       printf("[FSCK] Fill up zone failed: %s\n", dev->path);
+               ASSERT_MSG("Finishing zone failed: %s, err=%d\n",
+                       dev->path, ret);
+               return ret;
        }
 
-       if (!ret)
-               fsck->chk.wp_fixed = 1;
-       return ret;
+       fsck->chk.wp_fixed = 1;
+       return 0;
 }
 
 static void fix_wp_sit_alignment(struct f2fs_sb_info *sbi)
--

2.46.0.76.ge559c4bf1a-goog

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw
Quoted 27 lines · Daeho Jeong
Quoted 26 lines · Jaegeuk Kim

It'll crach fsck.f2fs. Even, let's keep the write pointers and just finish it.

---
 fsck/fsck.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
fsck/fsck.c +3 -2
index a18bee9d0c3b..5fe8ad4ef327 100644
@@ -3299,8 +3299,9 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
                                        "segment 0x%x", zone_segno);
                                ret = f2fs_reset_zone(wpd->dev_index, blkz);
                                if (ret) {
-                                       printf("[FSCK] Write pointer reset "
-                                              "failed: %s\n", dev->path);
+                                       ASSERT_MSG("Write pointer reset "
+                                              "failed: %s, err=%d\n",
+                                              dev->path, ret);
                                        return ret;
                                }
                                fsck->chk.wp_fixed = 1;
@@ -3326,18 +3327,13 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
 
Quoted 10 lines

fsck/fsck.c static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque) · line 3333

Quoted 7 lines
fsck/fsck.c +0 -5
        ret = f2fs_finish_zone(wpd->dev_index, blkz);
        if (ret) {
-               u64 fill_sects = blk_zone_length(blkz) -
-                       (blk_zone_wp_sector(blkz) - blk_zone_sector(blkz));
-               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);

This was for zoned devices that don't support the FINISH command. If NULL buf is the problem, how about using zero value filled buffer?

Do we really need to fill them, if it'll be reset later before use?

Quoted 21 lines
Quoted 21 lines
fsck/fsck.c +5 -6
-               if (ret)
-                       printf("[FSCK] Fill up zone failed: %s\n", dev->path);
+               ASSERT_MSG("Finishing zone failed: %s, err=%d\n",
+                       dev->path, ret);
+               return ret;
        }
 
-       if (!ret)
-               fsck->chk.wp_fixed = 1;
-       return ret;
+       fsck->chk.wp_fixed = 1;
+       return 0;
 }
 
 static void fix_wp_sit_alignment(struct f2fs_sb_info *sbi)
--

2.46.0.76.ge559c4bf1a-goog

Quoted 4 lines
Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
Quoted 40 lines · Jaegeuk Kim
Quoted 27 lines · Daeho Jeong
Quoted 26 lines · Jaegeuk Kim

It'll crach fsck.f2fs. Even, let's keep the write pointers and just finish it.

---
 fsck/fsck.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
fsck/fsck.c +3 -2
index a18bee9d0c3b..5fe8ad4ef327 100644
@@ -3299,8 +3299,9 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
                                        "segment 0x%x", zone_segno);
                                ret = f2fs_reset_zone(wpd->dev_index, blkz);
                                if (ret) {
-                                       printf("[FSCK] Write pointer reset "
-                                              "failed: %s\n", dev->path);
+                                       ASSERT_MSG("Write pointer reset "
+                                              "failed: %s, err=%d\n",
+                                              dev->path, ret);
                                        return ret;
                                }
                                fsck->chk.wp_fixed = 1;
@@ -3326,18 +3327,13 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque)
 
Quoted 10 lines

fsck/fsck.c static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque) · line 3333

Quoted 7 lines
fsck/fsck.c +0 -5
        ret = f2fs_finish_zone(wpd->dev_index, blkz);
        if (ret) {
-               u64 fill_sects = blk_zone_length(blkz) -
-                       (blk_zone_wp_sector(blkz) - blk_zone_sector(blkz));
-               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);

This was for zoned devices that don't support the FINISH command. If NULL buf is the problem, how about using zero value filled buffer?

Quoted 1 line

Do we really need to fill them, if it'll be reset later before use?

That's for devices not supporting the FINISH command. Let me make another patch for it.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
fsck/fsck.c +5 -6
-               if (ret)
-                       printf("[FSCK] Fill up zone failed: %s\n", dev->path);
+               ASSERT_MSG("Finishing zone failed: %s, err=%d\n",
+                       dev->path, ret);
+               return ret;
        }
 
-       if (!ret)
-               fsck->chk.wp_fixed = 1;
-       return ret;
+       fsck->chk.wp_fixed = 1;
+       return 0;
 }
 
 static void fix_wp_sit_alignment(struct f2fs_sb_info *sbi)
--

2.46.0.76.ge559c4bf1a-goog

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel