Skip to content

Commit e4f72bb

Browse files
author
Kent Overstreet
committed
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: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 7d9f846 commit e4f72bb

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

fs/bcachefs/extents.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -649,37 +649,31 @@ unsigned bch2_bkey_replicas(struct bch_fs *c, struct bkey_s_c k)
649649
return replicas;
650650
}
651651

652-
unsigned bch2_extent_ptr_desired_durability(struct bch_fs *c, struct extent_ptr_decoded *p)
652+
static inline unsigned __extent_ptr_durability(struct bch_dev *ca, struct extent_ptr_decoded *p)
653653
{
654-
struct bch_dev *ca;
655-
656654
if (p->ptr.cached)
657655
return 0;
658656

659-
ca = bch_dev_bkey_exists(c, p->ptr.dev);
660-
661-
return ca->mi.durability +
662-
(p->has_ec
663-
? p->ec.redundancy
664-
: 0);
657+
return p->has_ec
658+
? p->ec.redundancy + 1
659+
: ca->mi.durability;
665660
}
666661

667-
unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded *p)
662+
unsigned bch2_extent_ptr_desired_durability(struct bch_fs *c, struct extent_ptr_decoded *p)
668663
{
669-
struct bch_dev *ca;
664+
struct bch_dev *ca = bch_dev_bkey_exists(c, p->ptr.dev);
670665

671-
if (p->ptr.cached)
672-
return 0;
666+
return __extent_ptr_durability(ca, p);
667+
}
673668

674-
ca = bch_dev_bkey_exists(c, p->ptr.dev);
669+
unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded *p)
670+
{
671+
struct bch_dev *ca = bch_dev_bkey_exists(c, p->ptr.dev);
675672

676673
if (ca->mi.state == BCH_MEMBER_STATE_failed)
677674
return 0;
678675

679-
return ca->mi.durability +
680-
(p->has_ec
681-
? p->ec.redundancy
682-
: 0);
676+
return __extent_ptr_durability(ca, p);
683677
}
684678

685679
unsigned bch2_bkey_durability(struct bch_fs *c, struct bkey_s_c k)

0 commit comments

Comments
 (0)