diff mbox series

[6/7] btrfs: use the new read repair code for direct I/O

Message ID cc97f85ceb603c81f4080b0834ca2477399fc55e.1653270323.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: synchronous (but super simple) read-repair rework | expand

Commit Message

Qu Wenruo May 23, 2022, 1:48 a.m. UTC
Just convert the btrfs_repair_one_sector() call to
btrfs_read_repair_sector().

And we can remove the dio specific repair helper now.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/inode.c | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dd0882e1b982..2d52a19e02cf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -55,6 +55,7 @@ 
 #include "zoned.h"
 #include "subpage.h"
 #include "inode-item.h"
+#include "read-repair.h"
 
 struct btrfs_iget_args {
 	u64 ino;
@@ -7863,23 +7864,6 @@  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);
-
-	if (btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA))
-		return;
-
-	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)
@@ -7904,12 +7888,21 @@  static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 					 bv.bv_page, btrfs_ino(BTRFS_I(inode)),
 					 bv.bv_offset);
 		} else {
+			u8 *csum_expected = NULL;
+			const u64 logical = (bbio->iter.bi_sector <<
+					     SECTOR_SHIFT) + offset;
+			int num_copies;
 			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 (bbio->csum)
+				csum_expected = btrfs_csum_ptr(fs_info,
+						bbio->csum, offset);
+			num_copies = btrfs_num_copies(fs_info, logical,
+						      fs_info->sectorsize);
+
+			ret = btrfs_read_repair_sector(inode, bv.bv_page,
+					bv.bv_offset, logical, start,
+					bbio->mirror_num, num_copies, csum_expected);
 			if (ret)
 				err = errno_to_blk_status(ret);
 		}