diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-17 19:35:38 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:36 -0400 |
commit | e941ae7d3afc68127adef917a2b779dabe83fdfe (patch) | |
tree | 577edab610a98f574dbfc9cc9bf2622959affe95 /fs/bcachefs/btree_update.h | |
parent | 445d184af25abd70575539f7d7b2c8e25b8c49c8 (diff) | |
download | linux-e941ae7d3afc68127adef917a2b779dabe83fdfe.tar.gz linux-e941ae7d3afc68127adef917a2b779dabe83fdfe.tar.bz2 linux-e941ae7d3afc68127adef917a2b779dabe83fdfe.zip |
bcachefs: Add a counter for btree_trans restarts
This will help us improve nested transactions - we need to add
assertions that whenever an inner transaction handles a restart, it
still returns -EINTR to the outer transaction.
This also adds nested_lockrestart_do() and nested_commit_do() which use
the new counters to correctly return -EINTR when the transaction was
restarted.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_update.h')
-rw-r--r-- | fs/bcachefs/btree_update.h | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/fs/bcachefs/btree_update.h b/fs/bcachefs/btree_update.h index 1c3dd012cae8..9b5a8b18b01b 100644 --- a/fs/bcachefs/btree_update.h +++ b/fs/bcachefs/btree_update.h @@ -106,22 +106,14 @@ static inline int bch2_trans_commit(struct btree_trans *trans, return __bch2_trans_commit(trans); } -#define lockrestart_do(_trans, _do) \ -({ \ - int _ret; \ - \ - do { \ - bch2_trans_begin(_trans); \ - _ret = (_do); \ - } while (_ret == -EINTR); \ - \ - _ret; \ -}) - #define commit_do(_trans, _disk_res, _journal_seq, _flags, _do) \ lockrestart_do(_trans, _do ?: bch2_trans_commit(_trans, (_disk_res),\ (_journal_seq), (_flags))) +#define nested_commit_do(_trans, _disk_res, _journal_seq, _flags, _do) \ + nested_lockrestart_do(_trans, _do ?: bch2_trans_commit(_trans, (_disk_res),\ + (_journal_seq), (_flags))) + #define bch2_trans_do(_c, _disk_res, _journal_seq, _flags, _do) \ ({ \ struct btree_trans trans; \ |