From: Kent Overstreet Date: Sat, 8 Mar 2025 16:37:51 +0000 (-0500) Subject: bcachefs: BCH_ERR_data_read_buffer_too_small X-Git-Tag: v6.15-rc1~146^2~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=881b598ef144a1dee3850be9e6b9ecfcfc5bf4b0;p=thirdparty%2Flinux.git bcachefs: BCH_ERR_data_read_buffer_too_small Now that the read path uses proper error codes, we can get rid of the weird rbio->hole signalling to the move path that the read didn't happen. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h index 5050d978624b7..afa16d58041eb 100644 --- a/fs/bcachefs/errcode.h +++ b/fs/bcachefs/errcode.h @@ -295,6 +295,8 @@ x(BCH_ERR_data_read, data_read_ptr_stale_race) \ x(BCH_ERR_data_read_retry, data_read_ptr_stale_retry) \ x(BCH_ERR_data_read, data_read_no_encryption_key) \ + x(BCH_ERR_data_read, data_read_buffer_too_small) \ + x(BCH_ERR_data_read, data_read_key_overwritten) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \ diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c index a7865f34ea354..d1497af58180b 100644 --- a/fs/bcachefs/io_read.c +++ b/fs/bcachefs/io_read.c @@ -443,7 +443,7 @@ retry: if (!bkey_and_val_eq(k, bkey_i_to_s_c(u->k.k))) { /* extent we wanted to read no longer exists: */ - rbio->hole = true; + rbio->ret = -BCH_ERR_data_read_key_overwritten; goto err; } @@ -1000,10 +1000,10 @@ retry_pick: */ struct data_update *u = container_of(orig, struct data_update, rbio); if (pick.crc.compressed_size > u->op.wbio.bio.bi_iter.bi_size) { - BUG(); if (ca) percpu_ref_put(&ca->io_ref); - goto hole; + rbio->ret = -BCH_ERR_data_read_buffer_too_small; + goto out_read_done; } iter.bi_size = pick.crc.compressed_size << 9; @@ -1083,7 +1083,6 @@ retry_pick: rbio->flags = flags; rbio->have_ioref = ca != NULL; rbio->narrow_crcs = narrow_crcs; - rbio->hole = 0; rbio->ret = 0; rbio->context = 0; rbio->pick = pick; @@ -1215,7 +1214,7 @@ hole: * to read no longer exists we have to signal that: */ if (flags & BCH_READ_data_update) - orig->hole = true; + orig->ret = -BCH_ERR_data_read_key_overwritten; zero_fill_bio_iter(&orig->bio, iter); out_read_done: diff --git a/fs/bcachefs/io_read.h b/fs/bcachefs/io_read.h index 1eb01e9847d75..924406558f781 100644 --- a/fs/bcachefs/io_read.h +++ b/fs/bcachefs/io_read.h @@ -40,7 +40,6 @@ struct bch_read_bio { split:1, have_ioref:1, narrow_crcs:1, - hole:1, saw_error:1, context:2; }; diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index f86fb8ad636a8..307b918fa2e7a 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -125,8 +125,8 @@ static void move_write(struct moving_io *io) &ctxt->stats->sectors_error_corrected); } - if (unlikely(io->write.rbio.bio.bi_status || - io->write.rbio.hole || + if (unlikely(io->write.rbio.ret || + io->write.rbio.bio.bi_status || io->write.data_opts.scrub)) { move_free(io); return;