REQ_FUA means "skip the drive cache", and it can be used with reads to.
If there was a checksum error, we want to retry the whole read path, not
read it from cache again.

Suggested-by: Benjamin LaHaise <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
---
 fs/bcachefs/io_read.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c
index 69c1422685e0..d90e32fb6893 100644
--- a/fs/bcachefs/io_read.c
+++ b/fs/bcachefs/io_read.c
@@ -1217,6 +1217,10 @@ int __bch2_read_extent(struct btree_trans *trans, struct 
bch_read_bio *orig,
        rbio->bio.bi_iter.bi_sector = pick.ptr.offset;
        rbio->bio.bi_end_io     = bch2_read_endio;
 
+       /* XXX: also nvme read recovery level */
+       if (unlikely(failed && bch2_dev_io_failures(failed, pick.ptr.dev)))
+               rbio->bio.bi_opf |= REQ_FUA;
+
        if (rbio->bounce)
                trace_and_count(c, io_read_bounce, &rbio->bio);
 
-- 
2.47.2


Reply via email to