zbd: Ensure first I/O is write for random read/write to sequential zones
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Mon, 13 Apr 2020 08:33:00 +0000 (17:33 +0900)
committerJens Axboe <axboe@kernel.dk>
Mon, 13 Apr 2020 14:22:14 +0000 (08:22 -0600)
In case read is chosen for the first random I/O for sequential write
required zones, fio stops because no data can be read from the zones with
empty status. Enforce to write at the first I/O to make sure data to read
exists for the following read operations.

The unexpected fio stop symptom was observed with test case #30 of
t/zbd/test-zbd-support. When the test case was run repeatedly resetting
all zones with -r option, it often passes with too short run time.

Reviewed-by: Damien Le Moal <damien.lemoaal@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
zbd.c

diff --git a/zbd.c b/zbd.c
index aa1fa33fe903171bc14b9053c2b73d9a3357b7dc..99ac72cab71cbcbdec4c32f755367aff94a8669a 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -1350,6 +1350,16 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
        if (!zbd_zone_swr(zb))
                return io_u_accept;
 
+       /*
+        * In case read direction is chosen for the first random I/O, fio with
+        * zonemode=zbd stops because no data can be read from zoned block
+        * devices with all empty zones. Overwrite the first I/O direction as
+        * write to make sure data to read exists.
+        */
+       if (td_rw(td) && !f->zbd_info->sectors_with_data
+           && !td->o.read_beyond_wp)
+               io_u->ddir = DDIR_WRITE;
+
        /*
         * Accept the I/O offset for reads if reading beyond the write pointer
         * is enabled.