From 143aaff963694ee3745c204f414e1e27a759a7df Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Fri, 25 Apr 2025 14:21:44 +0900 Subject: [PATCH] zbd: introduce zbd_move_zone_wp() As a preparation for continue_on_error option support for zonemode=zbd, introduce the function zbd_move_zone_wp(). It moves write pointers by calling blkzoned_move_zone_wp() or move_zone_wp() callback of IO engines. Signed-off-by: Shin'ichiro Kawasaki Reviewed-by: Damien Le Moal Link: https://lore.kernel.org/r/20250425052148.126788-5-shinichiro.kawasaki@wdc.com Signed-off-by: Jens Axboe --- zbd.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/zbd.c b/zbd.c index 89519234..61770575 100644 --- a/zbd.c +++ b/zbd.c @@ -442,6 +442,46 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f, return res; } +/** + * zbd_move_zone_wp - move the write pointer of a zone by writing the data in + * the specified buffer + * @td: FIO thread data. + * @f: FIO file for which to move write pointer + * @z: Target zone to move the write pointer + * @length: Length of the move + * @buf: Buffer which holds the data to write + * + * Move the write pointer at the specified offset by writing the data + * in the specified buffer. + * Returns 0 upon success and a negative error code upon failure. + */ +static int zbd_move_zone_wp(struct thread_data *td, struct fio_file *f, + struct zbd_zone *z, uint64_t length, + const char *buf) +{ + int ret = 0; + + switch (f->zbd_info->model) { + case ZBD_HOST_AWARE: + case ZBD_HOST_MANAGED: + if (td->io_ops && td->io_ops->move_zone_wp) + ret = td->io_ops->move_zone_wp(td, f, z, length, buf); + else + ret = blkzoned_move_zone_wp(td, f, z, length, buf); + break; + default: + break; + } + + if (ret < 0) { + td_verror(td, errno, "move wp failed"); + log_err("%s: moving wp for %"PRIu64" sectors at sector %"PRIu64" failed (%d).\n", + f->file_name, length >> 9, z->wp >> 9, errno); + } + + return ret; +} + /** * zbd_get_max_open_zones - Get the maximum number of open zones * @td: FIO thread data -- 2.25.1