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

bcachefs: Add BCH_BKEY_PTRS_MAX

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent ded54580
...@@ -1363,6 +1363,8 @@ enum bch_sb_compat { ...@@ -1363,6 +1363,8 @@ enum bch_sb_compat {
#define BCH_REPLICAS_MAX 4U #define BCH_REPLICAS_MAX 4U
#define BCH_BKEY_PTRS_MAX 16U
enum bch_error_actions { enum bch_error_actions {
BCH_ON_ERROR_CONTINUE = 0, BCH_ON_ERROR_CONTINUE = 0,
BCH_ON_ERROR_RO = 1, BCH_ON_ERROR_RO = 1,
......
...@@ -300,7 +300,7 @@ static unsigned ec_nr_failed(struct ec_stripe_buf *buf) ...@@ -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) static int ec_do_recov(struct bch_fs *c, struct ec_stripe_buf *buf)
{ {
struct bch_stripe *v = &buf->key.v; 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 nr_data = v->nr_blocks - v->nr_redundant;
unsigned bytes = buf->size << 9; unsigned bytes = buf->size << 9;
...@@ -1101,7 +1101,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h) ...@@ -1101,7 +1101,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h)
s->c = c; s->c = c;
s->h = h; s->h = h;
s->nr_data = min_t(unsigned, h->nr_active_devs, 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; s->nr_parity = h->redundancy;
bch2_keylist_init(&s->keys, s->inline_keys); 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) ...@@ -1211,13 +1211,13 @@ static int new_stripe_alloc_buckets(struct bch_fs *c, struct ec_stripe_head *h)
struct open_bucket *ob; struct open_bucket *ob;
unsigned i, nr_have, nr_data = unsigned i, nr_have, nr_data =
min_t(unsigned, h->nr_active_devs, min_t(unsigned, h->nr_active_devs,
EC_STRIPE_MAX) - h->redundancy; BCH_BKEY_PTRS_MAX) - h->redundancy;
bool have_cache = true; bool have_cache = true;
int ret = 0; int ret = 0;
devs = h->devs; 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); __clear_bit(h->s->stripe.key.v.ptrs[i].dev, devs.d);
--nr_data; --nr_data;
} }
......
...@@ -71,9 +71,9 @@ struct ec_stripe_buf { ...@@ -71,9 +71,9 @@ struct ec_stripe_buf {
/* might not be buffering the entire stripe: */ /* might not be buffering the entire stripe: */
unsigned offset; unsigned offset;
unsigned size; 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 { union {
struct bkey_i_stripe key; struct bkey_i_stripe key;
...@@ -101,10 +101,10 @@ struct ec_stripe_new { ...@@ -101,10 +101,10 @@ struct ec_stripe_new {
bool existing_stripe; bool existing_stripe;
u64 existing_stripe_idx; 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; struct open_buckets blocks;
u8 data_block_idx[EC_STRIPE_MAX]; u8 data_block_idx[BCH_BKEY_PTRS_MAX];
struct open_buckets parity; struct open_buckets parity;
struct disk_reservation res; struct disk_reservation res;
......
...@@ -4,11 +4,9 @@ ...@@ -4,11 +4,9 @@
#include <linux/llist.h> #include <linux/llist.h>
#define EC_STRIPE_MAX 16
struct bch_replicas_padded { struct bch_replicas_padded {
struct bch_replicas_entry e; struct bch_replicas_entry e;
u8 pad[EC_STRIPE_MAX]; u8 pad[BCH_BKEY_PTRS_MAX];
}; };
struct stripe { struct stripe {
...@@ -24,7 +22,7 @@ struct stripe { ...@@ -24,7 +22,7 @@ struct stripe {
unsigned dirty:1; unsigned dirty:1;
unsigned on_heap:1; unsigned on_heap:1;
u8 blocks_nonempty; u8 blocks_nonempty;
u16 block_sectors[EC_STRIPE_MAX]; u16 block_sectors[BCH_BKEY_PTRS_MAX];
struct bch_replicas_padded r; struct bch_replicas_padded r;
}; };
......
...@@ -21,7 +21,7 @@ struct bch_devs_mask { ...@@ -21,7 +21,7 @@ struct bch_devs_mask {
struct bch_devs_list { struct bch_devs_list {
u8 nr; u8 nr;
u8 devs[BCH_REPLICAS_MAX + 1]; u8 devs[BCH_BKEY_PTRS_MAX];
}; };
struct bch_member_cpu { struct bch_member_cpu {
......
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