diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-01-24 00:26:48 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-13 11:34:45 -0400 |
commit | f1f06eb19b520ce8168aba6770a1b5215dcd588e (patch) | |
tree | 5f3e17b13dac0be39c6373102de380015d656b7e | |
parent | 384e7d6a85a7d63c6364e24c01cc8bcdb7075f19 (diff) |
bcachefs: bch2_trans_relock_notrace()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/alloc_background.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 1 | ||||
-rw-r--r-- | fs/bcachefs/btree_locking.c | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 93e765840915..94ec89e36cdf 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -995,7 +995,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans, GFP_KERNEL); *discard_pos_done = iter.pos; - ret = bch2_trans_relock(trans); + ret = bch2_trans_relock_notrace(trans); if (ret) goto out; } diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 361f1b64060a..a50e01a45d40 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -207,6 +207,7 @@ int bch2_btree_path_relock_intent(struct btree_trans *, struct btree_path *); void bch2_path_put(struct btree_trans *, struct btree_path *, bool); int bch2_trans_relock(struct btree_trans *); +int bch2_trans_relock_notrace(struct btree_trans *); void bch2_trans_unlock(struct btree_trans *); bool bch2_trans_locked(struct btree_trans *); diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 9a9c44f1d981..caed21d13547 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -691,6 +691,21 @@ int bch2_trans_relock(struct btree_trans *trans) return 0; } +int bch2_trans_relock_notrace(struct btree_trans *trans) +{ + struct btree_path *path; + + if (unlikely(trans->restarted)) + return -((int) trans->restarted); + + trans_for_each_path(trans, path) + if (path->should_be_locked && + !bch2_btree_path_relock_norestart(trans, path, _RET_IP_)) { + return btree_trans_restart(trans, BCH_ERR_transaction_restart_relock); + } + return 0; +} + void bch2_trans_unlock(struct btree_trans *trans) { struct btree_path *path; |