]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Do not allow no fail lock request to fail
authorAlan Huang <mmpgouride@gmail.com>
Thu, 10 Oct 2024 13:21:50 +0000 (21:21 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 14 Jan 2025 15:45:08 +0000 (10:45 -0500)
If the transaction chose itself as a victim before and restarted, it
might request a no fail lock request this time. But it might be added to
others' lock graph and be chose as the victim again, it's no longer safe
without additional check. We can also convert the cycle detector to be
fully RCU-based to solve that unsoundness, but the latency added to trans_put
and additional memory required may not worth it.

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_locking.c

index c1a0f8f78eb42ae88ff4b19cbacd27f241a81b00..771d531d6533f2c693b0d20b33ff32f52d350f8b 100644 (file)
@@ -281,7 +281,7 @@ int bch2_check_for_deadlock(struct btree_trans *trans, struct printbuf *cycle)
 
        g.nr = 0;
 
-       if (trans->lock_must_abort) {
+       if (trans->lock_must_abort && !trans->lock_may_not_fail) {
                if (cycle)
                        return -1;