zbd: introduce zbd_move_zone_wp()
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 25 Apr 2025 05:21:44 +0000 (14:21 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 May 2025 11:28:47 +0000 (05:28 -0600)
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 <shinichiro.kawasaki@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20250425052148.126788-5-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
zbd.c

diff --git a/zbd.c b/zbd.c
index 895192342cc2443f55560be4e783091eb93c82d5..617705752b881b29cab7a1a23e2503c8524ce102 100644 (file)
--- 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