Skip to content

Commit a2ddaf9

Browse files
author
Kent Overstreet
committed
bcachefs: bucket_pos_to_bp_noerror()
We don't want the assert when we're checking if the backpointer is valid. Reported-by: syzbot+bf7215c0525098e7747a@syzkaller.appspotmail.com Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 7ffec9c commit a2ddaf9

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

fs/bcachefs/backpointers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int bch2_backpointer_invalid(struct bch_fs *c, struct bkey_s_c k,
5454
int ret = 0;
5555

5656
bkey_fsck_err_on((bp.v->bucket_offset >> MAX_EXTENT_COMPRESS_RATIO_SHIFT) >= ca->mi.bucket_size ||
57-
!bpos_eq(bp.k->p, bucket_pos_to_bp(c, bucket, bp.v->bucket_offset)),
57+
!bpos_eq(bp.k->p, bucket_pos_to_bp_noerror(ca, bucket, bp.v->bucket_offset)),
5858
c, err,
5959
backpointer_bucket_offset_wrong,
6060
"backpointer bucket_offset wrong");

fs/bcachefs/backpointers.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ static inline struct bpos bp_pos_to_bucket(const struct bch_fs *c,
4545
return POS(bp_pos.inode, sector_to_bucket(ca, bucket_sector));
4646
}
4747

48+
static inline struct bpos bucket_pos_to_bp_noerror(const struct bch_dev *ca,
49+
struct bpos bucket,
50+
u64 bucket_offset)
51+
{
52+
return POS(bucket.inode,
53+
(bucket_to_sector(ca, bucket.offset) <<
54+
MAX_EXTENT_COMPRESS_RATIO_SHIFT) + bucket_offset);
55+
}
56+
4857
/*
4958
* Convert from pos in alloc btree + bucket offset to pos in backpointer btree:
5059
*/
@@ -53,10 +62,7 @@ static inline struct bpos bucket_pos_to_bp(const struct bch_fs *c,
5362
u64 bucket_offset)
5463
{
5564
struct bch_dev *ca = bch_dev_bkey_exists(c, bucket.inode);
56-
struct bpos ret = POS(bucket.inode,
57-
(bucket_to_sector(ca, bucket.offset) <<
58-
MAX_EXTENT_COMPRESS_RATIO_SHIFT) + bucket_offset);
59-
65+
struct bpos ret = bucket_pos_to_bp_noerror(ca, bucket, bucket_offset);
6066
EBUG_ON(!bkey_eq(bucket, bp_pos_to_bucket(c, ret)));
6167
return ret;
6268
}

0 commit comments

Comments
 (0)