diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-14 02:08:58 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:36 -0400 |
commit | dadecd02c49c7bb14c04445fc514c394e28c1ae3 (patch) | |
tree | 13c5f6470106c8a9ee7d0cfac9e466279e96d984 /fs/bcachefs/btree_update.h | |
parent | 326568f18cb57ed95a420361da9a64330e122cda (diff) | |
download | linux-stable-dadecd02c49c7bb14c04445fc514c394e28c1ae3.tar.gz linux-stable-dadecd02c49c7bb14c04445fc514c394e28c1ae3.tar.bz2 linux-stable-dadecd02c49c7bb14c04445fc514c394e28c1ae3.zip |
bcachefs: bch2_trans_run()
This adds a new helper, bch2_trans_run(), that runs a function with a
btree_transaction context but without handling transaction restarts.
We're adding checks for nested transaction restart handling: when an
inner transaction handles a transaction restart it will still have to
return it to the outer transaction, or else assertions will be popped in
the outer transaction.
But some places don't need restart handling at the outer scope, so this
helper does what they need.
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 | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_update.h b/fs/bcachefs/btree_update.h index e9127dbf7e24..1c3dd012cae8 100644 --- a/fs/bcachefs/btree_update.h +++ b/fs/bcachefs/btree_update.h @@ -134,6 +134,18 @@ static inline int bch2_trans_commit(struct btree_trans *trans, _ret; \ }) +#define bch2_trans_run(_c, _do) \ +({ \ + struct btree_trans trans; \ + int _ret; \ + \ + bch2_trans_init(&trans, (_c), 0, 0); \ + _ret = (_do); \ + bch2_trans_exit(&trans); \ + \ + _ret; \ +}) + #define trans_for_each_update(_trans, _i) \ for ((_i) = (_trans)->updates; \ (_i) < (_trans)->updates + (_trans)->nr_updates; \ |