]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: bch2_trans_relock() is trylock for lockdep
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 28 Nov 2024 23:05:06 +0000 (18:05 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:20 +0000 (01:36 -0500)
fix some spurious lockdep splats

Reported-by: syzbot+e088be3c2d5c05aaac35@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_locking.c
fs/bcachefs/btree_locking.h

index 80c3b55ce7637f23a7c8fbbe82e2881ede726d01..9c54891c737a02e0adc4c7553af797ea83a105bf 100644 (file)
@@ -1007,7 +1007,7 @@ retry_all:
 
        bch2_trans_unlock(trans);
        cond_resched();
-       trans_set_locked(trans);
+       trans_set_locked(trans, false);
 
        if (unlikely(trans->memory_allocation_failure)) {
                struct closure cl;
@@ -3248,7 +3248,7 @@ u32 bch2_trans_begin(struct btree_trans *trans)
 
        trans->last_begin_ip = _RET_IP_;
 
-       trans_set_locked(trans);
+       trans_set_locked(trans, false);
 
        if (trans->restarted) {
                bch2_btree_path_traverse_all(trans);
@@ -3354,7 +3354,7 @@ got_trans:
        trans->srcu_idx         = srcu_read_lock(&c->btree_trans_barrier);
        trans->srcu_lock_time   = jiffies;
        trans->srcu_held        = true;
-       trans_set_locked(trans);
+       trans_set_locked(trans, false);
 
        closure_init_stack_release(&trans->ref);
        return trans;
@@ -3622,7 +3622,7 @@ int bch2_fs_btree_iter_init(struct bch_fs *c)
 #ifdef CONFIG_LOCKDEP
        fs_reclaim_acquire(GFP_KERNEL);
        struct btree_trans *trans = bch2_trans_get(c);
-       trans_set_locked(trans);
+       trans_set_locked(trans, false);
        bch2_trans_put(trans);
        fs_reclaim_release(GFP_KERNEL);
 #endif
index efe2a007b482801a8d66e628f10384358040f24c..d343df9f0ad2ebaf9a40af2d8c741ff528388518 100644 (file)
@@ -782,7 +782,7 @@ static inline int __bch2_trans_relock(struct btree_trans *trans, bool trace)
                        return bch2_trans_relock_fail(trans, path, &f, trace);
        }
 
-       trans_set_locked(trans);
+       trans_set_locked(trans, true);
 out:
        bch2_trans_verify_locks(trans);
        return 0;
index ca4aeefd631e07dda8637c475f264c29a707c931..7474ab6ce0191a4cd276dc22f65bf6aed6e503b9 100644 (file)
@@ -188,10 +188,10 @@ int bch2_six_check_for_deadlock(struct six_lock *lock, void *p);
 
 /* lock: */
 
-static inline void trans_set_locked(struct btree_trans *trans)
+static inline void trans_set_locked(struct btree_trans *trans, bool try)
 {
        if (!trans->locked) {
-               lock_acquire_exclusive(&trans->dep_map, 0, 0, NULL, _THIS_IP_);
+               lock_acquire_exclusive(&trans->dep_map, 0, try, NULL, _THIS_IP_);
                trans->locked = true;
                trans->last_unlock_ip = 0;