diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-17 22:43:47 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:53 -0400 |
commit | 73d86dfd888541fd85f7e4d03c898f2ad8486196 (patch) | |
tree | 8f8008259cbcb45eb752c1c6d5b820c580cdb64b /fs/bcachefs/btree_locking.c | |
parent | af0ee5bcf3012be753ab15ce9c27971e5b34bd74 (diff) | |
download | lwn-73d86dfd888541fd85f7e4d03c898f2ad8486196.tar.gz lwn-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.c | 13 |
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 |