public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 7/2] mkfs: more sunit/swidth sanity checking
Date: Tue, 30 Jan 2018 08:48:38 -0800	[thread overview]
Message-ID: <20180130164838.GA4849@magnolia> (raw)
In-Reply-To: <1c6697a8-3e71-31b5-e07d-375eb766f85c@sandeen.net>

On Mon, Jan 29, 2018 at 10:13:58PM -0600, Eric Sandeen wrote:
> This fixes 2 issues with stripe geometry validation.
> 
> # mkfs.xfs -d sunit=64,swidth=0 ...
> both data sunit and data swidth options must be specified
> 
> But I did specify it, I specified 0!
> 
> So use cli_opt_set() to detect that it was specified.
> 
> But we can't allow the above configuration (in fact it causes
> a % 0 later in mkfs), so catch it in the "swidth must be a
> multiple of sunit" test a bit further down.
> 
> (sunit=0,swidth=0 /is/ valid, it's used to override disk
> geometry if desired.)
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
> 
> don't mind my mkfs patch series hijacking! ;)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index f527476..219b209 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2233,7 +2233,7 @@ calc_stripe_factors(
>  		dsw = cli->dsw;
>  
>  	/* data sunit/swidth options */
> -	if ((dsunit && !dswidth) || (!dsunit && dswidth)) {
> +	if (cli_opt_set(&dopts, D_SUNIT) != cli_opt_set(&dopts, D_SWIDTH)) {
>  		fprintf(stderr,
>  _("both data sunit and data swidth options must be specified\n"));
>  		usage();
> @@ -2241,7 +2241,7 @@ _("both data sunit and data swidth options must be specified\n"));
>  
>  	/* convert dsu/dsw to dsunit/dswidth and use them from now on */
>  	if (dsu || dsw) {
> -		if ((dsu && !dsw) || (!dsu && dsw)) {
> +		if (cli_opt_set(&dopts, D_SU) != cli_opt_set(&dopts, D_SW)) {
>  			fprintf(stderr,
>  _("both data su and data sw options must be specified\n"));
>  			usage();
> @@ -2264,7 +2264,7 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit (
>  		dswidth = big_dswidth;
>  	}
>  
> -	if (dsunit && (dswidth % dsunit != 0)) {
> +	if (dsunit && (!dswidth || (dswidth % dsunit != 0))) {
>  		fprintf(stderr,
>  _("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n"),
>  			dswidth, dsunit);
> 
> --
> 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

      reply	other threads:[~2018-01-30 16:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 23:48 [PATCH 0/2] xfsprogs: 4.15 rollup pt. 3 Darrick J. Wong
2018-01-25 23:48 ` [PATCH 1/2] xfs_db: print transaction reservation type information Darrick J. Wong
2018-01-25 23:48 ` [PATCH 2/2] xfs_db: interpret inode timestamps as signed integers Darrick J. Wong
2018-01-30 16:46   ` Eric Sandeen
2018-01-26 18:14 ` [PATCH 3/2] misc: ubsan fixes Darrick J. Wong
2018-01-30 16:47   ` Eric Sandeen
2018-01-30  3:38 ` [PATCH 4/2] mkfs: don't crash on dswidth overflow Darrick J. Wong
2018-01-30  3:54   ` Eric Sandeen
2018-01-30  3:38 ` [PATCH 5/2] mkfs: don't call values 'illegal', they're invalid Darrick J. Wong
2018-01-30  3:55   ` Eric Sandeen
2018-01-30  3:39 ` [PATCH 6/2] mkfs: always explain why numeric inputs are invalid Darrick J. Wong
2018-01-30  3:57   ` Eric Sandeen
2018-01-30  4:13 ` [PATCH 7/2] mkfs: more sunit/swidth sanity checking Eric Sandeen
2018-01-30 16:48   ` Darrick J. Wong [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=20180130164838.GA4849@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --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