path: root/io_u.c
diff options
authorBart Van Assche <>2018-08-24 11:31:27 -0700
committerJens Axboe <>2018-08-24 12:54:36 -0600
commitbfbdd35b3e8f7de1bf1f48e7087c04a6b37e9c61 (patch)
tree60f60a55b46990c3d6167fa93f897c6e2614b43d /io_u.c
parentbd6b959a034cdcfcef010e56b139c609f56b83cf (diff)
Add support for zoned block devices
This patch adds support for zoned block devices as follows: - After the file size has been determined, check whether the file name refers to a block device. If so, check whether that block device is a host-managed block device. If that is the case, read the zone information using the BLKREPORTZONE ioctl. That ioctl is supported by the Linux kernel since kernel version v4.10. - After all command-line options have been processed and all job files have been read, verify whether these refer to a zoned block device and also whether the specified options are compatible with a zoned block device. Complain if that is not the case. - After each get_next_block() call, verify whether the block is appropriate for a zoned block device. When writing data to a sequential zone, adjust the write offset to the zone write pointer. When reading from a sequential zone, avoid reading past the write pointer. - After I/O submission, update the variable that represents the write pointer. - When writing data and with data verification enabled, reset a zone before writing any data into a zone. Otherwise reset a zone before issuing a write if that zone is full. - Translate trim into zone resets. Zoned block devices namely do not have to support any of the SCSI commands that are used by the kernel to implement the discard ioctl (UNMAP / WRITE SAME). This work started from a patch from Masato Suzuki <>. Some of the ideas in this patch come from Phillip Chen <>. Signed-off-by: Bart Van Assche <> Signed-off-by: Jens Axboe <>
Diffstat (limited to 'io_u.c')
1 files changed, 11 insertions, 2 deletions
diff --git a/io_u.c b/io_u.c
index 9b5f203c..3fbcf0fd 100644
--- a/io_u.c
+++ b/io_u.c
@@ -10,6 +10,7 @@
#include "err.h"
#include "lib/pow2.h"
#include "minmax.h"
+#include "zbd.h"
struct io_completion_data {
int nr; /* input */
@@ -872,6 +873,8 @@ static void setup_strided_zone_mode(struct thread_data *td, struct io_u *io_u)
static int fill_io_u(struct thread_data *td, struct io_u *io_u)
bool is_random;
+ uint64_t offset;
+ enum io_u_action ret;
if (td_ioengine_flagged(td, FIO_NOIO))
goto out;
@@ -902,6 +905,13 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
return 1;
+ offset = io_u->offset;
+ if (td->o.zone_mode == ZONE_MODE_ZBD) {
+ ret = zbd_adjust_block(td, io_u);
+ if (ret == io_u_eof)
+ return 1;
+ }
if (io_u->offset + io_u->buflen > io_u->file->real_file_size) {
dprint(FD_IO, "io_u %p, off=0x%llx + len=0x%llx exceeds file size=0x%llx\n",
@@ -914,8 +924,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
* mark entry before potentially trimming io_u
if (td_random(td) && file_randommap(td, io_u->file))
- io_u->buflen = mark_random_map(td, io_u, io_u->offset,
- io_u->buflen);
+ io_u->buflen = mark_random_map(td, io_u, offset, io_u->buflen);
dprint_io_u(io_u, "fill");