diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-05-28 18:06:27 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:03 -0400 |
commit | b5fd75669ab1283e7a9caf6288c425108bd382b0 (patch) | |
tree | 65003eef4cafbff47425bc4e726c2ab895c91e9d /fs/bcachefs/btree_update_interior.c | |
parent | 19c304bebda4d8815a20c8d3330459a112c329f6 (diff) | |
download | linux-b5fd75669ab1283e7a9caf6288c425108bd382b0.tar.gz linux-b5fd75669ab1283e7a9caf6288c425108bd382b0.tar.bz2 linux-b5fd75669ab1283e7a9caf6288c425108bd382b0.zip |
bcachefs: drop_locks_do()
Add a new helper for the common pattern of:
- trans_unlock()
- do something
- trans_relock()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_update_interior.c')
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index db0d09b59f2f..4d6c286edb04 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1083,9 +1083,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, if (flags & BTREE_INSERT_GC_LOCK_HELD) lockdep_assert_held(&c->gc_lock); else if (!down_read_trylock(&c->gc_lock)) { - bch2_trans_unlock(trans); - down_read(&c->gc_lock); - ret = bch2_trans_relock(trans); + ret = drop_locks_do(trans, (down_read(&c->gc_lock), 0)); if (ret) { up_read(&c->gc_lock); return ERR_PTR(ret); @@ -2256,9 +2254,7 @@ int bch2_btree_node_update_key(struct btree_trans *trans, struct btree_iter *ite if (btree_ptr_hash_val(new_key) != b->hash_val) { ret = bch2_btree_cache_cannibalize_lock(c, &cl); if (ret) { - bch2_trans_unlock(trans); - closure_sync(&cl); - ret = bch2_trans_relock(trans); + ret = drop_locks_do(trans, (closure_sync(&cl), 0)); if (ret) return ret; } |