diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-06-13 15:12:04 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:04 -0400 |
commit | 91ecd41b7f02b95279dddcb2193af454efd39497 (patch) | |
tree | 2aa5f8fecb243e4e32ae85a23d94ce631c403f3f /fs/bcachefs/extents.c | |
parent | 253748a26a14ae22123f3ab670ae04eb15fccc2e (diff) | |
download | lwn-91ecd41b7f02b95279dddcb2193af454efd39497.tar.gz lwn-91ecd41b7f02b95279dddcb2193af454efd39497.zip |
bcachefs: bch2_extent_ptr_desired_durability()
This adds a new helper for getting a pointer's durability irrespective
of the device state, and uses it in the the data update path.
This fixes a bug where we do a data update but request 0 replicas to be
allocated, because the replica being rewritten is on a device marked as
failed.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/extents.c')
-rw-r--r-- | fs/bcachefs/extents.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index e2b126ad2bab..7e00550980de 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -641,9 +641,8 @@ unsigned bch2_bkey_replicas(struct bch_fs *c, struct bkey_s_c k) return replicas; } -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) { - unsigned durability = 0; struct bch_dev *ca; if (p->ptr.cached) @@ -651,13 +650,28 @@ unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded ca = bch_dev_bkey_exists(c, p->ptr.dev); - if (ca->mi.state != BCH_MEMBER_STATE_failed) - durability = max_t(unsigned, durability, ca->mi.durability); + return ca->mi.durability + + (p->has_ec + ? p->ec.redundancy + : 0); +} - if (p->has_ec) - durability += p->ec.redundancy; +unsigned bch2_extent_ptr_durability(struct bch_fs *c, struct extent_ptr_decoded *p) +{ + struct bch_dev *ca; - return durability; + if (p->ptr.cached) + return 0; + + ca = bch_dev_bkey_exists(c, p->ptr.dev); + + if (ca->mi.state == BCH_MEMBER_STATE_failed) + return 0; + + return ca->mi.durability + + (p->has_ec + ? p->ec.redundancy + : 0); } unsigned bch2_bkey_durability(struct bch_fs *c, struct bkey_s_c k) |