mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-04 04:02:26 +00:00
bcachefs: reserve path idx 0 for sentinal
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
5028b9078c
commit
f8fd5871be
@ -2515,7 +2515,7 @@ static void btree_trans_verify_sorted_refs(struct btree_trans *trans)
|
|||||||
struct btree_path *path;
|
struct btree_path *path;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
BUG_ON(trans->nr_sorted != bitmap_weight(trans->paths_allocated, BTREE_ITER_MAX));
|
BUG_ON(trans->nr_sorted != bitmap_weight(trans->paths_allocated, BTREE_ITER_MAX) - 1);
|
||||||
|
|
||||||
trans_for_each_path(trans, path) {
|
trans_for_each_path(trans, path) {
|
||||||
BUG_ON(path->sorted_idx >= trans->nr_sorted);
|
BUG_ON(path->sorted_idx >= trans->nr_sorted);
|
||||||
@ -2896,6 +2896,8 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)
|
|||||||
atomic_inc_not_zero(&c->journal_keys.ref);
|
atomic_inc_not_zero(&c->journal_keys.ref);
|
||||||
closure_init_stack(&trans->ref);
|
closure_init_stack(&trans->ref);
|
||||||
|
|
||||||
|
trans->paths_allocated[0] = 1;
|
||||||
|
|
||||||
s = btree_trans_stats(trans);
|
s = btree_trans_stats(trans);
|
||||||
if (s && s->max_mem) {
|
if (s && s->max_mem) {
|
||||||
unsigned expected_mem_bytes = roundup_pow_of_two(s->max_mem);
|
unsigned expected_mem_bytes = roundup_pow_of_two(s->max_mem);
|
||||||
|
@ -80,7 +80,7 @@ __trans_next_path(struct btree_trans *trans, unsigned idx)
|
|||||||
_path = __trans_next_path((_trans), (_path)->idx + 1))
|
_path = __trans_next_path((_trans), (_path)->idx + 1))
|
||||||
|
|
||||||
#define trans_for_each_path(_trans, _path) \
|
#define trans_for_each_path(_trans, _path) \
|
||||||
trans_for_each_path_from(_trans, _path, 0)
|
trans_for_each_path_from(_trans, _path, 1)
|
||||||
|
|
||||||
static inline struct btree_path *
|
static inline struct btree_path *
|
||||||
__trans_next_path_safe(struct btree_trans *trans, unsigned *idx)
|
__trans_next_path_safe(struct btree_trans *trans, unsigned *idx)
|
||||||
@ -103,7 +103,7 @@ __trans_next_path_safe(struct btree_trans *trans, unsigned *idx)
|
|||||||
_idx++)
|
_idx++)
|
||||||
|
|
||||||
#define trans_for_each_path_safe(_trans, _path, _idx) \
|
#define trans_for_each_path_safe(_trans, _path, _idx) \
|
||||||
trans_for_each_path_safe_from(_trans, _path, _idx, 0)
|
trans_for_each_path_safe_from(_trans, _path, _idx, 1)
|
||||||
|
|
||||||
static inline struct btree_path *next_btree_path(struct btree_trans *trans, struct btree_path *path)
|
static inline struct btree_path *next_btree_path(struct btree_trans *trans, struct btree_path *path)
|
||||||
{
|
{
|
||||||
@ -155,7 +155,7 @@ __trans_next_path_with_node(struct btree_trans *trans, struct btree *b,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define trans_for_each_path_with_node(_trans, _b, _path) \
|
#define trans_for_each_path_with_node(_trans, _b, _path) \
|
||||||
for (_path = __trans_next_path_with_node((_trans), (_b), 0); \
|
for (_path = __trans_next_path_with_node((_trans), (_b), 1); \
|
||||||
(_path); \
|
(_path); \
|
||||||
_path = __trans_next_path_with_node((_trans), (_b), \
|
_path = __trans_next_path_with_node((_trans), (_b), \
|
||||||
(_path)->idx + 1))
|
(_path)->idx + 1))
|
||||||
|
Loading…
Reference in New Issue
Block a user