To prepare for write pointer consistency fix by fsck, add f2fs_reset_zone() helper function which calls RESET ZONE command. The function is added to lib/libf2fs_zoned which gathers zoned block device related functions.
When f2fs-tools are built without blkzoned.h kernel header, the helper function f2fs_reset_zone() prints an error message as other helper functions in lib/libf2fs_zoned print. To make the message consistent through the all helper functions, modify message strings in f2fs_check_zones() and f2fs_reset_zones(). Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]> --- include/f2fs_fs.h | 1 + lib/libf2fs_zoned.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index d6ea688..9c26314 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1323,6 +1323,7 @@ extern int f2fs_report_zone(int, u_int64_t, void *); typedef int (report_zones_cb_t)(int i, void *, void *); extern int f2fs_report_zones(int, report_zones_cb_t *, void *); extern int f2fs_check_zones(int); +int f2fs_reset_zone(int, void *); extern int f2fs_reset_zones(int); #define SIZE_ALIGN(val, size) ((val) + (size) - 1) / (size) diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c index 5328c56..8b88fe9 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -388,6 +388,28 @@ out: return ret; } +int f2fs_reset_zone(int i, void *blkzone) +{ + struct blk_zone *blkz = (struct blk_zone *)blkzone; + struct device_info *dev = c.devices + i; + struct blk_zone_range range; + int ret; + + if (!blk_zone_seq(blkz) || blk_zone_empty(blkz)) + return 0; + + /* Non empty sequential zone: reset */ + range.sector = blk_zone_sector(blkz); + range.nr_sectors = blk_zone_length(blkz); + ret = ioctl(dev->fd, BLKRESETZONE, &range); + if (ret != 0) { + ret = -errno; + ERR_MSG("ioctl BLKRESETZONE failed: errno=%d\n", errno); + } + + return ret; +} + int f2fs_reset_zones(int j) { struct device_info *dev = c.devices + j; @@ -487,13 +509,19 @@ int f2fs_get_zone_blocks(int i) int f2fs_check_zones(int i) { - ERR_MSG("%d: Zoned block devices are not supported\n", i); + ERR_MSG("%d: Unsupported zoned block device\n", i); + return -1; +} + +int f2fs_reset_zone(int i, void *blkzone) +{ + ERR_MSG("%d: Unsupported zoned block device\n", i); return -1; } int f2fs_reset_zones(int i) { - ERR_MSG("%d: Zoned block devices are not supported\n", i); + ERR_MSG("%d: Unsupported zoned block device\n", i); return -1; } -- 2.23.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
