summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_locking.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-18 04:43:47 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:09:53 +0200
commit73d86dfd888541fd85f7e4d03c898f2ad8486196 (patch)
tree8f8008259cbcb45eb752c1c6d5b820c580cdb64b /fs/bcachefs/btree_locking.c
parentbcachefs: Don't block on ec_stripe_head_lock with btree locks held (diff)
downloadlinux-73d86dfd888541fd85f7e4d03c898f2ad8486196.tar.xz
linux-73d86dfd888541fd85f7e4d03c898f2ad8486196.zip
bcachefs: Fix erasure coding locking
This adds a new helper, bch2_trans_mutex_lock(), for locking a mutex - dropping and retaking btree locks as needed. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_locking.c')
-rw-r--r--fs/bcachefs/btree_locking.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c
index 49c7e94573c9..14a0614af436 100644
--- a/fs/bcachefs/btree_locking.c
+++ b/fs/bcachefs/btree_locking.c
@@ -725,6 +725,19 @@ bool bch2_trans_locked(struct btree_trans *trans)
return false;
}
+int __bch2_trans_mutex_lock(struct btree_trans *trans,
+ struct mutex *lock)
+{
+ int ret;
+
+ bch2_trans_unlock(trans);
+ mutex_lock(lock);
+ ret = bch2_trans_relock(trans);
+ if (ret)
+ mutex_unlock(lock);
+ return ret;
+}
+
/* Debug */
#ifdef CONFIG_BCACHEFS_DEBUG