Commit 52df04f0 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: More BCH_SB_MEMBER_INVALID support

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent df88febc
...@@ -100,12 +100,13 @@ static int bch2_check_fix_ptr(struct btree_trans *trans, ...@@ -100,12 +100,13 @@ static int bch2_check_fix_ptr(struct btree_trans *trans,
struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev); struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);
if (!ca) { if (!ca) {
if (fsck_err(trans, ptr_to_invalid_device, if (fsck_err_on(p.ptr.dev != BCH_SB_MEMBER_INVALID,
"pointer to missing device %u\n" trans, ptr_to_invalid_device,
"while marking %s", "pointer to missing device %u\n"
p.ptr.dev, "while marking %s",
(printbuf_reset(&buf), p.ptr.dev,
bch2_bkey_val_to_text(&buf, c, k), buf.buf))) (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
*do_update = true; *do_update = true;
return 0; return 0;
} }
...@@ -562,7 +563,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans, ...@@ -562,7 +563,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev); struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);
if (unlikely(!ca)) { if (unlikely(!ca)) {
if (insert) if (insert && p.ptr.dev != BCH_SB_MEMBER_INVALID)
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
......
...@@ -97,7 +97,9 @@ static inline bool __bch2_ptr_matches_stripe(const struct bch_extent_ptr *stripe ...@@ -97,7 +97,9 @@ static inline bool __bch2_ptr_matches_stripe(const struct bch_extent_ptr *stripe
const struct bch_extent_ptr *data_ptr, const struct bch_extent_ptr *data_ptr,
unsigned sectors) unsigned sectors)
{ {
return data_ptr->dev == stripe_ptr->dev && return (data_ptr->dev == stripe_ptr->dev ||
data_ptr->dev == BCH_SB_MEMBER_INVALID ||
stripe_ptr->dev == BCH_SB_MEMBER_INVALID) &&
data_ptr->gen == stripe_ptr->gen && data_ptr->gen == stripe_ptr->gen &&
data_ptr->offset >= stripe_ptr->offset && data_ptr->offset >= stripe_ptr->offset &&
data_ptr->offset < stripe_ptr->offset + sectors; data_ptr->offset < stripe_ptr->offset + sectors;
......
...@@ -787,6 +787,11 @@ void bch2_bkey_drop_ptr_noerror(struct bkey_s k, struct bch_extent_ptr *ptr) ...@@ -787,6 +787,11 @@ void bch2_bkey_drop_ptr_noerror(struct bkey_s k, struct bch_extent_ptr *ptr)
union bch_extent_entry *entry = to_entry(ptr), *next; union bch_extent_entry *entry = to_entry(ptr), *next;
bool drop_crc = true; bool drop_crc = true;
if (k.k->type == KEY_TYPE_stripe) {
ptr->dev = BCH_SB_MEMBER_INVALID;
return;
}
EBUG_ON(ptr < &ptrs.start->ptr || EBUG_ON(ptr < &ptrs.start->ptr ||
ptr >= &ptrs.end->ptr); ptr >= &ptrs.end->ptr);
EBUG_ON(ptr->type != 1 << BCH_EXTENT_ENTRY_ptr); EBUG_ON(ptr->type != 1 << BCH_EXTENT_ENTRY_ptr);
......
...@@ -796,7 +796,7 @@ bool bch2_have_enough_devs(struct bch_fs *c, struct bch_devs_mask devs, ...@@ -796,7 +796,7 @@ bool bch2_have_enough_devs(struct bch_fs *c, struct bch_devs_mask devs,
nr_online += test_bit(e->devs[i], devs.d); nr_online += test_bit(e->devs[i], devs.d);
struct bch_dev *ca = bch2_dev_rcu(c, e->devs[i]); struct bch_dev *ca = bch2_dev_rcu(c, e->devs[i]);
nr_failed += ca && ca->mi.state == BCH_MEMBER_STATE_failed; nr_failed += !ca || ca->mi.state == BCH_MEMBER_STATE_failed;
} }
rcu_read_unlock(); rcu_read_unlock();
......
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