]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: get sector size from host fs d_miniosz when mkfs'ing file
authorEric Sandeen <sandeen@sandeen.net>
Fri, 18 Dec 2015 01:15:25 +0000 (12:15 +1100)
committerDave Chinner <david@fromorbit.com>
Fri, 18 Dec 2015 01:15:25 +0000 (12:15 +1100)
Now that we allow logical-sector-sized DIOs even if our xfs
filesystem is set to physical-sector-sized "sectors," we can
allow the creation of filesystem images with block and sector
sizes down to the host device's logical sector size, rather
than the filesystem's sector size.

So in platform_findsizes(), change our query of the filesystem
to an XFS_IOC_DIOINFO query, and use the returned d_miniosz for
sector size in the S_IFREG case.

This allows the creation of i.e. a 2k block sized image on
an xfs filesystem w/ 4k sector size created on a 4k/512
block device, which would otherwise fail today.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/linux.c

index 885016a016734d71e50ee8e76c3c40d808a95e29..f6ea1b2ce74753e2e241e43488e8d69ba513be12 100644 (file)
@@ -142,18 +142,20 @@ platform_findsizes(char *path, int fd, long long *sz, int *bsz)
                        progname, path, strerror(errno));
                exit(1);
        }
+
        if ((st.st_mode & S_IFMT) == S_IFREG) {
-               struct xfs_fsop_geom_v1 geom = { 0 };
+               struct dioattr  da;
 
                *sz = (long long)(st.st_size >> 9);
-               if (ioctl(fd, XFS_IOC_FSGEOMETRY_V1, &geom) < 0) {
+
+               if (ioctl(fd, XFS_IOC_DIOINFO, &da) < 0) {
                        /*
                         * fall back to BBSIZE; mkfs might fail if there's a
                         * size mismatch between the image & the host fs...
                         */
                        *bsz = BBSIZE;
                } else
-                       *bsz = geom.sectsize;
+                       *bsz = da.d_miniosz;
 
                if (*bsz > max_block_alignment)
                        max_block_alignment = *bsz;