From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/7] mkfs: resolve sector size CLI conflicts
Date: Tue, 19 Dec 2017 18:59:58 -0800 [thread overview]
Message-ID: <20171220025958.GN12613@magnolia> (raw)
In-Reply-To: <20171218091158.14537-7-david@fromorbit.com>
On Mon, Dec 18, 2017 at 08:11:57PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Now we have a two dimensional conflict array, convert the sector
> size CLI option conflict determination to use it. To get the error
> specification just right, we also need to tweak how we store
> and validate the sector size CLI parameter state in the options
> table.
>
> Old:
>
> $ mkfs.xfs -N -s size=4k -d sectsize=512 /dev/pmem0
> Cannot specify both -d sectsize and -d sectlog
> .....
>
> New:
>
> $ mkfs.xfs -N -s size=4k -d sectsize=512 /dev/pmem0
> Cannot specify both -s size and -d sectsize
> .....
>
>
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>
> ---
> mkfs/xfs_mkfs.c | 43 +++++++++++++++++++++++++++++++------------
> 1 file changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 4b79c03e442b..b8752965c6d7 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -230,6 +230,13 @@ struct opt_params {
> } subopt_params[MAX_SUBOPTS];
> };
>
> +/*
> + * The two dimensional conflict array requires some initialisations to know
> + * about tables that haven't yet been defined. Work around this ordering
> + * issue with extern definitions here.
> + */
> +extern struct opt_params sopts;
> +
> struct opt_params bopts = {
> .name = 'b',
> .subopts = {
> @@ -348,6 +355,10 @@ struct opt_params dopts = {
> },
> { .index = D_SECTLOG,
> .conflicts = { { &dopts, D_SECTSIZE },
> + { &sopts, S_SIZE },
> + { &sopts, S_SECTSIZE },
> + { &sopts, S_LOG },
> + { &sopts, S_SECTLOG },
> { &dopts, LAST_CONFLICT } },
> .minval = XFS_MIN_SECTORSIZE_LOG,
> .maxval = XFS_MAX_SECTORSIZE_LOG,
> @@ -355,6 +366,10 @@ struct opt_params dopts = {
> },
> { .index = D_SECTSIZE,
> .conflicts = { { &dopts, D_SECTLOG },
> + { &sopts, S_SIZE },
> + { &sopts, S_SECTSIZE },
> + { &sopts, S_LOG },
> + { &sopts, S_SECTLOG },
> { &dopts, LAST_CONFLICT } },
> .convert = true,
> .is_power_2 = true,
> @@ -680,6 +695,9 @@ struct opt_params sopts = {
> { .index = S_LOG,
> .conflicts = { { &sopts, S_SIZE },
> { &sopts, S_SECTSIZE },
> + { &sopts, S_SECTLOG },
> + { &dopts, D_SECTSIZE },
> + { &dopts, D_SECTLOG },
> { &sopts, LAST_CONFLICT } },
> .minval = XFS_MIN_SECTORSIZE_LOG,
> .maxval = XFS_MAX_SECTORSIZE_LOG,
> @@ -688,6 +706,9 @@ struct opt_params sopts = {
> { .index = S_SECTLOG,
> .conflicts = { { &sopts, S_SIZE },
> { &sopts, S_SECTSIZE },
> + { &sopts, S_LOG },
> + { &dopts, D_SECTSIZE },
> + { &dopts, D_SECTLOG },
> { &sopts, LAST_CONFLICT } },
> .minval = XFS_MIN_SECTORSIZE_LOG,
> .maxval = XFS_MAX_SECTORSIZE_LOG,
> @@ -696,6 +717,9 @@ struct opt_params sopts = {
> { .index = S_SIZE,
> .conflicts = { { &sopts, S_LOG },
> { &sopts, S_SECTLOG },
> + { &sopts, S_SECTSIZE },
> + { &dopts, D_SECTSIZE },
> + { &dopts, D_SECTLOG },
> { &sopts, LAST_CONFLICT } },
> .convert = true,
> .is_power_2 = true,
> @@ -706,6 +730,9 @@ struct opt_params sopts = {
> { .index = S_SECTSIZE,
> .conflicts = { { &sopts, S_LOG },
> { &sopts, S_SECTLOG },
> + { &sopts, S_SIZE },
> + { &dopts, D_SECTSIZE },
> + { &dopts, D_SECTLOG },
> { &sopts, LAST_CONFLICT } },
> .convert = true,
> .is_power_2 = true,
> @@ -964,8 +991,8 @@ conflict(
> int conflict)
> {
> fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"),
> - opts->name, opts->subopts[option],
> - con_opts->name, con_opts->subopts[conflict]);
> + con_opts->name, con_opts->subopts[conflict],
> + opts->name, opts->subopts[option]);
Why is it necessary to change this around? Surely
Cannot specify both -s barfu and -d fubar
and
Cannot specify both -d fubar and -s barfu
aren't /that/ much different?
Or is this one of those things that fixes up an xfstest or something?
(Not opposed, just wondering...)
--D
> usage();
> }
>
> @@ -1523,14 +1550,10 @@ data_opts_parser(
> cli->sb_feat.nodalign = getnum(value, opts, D_NOALIGN);
> break;
> case D_SECTLOG:
> - if (cli->sectorsize)
> - conflict(opts, D_SECTSIZE, opts, D_SECTLOG);
> sectorlog = getnum(value, opts, D_SECTLOG);
> cli->sectorsize = 1 << sectorlog;
> break;
> case D_SECTSIZE:
> - if (cli->sectorsize)
> - conflict(opts, D_SECTSIZE, opts, D_SECTLOG);
> cli->sectorsize = getnum(value, opts, D_SECTSIZE);
> break;
> case D_RTINHERIT:
> @@ -1756,17 +1779,13 @@ sector_opts_parser(
> switch (subopt) {
> case S_LOG:
> case S_SECTLOG:
> - if (cli->sectorsize)
> - conflict(opts, S_SECTSIZE, opts, S_SECTLOG);
> - sectorlog = getnum(value, opts, S_SECTLOG);
> + sectorlog = getnum(value, opts, subopt);
> cli->sectorsize = 1 << sectorlog;
> cli->lsectorsize = cli->sectorsize;
> break;
> case S_SIZE:
> case S_SECTSIZE:
> - if (cli->sectorsize)
> - conflict(opts, S_SECTSIZE, opts, S_SECTLOG);
> - cli->sectorsize = getnum(value, opts, S_SECTSIZE);
> + cli->sectorsize = getnum(value, opts, subopt);
> cli->lsectorsize = cli->sectorsize;
> break;
> default:
> --
> 2.15.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-12-20 3:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 9:11 [PATCH 0/7] mkfs: various cleanups Dave Chinner
2017-12-18 9:11 ` [PATCH 1/7] mkfs: use opts parameter during option parsing Dave Chinner
2017-12-20 2:47 ` Darrick J. Wong
2017-12-18 9:11 ` [PATCH 2/7] mkfs: simplify minimum log size calculation Dave Chinner
2017-12-20 3:02 ` Darrick J. Wong
2017-12-18 9:11 ` [PATCH 3/7] mkfs: protofile only needs to be set up once Dave Chinner
2017-12-20 2:48 ` Darrick J. Wong
2017-12-18 9:11 ` [PATCH 4/7] mkfs: support arbitrary conflict specification Dave Chinner
2017-12-20 2:53 ` Darrick J. Wong
2017-12-20 3:52 ` Dave Chinner
2017-12-24 20:45 ` Eric Sandeen
2017-12-28 21:45 ` Eric Sandeen
2017-12-18 9:11 ` [PATCH 5/7] mkfs: convert subopt name,val pairs to enums and declared arrays Dave Chinner
2017-12-20 2:56 ` Darrick J. Wong
2017-12-18 9:11 ` [PATCH 6/7] mkfs: resolve sector size CLI conflicts Dave Chinner
2017-12-20 2:59 ` Darrick J. Wong [this message]
2017-12-20 3:56 ` Dave Chinner
2017-12-28 21:36 ` Eric Sandeen
2017-12-18 9:11 ` [PATCH 7/7] mkfs: remove logarithm based CLI options Dave Chinner
2017-12-20 3:01 ` Darrick J. Wong
2017-12-20 4:01 ` Dave Chinner
2017-12-20 5:21 ` Darrick J. Wong
2017-12-28 21:35 ` Eric Sandeen
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=20171220025958.GN12613@magnolia \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/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).