All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Christoph Hellwig <hch@lst.de>, 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: Re: [PATCH 5/8] btrfs: cleanup scrub_rbio
Date: Tue, 13 Dec 2022 16:53:33 +0800	[thread overview]
Message-ID: <083cd81a-644e-a054-80c1-1b3b902ff6e9@gmx.com> (raw)
In-Reply-To: <20221213084123.309790-6-hch@lst.de>



On 2022/12/13 16:41, Christoph Hellwig wrote:
> The bio_list is only filled by scrub_assemble_read_bios when
> successful, so don't try to walk it and put the bios on any
> failure before the successful call to recover_assemble_read_bios.
> Also initialize bio_list at initialization time.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   fs/btrfs/raid56.c | 21 ++++++++-------------
>   1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index 5dab0685e17dd5..2a5857d42fff20 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -2754,31 +2754,32 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
>   
>   static int scrub_rbio(struct btrfs_raid_bio *rbio)
>   {
> +	struct bio_list bio_list = BIO_EMPTY_LIST;
>   	bool need_check = false;
> -	struct bio_list bio_list;
>   	int sector_nr;
>   	int ret;
>   	struct bio *bio;
>   
> -	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);
>   	if (ret < 0)
> -		goto cleanup;
> +		return ret;
>   
>   	submit_read_bios(rbio, &bio_list);
>   	wait_event(rbio->io_wait, atomic_read(&rbio->stripes_pending) == 0);
>   
>   	/* We may have some failures, recover the failed sectors first. */
>   	ret = recover_scrub_rbio(rbio);
> -	if (ret < 0)
> -		goto cleanup;
> +	if (ret < 0) {
> +		while ((bio = bio_list_pop(&bio_list)))
> +			bio_put(bio);
> +		return ret;
> +	}

Do we still need the cleanup? IIRC after submit_read_bios() (or be more 
safe, after wait_event()), we should no longer touch @bio_list anymore.

Thus the cleanup itself is no longer needed AFAIK.

Thanks,
Qu

>   
>   	/*
>   	 * We have every sector properly prepared. Can finish the scrub
> @@ -2796,12 +2797,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
>   		}
>   	}
>   	return ret;
> -
> -cleanup:
> -	while ((bio = bio_list_pop(&bio_list)))
> -		bio_put(bio);
> -
> -	return ret;
>   }
>   
>   static void scrub_rbio_work_locked(struct work_struct *work)

  reply	other threads:[~2022-12-13  8:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13  8:41 small raid56 cleanups v2 Christoph Hellwig
2022-12-13  8:41 ` [PATCH 1/8] btrfs: cleanup raid56_parity_write Christoph Hellwig
2022-12-13  8:41 ` [PATCH 2/8] btrfs: cleanup rmw_rbio Christoph Hellwig
2022-12-13  8:41 ` [PATCH 3/8] btrfs: cleanup rmw_read_wait_recover Christoph Hellwig
2022-12-13  8:41 ` [PATCH 4/8] btrfs: cleanup recover_rbio Christoph Hellwig
2022-12-13  8:50   ` Qu Wenruo
2022-12-13  8:41 ` [PATCH 5/8] btrfs: cleanup scrub_rbio Christoph Hellwig
2022-12-13  8:53   ` Qu Wenruo [this message]
2022-12-13 13:24     ` Christoph Hellwig
2022-12-13 23:32       ` Qu Wenruo
2022-12-14 16:45         ` Christoph Hellwig
2022-12-13  8:41 ` [PATCH 6/8] btrfs: call rbio_orig_end_io from rmw_rbio Christoph Hellwig
2022-12-13  8:54   ` Qu Wenruo
2022-12-13  8:41 ` [PATCH 7/8] btrfs: call rbio_orig_end_io from recover_rbio Christoph Hellwig
2022-12-13  8:54   ` Qu Wenruo
2022-12-13  8:41 ` [PATCH 8/8] btrfs: call rbio_orig_end_io from scrub_rbio Christoph Hellwig
2022-12-13  8:55   ` Qu Wenruo
2022-12-13  8:59 ` small raid56 cleanups v2 Qu Wenruo
2022-12-13 13:25   ` Christoph Hellwig

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=083cd81a-644e-a054-80c1-1b3b902ff6e9@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=hch@lst.de \
    --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.