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

bcachefs: More BCH_SB_MEMBER_INVALID support

parent df88febc
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -100,7 +100,8 @@ static int bch2_check_fix_ptr(struct btree_trans *trans,

	struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);
	if (!ca) {
		if (fsck_err(trans, ptr_to_invalid_device,
		if (fsck_err_on(p.ptr.dev != BCH_SB_MEMBER_INVALID,
				trans, ptr_to_invalid_device,
				"pointer to missing device %u\n"
				"while marking %s",
				p.ptr.dev,
@@ -562,7 +563,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
	struct bch_fs *c = trans->c;
	struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);
	if (unlikely(!ca)) {
		if (insert)
		if (insert && p.ptr.dev != BCH_SB_MEMBER_INVALID)
			ret = -EIO;
		goto err;
	}
+3 −1
Original line number Diff line number Diff line
@@ -97,7 +97,9 @@ static inline bool __bch2_ptr_matches_stripe(const struct bch_extent_ptr *stripe
					     const struct bch_extent_ptr *data_ptr,
					     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->offset >= stripe_ptr->offset &&
		data_ptr->offset  < stripe_ptr->offset + sectors;
+5 −0
Original line number Diff line number Diff line
@@ -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;
	bool drop_crc = true;

	if (k.k->type == KEY_TYPE_stripe) {
		ptr->dev = BCH_SB_MEMBER_INVALID;
		return;
	}

	EBUG_ON(ptr < &ptrs.start->ptr ||
		ptr >= &ptrs.end->ptr);
	EBUG_ON(ptr->type != 1 << BCH_EXTENT_ENTRY_ptr);
+1 −1
Original line number Diff line number Diff line
@@ -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);

			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();