diff mbox

mkfs.xfs: if either sunit or swidth is nonzero, the other must be as well

Message ID 026467a9-0249-26a4-9661-c2f5f6e0586e@sandeen.net (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Eric Sandeen May 17, 2018, 6:33 p.m. UTC
Don't allow the user to set one but not the other.

Reported-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---



--
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

Comments

Darrick J. Wong May 17, 2018, 7:44 p.m. UTC | #1
On Thu, May 17, 2018 at 01:33:29PM -0500, Eric Sandeen wrote:
> Don't allow the user to set one but not the other.
> 
> Reported-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

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

--D

> ---
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 78d0ce5..b356d4d 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2271,7 +2271,8 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit (
>  		dswidth = big_dswidth;
>  	}
> -	if (dsunit && (!dswidth || (dswidth % dsunit != 0))) {
> +	if ((dsunit && !dswidth) || (!dsunit && dswidth) ||
> +           (dsunit && (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
--
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
Bill O'Donnell May 17, 2018, 9:11 p.m. UTC | #2
On Thu, May 17, 2018 at 01:33:29PM -0500, Eric Sandeen wrote:
> Don't allow the user to set one but not the other.
> 
> Reported-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

looks fine.

Reviewed-by: Bill O'Donnell <billodo@redhat.com>

> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 78d0ce5..b356d4d 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2271,7 +2271,8 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit (
>  		dswidth = big_dswidth;
>  	}
> -	if (dsunit && (!dswidth || (dswidth % dsunit != 0))) {
> +	if ((dsunit && !dswidth) || (!dsunit && dswidth) ||
> +           (dsunit && (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
--
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
diff mbox

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 78d0ce5..b356d4d 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2271,7 +2271,8 @@  _("data stripe width (%lld) is too large of a multiple of the data stripe unit (
  		dswidth = big_dswidth;
  	}
  
-	if (dsunit && (!dswidth || (dswidth % dsunit != 0))) {
+	if ((dsunit && !dswidth) || (!dsunit && dswidth) ||
+           (dsunit && (dswidth % dsunit != 0))) {
  		fprintf(stderr,
  _("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n"),
  			dswidth, dsunit);