Commit 2611a041 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch2_mark_key() now takes btree_id & level

btree & level are passed to trans_mark - for backpointers -
bch2_mark_key() should take them as well.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e9020958
...@@ -29,8 +29,8 @@ struct bkey_ops { ...@@ -29,8 +29,8 @@ struct bkey_ops {
bool (*key_merge)(struct bch_fs *, struct bkey_s, struct bkey_s_c); bool (*key_merge)(struct bch_fs *, struct bkey_s, struct bkey_s_c);
int (*trans_trigger)(struct btree_trans *, enum btree_id, unsigned, int (*trans_trigger)(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, struct bkey_i *, unsigned); struct bkey_s_c, struct bkey_i *, unsigned);
int (*atomic_trigger)(struct btree_trans *, struct bkey_s_c, int (*atomic_trigger)(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, unsigned); struct bkey_s_c, struct bkey_s_c, unsigned);
void (*compat)(enum btree_id id, unsigned version, void (*compat)(enum btree_id id, unsigned version,
unsigned big_endian, int write, unsigned big_endian, int write,
struct bkey_s); struct bkey_s);
...@@ -68,14 +68,14 @@ static inline bool bch2_bkey_maybe_mergable(const struct bkey *l, const struct b ...@@ -68,14 +68,14 @@ static inline bool bch2_bkey_maybe_mergable(const struct bkey *l, const struct b
bool bch2_bkey_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c); bool bch2_bkey_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
static inline int bch2_mark_key(struct btree_trans *trans, static inline int bch2_mark_key(struct btree_trans *trans,
struct bkey_s_c old, enum btree_id btree, unsigned level,
struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
const struct bkey_ops *ops = &bch2_bkey_ops[old.k->type ?: new.k->type]; const struct bkey_ops *ops = &bch2_bkey_ops[old.k->type ?: new.k->type];
return ops->atomic_trigger return ops->atomic_trigger
? ops->atomic_trigger(trans, old, new, flags) ? ops->atomic_trigger(trans, btree, level, old, new, flags)
: 0; : 0;
} }
......
...@@ -808,7 +808,7 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id, ...@@ -808,7 +808,7 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
} }
ret = commit_do(trans, NULL, NULL, 0, ret = commit_do(trans, NULL, NULL, 0,
bch2_mark_key(trans, old, *k, flags)); bch2_mark_key(trans, btree_id, level, old, *k, flags));
fsck_err: fsck_err:
err: err:
if (ret) if (ret)
...@@ -887,7 +887,7 @@ static int bch2_gc_btree(struct btree_trans *trans, enum btree_id btree_id, ...@@ -887,7 +887,7 @@ static int bch2_gc_btree(struct btree_trans *trans, enum btree_id btree_id,
if (!btree_node_fake(b)) { if (!btree_node_fake(b)) {
struct bkey_s_c k = bkey_i_to_s_c(&b->key); struct bkey_s_c k = bkey_i_to_s_c(&b->key);
ret = bch2_gc_mark_key(trans, b->c.btree_id, b->c.level, ret = bch2_gc_mark_key(trans, b->c.btree_id, b->c.level + 1,
true, &k, initial); true, &k, initial);
} }
gc_pos_set(c, gc_pos_btree_root(b->c.btree_id)); gc_pos_set(c, gc_pos_btree_root(b->c.btree_id));
...@@ -1040,7 +1040,7 @@ static int bch2_gc_btree_init(struct btree_trans *trans, ...@@ -1040,7 +1040,7 @@ static int bch2_gc_btree_init(struct btree_trans *trans,
if (!ret) { if (!ret) {
struct bkey_s_c k = bkey_i_to_s_c(&b->key); struct bkey_s_c k = bkey_i_to_s_c(&b->key);
ret = bch2_gc_mark_key(trans, b->c.btree_id, b->c.level, true, ret = bch2_gc_mark_key(trans, b->c.btree_id, b->c.level + 1, true,
&k, true); &k, true);
} }
fsck_err: fsck_err:
......
...@@ -434,7 +434,8 @@ static int run_one_mem_trigger(struct btree_trans *trans, ...@@ -434,7 +434,8 @@ static int run_one_mem_trigger(struct btree_trans *trans,
if (bch2_bkey_ops[old.k->type].atomic_trigger == if (bch2_bkey_ops[old.k->type].atomic_trigger ==
bch2_bkey_ops[i->k->k.type].atomic_trigger && bch2_bkey_ops[i->k->k.type].atomic_trigger &&
((1U << old.k->type) & BTREE_TRIGGER_WANTS_OLD_AND_NEW)) { ((1U << old.k->type) & BTREE_TRIGGER_WANTS_OLD_AND_NEW)) {
ret = bch2_mark_key(trans, old, bkey_i_to_s_c(new), ret = bch2_mark_key(trans, i->btree_id, i->level,
old, bkey_i_to_s_c(new),
BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE|flags); BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE|flags);
} else { } else {
struct bkey _deleted = KEY(0, 0, 0); struct bkey _deleted = KEY(0, 0, 0);
...@@ -442,9 +443,11 @@ static int run_one_mem_trigger(struct btree_trans *trans, ...@@ -442,9 +443,11 @@ static int run_one_mem_trigger(struct btree_trans *trans,
_deleted.p = i->path->pos; _deleted.p = i->path->pos;
ret = bch2_mark_key(trans, deleted, bkey_i_to_s_c(new), ret = bch2_mark_key(trans, i->btree_id, i->level,
deleted, bkey_i_to_s_c(new),
BTREE_TRIGGER_INSERT|flags) ?: BTREE_TRIGGER_INSERT|flags) ?:
bch2_mark_key(trans, old, deleted, bch2_mark_key(trans, i->btree_id, i->level,
old, deleted,
BTREE_TRIGGER_OVERWRITE|flags); BTREE_TRIGGER_OVERWRITE|flags);
} }
......
...@@ -486,6 +486,7 @@ static inline void update_cached_sectors_list(struct btree_trans *trans, ...@@ -486,6 +486,7 @@ static inline void update_cached_sectors_list(struct btree_trans *trans,
} }
int bch2_mark_alloc(struct btree_trans *trans, int bch2_mark_alloc(struct btree_trans *trans,
enum btree_id btree, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
...@@ -929,6 +930,7 @@ static int bch2_mark_stripe_ptr(struct btree_trans *trans, ...@@ -929,6 +930,7 @@ static int bch2_mark_stripe_ptr(struct btree_trans *trans,
} }
int bch2_mark_extent(struct btree_trans *trans, int bch2_mark_extent(struct btree_trans *trans,
enum btree_id btree_id, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
...@@ -1012,6 +1014,7 @@ int bch2_mark_extent(struct btree_trans *trans, ...@@ -1012,6 +1014,7 @@ int bch2_mark_extent(struct btree_trans *trans,
} }
int bch2_mark_stripe(struct btree_trans *trans, int bch2_mark_stripe(struct btree_trans *trans,
enum btree_id btree_id, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
...@@ -1117,6 +1120,7 @@ int bch2_mark_stripe(struct btree_trans *trans, ...@@ -1117,6 +1120,7 @@ int bch2_mark_stripe(struct btree_trans *trans,
} }
int bch2_mark_inode(struct btree_trans *trans, int bch2_mark_inode(struct btree_trans *trans,
enum btree_id btree_id, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
...@@ -1148,6 +1152,7 @@ int bch2_mark_inode(struct btree_trans *trans, ...@@ -1148,6 +1152,7 @@ int bch2_mark_inode(struct btree_trans *trans,
} }
int bch2_mark_reservation(struct btree_trans *trans, int bch2_mark_reservation(struct btree_trans *trans,
enum btree_id btree_id, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
...@@ -1234,6 +1239,7 @@ static s64 __bch2_mark_reflink_p(struct btree_trans *trans, ...@@ -1234,6 +1239,7 @@ static s64 __bch2_mark_reflink_p(struct btree_trans *trans,
} }
int bch2_mark_reflink_p(struct btree_trans *trans, int bch2_mark_reflink_p(struct btree_trans *trans,
enum btree_id btree_id, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
......
...@@ -235,12 +235,18 @@ int bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *, ...@@ -235,12 +235,18 @@ int bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *,
size_t, enum bch_data_type, unsigned, size_t, enum bch_data_type, unsigned,
struct gc_pos, unsigned); struct gc_pos, unsigned);
int bch2_mark_alloc(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); int bch2_mark_alloc(struct btree_trans *, enum btree_id, unsigned,
int bch2_mark_extent(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); struct bkey_s_c, struct bkey_s_c, unsigned);
int bch2_mark_stripe(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); int bch2_mark_extent(struct btree_trans *, enum btree_id, unsigned,
int bch2_mark_inode(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); struct bkey_s_c, struct bkey_s_c, unsigned);
int bch2_mark_reservation(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); int bch2_mark_stripe(struct btree_trans *, enum btree_id, unsigned,
int bch2_mark_reflink_p(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); struct bkey_s_c, struct bkey_s_c, unsigned);
int bch2_mark_inode(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, struct bkey_s_c, unsigned);
int bch2_mark_reservation(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, struct bkey_s_c, unsigned);
int bch2_mark_reflink_p(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, struct bkey_s_c, unsigned);
int bch2_trans_mark_extent(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned); int bch2_trans_mark_extent(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned);
int bch2_trans_mark_stripe(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned); int bch2_trans_mark_stripe(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned);
......
...@@ -76,6 +76,7 @@ int bch2_snapshot_invalid(const struct bch_fs *c, struct bkey_s_c k, ...@@ -76,6 +76,7 @@ int bch2_snapshot_invalid(const struct bch_fs *c, struct bkey_s_c k,
} }
int bch2_mark_snapshot(struct btree_trans *trans, int bch2_mark_snapshot(struct btree_trans *trans,
enum btree_id btree, unsigned level,
struct bkey_s_c old, struct bkey_s_c new, struct bkey_s_c old, struct bkey_s_c new,
unsigned flags) unsigned flags)
{ {
...@@ -361,7 +362,7 @@ int bch2_fs_snapshots_start(struct bch_fs *c) ...@@ -361,7 +362,7 @@ int bch2_fs_snapshots_start(struct bch_fs *c)
for_each_btree_key2(&trans, iter, BTREE_ID_snapshots, for_each_btree_key2(&trans, iter, BTREE_ID_snapshots,
POS_MIN, 0, k, POS_MIN, 0, k,
bch2_mark_snapshot(&trans, bkey_s_c_null, k, 0) ?: bch2_mark_snapshot(&trans, BTREE_ID_snapshots, 0, bkey_s_c_null, k, 0) ?:
bch2_snapshot_set_equiv(&trans, k)); bch2_snapshot_set_equiv(&trans, k));
bch2_trans_exit(&trans); bch2_trans_exit(&trans);
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
int bch2_snapshot_invalid(const struct bch_fs *, struct bkey_s_c, int bch2_snapshot_invalid(const struct bch_fs *, struct bkey_s_c,
unsigned, struct printbuf *); unsigned, struct printbuf *);
int bch2_mark_snapshot(struct btree_trans *, struct bkey_s_c, int bch2_mark_snapshot(struct btree_trans *, enum btree_id, unsigned,
struct bkey_s_c, unsigned); struct bkey_s_c, struct bkey_s_c, unsigned);
#define bch2_bkey_ops_snapshot ((struct bkey_ops) { \ #define bch2_bkey_ops_snapshot ((struct bkey_ops) { \
.key_invalid = bch2_snapshot_invalid, \ .key_invalid = bch2_snapshot_invalid, \
......
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