To allow fsck to reset a zone with inconsistent write pointer, introduce a helper function f2fs_reset_zone().
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawas...@wdc.com> --- include/f2fs_fs.h | 1 + lib/libf2fs_zoned.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index abadd1b..34679d8 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1282,6 +1282,7 @@ extern int f2fs_get_zone_blocks(int); typedef int (report_zones_cb_t)(int i, struct blk_zone *blkz, void *opaque); extern int f2fs_report_zones(int, report_zones_cb_t *, void *); extern int f2fs_check_zones(int); +int f2fs_reset_zone(struct device_info *dev, struct blk_zone *blkz); 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 fc4974f..f56fa62 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -359,6 +359,24 @@ out: return ret; } +int f2fs_reset_zone(struct device_info *dev, struct blk_zone *blkz) +{ + 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) + ERR_MSG("ioctl BLKRESETZONE failed\n"); + + return ret; +} + int f2fs_reset_zones(int j) { struct device_info *dev = c.devices + j; @@ -456,6 +474,12 @@ int f2fs_check_zones(int i) return -1; } +int f2fs_reset_zone(struct device_info *dev, struct blk_zone *blkz) +{ + ERR_MSG("%d: Zoned block devices are not supported\n", i); + return -1; +} + int f2fs_reset_zones(int i) { ERR_MSG("%d: Zoned block devices are not supported\n", i); -- 2.21.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel