diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-17 14:36:24 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:40 -0400 |
commit | 367d72dd5fd5b9e0b87633cbcb11b58b91d6bcc5 (patch) | |
tree | d826d622012d9bd59cad201af89f2c5fbff5527b /fs/bcachefs/btree_locking.h | |
parent | b8eec675912ecb7e53dabe35d2869c2da60c45c9 (diff) | |
download | lwn-367d72dd5fd5b9e0b87633cbcb11b58b91d6bcc5.tar.gz lwn-367d72dd5fd5b9e0b87633cbcb11b58b91d6bcc5.zip |
bcachefs: bch2_btree_path_upgrade() now emits transaction restart
Centralizing the transaction restart/tracepoint in
bch2_btree_path_upgrade() lets us improve the tracepoint - now it emits
old and new locks_want.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_locking.h')
-rw-r--r-- | fs/bcachefs/btree_locking.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h index 9758a0c05d25..aea2ebafffd8 100644 --- a/fs/bcachefs/btree_locking.h +++ b/fs/bcachefs/btree_locking.h @@ -345,15 +345,22 @@ bool bch2_btree_path_upgrade_noupgrade_sibs(struct btree_trans *, bool __bch2_btree_path_upgrade(struct btree_trans *, struct btree_path *, unsigned); -static inline bool bch2_btree_path_upgrade(struct btree_trans *trans, - struct btree_path *path, - unsigned new_locks_want) +static inline int bch2_btree_path_upgrade(struct btree_trans *trans, + struct btree_path *path, + unsigned new_locks_want) { + unsigned old_locks_want = path->locks_want; + new_locks_want = min(new_locks_want, BTREE_MAX_DEPTH); - return path->locks_want < new_locks_want - ? __bch2_btree_path_upgrade(trans, path, new_locks_want) - : path->uptodate == BTREE_ITER_UPTODATE; + if (path->locks_want < new_locks_want + ? __bch2_btree_path_upgrade(trans, path, new_locks_want) + : path->uptodate == BTREE_ITER_UPTODATE) + return 0; + + trace_and_count(trans->c, trans_restart_upgrade, trans, _THIS_IP_, path, + old_locks_want, new_locks_want); + return btree_trans_restart(trans, BCH_ERR_transaction_restart_upgrade); } /* misc: */ |