From 746d40a73162f942f63f6a2f612f491d107b9824 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Thu, 20 Jul 2017 10:51:34 -0500 Subject: [PATCH] mkfs.xfs: allow specification of 0 data stripe width & unit The "noalign" option works for this too, but it seems reasonable to allow explicit specification of stripe unit and stripe width to 0; today, doing so today makes the code think it's unspecified, and so it goes ahead and detects stripe geometry and sets it in the superblock. That's unexpected and surprising. Create a new flag that tracks whtether a geometry option has been specified, and if it's set along with 0 values, treat it the same as if "noalign" had been specified. Signed-off-by: Eric Sandeen Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- mkfs/xfs_mkfs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: xfsprogs-rhel7.5/mkfs/xfs_mkfs.c =================================================================== --- xfsprogs-rhel7.5.orig/mkfs/xfs_mkfs.c +++ xfsprogs-rhel7.5/mkfs/xfs_mkfs.c @@ -909,6 +909,7 @@ main( int dsw; int dsunit; int dswidth; + int dsflag; int force_overwrite; struct fsxattr fsx; int iaflag; @@ -1012,7 +1013,7 @@ main( dfile = logfile = rtfile = NULL; dsize = logsize = rtsize = rtextsize = protofile = NULL; dsu = dsw = dsunit = dswidth = lalign = lsu = lsunit = 0; - nodsflag = norsflag = 0; + dsflag = nodsflag = norsflag = 0; force_overwrite = 0; worst_freelist = 0; lazy_sb_counters = 1; @@ -1137,6 +1138,7 @@ main( exit(1); } dsunit = cvtnum(0, 0, value); + dsflag = 1; break; case D_SWIDTH: if (!value || *value == '\0') @@ -1153,6 +1155,7 @@ main( exit(1); } dswidth = cvtnum(0, 0, value); + dsflag = 1; break; case D_SU: if (!value || *value == '\0') @@ -1164,6 +1167,7 @@ main( D_SU); dsu = cvtnum( blocksize, sectorsize, value); + dsflag = 1; break; case D_SW: if (!value || *value == '\0') @@ -1180,6 +1184,7 @@ main( exit(1); } dsw = cvtnum(0, 0, value); + dsflag = 1; break; case D_NOALIGN: if (dsu) @@ -2078,6 +2083,10 @@ _("warning: sparse inodes not supported calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize, &dsunit, &dswidth, &lsunit); + /* If sunit & swidth were manually specified as 0, same as noalign */ + if (dsflag && !dsunit && !dswidth) + nodsflag = 1; + xi.setblksize = sectorsize; /*