@@ -188,6 +188,13 @@ static void submit_one_bio(struct bio *bio, int mirror_num,
/* Caller should ensure the bio has at least some range added */
ASSERT(bio->bi_iter.bi_size);
+ /*
+ * Save the original bi_iter for read bios, as read repair wants the
+ * orignial logical bytenr.
+ */
+ if (bio_op(bio) == REQ_OP_READ)
+ btrfs_bio(bio)->iter = bio->bi_iter;
+
if (is_data_inode(tree->private_data))
btrfs_submit_data_bio(tree->private_data, bio, mirror_num,
compress_type);
@@ -7974,6 +7974,8 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA);
if (ret)
goto err;
+ /* Check submit_one_bio() for the reason. */
+ btrfs_bio(bio)->iter = bio->bi_iter;
}
if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)