From 3aefe2d27e599c6b2f9882a8103a1f402cb9f443 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 8 Aug 2024 20:56:48 +0000 Subject: [PATCH] fsck.f2fs: don't finish zones if it's not open Should finish zones if they are open. Reviewed-by: Daeho Jeong Signed-off-by: Jaegeuk Kim --- include/f2fs_fs.h | 2 ++ lib/libf2fs_zoned.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 3f5583d1..15a1c82a 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1742,6 +1742,8 @@ blk_zone_cond_str(struct blk_zone *blkz) * Handle kernel zone capacity support */ #define blk_zone_empty(z) (blk_zone_cond(z) == BLK_ZONE_COND_EMPTY) +#define blk_zone_open(z) (blk_zone_cond(z) == BLK_ZONE_COND_IMP_OPEN || \ + blk_zone_cond(z) == BLK_ZONE_COND_EXP_OPEN) #define blk_zone_sector(z) (z)->start #define blk_zone_length(z) (z)->len #define blk_zone_wp_sector(z) (z)->wp diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c index 221d7d13..89ba5ad7 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -513,7 +513,7 @@ int f2fs_finish_zone(int i, void *blkzone) struct blk_zone_range range; int ret; - if (!blk_zone_seq(blkz) || blk_zone_empty(blkz)) + if (!blk_zone_seq(blkz) || !blk_zone_open(blkz)) return 0; /* Non empty sequential zone: finish */ @@ -522,7 +522,8 @@ int f2fs_finish_zone(int i, void *blkzone) ret = ioctl(dev->fd, BLKFINISHZONE, &range); if (ret != 0) { ret = -errno; - ERR_MSG("ioctl BLKFINISHZONE failed: errno=%d\n", errno); + ERR_MSG("ioctl BLKFINISHZONE failed: errno=%d, status=%s\n", + errno, blk_zone_cond_str(blkz)); } return ret;