public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@infradead.org>, Ben Myers <bpm@sgi.com>,
	Zach Brown <zab@zabbo.net>, XFS <xfs@oss.sgi.com>
Subject: Re: [PATCH V4] xfs: cleanup the mount options
Date: Mon, 09 Jul 2012 17:21:56 +0800	[thread overview]
Message-ID: <4FFAA2B4.6090503@cn.fujitsu.com> (raw)
In-Reply-To: <20120709002218.GW19223@dastard>

On 07/09/2012 08:22 AM, Dave Chinner wrote:
> On Sun, Jul 08, 2012 at 07:36:37PM +0800, Wanlong Gao wrote:
>> remove the mount options macro, use tokens instead.
>>
>> CC: Ben Myers <bpm@sgi.com>
>> CC: Christoph Hellwig <hch@infradead.org>
>> CC: Dave Chinner <david@fromorbit.com>
>> CC: Zach Brown <zab@zabbo.net>
>> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
>> ---
> 
> A "what's changed in this version" list would be handy here.
> 
>>  fs/xfs/xfs_super.c |  539 +++++++++++++++++++++++++++++++---------------------
>>  1 file changed, 320 insertions(+), 219 deletions(-)
> 
> ....
> 
>> -
>> -STATIC unsigned long
>> -suffix_strtoul(char *s, char **endp, unsigned int base)
>> +STATIC int
>> +suffix_match_int(substring_t *s, int *result)
> 
> I'm not sure ints are the best unit to use here....
> 
>>  {
>> -	int	last, shift_left_factor = 0;
>> -	char	*value = s;
>> +	int ret;
>> +	int last, shift_left_factor = 0;
>> +	char *value = s->to - 1;
>>  
>> -	last = strlen(value) - 1;
>> -	if (value[last] == 'K' || value[last] == 'k') {
>> +	if (*value == 'K' || *value == 'k') {
>>  		shift_left_factor = 10;
>> -		value[last] = '\0';
>> +		s->to--;
>>  	}
>> -	if (value[last] == 'M' || value[last] == 'm') {
>> +	if (*value == 'M' || *value == 'm') {
>>  		shift_left_factor = 20;
>> -		value[last] = '\0';
>> +		s->to--;
>>  	}
>> -	if (value[last] == 'G' || value[last] == 'g') {
>> +	if (*value == 'G' || *value == 'g') {
>>  		shift_left_factor = 30;
>> -		value[last] = '\0';
>> +		s->to--;
>>  	}
>>  
>> -	return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
>> +	ret = match_number(s, result, 0);
>> +	*result = *result << shift_left_factor;
> 
> Because this overflows or gives the negative values for numbers like
> 2G far too easily. I think this function needs to return an unsigned
> long.

Do you mean the "result" should be "unsigned long" but not the return value?
Because the return value is a error state.

> 
>> +	ret = ENOMEM;
>> +	options = kstrdup(options, GFP_NOFS);
>> +	if (!options)
>> +		goto done;
> 
> I commented on this error form previously. Can you convert them all
> to be consistent with the rest of the code? i.e:

OK, got it, will do in next version.

> 
> 	options = kstrdup(options, GFP_NOFS);
> 	if (!options) {
> 		ret = ENOMEM;
> 		goto done;
> 	}
> 
> i.e. set the error value (if necessary) in the error branch....
> 
>> +	orig = options;
>> +
>> +	while ((p = strsep(&orig, ",")) != NULL) {
>> +		int token;
>> +		if (!*p)
>>  			continue;
>> +
>> +		token = match_token(p, tokens, args);
>> +		switch (token) {
>> +		case Opt_logbufs:
>> +			intarg = 0;
> 
> Please move the initialisation of intarg up above the switch
> statement so that it is initialised once for all cases instead of
> individually in the cases that use it. That means we don't have to
> remember to do it in future for new or changed mount options...

OK, got it.

> 
>> +			ret = match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			mp->m_logbufs = intarg;
>> +			break;
>> +		case Opt_logbsize:
>> +			ret = suffix_match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			mp->m_logbsize = intarg;
>> +			break;
>> +		case Opt_logdev:
>> +			ret = ENOMEM;
>> +			string = match_strdup(args);
>> +			if (!string)
>> +				goto free_orig;
>> +
>> +			mp->m_logname = kstrndup(string, MAXNAMELEN, GFP_KERNEL);
>>  			if (!mp->m_logname)
>> +				goto free_string;
> 
> This match_strdup/kstrndup pattern is repeated a couple of times,
> and requires a special failure case (goto free_string) - wrapping it
> in helper function is probably a good idea so that the special
> failure case can be removed from this main parse loop...

Thank you for this suggestion, will do.

> 
>> +		case Opt_biosize:
>> +			intarg = 0;
>> +			ret = match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			iosizelog = ffs(intarg) - 1;
>> +			break;
>> +		case Opt_allocsize:
>> +			ret = suffix_match_int(args, &intarg);
>> +			if (ret)
>> +				goto free_orig;
>> +			iosizelog = ffs(intarg) - 1;
>> +			break;
> 
> These two can be collapsed into:
> 
> 		case Opt_biosize:
> 		case Opt_allocsize:
> 			ret = suffix_match_int(args, &intarg);
> 			if (ret)
> 				goto free_orig;
> 			iosizelog = ffs(intarg) - 1;
> 			break;
> 
> Also, these two a a good example of why intarg should be initialised
> to zero outside the switch statement - they both do almost exactly
> the same thing, but one initialises intarg and the other doesn't. Is
> that a bug? I can't tell without looking at the implementations of
> match_int and suffix_match_int....

Yeah, thank you.

> 
>> +		case Opt_delaylog:
>> +			xfs_warn(mp,
>> +		"delaylog is the default now, option is deprecated.");
> 
> As preivously mentioned, duplication of the mount option is here.

Sorry, will update.


Thanks,
Wanlong Gao

> 
> Adding something like:
> 
> #define MNTOPT_DEPRECATED "has no effect, option is deprecated"
> 
> Means these can become:
> 
> 		case Opt_delaylog:
> 			xfs_warn(mp, MNTOPT_DELAYLOG MNTOPT_DEPRECATED);
> 			break;
> 
>> +		case Opt_nodelaylog:
>> +			xfs_warn(mp,
>> +		"nodelaylog support has been removed, option is deprecated.");
> 
> 			xfs_warn(mp, MNTOPT_NODELAYLOG MNTOPT_DEPRECATED);
> 
>> +			break;
>> +		case Opt_ihashsize:
>>  			xfs_warn(mp,
>> +		"ihashsize no longer used, option is deprecated.");
> 
> 			xfs_warn(mp, MNTOPT_IHASHSIZE MNTOPT_DEPRECATED);
> 
> And so on for all the deprecated options. That way we get a
> consistent mesage for all deprecated options and it's easy to keep
> that way in the future.
> 
> Cheers,
> 
> Dave.
> 


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2012-07-09  9:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-27 16:57 [PATCH] xfs: cleanup the mount options Wanlong Gao
2012-06-27 17:44 ` Christoph Hellwig
2012-06-28  0:54   ` Wanlong Gao
2012-06-28 16:01     ` Ben Myers
2012-06-28 16:33       ` Zach Brown
2012-06-28 19:54         ` Carlos Maiolino
2012-06-29  1:00         ` Wanlong Gao
2012-06-29 16:29           ` Zach Brown
2012-06-29 16:37             ` Wanlong Gao
2012-06-29 18:06 ` [PATCH 1/2 V2] " Wanlong Gao
2012-06-29 18:06   ` [PATCH 2/2] xfs: rename xfs_fs_* to xfs_* Wanlong Gao
2012-07-01 23:47     ` Dave Chinner
2012-07-02  0:39       ` Wanlong Gao
2012-07-02  6:26   ` [PATCH 1/2 V2] xfs: cleanup the mount options Christoph Hellwig
2012-07-02  7:05     ` [PATCH V3] " Wanlong Gao
2012-07-06  3:05       ` Dave Chinner
2012-07-08 11:36         ` [PATCH V4] " Wanlong Gao
2012-07-09  0:22           ` Dave Chinner
2012-07-09  9:21             ` Wanlong Gao [this message]
2012-07-11  2:26               ` Dave Chinner
2012-07-11  6:29                 ` [PATCH V5] " Wanlong Gao
2012-07-16  8:06                   ` Wanlong Gao
2012-07-23 20:33                     ` Ben Myers
2012-07-23 23:28                   ` Dave Chinner
2012-07-24  2:01                     ` Wanlong Gao
2012-07-24 21:18                       ` Dave Chinner
2012-07-25  1:09                         ` Wanlong Gao
2012-07-25  1:11                         ` [PATCH V7] " Wanlong Gao
2012-07-29 22:09                           ` Dave Chinner
2012-08-28 19:38                           ` Ben Myers
2012-07-24  2:10                     ` [PATCH V6] " Wanlong Gao

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=4FFAA2B4.6090503@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=bpm@sgi.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    --cc=zab@zabbo.net \
    /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