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)
commitfd1d8e0ab3dc852193037a3acebcf8b8bdbcd9c5
treeb0027ef49e5f1935e18b3600bc509f3a3918ef99
parented7f3a07363d62c6d6147b0c568f87f079d241a8
filesetup: create zbd_info before jumping to done label

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