mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: linan666@huaweicloud.com, song@kernel.org
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH v2] md: make md_flush_request() more readable
Date: Tue, 28 May 2024 21:32:40 +0800	[thread overview]
Message-ID: <8dc33d99-4b50-fdb7-e81b-581939dadeaa@huaweicloud.com> (raw)
In-Reply-To: <20240528203149.2383260-1-linan666@huaweicloud.com>

Hi,

在 2024/05/29 4:31, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> Setting bio to NULL and checking 'if(!bio)' is redundant and looks strange,
> just consolidate them into one condition. There are no functional changes.
> 
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
> v2: Rewrite the code according to Christoph's suggestion.
> 
>   drivers/md/md.c | 28 +++++++++++++---------------
>   1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index aff9118ff697..9598b4898ea9 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -654,24 +654,22 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio)
>   		WARN_ON(percpu_ref_is_zero(&mddev->active_io));
>   		percpu_ref_get(&mddev->active_io);
>   		mddev->flush_bio = bio;
> -		bio = NULL;
> -	}
> -	spin_unlock_irq(&mddev->lock);
> -
> -	if (!bio) {
> +		spin_unlock_irq(&mddev->lock);
>   		INIT_WORK(&mddev->flush_work, submit_flushes);
>   		queue_work(md_wq, &mddev->flush_work);
> -	} else {
> -		/* flush was performed for some other bio while we waited. */
> -		if (bio->bi_iter.bi_size == 0)
> -			/* an empty barrier - all done */
> -			bio_endio(bio);
> -		else {
> -			bio->bi_opf &= ~REQ_PREFLUSH;
> -			return false;
> -		}
> +		return true;
>   	}
> -	return true;
> +
> +	/* flush was performed for some other bio while we waited. */
> +	spin_unlock_irq(&mddev->lock);
> +	if (bio->bi_iter.bi_size == 0) {

It's better to use bio_sectors() here.

Thanks,
Kuai

> +		/* pure flush without data - all done */
> +		bio_endio(bio);
> +		return true;
> +	}
> +
> +	bio->bi_opf &= ~REQ_PREFLUSH;
> +	return false;
>   }
>   EXPORT_SYMBOL(md_flush_request);
>   
> 


  parent reply	other threads:[~2024-05-28 13:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 20:31 linan666
2024-05-28 13:23 ` Christoph Hellwig
2024-05-28 13:49   ` Li Nan
2024-05-29  5:44     ` Christoph Hellwig
2024-05-29  6:08       ` Yu Kuai
2024-05-29  6:09         ` Christoph Hellwig
2024-05-28 13:32 ` Yu Kuai [this message]
2024-06-10 20:53 ` Song Liu

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=8dc33d99-4b50-fdb7-e81b-581939dadeaa@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=houtao1@huawei.com \
    --cc=linan666@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®