diff options
author | Daeho Jeong <daehojeong@google.com> | 2024-03-08 10:16:46 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2024-03-11 13:37:43 -0700 |
commit | f611eac6d99cf766ffde76ecac3463774266a4ef (patch) | |
tree | eb26b5fc2003c7bad485fdfe9997faf6f33ee461 | |
parent | 151fdb1aa090894eaa3dcef3194f7aaaeafb94cb (diff) | |
download | f2fs-tools-f611eac6d99cf766ffde76ecac3463774266a4ef.tar.gz |
f2fs-tools: reset only current zones
Send reset commands to only current zones and finish the others.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/fsck.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index a42b597..5d345d0 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -3288,38 +3288,39 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), void *blkzone, void *opaque) last_valid_blkoff = last_vblk_off_in_zone(sbi, zone_segno); - /* - * When there is no valid block in the zone, check write pointer is - * at zone start. If not, reset the write pointer. - */ - if (last_valid_blkoff < 0 && - blk_zone_wp_sector(blkz) != blk_zone_sector(blkz)) { - if (!c.fix_on) { - MSG(0, "Inconsistent write pointer: wp[0x%x,0x%x]\n", - wp_segno, wp_blkoff); - fsck->chk.wp_inconsistent_zones++; - return 0; - } - - FIX_MSG("Reset write pointer of zone at 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); - return ret; - } - fsck->chk.wp_fixed = 1; - return 0; - } - /* if a curseg points to the zone, do not finishing zone */ for (i = 0; i < NO_CHECK_TYPE; i++) { struct curseg_info *cs = CURSEG_I(sbi, i); if (zone_segno <= cs->segno && - cs->segno < zone_segno + segs_per_zone) + cs->segno < zone_segno + segs_per_zone) { + /* + * When there is no valid block in the zone, check + * write pointer is at zone start. If not, reset + * the write pointer. + */ + if (last_valid_blkoff < 0 && + blk_zone_wp_sector(blkz) != blk_zone_sector(blkz)) { + if (!c.fix_on) { + MSG(0, "Inconsistent write pointer: " + "wp[0x%x,0x%x]\n", + wp_segno, wp_blkoff); + fsck->chk.wp_inconsistent_zones++; + return 0; + } + + FIX_MSG("Reset write pointer of zone at " + "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); + return ret; + } + fsck->chk.wp_fixed = 1; + } return 0; + } } /* |