]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs.xfs: don't detect geometry values <= psectorsize
authorEric Sandeen <sandeen@sandeen.net>
Wed, 12 Dec 2012 23:26:24 +0000 (17:26 -0600)
committerBen Myers <bpm@sgi.com>
Fri, 18 Jan 2013 22:10:38 +0000 (16:10 -0600)
blkid_get_topology() ignores devices which report 512
as their minimum & optimal IO size, but we should ignore
anything up to the physical sector size; otherwise hard-4k
sector devices will report a "stripe size" of 4k, and warn
if anything larger is specified:

# modprobe scsi_debug physblk_exp=3 num_parts=2 dev_size_mb=128
# mdadm --create /dev/md1 --level=0 --raid-devices=2  -c 4 /dev/sdb1 /dev/sdb2
# mkfs.xfs -f -d su=16k,sw=2 /dev/md1
mkfs.xfs: Specified data stripe unit 32 is not the same as the volume stripe unit 8
mkfs.xfs: Specified data stripe width 64 is not the same as the volume stripe width 16
...

but a stripe unit of 4k is pretty nonsensical.  And that's even chosen by
default in this case, which is maybe even worse?

# mkfs.xfs -f /dev/md1
meta-data=/dev/md1               isize=256    agcount=2, agsize=8125 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=16249, imaxpct=25
         =                       sunit=1      swidth=8 blks
...

We can rearrange things a bit, get the physical sector size first,
and then ignore reported minimum/optimal sizes which is no larger
than that.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
mkfs/xfs_mkfs.c

index 577880b1cf0423cc6cd5d91cfb82d2b3c09a91f4..3cfab0649abc93259dd9383ad6da5e1d0d626a33 100644 (file)
@@ -396,25 +396,25 @@ static void blkid_get_topology(
        if (!tp)
                goto out_free_probe;
 
+       val = blkid_topology_get_logical_sector_size(tp);
+       *lsectorsize = val;
+       val = blkid_topology_get_physical_sector_size(tp);
+       *psectorsize = 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 just the normal 512 byte block size
-        * do not bother to report anything.  It will just causes warnings
-        * if people specifier larger stripe units or widths manually.
+        * If the reported values are the same as the physical sector size
+        * do not bother to report anything.  It will just cause warnings
+        * if people specify larger stripe units or widths manually.
         */
-       val = blkid_topology_get_minimum_io_size(tp) >> 9;
-       if (val > 1)
-               *sunit = val;
-       val = blkid_topology_get_optimal_io_size(tp) >> 9;
-       if (val > 1)
-               *swidth = val;
-
-       val = blkid_topology_get_logical_sector_size(tp);
-       *lsectorsize = val;
-       val = blkid_topology_get_physical_sector_size(tp);
-       *psectorsize = val;
+       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 (blkid_topology_get_alignment_offset(tp) != 0) {
                fprintf(stderr,