From: Jan Tulak <jtulak@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 7/7] mkfs: save user input values into opts
Date: Thu, 27 Jul 2017 16:21:18 +0200 [thread overview]
Message-ID: <f506b08d-361f-041c-5667-5555f4833890@redhat.com> (raw)
In-Reply-To: <b9dca0fe-be1f-258e-8e55-0ecff3669139@sandeen.net>
On 27/07/2017 01:53, Eric Sandeen wrote:
> On 7/20/17 4:29 AM, Jan Tulak wrote:
>> Save the parsed values from users into the opts table. This will ensure that
>> the user values gets there and are validated, but we are not yet using them for
>> anything - the usage makes a lot of changes through the code, so it is better
>> if that is separated into smaller chunks.
>>
>> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> This seems reasonable, but AFAICT nothing uses the set values yet,
> right? As such I'll probably hold off on merging it until somethig
> makes use of the result... i.e. merge it (and the prior patch)
> along with later patches which make use of the stored values.
The second patchset I submitted just after this one uses it. I just
split it, so this set doesn't have to wait if there are any issues in
the second part. But if you would rather merge it together, I'm ok with
it and if I will need to respin a whole set once more in a final
version, I can put it together again.
>
> Also, questions below.
>
>> case I_PROJID32BIT:
>> sb_feat.projid16bit =
>> !getnum(value, &opts[OPT_I],
>> I_PROJID32BIT);
>> + set_conf_val(OPT_I, I_PROJID32BIT,
>> + sb_feat.projid16bit);
>> break;
> why isn't this just:
>
> sb_feat.projid16bit = parse_conf_val(OPT_I, I_PROJID32BIT, value) ?
Note the ! in the getnum assignment, we have two variables with opposite
values (16/32 bit) - that's the reason why I used getnum. But there
indeed is an issue with that - the set_conf_val shouldn't be the same
value as the sb_feat. So, I'm changing it to:
sb_feat.projid16bit = ! parse_conf_val(OPT_I, I_PROJID32BIT, value);
>
>
>> @@ -1812,34 +1843,48 @@ main(
>> xi.logname = logfile;
>> ldflag = 1;
>> loginternal = 0;
>> + set_conf_val(OPT_L, L_NAME, 1);
>> + set_conf_val(OPT_L, L_DEV, 1);
> Hm, ok, maybe these subopts will collapse into one some day?
It is on my (long) TODO. But it might be a change simple enough to do it
ASAP.
>
>> break;
>> case L_VERSION:
>> sb_feat.log_version =
>> - getnum(value, &opts[OPT_L],
>> - L_VERSION);
>> + parse_conf_val(OPT_L,
>> + L_VERSION,
>> + value);
>> lvflag = 1;
>> + set_conf_val(OPT_L, L_VERSION,
>> + sb_feat.log_version);
>> break;
> wait, didn't parse_conf_val already set a value into OPT_L, L_VERSION?
>
>
>> case M_FINOBT:
>> - sb_feat.finobt = getnum(
>> - value, &opts[OPT_M], M_FINOBT);
>> + sb_feat.finobt =
>> + parse_conf_val(OPT_M, M_FINOBT,
>> + value);
>> + set_conf_val(OPT_M, M_FINOBT,
>> + sb_feat.finobt);
> Same here, hasn't OPT_M, M_FINOBT's value already been set by the parse
> call?
Yes and yes. Removing.
>
>> @@ -1920,14 +1977,17 @@ main(
>> } else {
>> sb_feat.dir_version =
>> getnum(value,
>> - &opts[OPT_N],
>> - N_VERSION);
>> + &opts[OPT_N],
>> + N_VERSION);
>> }
>> nvflag = 1;
>> + set_conf_val(OPT_N, N_VERSION,
>> + sb_feat.dir_version);
> shouldn't this be in the else clause? We didn't necessarily set a
> version number, right? Also, should the ci state be stored as well?
> i.e.
>
> case N_VERSION:
> value = getstr(value, &nopts, N_VERSION);
> if (!strcasecmp(value, "ci")) {
> /* ASCII CI mode */
> sb_feat.nci = true;
> /* is this in the opts table anywhere? */
> } else {
> sb_feat.dir_version =
> parse_conf_val(OPT_N,
> N_VERSION,
> value);
> }
> nvflag = 1;
> break;
To be honest, I think this option is weird; it feels to me like two
options merged into one. It has only two valid values: 2 and 'ci'. But 2
is a version, which could be any number, and ci is a modifier for the
given version.
I mean, it looks like it should be accepting "2 or 2ci", rather than "2
or ci". Because the ci is just a modifier and the version remains as 2.
Or we can say that this option only decides ci/non-ci, and then the
option would better to be renamed and turned to a flag.
But either of those would be a visible change to the interface, so I
tried to avoid it. sb_feat.dir_version seems to be used later in the
code even when nci is set and the dir_version is currently always 2.
Thus I put the assignment to happen either way, to avoid hardcoding one
value at multiple places: we save whatever is the value of dir_version,
either from user or from default (XFS_DFL_DIR_VERSION).
At this moment, I'm not saving the ci flag anywhere. Once the opts can
hold strings and not only numbers, it becomes no issue, but now I would
have to add another option as a flag, or save something else than the
version into opt (e.g. 1 or 3 or anything else than 2...) but that would
bring its own issues. The way I did it (ignoring a value that we won't
read from opts anytime soon anyway) seems the safest to me.
>
>> break;
>> case N_FTYPE:
>> - sb_feat.dirftype = getnum(value,
>> - &opts[OPT_N], N_FTYPE);
>> + sb_feat.dirftype =
>> + parse_conf_val(OPT_N, N_FTYPE,
>> + value);
>> break;
>> default:
>> unknown('n', value);
>> @@ -1957,25 +2017,30 @@ main(
>>
>> switch (getsubopt(&p, subopts, &value)) {
>> case R_EXTSIZE:
>> - rtextbytes = getnum(value,
>> - &opts[OPT_R], R_EXTSIZE);
>> + rtextbytes = parse_conf_val(OPT_R,
>> + R_EXTSIZE,
>> + value);
>> break;
>> case R_FILE:
>> - xi.risfile = getnum(value,
>> - &opts[OPT_R], R_FILE);
>> + xi.risfile = parse_conf_val(OPT_R,
>> + R_FILE,
>> + value);
>> break;
>> case R_NAME:
>> case R_DEV:
>> xi.rtname = getstr(value, &opts[OPT_R],
>> R_NAME);
>> + set_conf_val(OPT_R, R_NAME, 1);
>> + set_conf_val(OPT_R, R_DEV, 1);
>> break;
>> case R_SIZE:
>> - rtbytes = getnum(value, &opts[OPT_R],
>> - R_SIZE);
>> + rtbytes = parse_conf_val(OPT_R, R_SIZE,
>> + value);
>> break;
>> case R_NOALIGN:
>> - norsflag = getnum(value, &opts[OPT_R],
>> - R_NOALIGN);
>> + norsflag = parse_conf_val(OPT_R,
>> + R_NOALIGN,
>> + value);
>> break;
>> default:
>> unknown('r', value);
>> @@ -1996,12 +2061,14 @@ main(
>> conflict('s', subopts,
>> S_SECTSIZE,
>> S_SECTLOG);
>> - sectorlog = getnum(value, &opts[OPT_S],
>> - S_SECTLOG);
>> + sectorlog = parse_conf_val(OPT_S,
>> + S_SECTLOG,
>> + value);
>> lsectorlog = sectorlog;
>> sectorsize = 1 << sectorlog;
>> lsectorsize = sectorsize;
>> lslflag = slflag = 1;
>> + set_conf_val(OPT_S, S_LOG, sectorsize);
> Is this right? S_LOG is the log of the sectorsize, right, not the sector size
> itself. Do S_SIZE & S_SECTSIZE need to be stored as well?
This appears to be an issue. I'll fix it.
>
>> break;
>> case S_SIZE:
>> case S_SECTSIZE:
>> @@ -2009,13 +2076,16 @@ main(
>> conflict('s', subopts,
>> S_SECTLOG,
>> S_SECTSIZE);
>> - sectorsize = getnum(value,
>> - &opts[OPT_S], S_SECTSIZE);
>> + sectorsize = parse_conf_val(OPT_S,
>> + S_SECTSIZE,
>> + value);
>> lsectorsize = sectorsize;
>> sectorlog =
>> libxfs_highbit32(sectorsize);
>> lsectorlog = sectorlog;
>> lssflag = ssflag = 1;
>> + set_conf_val(OPT_S,
>> + S_SIZE, sectorlog);
> same questions here - this looks wrong, and other values not stored, do
> they need to be?
>
>> break;
>> default:
>> unknown('s', value);
>>
Thanks,
Jan
prev parent reply other threads:[~2017-07-27 14:21 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 9:29 [PATCH 0/7] mkfs: save user input into opts table Jan Tulak
2017-07-20 9:29 ` [PATCH 1/7] mkfs: Save raw user input field to the opts struct Jan Tulak
2017-07-27 16:27 ` Luis R. Rodriguez
2017-07-28 14:45 ` Jan Tulak
2017-07-29 17:12 ` Luis R. Rodriguez
2017-08-02 14:30 ` Jan Tulak
2017-08-02 15:51 ` Jan Tulak
2017-08-02 19:41 ` Luis R. Rodriguez
2017-08-02 19:19 ` Luis R. Rodriguez
2017-08-03 13:07 ` Jan Tulak
2017-08-03 22:25 ` Luis R. Rodriguez
2017-08-04 13:50 ` Jan Tulak
2017-08-07 17:26 ` Luis R. Rodriguez
2017-08-07 17:36 ` Jan Tulak
2017-07-20 9:29 ` [PATCH 2/7] mkfs: rename defaultval to flagval in opts Jan Tulak
2017-07-20 9:29 ` [PATCH 3/7] mkfs: remove intermediate getstr followed by getnum Jan Tulak
2017-07-20 15:54 ` Darrick J. Wong
2017-07-21 8:56 ` Jan Tulak
2017-07-26 20:49 ` Eric Sandeen
2017-07-27 7:50 ` Jan Tulak
2017-07-27 13:35 ` Eric Sandeen
2017-07-21 12:24 ` [PATCH 3/7 v2] " Jan Tulak
2017-07-26 23:23 ` Eric Sandeen
2017-07-20 9:29 ` [PATCH 4/7] mkfs: merge tables for opts parsing into one table Jan Tulak
2017-07-20 9:29 ` [PATCH 5/7] mkfs: move getnum within the file Jan Tulak
2017-07-26 23:27 ` Eric Sandeen
2017-07-20 9:29 ` [PATCH 6/7] mkfs: extend opt_params with a value field Jan Tulak
2017-07-27 16:18 ` Luis R. Rodriguez
2017-07-28 14:44 ` Jan Tulak
2017-07-29 17:02 ` Luis R. Rodriguez
2017-08-02 14:43 ` Jan Tulak
2017-08-02 16:57 ` Luis R. Rodriguez
2017-08-02 18:11 ` Jan Tulak
2017-08-02 19:48 ` Luis R. Rodriguez
2017-08-03 13:23 ` Jan Tulak
2017-08-03 20:47 ` Luis R. Rodriguez
2017-07-20 9:29 ` [PATCH 7/7] mkfs: save user input values into opts Jan Tulak
2017-07-26 23:53 ` Eric Sandeen
2017-07-27 14:21 ` Jan Tulak [this message]
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=f506b08d-361f-041c-5667-5555f4833890@redhat.com \
--to=jtulak@redhat.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 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.