All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: [PATCH 07/10] btrfs: submit the read bios from scrub_assemble_read_bios
Date: Wed, 11 Jan 2023 07:23:31 +0100	[thread overview]
Message-ID: <20230111062335.1023353-8-hch@lst.de> (raw)
In-Reply-To: <20230111062335.1023353-1-hch@lst.de>

Instead of filling in a bio_list and submitting the bios in the only
caller, do that in scrub_assemble_read_bios.  This removes the
need to pass the bio_list, and also makes it clear that the extra
bio_list cleanup in the caller is entirely pointless.  Rename the
function to scrub_read_bios to make it clear that the bios are not
only assembled.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/raid56.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 88404a6b0b98e7..374c3873169b3f 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -2668,14 +2668,12 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio)
 	return ret;
 }
 
-static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
-				    struct bio_list *bio_list)
+static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio)
 {
+	struct bio_list bio_list = BIO_EMPTY_LIST;
 	int total_sector_nr;
 	int ret = 0;
 
-	ASSERT(bio_list_size(bio_list) == 0);
-
 	/* Build a list of bios to read all the missing parts. */
 	for (total_sector_nr = 0; total_sector_nr < rbio->nr_sectors;
 	     total_sector_nr++) {
@@ -2704,42 +2702,38 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
 		if (sector->uptodate)
 			continue;
 
-		ret = rbio_add_io_sector(rbio, bio_list, sector, stripe,
+		ret = rbio_add_io_sector(rbio, &bio_list, sector, stripe,
 					 sectornr, REQ_OP_READ);
-		if (ret)
-			goto error;
+		if (ret) {
+			bio_list_put(&bio_list);
+			return ret;
+		}
 	}
+
+	submit_read_wait_bio_list(rbio, &bio_list);
 	return 0;
-error:
-	bio_list_put(bio_list);
-	return ret;
 }
 
 static int scrub_rbio(struct btrfs_raid_bio *rbio)
 {
 	bool need_check = false;
-	struct bio_list bio_list;
 	int sector_nr;
 	int ret;
 
-	bio_list_init(&bio_list);
-
 	ret = alloc_rbio_essential_pages(rbio);
 	if (ret)
-		goto cleanup;
+		return ret;
 
 	bitmap_clear(rbio->error_bitmap, 0, rbio->nr_sectors);
 
-	ret = scrub_assemble_read_bios(rbio, &bio_list);
+	ret = scrub_assemble_read_bios(rbio);
 	if (ret < 0)
-		goto cleanup;
-
-	submit_read_wait_bio_list(rbio, &bio_list);
+		return ret;
 
 	/* We may have some failures, recover the failed sectors first. */
 	ret = recover_scrub_rbio(rbio);
 	if (ret < 0)
-		goto cleanup;
+		return ret;
 
 	/*
 	 * We have every sector properly prepared. Can finish the scrub
@@ -2757,10 +2751,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
 		}
 	}
 	return ret;
-
-cleanup:
-	bio_list_put(&bio_list);
-	return ret;
 }
 
 static void scrub_rbio_work_locked(struct work_struct *work)
-- 
2.35.1


  parent reply	other threads:[~2023-01-11  6:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  6:23 small raid56 cleanups v3 Christoph Hellwig
2023-01-11  6:23 ` [PATCH 01/10] btrfs: cleanup raid56_parity_write Christoph Hellwig
2023-01-11  6:23 ` [PATCH 02/10] btrfs: cleanup rmw_rbio Christoph Hellwig
2023-01-11  6:23 ` [PATCH 03/10] btrfs: wait for I/O completion in submit_read_bios Christoph Hellwig
2023-01-11  6:38   ` Qu Wenruo
2023-01-11  6:23 ` [PATCH 04/10] btrfs: add a bio_list_put helper Christoph Hellwig
2023-01-11  6:38   ` Qu Wenruo
2023-01-11 11:12   ` Johannes Thumshirn
2023-01-12  8:09     ` Christoph Hellwig
2023-01-12 11:00       ` Johannes Thumshirn
2023-01-11  6:23 ` [PATCH 05/10] btrfs: fold recover_assemble_read_bios into recover_rbio Christoph Hellwig
2023-01-11  6:42   ` Qu Wenruo
2023-01-11  6:23 ` [PATCH 06/10] btrfs: fold rmw_read_wait_recover into rmw_read_bios Christoph Hellwig
2023-01-11  6:45   ` Qu Wenruo
2023-01-11  6:23 ` Christoph Hellwig [this message]
2023-01-11  6:48   ` [PATCH 07/10] btrfs: submit the read bios from scrub_assemble_read_bios Qu Wenruo
2023-01-11  6:23 ` [PATCH 08/10] btrfs: call rbio_orig_end_io from rmw_rbio Christoph Hellwig
2023-01-11  6:49   ` Qu Wenruo
2023-01-11  6:23 ` [PATCH 09/10] btrfs: call rbio_orig_end_io from recover_rbio Christoph Hellwig
2023-01-11  6:50   ` Qu Wenruo
2023-01-11  6:23 ` [PATCH 10/10] btrfs: call rbio_orig_end_io from scrub_rbio Christoph Hellwig
2023-01-11  6:50   ` Qu Wenruo
2023-01-11 11:18 ` small raid56 cleanups v3 Johannes Thumshirn
2023-02-08 20:00 ` 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=20230111062335.1023353-8-hch@lst.de \
    --to=hch@lst.de \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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.