]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: ignore stripe geom if sunit or swidth == physical sector size
authorEric Sandeen <sandeen@redhat.com>
Wed, 29 Oct 2014 05:34:38 +0000 (16:34 +1100)
committerDave Chinner <david@fromorbit.com>
Wed, 29 Oct 2014 05:34:38 +0000 (16:34 +1100)
Today, this geometry:

# modprobe scsi_debug  opt_blks=2048 dev_size_mb=2048
# blockdev --getpbsz --getss --getiomin --getioopt  /dev/sdd
512
512
512
1048576

will result in a warning at mkfs time, like this:

# mkfs.xfs -f -d su=64k,sw=12 -l su=64k /dev/sdd
mkfs.xfs: Specified data stripe width 1536 is not the same as the volume stripe width 2048

because our geometry discovery thinks it looks like a
valid striping setup which the commandline is overriding.
However, a stripe unit of 512 really isn't indicative of
a proper stripe geometry.

Prior to this patch, we reset only sunit *or* swidth,
if either was equal to physical block size, but not
necessarily both.

Change the heuristic so that if either the discovered
sunit or the discovered swidth is physical block size,
we reset *both* to zero and ignore the geom completely.

While we're at it, don't pass &dummy in for multiple
arguments to blkid_get_topology(); that'll mean that
inside the function, the last assignment wins, and could
lead to unexpected results.

Reported-by: Stan Hoeppner <stan@hardwarefreak.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
mkfs/xfs_mkfs.c

index 4546e357c1216fbc1552a91a31c6e24705e7be58..a0fed3171982352111b1758ba07697640751efdc 100644 (file)
@@ -410,21 +410,27 @@ static void blkid_get_topology(
        *lsectorsize = val;
        val = blkid_topology_get_physical_sector_size(tp);
        *psectorsize = val;
+       val = blkid_topology_get_minimum_io_size(tp);
+       *sunit = val;
+       val = blkid_topology_get_optimal_io_size(tp);
+       *swidth = val;
 
        /*
-        * Blkid reports the information in terms of bytes, but we want it in
-        * terms of 512 bytes blocks (just to convert it to bytes later..)
-        *
         * If the reported values are the same as the physical sector size
-        * do not bother to report anything.  It will just cause warnings
+        * do not bother to report anything.  It will only cause warnings
         * if people specify larger stripe units or widths manually.
         */
-       val = blkid_topology_get_minimum_io_size(tp);
-       if (val > *psectorsize)
-               *sunit = val >> 9;
-       val = blkid_topology_get_optimal_io_size(tp);
-       if (val > *psectorsize)
-               *swidth = val >> 9;
+       if (*sunit == *psectorsize || *swidth == *psectorsize) {
+               *sunit = 0;
+               *swidth = 0;
+       }
+
+       /*
+        * Blkid reports the information in terms of bytes, but we want it in
+        * terms of 512 bytes blocks (only to convert it to bytes later..)
+        */
+       *sunit = *sunit >> 9;
+       *swidth = *swidth >> 9; 
 
        if (blkid_topology_get_alignment_offset(tp) != 0) {
                fprintf(stderr,
@@ -484,10 +490,10 @@ static void get_topology(
        }
 
        if (xi->rtname && !xi->risfile) {
-               int dummy;
+               int sunit, lsectorsize, psectorsize;
 
-               blkid_get_topology(xi->rtname, &dummy, &ft->rtswidth,
-                                  &dummy, &dummy, force_overwrite);
+               blkid_get_topology(xi->rtname, &sunit, &ft->rtswidth,
+                                  &lsectorsize, &psectorsize, force_overwrite);
        }
 }
 #else /* ENABLE_BLKID */