]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: bch2_mark_key() now takes bch_data_type
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 24 Jul 2018 16:59:13 +0000 (12:59 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:08 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_update_interior.c
fs/bcachefs/buckets.c
fs/bcachefs/buckets.h
fs/bcachefs/extents.c

index 5053247a6b4222402f954a19e9d3c40bbe020fae..a82677d053b0747dffdc6f18c33af37938b63842 100644 (file)
@@ -123,13 +123,14 @@ static u8 bch2_gc_mark_key(struct bch_fs *c, enum bkey_type type,
 
        switch (type) {
        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|
                              BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE|
                              BCH_BUCKET_MARK_GC_LOCK_HELD);
                break;
        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|
                              BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE|
                              BCH_BUCKET_MARK_GC_LOCK_HELD);
@@ -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)
                if (d->index_update_done)
                        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,
                                      BCH_BUCKET_MARK_MAY_MAKE_UNAVAILABLE|
                                      BCH_BUCKET_MARK_GC_LOCK_HELD);
index bc667ac70f57f880bf2102da4dfdc6ff9a6092af..c0f1c77b340f6d7d774749f66e9583f6fc0f2eda 100644 (file)
@@ -211,7 +211,7 @@ found:
                struct bch_fs_usage tmp = { 0 };
 
                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_root(as->btree_id),
                             &tmp, 0, 0);
@@ -290,7 +290,7 @@ static void bch2_btree_node_free_ondisk(struct bch_fs *c,
        BUG_ON(!pending->index_update_done);
 
        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),
                     &stats, 0, 0);
        /*
@@ -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_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),
                      &stats, 0, 0);
 
@@ -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))
                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);
 
        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,
                bch2_btree_node_lock_write(b, iter);
 
                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),
                              &stats, 0, 0);
                bch2_btree_node_free_index(as, NULL,
index 65232f5e61bcca64888016b198c8182b6e0a6663..06ef268fd9917831d0277afa730463053a231977 100644 (file)
@@ -512,15 +512,13 @@ static void bch2_mark_pointer(struct bch_fs *c,
                              struct bkey_s_c_extent e,
                              const struct bch_extent_ptr *ptr,
                              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,
                              u64 journal_seq, unsigned flags)
 {
        struct bucket_mark old, new;
        struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
        struct bucket *g = PTR_BUCKET(ca, ptr);
-       enum bch_data_type data_type = type == S_META
-               ? BCH_DATA_BTREE : BCH_DATA_USER;
        u64 v;
 
        if (crc.compression_type) {
@@ -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,
-                  s64 sectors, bool metadata,
+                  s64 sectors, enum bch_data_type data_type,
                   struct gc_pos pos,
                   struct bch_fs_usage *stats,
                   u64 journal_seq, unsigned flags)
@@ -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);
                const struct bch_extent_ptr *ptr;
                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;
 
-               BUG_ON(metadata && bkey_extent_is_cached(e.k));
                BUG_ON(!sectors);
 
                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);
                        replicas += !ptr->cached;
                }
index 2671ad29edf9780c1d928d84442759e85682b1e9..6b312d32238944eb4161585cc265e1a98f6a61e2 100644 (file)
@@ -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_LOCK_HELD           (1 << 3)
 
-void bch2_mark_key(struct bch_fs *, struct bkey_s_c, s64, bool, struct gc_pos,
-                  struct bch_fs_usage *, u64, unsigned);
+void bch2_mark_key(struct bch_fs *, struct bkey_s_c, s64, enum bch_data_type,
+                  struct gc_pos, struct bch_fs_usage *, u64, unsigned);
 
 void bch2_recalc_sectors_available(struct bch_fs *);
 
index e0150fbe85afdbd8e3965b079595dc47fe62753b..276545dfa2462dd5274511bf2741209893e24d92 100644 (file)
@@ -1071,7 +1071,7 @@ static void bch2_add_sectors(struct extent_insert_state *s,
        if (!sectors)
                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);
 }