Commit a7c7a309 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: bch2_mark_key() now takes bch_data_type

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 647d7b60
...@@ -123,13 +123,14 @@ static u8 bch2_gc_mark_key(struct bch_fs *c, enum bkey_type type, ...@@ -123,13 +123,14 @@ static u8 bch2_gc_mark_key(struct bch_fs *c, enum bkey_type type,
switch (type) { switch (type) {
case BKEY_TYPE_BTREE: case BKEY_TYPE_BTREE:
bch2_mark_key(c, k, c->opts.btree_node_size, true, pos, NULL, bch2_mark_key(c, k, c->opts.btree_node_size,
BCH_DATA_BTREE, pos, NULL,
0, flags| 0, flags|
BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE| BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE|
BCH_BUCKET_MARK_GC_LOCK_HELD); BCH_BUCKET_MARK_GC_LOCK_HELD);
break; break;
case BKEY_TYPE_EXTENTS: case BKEY_TYPE_EXTENTS:
bch2_mark_key(c, k, k.k->size, false, pos, NULL, bch2_mark_key(c, k, k.k->size, BCH_DATA_USER, pos, NULL,
0, flags| 0, flags|
BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE| BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE|
BCH_BUCKET_MARK_GC_LOCK_HELD); BCH_BUCKET_MARK_GC_LOCK_HELD);
...@@ -398,7 +399,8 @@ static void bch2_mark_pending_btree_node_frees(struct bch_fs *c) ...@@ -398,7 +399,8 @@ static void bch2_mark_pending_btree_node_frees(struct bch_fs *c)
for_each_pending_btree_node_free(c, as, d) for_each_pending_btree_node_free(c, as, d)
if (d->index_update_done) if (d->index_update_done)
bch2_mark_key(c, bkey_i_to_s_c(&d->key), bch2_mark_key(c, bkey_i_to_s_c(&d->key),
c->opts.btree_node_size, true, pos, c->opts.btree_node_size,
BCH_DATA_BTREE, pos,
&stats, 0, &stats, 0,
BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE| BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE|
BCH_BUCKET_MARK_GC_LOCK_HELD); BCH_BUCKET_MARK_GC_LOCK_HELD);
......
...@@ -211,7 +211,7 @@ static void bch2_btree_node_free_index(struct btree_update *as, struct btree *b, ...@@ -211,7 +211,7 @@ static void bch2_btree_node_free_index(struct btree_update *as, struct btree *b,
struct bch_fs_usage tmp = { 0 }; struct bch_fs_usage tmp = { 0 };
bch2_mark_key(c, bkey_i_to_s_c(&d->key), bch2_mark_key(c, bkey_i_to_s_c(&d->key),
-c->opts.btree_node_size, true, b -c->opts.btree_node_size, BCH_DATA_BTREE, b
? gc_pos_btree_node(b) ? gc_pos_btree_node(b)
: gc_pos_btree_root(as->btree_id), : gc_pos_btree_root(as->btree_id),
&tmp, 0, 0); &tmp, 0, 0);
...@@ -290,7 +290,7 @@ static void bch2_btree_node_free_ondisk(struct bch_fs *c, ...@@ -290,7 +290,7 @@ static void bch2_btree_node_free_ondisk(struct bch_fs *c,
BUG_ON(!pending->index_update_done); BUG_ON(!pending->index_update_done);
bch2_mark_key(c, bkey_i_to_s_c(&pending->key), bch2_mark_key(c, bkey_i_to_s_c(&pending->key),
-c->opts.btree_node_size, true, -c->opts.btree_node_size, BCH_DATA_BTREE,
gc_phase(GC_PHASE_PENDING_DELETE), gc_phase(GC_PHASE_PENDING_DELETE),
&stats, 0, 0); &stats, 0, 0);
/* /*
...@@ -1098,7 +1098,7 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b) ...@@ -1098,7 +1098,7 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b)
__bch2_btree_set_root_inmem(c, b); __bch2_btree_set_root_inmem(c, b);
bch2_mark_key(c, bkey_i_to_s_c(&b->key), bch2_mark_key(c, bkey_i_to_s_c(&b->key),
c->opts.btree_node_size, true, c->opts.btree_node_size, BCH_DATA_BTREE,
gc_pos_btree_root(b->btree_id), gc_pos_btree_root(b->btree_id),
&stats, 0, 0); &stats, 0, 0);
...@@ -1186,7 +1186,7 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b ...@@ -1186,7 +1186,7 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b
if (bkey_extent_is_data(&insert->k)) if (bkey_extent_is_data(&insert->k))
bch2_mark_key(c, bkey_i_to_s_c(insert), bch2_mark_key(c, bkey_i_to_s_c(insert),
c->opts.btree_node_size, true, c->opts.btree_node_size, BCH_DATA_BTREE,
gc_pos_btree_node(b), &stats, 0, 0); gc_pos_btree_node(b), &stats, 0, 0);
while ((k = bch2_btree_node_iter_peek_all(node_iter, b)) && while ((k = bch2_btree_node_iter_peek_all(node_iter, b)) &&
...@@ -1967,7 +1967,7 @@ static void __bch2_btree_node_update_key(struct bch_fs *c, ...@@ -1967,7 +1967,7 @@ static void __bch2_btree_node_update_key(struct bch_fs *c,
bch2_btree_node_lock_write(b, iter); bch2_btree_node_lock_write(b, iter);
bch2_mark_key(c, bkey_i_to_s_c(&new_key->k_i), bch2_mark_key(c, bkey_i_to_s_c(&new_key->k_i),
c->opts.btree_node_size, true, c->opts.btree_node_size, BCH_DATA_BTREE,
gc_pos_btree_root(b->btree_id), gc_pos_btree_root(b->btree_id),
&stats, 0, 0); &stats, 0, 0);
bch2_btree_node_free_index(as, NULL, bch2_btree_node_free_index(as, NULL,
......
...@@ -512,15 +512,13 @@ static void bch2_mark_pointer(struct bch_fs *c, ...@@ -512,15 +512,13 @@ static void bch2_mark_pointer(struct bch_fs *c,
struct bkey_s_c_extent e, struct bkey_s_c_extent e,
const struct bch_extent_ptr *ptr, const struct bch_extent_ptr *ptr,
struct bch_extent_crc_unpacked crc, struct bch_extent_crc_unpacked crc,
s64 sectors, enum s_alloc type, s64 sectors, enum bch_data_type data_type,
struct bch_fs_usage *stats, struct bch_fs_usage *stats,
u64 journal_seq, unsigned flags) u64 journal_seq, unsigned flags)
{ {
struct bucket_mark old, new; struct bucket_mark old, new;
struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev); struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
struct bucket *g = PTR_BUCKET(ca, ptr); struct bucket *g = PTR_BUCKET(ca, ptr);
enum bch_data_type data_type = type == S_META
? BCH_DATA_BTREE : BCH_DATA_USER;
u64 v; u64 v;
if (crc.compression_type) { if (crc.compression_type) {
...@@ -596,7 +594,7 @@ static void bch2_mark_pointer(struct bch_fs *c, ...@@ -596,7 +594,7 @@ static void bch2_mark_pointer(struct bch_fs *c,
} }
void bch2_mark_key(struct bch_fs *c, struct bkey_s_c k, void bch2_mark_key(struct bch_fs *c, struct bkey_s_c k,
s64 sectors, bool metadata, s64 sectors, enum bch_data_type data_type,
struct gc_pos pos, struct gc_pos pos,
struct bch_fs_usage *stats, struct bch_fs_usage *stats,
u64 journal_seq, unsigned flags) u64 journal_seq, unsigned flags)
...@@ -643,14 +641,14 @@ void bch2_mark_key(struct bch_fs *c, struct bkey_s_c k, ...@@ -643,14 +641,14 @@ void bch2_mark_key(struct bch_fs *c, struct bkey_s_c k,
struct bkey_s_c_extent e = bkey_s_c_to_extent(k); struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
const struct bch_extent_ptr *ptr; const struct bch_extent_ptr *ptr;
struct bch_extent_crc_unpacked crc; struct bch_extent_crc_unpacked crc;
enum s_alloc type = metadata ? S_META : S_DIRTY; enum s_alloc type = data_type == BCH_DATA_USER
? S_DIRTY : S_META;
unsigned replicas = 0; unsigned replicas = 0;
BUG_ON(metadata && bkey_extent_is_cached(e.k));
BUG_ON(!sectors); BUG_ON(!sectors);
extent_for_each_ptr_crc(e, ptr, crc) { extent_for_each_ptr_crc(e, ptr, crc) {
bch2_mark_pointer(c, e, ptr, crc, sectors, type, bch2_mark_pointer(c, e, ptr, crc, sectors, data_type,
stats, journal_seq, flags); stats, journal_seq, flags);
replicas += !ptr->cached; replicas += !ptr->cached;
} }
......
...@@ -218,8 +218,8 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *, ...@@ -218,8 +218,8 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *,
#define BCH_BUCKET_MARK_GC_WILL_VISIT (1 << 2) #define BCH_BUCKET_MARK_GC_WILL_VISIT (1 << 2)
#define BCH_BUCKET_MARK_GC_LOCK_HELD (1 << 3) #define BCH_BUCKET_MARK_GC_LOCK_HELD (1 << 3)
void bch2_mark_key(struct bch_fs *, struct bkey_s_c, s64, bool, struct gc_pos, void bch2_mark_key(struct bch_fs *, struct bkey_s_c, s64, enum bch_data_type,
struct bch_fs_usage *, u64, unsigned); struct gc_pos, struct bch_fs_usage *, u64, unsigned);
void bch2_recalc_sectors_available(struct bch_fs *); void bch2_recalc_sectors_available(struct bch_fs *);
......
...@@ -1071,7 +1071,7 @@ static void bch2_add_sectors(struct extent_insert_state *s, ...@@ -1071,7 +1071,7 @@ static void bch2_add_sectors(struct extent_insert_state *s,
if (!sectors) if (!sectors)
return; return;
bch2_mark_key(c, k, sectors, false, gc_pos_btree_node(b), bch2_mark_key(c, k, sectors, BCH_DATA_USER, gc_pos_btree_node(b),
&s->stats, s->trans->journal_res.seq, 0); &s->stats, s->trans->journal_res.seq, 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