init: zonemode=zbd does not work with create_serialize=0
authorNiklas Cassel <niklas.cassel@wdc.com>
Thu, 22 Apr 2021 09:17:58 +0000 (11:17 +0200)
committerNiklas Cassel <niklas.cassel@wdc.com>
Thu, 22 Apr 2021 10:42:05 +0000 (12:42 +0200)
commit4662c206a07e408b1970a577fda107e4f9397a68
tree840d61bc5375377e7f938ad398b2d85ee85582f8
parent5592e99219864e21b425cfc66fa05ece5b514259
init: zonemode=zbd does not work with create_serialize=0

zbd_init_zone_info() has a comment that it only works correctly if it
called before the first fio fork() call.
However, right now, there is nothing that ensures this.

If the user specifies --create_serialize=0 and --numjobs=2, each thread
will get their own version of zbd_info.

zbd_info contains one mutex per zone, so if the threads get different
zbd_info, two threads can manage to lock the same zone at the same time,
which will lead to I/O errors.

Explicitly disallow --zonemode=zbd together with --create_serialize=0,
so that we know that all threads will use the same zbd_info, instead of
silently misbehaving.

Analysis:
setup_files() calls zbd_init_files() which calls zbd_init_zone_info().
zbd_init_zone_info() does a for_each_td(), where it checks if zbd_info
(for the same filename) has already been allocated by another thread.
This only works if create_serialize=1 (default).
If create_serialize=0, zbd_init_zone_info() will get called in parallel,
and in this case when the second thread checks if any other thread has
allocated zbd_info, the check will fail, since the first thread has not
yet been running long enough to allocate zbd_info.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
init.c