mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 10:19:47 +00:00
bcachefs: Use bch2_trans_reset in bch2_trans_commit()
Clean up a bit of duplicated code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
bcd6f3e06f
commit
f21539a56d
3 changed files with 12 additions and 19 deletions
|
@ -2104,6 +2104,15 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags)
|
|||
if (flags & TRANS_RESET_MEM)
|
||||
trans->mem_top = 0;
|
||||
|
||||
if (trans->fs_usage_deltas) {
|
||||
trans->fs_usage_deltas->used = 0;
|
||||
memset((void *) trans->fs_usage_deltas +
|
||||
offsetof(struct replicas_delta_list, memset_start), 0,
|
||||
(void *) &trans->fs_usage_deltas->memset_end -
|
||||
(void *) &trans->fs_usage_deltas->memset_start);
|
||||
}
|
||||
|
||||
if (!(flags & TRANS_RESET_NOTRAVERSE))
|
||||
bch2_btree_iter_traverse_all(trans);
|
||||
}
|
||||
|
||||
|
|
|
@ -291,6 +291,7 @@ struct btree_iter *bch2_trans_get_node_iter(struct btree_trans *,
|
|||
|
||||
#define TRANS_RESET_ITERS (1 << 0)
|
||||
#define TRANS_RESET_MEM (1 << 1)
|
||||
#define TRANS_RESET_NOTRAVERSE (1 << 2)
|
||||
|
||||
void bch2_trans_reset(struct btree_trans *, unsigned);
|
||||
|
||||
|
|
|
@ -715,7 +715,6 @@ bch2_trans_commit_get_rw_cold(struct btree_trans *trans)
|
|||
int __bch2_trans_commit(struct btree_trans *trans)
|
||||
{
|
||||
struct btree_insert_entry *i = NULL;
|
||||
struct btree_iter *iter;
|
||||
unsigned u64s;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -782,23 +781,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
|||
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
|
||||
percpu_ref_put(&trans->c->writes);
|
||||
out_noupdates:
|
||||
trans_for_each_iter_all(trans, iter)
|
||||
iter->flags &= ~BTREE_ITER_KEEP_UNTIL_COMMIT;
|
||||
|
||||
if (!ret) {
|
||||
bch2_trans_unlink_iters(trans);
|
||||
trans->iters_touched = 0;
|
||||
}
|
||||
trans->nr_updates = 0;
|
||||
trans->mem_top = 0;
|
||||
|
||||
if (trans->fs_usage_deltas) {
|
||||
trans->fs_usage_deltas->used = 0;
|
||||
memset((void *) trans->fs_usage_deltas +
|
||||
offsetof(struct replicas_delta_list, memset_start), 0,
|
||||
(void *) &trans->fs_usage_deltas->memset_end -
|
||||
(void *) &trans->fs_usage_deltas->memset_start);
|
||||
}
|
||||
bch2_trans_reset(trans, TRANS_RESET_MEM|TRANS_RESET_NOTRAVERSE);
|
||||
|
||||
return ret;
|
||||
err:
|
||||
|
|
Loading…
Reference in a new issue