All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Guilherme G. Piccoli" <gpiccoli@canonical.com>
To: NeilBrown <neilb@suse.de>
Cc: Neil F Brown <nfbrown@suse.com>, Song Liu <songliubraving@fb.com>,
	jes.sorensen@gmail.com, liu.song.a23@gmail.com,
	linux-raid@vger.kernel.org, dm-devel@redhat.com,
	linux-block@vger.kernel.org, jay.vosburgh@canonical.com
Subject: Re: [PATCH v3 2/2] mdadm: Introduce new array state 'broken' for raid0/linear
Date: Fri, 30 Aug 2019 09:48:11 -0300	[thread overview]
Message-ID: <1a215cee-cbbb-ec3a-937a-2bcfb8049fef@canonical.com> (raw)
In-Reply-To: <87a7brf4or.fsf@notabene.neil.brown.name>

Thanks Neil! CCing Jes, also comments inline:


On 30/08/2019 05:17, NeilBrown wrote:
>> [...]
>> +	char arrayst[12] = { 0 }; /* no state is >10 chars currently */
> 
> Why do you have an array?  Why not just a "char *".
> Then all the "strncpy" below become simple pointer assignment.

OK, makes sense! I'll try to change it.


>> [...]  
>>  int WaitClean(char *dev, int verbose)
>>  {
>> @@ -1116,7 +1120,8 @@ int WaitClean(char *dev, int verbose)
>>  			rv = read(state_fd, buf, sizeof(buf));
>>  			if (rv < 0)
>>  				break;
>> -			if (sysfs_match_word(buf, clean_states) <= 4)
> 
> Arg.  That is horrible.  Who wrote that code???
> Oh, it was me.  And only 8 years ago.

rofl, happens!


> sysfs_match_word() should return a clear "didn't match" indicator, like
> "-1".
> 
> Ideally that should be fixed, but I cannot really expect you to do that.
> 
> Maybe make it
>    if (clean_states[sysfs_match_word(buf, clean_states)] != NULL)
>  ??
> or
>    if (sysfs_match_word(buf, clean_states) < ARRAY_SIZE(clean_states)-1)
> 
> Otherwise the patch looks ok.

OK, thanks for the review! I'll try to change that in V4 too.
cheers,


Guilherme

WARNING: multiple messages have this Message-ID (diff)
From: "Guilherme G. Piccoli" <gpiccoli@canonical.com>
To: NeilBrown <neilb@suse.de>
Cc: linux-raid@vger.kernel.org, jay.vosburgh@canonical.com,
	Song Liu <songliubraving@fb.com>,
	liu.song.a23@gmail.com, dm-devel@redhat.com,
	Neil F Brown <nfbrown@suse.com>,
	linux-block@vger.kernel.org, jes.sorensen@gmail.com
Subject: Re: [PATCH v3 2/2] mdadm: Introduce new array state 'broken' for raid0/linear
Date: Fri, 30 Aug 2019 09:48:11 -0300	[thread overview]
Message-ID: <1a215cee-cbbb-ec3a-937a-2bcfb8049fef@canonical.com> (raw)
In-Reply-To: <87a7brf4or.fsf@notabene.neil.brown.name>

Thanks Neil! CCing Jes, also comments inline:


On 30/08/2019 05:17, NeilBrown wrote:
>> [...]
>> +	char arrayst[12] = { 0 }; /* no state is >10 chars currently */
> 
> Why do you have an array?  Why not just a "char *".
> Then all the "strncpy" below become simple pointer assignment.

OK, makes sense! I'll try to change it.


>> [...]  
>>  int WaitClean(char *dev, int verbose)
>>  {
>> @@ -1116,7 +1120,8 @@ int WaitClean(char *dev, int verbose)
>>  			rv = read(state_fd, buf, sizeof(buf));
>>  			if (rv < 0)
>>  				break;
>> -			if (sysfs_match_word(buf, clean_states) <= 4)
> 
> Arg.  That is horrible.  Who wrote that code???
> Oh, it was me.  And only 8 years ago.

rofl, happens!


> sysfs_match_word() should return a clear "didn't match" indicator, like
> "-1".
> 
> Ideally that should be fixed, but I cannot really expect you to do that.
> 
> Maybe make it
>    if (clean_states[sysfs_match_word(buf, clean_states)] != NULL)
>  ??
> or
>    if (sysfs_match_word(buf, clean_states) < ARRAY_SIZE(clean_states)-1)
> 
> Otherwise the patch looks ok.

OK, thanks for the review! I'll try to change that in V4 too.
cheers,


Guilherme

  reply	other threads:[~2019-08-30 12:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 16:13 [PATCH v3 1/2] md raid0/linear: Mark array as 'broken' and fail BIOs if a member is gone Guilherme G. Piccoli
2019-08-22 16:13 ` Guilherme G. Piccoli
2019-08-22 16:13 ` [PATCH v3 2/2] mdadm: Introduce new array state 'broken' for raid0/linear Guilherme G. Piccoli
2019-08-22 16:13   ` Guilherme G. Piccoli
2019-08-22 21:56   ` Song Liu
2019-08-22 21:56     ` Song Liu
2019-08-29 12:51   ` Guilherme G. Piccoli
2019-08-29 12:51     ` Guilherme G. Piccoli
2019-08-30  8:17   ` NeilBrown
2019-08-30  8:17     ` NeilBrown
2019-08-30 12:48     ` Guilherme G. Piccoli [this message]
2019-08-30 12:48       ` Guilherme G. Piccoli
2019-08-22 21:55 ` [PATCH v3 1/2] md raid0/linear: Mark array as 'broken' and fail BIOs if a member is gone Song Liu
2019-08-22 21:55   ` Song Liu
2019-08-23 17:48   ` Guilherme G. Piccoli
2019-08-23 17:48     ` Guilherme G. Piccoli
2019-08-23 17:51     ` Song Liu
2019-08-23 17:51       ` Song Liu
2019-08-30 10:47       ` Wols Lists
2019-08-30 10:47         ` Wols Lists
2019-08-30 11:25         ` Guilherme Piccoli
2019-08-30 11:25           ` Guilherme Piccoli
2019-09-03 19:53           ` Guilherme G. Piccoli
2019-09-03 19:53             ` Guilherme G. Piccoli
2019-08-30  8:08 ` NeilBrown
2019-08-30  8:08   ` NeilBrown

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=1a215cee-cbbb-ec3a-937a-2bcfb8049fef@canonical.com \
    --to=gpiccoli@canonical.com \
    --cc=dm-devel@redhat.com \
    --cc=jay.vosburgh@canonical.com \
    --cc=jes.sorensen@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=liu.song.a23@gmail.com \
    --cc=neilb@suse.de \
    --cc=nfbrown@suse.com \
    --cc=songliubraving@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 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.