bcachefs: Fix btree_path leaks in bch2_trans_update()

bch2_trans_update() had some dodgy gets() and puts() - this fixes a few
leaks.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-12-01 03:47:54 -05:00 committed by Kent Overstreet
parent b547d005d5
commit 92d2ec1092

View File

@ -1336,8 +1336,6 @@ int bch2_trans_update(struct btree_trans *trans, struct btree_iter *iter,
.ip_allocated = _RET_IP_,
};
__btree_path_get(n.path, true);
#ifdef CONFIG_BCACHEFS_DEBUG
trans_for_each_update(trans, i)
BUG_ON(i != trans->updates &&
@ -1374,16 +1372,17 @@ int bch2_trans_update(struct btree_trans *trans, struct btree_iter *iter,
if (n.cached && !i->cached) {
i->k = n.k;
i->flags = n.flags;
__btree_path_get(n.path, false);
} else {
bch2_path_put(trans, i->path, true);
*i = n;
return 0;
}
bch2_path_put(trans, i->path, true);
*i = n;
} else
array_insert_item(trans->updates, trans->nr_updates,
i - trans->updates, n);
__btree_path_get(n.path, true);
return 0;
}