diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-03-22 11:32:29 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:08:18 +0300 |
commit | 65e7ab8f2aa7d45190f1e90b1332c71ef83587a6 (patch) | |
tree | 249f9f5ae138e3b04b27af9cca0f6473f43222d3 | |
parent | 11e6f19a30f65b854ba2fd3e142b3247150efe0d (diff) | |
download | linux-65e7ab8f2aa7d45190f1e90b1332c71ef83587a6.tar.xz |
bcachefs: Fix a deadlock
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 503cbc5ae309..a05fd7104a72 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -560,6 +560,8 @@ static inline int do_btree_insert_at(struct btree_trans *trans, trans_for_each_update_iter(trans, i) BUG_ON(i->iter->uptodate >= BTREE_ITER_NEED_RELOCK); + btree_trans_lock_write(c, trans); + trans_for_each_update_iter(trans, i) { if (i->deferred || !btree_node_type_needs_gc(i->iter->btree_id)) @@ -577,12 +579,10 @@ static inline int do_btree_insert_at(struct btree_trans *trans, } } - btree_trans_lock_write(c, trans); - if (race_fault()) { ret = -EINTR; trans_restart(" (race)"); - goto out_unlock; + goto out; } /* @@ -592,7 +592,7 @@ static inline int do_btree_insert_at(struct btree_trans *trans, */ ret = btree_trans_check_can_insert(trans, stopped_at); if (ret) - goto out_unlock; + goto out; /* * Don't get journal reservation until after we know insert will @@ -600,7 +600,7 @@ static inline int do_btree_insert_at(struct btree_trans *trans, */ ret = bch2_trans_journal_res_get(trans, JOURNAL_RES_GET_NONBLOCK); if (ret) - goto out_unlock; + goto out; if (!(trans->flags & BTREE_INSERT_JOURNAL_REPLAY)) { if (journal_seq_verify(c)) @@ -632,13 +632,13 @@ static inline int do_btree_insert_at(struct btree_trans *trans, trans_for_each_update(trans, i) do_btree_insert_one(trans, i); -out_unlock: +out: BUG_ON(ret && (trans->flags & BTREE_INSERT_JOURNAL_RESERVED) && trans->journal_res.ref); btree_trans_unlock_write(trans); -out: + if (fs_usage) { bch2_fs_usage_scratch_put(c, fs_usage); percpu_up_read(&c->mark_lock); |