Skip to content

Commit 3c72d3e

Browse files
author
Kent Overstreet
committed
bcachefs: Fix WARN() in bch2_bkey_pick_read_device()
syzbot discovered that this one is possible: we have pointers, but none of them are to valid devices. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent af3d4c2 commit 3c72d3e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

fs/bcachefs/errcode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310
x(BCH_ERR_data_write, data_write_misaligned) \
311311
x(BCH_ERR_decompress, data_read) \
312312
x(BCH_ERR_data_read, no_device_to_read_from) \
313+
x(BCH_ERR_data_read, no_devices_valid) \
313314
x(BCH_ERR_data_read, data_read_io_err) \
314315
x(BCH_ERR_data_read, data_read_csum_err) \
315316
x(BCH_ERR_data_read, data_read_retry) \

fs/bcachefs/extents.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,11 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
227227
if (have_io_errors)
228228
return -BCH_ERR_data_read_io_err;
229229

230-
WARN_ONCE(1, "unhandled error case in %s\n", __func__);
231-
return -EINVAL;
230+
/*
231+
* If we get here, we have pointers (bkey_ptrs_validate() ensures that),
232+
* but they don't point to valid devices:
233+
*/
234+
return -BCH_ERR_no_devices_valid;
232235
}
233236

234237
/* KEY_TYPE_btree_ptr: */

0 commit comments

Comments
 (0)