diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-11 18:40:17 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-11 20:43:11 -0500 |
commit | bedd6fe4d357f3cffb392f2153b52ef71f810259 (patch) | |
tree | 1ae1c94cc42ddf4aa0efc85b06e87c479a14f565 | |
parent | a66ff26b0f31189e413a87065c25949c359e4bef (diff) | |
download | linux-stable-bedd6fe4d357f3cffb392f2153b52ef71f810259.tar.gz linux-stable-bedd6fe4d357f3cffb392f2153b52ef71f810259.tar.bz2 linux-stable-bedd6fe4d357f3cffb392f2153b52ef71f810259.zip |
bcachefs: Fix nocow locks deadlock
On trylock failure we were waiting for outstanding reads to complete -
but nocow locks need to be held until the whole move is finished.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/data_update.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index 2418c528c533..b05457d284a6 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -560,7 +560,8 @@ int bch2_data_update_init(struct btree_trans *trans, move_ctxt_wait_event(ctxt, (locked = bch2_bucket_nocow_trylock(&c->nocow_locks, PTR_BUCKET_POS(c, &p.ptr), 0)) || - !atomic_read(&ctxt->read_sectors)); + (!atomic_read(&ctxt->read_sectors) && + !atomic_read(&ctxt->write_sectors))); if (!locked) bch2_bucket_nocow_lock(&c->nocow_locks, |