bcachefs: Add BCH_BKEY_PTRS_MAX
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 16 Dec 2020 19:23:27 +0000 (14:23 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:50 +0000 (17:08 -0400)
This now means "the maximum number of pointers within a bkey" - and
bch_devs_list is updated to use it instead of BCH_REPLICAS_MAX, since
stripes can contain more than BCH_REPLICAS_MAX pointers.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs_format.h
fs/bcachefs/ec.c
fs/bcachefs/ec.h
fs/bcachefs/ec_types.h
fs/bcachefs/super_types.h

index 7df2bc7ecd4f49320648316db117d92f85fa9b68..3f8281b5db4177f72627d6f6f790bf5501393bf0 100644 (file)
@@ -1363,6 +1363,8 @@ enum bch_sb_compat {
 
 #define BCH_REPLICAS_MAX               4U
 
+#define BCH_BKEY_PTRS_MAX              16U
+
 enum bch_error_actions {
        BCH_ON_ERROR_CONTINUE           = 0,
        BCH_ON_ERROR_RO                 = 1,
index db1c652f1ed4bca788c32d9735418dfe73e5f382..95abc00bd0e017e80117b2d0410271bbe436b5d0 100644 (file)
@@ -300,7 +300,7 @@ static unsigned ec_nr_failed(struct ec_stripe_buf *buf)
 static int ec_do_recov(struct bch_fs *c, struct ec_stripe_buf *buf)
 {
        struct bch_stripe *v = &buf->key.v;
-       unsigned i, failed[EC_STRIPE_MAX], nr_failed = 0;
+       unsigned i, failed[BCH_BKEY_PTRS_MAX], nr_failed = 0;
        unsigned nr_data = v->nr_blocks - v->nr_redundant;
        unsigned bytes = buf->size << 9;
 
@@ -1101,7 +1101,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h)
        s->c            = c;
        s->h            = h;
        s->nr_data      = min_t(unsigned, h->nr_active_devs,
-                               EC_STRIPE_MAX) - h->redundancy;
+                               BCH_BKEY_PTRS_MAX) - h->redundancy;
        s->nr_parity    = h->redundancy;
 
        bch2_keylist_init(&s->keys, s->inline_keys);
@@ -1211,13 +1211,13 @@ static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h)
        struct open_bucket *ob;
        unsigned i, nr_have, nr_data =
                min_t(unsigned, h->nr_active_devs,
-                     EC_STRIPE_MAX) - h->redundancy;
+                     BCH_BKEY_PTRS_MAX) - h->redundancy;
        bool have_cache = true;
        int ret = 0;
 
        devs = h->devs;
 
-       for_each_set_bit(i, h->s->blocks_allocated, EC_STRIPE_MAX) {
+       for_each_set_bit(i, h->s->blocks_allocated, BCH_BKEY_PTRS_MAX) {
                __clear_bit(h->s->stripe.key.v.ptrs[i].dev, devs.d);
                --nr_data;
        }
index 15f751fc2a35d32bea03efde0cf5cbbd332bb41a..450bb1a113a30c200db219525076a7522d34b275 100644 (file)
@@ -71,9 +71,9 @@ struct ec_stripe_buf {
        /* might not be buffering the entire stripe: */
        unsigned                offset;
        unsigned                size;
-       unsigned long           valid[BITS_TO_LONGS(EC_STRIPE_MAX)];
+       unsigned long           valid[BITS_TO_LONGS(BCH_BKEY_PTRS_MAX)];
 
-       void                    *data[EC_STRIPE_MAX];
+       void                    *data[BCH_BKEY_PTRS_MAX];
 
        union {
                struct bkey_i_stripe    key;
@@ -101,10 +101,10 @@ struct ec_stripe_new {
        bool                    existing_stripe;
        u64                     existing_stripe_idx;
 
-       unsigned long           blocks_allocated[BITS_TO_LONGS(EC_STRIPE_MAX)];
+       unsigned long           blocks_allocated[BITS_TO_LONGS(BCH_BKEY_PTRS_MAX)];
 
        struct open_buckets     blocks;
-       u8                      data_block_idx[EC_STRIPE_MAX];
+       u8                      data_block_idx[BCH_BKEY_PTRS_MAX];
        struct open_buckets     parity;
        struct disk_reservation res;
 
index e4d633fca5bf913a78a4d78168141dc1458fdaf1..5b688b4394f788a8ec2accbce2365d1c7d45f76f 100644 (file)
@@ -4,11 +4,9 @@
 
 #include <linux/llist.h>
 
-#define EC_STRIPE_MAX  16
-
 struct bch_replicas_padded {
        struct bch_replicas_entry       e;
-       u8                              pad[EC_STRIPE_MAX];
+       u8                              pad[BCH_BKEY_PTRS_MAX];
 };
 
 struct stripe {
@@ -24,7 +22,7 @@ struct stripe {
        unsigned                dirty:1;
        unsigned                on_heap:1;
        u8                      blocks_nonempty;
-       u16                     block_sectors[EC_STRIPE_MAX];
+       u16                     block_sectors[BCH_BKEY_PTRS_MAX];
 
        struct bch_replicas_padded r;
 };
index 6d0168a73ee47d7d66a82006a058ef129820d300..e3a989e3e9d91e28834d34f8f278425f84a47562 100644 (file)
@@ -21,7 +21,7 @@ struct bch_devs_mask {
 
 struct bch_devs_list {
        u8                      nr;
-       u8                      devs[BCH_REPLICAS_MAX + 1];
+       u8                      devs[BCH_BKEY_PTRS_MAX];
 };
 
 struct bch_member_cpu {