@@ -55,6 +55,7 @@
#include "zoned.h"
#include "subpage.h"
#include "inode-item.h"
+#include "read-repair.h"
struct btrfs_iget_args {
u64 ino;
@@ -7853,55 +7854,34 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
bio_endio(&dip->bio);
}
-static void submit_dio_repair_bio(struct inode *inode, struct bio *bio,
- int mirror_num,
- enum btrfs_compression_type compress_type)
-{
- struct btrfs_dio_private *dip = bio->bi_private;
- struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-
- BUG_ON(bio_op(bio) == REQ_OP_WRITE);
-
- refcount_inc(&dip->refs);
- if (btrfs_map_bio(fs_info, bio, mirror_num))
- refcount_dec(&dip->refs);
-}
-
static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
struct btrfs_bio *bbio,
const bool uptodate)
{
struct inode *inode = dip->inode;
struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
- struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
- struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
+ struct btrfs_read_repair rr = { };
blk_status_t err = BLK_STS_OK;
struct bvec_iter iter;
struct bio_vec bv;
u32 offset;
btrfs_bio_for_each_sector(fs_info, bv, bbio, iter, offset) {
- u64 start = bbio->file_offset + offset;
-
if (uptodate &&
(!csum || !check_data_csum(inode, bbio, offset, bv.bv_page,
- bv.bv_offset, start))) {
- clean_io_failure(fs_info, failure_tree, io_tree, start,
- bv.bv_page, btrfs_ino(BTRFS_I(inode)),
- bv.bv_offset);
+ bv.bv_offset, bbio->file_offset + offset))) {
+ if (!btrfs_read_repair_finish(&rr, bbio, inode, offset,
+ NULL))
+ err = BLK_STS_IOERR;
} else {
- int ret;
-
- ret = btrfs_repair_one_sector(inode, &bbio->bio, offset,
- bv.bv_page, bv.bv_offset, start,
- bbio->mirror_num,
- submit_dio_repair_bio);
- if (ret)
- err = errno_to_blk_status(ret);
+ if (!btrfs_read_repair_add(&rr, bbio, inode, offset))
+ err = BLK_STS_IOERR;
}
}
+ if (!btrfs_read_repair_finish(&rr, bbio, inode, offset, NULL))
+ err = BLK_STS_IOERR;
return err;
}
Rewrite btrfs_check_read_dio_bio to use btrfs_bio_for_each_sector and start/end a repair session as needed. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/btrfs/inode.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-)