public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: xfsprogs <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfsprogs: cleanup size/log setting flags of mkfs
Date: Sun, 29 Sep 2013 22:14:50 -0500	[thread overview]
Message-ID: <5248ECAA.1010506@sandeen.net> (raw)
In-Reply-To: <1380510260.2985.4.camel@ThinkPad-T5421>

On 9/29/13 10:04 PM, Li Zhong wrote:
> On Mon, 2013-09-30 at 09:06 +1000, Dave Chinner wrote:
>> On Sun, Sep 29, 2013 at 05:12:51PM +0800, Li Zhong wrote:
>>> As Eric suggested, we could set both of the size/log flags after we have
>>> parsed the options - and from there on it simply means "manually set".
>>>
>>> After that, we could use just one flag, e.g. *sflag, to check whether 
>>> the corresponding value is manually set or not.
>>
>> It's a start, but I'm not sure that it is an improvement or not.
>> i.e. you're adding yet another piece of logic to the already
>> tortured argument parsing and flag setting.
>>
>> This could be done in the argument parsing itself, without needing
>> separate post-processing code. e.g. changing the parsing code like
>> so:
>>
>> 	case N_LOG:
>> 		if (!value || *value == '\0')
>> 			reqval('n', nopts, N_LOG);
>> -		if (nlflag)
>> +		if (nlflag > 1)
>> 			respec('n', nopts, N_LOG);
>> 		if (nsflag)
>> 			conflict('n', nopts, N_SIZE,
>> 				 N_LOG);
>> +		nlflag = 2;
>> 		dirblocklog = atoi(value);
>> 		if (dirblocklog <= 0)
>> 			illegal(value, "n log");
>> +		nsflag = 1;
>> 		dirblocksize = 1 << dirblocklog;
>> -		nlflag = 1;
>> 		break;
>>
>> Would acheive exactly the same thing - i.e.
>> a value of 1 means it was initialised, a value of 2 means it was a
>> command line parameter...
>>
>> This means the code checks can be cleaned up as you have done, but
>> we don't need a separate post-processing step for the arguments to
>> set flags that weren't set...
> 
> Thank you for the suggestion, I will try this approach. 
> I think It could also preserve the information which suboption is used
> actually in the command line through the main() function, though it
> seems not needed currently. 

sounds good to me too; just watch out for the conflict/respec stuff to
be sure it all still works... I wasn't super happy with my suggestion
after I made it, I guess. :)

-Eric

> Thanks, Zhong
>>
>>
>>> Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
>>> ---
>>>  mkfs/xfs_mkfs.c | 29 ++++++++++++++++++++++-------
>>>  1 file changed, 22 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
>>> index 34bf2ff..aa3f391 100644
>>> --- a/mkfs/xfs_mkfs.c
>>> +++ b/mkfs/xfs_mkfs.c
>>> @@ -1667,11 +1667,26 @@ main(
>>>  		dfile = xi.dname;
>>>  
>>>  	/*
>>> +	 * Later code wants to know if the user manually set a value.
>>> +	 * There are two ways to specify on the cmdline; as size or as a log.
>>> +	 * if either was used, set both flags - from here on it simply means
>>> +	 * "manually set"
>>> +	 */
>>> +	if (bsflag || blflag)
>>> +		bsflag = blflag = 1;
>>> +	if (ssflag || slflag)
>>> +		ssflag = slflag = 1;
>>> +	if (isflag || ilflag)
>>> +		isflag = ilflag = 1;
>>> +	if (nsflag || nlflag)
>>> +		nsflag = nlflag = 1;
>>
>> You missed the log sector size/log flags.
>>
>> Cheers,
>>
>> Dave.
> 
> 

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

  reply	other threads:[~2013-09-30  3:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27  9:09 [PATCH] xfsprogs: make log/size consistent for mkfs's -s option Li Zhong
2013-09-27 17:29 ` Eric Sandeen
2013-09-27 23:39   ` Dave Chinner
2013-09-29  6:45   ` Li Zhong
2013-09-29  6:50   ` [PATCH v2] " Li Zhong
2013-09-29  9:12     ` [PATCH] xfsprogs: cleanup size/log setting flags of mkfs Li Zhong
2013-09-29 23:06       ` Dave Chinner
2013-09-30  3:04         ` Li Zhong
2013-09-30  3:14           ` Eric Sandeen [this message]
2013-09-30  5:24             ` Li Zhong
2013-09-30  5:20         ` [PATCH v2] " Li Zhong

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=5248ECAA.1010506@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.com \
    --cc=zhong@linux.vnet.ibm.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