diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-24 21:46:58 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-31 04:48:22 +0300 |
commit | ee526b88caaa4b4182144bf2576af2c3b1e9c759 (patch) | |
tree | d25c1a6b69d86c8a7ed518334dbcc13a842b37e4 /fs | |
parent | 2bce6368c46b835a133f7f4946eea9c4513828dd (diff) | |
download | linux-ee526b88caaa4b4182144bf2576af2c3b1e9c759.tar.xz |
closures: Fix race in closure_sync()
As pointed out by Linus, closure_sync() was racy; we could skip blocking
immediately after a get() and a put(), but then that would skip any
barrier corresponding to the other thread's put() barrier.
To fix this, always do the full __closure_sync() sequence whenever any
get() has happened and the closure might have been used by other
threads.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/fs-io-direct.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/bcachefs/fs-io-direct.c b/fs/bcachefs/fs-io-direct.c index 6a9557e7ecab..5b42a76c4796 100644 --- a/fs/bcachefs/fs-io-direct.c +++ b/fs/bcachefs/fs-io-direct.c @@ -113,6 +113,7 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter) } else { atomic_set(&dio->cl.remaining, CLOSURE_REMAINING_INITIALIZER + 1); + dio->cl.closure_get_happened = true; } dio->req = req; |