From: kaixuxia <xiakaixu1987@gmail.com>
To: Eric Sandeen <sandeen@sandeen.net>,
Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Cc: "linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
Kaixu Xia <kaixuxia@tencent.com>
Subject: Re: [PATCH] mkfs: simplify the configured sector sizes setting in validate_sectorsize
Date: Tue, 19 May 2020 22:56:01 +0800 [thread overview]
Message-ID: <64a8d225-1d55-e6f1-eed3-b9a04eb426d6@gmail.com> (raw)
In-Reply-To: <1b6748ad-249a-dbf0-efbd-c13edd344aaa@sandeen.net>
On 2020/5/19 21:03, Eric Sandeen wrote:
> On 5/19/20 3:38 AM, Chaitanya Kulkarni wrote:
>> On 5/18/20 11:39 PM, xiakaixu1987@gmail.com wrote:
>>> From: Kaixu Xia <kaixuxia@tencent.com>
>>>
>>> There are two places that set the configured sector sizes in validate_sectorsize,
>>> actually we can simplify them and combine into one if statement.
>>> Is it me or patch description seems to be longer than what is in the
>> tree ?
>>> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
>>> ---
>>> mkfs/xfs_mkfs.c | 14 ++++----------
>>> 1 file changed, 4 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
>>> index 039b1dcc..e1904d57 100644
>>> --- a/mkfs/xfs_mkfs.c
>>> +++ b/mkfs/xfs_mkfs.c
>>> @@ -1696,14 +1696,6 @@ validate_sectorsize(
>>> int dry_run,
>>> int force_overwrite)
>>> {
>>> - /* set configured sector sizes in preparation for checks */
>>> - if (!cli->sectorsize) {
>>> - cfg->sectorsize = dft->sectorsize;
>>> - } else {
>>> - cfg->sectorsize = cli->sectorsize;
>>> - }
>>> - cfg->sectorlog = libxfs_highbit32(cfg->sectorsize);
>>> -
>>
>> If above logic is correct which I've not looked into it, then dft is
>> not used in validate_sectorsize(), how about something like this on
>> the top of this this patch (totally untested):-
>
> Honestly if not set via commandline, and probing fails, we should fall
> back to dft->sectorsize so that all the defaults are still set in one place,
> i.e. the defaults structure mkfs_default_params.
The original logic in validate_sectorsize() is:
static void
validate_sectorsize(
...
if (!cli->sectorsize) {
cfg->sectorsize = dft->sectorsize;
} else {
cfg->sectorsize = cli->sectorsize;
}
...
if (!cli->sectorsize) {
if (!ft->lsectorsize)
ft->lsectorsize = XFS_MIN_SECTORSIZE;
...
cfg->sectorsize = ft->psectorsize;
...
}
...
}
Firstly, if not set via commandline and probing fails, we will use the
XFS_MIN_SECTORSIZE (actually equal to dft->sectorsize).
Secondly, for the !cli->sectorsize case, the first if statement set cfg->sectorsize
to dft->sectorsize, but the cfg->sectorsize value would be overwrote and set to
ft->psectorsize in the next if statement, so the first if statement is meaningless
and the two if statements can be combined.
>
> -Eric
>
>
--
kaixuxia
next prev parent reply other threads:[~2020-05-19 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 6:38 [PATCH] mkfs: simplify the configured sector sizes setting in validate_sectorsize xiakaixu1987
2020-05-19 8:38 ` Chaitanya Kulkarni
2020-05-19 13:03 ` Eric Sandeen
2020-05-19 14:56 ` kaixuxia [this message]
2020-05-19 21:15 ` Dave Chinner
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=64a8d225-1d55-e6f1-eed3-b9a04eb426d6@gmail.com \
--to=xiakaixu1987@gmail.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=kaixuxia@tencent.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.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