Skip to content

Commit e7f1a52

Browse files
author
Kent Overstreet
committed
bcachefs: Improve bch2_dev_bucket_missing()
More useful error message. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 0024664 commit e7f1a52

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

fs/bcachefs/sb-members.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ void bch2_dev_missing(struct bch_fs *c, unsigned dev)
1515
bch2_fs_inconsistent(c, "pointer to nonexistent device %u", dev);
1616
}
1717

18-
void bch2_dev_bucket_missing(struct bch_fs *c, struct bpos bucket)
18+
void bch2_dev_bucket_missing(struct bch_dev *ca, u64 bucket)
1919
{
20-
bch2_fs_inconsistent(c, "pointer to nonexistent bucket %llu:%llu", bucket.inode, bucket.offset);
20+
bch2_fs_inconsistent(ca->fs,
21+
"pointer to nonexistent bucket %llu on device %s (valid range %u-%llu)",
22+
bucket, ca->name, ca->mi.first_bucket, ca->mi.nbuckets);
2123
}
2224

2325
#define x(t, n, ...) [n] = #t,

fs/bcachefs/sb-members.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,23 @@ static inline struct bch_dev *bch2_dev_tryget(struct bch_fs *c, unsigned dev)
249249
static inline struct bch_dev *bch2_dev_bucket_tryget_noerror(struct bch_fs *c, struct bpos bucket)
250250
{
251251
struct bch_dev *ca = bch2_dev_tryget_noerror(c, bucket.inode);
252-
if (ca && !bucket_valid(ca, bucket.offset)) {
252+
if (ca && unlikely(!bucket_valid(ca, bucket.offset))) {
253253
bch2_dev_put(ca);
254254
ca = NULL;
255255
}
256256
return ca;
257257
}
258258

259-
void bch2_dev_bucket_missing(struct bch_fs *, struct bpos);
259+
void bch2_dev_bucket_missing(struct bch_dev *, u64);
260260

261261
static inline struct bch_dev *bch2_dev_bucket_tryget(struct bch_fs *c, struct bpos bucket)
262262
{
263-
struct bch_dev *ca = bch2_dev_bucket_tryget_noerror(c, bucket);
264-
if (!ca)
265-
bch2_dev_bucket_missing(c, bucket);
263+
struct bch_dev *ca = bch2_dev_tryget(c, bucket.inode);
264+
if (ca && unlikely(!bucket_valid(ca, bucket.offset))) {
265+
bch2_dev_bucket_missing(ca, bucket.offset);
266+
bch2_dev_put(ca);
267+
ca = NULL;
268+
}
266269
return ca;
267270
}
268271

0 commit comments

Comments
 (0)