filesetup: create zbd_info before jumping to done label
authorNiklas Cassel <niklas.cassel@wdc.com>
Thu, 2 Dec 2021 09:42:06 +0000 (09:42 +0000)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Dec 2021 00:54:15 +0000 (17:54 -0700)
For a thread that has zonemode == ZONE_MODE_ZBD set, the zbd code requires
that each file (for that thread) has a valid f->zbd_info pointer.

This intent was further clarified by commit 5ddf46d0b2df ("zbd: change some
f->zbd_info conditionals to asserts").

The zbd info pointer is set by zbd_init_files(), either by creating a new
zbd_info struct, or by increasing the refcount of an existing zbd_info.

A zbd_info struct contains the in memory state of the zones, including e.g.
each zone's wp and zone capacity.

Normally, zbd_init_files() is always called, even for read only workloads.
However, in the case where a read iolog was supplied, setup_files()
currently jumps to the done label before zbd_init_files() has been called.

Even for a read only workload, zbd_adjust_block() will do things as
checking if the read I/O is below the wp (unless td->o.read_beyond_wp is
enabled). In order to be able to do this comparison, we need a valid
zbd_info.

There is no reason why the zbd code should treat a read only workload
different from a read iolog workload. (E.g. the wp for the zones might
have changed since the read iolog was recorded.)

If the user for some reason wants to disregard the wp check during a read
iolog workload, the td->o.read_beyond_wp option can be used, just like in
the regular read only workload case.

Move the read iolog check and the matching "goto done" after the call to
zbd_init_files(). This way, we treat a read iolog workload simlar to a
regular read only workload, while avoiding an assertion failure in
zbd_setup_files() (which is called after the done label).

Reported-by: Shane Moore <shane.moore@wdc.com>
Suggested-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Tested-by: Shane Moore <shane.moore@wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20211202094153.8381-1-Niklas.Cassel@wdc.com
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
filesetup.c

index 228e4fffe3c5e7dd509a9ac642497093aca35f87..fb556d8444e4a1a29b027a6e53ffecab3708898d 100644 (file)
@@ -1119,9 +1119,6 @@ int setup_files(struct thread_data *td)
        if (err)
                goto err_out;
 
-       if (o->read_iolog_file)
-               goto done;
-
        if (td->o.zone_mode == ZONE_MODE_ZBD) {
                err = zbd_init_files(td);
                if (err)
@@ -1129,6 +1126,9 @@ int setup_files(struct thread_data *td)
        }
        zbd_recalc_options_with_zone_granularity(td);
 
+       if (o->read_iolog_file)
+               goto done;
+
        /*
         * check sizes. if the files/devices do not exist and the size
         * isn't passed to fio, abort.