All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zhong <zhong@linux.vnet.ibm.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: xfsprogs <xfs@oss.sgi.com>
Subject: [PATCH] xfsprogs: cleanup size/log setting flags of mkfs
Date: Sun, 29 Sep 2013 17:12:51 +0800	[thread overview]
Message-ID: <1380445971.3811.14.camel@ThinkPad-T5421> (raw)
In-Reply-To: <1380437441.3811.9.camel@ThinkPad-T5421>

As Eric suggested, we could set both of the size/log flags after we have
parsed the options - and from there on it simply means "manually set".

After that, we could use just one flag, e.g. *sflag, to check whether 
the corresponding value is manually set or not.

Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
---
 mkfs/xfs_mkfs.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 34bf2ff..aa3f391 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1667,11 +1667,26 @@ main(
 		dfile = xi.dname;
 
 	/*
+	 * Later code wants to know if the user manually set a value.
+	 * There are two ways to specify on the cmdline; as size or as a log.
+	 * if either was used, set both flags - from here on it simply means
+	 * "manually set"
+	 */
+	if (bsflag || blflag)
+		bsflag = blflag = 1;
+	if (ssflag || slflag)
+		ssflag = slflag = 1;
+	if (isflag || ilflag)
+		isflag = ilflag = 1;
+	if (nsflag || nlflag)
+		nsflag = nlflag = 1;
+
+	/*
 	 * Blocksize and sectorsize first, other things depend on them
 	 * For RAID4/5/6 we want to align sector size and block size,
 	 * so we need to start with the device geometry extraction too.
 	 */
-	if (!blflag && !bsflag) {
+	if (!bsflag) {
 		blocklog = XFS_DFL_BLOCKSIZE_LOG;
 		blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
 	}
@@ -1693,7 +1708,7 @@ main(
 		 * ft.sectoralign will never be set.
 		 */
 		sectorsize = blocksize;
-	} else if (!ssflag && !slflag) {
+	} else if (!ssflag) {
 		/*
 		 * Unless specified manually on the command line use the
 		 * advertised sector size of the device.  We use the physical
@@ -1721,7 +1736,7 @@ _("switching to logical sector size %d\n"),
 		}
 	}
 
-	if (ft.sectoralign || (!ssflag && !slflag)) {
+	if (ft.sectoralign || !ssflag) {
 		sectorlog = libxfs_highbit32(sectorsize);
 		if (loginternal) {
 			lsectorsize = sectorsize;
@@ -1731,7 +1746,7 @@ _("switching to logical sector size %d\n"),
 
 	if (sectorsize < XFS_MIN_SECTORSIZE ||
 	    sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
-		if (ssflag || slflag)
+		if (ssflag)
 			fprintf(stderr, _("illegal sector size %d\n"), sectorsize);
 		else
 			fprintf(stderr,
@@ -1760,7 +1775,7 @@ _("block size %d cannot be smaller than logical sector size %d\n"),
 	 */
 	if (crcs_enabled) {
 		/* minimum inode size is 512 bytes, ipflag checked later */
-		if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) {
+		if (isflag && inodelog < XFS_DINODE_DFL_CRC_LOG) {
 			fprintf(stderr,
 _("Minimum inode size for CRCs is %d bytes\n"),
 				1 << XFS_DINODE_DFL_CRC_LOG);
@@ -1804,7 +1819,7 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n"));
 		}
 	}
 
-	if (nsflag || nlflag) {
+	if (nsflag) {
 		if (dirblocksize < blocksize ||
 					dirblocksize > XFS_MAX_BLOCKSIZE) {
 			fprintf(stderr, _("illegal directory block size %d\n"),
@@ -1850,7 +1865,7 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n"));
 	if (ipflag) {
 		inodelog = blocklog - libxfs_highbit32(inopblock);
 		isize = 1 << inodelog;
-	} else if (!ilflag && !isflag) {
+	} else if (!isflag) {
 		inodelog = crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
 					: XFS_DINODE_DFL_LOG;
 		isize = 1 << inodelog;
-- 
1.8.1.4



_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-09-29  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27  9:09 [PATCH] xfsprogs: make log/size consistent for mkfs's -s option Li Zhong
2013-09-27 17:29 ` Eric Sandeen
2013-09-27 23:39   ` Dave Chinner
2013-09-29  6:45   ` Li Zhong
2013-09-29  6:50   ` [PATCH v2] " Li Zhong
2013-09-29  9:12     ` Li Zhong [this message]
2013-09-29 23:06       ` [PATCH] xfsprogs: cleanup size/log setting flags of mkfs Dave Chinner
2013-09-30  3:04         ` Li Zhong
2013-09-30  3:14           ` Eric Sandeen
2013-09-30  5:24             ` Li Zhong
2013-09-30  5:20         ` [PATCH v2] " Li Zhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380445971.3811.14.camel@ThinkPad-T5421 \
    --to=zhong@linux.vnet.ibm.com \
    --cc=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.