mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 10:10:00 +00:00
libf2fs_zoned: Introduce f2fs_reset_zone() helper function
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 <shinichiro.kawasaki@wdc.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
6d7c7b785f
commit
1d145cb86b
@ -1303,6 +1303,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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user