xfs
[Top] [All Lists]

[PATCH v2] xfsprogs: make log/size consistent for mkfs's -s option

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: [PATCH v2] xfsprogs: make log/size consistent for mkfs's -s option
From: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx>
Date: Sun, 29 Sep 2013 14:50:41 +0800
Cc: xfsprogs <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <5245C07A.3000700@xxxxxxxxxxx>
References: <1380272973.2836.5.camel@ThinkPad-T5421> <5245C07A.3000700@xxxxxxxxxxx>
It seems using -s log is not able to set the sectsz correctly. Because slflag
is set but ignored by later codes, so the advertised sector size of the device
is used instead.

$ mkfs.xfs -f -s size=4096 /dev/sdd
meta-data=/dev/sdd               isize=256    agcount=2, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         ......

$ mkfs.xfs -f -s log=12 /dev/sdd
meta-data=/dev/sdd               isize=256    agcount=2, agsize=4096 blks
         =                       sectsz=2048  attr=2, projid32bit=1
         ......

Signed-off-by: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx>
---
v2: fix an error in v1 found by Eric reviewing the code.

 mkfs/xfs_mkfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index eafbed3..34bf2ff 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1693,7 +1693,7 @@ main(
                 * ft.sectoralign will never be set.
                 */
                sectorsize = blocksize;
-       } else if (!ssflag) {
+       } else if (!ssflag && !slflag) {
                /*
                 * Unless specified manually on the command line use the
                 * advertised sector size of the device.  We use the physical
@@ -1721,7 +1721,7 @@ _("switching to logical sector size %d\n"),
                }
        }
 
-       if (ft.sectoralign || !ssflag) {
+       if (ft.sectoralign || (!ssflag && !slflag)) {
                sectorlog = libxfs_highbit32(sectorsize);
                if (loginternal) {
                        lsectorsize = sectorsize;
@@ -1731,7 +1731,7 @@ _("switching to logical sector size %d\n"),
 
        if (sectorsize < XFS_MIN_SECTORSIZE ||
            sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
-               if (ssflag)
+               if (ssflag || slflag)
                        fprintf(stderr, _("illegal sector size %d\n"), 
sectorsize);
                else
                        fprintf(stderr,
-- 
1.8.1.4



<Prev in Thread] Current Thread [Next in Thread>