zbd: Fix potential zone lock deadlock
authorDamien Le Moal <damien.lemoal@wdc.com>
Mon, 6 Apr 2020 10:51:32 +0000 (19:51 +0900)
committerJens Axboe <axboe@kernel.dk>
Mon, 6 Apr 2020 15:30:14 +0000 (09:30 -0600)
commit1f57803b16232187a374e7e230a8d442b05fd265
tree5427e10324eb56feb7e26cf4dcbeade1dd9f09a8
parent6463db6c1d3a2a961008e87a86d464b596886f1a
zbd: Fix potential zone lock deadlock

Commit b27aef6abfba ("zbd: use zone_lock to lock a zone") to fix
potential deadlocks with zonemode=zbd  zone locking was incomplete.
The execution of the zone lock stress test t/zbd test case 48 still
sometimes lead to deadlocks (a large number of repeated execution is
sometimes needed).

The remaining deadlock pattern identified with the repeated execution
of this test is due to the concurrent execution of jobs doing random
async writes to zones. In such case, any of the job may trigger an all
zone reset through the path get_next_rand_block() -> fio_file_reset()
while async writes are still inflight. The fix for this is to use the
zone_lock() function instead of directly calling pthread_mutex_lock()i
to ensure that no async IO is inflight for a zone that is part of a
reset range.

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