bcachefs: Improve bch2_dev_bucket_missing()

More useful error message.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet
2025-04-28 12:01:51 -04:00
parent 002466446a
commit e7f1a52849
2 changed files with 12 additions and 7 deletions
+4 -2
View File
@@ -15,9 +15,11 @@ void bch2_dev_missing(struct bch_fs *c, unsigned dev)
bch2_fs_inconsistent(c, "pointer to nonexistent device %u", dev);
}
void bch2_dev_bucket_missing(struct bch_fs *c, struct bpos bucket)
void bch2_dev_bucket_missing(struct bch_dev *ca, u64 bucket)
{
bch2_fs_inconsistent(c, "pointer to nonexistent bucket %llu:%llu", bucket.inode, bucket.offset);
bch2_fs_inconsistent(ca->fs,
"pointer to nonexistent bucket %llu on device %s (valid range %u-%llu)",
bucket, ca->name, ca->mi.first_bucket, ca->mi.nbuckets);
}
#define x(t, n, ...) [n] = #t,
+8 -5
View File
@@ -249,20 +249,23 @@ static inline struct bch_dev *bch2_dev_tryget(struct bch_fs *c, unsigned dev)
static inline struct bch_dev *bch2_dev_bucket_tryget_noerror(struct bch_fs *c, struct bpos bucket)
{
struct bch_dev *ca = bch2_dev_tryget_noerror(c, bucket.inode);
if (ca && !bucket_valid(ca, bucket.offset)) {
if (ca && unlikely(!bucket_valid(ca, bucket.offset))) {
bch2_dev_put(ca);
ca = NULL;
}
return ca;
}
void bch2_dev_bucket_missing(struct bch_fs *, struct bpos);
void bch2_dev_bucket_missing(struct bch_dev *, u64);
static inline struct bch_dev *bch2_dev_bucket_tryget(struct bch_fs *c, struct bpos bucket)
{
struct bch_dev *ca = bch2_dev_bucket_tryget_noerror(c, bucket);
if (!ca)
bch2_dev_bucket_missing(c, bucket);
struct bch_dev *ca = bch2_dev_tryget(c, bucket.inode);
if (ca && unlikely(!bucket_valid(ca, bucket.offset))) {
bch2_dev_bucket_missing(ca, bucket.offset);
bch2_dev_put(ca);
ca = NULL;
}
return ca;
}