All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 6/7] btrfs: make direct io read path to use the new read repair infrastructure
Date: Wed, 25 May 2022 18:59:16 +0800	[thread overview]
Message-ID: <9d71475db36ef39574fb1015a3f6a9d37db980db.1653476251.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1653476251.git.wqu@suse.com>

By doing this, we can also remove the function submit_dio_repair_bio().

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/inode.c | 51 +++++++++++++++++-------------------------------
 1 file changed, 18 insertions(+), 33 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dd0882e1b982..26718ec1e07b 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,58 +7864,42 @@ 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)
 {
 	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;
+	struct btrfs_read_repair_ctrl ctrl = {0};
 	const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
 	blk_status_t err = BLK_STS_OK;
 	struct bvec_iter iter;
 	struct bio_vec bv;
+	int ret;
 	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);
-		} 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 (!uptodate ||
+		    (csum && check_data_csum(inode, bbio, offset, bv.bv_page,
+					     bv.bv_offset, start))) {
+			u64 logical = (bbio->iter.bi_sector << SECTOR_SHIFT) +
+				      offset;
+			u8 *csum = NULL;
+
+			if (bbio->csum)
+				csum = btrfs_csum_ptr(fs_info, bbio->csum, offset);
+			ret = btrfs_read_repair_add_sector(inode, &ctrl,
+					bv.bv_page, bv.bv_offset, logical,
+					start, csum, bbio->mirror_num, true);
 			if (ret)
 				err = errno_to_blk_status(ret);
 		}
 	}
-
+	ret = btrfs_read_repair_finish(&ctrl);
+	if (ret)
+		err = errno_to_blk_status(ret);
 	return err;
 }
 
-- 
2.36.1


  parent reply	other threads:[~2022-05-25 10:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 10:59 [PATCH v2 0/7] btrfs: read-repair rework based on bitmap Qu Wenruo
2022-05-25 10:59 ` [PATCH v2 1/7] btrfs: save the original bi_iter into btrfs_bio for buffered read Qu Wenruo
2022-05-25 10:59 ` [PATCH v2 2/7] btrfs: make repair_io_failure available outside of extent_io.c Qu Wenruo
2022-05-25 10:59 ` [PATCH v2 3/7] btrfs: add a btrfs_map_bio_wait helper Qu Wenruo
2022-05-25 10:59 ` [PATCH v2 4/7] btrfs: introduce new read-repair infrastructure Qu Wenruo
2022-05-26  3:06   ` Qu Wenruo
2022-05-26  7:30     ` Christoph Hellwig
2022-05-26  7:37       ` Qu Wenruo
2022-05-26  7:45         ` Christoph Hellwig
2022-05-26  7:52           ` Qu Wenruo
2022-05-26  8:00             ` Christoph Hellwig
2022-05-26  8:07               ` Qu Wenruo
2022-05-26  8:17                 ` Christoph Hellwig
2022-05-26  8:26                   ` Qu Wenruo
2022-05-26  8:28                     ` Christoph Hellwig
2022-05-26  8:49                       ` Qu Wenruo
2022-05-26  8:54                         ` Christoph Hellwig
2022-05-26  9:13                           ` Qu Wenruo
2022-05-27  8:10                             ` Christoph Hellwig
2022-05-25 10:59 ` [PATCH v2 5/7] btrfs: make buffered read path to use the new read repair infrastructure Qu Wenruo
2022-05-25 10:59 ` Qu Wenruo [this message]
2022-05-25 10:59 ` [PATCH v2 7/7] btrfs: remove io_failure_record infrastructure completely Qu Wenruo
2022-05-25 14:55 ` [PATCH v2 0/7] btrfs: read-repair rework based on bitmap David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d71475db36ef39574fb1015a3f6a9d37db980db.1653476251.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.