linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: linan666@huaweicloud.com, song@kernel.org,
	guoqing.jiang@cloud.ionos.com, colyli@suse.de, xni@redhat.com
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	linan122@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com,
	yangerkun@huawei.com, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH 2/3] md/raid10: factor out get_rdev_repl_from_mirror()
Date: Wed, 28 Jun 2023 17:26:38 +0800	[thread overview]
Message-ID: <36a6be92-f9c5-fd7c-20d9-741e2a6f133f@huaweicloud.com> (raw)
In-Reply-To: <20230628015752.102267-3-linan666@huaweicloud.com>

Hi,

在 2023/06/28 9:57, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> Factor out a helper to get 'rdev' and 'replacement' from config->mirrors.
> Just to make code cleaner and prepare to fix the bug of io loss while
> 'replacement' replace 'rdev'.
> 
> There is no functional change.
> 
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/raid10.c | 30 +++++++++++++++++++++---------
>   1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 3e6a09aaaba6..eaaf6307ddda 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1346,6 +1346,26 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio,
>   	}
>   }
>   
> +static void get_rdev_repl_from_mirror(struct raid10_info *mirror,
> +				 struct md_rdev **prdev,
> +				 struct md_rdev **prrdev)

I don't like this name, but I can live with this for now, related code
will be removed eventually.

Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> +{
> +	struct md_rdev *rdev, *rrdev;
> +
> +	rrdev = rcu_dereference(mirror->replacement);
> +	/*
> +	 * Read replacement first to prevent reading both rdev and
> +	 * replacement as NULL during replacement replace rdev.
> +	 */
> +	smp_mb();
> +	rdev = rcu_dereference(mirror->rdev);
> +	if (rdev == rrdev)
> +		rrdev = NULL;
> +
> +	*prrdev = rrdev;
> +	*prdev = rdev;
> +}
> +
>   static void wait_blocked_dev(struct mddev *mddev, struct r10bio *r10_bio)
>   {
>   	int i;
> @@ -1489,15 +1509,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
>   		int d = r10_bio->devs[i].devnum;
>   		struct md_rdev *rdev, *rrdev;
>   
> -		rrdev = rcu_dereference(conf->mirrors[d].replacement);
> -		/*
> -		 * Read replacement first to prevent reading both rdev and
> -		 * replacement as NULL during replacement replace rdev.
> -		 */
> -		smp_mb();
> -		rdev = rcu_dereference(conf->mirrors[d].rdev);
> -		if (rdev == rrdev)
> -			rrdev = NULL;
> +		get_rdev_repl_from_mirror(&conf->mirrors[d], &rdev, &rrdev);
>   		if (rdev && (test_bit(Faulty, &rdev->flags)))
>   			rdev = NULL;
>   		if (rrdev && (test_bit(Faulty, &rrdev->flags)))
> 


  reply	other threads:[~2023-06-28  9:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  1:57 [PATCH 0/3] raid10 bugfix linan666
2023-06-28  1:57 ` [PATCH 1/3] md/raid10: check replacement and rdev to prevent submit the same io twice linan666
2023-06-28  6:36   ` Yu Kuai
2023-06-28  1:57 ` [PATCH 2/3] md/raid10: factor out get_rdev_repl_from_mirror() linan666
2023-06-28  9:26   ` Yu Kuai [this message]
2023-06-30 23:53   ` Song Liu
2023-07-01  1:40     ` Li Nan
2023-06-28  1:57 ` [PATCH 3/3] md/raid10: use get_rdev_repl_from_mirror() to get devices linan666
2023-06-28  9:28   ` Yu Kuai

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=36a6be92-f9c5-fd7c-20d9-741e2a6f133f@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=colyli@suse.de \
    --cc=guoqing.jiang@cloud.ionos.com \
    --cc=houtao1@huawei.com \
    --cc=linan122@huawei.com \
    --cc=linan666@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).