Skip to content

Commit 765b8cb

Browse files
author
Kent Overstreet
committed
bcachefs: Check for subvolues with bogus snapshot/inode fields
This fixes an assertion pop in btree_iter.c that checks for forgetting to pass a snapshot ID when iterating over snapshots btrees. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 6b74fdc commit 765b8cb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

fs/bcachefs/sb-errors_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@
273273
x(dup_backpointer_to_bad_csum_extent, 265) \
274274
x(btree_bitmap_not_marked, 266) \
275275
x(sb_clean_entry_overrun, 267) \
276-
x(btree_ptr_v2_written_0, 268)
276+
x(btree_ptr_v2_written_0, 268) \
277+
x(subvol_snapshot_bad, 269) \
278+
x(subvol_inode_bad, 270)
277279

278280
enum bch_sb_error_id {
279281
#define x(t, n) BCH_FSCK_ERR_##t = n,

fs/bcachefs/subvolume.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,21 @@ int bch2_check_subvol_children(struct bch_fs *c)
210210
int bch2_subvolume_invalid(struct bch_fs *c, struct bkey_s_c k,
211211
enum bch_validate_flags flags, struct printbuf *err)
212212
{
213+
struct bkey_s_c_subvolume subvol = bkey_s_c_to_subvolume(k);
213214
int ret = 0;
214215

215216
bkey_fsck_err_on(bkey_lt(k.k->p, SUBVOL_POS_MIN) ||
216217
bkey_gt(k.k->p, SUBVOL_POS_MAX), c, err,
217218
subvol_pos_bad,
218219
"invalid pos");
220+
221+
bkey_fsck_err_on(!subvol.v->snapshot, c, err,
222+
subvol_snapshot_bad,
223+
"invalid snapshot");
224+
225+
bkey_fsck_err_on(!subvol.v->inode, c, err,
226+
subvol_inode_bad,
227+
"invalid inode");
219228
fsck_err:
220229
return ret;
221230
}

0 commit comments

Comments
 (0)