summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-03-11 09:04:09 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-03-16 13:47:55 -0400
commite75993b0bf8baa48b2e96d693852191f63b615fd (patch)
treeff9eeba1dae84fb3054a8aa7050c132d26173cdd
parent943f0cfb1559ac6c9fc9082998f20dfe2aa01a74 (diff)
bcachefs: Fix BCH_ERR_data_read_csum_err_maybe_userspace in retry path
When we do a read to a buffer that's mapped into userspace, it's possible to get a spurious checksum error if userspace was modified the buffer at the same time. When we retry those, they have to be bounced before we know definitively whether we're reading corrupt data. But the retry path propagates read flags differently, so needs special handling. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/io_read.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c
index 797c29bde9b6..17bc413c27ba 100644
--- a/fs/bcachefs/io_read.c
+++ b/fs/bcachefs/io_read.c
@@ -1291,6 +1291,9 @@ void __bch2_read(struct bch_fs *c, struct bch_read_bio *rbio,
swap(bvec_iter.bi_size, bytes);
bio_advance_iter(&rbio->bio, &bvec_iter, bytes);
err:
+ if (ret == -BCH_ERR_data_read_retry_csum_err_maybe_userspace)
+ flags |= BCH_READ_must_bounce;
+
if (ret &&
!bch2_err_matches(ret, BCH_ERR_transaction_restart) &&
!bch2_err_matches(ret, BCH_ERR_data_read_retry))