Commit 0fbf71f8 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: bch2_trans_reset_updates()

Factor out a new helper.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 9b688da3
...@@ -3186,20 +3186,12 @@ void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size) ...@@ -3186,20 +3186,12 @@ void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)
*/ */
void bch2_trans_begin(struct btree_trans *trans) void bch2_trans_begin(struct btree_trans *trans)
{ {
struct btree_insert_entry *i;
struct btree_path *path; struct btree_path *path;
trans_for_each_update(trans, i) bch2_trans_reset_updates(trans);
__btree_path_put(i->path, true);
memset(&trans->journal_res, 0, sizeof(trans->journal_res));
trans->extra_journal_res = 0;
trans->nr_updates = 0;
trans->mem_top = 0; trans->mem_top = 0;
trans->hooks = NULL;
trans->extra_journal_entries.nr = 0;
if (trans->fs_usage_deltas) { if (trans->fs_usage_deltas) {
trans->fs_usage_deltas->used = 0; trans->fs_usage_deltas->used = 0;
memset((void *) trans->fs_usage_deltas + memset((void *) trans->fs_usage_deltas +
......
...@@ -140,4 +140,17 @@ static inline int bch2_trans_commit(struct btree_trans *trans, ...@@ -140,4 +140,17 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
(_i) < (_trans)->updates + (_trans)->nr_updates; \ (_i) < (_trans)->updates + (_trans)->nr_updates; \
(_i)++) (_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 */ #endif /* _BCACHEFS_BTREE_UPDATE_H */
...@@ -1177,13 +1177,7 @@ int __bch2_trans_commit(struct btree_trans *trans) ...@@ -1177,13 +1177,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW))) if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
percpu_ref_put(&c->writes); percpu_ref_put(&c->writes);
out_reset: out_reset:
trans_for_each_update(trans, i) bch2_trans_reset_updates(trans);
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;
if (trans->fs_usage_deltas) { if (trans->fs_usage_deltas) {
trans->fs_usage_deltas->used = 0; trans->fs_usage_deltas->used = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment