io-wq: serialize hash clear with wakeup
authorJens Axboe <axboe@kernel.dk>
Sun, 14 Nov 2021 14:36:47 +0000 (07:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Nov 2021 10:04:47 +0000 (11:04 +0100)
commit5741bd42f7c599f4b38246a7c0c267efa72b9eb7
tree75d1e2a78932d775558bf3d834e7ba4d449fb0b5
parent9f9d088a4b7d0b6451e9cdd5225d7b192608ca38
io-wq: serialize hash clear with wakeup

commit d3e3c102d107bb84251455a298cf475f24bab995 upstream.

We need to ensure that we serialize the stalled and hash bits with the
wait_queue wait handler, or we could be racing with someone modifying
the hashed state after we find it busy, but before we then give up and
wait for it to be cleared. This can cause random delays or stalls when
handling buffered writes for many files, where some of these files cause
hash collisions between the worker threads.

Cc: stable@vger.kernel.org
Reported-by: Daniel Black <daniel@mariadb.org>
Fixes: e941894eae31 ("io-wq: make buffered file write hashed work map per-ctx")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io-wq.c