Commit 99179fb8 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Invalid devices are now checked for by fsck, not .invalid methods

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2f4b4a3b
...@@ -1101,22 +1101,8 @@ static int extent_ptr_invalid(struct bch_fs *c, ...@@ -1101,22 +1101,8 @@ static int extent_ptr_invalid(struct bch_fs *c,
bool metadata, bool metadata,
struct printbuf *err) struct printbuf *err)
{ {
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
int ret = 0; int ret = 0;
if (!bch2_dev_exists(c, ptr->dev)) {
/*
* If we're in the write path this key might have already been
* overwritten, and we could be seeing a device that doesn't
* exist anymore due to racing with device removal:
*/
if (flags & BKEY_INVALID_WRITE)
return 0;
bkey_fsck_err(c, err, ptr_to_invalid_device,
"pointer to invalid device (%u)", ptr->dev);
}
rcu_read_lock(); rcu_read_lock();
struct bch_dev *ca = bch2_dev_rcu(c, ptr->dev); struct bch_dev *ca = bch2_dev_rcu(c, ptr->dev);
if (!ca) { if (!ca) {
...@@ -1130,6 +1116,7 @@ static int extent_ptr_invalid(struct bch_fs *c, ...@@ -1130,6 +1116,7 @@ static int extent_ptr_invalid(struct bch_fs *c,
unsigned bucket_size = ca->mi.bucket_size; unsigned bucket_size = ca->mi.bucket_size;
rcu_read_unlock(); rcu_read_unlock();
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
bkey_for_each_ptr(ptrs, ptr2) bkey_for_each_ptr(ptrs, ptr2)
bkey_fsck_err_on(ptr != ptr2 && ptr->dev == ptr2->dev, c, err, bkey_fsck_err_on(ptr != ptr2 && ptr->dev == ptr2->dev, c, err,
ptr_to_duplicate_device, ptr_to_duplicate_device,
......
...@@ -690,7 +690,6 @@ static int journal_entry_dev_usage_validate(struct bch_fs *c, ...@@ -690,7 +690,6 @@ static int journal_entry_dev_usage_validate(struct bch_fs *c,
container_of(entry, struct jset_entry_dev_usage, entry); container_of(entry, struct jset_entry_dev_usage, entry);
unsigned bytes = jset_u64s(le16_to_cpu(entry->u64s)) * sizeof(u64); unsigned bytes = jset_u64s(le16_to_cpu(entry->u64s)) * sizeof(u64);
unsigned expected = sizeof(*u); unsigned expected = sizeof(*u);
unsigned dev;
int ret = 0; int ret = 0;
if (journal_entry_err_on(bytes < expected, if (journal_entry_err_on(bytes < expected,
...@@ -702,16 +701,6 @@ static int journal_entry_dev_usage_validate(struct bch_fs *c, ...@@ -702,16 +701,6 @@ static int journal_entry_dev_usage_validate(struct bch_fs *c,
return ret; return ret;
} }
dev = le32_to_cpu(u->dev);
if (journal_entry_err_on(!bch2_dev_exists(c, dev),
c, version, jset, entry,
journal_entry_dev_usage_bad_dev,
"bad dev")) {
journal_entry_null_range(entry, vstruct_next(entry));
return ret;
}
if (journal_entry_err_on(u->pad, if (journal_entry_err_on(u->pad,
c, version, jset, entry, c, version, jset, entry,
journal_entry_dev_usage_bad_pad, journal_entry_dev_usage_bad_pad,
......
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