diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-18 04:43:47 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:53 +0200 |
commit | 73d86dfd888541fd85f7e4d03c898f2ad8486196 (patch) | |
tree | 8f8008259cbcb45eb752c1c6d5b820c580cdb64b /fs/bcachefs/alloc_foreground.c | |
parent | bcachefs: Don't block on ec_stripe_head_lock with btree locks held (diff) | |
download | linux-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/alloc_foreground.c')
-rw-r--r-- | fs/bcachefs/alloc_foreground.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 2eab63b90664..0b0fe4fea6cc 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -1073,7 +1073,7 @@ static bool try_decrease_writepoints(struct bch_fs *c, return true; } -static void bch2_trans_mutex_lock(struct btree_trans *trans, +static void bch2_trans_mutex_lock_norelock(struct btree_trans *trans, struct mutex *lock) { if (!mutex_trylock(lock)) { @@ -1091,7 +1091,7 @@ static struct write_point *writepoint_find(struct btree_trans *trans, if (!(write_point & 1UL)) { wp = (struct write_point *) write_point; - bch2_trans_mutex_lock(trans, &wp->lock); + bch2_trans_mutex_lock_norelock(trans, &wp->lock); return wp; } @@ -1100,7 +1100,7 @@ restart_find: wp = __writepoint_find(head, write_point); if (wp) { lock_wp: - bch2_trans_mutex_lock(trans, &wp->lock); + bch2_trans_mutex_lock_norelock(trans, &wp->lock); if (wp->write_point == write_point) goto out; mutex_unlock(&wp->lock); @@ -1113,8 +1113,8 @@ restart_find_oldest: if (!oldest || time_before64(wp->last_used, oldest->last_used)) oldest = wp; - bch2_trans_mutex_lock(trans, &oldest->lock); - bch2_trans_mutex_lock(trans, &c->write_points_hash_lock); + bch2_trans_mutex_lock_norelock(trans, &oldest->lock); + bch2_trans_mutex_lock_norelock(trans, &c->write_points_hash_lock); if (oldest >= c->write_points + c->write_points_nr || try_increase_writepoints(c)) { mutex_unlock(&c->write_points_hash_lock); |