bcachefs: bch2_trans_reset_updates()

Factor out a new helper.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2022-05-29 11:38:48 -04:00 committed by Kent Overstreet
parent 9b688da350
commit 0fbf71f80d
3 changed files with 15 additions and 16 deletions

View File

@ -3186,20 +3186,12 @@ void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)
*/
void bch2_trans_begin(struct btree_trans *trans)
{
struct btree_insert_entry *i;
struct btree_path *path;
trans_for_each_update(trans, i)
__btree_path_put(i->path, true);
bch2_trans_reset_updates(trans);
memset(&trans->journal_res, 0, sizeof(trans->journal_res));
trans->extra_journal_res = 0;
trans->nr_updates = 0;
trans->mem_top = 0;
trans->hooks = NULL;
trans->extra_journal_entries.nr = 0;
if (trans->fs_usage_deltas) {
trans->fs_usage_deltas->used = 0;
memset((void *) trans->fs_usage_deltas +

View File

@ -140,4 +140,17 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
(_i) < (_trans)->updates + (_trans)->nr_updates; \
(_i)++)
static inline void bch2_trans_reset_updates(struct btree_trans *trans)
{
struct btree_insert_entry *i;
trans_for_each_update(trans, i)
bch2_path_put(trans, i->path, true);
trans->extra_journal_res = 0;
trans->nr_updates = 0;
trans->hooks = NULL;
trans->extra_journal_entries.nr = 0;
}
#endif /* _BCACHEFS_BTREE_UPDATE_H */

View File

@ -1177,13 +1177,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
percpu_ref_put(&c->writes);
out_reset:
trans_for_each_update(trans, i)
bch2_path_put(trans, i->path, true);
trans->extra_journal_res = 0;
trans->nr_updates = 0;
trans->hooks = NULL;
trans->extra_journal_entries.nr = 0;
bch2_trans_reset_updates(trans);
if (trans->fs_usage_deltas) {
trans->fs_usage_deltas->used = 0;