From: NeilBrown <neilb@suse.com>
To: Guoqing Jiang <gqjiang@suse.com>, linux-raid@vger.kernel.org
Cc: shli@fb.com
Subject: Re: [PATCH] md/raid10: remove unnecessary checks with 'first'
Date: Mon, 03 Apr 2017 12:21:21 +1000 [thread overview]
Message-ID: <87inmmdye6.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <1491017900-8150-1-git-send-email-gqjiang@suse.com>
[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]
On Sat, Apr 01 2017, Guoqing Jiang wrote:
> Since the value of first is always '1', we can
> set min_offset_diff directly.
Alternately, maybe the fact that first is always '1', is a sign of a bug
that should be fixed.
The calculation of "min_offset_diff" doesn't make much sense now. It is
just the last_offset_diff.
I think the correct fix is to set "first = 0;" at the end of the
rdev_for_each() loop.
Thanks for spotting this.
NeilBrown
>
> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
> ---
> drivers/md/raid10.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 0f13d57..edaf8f4 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -3702,7 +3702,6 @@ static int raid10_run(struct mddev *mddev)
> struct md_rdev *rdev;
> sector_t size;
> sector_t min_offset_diff = 0;
> - int first = 1;
> bool discard_supported = false;
>
> if (mddev->private == NULL) {
> @@ -3758,8 +3757,7 @@ static int raid10_run(struct mddev *mddev)
> diff = -diff;
> if (diff < 0)
> diff = 0;
> - if (first || diff < min_offset_diff)
> - min_offset_diff = diff;
> + min_offset_diff = diff;
>
> if (mddev->gendisk)
> disk_stack_limits(mddev->gendisk, rdev->bdev,
> @@ -4140,7 +4138,6 @@ static int raid10_start_reshape(struct mddev *mddev)
>
> unsigned long before_length, after_length;
> sector_t min_offset_diff = 0;
> - int first = 1;
> struct geom new;
> struct r10conf *conf = mddev->private;
> struct md_rdev *rdev;
> @@ -4169,8 +4166,7 @@ static int raid10_start_reshape(struct mddev *mddev)
> diff = -diff;
> if (diff < 0)
> diff = 0;
> - if (first || diff < min_offset_diff)
> - min_offset_diff = diff;
> + min_offset_diff = diff;
> }
> }
>
> --
> 2.6.6
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2017-04-03 2:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 3:38 [PATCH] md/raid10: remove unnecessary checks with 'first' Guoqing Jiang
2017-04-03 2:21 ` NeilBrown [this message]
2017-04-06 1:12 ` [PATCH V2] md/raid10: reset the 'first' at the end of loop Guoqing Jiang
2017-04-06 2:27 ` NeilBrown
2017-04-10 17:41 ` Shaohua Li
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=87inmmdye6.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=gqjiang@suse.com \
--cc=linux-raid@vger.kernel.org \
--cc=shli@fb.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).