Commit e4f72bb4 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix ec + durability calculation

Durability of an erasure coded pointer doesn't add the device
durability; durability is the same for any extent in that stripe so the
calculation only comes from the stripe.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 7d9f8468
...@@ -649,37 +649,31 @@ unsigned bch2_bkey_replicas(struct bch_fs *c, struct bkey_s_c k) ...@@ -649,37 +649,31 @@ unsigned bch2_bkey_replicas(struct bch_fs *c, struct bkey_s_c k)
return replicas; return replicas;
} }
unsigned bch2_extent_ptr_desired_durability(struct bch_fs *c, struct extent_ptr_decoded *p) static inline unsigned __extent_ptr_durability(struct bch_dev *ca, struct extent_ptr_decoded *p)
{ {
struct bch_dev *ca;
if (p->ptr.cached) if (p->ptr.cached)
return 0; return 0;
ca = bch_dev_bkey_exists(c, p->ptr.dev); return p->has_ec
? p->ec.redundancy + 1
return ca->mi.durability + : ca->mi.durability;
(p->has_ec
? p->ec.redundancy
: 0);
} }
unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded *p) unsigned bch2_extent_ptr_desired_durability(struct bch_fs *c, struct extent_ptr_decoded *p)
{ {
struct bch_dev *ca; struct bch_dev *ca = bch_dev_bkey_exists(c, p->ptr.dev);
if (p->ptr.cached) return __extent_ptr_durability(ca, p);
return 0; }
ca = bch_dev_bkey_exists(c, p->ptr.dev); unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded *p)
{
struct bch_dev *ca = bch_dev_bkey_exists(c, p->ptr.dev);
if (ca->mi.state == BCH_MEMBER_STATE_failed) if (ca->mi.state == BCH_MEMBER_STATE_failed)
return 0; return 0;
return ca->mi.durability + return __extent_ptr_durability(ca, p);
(p->has_ec
? p->ec.redundancy
: 0);
} }
unsigned bch2_bkey_durability(struct bch_fs *c, struct bkey_s_c k) unsigned bch2_bkey_durability(struct bch_fs *c, struct bkey_s_c k)
......
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