All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6 v2] mkfs: use user values saved in opts table
@ 2017-08-11 12:30 Jan Tulak
  2017-08-11 12:30 ` [PATCH 1/6] mkfs: save user input values into opts Jan Tulak
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Second version of this set. All issues raised so far should be addressed.
The first patch of this set was moved from the other set ("save user input into
opts table"), see specific patches for description of changes.

Text from v1 follows:

The previous set (mkfs: save user input into opts table) added infrastructure,
which we are going to use now. I split it into two patchsets, because this
part is more ugly, so if there is an issue with this part, it doesn't stop
the other patches from merging.

The only thing this set is doing is that it replaces various ad-hoc variables
with set/get functions. As a result, we now have just a single place for these
values to be.  Once all the values are in a single place, we can expand the
automated validation and use it e.g.  for loading up optional config file like
Luis wants to do.

I'm not removing all variables, because for now, we need e.g. flags which are
not in the opts table. This is something that can happen later on, but for now,
I'm just replacing variables that can be done 1:1.

Jan Tulak (6):
  mkfs: save user input values into opts
  mkfs: replace variables with opts table: -b,d,s options
  mkfs: replace variables with opts table: -i options
  mkfs: replace variables with opts table: -l options
  mkfs: replace variables with opts table: -n options
  mkfs: replace variables with opts table: -r options

 mkfs/xfs_mkfs.c | 1246 ++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 728 insertions(+), 518 deletions(-)

-- 
2.13.3


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] mkfs: save user input values into opts
  2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
@ 2017-08-11 12:30 ` Jan Tulak
  2017-08-14 23:21   ` Darrick J. Wong
  2017-08-11 12:30 ` [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Save the parsed values from users into the opts table. This will ensure
that the user values gets there and are validated, but we are not yet
using them for anything - the usage makes a lot of changes through the
code, so it is better if that is separated into smaller chunks.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
Edit:
 * sectorizes fix
 * remove collateral assignments that are now covered within parse
   function
 * remove duplicit assignments into opts within one option
 * fix issue with proj(16|32)bit
 * updated description
---
 mkfs/xfs_mkfs.c | 239 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 142 insertions(+), 97 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 61ef09e8..12ffa715 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1826,14 +1826,15 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case B_LOG:
-					blocklog = getnum(value, &opts[OPT_B],
-								B_LOG);
+					blocklog = parse_conf_val(OPT_B, B_LOG,
+								  value);
 					blocksize = 1 << blocklog;
 					blflag = 1;
 					break;
 				case B_SIZE:
-					blocksize = getnum(value, &opts[OPT_B],
-							   B_SIZE);
+					blocksize = parse_conf_val(OPT_B,
+								   B_SIZE,
+								   value);
 					blocklog = libxfs_highbit32(blocksize);
 					bsflag = 1;
 					break;
@@ -1851,80 +1852,92 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case D_AGCOUNT:
-					agcount = getnum(value, &opts[OPT_D],
-							 D_AGCOUNT);
+					agcount = parse_conf_val(OPT_D,
+								 D_AGCOUNT,
+								 value);
 					daflag = 1;
 					break;
 				case D_AGSIZE:
-					agsize = getnum(value, &opts[OPT_D],
-								D_AGSIZE);
+					agsize = parse_conf_val(OPT_D,
+								D_AGSIZE,
+								value);
 					dasize = 1;
 					break;
 				case D_FILE:
-					xi.disfile = getnum(value,
-						&opts[OPT_D], D_FILE);
+					xi.disfile = parse_conf_val(OPT_D,
+								    D_FILE,
+								    value);
 					break;
 				case D_NAME:
 					xi.dname = getstr(value, &opts[OPT_D],
 								D_NAME);
+					set_conf_val(OPT_D, D_NAME,  1);
 					break;
 				case D_SIZE:
-					dbytes = getnum(value, &opts[OPT_D],
-								D_SIZE);
+					dbytes = parse_conf_val(OPT_D, D_SIZE,
+								value);
 					break;
 				case D_SUNIT:
-					dsunit = getnum(value, &opts[OPT_D],
-								D_SUNIT);
+					dsunit = parse_conf_val(OPT_D, D_SUNIT,
+								value);
 					dsflag = 1;
 					break;
 				case D_SWIDTH:
-					dswidth = getnum(value, &opts[OPT_D],
-							 D_SWIDTH);
+					dswidth = parse_conf_val(OPT_D,
+								 D_SWIDTH,
+								 value);
 					dsflag = 1;
 					break;
 				case D_SU:
-					dsu = getnum(value, &opts[OPT_D],
-								D_SU);
+					dsu = parse_conf_val(OPT_D, D_SU,
+							     value);
 					dsflag = 1;
 					break;
 				case D_SW:
-					dsw = getnum(value, &opts[OPT_D],
-								D_SW);
+					dsw = parse_conf_val(OPT_D, D_SW,
+							     value);
 					dsflag = 1;
 					break;
 				case D_NOALIGN:
-					nodsflag = getnum(value, &opts[OPT_D],
-								D_NOALIGN);
+					nodsflag = parse_conf_val(OPT_D,
+								  D_NOALIGN,
+								  value);
 					break;
 				case D_SECTLOG:
-					sectorlog = getnum(value, &opts[OPT_D],
-							   D_SECTLOG);
+					sectorlog = parse_conf_val(OPT_D,
+								   D_SECTLOG,
+								   value);
 					sectorsize = 1 << sectorlog;
 					slflag = 1;
 					break;
 				case D_SECTSIZE:
-					sectorsize = getnum(value,
-						&opts[OPT_D], D_SECTSIZE);
+					sectorsize = parse_conf_val(OPT_D,
+								    D_SECTSIZE,
+								    value);
 					sectorlog =
 						libxfs_highbit32(sectorsize);
 					ssflag = 1;
 					break;
 				case D_RTINHERIT:
-					c = getnum(value, &opts[OPT_D],
-								D_RTINHERIT);
+					c = parse_conf_val(OPT_D, D_RTINHERIT,
+							   value);
 					if (c)
 						fsx.fsx_xflags |=
 							XFS_DIFLAG_RTINHERIT;
 					break;
 				case D_PROJINHERIT:
-					fsx.fsx_projid = getnum(value,
-						&opts[OPT_D], D_PROJINHERIT);
+					fsx.fsx_projid =
+						parse_conf_val(OPT_D,
+							       D_PROJINHERIT,
+							       value);
 					fsx.fsx_xflags |=
 						XFS_DIFLAG_PROJINHERIT;
 					break;
 				case D_EXTSZINHERIT:
-					fsx.fsx_extsize = getnum(value,
-						&opts[OPT_D], D_EXTSZINHERIT);
+					fsx.fsx_extsize =
+						parse_conf_val(OPT_D,
+							       D_EXTSZINHERIT,
+							       value);
 					fsx.fsx_xflags |=
 						XFS_DIFLAG_EXTSZINHERIT;
 					break;
@@ -1942,45 +1955,49 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case I_ALIGN:
-					sb_feat.inode_align = getnum(value,
-						&opts[OPT_I], I_ALIGN);
+					sb_feat.inode_align =
+						parse_conf_val(OPT_I, I_ALIGN,
+							       value);
 					break;
 				case I_LOG:
-					inodelog = getnum(value, &opts[OPT_I],
-								I_LOG);
+					inodelog = parse_conf_val(OPT_I, I_LOG,
+								  value);
 					isize = 1 << inodelog;
 					ilflag = 1;
 					break;
 				case I_MAXPCT:
-					imaxpct = getnum(value, &opts[OPT_I],
-							 I_MAXPCT);
+					imaxpct = parse_conf_val(OPT_I,
+								 I_MAXPCT,
+								 value);
 					imflag = 1;
 					break;
 				case I_PERBLOCK:
-					inopblock = getnum(value, &opts[OPT_I],
-							   I_PERBLOCK);
+					inopblock = parse_conf_val(OPT_I,
+								   I_PERBLOCK,
+								   value);
 					ipflag = 1;
 					break;
 				case I_SIZE:
-					isize = getnum(value, &opts[OPT_I],
-								I_SIZE);
+					isize = parse_conf_val(OPT_I, I_SIZE,
+							       value);
 					inodelog = libxfs_highbit32(isize);
 					isflag = 1;
 					break;
 				case I_ATTR:
 					sb_feat.attr_version =
-						getnum(value, &opts[OPT_I],
-								I_ATTR);
+						parse_conf_val(OPT_I, I_ATTR,
+							       value);
 					break;
 				case I_PROJID32BIT:
 					sb_feat.projid16bit =
-						!getnum(value, &opts[OPT_I],
-							I_PROJID32BIT);
+						!parse_conf_val(OPT_I,
+							I_PROJID32BIT, value);
 					break;
 				case I_SPINODES:
-					sb_feat.spinodes = getnum(value,
-								&opts[OPT_I],
-								I_SPINODES);
+					sb_feat.spinodes =
+						parse_conf_val(OPT_I,
+							       I_SPINODES,
+							       value);
 					break;
 				default:
 					unknown('i', value);
@@ -1996,27 +2013,31 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case L_AGNUM:
-					logagno = getnum(value, &opts[OPT_L],
-								L_AGNUM);
+					logagno = parse_conf_val(OPT_L,
+								 L_AGNUM,
+								 value);
 					laflag = 1;
 					break;
 				case L_FILE:
-					xi.lisfile = getnum(value,
-						&opts[OPT_L], L_FILE);
+					xi.lisfile = parse_conf_val(OPT_L,
+								    L_FILE,
+								    value);
 					break;
 				case L_INTERNAL:
-					loginternal = getnum(value,
-						&opts[OPT_L], L_INTERNAL);
+					loginternal =
+						parse_conf_val(OPT_L,
+							       L_INTERNAL,
+							       value);
 					liflag = 1;
 					break;
 				case L_SU:
-					lsu = getnum(value, &opts[OPT_L],
-								L_SU);
+					lsu = parse_conf_val(OPT_L, L_SU,
+							     value);
 					lsuflag = 1;
 					break;
 				case L_SUNIT:
-					lsunit = getnum(value, &opts[OPT_L],
-								L_SUNIT);
+					lsunit = parse_conf_val(OPT_L, L_SUNIT,
+								value);
 					lsunitflag = 1;
 					break;
 				case L_NAME:
@@ -2026,34 +2047,42 @@ main(
 					xi.logname = logfile;
 					ldflag = 1;
 					loginternal = 0;
+					set_conf_val(OPT_L, L_NAME, 1);
+					set_conf_val(OPT_L, L_DEV, 1);
 					break;
 				case L_VERSION:
 					sb_feat.log_version =
-						getnum(value, &opts[OPT_L],
-								L_VERSION);
+						parse_conf_val(OPT_L,
+							       L_VERSION,
+							       value);
 					lvflag = 1;
 					break;
 				case L_SIZE:
-					logbytes = getnum(value,
-						&opts[OPT_L], L_SIZE);
+					logbytes = parse_conf_val(OPT_L,
+								  L_SIZE,
+								  value);
 					break;
 				case L_SECTLOG:
-					lsectorlog = getnum(value,
-						&opts[OPT_L], L_SECTLOG);
+					lsectorlog = parse_conf_val(OPT_L,
+								    L_SECTLOG,
+								    value);
 					lsectorsize = 1 << lsectorlog;
 					lslflag = 1;
 					break;
 				case L_SECTSIZE:
-					lsectorsize = getnum(value,
-						&opts[OPT_L], L_SECTSIZE);
+					lsectorsize =
+						parse_conf_val(OPT_L,
+							       L_SECTSIZE,
+							       value);
 					lsectorlog =
 						libxfs_highbit32(lsectorsize);
 					lssflag = 1;
 					break;
 				case L_LAZYSBCNTR:
 					sb_feat.lazy_sb_counters =
-						getnum(value, &opts[OPT_L],
-							L_LAZYSBCNTR);
+						parse_conf_val(OPT_L,
+							       L_LAZYSBCNTR,
+							       value);
 					break;
 				default:
 					unknown('l', value);
@@ -2075,29 +2104,33 @@ main(
 				switch (getsubopt(&p, subopts, &value)) {
 				case M_CRC:
 					sb_feat.crcs_enabled =
-						getnum(value, &opts[OPT_M],
-								M_CRC);
+						parse_conf_val(OPT_M, M_CRC,
+							       value);
 					if (sb_feat.crcs_enabled)
 						sb_feat.dirftype = true;
 					break;
 				case M_FINOBT:
-					sb_feat.finobt = getnum(
-						value, &opts[OPT_M], M_FINOBT);
+					sb_feat.finobt =
+						parse_conf_val(OPT_M, M_FINOBT,
+							       value);
 					break;
 				case M_UUID:
 					if (!value || *value == '\0')
 						reqval('m', subopts, M_UUID);
 					if (platform_uuid_parse(value, &uuid))
 						illegal(optarg, "m uuid");
+					set_conf_val(OPT_M, M_UUID, 1);
 					break;
 				case M_RMAPBT:
-					sb_feat.rmapbt = getnum(
-						value, &opts[OPT_M], M_RMAPBT);
+					sb_feat.rmapbt =
+						parse_conf_val(OPT_M, M_RMAPBT,
+							       value);
 					break;
 				case M_REFLINK:
 					sb_feat.reflink =
-						getnum(value, &opts[OPT_M],
-							M_REFLINK);
+						parse_conf_val(OPT_M,
+							       M_REFLINK,
+							       value);
 					break;
 				default:
 					unknown('m', value);
@@ -2113,14 +2146,16 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case N_LOG:
-					dirblocklog = getnum(value,
-						&opts[OPT_N], N_LOG);
+					dirblocklog = parse_conf_val(OPT_N,
+								     N_LOG,
+								     value);
 					dirblocksize = 1 << dirblocklog;
 					nlflag = 1;
 					break;
 				case N_SIZE:
-					dirblocksize = getnum(value,
-						&opts[OPT_N], N_SIZE);
+					dirblocksize = parse_conf_val(OPT_N,
+								      N_SIZE,
+								      value);
 					dirblocklog =
 						libxfs_highbit32(dirblocksize);
 					nsflag = 1;
@@ -2134,14 +2169,17 @@ main(
 					} else {
 						sb_feat.dir_version =
 							getnum(value,
-							       &opts[OPT_N],
-							       N_VERSION);
+								&opts[OPT_N],
+								N_VERSION);
 					}
 					nvflag = 1;
+					set_conf_val(OPT_N, N_VERSION,
+						     sb_feat.dir_version);
 					break;
 				case N_FTYPE:
-					sb_feat.dirftype = getnum(value,
-						&opts[OPT_N], N_FTYPE);
+					sb_feat.dirftype =
+						parse_conf_val(OPT_N, N_FTYPE,
+							       value);
 					break;
 				default:
 					unknown('n', value);
@@ -2171,25 +2209,30 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case R_EXTSIZE:
-					rtextbytes = getnum(value,
-						&opts[OPT_R], R_EXTSIZE);
+					rtextbytes = parse_conf_val(OPT_R,
+								    R_EXTSIZE,
+								    value);
 					break;
 				case R_FILE:
-					xi.risfile = getnum(value,
-						&opts[OPT_R], R_FILE);
+					xi.risfile = parse_conf_val(OPT_R,
+								    R_FILE,
+								    value);
 					break;
 				case R_NAME:
 				case R_DEV:
 					xi.rtname = getstr(value, &opts[OPT_R],
 							   R_NAME);
+					set_conf_val(OPT_R, R_NAME, 1);
+					set_conf_val(OPT_R, R_DEV, 1);
 					break;
 				case R_SIZE:
-					rtbytes = getnum(value, &opts[OPT_R],
-								R_SIZE);
+					rtbytes = parse_conf_val(OPT_R, R_SIZE,
+								 value);
 					break;
 				case R_NOALIGN:
-					norsflag = getnum(value, &opts[OPT_R],
-								R_NOALIGN);
+					norsflag = parse_conf_val(OPT_R,
+								  R_NOALIGN,
+								  value);
 					break;
 				default:
 					unknown('r', value);
@@ -2210,8 +2253,9 @@ main(
 						conflict('s', subopts,
 							 S_SECTSIZE,
 							 S_SECTLOG);
-					sectorlog = getnum(value, &opts[OPT_S],
-							   S_SECTLOG);
+					sectorlog = parse_conf_val(OPT_S,
+								   S_SECTLOG,
+								   value);
 					lsectorlog = sectorlog;
 					sectorsize = 1 << sectorlog;
 					lsectorsize = sectorsize;
@@ -2223,8 +2267,9 @@ main(
 						conflict('s', subopts,
 							 S_SECTLOG,
 							 S_SECTSIZE);
-					sectorsize = getnum(value,
-						&opts[OPT_S], S_SECTSIZE);
+					sectorsize = parse_conf_val(OPT_S,
+								    S_SECTSIZE,
+								    value);
 					lsectorsize = sectorsize;
 					sectorlog =
 						libxfs_highbit32(sectorsize);
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options
  2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
  2017-08-11 12:30 ` [PATCH 1/6] mkfs: save user input values into opts Jan Tulak
@ 2017-08-11 12:30 ` Jan Tulak
  2017-08-14 23:30   ` Darrick J. Wong
  2017-08-15 15:00   ` [PATCH 2/6 v2] " Jan Tulak
  2017-08-11 12:30 ` [PATCH 3/6] mkfs: replace variables with opts table: -i options Jan Tulak
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Remove variables that can be replaced with a direct access to the opts
table, so we have it all in a single place, acessible from anywhere.

In future, we can remove some instances where we are passing values as
arguments to helper functions, when we have the values in the opts
struct and could pass only the struct.  But for now, limit the changes
to simple replacement without any change in the logic.

This is first of multiple similar patches that do the same, but for
other options.

Signed-off-by: Jan Tulak <jtulak@redhat.com>

---
CHANGES:
* remove collaterals which are set during parsing
---
 mkfs/xfs_mkfs.c | 792 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 463 insertions(+), 329 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 12ffa715..7f7f4554 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -32,13 +32,6 @@ static void respec(char opt, char *tab[], int idx);
 static void unknown(char opt, char *s);
 static int  ispow2(unsigned int i);
 
-/*
- * The configured block and sector sizes are defined as global variables so
- * that they don't need to be passed to functions that require them.
- */
-unsigned int		blocksize;
-unsigned int		sectorsize;
-
 #define MAX_OPTS	16
 #define MAX_SUBOPTS	16
 #define SUBOPT_NEEDS_VAL	(-1LL)
@@ -740,7 +733,8 @@ struct opt_params {
 /*
  * Use this macro before we have superblock and mount structure
  */
-#define	DTOBT(d)	((xfs_rfsblock_t)((d) >> (blocklog - BBSHIFT)))
+#define	DTOBT(d) \
+	((xfs_rfsblock_t)((d) >> (get_conf_val(OPT_B, B_LOG) - BBSHIFT)))
 
 /*
  * Use this for block reservations needed for mkfs's conditions
@@ -1092,7 +1086,8 @@ getnum(
 	 * number.
 	 */
 	if (sp->convert)
-		c = cvtnum(blocksize, sectorsize, str);
+		c = cvtnum(get_conf_val(OPT_B, B_SIZE),
+			   get_conf_val(OPT_D, D_SECTSIZE), str);
 	else {
 		char		*str_end;
 
@@ -1179,16 +1174,16 @@ calc_stripe_factors(
 		*lsunit = (int)BTOBBT(lsu);
 
 	/* verify if lsu/lsunit is a multiple block size */
-	if (lsu % blocksize != 0) {
+	if (lsu % get_conf_val(OPT_B, B_SIZE) != 0) {
 		fprintf(stderr,
-_("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
-		lsu, blocksize);
+_("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
+		lsu, get_conf_val(OPT_B, B_SIZE));
 		exit(1);
 	}
-	if ((BBTOB(*lsunit) % blocksize != 0)) {
+	if ((BBTOB(*lsunit) % get_conf_val(OPT_B, B_SIZE) != 0)) {
 		fprintf(stderr,
-_("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
-		BBTOB(*lsunit), blocksize);
+_("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
+		BBTOB(*lsunit), get_conf_val(OPT_B, B_SIZE));
 		exit(1);
 	}
 }
@@ -1344,7 +1339,7 @@ validate_log_size(uint64_t logblocks, int blocklog, int min_logblocks)
 			(long long)logblocks, XFS_MAX_LOG_BLOCKS);
 		usage();
 	}
-	if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
+	if ((logblocks << get_conf_val(OPT_B, B_LOG)) > XFS_MAX_LOG_BYTES) {
 		fprintf(stderr,
 	_("log size %lld bytes too large, maximum size is %lld bytes\n"),
 			(long long)(logblocks << blocklog), XFS_MAX_LOG_BYTES);
@@ -1438,9 +1433,9 @@ validate_ag_geometry(
 	}
 
 	/*
-	 * If agcount is too large, make it smaller.
+	 * If D_AGCOUNT is too large, make it smaller.
 	 */
-	if (agcount > XFS_MAX_AGNUMBER + 1) {
+	if (get_conf_val(OPT_D, D_AGCOUNT) > XFS_MAX_AGNUMBER + 1) {
 		fprintf(stderr,
 	_("%lld allocation groups is too many, maximum is %lld\n"),
 			(long long)agcount, (long long)XFS_MAX_AGNUMBER + 1);
@@ -1674,15 +1669,12 @@ main(
 	int			argc,
 	char			**argv)
 {
-	uint64_t		agcount;
 	xfs_agf_t		*agf;
 	xfs_agi_t		*agi;
 	xfs_agnumber_t		agno;
-	uint64_t		agsize;
 	xfs_alloc_rec_t		*arec;
 	struct xfs_btree_block	*block;
 	int			blflag;
-	int			blocklog;
 	int			bsflag;
 	int			bsize;
 	xfs_buf_t		*buf;
@@ -1693,11 +1685,6 @@ main(
 	char			*dfile;
 	int			dirblocklog;
 	int			dirblocksize;
-	uint64_t		dbytes;
-	int			dsu;
-	int			dsw;
-	int			dsunit;
-	int			dswidth;
 	int			dsflag;
 	bool			force_overwrite;
 	struct fsxattr		fsx;
@@ -1735,7 +1722,6 @@ main(
 	xfs_mount_t		mbuf;
 	xfs_extlen_t		nbmblocks;
 	int			nlflag;
-	int			nodsflag;
 	int			norsflag;
 	xfs_alloc_rec_t		*nrec;
 	int			nsflag;
@@ -1753,7 +1739,6 @@ main(
 	uint64_t		rtextbytes;
 	char			*rtfile;
 	xfs_sb_t		*sbp;
-	int			sectorlog;
 	uint64_t		sector_mask;
 	int			slflag;
 	int			ssflag;
@@ -1786,12 +1771,11 @@ main(
 	textdomain(PACKAGE);
 
 	blflag = bsflag = slflag = ssflag = lslflag = lssflag = 0;
-	blocklog = blocksize = 0;
-	sectorlog = lsectorlog = 0;
-	sectorsize = lsectorsize = 0;
-	agsize = daflag = dasize = dblocks = 0;
-	ilflag = imflag = ipflag = isflag = 0;
-	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = 0;
+	lsectorlog = 0;
+	lsectorsize = 0;
+	dasize = dblocks = 0;
+	daflag = ilflag = imflag = ipflag = isflag = false;
+	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
 	loginternal = 1;
 	logagno = logblocks = rtblocks = rtextblocks = 0;
 	Nflag = nlflag = nsflag = nvflag = 0;
@@ -1800,10 +1784,10 @@ main(
 	imaxpct = inodelog = inopblock = isize = 0;
 	dfile = logfile = rtfile = NULL;
 	protofile = NULL;
-	rtbytes = rtextbytes = logbytes = dbytes = 0;
-	dsu = dsw = dsunit = dswidth = lalign = lsu = lsunit = 0;
-	dsflag = nodsflag = norsflag = 0;
-	force_overwrite = 0;
+	rtbytes = rtextbytes = logbytes = 0;
+	lalign = lsu = lsunit = 0;
+	dsflag = norsflag = false;
+	force_overwrite = false;
 	worst_freelist = 0;
 	memset(&fsx, 0, sizeof(fsx));
 
@@ -1826,16 +1810,13 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case B_LOG:
-					blocklog = parse_conf_val(OPT_B, B_LOG,
-								  value);
-					blocksize = 1 << blocklog;
+					parse_conf_val(OPT_B, B_LOG,
+							     value);
 					blflag = 1;
 					break;
 				case B_SIZE:
-					blocksize = parse_conf_val(OPT_B,
-								   B_SIZE,
-								   value);
-					blocklog = libxfs_highbit32(blocksize);
+					parse_conf_val(OPT_B, B_SIZE,
+							     value);
 					bsflag = 1;
 					break;
 				default:
@@ -1852,15 +1833,12 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case D_AGCOUNT:
-					agcount = parse_conf_val(OPT_D,
-								 D_AGCOUNT,
-								 value);
+					parse_conf_val(OPT_D, D_AGCOUNT,
+						       value);
 					daflag = 1;
 					break;
 				case D_AGSIZE:
-					agsize = parse_conf_val(OPT_D,
-								D_AGSIZE,
-								value);
+					parse_conf_val(OPT_D, D_AGSIZE, value);
 					dasize = 1;
 					break;
 				case D_FILE:
@@ -1874,48 +1852,36 @@ main(
 					set_conf_val(OPT_D, D_NAME,  1);
 					break;
 				case D_SIZE:
-					dbytes = parse_conf_val(OPT_D, D_SIZE,
-								value);
+					parse_conf_val(OPT_D, D_SIZE, value);
 					break;
 				case D_SUNIT:
-					dsunit = parse_conf_val(OPT_D, D_SUNIT,
-								value);
+					parse_conf_val(OPT_D, D_SUNIT, value);
 					dsflag = 1;
 					break;
 				case D_SWIDTH:
-					dswidth = parse_conf_val(OPT_D,
-								 D_SWIDTH,
-								 value);
+					parse_conf_val(OPT_D, D_SWIDTH, value);
 					dsflag = 1;
 					break;
 				case D_SU:
-					dsu = parse_conf_val(OPT_D, D_SU,
-							     value);
+					parse_conf_val(OPT_D, D_SU, value);
 					dsflag = 1;
 					break;
 				case D_SW:
-					dsw = parse_conf_val(OPT_D, D_SW,
-							     value);
+					parse_conf_val(OPT_D, D_SW, value);
 					dsflag = 1;
 					break;
 				case D_NOALIGN:
-					nodsflag = parse_conf_val(OPT_D,
-								  D_NOALIGN,
-								  value);
+					parse_conf_val(OPT_D, D_NOALIGN,
+						       value);
 					break;
 				case D_SECTLOG:
-					sectorlog = parse_conf_val(OPT_D,
-								   D_SECTLOG,
-								   value);
-					sectorsize = 1 << sectorlog;
+					parse_conf_val(OPT_D, D_SECTLOG,
+							     value);
 					slflag = 1;
 					break;
 				case D_SECTSIZE:
-					sectorsize = parse_conf_val(OPT_D,
-								    D_SECTSIZE,
-								    value);
-					sectorlog =
-						libxfs_highbit32(sectorsize);
+					parse_conf_val(OPT_D, D_SECTSIZE,
+							     value);
 					ssflag = 1;
 					break;
 				case D_RTINHERIT:
@@ -2245,6 +2211,7 @@ main(
 				char	**subopts =
 						(char **)opts[OPT_S].subopts;
 				char	*value;
+				uint64_t tmp;
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case S_LOG:
@@ -2253,12 +2220,12 @@ main(
 						conflict('s', subopts,
 							 S_SECTSIZE,
 							 S_SECTLOG);
-					sectorlog = parse_conf_val(OPT_S,
+					tmp = parse_conf_val(OPT_S,
 								   S_SECTLOG,
 								   value);
-					lsectorlog = sectorlog;
-					sectorsize = 1 << sectorlog;
-					lsectorsize = sectorsize;
+
+					lsectorlog = tmp;
+					lsectorsize = tmp;
 					lslflag = slflag = 1;
 					break;
 				case S_SIZE:
@@ -2267,13 +2234,12 @@ main(
 						conflict('s', subopts,
 							 S_SECTLOG,
 							 S_SECTSIZE);
-					sectorsize = parse_conf_val(OPT_S,
+					tmp = parse_conf_val(OPT_S,
 								    S_SECTSIZE,
 								    value);
-					lsectorsize = sectorsize;
-					sectorlog =
-						libxfs_highbit32(sectorsize);
-					lsectorlog = sectorlog;
+
+					lsectorlog = libxfs_highbit32(tmp);
+					lsectorsize = tmp;
 					lssflag = ssflag = 1;
 					break;
 				default:
@@ -2298,19 +2264,22 @@ main(
 		dfile = xi.dname;
 
 	/*
-	 * Blocksize and sectorsize first, other things depend on them
+	 * Blocksize and D_SECTSIZE 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) {
-		blocklog = XFS_DFL_BLOCKSIZE_LOG;
-		blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
+		set_conf_val(OPT_B, B_LOG, XFS_DFL_BLOCKSIZE_LOG);
+		set_conf_val(OPT_B, B_SIZE, 1 << XFS_DFL_BLOCKSIZE_LOG);
 	}
-	if (blocksize < XFS_MIN_BLOCKSIZE || blocksize > XFS_MAX_BLOCKSIZE) {
-		fprintf(stderr, _("illegal block size %d\n"), blocksize);
+	if (get_conf_val(OPT_B, B_SIZE) < XFS_MIN_BLOCKSIZE ||
+	    get_conf_val(OPT_B, B_SIZE) > XFS_MAX_BLOCKSIZE) {
+		fprintf(stderr, _("illegal block size %lld\n"),
+			get_conf_val(OPT_B, B_SIZE));
 		usage();
 	}
-	if (sb_feat.crcs_enabled && blocksize < XFS_MIN_CRC_BLOCKSIZE) {
+	if (sb_feat.crcs_enabled &&
+	    get_conf_val(OPT_B, B_SIZE) < XFS_MIN_CRC_BLOCKSIZE) {
 		fprintf(stderr,
 _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 			XFS_MIN_CRC_BLOCKSIZE);
@@ -2322,12 +2291,12 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 	}
 
 	if (!slflag && !ssflag) {
-		sectorlog = XFS_MIN_SECTORSIZE_LOG;
-		sectorsize = XFS_MIN_SECTORSIZE;
+		set_conf_val(OPT_D, D_SECTLOG, XFS_MIN_SECTORSIZE_LOG);
+		set_conf_val(OPT_D, D_SECTSIZE, XFS_MIN_SECTORSIZE);
 	}
 	if (!lslflag && !lssflag) {
-		lsectorlog = sectorlog;
-		lsectorsize = sectorsize;
+		lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
+		lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
 	}
 
 	/*
@@ -2337,7 +2306,8 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 	 * sector size mismatches between the new filesystem and the underlying
 	 * host filesystem.
 	 */
-	check_device_type(dfile, &xi.disfile, !dbytes, !dfile,
+	check_device_type(dfile, &xi.disfile, !get_conf_val(OPT_D, D_SIZE),
+			  !dfile,
 			  Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
 	if (!loginternal)
 		check_device_type(xi.logname, &xi.lisfile, !logbytes,
@@ -2366,50 +2336,58 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 		if (!ft.psectorsize)
 			ft.psectorsize = ft.lsectorsize;
 
-		sectorsize = ft.psectorsize ? ft.psectorsize :
-					      XFS_MIN_SECTORSIZE;
+		set_conf_val(OPT_D, D_SECTSIZE,
+			     ft.psectorsize ? ft.psectorsize :
+					      XFS_MIN_SECTORSIZE);
 
-		if ((blocksize < sectorsize) && (blocksize >= ft.lsectorsize)) {
+		if ((get_conf_val(OPT_B, B_SIZE) <
+		     get_conf_val(OPT_D, D_SECTSIZE)) &&
+		    (get_conf_val(OPT_B, B_SIZE) >= ft.lsectorsize)) {
 			fprintf(stderr,
-_("specified blocksize %d is less than device physical sector size %d\n"),
-				blocksize, ft.psectorsize);
+_("specified blocksize %lld is less than device physical sector size %d\n"),
+				get_conf_val(OPT_B, B_SIZE), ft.psectorsize);
 			fprintf(stderr,
 _("switching to logical sector size %d\n"),
 				ft.lsectorsize);
-			sectorsize = ft.lsectorsize ? ft.lsectorsize :
-						      XFS_MIN_SECTORSIZE;
+			set_conf_val(OPT_D, D_SECTSIZE,
+				     ft.lsectorsize ? ft.lsectorsize :
+						      XFS_MIN_SECTORSIZE);
 		}
 	}
 
 	if (!ssflag) {
-		sectorlog = libxfs_highbit32(sectorsize);
+		set_conf_val(OPT_D, D_SECTLOG,
+			     libxfs_highbit32(get_conf_val(OPT_D, D_SECTSIZE)));
 		if (loginternal) {
-			lsectorsize = sectorsize;
-			lsectorlog = sectorlog;
+			lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
+			lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
 		}
 	}
 
-	if (sectorsize < XFS_MIN_SECTORSIZE ||
-	    sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
+	if (get_conf_val(OPT_D, D_SECTSIZE) < XFS_MIN_SECTORSIZE ||
+	    get_conf_val(OPT_D, D_SECTSIZE) > XFS_MAX_SECTORSIZE ||
+	    get_conf_val(OPT_D, D_SECTSIZE) > get_conf_val(OPT_B, B_SIZE)) {
 		if (ssflag)
-			fprintf(stderr, _("illegal sector size %d\n"), sectorsize);
+			fprintf(stderr, _("illegal sector size %lld\n"),
+				get_conf_val(OPT_D, D_SECTSIZE));
 		else
 			fprintf(stderr,
-_("block size %d cannot be smaller than logical sector size %d\n"),
-				blocksize, ft.lsectorsize);
+_("block size %lld cannot be smaller than logical sector size %d\n"),
+				get_conf_val(OPT_B, B_SIZE), ft.lsectorsize);
 		usage();
 	}
-	if (sectorsize < ft.lsectorsize) {
-		fprintf(stderr, _("illegal sector size %d; hw sector is %d\n"),
-			sectorsize, ft.lsectorsize);
+	if (get_conf_val(OPT_D, D_SECTSIZE) < ft.lsectorsize) {
+		fprintf(stderr, _("illegal sector size %lld; hw sector is %d\n"),
+			get_conf_val(OPT_D, D_SECTSIZE), ft.lsectorsize);
 		usage();
 	}
 	if (lsectorsize < XFS_MIN_SECTORSIZE ||
-	    lsectorsize > XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {
+	    lsectorsize > XFS_MAX_SECTORSIZE ||
+	    lsectorsize > get_conf_val(OPT_B, B_SIZE)) {
 		fprintf(stderr, _("illegal log sector size %d\n"), lsectorsize);
 		usage();
 	} else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
-		lsu = blocksize;
+		lsu = get_conf_val(OPT_B, B_SIZE);
 		sb_feat.log_version = 2;
 	}
 
@@ -2511,37 +2489,41 @@ _("rmapbt not supported with realtime devices\n"));
 	}
 
 	if (nsflag || nlflag) {
-		if (dirblocksize < blocksize ||
+		if (dirblocksize < get_conf_val(OPT_B, B_SIZE) ||
 					dirblocksize > XFS_MAX_BLOCKSIZE) {
 			fprintf(stderr, _("illegal directory block size %d\n"),
 				dirblocksize);
 			usage();
 		}
 	} else {
-		if (blocksize < (1 << XFS_MIN_REC_DIRSIZE))
+		if (get_conf_val(OPT_B, B_SIZE) < (1 << XFS_MIN_REC_DIRSIZE))
 			dirblocklog = XFS_MIN_REC_DIRSIZE;
 		else
-			dirblocklog = blocklog;
+			dirblocklog = get_conf_val(OPT_B, B_LOG);
 		dirblocksize = 1 << dirblocklog;
 	}
 
 
-	if (dbytes) {
-		if (dbytes % XFS_MIN_BLOCKSIZE) {
+	if (get_conf_val(OPT_D, D_SIZE)) {
+		if (get_conf_val(OPT_D, D_SIZE) % XFS_MIN_BLOCKSIZE) {
 			fprintf(stderr,
 			_("illegal data length %lld, not a multiple of %d\n"),
-				(long long)dbytes, XFS_MIN_BLOCKSIZE);
+				get_conf_val(OPT_D, D_SIZE), XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		dblocks = (xfs_rfsblock_t)(dbytes >> blocklog);
-		if (dbytes % blocksize)
+		dblocks = (xfs_rfsblock_t)(get_conf_val(OPT_D, D_SIZE) >>
+					   get_conf_val(OPT_B, B_LOG));
+		if (get_conf_val(OPT_D, D_SIZE) % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr, _("warning: "
-	"data length %lld not a multiple of %d, truncated to %lld\n"),
-				(long long)dbytes, blocksize,
-				(long long)(dblocks << blocklog));
+	"data length %lld not a multiple of %lld, truncated to %lld\n"),
+				get_conf_val(OPT_D, D_SIZE),
+				get_conf_val(OPT_B, B_SIZE),
+				(long long)(dblocks <<
+					   get_conf_val(OPT_B, B_LOG)));
 	}
 	if (ipflag) {
-		inodelog = blocklog - libxfs_highbit32(inopblock);
+		inodelog = get_conf_val(OPT_B, B_LOG) -
+			libxfs_highbit32(inopblock);
 		isize = 1 << inodelog;
 	} else if (!ilflag && !isflag) {
 		inodelog = sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
@@ -2562,12 +2544,14 @@ _("rmapbt not supported with realtime devices\n"));
 				(long long)logbytes, XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		logblocks = (xfs_rfsblock_t)(logbytes >> blocklog);
-		if (logbytes % blocksize)
+		logblocks = (xfs_rfsblock_t)(logbytes >>
+					     get_conf_val(OPT_B, B_LOG));
+		if (logbytes % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr,
-	_("warning: log length %lld not a multiple of %d, truncated to %lld\n"),
-				(long long)logbytes, blocksize,
-				(long long)(logblocks << blocklog));
+	_("warning: log length %lld not a multiple of %lld, truncated to %lld\n"),
+				(long long)logbytes, get_conf_val(OPT_B, B_SIZE),
+				(long long)(logblocks <<
+					   get_conf_val(OPT_B, B_LOG)));
 	}
 	if (rtbytes) {
 		if (rtbytes % XFS_MIN_BLOCKSIZE) {
@@ -2576,24 +2560,27 @@ _("rmapbt not supported with realtime devices\n"));
 				(long long)rtbytes, XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		rtblocks = (xfs_rfsblock_t)(rtbytes >> blocklog);
-		if (rtbytes % blocksize)
+		rtblocks = (xfs_rfsblock_t)(rtbytes >>
+					    get_conf_val(OPT_B, B_LOG));
+		if (rtbytes % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr,
-	_("warning: rt length %lld not a multiple of %d, truncated to %lld\n"),
-				(long long)rtbytes, blocksize,
-				(long long)(rtblocks << blocklog));
+	_("warning: rt length %lld not a multiple of %lld, truncated to %lld\n"),
+				(long long)rtbytes, get_conf_val(OPT_B, B_SIZE),
+				(long long)(rtblocks <<
+					   get_conf_val(OPT_B, B_LOG)));
 	}
 	/*
 	 * If specified, check rt extent size against its constraints.
 	 */
 	if (rtextbytes) {
-		if (rtextbytes % blocksize) {
+		if (rtextbytes % get_conf_val(OPT_B, B_SIZE)) {
 			fprintf(stderr,
-		_("illegal rt extent size %lld, not a multiple of %d\n"),
-				(long long)rtextbytes, blocksize);
+		_("illegal rt extent size %lld, not a multiple of %lld\n"),
+				(long long)rtextbytes, get_conf_val(OPT_B, B_SIZE));
 			usage();
 		}
-		rtextblocks = (xfs_extlen_t)(rtextbytes >> blocklog);
+		rtextblocks = (xfs_extlen_t)(rtextbytes >>
+					     get_conf_val(OPT_B, B_LOG));
 	} else {
 		/*
 		 * If realtime extsize has not been specified by the user,
@@ -2608,18 +2595,21 @@ _("rmapbt not supported with realtime devices\n"));
 		else
 			rswidth = 0;
 
-		/* check that rswidth is a multiple of fs blocksize */
-		if (!norsflag && rswidth && !(BBTOB(rswidth) % blocksize)) {
+		/* check that rswidth is a multiple of fs B_SIZE */
+		if (!norsflag && rswidth &&
+		    !(BBTOB(rswidth) % get_conf_val(OPT_B, B_SIZE))) {
 			rswidth = DTOBT(rswidth);
-			rtextbytes = rswidth << blocklog;
+			rtextbytes = rswidth << get_conf_val(OPT_B, B_LOG);
 			if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
 			    (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
 				rtextblocks = rswidth;
 			}
 		}
 		if (!rtextblocks) {
-			rtextblocks = (blocksize < XFS_MIN_RTEXTSIZE) ?
-					XFS_MIN_RTEXTSIZE >> blocklog : 1;
+			rtextblocks = (get_conf_val(OPT_B, B_SIZE) <
+				       XFS_MIN_RTEXTSIZE) ?
+				       XFS_MIN_RTEXTSIZE >>
+				       get_conf_val(OPT_B, B_LOG) : 1;
 		}
 	}
 	ASSERT(rtextblocks);
@@ -2627,22 +2617,25 @@ _("rmapbt not supported with realtime devices\n"));
 	/*
 	 * Check some argument sizes against mins, maxes.
 	 */
-	if (isize > blocksize / XFS_MIN_INODE_PERBLOCK ||
+	if (isize > get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
 	    isize < XFS_DINODE_MIN_SIZE ||
 	    isize > XFS_DINODE_MAX_SIZE) {
 		int	maxsz;
 
 		fprintf(stderr, _("illegal inode size %d\n"), isize);
-		maxsz = MIN(blocksize / XFS_MIN_INODE_PERBLOCK,
+		maxsz = MIN(get_conf_val(OPT_B, B_SIZE) /
+			    XFS_MIN_INODE_PERBLOCK,
 			    XFS_DINODE_MAX_SIZE);
 		if (XFS_DINODE_MIN_SIZE == maxsz)
 			fprintf(stderr,
-			_("allowable inode size with %d byte blocks is %d\n"),
-				blocksize, XFS_DINODE_MIN_SIZE);
+			_("allowable inode size with %lld byte blocks is %d\n"),
+				get_conf_val(OPT_B, B_SIZE),
+				XFS_DINODE_MIN_SIZE);
 		else
 			fprintf(stderr,
-	_("allowable inode size with %d byte blocks is between %d and %d\n"),
-				blocksize, XFS_DINODE_MIN_SIZE, maxsz);
+	_("allowable inode size with %lld byte blocks is between %d and %d\n"),
+				get_conf_val(OPT_B, B_SIZE),
+				XFS_DINODE_MIN_SIZE, maxsz);
 		exit(1);
 	}
 
@@ -2653,14 +2646,24 @@ _("rmapbt not supported with realtime devices\n"));
 		sb_feat.log_version = 2;
 	}
 
-	calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize,
+	int dsunit = get_conf_val(OPT_D, D_SUNIT);
+	int dswidth = get_conf_val(OPT_D, D_SWIDTH);
+
+	calc_stripe_factors(get_conf_val(OPT_D, D_SU),
+			    get_conf_val(OPT_D, D_SW),
+			    get_conf_val(OPT_D, D_SECTSIZE),
+			    lsu,
+			    lsectorsize,
 				&dsunit, &dswidth, &lsunit);
 
 	/* If sunit & swidth were manually specified as 0, same as noalign */
 	if (dsflag && !dsunit && !dswidth)
-		nodsflag = 1;
+		set_conf_val(OPT_D, D_NOALIGN, 1);
+
+	set_conf_val(OPT_D, D_SUNIT, dsunit);
+	set_conf_val(OPT_D, D_SWIDTH, dswidth);
 
-	xi.setblksize = sectorsize;
+	xi.setblksize = get_conf_val(OPT_D, D_SECTSIZE);
 
 	/*
 	 * Initialize.  This will open the log and rt devices as well.
@@ -2683,7 +2686,8 @@ _("rmapbt not supported with realtime devices\n"));
 	 * multiple of the sector size, or 1024, whichever is larger.
 	 */
 
-	sector_mask = (uint64_t)-1 << (MAX(sectorlog, 10) - BBSHIFT);
+	sector_mask = (uint64_t)-1 <<
+		(MAX(get_conf_val(OPT_D, D_SECTLOG), 10) - BBSHIFT);
 	xi.dsize &= sector_mask;
 	xi.rtsize &= sector_mask;
 	xi.logBBsize &= (uint64_t)-1 << (MAX(lsectorlog, 10) - BBSHIFT);
@@ -2718,16 +2722,17 @@ _("rmapbt not supported with realtime devices\n"));
 		rtfile = _("volume rt");
 	else if (!xi.rtdev)
 		rtfile = _("none");
-	if (dbytes && xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
+	if (get_conf_val(OPT_D, D_SIZE) &&
+	    xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
 		fprintf(stderr,
 			_("size %s specified for data subvolume is too large, "
 			"maximum is %lld blocks\n"),
 			get_conf_raw_safe(OPT_D, D_SIZE),
 			(long long)DTOBT(xi.dsize));
 		usage();
-	} else if (!dbytes && xi.dsize > 0)
+	} else if (!get_conf_val(OPT_D, D_SIZE) && xi.dsize > 0)
 		dblocks = DTOBT(xi.dsize);
-	else if (!dbytes) {
+	else if (!get_conf_val(OPT_D, D_SIZE)) {
 		fprintf(stderr, _("can't get size of data subvolume\n"));
 		usage();
 	}
@@ -2742,17 +2747,18 @@ _("rmapbt not supported with realtime devices\n"));
 		fprintf(stderr,
 			_("can't have both external and internal logs\n"));
 		usage();
-	} else if (loginternal && sectorsize != lsectorsize) {
+	} else if (loginternal &&
+		   get_conf_val(OPT_D, D_SECTSIZE) != lsectorsize) {
 		fprintf(stderr,
 	_("data and log sector sizes must be equal for internal logs\n"));
 		usage();
 	}
 
-	if (xi.dbsize > sectorsize) {
+	if (xi.dbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
 		fprintf(stderr, _(
-"Warning: the data subvolume sector size %u is less than the sector size \n\
+"Warning: the data subvolume sector size %lld is less than the sector size \n\
 reported by the device (%u).\n"),
-			sectorsize, xi.dbsize);
+			get_conf_val(OPT_D, D_SECTSIZE), xi.dbsize);
 	}
 	if (!loginternal && xi.lbsize > lsectorsize) {
 		fprintf(stderr, _(
@@ -2760,11 +2766,12 @@ reported by the device (%u).\n"),
 reported by the device (%u).\n"),
 			lsectorsize, xi.lbsize);
 	}
-	if (rtbytes && xi.rtsize > 0 && xi.rtbsize > sectorsize) {
+	if (rtbytes && xi.rtsize > 0 &&
+	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
 		fprintf(stderr, _(
-"Warning: the realtime subvolume sector size %u is less than the sector size\n\
+"Warning: the realtime subvolume sector size %lld is less than the sector size\n\
 reported by the device (%u).\n"),
-			sectorsize, xi.rtbsize);
+			get_conf_val(OPT_D, D_SECTSIZE), xi.rtbsize);
 	}
 
 	if (rtbytes && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
@@ -2783,119 +2790,175 @@ reported by the device (%u).\n"),
 	}
 	if (xi.rtdev) {
 		rtextents = rtblocks / rtextblocks;
-		nbmblocks = (xfs_extlen_t)howmany(rtextents, NBBY * blocksize);
+		nbmblocks = (xfs_extlen_t)howmany(rtextents, NBBY *
+						  get_conf_val(OPT_B, B_SIZE));
 	} else {
 		rtextents = rtblocks = 0;
 		nbmblocks = 0;
 	}
 
-	if (!nodsflag) {
-		if (dsunit) {
-			if (ft.dsunit && ft.dsunit != dsunit) {
+	if (!get_conf_val(OPT_D, D_NOALIGN)) {
+		if (get_conf_val(OPT_D, D_SUNIT)) {
+			if (ft.dsunit &&
+			    ft.dsunit != get_conf_val(OPT_D, D_SUNIT)) {
 				fprintf(stderr,
-					_("%s: Specified data stripe unit %d "
+					_("%s: Specified data stripe unit %lld "
 					"is not the same as the volume stripe "
 					"unit %d\n"),
-					progname, dsunit, ft.dsunit);
+					progname,
+					get_conf_val(OPT_D, D_SUNIT),
+					ft.dsunit);
 			}
-			if (ft.dswidth && ft.dswidth != dswidth) {
+			if (ft.dswidth &&
+			    ft.dswidth != get_conf_val(OPT_D, D_SWIDTH)) {
 				fprintf(stderr,
-					_("%s: Specified data stripe width %d "
+					_("%s: Specified data stripe width %lld "
 					"is not the same as the volume stripe "
 					"width %d\n"),
-					progname, dswidth, ft.dswidth);
+					progname,
+					get_conf_val(OPT_D, D_SWIDTH),
+					ft.dswidth);
 			}
 		} else {
-			dsunit = ft.dsunit;
-			dswidth = ft.dswidth;
-			nodsflag = 1;
+			set_conf_val(OPT_D, D_SUNIT, ft.dsunit);
+			set_conf_val(OPT_D, D_SWIDTH, ft.dswidth);
+			set_conf_val(OPT_D, D_NOALIGN, 1);
 		}
-	} /* else dsunit & dswidth can't be set if nodsflag is set */
+	} /* else D_SUNIT & D_SWIDTH can't be set if D_NOALIGN is set */
 
 	if (dasize) {		/* User-specified AG size */
 		/*
-		 * Check specified agsize is a multiple of blocksize.
+		 * Check specified D_AGSIZE is a multiple of B_SIZE.
 		 */
-		if (agsize % blocksize) {
+		if (get_conf_val(OPT_D, D_AGSIZE) %
+		    get_conf_val(OPT_B, B_SIZE)) {
 			fprintf(stderr,
-		_("agsize (%lld) not a multiple of fs blk size (%d)\n"),
-				(long long)agsize, blocksize);
+		_("agsize (%lld) not a multiple of fs blk size (%lld)\n"),
+				get_conf_val(OPT_D, D_AGSIZE),
+				get_conf_val(OPT_B, B_SIZE));
 			usage();
 		}
-		agsize /= blocksize;
-		agcount = dblocks / agsize + (dblocks % agsize != 0);
+		set_conf_val(OPT_D, D_AGSIZE,
+			     get_conf_val(OPT_D, D_AGSIZE) /
+			     get_conf_val(OPT_B, B_SIZE));
+		set_conf_val(OPT_D, D_AGCOUNT,
+			     dblocks / get_conf_val(OPT_D, D_AGSIZE) +
+			     (dblocks % get_conf_val(OPT_D, D_AGSIZE) != 0));
 
 	} else if (daflag) {	/* User-specified AG count */
-		agsize = dblocks / agcount + (dblocks % agcount != 0);
+		set_conf_val(OPT_D, D_AGSIZE,
+			     dblocks / get_conf_val(OPT_D, D_AGCOUNT) +
+			     (dblocks % get_conf_val(OPT_D, D_AGCOUNT) != 0));
 	} else {
-		calc_default_ag_geometry(blocklog, dblocks,
-				dsunit | dswidth, &agsize, &agcount);
+		/* TODO change the calc_... function so it accepts opts
+		 * directly, without the need to pass all the values. */
+		uint64_t agcount = get_conf_val(OPT_D, D_AGCOUNT);
+		uint64_t agsize = get_conf_val(OPT_D, D_AGSIZE);
+
+		calc_default_ag_geometry(get_conf_val(OPT_B, B_LOG),
+					 dblocks, get_conf_val(OPT_D, D_SUNIT)
+					 | get_conf_val(OPT_D, D_SWIDTH),
+					 &agsize, &agcount);
+		set_conf_val(OPT_D, D_AGCOUNT, agcount);
+		set_conf_val(OPT_D, D_AGSIZE, agsize);
 	}
 
 	/*
-	 * If dsunit is a multiple of fs blocksize, then check that is a
-	 * multiple of the agsize too
+	 * If D_SUNIT is a multiple of fs B_SIZE,
+	 * then check that is a multiple of the D_AGSIZE too
 	 */
-	if (dsunit && !(BBTOB(dsunit) % blocksize) &&
-	    dswidth && !(BBTOB(dswidth) % blocksize)) {
-
-		/* convert from 512 byte blocks to fs blocksize */
-		dsunit = DTOBT(dsunit);
-		dswidth = DTOBT(dswidth);
+	if (get_conf_val(OPT_D, D_SUNIT) &&
+	    !(BBTOB(get_conf_val(OPT_D, D_SUNIT)) %
+	      get_conf_val(OPT_B, B_SIZE)) &&
+	    get_conf_val(OPT_D, D_SWIDTH) &&
+	    !(BBTOB(get_conf_val(OPT_D, D_SWIDTH)) %
+	      get_conf_val(OPT_B, B_SIZE))) {
+
+		/* convert from 512 byte blocks to fs B_SIZE
+		 */
+		set_conf_val(OPT_D, D_SUNIT,
+			     DTOBT(get_conf_val(OPT_D, D_SUNIT)));
+		set_conf_val(OPT_D, D_SWIDTH,
+			     DTOBT(get_conf_val(OPT_D, D_SWIDTH)));
 
 		/*
-		 * agsize is not a multiple of dsunit
+		 * D_AGSIZE is not a multiple of D_SUNIT
 		 */
-		if ((agsize % dsunit) != 0) {
+		if ((get_conf_val(OPT_D, D_AGSIZE) %
+		     get_conf_val(OPT_D, D_SUNIT)) != 0) {
 			/*
 			 * Round up to stripe unit boundary. Also make sure
-			 * that agsize is still larger than
-			 * XFS_AG_MIN_BLOCKS(blocklog)
+			 * that D_AGSIZE is still larger than
+			 * XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))
 		 	 */
-			tmp_agsize = ((agsize + (dsunit - 1))/ dsunit) * dsunit;
+			tmp_agsize = ((get_conf_val(OPT_D, D_AGSIZE) +
+				       (get_conf_val(OPT_D, D_SUNIT) - 1)) /
+				      get_conf_val(OPT_D, D_SUNIT)) *
+				get_conf_val(OPT_D, D_SUNIT);
 			/*
 			 * Round down to stripe unit boundary if rounding up
 			 * created an AG size that is larger than the AG max.
 			 */
-			if (tmp_agsize > XFS_AG_MAX_BLOCKS(blocklog))
-				tmp_agsize = ((agsize) / dsunit) * dsunit;
-
-			if ((tmp_agsize >= XFS_AG_MIN_BLOCKS(blocklog)) &&
-			    (tmp_agsize <= XFS_AG_MAX_BLOCKS(blocklog))) {
-				agsize = tmp_agsize;
+			if (tmp_agsize >
+			    XFS_AG_MAX_BLOCKS(get_conf_val(OPT_B, B_LOG)))
+				tmp_agsize = ((get_conf_val(OPT_D, D_AGSIZE)) /
+					      get_conf_val(OPT_D, D_SUNIT)) *
+					get_conf_val(OPT_D, D_SUNIT);
+
+			if ((tmp_agsize >=
+			     XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))) &&
+			    (tmp_agsize <=
+			     XFS_AG_MAX_BLOCKS(get_conf_val(OPT_B, B_LOG)))) {
+				set_conf_val(OPT_D, D_AGSIZE, tmp_agsize);
 				if (!daflag)
-					agcount = dblocks/agsize +
-						(dblocks % agsize != 0);
+					set_conf_val(OPT_D, D_AGCOUNT,
+						dblocks /
+						get_conf_val(OPT_D, D_AGSIZE) +
+						(dblocks %
+						 get_conf_val(OPT_D, D_AGSIZE)
+						!= 0));
 				if (dasize)
 					fprintf(stderr,
-				_("agsize rounded to %lld, swidth = %d\n"),
-						(long long)agsize, dswidth);
+				_("agsize rounded to %lld, swidth = %lld\n"),
+						get_conf_val(OPT_D, D_AGSIZE),
+						get_conf_val(OPT_D, D_SWIDTH));
 			} else {
-				if (nodsflag) {
-					dsunit = dswidth = 0;
+				if (get_conf_val(OPT_D, D_NOALIGN)) {
+					set_conf_val(OPT_D, D_SUNIT, 0);
+					set_conf_val(OPT_D, D_SWIDTH, 0);
 				} else {
 					/*
-					 * agsize is out of bounds, this will
+					 * D_AGSIZE is out of bounds, this will
 					 * print nice details & exit.
 					 */
-					validate_ag_geometry(blocklog, dblocks,
-							    agsize, agcount);
+					validate_ag_geometry(
+						get_conf_val(OPT_B, B_LOG),
+						dblocks,
+						get_conf_val(OPT_D, D_AGSIZE),
+						get_conf_val(OPT_D, D_AGCOUNT));
 					exit(1);
 				}
 			}
 		}
-		if (dswidth && ((agsize % dswidth) == 0) && (agcount > 1)) {
+		if (get_conf_val(OPT_D, D_SWIDTH) &&
+		    ((get_conf_val(OPT_D, D_AGSIZE) %
+		      get_conf_val(OPT_D, D_SWIDTH)) == 0) &&
+		    (get_conf_val(OPT_D, D_AGCOUNT) > 1)) {
 			/* This is a non-optimal configuration because all AGs
 			 * start on the same disk in the stripe.  Changing
 			 * the AG size by one sunit will guarantee that this
 			 * does not happen.
 			 */
-			tmp_agsize = agsize - dsunit;
-			if (tmp_agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
-				tmp_agsize = agsize + dsunit;
-				if (dblocks < agsize) {
+			tmp_agsize = get_conf_val(OPT_D, D_AGSIZE) -
+				get_conf_val(OPT_D, D_SUNIT);
+			if (tmp_agsize <
+			    XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))) {
+				tmp_agsize = get_conf_val(OPT_D, D_AGSIZE) +
+					get_conf_val(OPT_D, D_SUNIT);
+				if (dblocks < get_conf_val(OPT_D, D_AGSIZE)) {
 					/* oh well, nothing to do */
-					tmp_agsize = agsize;
+					tmp_agsize =
+						get_conf_val(OPT_D, D_AGSIZE);
 				}
 			}
 			if (daflag || dasize) {
@@ -2905,30 +2968,46 @@ problems by aligning all AGs on the same disk.  To avoid this, run mkfs with\n\
 an AG size that is one stripe unit smaller, for example %llu.\n"),
 					(unsigned long long)tmp_agsize);
 			} else {
-				agsize = tmp_agsize;
-				agcount = dblocks/agsize + (dblocks % agsize != 0);
+				set_conf_val(OPT_D, D_AGSIZE, tmp_agsize);
+				set_conf_val(OPT_D, D_AGCOUNT,
+					dblocks/get_conf_val(OPT_D, D_AGSIZE) +
+					     (dblocks %
+					      get_conf_val(OPT_D, D_AGSIZE)
+					      != 0));
 				/*
 				 * If the last AG is too small, reduce the
 				 * filesystem size and drop the blocks.
 				 */
-				if ( dblocks % agsize != 0 &&
-				    (dblocks % agsize <
-				    XFS_AG_MIN_BLOCKS(blocklog))) {
-					dblocks = (xfs_rfsblock_t)((agcount - 1) * agsize);
-					agcount--;
-					ASSERT(agcount != 0);
+				if (dblocks % get_conf_val(OPT_D, D_AGSIZE)
+				    != 0 &&
+				    (dblocks % get_conf_val(OPT_D, D_AGSIZE) <
+				    XFS_AG_MIN_BLOCKS(
+					get_conf_val(OPT_B, B_LOG)))) {
+
+					dblocks = (xfs_rfsblock_t)(
+						(get_conf_val(OPT_D, D_AGCOUNT)
+						 - 1) *
+						get_conf_val(OPT_D, D_AGSIZE));
+					set_conf_val(OPT_D, D_AGCOUNT,
+						get_conf_val(OPT_D, D_AGCOUNT)
+						- 1);
+					ASSERT(get_conf_val(OPT_D, D_AGCOUNT)
+					       != 0);
 				}
 			}
 		}
 	} else {
-		if (nodsflag)
-			dsunit = dswidth = 0;
-		else {
+		if (get_conf_val(OPT_D, D_NOALIGN)) {
+			set_conf_val(OPT_D, D_SWIDTH, 0);
+			set_conf_val(OPT_D, D_SUNIT, 0);
+		} else {
 			fprintf(stderr,
-				_("%s: Stripe unit(%d) or stripe width(%d) is "
-				"not a multiple of the block size(%d)\n"),
-				progname, BBTOB(dsunit), BBTOB(dswidth),
-				blocksize);
+				_("%s: Stripe unit(%lld) or stripe width(%lld) is "
+				"not a multiple of the block size(%lld)\n"),
+				progname,
+				BBTOB(get_conf_val(OPT_D, D_SUNIT)),
+				BBTOB(get_conf_val(OPT_D, D_SWIDTH)),
+				get_conf_val(OPT_B, B_SIZE));
 			exit(1);
 		}
 	}
@@ -2937,53 +3016,69 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 	 * If the last AG is too small, reduce the filesystem size
 	 * and drop the blocks.
 	 */
-	if ( dblocks % agsize != 0 &&
-	     (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) {
+	if (dblocks % get_conf_val(OPT_D, D_AGSIZE) != 0 &&
+	     (dblocks % get_conf_val(OPT_D, D_AGSIZE) <
+	      XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG)))) {
 		ASSERT(!daflag);
-		dblocks = (xfs_rfsblock_t)((agcount - 1) * agsize);
-		agcount--;
-		ASSERT(agcount != 0);
+		dblocks = (xfs_rfsblock_t)(
+				(get_conf_val(OPT_D, D_AGCOUNT) - 1) *
+				get_conf_val(OPT_D, D_AGSIZE));
+		set_conf_val(OPT_D, D_AGCOUNT,
+			     get_conf_val(OPT_D, D_AGCOUNT) - 1);
+		ASSERT(get_conf_val(OPT_D, D_AGCOUNT) != 0);
 	}
 
-	validate_ag_geometry(blocklog, dblocks, agsize, agcount);
+	validate_ag_geometry(get_conf_val(OPT_B, B_LOG),
+			     dblocks,
+			     get_conf_val(OPT_D, D_AGSIZE),
+			     get_conf_val(OPT_D, D_AGCOUNT));
 
 	if (!imflag)
-		imaxpct = calc_default_imaxpct(blocklog, dblocks);
+		imaxpct = calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
+					       dblocks);
 
 	/*
-	 * check that log sunit is modulo fsblksize or default it to dsunit.
+	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
 	 */
 
 	if (lsunit) {
 		/* convert from 512 byte blocks to fs blocks */
 		lsunit = DTOBT(lsunit);
-	} else if (sb_feat.log_version == 2 && loginternal && dsunit) {
-		/* lsunit and dsunit now in fs blocks */
-		lsunit = dsunit;
+	} else if (sb_feat.log_version == 2 &&
+		   loginternal &&
+		   get_conf_val(OPT_D, D_SUNIT)) {
+		/* lsunit and get_conf_val(OPT_D, D_SUNIT) now in fs blocks */
+		lsunit = get_conf_val(OPT_D, D_SUNIT);
 	}
 
-	if (sb_feat.log_version == 2 && (lsunit * blocksize) > 256 * 1024) {
+	if (sb_feat.log_version == 2 &&
+	    (lsunit * get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
 		/* Warn only if specified on commandline */
 		if (lsuflag || lsunitflag) {
 			fprintf(stderr,
-	_("log stripe unit (%d bytes) is too large (maximum is 256KiB)\n"),
-				(lsunit * blocksize));
+	_("log stripe unit (%lld bytes) is too large (maximum is 256KiB)\n"),
+				(lsunit * get_conf_val(OPT_B, B_SIZE)));
 			fprintf(stderr,
 	_("log stripe unit adjusted to 32KiB\n"));
 		}
-		lsunit = (32 * 1024) >> blocklog;
+		lsunit = (32 * 1024) >> get_conf_val(OPT_B, B_LOG);
 	}
 
-	min_logblocks = max_trans_res(agsize,
+	min_logblocks = max_trans_res(get_conf_val(OPT_D, D_AGSIZE),
 				   sb_feat.crcs_enabled, sb_feat.dir_version,
-				   sectorlog, blocklog, inodelog, dirblocklog,
+				   get_conf_val(OPT_D, D_SECTLOG),
+				   get_conf_val(OPT_B, B_LOG),
+				   inodelog, dirblocklog,
 				   sb_feat.log_version, lsunit, sb_feat.finobt,
 				   sb_feat.rmapbt, sb_feat.reflink,
 				   sb_feat.inode_align);
 	ASSERT(min_logblocks);
 	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
-	if (!logbytes && dblocks >= (1024*1024*1024) >> blocklog)
-		min_logblocks = MAX(min_logblocks, XFS_MIN_LOG_BYTES>>blocklog);
+	if (!logbytes &&
+	    dblocks >= (1024*1024*1024) >> get_conf_val(OPT_B, B_LOG))
+		min_logblocks = MAX(min_logblocks,
+				    XFS_MIN_LOG_BYTES >>
+				    get_conf_val(OPT_B, B_LOG));
 	if (logbytes && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
 		fprintf(stderr,
 _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
@@ -3004,17 +3099,19 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		logblocks = 0;
 	} else if (loginternal && !logbytes) {
 
-		if (dblocks < GIGABYTES(1, blocklog)) {
+		if (dblocks < GIGABYTES(1, get_conf_val(OPT_B, B_LOG))) {
 			/* tiny filesystems get minimum sized logs. */
 			logblocks = min_logblocks;
-		} else if (dblocks < GIGABYTES(16, blocklog)) {
+		} else if (dblocks <
+			   GIGABYTES(16, get_conf_val(OPT_B, B_LOG))) {
 
 			/*
 			 * For small filesystems, we want to use the
 			 * XFS_MIN_LOG_BYTES for filesystems smaller than 16G if
 			 * at all possible, ramping up to 128MB at 256GB.
 			 */
-			logblocks = MIN(XFS_MIN_LOG_BYTES >> blocklog,
+			logblocks = MIN(XFS_MIN_LOG_BYTES >>
+					get_conf_val(OPT_B, B_LOG),
 					min_logblocks * XFS_DFL_LOG_FACTOR);
 		} else {
 			/*
@@ -3023,34 +3120,38 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			 * max log size of 128M at 256GB fs size. IOWs,
 			 * the ratio of fs size to log size is 2048:1.
 			 */
-			logblocks = (dblocks << blocklog) / 2048;
-			logblocks = logblocks >> blocklog;
+			logblocks = (dblocks <<
+				     get_conf_val(OPT_B, B_LOG)) / 2048;
+			logblocks = logblocks >> get_conf_val(OPT_B, B_LOG);
 		}
 
 		/* Ensure the chosen size meets minimum log size requirements */
 		logblocks = MAX(min_logblocks, logblocks);
 
 		/* make sure the log fits wholly within an AG */
-		if (logblocks >= agsize)
+		if (logblocks >= get_conf_val(OPT_D, D_AGSIZE))
 			logblocks = min_logblocks;
 
 		/* and now clamp the size to the maximum supported size */
 		logblocks = MIN(logblocks, XFS_MAX_LOG_BLOCKS);
-		if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES)
-			logblocks = XFS_MAX_LOG_BYTES >> blocklog;
+		if ((logblocks << get_conf_val(OPT_B, B_LOG)) >
+		    XFS_MAX_LOG_BYTES)
+			logblocks = XFS_MAX_LOG_BYTES >>
+				get_conf_val(OPT_B, B_LOG);
 
 	}
-	validate_log_size(logblocks, blocklog, min_logblocks);
+	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
 
 	protostring = setup_proto(protofile);
-	bsize = 1 << (blocklog - BBSHIFT);
+	bsize = 1 << (get_conf_val(OPT_B, B_LOG) - BBSHIFT);
 	mp = &mbuf;
 	sbp = &mp->m_sb;
 	memset(mp, 0, sizeof(xfs_mount_t));
-	sbp->sb_blocklog = (uint8_t)blocklog;
-	sbp->sb_sectlog = (uint8_t)sectorlog;
-	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup((unsigned int)agsize);
-	sbp->sb_agblocks = (xfs_agblock_t)agsize;
+	sbp->sb_blocklog = (uint8_t)get_conf_val(OPT_B, B_LOG);
+	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
+	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup(
+				(unsigned int)get_conf_val(OPT_D, D_AGSIZE));
+	sbp->sb_agblocks = (xfs_agblock_t)get_conf_val(OPT_D, D_AGSIZE);
 	mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
 	mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
 
@@ -3058,7 +3159,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 * sb_versionnum, finobt and rmapbt flags must be set before we use
 	 * libxfs_prealloc_blocks().
 	 */
-	sb_set_features(&mp->m_sb, &sb_feat, sectorsize, lsectorsize, dsunit);
+	sb_set_features(&mp->m_sb, &sb_feat,
+			get_conf_val(OPT_D, D_SECTSIZE),
+			lsectorsize,
+			get_conf_val(OPT_D, D_SUNIT));
 
 
 	if (loginternal) {
@@ -3071,9 +3175,12 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 					libxfs_alloc_ag_max_usable(mp));
 
 			/* revalidate the log size is valid if we changed it */
-			validate_log_size(logblocks, blocklog, min_logblocks);
+			validate_log_size(logblocks,
+					  get_conf_val(OPT_B, B_LOG),
+					  min_logblocks);
 		}
-		if (logblocks > agsize - libxfs_prealloc_blocks(mp)) {
+		if (logblocks > get_conf_val(OPT_D, D_AGSIZE) -
+		    libxfs_prealloc_blocks(mp)) {
 			fprintf(stderr,
 	_("internal log size %lld too large, must fit in allocation group\n"),
 				(long long)logblocks);
@@ -3081,14 +3188,16 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		}
 
 		if (laflag) {
-			if (logagno >= agcount) {
+			if (logagno >= get_conf_val(OPT_D, D_AGCOUNT)) {
 				fprintf(stderr,
 		_("log ag number %d too large, must be less than %lld\n"),
-					logagno, (long long)agcount);
+					logagno,
+					get_conf_val(OPT_D, D_AGCOUNT));
 				usage();
 			}
 		} else
-			logagno = (xfs_agnumber_t)(agcount / 2);
+			logagno = (xfs_agnumber_t)(
+					get_conf_val(OPT_D, D_AGCOUNT) / 2);
 
 		logstart = XFS_AGB_TO_FSB(mp, logagno, libxfs_prealloc_blocks(mp));
 		/*
@@ -3096,45 +3205,53 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		 */
 		if (lsunit) {
 			logstart = fixup_internal_log_stripe(mp,
-					lsflag, logstart, agsize, lsunit,
-					&logblocks, blocklog, &lalign);
-		} else if (dsunit) {
+					lsflag, logstart,
+					get_conf_val(OPT_D, D_AGSIZE), lsunit,
+					&logblocks,
+					get_conf_val(OPT_B, B_LOG), &lalign);
+		} else if (get_conf_val(OPT_D, D_SUNIT)) {
 			logstart = fixup_internal_log_stripe(mp,
-					lsflag, logstart, agsize, dsunit,
-					&logblocks, blocklog, &lalign);
+					lsflag, logstart,
+					get_conf_val(OPT_D, D_AGSIZE),
+					get_conf_val(OPT_D, D_SUNIT),
+					&logblocks,
+					get_conf_val(OPT_B, B_LOG), &lalign);
 		}
 	} else {
 		logstart = 0;
 		if (lsunit)
 			fixup_log_stripe_unit(lsflag, lsunit,
-					&logblocks, blocklog);
+					&logblocks, get_conf_val(OPT_B, B_LOG));
 	}
-	validate_log_size(logblocks, blocklog, min_logblocks);
+	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
 
 	if (!qflag || Nflag) {
 		printf(_(
 		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
-		   "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
+		   "         =%-22s sectsz=%-5lld attr=%u, projid32bit=%u\n"
 		   "         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u, reflink=%u\n"
-		   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
-		   "         =%-22s sunit=%-6u swidth=%u blks\n"
+		   "data     =%-22s bsize=%-6lld blocks=%llu, imaxpct=%u\n"
+		   "         =%-22s sunit=%-6lld swidth=%lld blks\n"
 		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
 		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
 		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
 		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
-			dfile, isize, (long long)agcount, (long long)agsize,
-			"", sectorsize, sb_feat.attr_version,
+			dfile, isize, get_conf_val(OPT_D, D_AGCOUNT),
+			get_conf_val(OPT_D, D_AGSIZE),
+			"", get_conf_val(OPT_D, D_SECTSIZE),
+			sb_feat.attr_version,
 				    !sb_feat.projid16bit,
 			"", sb_feat.crcs_enabled, sb_feat.finobt, sb_feat.spinodes,
 			sb_feat.rmapbt, sb_feat.reflink,
-			"", blocksize, (long long)dblocks, imaxpct,
-			"", dsunit, dswidth,
+			"", get_conf_val(OPT_B, B_SIZE), (long long)dblocks, imaxpct,
+			"", get_conf_val(OPT_D, D_SUNIT),
+			get_conf_val(OPT_D, D_SWIDTH),
 			sb_feat.dir_version, dirblocksize, sb_feat.nci,
 				sb_feat.dirftype,
-			logfile, 1 << blocklog, (long long)logblocks,
+			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
 			sb_feat.log_version, "", lsectorsize, lsunit,
 				sb_feat.lazy_sb_counters,
-			rtfile, rtextblocks << blocklog,
+			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
 			(long long)rtblocks, (long long)rtextents);
 		if (Nflag)
 			exit(0);
@@ -3143,7 +3260,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	if (label)
 		strncpy(sbp->sb_fname, label, sizeof(sbp->sb_fname));
 	sbp->sb_magicnum = XFS_SB_MAGIC;
-	sbp->sb_blocksize = blocksize;
+	sbp->sb_blocksize = get_conf_val(OPT_B, B_SIZE);
 	sbp->sb_dblocks = dblocks;
 	sbp->sb_rblocks = rtblocks;
 	sbp->sb_rextents = rtextents;
@@ -3153,15 +3270,15 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_logstart = logstart;
 	sbp->sb_rootino = sbp->sb_rbmino = sbp->sb_rsumino = NULLFSINO;
 	sbp->sb_rextsize = rtextblocks;
-	sbp->sb_agcount = (xfs_agnumber_t)agcount;
+	sbp->sb_agcount = (xfs_agnumber_t)get_conf_val(OPT_D, D_AGCOUNT);
 	sbp->sb_rbmblocks = nbmblocks;
 	sbp->sb_logblocks = (xfs_extlen_t)logblocks;
-	sbp->sb_sectsize = (uint16_t)sectorsize;
+	sbp->sb_sectsize = (uint16_t)get_conf_val(OPT_D, D_SECTSIZE);
 	sbp->sb_inodesize = (uint16_t)isize;
-	sbp->sb_inopblock = (uint16_t)(blocksize / isize);
-	sbp->sb_sectlog = (uint8_t)sectorlog;
+	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) / isize);
+	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
 	sbp->sb_inodelog = (uint8_t)inodelog;
-	sbp->sb_inopblog = (uint8_t)(blocklog - inodelog);
+	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) - inodelog);
 	sbp->sb_rextslog =
 		(uint8_t)(rtextents ?
 			libxfs_highbit32((unsigned int)rtextents) : 0);
@@ -3169,14 +3286,15 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_imax_pct = imaxpct;
 	sbp->sb_icount = 0;
 	sbp->sb_ifree = 0;
-	sbp->sb_fdblocks = dblocks - agcount * libxfs_prealloc_blocks(mp) -
+	sbp->sb_fdblocks = dblocks -
+		get_conf_val(OPT_D, D_AGCOUNT) * libxfs_prealloc_blocks(mp) -
 		(loginternal ? logblocks : 0);
 	sbp->sb_frextents = 0;	/* will do a free later */
 	sbp->sb_uquotino = sbp->sb_gquotino = sbp->sb_pquotino = 0;
 	sbp->sb_qflags = 0;
-	sbp->sb_unit = dsunit;
-	sbp->sb_width = dswidth;
-	sbp->sb_dirblklog = dirblocklog - blocklog;
+	sbp->sb_unit = get_conf_val(OPT_D, D_SUNIT);
+	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
+	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
 	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
 		lsunit = (lsunit == 0) ? 1 : XFS_FSB_TO_B(mp, lsunit);
 		sbp->sb_logsunit = lsunit;
@@ -3186,11 +3304,12 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		int	cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
 		if (sb_feat.crcs_enabled)
 			cluster_size *= isize / XFS_DINODE_MIN_SIZE;
-		sbp->sb_inoalignmt = cluster_size >> blocklog;
+		sbp->sb_inoalignmt = cluster_size >> get_conf_val(OPT_B, B_LOG);
 		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
 	} else
 		sbp->sb_inoalignmt = 0;
-	if (lsectorsize != BBSIZE || sectorsize != BBSIZE) {
+	if (lsectorsize != BBSIZE ||
+	    get_conf_val(OPT_D, D_SECTSIZE) != BBSIZE) {
 		sbp->sb_logsectlog = (uint8_t)lsectorlog;
 		sbp->sb_logsectsize = (uint16_t)lsectorsize;
 	} else {
@@ -3198,7 +3317,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		sbp->sb_logsectsize = 0;
 	}
 
-	sb_set_features(&mp->m_sb, &sb_feat, sectorsize, lsectorsize, dsunit);
+	sb_set_features(&mp->m_sb, &sb_feat,
+			get_conf_val(OPT_D, D_SECTSIZE),
+			lsectorsize,
+			get_conf_val(OPT_D, D_SUNIT));
 
 	if (force_overwrite)
 		zero_old_xfs_structures(&xi, sbp);
@@ -3218,7 +3340,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	/* OK, now write the superblock */
 	buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, sectorsize);
+	memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_D, D_SECTSIZE));
 	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	libxfs_purgebuf(buf);
@@ -3228,8 +3350,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 * if needed so that the reads for the end of the device in the mount
 	 * code will succeed.
 	 */
-	if (xi.disfile && xi.dsize * xi.dbsize < dblocks * blocksize) {
-		if (ftruncate(xi.dfd, dblocks * blocksize) < 0) {
+	if (xi.disfile &&
+	    xi.dsize * xi.dbsize < dblocks * get_conf_val(OPT_B, B_SIZE)) {
+		if (ftruncate(xi.dfd,
+			     dblocks * get_conf_val(OPT_B, B_SIZE)) < 0) {
 			fprintf(stderr,
 				_("%s: Growing the data section failed\n"),
 				progname);
@@ -3271,7 +3395,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 * These initialisations should be pulled into libxfs to keep the
 	 * kernel/userspace header initialisation code the same.
 	 */
-	for (agno = 0; agno < agcount; agno++) {
+	for (agno = 0; agno < get_conf_val(OPT_D, D_AGCOUNT); agno++) {
 		struct xfs_agfl	*agfl;
 		int		bucket;
 		struct xfs_perag *pag = libxfs_perag_get(mp, agno);
@@ -3283,7 +3407,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
 				XFS_FSS_TO_BB(mp, 1));
 		buf->b_ops = &xfs_sb_buf_ops;
-		memset(XFS_BUF_PTR(buf), 0, sectorsize);
+		memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_D, D_SECTSIZE));
 		libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
@@ -3295,13 +3419,17 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				XFS_FSS_TO_BB(mp, 1));
 		buf->b_ops = &xfs_agf_buf_ops;
 		agf = XFS_BUF_TO_AGF(buf);
-		memset(agf, 0, sectorsize);
-		if (agno == agcount - 1)
-			agsize = dblocks - (xfs_rfsblock_t)(agno * agsize);
+		memset(agf, 0, get_conf_val(OPT_D, D_SECTSIZE));
+		if (agno == get_conf_val(OPT_D, D_AGCOUNT) - 1)
+			set_conf_val(OPT_D, D_AGSIZE,
+				dblocks -
+				(xfs_rfsblock_t)(agno *
+					get_conf_val(OPT_D, D_AGSIZE)));
+
 		agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
 		agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
 		agf->agf_seqno = cpu_to_be32(agno);
-		agf->agf_length = cpu_to_be32(agsize);
+		agf->agf_length = cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE));
 		agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp));
 		agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
 		agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
@@ -3323,7 +3451,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		agf->agf_flfirst = 0;
 		agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
 		agf->agf_flcount = 0;
-		nbmblocks = (xfs_extlen_t)(agsize - libxfs_prealloc_blocks(mp));
+		nbmblocks = (xfs_extlen_t)(get_conf_val(OPT_D, D_AGSIZE) -
+					   libxfs_prealloc_blocks(mp));
 		agf->agf_freeblks = cpu_to_be32(nbmblocks);
 		agf->agf_longest = cpu_to_be32(nbmblocks);
 		if (xfs_sb_version_hascrc(&mp->m_sb))
@@ -3331,7 +3460,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
 		if (loginternal && agno == logagno) {
 			be32_add_cpu(&agf->agf_freeblks, -logblocks);
-			agf->agf_longest = cpu_to_be32(agsize -
+			agf->agf_longest =
+				cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
 				XFS_FSB_TO_AGBNO(mp, logstart) - logblocks);
 		}
 		if (libxfs_alloc_min_freelist(mp, pag) > worst_freelist)
@@ -3347,7 +3477,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		buf->b_ops = &xfs_agfl_buf_ops;
 		agfl = XFS_BUF_TO_AGFL(buf);
 		/* setting to 0xff results in initialisation to NULLAGBLOCK */
-		memset(agfl, 0xff, sectorsize);
+		memset(agfl, 0xff, get_conf_val(OPT_D, D_SECTSIZE));
 		if (xfs_sb_version_hascrc(&mp->m_sb)) {
 			agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC);
 			agfl->agfl_seqno = cpu_to_be32(agno);
@@ -3366,11 +3496,13 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				XFS_FSS_TO_BB(mp, 1));
 		agi = XFS_BUF_TO_AGI(buf);
 		buf->b_ops = &xfs_agi_buf_ops;
-		memset(agi, 0, sectorsize);
+		memset(agi, 0, get_conf_val(OPT_D, D_SECTSIZE));
 		agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
 		agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
 		agi->agi_seqno = cpu_to_be32(agno);
-		agi->agi_length = cpu_to_be32((xfs_agblock_t)agsize);
+		agi->agi_length =
+			cpu_to_be32(
+				(xfs_agblock_t)get_conf_val(OPT_D, D_AGSIZE));
 		agi->agi_count = 0;
 		agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp));
 		agi->agi_level = cpu_to_be32(1);
@@ -3395,7 +3527,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 		buf->b_ops = &xfs_allocbt_buf_ops;
 		block = XFS_BUF_TO_BLOCK(buf);
-		memset(block, 0, blocksize);
+		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_btree_init_block(mp, buf, XFS_BTNUM_BNO, 0, 1, agno, 0);
 
 		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
@@ -3430,7 +3562,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		 * so, reset the record count to 0 to avoid exposure of an invalid
 		 * record start block.
 		 */
-		arec->ar_blockcount = cpu_to_be32(agsize -
+		arec->ar_blockcount =
+			cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
 					be32_to_cpu(arec->ar_startblock));
 		if (!arec->ar_blockcount)
 			block->bb_numrecs = 0;
@@ -3445,7 +3578,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 		buf->b_ops = &xfs_allocbt_buf_ops;
 		block = XFS_BUF_TO_BLOCK(buf);
-		memset(block, 0, blocksize);
+		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_btree_init_block(mp, buf, XFS_BTNUM_CNT, 0, 1, agno, 0);
 
 		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
@@ -3470,7 +3603,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		 * so, reset the record count to 0 to avoid exposure of an invalid
 		 * record start block.
 		 */
-		arec->ar_blockcount = cpu_to_be32(agsize -
+		arec->ar_blockcount =
+			cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
 					be32_to_cpu(arec->ar_startblock));
 		if (!arec->ar_blockcount)
 			block->bb_numrecs = 0;
@@ -3488,7 +3622,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			buf->b_ops = &xfs_refcountbt_buf_ops;
 
 			block = XFS_BUF_TO_BLOCK(buf);
-			memset(block, 0, blocksize);
+			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 			libxfs_btree_init_block(mp, buf, XFS_BTNUM_REFC, 0,
 						0, agno, 0);
 
@@ -3503,7 +3637,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 		buf->b_ops = &xfs_inobt_buf_ops;
 		block = XFS_BUF_TO_BLOCK(buf);
-		memset(block, 0, blocksize);
+		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_btree_init_block(mp, buf, XFS_BTNUM_INO, 0, 0, agno, 0);
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
@@ -3516,7 +3650,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 					bsize);
 			buf->b_ops = &xfs_inobt_buf_ops;
 			block = XFS_BUF_TO_BLOCK(buf);
-			memset(block, 0, blocksize);
+			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 			libxfs_btree_init_block(mp, buf, XFS_BTNUM_FINO, 0, 0, agno, 0);
 			libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 		}
@@ -3530,7 +3664,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 			buf->b_ops = &xfs_rmapbt_buf_ops;
 			block = XFS_BUF_TO_BLOCK(buf);
-			memset(block, 0, blocksize);
+			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 
 			libxfs_btree_init_block(mp, buf, XFS_BTNUM_RMAP, 0, 0, agno, 0);
 
@@ -3606,7 +3740,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 */
 	buf = libxfs_getbuf(mp->m_ddev_targp,
 		(xfs_daddr_t)XFS_FSB_TO_BB(mp, dblocks - 1LL), bsize);
-	memset(XFS_BUF_PTR(buf), 0, blocksize);
+	memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_B, B_SIZE));
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 	/*
@@ -3615,14 +3749,14 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	if (mp->m_rtdev_targp->dev && rtblocks > 0) {
 		buf = libxfs_getbuf(mp->m_rtdev_targp,
 				XFS_FSB_TO_BB(mp, rtblocks - 1LL), bsize);
-		memset(XFS_BUF_PTR(buf), 0, blocksize);
+		memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	}
 
 	/*
 	 * BNO, CNT free block list
 	 */
-	for (agno = 0; agno < agcount; agno++) {
+	for (agno = 0; agno < get_conf_val(OPT_D, D_AGCOUNT); agno++) {
 		xfs_alloc_arg_t	args;
 		xfs_trans_t	*tp;
 		struct xfs_trans_res tres = {0};
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] mkfs: replace variables with opts table: -i options
  2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
  2017-08-11 12:30 ` [PATCH 1/6] mkfs: save user input values into opts Jan Tulak
  2017-08-11 12:30 ` [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
@ 2017-08-11 12:30 ` Jan Tulak
  2017-08-14 23:31   ` Darrick J. Wong
  2017-08-11 12:30 ` [PATCH 4/6] mkfs: replace variables with opts table: -l options Jan Tulak
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Remove variables that can be replaced with a direct access to the opts
table, so we have it all in a single place, accessible from anywhere.

In future, we can remove some instances where we are passing values as
arguments to helper functions, when we have the values in the opts
struct and could pass only the struct.  But for now, limit the changes
to simple replacement without any change in the logic.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 mkfs/xfs_mkfs.c | 96 +++++++++++++++++++++++++++++----------------------------
 1 file changed, 49 insertions(+), 47 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 7f7f4554..66ba2869 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1689,13 +1689,9 @@ main(
 	bool			force_overwrite;
 	struct fsxattr		fsx;
 	int			ilflag;
-	int			imaxpct;
 	int			imflag;
-	int			inodelog;
-	int			inopblock;
 	int			ipflag;
 	int			isflag;
-	int			isize;
 	char			*label = NULL;
 	int			laflag;
 	int			lalign;
@@ -1780,8 +1776,7 @@ main(
 	logagno = logblocks = rtblocks = rtextblocks = 0;
 	Nflag = nlflag = nsflag = nvflag = 0;
 	dirblocklog = dirblocksize = 0;
-	qflag = 0;
-	imaxpct = inodelog = inopblock = isize = 0;
+	qflag = false;
 	dfile = logfile = rtfile = NULL;
 	protofile = NULL;
 	rtbytes = rtextbytes = logbytes = 0;
@@ -1926,27 +1921,22 @@ main(
 							       value);
 					break;
 				case I_LOG:
-					inodelog = parse_conf_val(OPT_I, I_LOG,
-								  value);
-					isize = 1 << inodelog;
+					parse_conf_val(OPT_I, I_LOG,
+							     value);
 					ilflag = 1;
 					break;
 				case I_MAXPCT:
-					imaxpct = parse_conf_val(OPT_I,
-								 I_MAXPCT,
-								 value);
+					parse_conf_val(OPT_I, I_MAXPCT, value);
 					imflag = 1;
 					break;
 				case I_PERBLOCK:
-					inopblock = parse_conf_val(OPT_I,
-								   I_PERBLOCK,
-								   value);
+					parse_conf_val(OPT_I, I_PERBLOCK,
+						       value);
 					ipflag = 1;
 					break;
 				case I_SIZE:
-					isize = parse_conf_val(OPT_I, I_SIZE,
+					parse_conf_val(OPT_I, I_SIZE,
 							       value);
-					inodelog = libxfs_highbit32(isize);
 					isflag = 1;
 					break;
 				case I_ATTR:
@@ -2398,7 +2388,8 @@ _("block size %lld cannot be smaller than logical sector size %d\n"),
 	 */
 	if (sb_feat.crcs_enabled) {
 		/* minimum inode size is 512 bytes, ipflag checked later */
-		if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) {
+		if ((isflag || ilflag) &&
+		    get_conf_val(OPT_I, I_LOG) < XFS_DINODE_DFL_CRC_LOG) {
 			fprintf(stderr,
 _("Minimum inode size for CRCs is %d bytes\n"),
 				1 << XFS_DINODE_DFL_CRC_LOG);
@@ -2522,15 +2513,17 @@ _("rmapbt not supported with realtime devices\n"));
 					   get_conf_val(OPT_B, B_LOG)));
 	}
 	if (ipflag) {
-		inodelog = get_conf_val(OPT_B, B_LOG) -
-			libxfs_highbit32(inopblock);
-		isize = 1 << inodelog;
+		set_conf_val(OPT_I, I_LOG, get_conf_val(OPT_B, B_LOG) -
+			libxfs_highbit32(get_conf_val(OPT_I, I_PERBLOCK)));
+		set_conf_val(OPT_I, I_SIZE, 1 << get_conf_val(OPT_I, I_LOG));
 	} else if (!ilflag && !isflag) {
-		inodelog = sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
-						: XFS_DINODE_DFL_LOG;
-		isize = 1 << inodelog;
+		set_conf_val(OPT_I, I_LOG,
+			     sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
+						: XFS_DINODE_DFL_LOG);
+		set_conf_val(OPT_I, I_SIZE, 1 << get_conf_val(OPT_I, I_LOG));
 	}
-	if (sb_feat.crcs_enabled && inodelog < XFS_DINODE_DFL_CRC_LOG) {
+	if (sb_feat.crcs_enabled && get_conf_val(OPT_I, I_LOG) <
+	    XFS_DINODE_DFL_CRC_LOG) {
 		fprintf(stderr,
 		_("Minimum inode size for CRCs is %d bytes\n"),
 			1 << XFS_DINODE_DFL_CRC_LOG);
@@ -2617,12 +2610,14 @@ _("rmapbt not supported with realtime devices\n"));
 	/*
 	 * Check some argument sizes against mins, maxes.
 	 */
-	if (isize > get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
-	    isize < XFS_DINODE_MIN_SIZE ||
-	    isize > XFS_DINODE_MAX_SIZE) {
+	if (get_conf_val(OPT_I, I_SIZE) >
+	    get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
+	    get_conf_val(OPT_I, I_SIZE) < XFS_DINODE_MIN_SIZE ||
+	    get_conf_val(OPT_I, I_SIZE) > XFS_DINODE_MAX_SIZE) {
 		int	maxsz;
 
-		fprintf(stderr, _("illegal inode size %d\n"), isize);
+		fprintf(stderr, _("illegal inode size %lld\n"),
+			get_conf_val(OPT_I, I_SIZE));
 		maxsz = MIN(get_conf_val(OPT_B, B_SIZE) /
 			    XFS_MIN_INODE_PERBLOCK,
 			    XFS_DINODE_MAX_SIZE);
@@ -3034,8 +3029,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 			     get_conf_val(OPT_D, D_AGCOUNT));
 
 	if (!imflag)
-		imaxpct = calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
-					       dblocks);
+		set_conf_val(OPT_I, I_MAXPCT,
+			     calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
+					       dblocks));
 
 	/*
 	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
@@ -3068,7 +3064,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 				   sb_feat.crcs_enabled, sb_feat.dir_version,
 				   get_conf_val(OPT_D, D_SECTLOG),
 				   get_conf_val(OPT_B, B_LOG),
-				   inodelog, dirblocklog,
+				   get_conf_val(OPT_I, I_LOG), dirblocklog,
 				   sb_feat.log_version, lsunit, sb_feat.finobt,
 				   sb_feat.rmapbt, sb_feat.reflink,
 				   sb_feat.inode_align);
@@ -3227,29 +3223,32 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
 	if (!qflag || Nflag) {
 		printf(_(
-		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
+		   "meta-data=%-22s isize=%-6lld agcount=%lld, agsize=%lld blks\n"
 		   "         =%-22s sectsz=%-5lld attr=%u, projid32bit=%u\n"
 		   "         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u, reflink=%u\n"
-		   "data     =%-22s bsize=%-6lld blocks=%llu, imaxpct=%u\n"
-		   "         =%-22s sunit=%-6lld swidth=%lld blks\n"
-		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
+		   "data     =%-22s bsize=%-6llu blocks=%lld, imaxpct=%lld\n"
+		   "         =%-22s sunit=%-6llu swidth=%lld blks\n"
+		   "naming   =version %-14u bsize=%-6llu ascii-ci=%d ftype=%d\n"
 		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
-		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
+		   "         =%-22s sectsz=%-5lld sunit=%lld blks, lazy-count=%d\n"
 		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
-			dfile, isize, get_conf_val(OPT_D, D_AGCOUNT),
+			dfile, get_conf_val(OPT_I, I_SIZE),
+			get_conf_val(OPT_D, D_AGCOUNT),
 			get_conf_val(OPT_D, D_AGSIZE),
 			"", get_conf_val(OPT_D, D_SECTSIZE),
 			sb_feat.attr_version,
 				    !sb_feat.projid16bit,
 			"", sb_feat.crcs_enabled, sb_feat.finobt, sb_feat.spinodes,
 			sb_feat.rmapbt, sb_feat.reflink,
-			"", get_conf_val(OPT_B, B_SIZE), (long long)dblocks, imaxpct,
+			"", get_conf_val(OPT_B, B_SIZE),
+			(long long)dblocks,
+			get_conf_val(OPT_I, I_MAXPCT),
 			"", get_conf_val(OPT_D, D_SUNIT),
 			get_conf_val(OPT_D, D_SWIDTH),
-			sb_feat.dir_version, dirblocksize, sb_feat.nci,
+			sb_feat.dir_version, (long long)dirblocksize, sb_feat.nci,
 				sb_feat.dirftype,
 			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
-			sb_feat.log_version, "", lsectorsize, lsunit,
+			sb_feat.log_version, "", (long long)lsectorsize, (long long)lsunit,
 				sb_feat.lazy_sb_counters,
 			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
 			(long long)rtblocks, (long long)rtextents);
@@ -3274,16 +3273,18 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_rbmblocks = nbmblocks;
 	sbp->sb_logblocks = (xfs_extlen_t)logblocks;
 	sbp->sb_sectsize = (uint16_t)get_conf_val(OPT_D, D_SECTSIZE);
-	sbp->sb_inodesize = (uint16_t)isize;
-	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) / isize);
+	sbp->sb_inodesize = (uint16_t)get_conf_val(OPT_I, I_SIZE);
+	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) /
+					 get_conf_val(OPT_I, I_SIZE));
 	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
-	sbp->sb_inodelog = (uint8_t)inodelog;
-	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) - inodelog);
+	sbp->sb_inodelog = (uint8_t)get_conf_val(OPT_I, I_LOG);
+	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) -
+				       get_conf_val(OPT_I, I_LOG));
 	sbp->sb_rextslog =
 		(uint8_t)(rtextents ?
 			libxfs_highbit32((unsigned int)rtextents) : 0);
 	sbp->sb_inprogress = 1;	/* mkfs is in progress */
-	sbp->sb_imax_pct = imaxpct;
+	sbp->sb_imax_pct = get_conf_val(OPT_I, I_MAXPCT);
 	sbp->sb_icount = 0;
 	sbp->sb_ifree = 0;
 	sbp->sb_fdblocks = dblocks -
@@ -3303,7 +3304,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	if (sb_feat.inode_align) {
 		int	cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
 		if (sb_feat.crcs_enabled)
-			cluster_size *= isize / XFS_DINODE_MIN_SIZE;
+			cluster_size *= get_conf_val(OPT_I, I_SIZE) /
+				XFS_DINODE_MIN_SIZE;
 		sbp->sb_inoalignmt = cluster_size >> get_conf_val(OPT_B, B_LOG);
 		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
 	} else
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] mkfs: replace variables with opts table: -l options
  2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
                   ` (2 preceding siblings ...)
  2017-08-11 12:30 ` [PATCH 3/6] mkfs: replace variables with opts table: -i options Jan Tulak
@ 2017-08-11 12:30 ` Jan Tulak
  2017-08-14 23:34   ` Darrick J. Wong
  2017-08-11 12:30 ` [PATCH 5/6] mkfs: replace variables with opts table: -n options Jan Tulak
  2017-08-11 12:30 ` [PATCH 6/6] mkfs: replace variables with opts table: -r options Jan Tulak
  5 siblings, 1 reply; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Remove variables that can be replaced with a direct access to the opts
table, so we have it all in a single place, accessible from anywhere.

In future, we can remove some instances where we are passing values as
arguments to helper functions, when we have the values in the opts
struct and could pass only the struct.  But for now, limit the changes
to simple replacement without any change in the logic.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 mkfs/xfs_mkfs.c | 258 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 134 insertions(+), 124 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 66ba2869..4e85694f 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -448,6 +448,7 @@ struct opt_params {
 			  .minval = 0,
 			  .maxval = 1,
 			  .flagval = 1,
+			  .value = 1,
 			},
 			{ .index = L_SIZE,
 			  .conflicts = { LAST_CONFLICT },
@@ -1121,7 +1122,8 @@ parse_conf_val(int opt, int subopt, char *value)
 }
 
 /*
- * Convert lsu to lsunit for 512 bytes blocks and check validity of the values.
+ * Convert L_SU to L_SUNIT for 512 bytes blocks and check validity of the
+ * values.
  */
 static void
 calc_stripe_factors(
@@ -1173,7 +1175,7 @@ calc_stripe_factors(
 	if (lsu)
 		*lsunit = (int)BTOBBT(lsu);
 
-	/* verify if lsu/lsunit is a multiple block size */
+	/* verify if L_SU/L_SUNIT is a multiple block size */
 	if (lsu % get_conf_val(OPT_B, B_SIZE) != 0) {
 		fprintf(stderr,
 _("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
@@ -1697,22 +1699,15 @@ main(
 	int			lalign;
 	int			ldflag;
 	int			liflag;
-	xfs_agnumber_t		logagno;
 	xfs_rfsblock_t		logblocks;
 	char			*logfile;
-	int			loginternal;
-	uint64_t		logbytes;
 	xfs_fsblock_t		logstart;
 	int			lvflag;
 	int			lsflag;
 	int			lsuflag;
 	int			lsunitflag;
-	int			lsectorlog;
-	int			lsectorsize;
 	int			lslflag;
 	int			lssflag;
-	int			lsu;
-	int			lsunit;
 	int			min_logblocks;
 	xfs_mount_t		*mp;
 	xfs_mount_t		mbuf;
@@ -1767,20 +1762,17 @@ main(
 	textdomain(PACKAGE);
 
 	blflag = bsflag = slflag = ssflag = lslflag = lssflag = 0;
-	lsectorlog = 0;
-	lsectorsize = 0;
 	dasize = dblocks = 0;
 	daflag = ilflag = imflag = ipflag = isflag = false;
 	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
-	loginternal = 1;
-	logagno = logblocks = rtblocks = rtextblocks = 0;
-	Nflag = nlflag = nsflag = nvflag = 0;
+	logblocks = rtblocks = rtextblocks = 0;
+	Nflag = nlflag = nsflag = nvflag = false;
 	dirblocklog = dirblocksize = 0;
 	qflag = false;
 	dfile = logfile = rtfile = NULL;
 	protofile = NULL;
-	rtbytes = rtextbytes = logbytes = 0;
-	lalign = lsu = lsunit = 0;
+	rtbytes = rtextbytes = 0;
+	lalign = 0;
 	dsflag = norsflag = false;
 	force_overwrite = false;
 	worst_freelist = 0;
@@ -1969,9 +1961,7 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case L_AGNUM:
-					logagno = parse_conf_val(OPT_L,
-								 L_AGNUM,
-								 value);
+					parse_conf_val(OPT_L, L_AGNUM, value);
 					laflag = 1;
 					break;
 				case L_FILE:
@@ -1980,20 +1970,16 @@ main(
 								    value);
 					break;
 				case L_INTERNAL:
-					loginternal =
-						parse_conf_val(OPT_L,
-							       L_INTERNAL,
-							       value);
+					parse_conf_val(OPT_L, L_INTERNAL,
+						       value);
 					liflag = 1;
 					break;
 				case L_SU:
-					lsu = parse_conf_val(OPT_L, L_SU,
-							     value);
+					parse_conf_val(OPT_L, L_SU, value);
 					lsuflag = 1;
 					break;
 				case L_SUNIT:
-					lsunit = parse_conf_val(OPT_L, L_SUNIT,
-								value);
+					parse_conf_val(OPT_L, L_SUNIT, value);
 					lsunitflag = 1;
 					break;
 				case L_NAME:
@@ -2002,7 +1988,7 @@ main(
 								L_NAME);
 					xi.logname = logfile;
 					ldflag = 1;
-					loginternal = 0;
+					set_conf_val(OPT_L, L_INTERNAL, 0);
 					set_conf_val(OPT_L, L_NAME, 1);
 					set_conf_val(OPT_L, L_DEV, 1);
 					break;
@@ -2014,24 +2000,18 @@ main(
 					lvflag = 1;
 					break;
 				case L_SIZE:
-					logbytes = parse_conf_val(OPT_L,
-								  L_SIZE,
-								  value);
+					parse_conf_val(OPT_L, L_SIZE, value);
 					break;
 				case L_SECTLOG:
-					lsectorlog = parse_conf_val(OPT_L,
+					parse_conf_val(OPT_L,
 								    L_SECTLOG,
 								    value);
-					lsectorsize = 1 << lsectorlog;
 					lslflag = 1;
 					break;
 				case L_SECTSIZE:
-					lsectorsize =
 						parse_conf_val(OPT_L,
 							       L_SECTSIZE,
 							       value);
-					lsectorlog =
-						libxfs_highbit32(lsectorsize);
 					lssflag = 1;
 					break;
 				case L_LAZYSBCNTR:
@@ -2201,7 +2181,6 @@ main(
 				char	**subopts =
 						(char **)opts[OPT_S].subopts;
 				char	*value;
-				uint64_t tmp;
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case S_LOG:
@@ -2210,12 +2189,8 @@ main(
 						conflict('s', subopts,
 							 S_SECTSIZE,
 							 S_SECTLOG);
-					tmp = parse_conf_val(OPT_S,
-								   S_SECTLOG,
-								   value);
-
-					lsectorlog = tmp;
-					lsectorsize = tmp;
+					parse_conf_val(OPT_S, S_SECTLOG,
+							value);
 					lslflag = slflag = 1;
 					break;
 				case S_SIZE:
@@ -2224,12 +2199,8 @@ main(
 						conflict('s', subopts,
 							 S_SECTLOG,
 							 S_SECTSIZE);
-					tmp = parse_conf_val(OPT_S,
-								    S_SECTSIZE,
-								    value);
-
-					lsectorlog = libxfs_highbit32(tmp);
-					lsectorsize = tmp;
+					parse_conf_val(OPT_S, S_SECTSIZE,
+							value);
 					lssflag = ssflag = 1;
 					break;
 				default:
@@ -2285,8 +2256,9 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 		set_conf_val(OPT_D, D_SECTSIZE, XFS_MIN_SECTORSIZE);
 	}
 	if (!lslflag && !lssflag) {
-		lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
-		lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
+		set_conf_val(OPT_L, L_SECTLOG, get_conf_val(OPT_D, D_SECTLOG));
+		set_conf_val(OPT_L, L_SECTSIZE,
+			     get_conf_val(OPT_D, D_SECTSIZE));
 	}
 
 	/*
@@ -2299,8 +2271,9 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 	check_device_type(dfile, &xi.disfile, !get_conf_val(OPT_D, D_SIZE),
 			  !dfile,
 			  Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
-	if (!loginternal)
-		check_device_type(xi.logname, &xi.lisfile, !logbytes,
+	if (!get_conf_val(OPT_L, L_INTERNAL))
+		check_device_type(xi.logname, &xi.lisfile,
+				  !get_conf_val(OPT_L, L_SIZE),
 				  !xi.logname, Nflag ? NULL : &xi.lcreat,
 				  force_overwrite, "l");
 	if (xi.rtname)
@@ -2348,9 +2321,11 @@ _("switching to logical sector size %d\n"),
 	if (!ssflag) {
 		set_conf_val(OPT_D, D_SECTLOG,
 			     libxfs_highbit32(get_conf_val(OPT_D, D_SECTSIZE)));
-		if (loginternal) {
-			lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
-			lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
+		if (get_conf_val(OPT_L, L_INTERNAL)) {
+			set_conf_val(OPT_L, L_SECTSIZE,
+				     get_conf_val(OPT_D, D_SECTSIZE));
+			set_conf_val(OPT_L, L_SECTLOG,
+				     get_conf_val(OPT_D, D_SECTLOG));
 		}
 	}
 
@@ -2371,13 +2346,16 @@ _("block size %lld cannot be smaller than logical sector size %d\n"),
 			get_conf_val(OPT_D, D_SECTSIZE), ft.lsectorsize);
 		usage();
 	}
-	if (lsectorsize < XFS_MIN_SECTORSIZE ||
-	    lsectorsize > XFS_MAX_SECTORSIZE ||
-	    lsectorsize > get_conf_val(OPT_B, B_SIZE)) {
-		fprintf(stderr, _("illegal log sector size %d\n"), lsectorsize);
+	if (get_conf_val(OPT_L, L_SECTSIZE) < XFS_MIN_SECTORSIZE ||
+	    get_conf_val(OPT_L, L_SECTSIZE) > XFS_MAX_SECTORSIZE ||
+	    get_conf_val(OPT_L, L_SECTSIZE) > get_conf_val(OPT_B, B_SIZE)) {
+		fprintf(stderr, _("illegal log sector size %lld\n"),
+			get_conf_val(OPT_L, L_SECTSIZE));
 		usage();
-	} else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
-		lsu = get_conf_val(OPT_B, B_SIZE);
+	} else if (get_conf_val(OPT_L, L_SECTSIZE) > XFS_MIN_SECTORSIZE &&
+		   !get_conf_val(OPT_L, L_SU) &&
+		   !get_conf_val(OPT_L, L_SUNIT)) {
+		set_conf_val(OPT_L, L_SU, get_conf_val(OPT_B, B_SIZE));
 		sb_feat.log_version = 2;
 	}
 
@@ -2530,19 +2508,20 @@ _("rmapbt not supported with realtime devices\n"));
 		usage();
 	}
 
-	if (logbytes) {
-		if (logbytes % XFS_MIN_BLOCKSIZE) {
+	if (get_conf_val(OPT_L, L_SIZE)) {
+		if (get_conf_val(OPT_L, L_SIZE) % XFS_MIN_BLOCKSIZE) {
 			fprintf(stderr,
 			_("illegal log length %lld, not a multiple of %d\n"),
-				(long long)logbytes, XFS_MIN_BLOCKSIZE);
+				get_conf_val(OPT_L, L_SIZE), XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		logblocks = (xfs_rfsblock_t)(logbytes >>
+		logblocks = (xfs_rfsblock_t)(get_conf_val(OPT_L, L_SIZE) >>
 					     get_conf_val(OPT_B, B_LOG));
-		if (logbytes % get_conf_val(OPT_B, B_SIZE))
+		if (get_conf_val(OPT_L, L_SIZE) % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr,
 	_("warning: log length %lld not a multiple of %lld, truncated to %lld\n"),
-				(long long)logbytes, get_conf_val(OPT_B, B_SIZE),
+				get_conf_val(OPT_L, L_SIZE),
+				get_conf_val(OPT_B, B_SIZE),
 				(long long)(logblocks <<
 					   get_conf_val(OPT_B, B_LOG)));
 	}
@@ -2634,8 +2613,9 @@ _("rmapbt not supported with realtime devices\n"));
 		exit(1);
 	}
 
-	/* if lsu or lsunit was specified, automatically use v2 logs */
-	if ((lsu || lsunit) && sb_feat.log_version == 1) {
+	/* if L_SU or L_SUNIT was specified, automatically use v2 logs */
+	if ((get_conf_val(OPT_L, L_SU) ||
+	     get_conf_val(OPT_L, L_SUNIT)) && sb_feat.log_version == 1) {
 		fprintf(stderr,
 			_("log stripe unit specified, using v2 logs\n"));
 		sb_feat.log_version = 2;
@@ -2643,13 +2623,14 @@ _("rmapbt not supported with realtime devices\n"));
 
 	int dsunit = get_conf_val(OPT_D, D_SUNIT);
 	int dswidth = get_conf_val(OPT_D, D_SWIDTH);
+	int lsunit = get_conf_val(OPT_L, L_SUNIT);
 
 	calc_stripe_factors(get_conf_val(OPT_D, D_SU),
 			    get_conf_val(OPT_D, D_SW),
 			    get_conf_val(OPT_D, D_SECTSIZE),
-			    lsu,
-			    lsectorsize,
-				&dsunit, &dswidth, &lsunit);
+			    get_conf_val(OPT_L, L_SU),
+			    get_conf_val(OPT_L, L_SECTSIZE),
+			    &dsunit, &dswidth, &lsunit);
 
 	/* If sunit & swidth were manually specified as 0, same as noalign */
 	if (dsflag && !dsunit && !dswidth)
@@ -2657,6 +2638,7 @@ _("rmapbt not supported with realtime devices\n"));
 
 	set_conf_val(OPT_D, D_SUNIT, dsunit);
 	set_conf_val(OPT_D, D_SWIDTH, dswidth);
+	set_conf_val(OPT_L, L_SUNIT, lsunit);
 
 	xi.setblksize = get_conf_val(OPT_D, D_SECTSIZE);
 
@@ -2685,7 +2667,8 @@ _("rmapbt not supported with realtime devices\n"));
 		(MAX(get_conf_val(OPT_D, D_SECTLOG), 10) - BBSHIFT);
 	xi.dsize &= sector_mask;
 	xi.rtsize &= sector_mask;
-	xi.logBBsize &= (uint64_t)-1 << (MAX(lsectorlog, 10) - BBSHIFT);
+	xi.logBBsize &= (uint64_t)-1 << (MAX(get_conf_val(OPT_L, L_SECTLOG),
+					     10) - BBSHIFT);
 
 
 	/* don't do discards on print-only runs or on files */
@@ -2699,10 +2682,10 @@ _("rmapbt not supported with realtime devices\n"));
 	}
 
 	if (!liflag && !ldflag)
-		loginternal = xi.logdev == 0;
+		set_conf_val(OPT_L, L_INTERNAL, xi.logdev == 0);
 	if (xi.logname)
 		logfile = xi.logname;
-	else if (loginternal)
+	else if (get_conf_val(OPT_L, L_INTERNAL))
 		logfile = _("internal log");
 	else if (xi.volname && xi.logdev)
 		logfile = _("volume log");
@@ -2738,12 +2721,13 @@ _("rmapbt not supported with realtime devices\n"));
 		usage();
 	}
 
-	if (loginternal && xi.logdev) {
+	if (get_conf_val(OPT_L, L_INTERNAL) && xi.logdev) {
 		fprintf(stderr,
 			_("can't have both external and internal logs\n"));
 		usage();
-	} else if (loginternal &&
-		   get_conf_val(OPT_D, D_SECTSIZE) != lsectorsize) {
+	} else if (get_conf_val(OPT_L, L_INTERNAL) &&
+		   get_conf_val(OPT_D, D_SECTSIZE) !=
+		   get_conf_val(OPT_L, L_SECTSIZE)) {
 		fprintf(stderr,
 	_("data and log sector sizes must be equal for internal logs\n"));
 		usage();
@@ -2755,11 +2739,12 @@ _("rmapbt not supported with realtime devices\n"));
 reported by the device (%u).\n"),
 			get_conf_val(OPT_D, D_SECTSIZE), xi.dbsize);
 	}
-	if (!loginternal && xi.lbsize > lsectorsize) {
+	if (!get_conf_val(OPT_L, L_INTERNAL) &&
+	    xi.lbsize > get_conf_val(OPT_L, L_SECTSIZE)) {
 		fprintf(stderr, _(
-"Warning: the log subvolume sector size %u is less than the sector size\n\
+"Warning: the log subvolume sector size %lld is less than the sector size\n\
 reported by the device (%u).\n"),
-			lsectorsize, xi.lbsize);
+			get_conf_val(OPT_L, L_SECTSIZE), xi.lbsize);
 	}
 	if (rtbytes && xi.rtsize > 0 &&
 	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
@@ -3037,27 +3022,31 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
 	 */
 
-	if (lsunit) {
+	if (get_conf_val(OPT_L, L_SUNIT)) {
 		/* convert from 512 byte blocks to fs blocks */
-		lsunit = DTOBT(lsunit);
+		set_conf_val(OPT_L, L_SUNIT,
+			     DTOBT(get_conf_val(OPT_L, L_SUNIT)));
 	} else if (sb_feat.log_version == 2 &&
-		   loginternal &&
+		   get_conf_val(OPT_L, L_INTERNAL) &&
 		   get_conf_val(OPT_D, D_SUNIT)) {
-		/* lsunit and get_conf_val(OPT_D, D_SUNIT) now in fs blocks */
-		lsunit = get_conf_val(OPT_D, D_SUNIT);
+		/* L_SUNIT and D_SUNIT now in fs blocks */
+		set_conf_val(OPT_L, L_SUNIT, get_conf_val(OPT_D, D_SUNIT));
 	}
 
 	if (sb_feat.log_version == 2 &&
-	    (lsunit * get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
+	    (get_conf_val(OPT_L, L_SUNIT) *
+	     get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
 		/* Warn only if specified on commandline */
 		if (lsuflag || lsunitflag) {
 			fprintf(stderr,
 	_("log stripe unit (%lld bytes) is too large (maximum is 256KiB)\n"),
-				(lsunit * get_conf_val(OPT_B, B_SIZE)));
+				(get_conf_val(OPT_L, L_SUNIT) *
+				 get_conf_val(OPT_B, B_SIZE)));
 			fprintf(stderr,
 	_("log stripe unit adjusted to 32KiB\n"));
 		}
-		lsunit = (32 * 1024) >> get_conf_val(OPT_B, B_LOG);
+		set_conf_val(OPT_L, L_SUNIT,
+			     (32 * 1024) >> get_conf_val(OPT_B, B_LOG));
 	}
 
 	min_logblocks = max_trans_res(get_conf_val(OPT_D, D_AGSIZE),
@@ -3065,35 +3054,41 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 				   get_conf_val(OPT_D, D_SECTLOG),
 				   get_conf_val(OPT_B, B_LOG),
 				   get_conf_val(OPT_I, I_LOG), dirblocklog,
-				   sb_feat.log_version, lsunit, sb_feat.finobt,
+				   sb_feat.log_version,
+				   get_conf_val(OPT_L, L_SUNIT),
+				   sb_feat.finobt,
 				   sb_feat.rmapbt, sb_feat.reflink,
 				   sb_feat.inode_align);
 	ASSERT(min_logblocks);
 	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
-	if (!logbytes &&
+	if (!get_conf_val(OPT_L, L_SIZE) &&
 	    dblocks >= (1024*1024*1024) >> get_conf_val(OPT_B, B_LOG))
 		min_logblocks = MAX(min_logblocks,
 				    XFS_MIN_LOG_BYTES >>
 				    get_conf_val(OPT_B, B_LOG));
-	if (logbytes && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
+	if (get_conf_val(OPT_L, L_SIZE) && xi.logBBsize > 0 &&
+	    logblocks > DTOBT(xi.logBBsize)) {
 		fprintf(stderr,
 _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			get_conf_raw_safe(OPT_L, L_SIZE),
 			(long long)DTOBT(xi.logBBsize));
 		usage();
-	} else if (!logbytes && xi.logBBsize > 0) {
+	} else if (!get_conf_val(OPT_L, L_SIZE) && xi.logBBsize > 0) {
 		logblocks = DTOBT(xi.logBBsize);
-	} else if (logbytes && !xi.logdev && !loginternal) {
+	} else if (get_conf_val(OPT_L, L_SIZE) && !xi.logdev &&
+		   !get_conf_val(OPT_L, L_INTERNAL)) {
 		fprintf(stderr,
 			_("size specified for non-existent log subvolume\n"));
 		usage();
-	} else if (loginternal && logbytes && logblocks >= dblocks) {
+	} else if (get_conf_val(OPT_L, L_INTERNAL) &&
+		   get_conf_val(OPT_L, L_SIZE) && logblocks >= dblocks) {
 		fprintf(stderr, _("size %lld too large for internal log\n"),
 			(long long)logblocks);
 		usage();
-	} else if (!loginternal && !xi.logdev) {
+	} else if (!get_conf_val(OPT_L, L_INTERNAL) && !xi.logdev) {
 		logblocks = 0;
-	} else if (loginternal && !logbytes) {
+	} else if (get_conf_val(OPT_L, L_INTERNAL) &&
+		   !get_conf_val(OPT_L, L_SIZE)) {
 
 		if (dblocks < GIGABYTES(1, get_conf_val(OPT_B, B_LOG))) {
 			/* tiny filesystems get minimum sized logs. */
@@ -3157,16 +3152,16 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 */
 	sb_set_features(&mp->m_sb, &sb_feat,
 			get_conf_val(OPT_D, D_SECTSIZE),
-			lsectorsize,
+			get_conf_val(OPT_L, L_SECTSIZE),
 			get_conf_val(OPT_D, D_SUNIT));
 
 
-	if (loginternal) {
+	if (get_conf_val(OPT_L, L_INTERNAL)) {
 		/*
 		 * Readjust the log size to fit within an AG if it was sized
 		 * automatically.
 		 */
-		if (!logbytes) {
+		if (!get_conf_val(OPT_L, L_SIZE)) {
 			logblocks = MIN(logblocks,
 					libxfs_alloc_ag_max_usable(mp));
 
@@ -3184,25 +3179,28 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		}
 
 		if (laflag) {
-			if (logagno >= get_conf_val(OPT_D, D_AGCOUNT)) {
+			if (get_conf_val(OPT_L, L_AGNUM) >=
+			    get_conf_val(OPT_D, D_AGCOUNT)) {
 				fprintf(stderr,
-		_("log ag number %d too large, must be less than %lld\n"),
-					logagno,
+	_("log ag number %lld too large, must be less than %lld\n"),
+					get_conf_val(OPT_L, L_AGNUM),
 					get_conf_val(OPT_D, D_AGCOUNT));
 				usage();
 			}
 		} else
-			logagno = (xfs_agnumber_t)(
-					get_conf_val(OPT_D, D_AGCOUNT) / 2);
+			set_conf_val(OPT_L, L_AGNUM, (xfs_agnumber_t)(
+					get_conf_val(OPT_D, D_AGCOUNT) / 2));
 
-		logstart = XFS_AGB_TO_FSB(mp, logagno, libxfs_prealloc_blocks(mp));
+		logstart = XFS_AGB_TO_FSB(mp, get_conf_val(OPT_L, L_AGNUM),
+					  libxfs_prealloc_blocks(mp));
 		/*
 		 * Align the logstart at stripe unit boundary.
 		 */
-		if (lsunit) {
+		if (get_conf_val(OPT_L, L_SUNIT)) {
 			logstart = fixup_internal_log_stripe(mp,
 					lsflag, logstart,
-					get_conf_val(OPT_D, D_AGSIZE), lsunit,
+					get_conf_val(OPT_D, D_AGSIZE),
+					get_conf_val(OPT_L, L_SUNIT),
 					&logblocks,
 					get_conf_val(OPT_B, B_LOG), &lalign);
 		} else if (get_conf_val(OPT_D, D_SUNIT)) {
@@ -3215,8 +3213,9 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		}
 	} else {
 		logstart = 0;
-		if (lsunit)
-			fixup_log_stripe_unit(lsflag, lsunit,
+		if (get_conf_val(OPT_L, L_SUNIT))
+			fixup_log_stripe_unit(lsflag,
+					      get_conf_val(OPT_L, L_SUNIT),
 					&logblocks, get_conf_val(OPT_B, B_LOG));
 	}
 	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
@@ -3248,7 +3247,9 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			sb_feat.dir_version, (long long)dirblocksize, sb_feat.nci,
 				sb_feat.dirftype,
 			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
-			sb_feat.log_version, "", (long long)lsectorsize, (long long)lsunit,
+			sb_feat.log_version, "",
+			get_conf_val(OPT_L, L_SECTSIZE),
+			get_conf_val(OPT_L, L_SUNIT),
 				sb_feat.lazy_sb_counters,
 			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
 			(long long)rtblocks, (long long)rtextents);
@@ -3289,7 +3290,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_ifree = 0;
 	sbp->sb_fdblocks = dblocks -
 		get_conf_val(OPT_D, D_AGCOUNT) * libxfs_prealloc_blocks(mp) -
-		(loginternal ? logblocks : 0);
+		(get_conf_val(OPT_L, L_INTERNAL) ? logblocks : 0);
 	sbp->sb_frextents = 0;	/* will do a free later */
 	sbp->sb_uquotino = sbp->sb_gquotino = sbp->sb_pquotino = 0;
 	sbp->sb_qflags = 0;
@@ -3297,8 +3298,11 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
 	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
 	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
-		lsunit = (lsunit == 0) ? 1 : XFS_FSB_TO_B(mp, lsunit);
-		sbp->sb_logsunit = lsunit;
+		set_conf_val(OPT_L, L_SUNIT,
+			     (get_conf_val(OPT_L, L_SUNIT) == 0) ?
+			     1 : XFS_FSB_TO_B(mp,
+					      get_conf_val(OPT_L, L_SUNIT)));
+		sbp->sb_logsunit = get_conf_val(OPT_L, L_SUNIT);
 	} else
 		sbp->sb_logsunit = 0;
 	if (sb_feat.inode_align) {
@@ -3310,10 +3314,11 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
 	} else
 		sbp->sb_inoalignmt = 0;
-	if (lsectorsize != BBSIZE ||
+	if (get_conf_val(OPT_L, L_SECTSIZE) != BBSIZE ||
 	    get_conf_val(OPT_D, D_SECTSIZE) != BBSIZE) {
-		sbp->sb_logsectlog = (uint8_t)lsectorlog;
-		sbp->sb_logsectsize = (uint16_t)lsectorsize;
+		sbp->sb_logsectlog = (uint8_t)get_conf_val(OPT_L, L_SECTLOG);
+		sbp->sb_logsectsize =
+			(uint16_t)get_conf_val(OPT_L, L_SECTSIZE);
 	} else {
 		sbp->sb_logsectlog = 0;
 		sbp->sb_logsectsize = 0;
@@ -3321,7 +3326,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
 	sb_set_features(&mp->m_sb, &sb_feat,
 			get_conf_val(OPT_D, D_SECTSIZE),
-			lsectorsize,
+			get_conf_val(OPT_L, L_SECTSIZE),
 			get_conf_val(OPT_D, D_SUNIT));
 
 	if (force_overwrite)
@@ -3383,7 +3388,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	libxfs_log_clear(mp->m_logdev_targp, NULL,
 		XFS_FSB_TO_DADDR(mp, logstart),
 		(xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
-		&sbp->sb_uuid, sb_feat.log_version, lsunit, XLOG_FMT, XLOG_INIT_CYCLE, false);
+		&sbp->sb_uuid, sb_feat.log_version,
+		get_conf_val(OPT_L, L_SUNIT), XLOG_FMT, XLOG_INIT_CYCLE, false);
 
 	mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 0);
 	if (mp == NULL) {
@@ -3460,7 +3466,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		if (xfs_sb_version_hascrc(&mp->m_sb))
 			platform_uuid_copy(&agf->agf_uuid, &mp->m_sb.sb_uuid);
 
-		if (loginternal && agno == logagno) {
+		if (get_conf_val(OPT_L, L_INTERNAL) &&
+		    agno == get_conf_val(OPT_L, L_AGNUM)) {
 			be32_add_cpu(&agf->agf_freeblks, -logblocks);
 			agf->agf_longest =
 				cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
@@ -3534,7 +3541,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
 		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
 		arec->ar_startblock = cpu_to_be32(libxfs_prealloc_blocks(mp));
-		if (loginternal && agno == logagno) {
+		if (get_conf_val(OPT_L, L_INTERNAL) &&
+		    agno == get_conf_val(OPT_L, L_AGNUM)) {
 			if (lalign) {
 				/*
 				 * Have to insert two records
@@ -3585,7 +3593,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
 		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
 		arec->ar_startblock = cpu_to_be32(libxfs_prealloc_blocks(mp));
-		if (loginternal && agno == logagno) {
+		if (get_conf_val(OPT_L, L_INTERNAL) &&
+		    agno == get_conf_val(OPT_L, L_AGNUM)) {
 			if (lalign) {
 				arec->ar_blockcount = cpu_to_be32(
 					XFS_FSB_TO_AGBNO(mp, logstart) -
@@ -3720,7 +3729,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			}
 
 			/* account for the log space */
-			if (loginternal && agno == logagno) {
+			if (get_conf_val(OPT_L, L_INTERNAL) && agno ==
+			    get_conf_val(OPT_L, L_AGNUM)) {
 				rrec = XFS_RMAP_REC_ADDR(block,
 					be16_to_cpu(block->bb_numrecs) + 1);
 				rrec->rm_startblock = cpu_to_be32(
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] mkfs: replace variables with opts table: -n options
  2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
                   ` (3 preceding siblings ...)
  2017-08-11 12:30 ` [PATCH 4/6] mkfs: replace variables with opts table: -l options Jan Tulak
@ 2017-08-11 12:30 ` Jan Tulak
  2017-08-14 23:34   ` Darrick J. Wong
  2017-08-11 12:30 ` [PATCH 6/6] mkfs: replace variables with opts table: -r options Jan Tulak
  5 siblings, 1 reply; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Remove variables that can be replaced with a direct access to the opts
table, so we have it all in a single place, accessible from anywhere.

In future, we can remove some instances where we are passing values as
arguments to helper functions, when we have the values in the opts
struct and could pass only the struct.  But for now, limit the changes
to simple replacement without any change in the logic.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 mkfs/xfs_mkfs.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 4e85694f..51c1a794 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1685,8 +1685,6 @@ main(
 	int			dasize;
 	xfs_rfsblock_t		dblocks;
 	char			*dfile;
-	int			dirblocklog;
-	int			dirblocksize;
 	int			dsflag;
 	bool			force_overwrite;
 	struct fsxattr		fsx;
@@ -1767,7 +1765,6 @@ main(
 	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
 	logblocks = rtblocks = rtextblocks = 0;
 	Nflag = nlflag = nsflag = nvflag = false;
-	dirblocklog = dirblocksize = 0;
 	qflag = false;
 	dfile = logfile = rtfile = NULL;
 	protofile = NULL;
@@ -2082,18 +2079,15 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case N_LOG:
-					dirblocklog = parse_conf_val(OPT_N,
+					parse_conf_val(OPT_N,
 								     N_LOG,
 								     value);
-					dirblocksize = 1 << dirblocklog;
 					nlflag = 1;
 					break;
 				case N_SIZE:
-					dirblocksize = parse_conf_val(OPT_N,
+					parse_conf_val(OPT_N,
 								      N_SIZE,
 								      value);
-					dirblocklog =
-						libxfs_highbit32(dirblocksize);
 					nsflag = 1;
 					break;
 				case N_VERSION:
@@ -2458,18 +2452,19 @@ _("rmapbt not supported with realtime devices\n"));
 	}
 
 	if (nsflag || nlflag) {
-		if (dirblocksize < get_conf_val(OPT_B, B_SIZE) ||
-					dirblocksize > XFS_MAX_BLOCKSIZE) {
-			fprintf(stderr, _("illegal directory block size %d\n"),
-				dirblocksize);
+		if (get_conf_val(OPT_N, N_SIZE) <
+		    get_conf_val(OPT_B, B_SIZE) ||
+		    get_conf_val(OPT_N, N_SIZE) > XFS_MAX_BLOCKSIZE) {
+			fprintf(stderr, _("illegal directory block size %lld\n"),
+				get_conf_val(OPT_N, N_SIZE));
 			usage();
 		}
 	} else {
 		if (get_conf_val(OPT_B, B_SIZE) < (1 << XFS_MIN_REC_DIRSIZE))
-			dirblocklog = XFS_MIN_REC_DIRSIZE;
+			set_conf_val(OPT_N, N_LOG, XFS_MIN_REC_DIRSIZE);
 		else
-			dirblocklog = get_conf_val(OPT_B, B_LOG);
-		dirblocksize = 1 << dirblocklog;
+			set_conf_val(OPT_N, N_LOG, get_conf_val(OPT_B, B_LOG));
+		set_conf_val(OPT_N, N_SIZE, 1 << get_conf_val(OPT_N, N_LOG));
 	}
 
 
@@ -3053,7 +3048,8 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 				   sb_feat.crcs_enabled, sb_feat.dir_version,
 				   get_conf_val(OPT_D, D_SECTLOG),
 				   get_conf_val(OPT_B, B_LOG),
-				   get_conf_val(OPT_I, I_LOG), dirblocklog,
+				   get_conf_val(OPT_I, I_LOG),
+				   get_conf_val(OPT_N, N_LOG),
 				   sb_feat.log_version,
 				   get_conf_val(OPT_L, L_SUNIT),
 				   sb_feat.finobt,
@@ -3244,7 +3240,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			get_conf_val(OPT_I, I_MAXPCT),
 			"", get_conf_val(OPT_D, D_SUNIT),
 			get_conf_val(OPT_D, D_SWIDTH),
-			sb_feat.dir_version, (long long)dirblocksize, sb_feat.nci,
+			sb_feat.dir_version,
+			get_conf_val(OPT_N, N_SIZE), sb_feat.nci,
 				sb_feat.dirftype,
 			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
 			sb_feat.log_version, "",
@@ -3296,7 +3293,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_qflags = 0;
 	sbp->sb_unit = get_conf_val(OPT_D, D_SUNIT);
 	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
-	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
+	sbp->sb_dirblklog = get_conf_val(OPT_N, N_LOG) -
+		get_conf_val(OPT_B, B_LOG);
 	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
 		set_conf_val(OPT_L, L_SUNIT,
 			     (get_conf_val(OPT_L, L_SUNIT) == 0) ?
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] mkfs: replace variables with opts table: -r options
  2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
                   ` (4 preceding siblings ...)
  2017-08-11 12:30 ` [PATCH 5/6] mkfs: replace variables with opts table: -n options Jan Tulak
@ 2017-08-11 12:30 ` Jan Tulak
  2017-08-14 23:35   ` Darrick J. Wong
  5 siblings, 1 reply; 14+ messages in thread
From: Jan Tulak @ 2017-08-11 12:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Remove variables that can be replaced with a direct access to the opts
table, so we have it all in a single place, accessible from anywhere.

In future, we can remove some instances where we are passing values as
arguments to helper functions, when we have the values in the opts
struct and could pass only the struct.  But for now, limit the changes
to simple replacement without any change in the logic.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 mkfs/xfs_mkfs.c | 71 ++++++++++++++++++++++++++++++---------------------------
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 51c1a794..aeb62589 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1711,7 +1711,6 @@ main(
 	xfs_mount_t		mbuf;
 	xfs_extlen_t		nbmblocks;
 	int			nlflag;
-	int			norsflag;
 	xfs_alloc_rec_t		*nrec;
 	int			nsflag;
 	int			nvflag;
@@ -1722,10 +1721,8 @@ main(
 	char			*protostring;
 	int			qflag;
 	xfs_rfsblock_t		rtblocks;
-	uint64_t		rtbytes;
 	xfs_extlen_t		rtextblocks;
 	xfs_rtblock_t		rtextents;
-	uint64_t		rtextbytes;
 	char			*rtfile;
 	xfs_sb_t		*sbp;
 	uint64_t		sector_mask;
@@ -1768,9 +1765,8 @@ main(
 	qflag = false;
 	dfile = logfile = rtfile = NULL;
 	protofile = NULL;
-	rtbytes = rtextbytes = 0;
 	lalign = 0;
-	dsflag = norsflag = false;
+	dsflag = false;
 	force_overwrite = false;
 	worst_freelist = 0;
 	memset(&fsx, 0, sizeof(fsx));
@@ -2139,9 +2135,8 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case R_EXTSIZE:
-					rtextbytes = parse_conf_val(OPT_R,
-								    R_EXTSIZE,
-								    value);
+					parse_conf_val(OPT_R, R_EXTSIZE,
+						       value);
 					break;
 				case R_FILE:
 					xi.risfile = parse_conf_val(OPT_R,
@@ -2156,13 +2151,11 @@ main(
 					set_conf_val(OPT_R, R_DEV, 1);
 					break;
 				case R_SIZE:
-					rtbytes = parse_conf_val(OPT_R, R_SIZE,
-								 value);
+					parse_conf_val(OPT_R, R_SIZE, value);
 					break;
 				case R_NOALIGN:
-					norsflag = parse_conf_val(OPT_R,
-								  R_NOALIGN,
-								  value);
+					parse_conf_val(OPT_R, R_NOALIGN,
+						       value);
 					break;
 				default:
 					unknown('r', value);
@@ -2271,7 +2264,10 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 				  !xi.logname, Nflag ? NULL : &xi.lcreat,
 				  force_overwrite, "l");
 	if (xi.rtname)
-		check_device_type(xi.rtname, &xi.risfile, !rtbytes, !xi.rtname,
+		check_device_type(xi.rtname,
+				  &xi.risfile,
+				  !get_conf_val(OPT_R, R_SIZE),
+				  !xi.rtname,
 				  Nflag ? NULL : &xi.rcreat,
 				  force_overwrite, "r");
 	if (xi.disfile || xi.lisfile || xi.risfile)
@@ -2520,33 +2516,36 @@ _("rmapbt not supported with realtime devices\n"));
 				(long long)(logblocks <<
 					   get_conf_val(OPT_B, B_LOG)));
 	}
-	if (rtbytes) {
-		if (rtbytes % XFS_MIN_BLOCKSIZE) {
+	if (get_conf_val(OPT_R, R_SIZE)) {
+		if (get_conf_val(OPT_R, R_SIZE) % XFS_MIN_BLOCKSIZE) {
 			fprintf(stderr,
 			_("illegal rt length %lld, not a multiple of %d\n"),
-				(long long)rtbytes, XFS_MIN_BLOCKSIZE);
+				get_conf_val(OPT_R, R_SIZE), XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		rtblocks = (xfs_rfsblock_t)(rtbytes >>
+		rtblocks = (xfs_rfsblock_t)(get_conf_val(OPT_R, R_SIZE) >>
 					    get_conf_val(OPT_B, B_LOG));
-		if (rtbytes % get_conf_val(OPT_B, B_SIZE))
+		if (get_conf_val(OPT_R, R_SIZE) % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr,
 	_("warning: rt length %lld not a multiple of %lld, truncated to %lld\n"),
-				(long long)rtbytes, get_conf_val(OPT_B, B_SIZE),
+				get_conf_val(OPT_R, R_SIZE),
+				get_conf_val(OPT_B, B_SIZE),
 				(long long)(rtblocks <<
 					   get_conf_val(OPT_B, B_LOG)));
 	}
 	/*
 	 * If specified, check rt extent size against its constraints.
 	 */
-	if (rtextbytes) {
-		if (rtextbytes % get_conf_val(OPT_B, B_SIZE)) {
+	if (get_conf_val(OPT_R, R_EXTSIZE)) {
+		if (get_conf_val(OPT_R, R_EXTSIZE) %
+		    get_conf_val(OPT_B, B_SIZE)) {
 			fprintf(stderr,
 		_("illegal rt extent size %lld, not a multiple of %lld\n"),
-				(long long)rtextbytes, get_conf_val(OPT_B, B_SIZE));
+				get_conf_val(OPT_R, R_EXTSIZE),
+				get_conf_val(OPT_B, B_SIZE));
 			usage();
 		}
-		rtextblocks = (xfs_extlen_t)(rtextbytes >>
+		rtextblocks = (xfs_extlen_t)(get_conf_val(OPT_R, R_EXTSIZE) >>
 					     get_conf_val(OPT_B, B_LOG));
 	} else {
 		/*
@@ -2555,20 +2554,23 @@ _("rmapbt not supported with realtime devices\n"));
 		 * to the stripe width.
 		 */
 		uint64_t	rswidth;
-		uint64_t	rtextbytes;
 
-		if (!norsflag && !xi.risfile && !(!rtbytes && xi.disfile))
+		if (!get_conf_val(OPT_R, R_NOALIGN) && !xi.risfile &&
+		    !(!get_conf_val(OPT_R, R_SIZE) && xi.disfile))
 			rswidth = ft.rtswidth;
 		else
 			rswidth = 0;
 
 		/* check that rswidth is a multiple of fs B_SIZE */
-		if (!norsflag && rswidth &&
+		if (!get_conf_val(OPT_R, R_NOALIGN) && rswidth &&
 		    !(BBTOB(rswidth) % get_conf_val(OPT_B, B_SIZE))) {
 			rswidth = DTOBT(rswidth);
-			rtextbytes = rswidth << get_conf_val(OPT_B, B_LOG);
-			if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
-			    (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
+			set_conf_val(OPT_R, R_EXTSIZE,
+				     rswidth << get_conf_val(OPT_B, B_LOG));
+			if (XFS_MIN_RTEXTSIZE <=
+			    get_conf_val(OPT_R, R_EXTSIZE) &&
+			    (get_conf_val(OPT_R, R_EXTSIZE) <=
+			     XFS_MAX_RTEXTSIZE)) {
 				rtextblocks = rswidth;
 			}
 		}
@@ -2741,7 +2743,7 @@ reported by the device (%u).\n"),
 reported by the device (%u).\n"),
 			get_conf_val(OPT_L, L_SECTSIZE), xi.lbsize);
 	}
-	if (rtbytes && xi.rtsize > 0 &&
+	if (get_conf_val(OPT_R, R_SIZE) && xi.rtsize > 0 &&
 	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
 		fprintf(stderr, _(
 "Warning: the realtime subvolume sector size %lld is less than the sector size\n\
@@ -2749,16 +2751,17 @@ reported by the device (%u).\n"),
 			get_conf_val(OPT_D, D_SECTSIZE), xi.rtbsize);
 	}
 
-	if (rtbytes && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
+	if (get_conf_val(OPT_R, R_SIZE) && xi.rtsize > 0 &&
+	    rtblocks > DTOBT(xi.rtsize)) {
 		fprintf(stderr,
 			_("size %s specified for rt subvolume is too large, "
 			"maximum is %lld blocks\n"),
 			get_conf_raw_safe(OPT_R, R_SIZE),
 			(long long)DTOBT(xi.rtsize));
 		usage();
-	} else if (!rtbytes && xi.rtsize > 0)
+	} else if (!get_conf_val(OPT_R, R_SIZE) && xi.rtsize > 0)
 		rtblocks = DTOBT(xi.rtsize);
-	else if (rtbytes && !xi.rtdev) {
+	else if (get_conf_val(OPT_R, R_SIZE) && !xi.rtdev) {
 		fprintf(stderr,
 			_("size specified for non-existent rt subvolume\n"));
 		usage();
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] mkfs: save user input values into opts
  2017-08-11 12:30 ` [PATCH 1/6] mkfs: save user input values into opts Jan Tulak
@ 2017-08-14 23:21   ` Darrick J. Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2017-08-14 23:21 UTC (permalink / raw)
  To: Jan Tulak; +Cc: linux-xfs

On Fri, Aug 11, 2017 at 02:30:53PM +0200, Jan Tulak wrote:
> Save the parsed values from users into the opts table. This will ensure
> that the user values gets there and are validated, but we are not yet
> using them for anything - the usage makes a lot of changes through the
> code, so it is better if that is separated into smaller chunks.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> ---
> Edit:
>  * sectorizes fix
>  * remove collateral assignments that are now covered within parse
>    function
>  * remove duplicit assignments into opts within one option
>  * fix issue with proj(16|32)bit
>  * updated description
> ---
>  mkfs/xfs_mkfs.c | 239 +++++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 142 insertions(+), 97 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 61ef09e8..12ffa715 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1826,14 +1826,15 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case B_LOG:
> -					blocklog = getnum(value, &opts[OPT_B],
> -								B_LOG);
> +					blocklog = parse_conf_val(OPT_B, B_LOG,
> +								  value);

Eww, look at those arguments jammed up against the RHS of the screen.
Now I really wish these were separate functions (or anything that
reduces the amount of indentation, really...)

But rebashing your whole mkfs series to fix minor whitespace problems is
probably a PITA, so I'll defer to Eric on this one.  Personally I'd just
throw an extra patch on the end to do it. :)

Otherwise, this looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  					blocksize = 1 << blocklog;
>  					blflag = 1;
>  					break;
>  				case B_SIZE:
> -					blocksize = getnum(value, &opts[OPT_B],
> -							   B_SIZE);
> +					blocksize = parse_conf_val(OPT_B,
> +								   B_SIZE,
> +								   value);
>  					blocklog = libxfs_highbit32(blocksize);
>  					bsflag = 1;
>  					break;
> @@ -1851,80 +1852,92 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case D_AGCOUNT:
> -					agcount = getnum(value, &opts[OPT_D],
> -							 D_AGCOUNT);
> +					agcount = parse_conf_val(OPT_D,
> +								 D_AGCOUNT,
> +								 value);
>  					daflag = 1;
>  					break;
>  				case D_AGSIZE:
> -					agsize = getnum(value, &opts[OPT_D],
> -								D_AGSIZE);
> +					agsize = parse_conf_val(OPT_D,
> +								D_AGSIZE,
> +								value);
>  					dasize = 1;
>  					break;
>  				case D_FILE:
> -					xi.disfile = getnum(value,
> -						&opts[OPT_D], D_FILE);
> +					xi.disfile = parse_conf_val(OPT_D,
> +								    D_FILE,
> +								    value);
>  					break;
>  				case D_NAME:
>  					xi.dname = getstr(value, &opts[OPT_D],
>  								D_NAME);
> +					set_conf_val(OPT_D, D_NAME,  1);
>  					break;
>  				case D_SIZE:
> -					dbytes = getnum(value, &opts[OPT_D],
> -								D_SIZE);
> +					dbytes = parse_conf_val(OPT_D, D_SIZE,
> +								value);
>  					break;
>  				case D_SUNIT:
> -					dsunit = getnum(value, &opts[OPT_D],
> -								D_SUNIT);
> +					dsunit = parse_conf_val(OPT_D, D_SUNIT,
> +								value);
>  					dsflag = 1;
>  					break;
>  				case D_SWIDTH:
> -					dswidth = getnum(value, &opts[OPT_D],
> -							 D_SWIDTH);
> +					dswidth = parse_conf_val(OPT_D,
> +								 D_SWIDTH,
> +								 value);
>  					dsflag = 1;
>  					break;
>  				case D_SU:
> -					dsu = getnum(value, &opts[OPT_D],
> -								D_SU);
> +					dsu = parse_conf_val(OPT_D, D_SU,
> +							     value);
>  					dsflag = 1;
>  					break;
>  				case D_SW:
> -					dsw = getnum(value, &opts[OPT_D],
> -								D_SW);
> +					dsw = parse_conf_val(OPT_D, D_SW,
> +							     value);
>  					dsflag = 1;
>  					break;
>  				case D_NOALIGN:
> -					nodsflag = getnum(value, &opts[OPT_D],
> -								D_NOALIGN);
> +					nodsflag = parse_conf_val(OPT_D,
> +								  D_NOALIGN,
> +								  value);
>  					break;
>  				case D_SECTLOG:
> -					sectorlog = getnum(value, &opts[OPT_D],
> -							   D_SECTLOG);
> +					sectorlog = parse_conf_val(OPT_D,
> +								   D_SECTLOG,
> +								   value);
>  					sectorsize = 1 << sectorlog;
>  					slflag = 1;
>  					break;
>  				case D_SECTSIZE:
> -					sectorsize = getnum(value,
> -						&opts[OPT_D], D_SECTSIZE);
> +					sectorsize = parse_conf_val(OPT_D,
> +								    D_SECTSIZE,
> +								    value);
>  					sectorlog =
>  						libxfs_highbit32(sectorsize);
>  					ssflag = 1;
>  					break;
>  				case D_RTINHERIT:
> -					c = getnum(value, &opts[OPT_D],
> -								D_RTINHERIT);
> +					c = parse_conf_val(OPT_D, D_RTINHERIT,
> +							   value);
>  					if (c)
>  						fsx.fsx_xflags |=
>  							XFS_DIFLAG_RTINHERIT;
>  					break;
>  				case D_PROJINHERIT:
> -					fsx.fsx_projid = getnum(value,
> -						&opts[OPT_D], D_PROJINHERIT);
> +					fsx.fsx_projid =
> +						parse_conf_val(OPT_D,
> +							       D_PROJINHERIT,
> +							       value);
>  					fsx.fsx_xflags |=
>  						XFS_DIFLAG_PROJINHERIT;
>  					break;
>  				case D_EXTSZINHERIT:
> -					fsx.fsx_extsize = getnum(value,
> -						&opts[OPT_D], D_EXTSZINHERIT);
> +					fsx.fsx_extsize =
> +						parse_conf_val(OPT_D,
> +							       D_EXTSZINHERIT,
> +							       value);
>  					fsx.fsx_xflags |=
>  						XFS_DIFLAG_EXTSZINHERIT;
>  					break;
> @@ -1942,45 +1955,49 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case I_ALIGN:
> -					sb_feat.inode_align = getnum(value,
> -						&opts[OPT_I], I_ALIGN);
> +					sb_feat.inode_align =
> +						parse_conf_val(OPT_I, I_ALIGN,
> +							       value);
>  					break;
>  				case I_LOG:
> -					inodelog = getnum(value, &opts[OPT_I],
> -								I_LOG);
> +					inodelog = parse_conf_val(OPT_I, I_LOG,
> +								  value);
>  					isize = 1 << inodelog;
>  					ilflag = 1;
>  					break;
>  				case I_MAXPCT:
> -					imaxpct = getnum(value, &opts[OPT_I],
> -							 I_MAXPCT);
> +					imaxpct = parse_conf_val(OPT_I,
> +								 I_MAXPCT,
> +								 value);
>  					imflag = 1;
>  					break;
>  				case I_PERBLOCK:
> -					inopblock = getnum(value, &opts[OPT_I],
> -							   I_PERBLOCK);
> +					inopblock = parse_conf_val(OPT_I,
> +								   I_PERBLOCK,
> +								   value);
>  					ipflag = 1;
>  					break;
>  				case I_SIZE:
> -					isize = getnum(value, &opts[OPT_I],
> -								I_SIZE);
> +					isize = parse_conf_val(OPT_I, I_SIZE,
> +							       value);
>  					inodelog = libxfs_highbit32(isize);
>  					isflag = 1;
>  					break;
>  				case I_ATTR:
>  					sb_feat.attr_version =
> -						getnum(value, &opts[OPT_I],
> -								I_ATTR);
> +						parse_conf_val(OPT_I, I_ATTR,
> +							       value);
>  					break;
>  				case I_PROJID32BIT:
>  					sb_feat.projid16bit =
> -						!getnum(value, &opts[OPT_I],
> -							I_PROJID32BIT);
> +						!parse_conf_val(OPT_I,
> +							I_PROJID32BIT, value);
>  					break;
>  				case I_SPINODES:
> -					sb_feat.spinodes = getnum(value,
> -								&opts[OPT_I],
> -								I_SPINODES);
> +					sb_feat.spinodes =
> +						parse_conf_val(OPT_I,
> +							       I_SPINODES,
> +							       value);
>  					break;
>  				default:
>  					unknown('i', value);
> @@ -1996,27 +2013,31 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case L_AGNUM:
> -					logagno = getnum(value, &opts[OPT_L],
> -								L_AGNUM);
> +					logagno = parse_conf_val(OPT_L,
> +								 L_AGNUM,
> +								 value);
>  					laflag = 1;
>  					break;
>  				case L_FILE:
> -					xi.lisfile = getnum(value,
> -						&opts[OPT_L], L_FILE);
> +					xi.lisfile = parse_conf_val(OPT_L,
> +								    L_FILE,
> +								    value);
>  					break;
>  				case L_INTERNAL:
> -					loginternal = getnum(value,
> -						&opts[OPT_L], L_INTERNAL);
> +					loginternal =
> +						parse_conf_val(OPT_L,
> +							       L_INTERNAL,
> +							       value);
>  					liflag = 1;
>  					break;
>  				case L_SU:
> -					lsu = getnum(value, &opts[OPT_L],
> -								L_SU);
> +					lsu = parse_conf_val(OPT_L, L_SU,
> +							     value);
>  					lsuflag = 1;
>  					break;
>  				case L_SUNIT:
> -					lsunit = getnum(value, &opts[OPT_L],
> -								L_SUNIT);
> +					lsunit = parse_conf_val(OPT_L, L_SUNIT,
> +								value);
>  					lsunitflag = 1;
>  					break;
>  				case L_NAME:
> @@ -2026,34 +2047,42 @@ main(
>  					xi.logname = logfile;
>  					ldflag = 1;
>  					loginternal = 0;
> +					set_conf_val(OPT_L, L_NAME, 1);
> +					set_conf_val(OPT_L, L_DEV, 1);
>  					break;
>  				case L_VERSION:
>  					sb_feat.log_version =
> -						getnum(value, &opts[OPT_L],
> -								L_VERSION);
> +						parse_conf_val(OPT_L,
> +							       L_VERSION,
> +							       value);
>  					lvflag = 1;
>  					break;
>  				case L_SIZE:
> -					logbytes = getnum(value,
> -						&opts[OPT_L], L_SIZE);
> +					logbytes = parse_conf_val(OPT_L,
> +								  L_SIZE,
> +								  value);
>  					break;
>  				case L_SECTLOG:
> -					lsectorlog = getnum(value,
> -						&opts[OPT_L], L_SECTLOG);
> +					lsectorlog = parse_conf_val(OPT_L,
> +								    L_SECTLOG,
> +								    value);
>  					lsectorsize = 1 << lsectorlog;
>  					lslflag = 1;
>  					break;
>  				case L_SECTSIZE:
> -					lsectorsize = getnum(value,
> -						&opts[OPT_L], L_SECTSIZE);
> +					lsectorsize =
> +						parse_conf_val(OPT_L,
> +							       L_SECTSIZE,
> +							       value);
>  					lsectorlog =
>  						libxfs_highbit32(lsectorsize);
>  					lssflag = 1;
>  					break;
>  				case L_LAZYSBCNTR:
>  					sb_feat.lazy_sb_counters =
> -						getnum(value, &opts[OPT_L],
> -							L_LAZYSBCNTR);
> +						parse_conf_val(OPT_L,
> +							       L_LAZYSBCNTR,
> +							       value);
>  					break;
>  				default:
>  					unknown('l', value);
> @@ -2075,29 +2104,33 @@ main(
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case M_CRC:
>  					sb_feat.crcs_enabled =
> -						getnum(value, &opts[OPT_M],
> -								M_CRC);
> +						parse_conf_val(OPT_M, M_CRC,
> +							       value);
>  					if (sb_feat.crcs_enabled)
>  						sb_feat.dirftype = true;
>  					break;
>  				case M_FINOBT:
> -					sb_feat.finobt = getnum(
> -						value, &opts[OPT_M], M_FINOBT);
> +					sb_feat.finobt =
> +						parse_conf_val(OPT_M, M_FINOBT,
> +							       value);
>  					break;
>  				case M_UUID:
>  					if (!value || *value == '\0')
>  						reqval('m', subopts, M_UUID);
>  					if (platform_uuid_parse(value, &uuid))
>  						illegal(optarg, "m uuid");
> +					set_conf_val(OPT_M, M_UUID, 1);
>  					break;
>  				case M_RMAPBT:
> -					sb_feat.rmapbt = getnum(
> -						value, &opts[OPT_M], M_RMAPBT);
> +					sb_feat.rmapbt =
> +						parse_conf_val(OPT_M, M_RMAPBT,
> +							       value);
>  					break;
>  				case M_REFLINK:
>  					sb_feat.reflink =
> -						getnum(value, &opts[OPT_M],
> -							M_REFLINK);
> +						parse_conf_val(OPT_M,
> +							       M_REFLINK,
> +							       value);
>  					break;
>  				default:
>  					unknown('m', value);
> @@ -2113,14 +2146,16 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case N_LOG:
> -					dirblocklog = getnum(value,
> -						&opts[OPT_N], N_LOG);
> +					dirblocklog = parse_conf_val(OPT_N,
> +								     N_LOG,
> +								     value);
>  					dirblocksize = 1 << dirblocklog;
>  					nlflag = 1;
>  					break;
>  				case N_SIZE:
> -					dirblocksize = getnum(value,
> -						&opts[OPT_N], N_SIZE);
> +					dirblocksize = parse_conf_val(OPT_N,
> +								      N_SIZE,
> +								      value);
>  					dirblocklog =
>  						libxfs_highbit32(dirblocksize);
>  					nsflag = 1;
> @@ -2134,14 +2169,17 @@ main(
>  					} else {
>  						sb_feat.dir_version =
>  							getnum(value,
> -							       &opts[OPT_N],
> -							       N_VERSION);
> +								&opts[OPT_N],
> +								N_VERSION);
>  					}
>  					nvflag = 1;
> +					set_conf_val(OPT_N, N_VERSION,
> +						     sb_feat.dir_version);
>  					break;
>  				case N_FTYPE:
> -					sb_feat.dirftype = getnum(value,
> -						&opts[OPT_N], N_FTYPE);
> +					sb_feat.dirftype =
> +						parse_conf_val(OPT_N, N_FTYPE,
> +							       value);
>  					break;
>  				default:
>  					unknown('n', value);
> @@ -2171,25 +2209,30 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case R_EXTSIZE:
> -					rtextbytes = getnum(value,
> -						&opts[OPT_R], R_EXTSIZE);
> +					rtextbytes = parse_conf_val(OPT_R,
> +								    R_EXTSIZE,
> +								    value);
>  					break;
>  				case R_FILE:
> -					xi.risfile = getnum(value,
> -						&opts[OPT_R], R_FILE);
> +					xi.risfile = parse_conf_val(OPT_R,
> +								    R_FILE,
> +								    value);
>  					break;
>  				case R_NAME:
>  				case R_DEV:
>  					xi.rtname = getstr(value, &opts[OPT_R],
>  							   R_NAME);
> +					set_conf_val(OPT_R, R_NAME, 1);
> +					set_conf_val(OPT_R, R_DEV, 1);
>  					break;
>  				case R_SIZE:
> -					rtbytes = getnum(value, &opts[OPT_R],
> -								R_SIZE);
> +					rtbytes = parse_conf_val(OPT_R, R_SIZE,
> +								 value);
>  					break;
>  				case R_NOALIGN:
> -					norsflag = getnum(value, &opts[OPT_R],
> -								R_NOALIGN);
> +					norsflag = parse_conf_val(OPT_R,
> +								  R_NOALIGN,
> +								  value);
>  					break;
>  				default:
>  					unknown('r', value);
> @@ -2210,8 +2253,9 @@ main(
>  						conflict('s', subopts,
>  							 S_SECTSIZE,
>  							 S_SECTLOG);
> -					sectorlog = getnum(value, &opts[OPT_S],
> -							   S_SECTLOG);
> +					sectorlog = parse_conf_val(OPT_S,
> +								   S_SECTLOG,
> +								   value);
>  					lsectorlog = sectorlog;
>  					sectorsize = 1 << sectorlog;
>  					lsectorsize = sectorsize;
> @@ -2223,8 +2267,9 @@ main(
>  						conflict('s', subopts,
>  							 S_SECTLOG,
>  							 S_SECTSIZE);
> -					sectorsize = getnum(value,
> -						&opts[OPT_S], S_SECTSIZE);
> +					sectorsize = parse_conf_val(OPT_S,
> +								    S_SECTSIZE,
> +								    value);
>  					lsectorsize = sectorsize;
>  					sectorlog =
>  						libxfs_highbit32(sectorsize);
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options
  2017-08-11 12:30 ` [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
@ 2017-08-14 23:30   ` Darrick J. Wong
  2017-08-15 15:00   ` [PATCH 2/6 v2] " Jan Tulak
  1 sibling, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2017-08-14 23:30 UTC (permalink / raw)
  To: Jan Tulak; +Cc: linux-xfs

On Fri, Aug 11, 2017 at 02:30:54PM +0200, Jan Tulak wrote:
> Remove variables that can be replaced with a direct access to the opts
> table, so we have it all in a single place, acessible from anywhere.
> 
> In future, we can remove some instances where we are passing values as
> arguments to helper functions, when we have the values in the opts
> struct and could pass only the struct.  But for now, limit the changes
> to simple replacement without any change in the logic.
> 
> This is first of multiple similar patches that do the same, but for
> other options.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> 
> ---
> CHANGES:
> * remove collaterals which are set during parsing
> ---
>  mkfs/xfs_mkfs.c | 792 +++++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 463 insertions(+), 329 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 12ffa715..7f7f4554 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -32,13 +32,6 @@ static void respec(char opt, char *tab[], int idx);
>  static void unknown(char opt, char *s);
>  static int  ispow2(unsigned int i);
>  
> -/*
> - * The configured block and sector sizes are defined as global variables so
> - * that they don't need to be passed to functions that require them.
> - */
> -unsigned int		blocksize;
> -unsigned int		sectorsize;
> -
>  #define MAX_OPTS	16
>  #define MAX_SUBOPTS	16
>  #define SUBOPT_NEEDS_VAL	(-1LL)
> @@ -740,7 +733,8 @@ struct opt_params {
>  /*
>   * Use this macro before we have superblock and mount structure
>   */
> -#define	DTOBT(d)	((xfs_rfsblock_t)((d) >> (blocklog - BBSHIFT)))
> +#define	DTOBT(d) \
> +	((xfs_rfsblock_t)((d) >> (get_conf_val(OPT_B, B_LOG) - BBSHIFT)))
>  
>  /*
>   * Use this for block reservations needed for mkfs's conditions
> @@ -1092,7 +1086,8 @@ getnum(
>  	 * number.
>  	 */
>  	if (sp->convert)
> -		c = cvtnum(blocksize, sectorsize, str);
> +		c = cvtnum(get_conf_val(OPT_B, B_SIZE),
> +			   get_conf_val(OPT_D, D_SECTSIZE), str);
>  	else {
>  		char		*str_end;
>  
> @@ -1179,16 +1174,16 @@ calc_stripe_factors(
>  		*lsunit = (int)BTOBBT(lsu);
>  
>  	/* verify if lsu/lsunit is a multiple block size */
> -	if (lsu % blocksize != 0) {
> +	if (lsu % get_conf_val(OPT_B, B_SIZE) != 0) {
>  		fprintf(stderr,
> -_("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
> -		lsu, blocksize);
> +_("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
> +		lsu, get_conf_val(OPT_B, B_SIZE));
>  		exit(1);
>  	}
> -	if ((BBTOB(*lsunit) % blocksize != 0)) {
> +	if ((BBTOB(*lsunit) % get_conf_val(OPT_B, B_SIZE) != 0)) {
>  		fprintf(stderr,
> -_("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
> -		BBTOB(*lsunit), blocksize);
> +_("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
> +		BBTOB(*lsunit), get_conf_val(OPT_B, B_SIZE));
>  		exit(1);
>  	}
>  }
> @@ -1344,7 +1339,7 @@ validate_log_size(uint64_t logblocks, int blocklog, int min_logblocks)
>  			(long long)logblocks, XFS_MAX_LOG_BLOCKS);
>  		usage();
>  	}
> -	if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
> +	if ((logblocks << get_conf_val(OPT_B, B_LOG)) > XFS_MAX_LOG_BYTES) {
>  		fprintf(stderr,
>  	_("log size %lld bytes too large, maximum size is %lld bytes\n"),
>  			(long long)(logblocks << blocklog), XFS_MAX_LOG_BYTES);
> @@ -1438,9 +1433,9 @@ validate_ag_geometry(
>  	}
>  
>  	/*
> -	 * If agcount is too large, make it smaller.
> +	 * If D_AGCOUNT is too large, make it smaller.
>  	 */
> -	if (agcount > XFS_MAX_AGNUMBER + 1) {
> +	if (get_conf_val(OPT_D, D_AGCOUNT) > XFS_MAX_AGNUMBER + 1) {
>  		fprintf(stderr,
>  	_("%lld allocation groups is too many, maximum is %lld\n"),
>  			(long long)agcount, (long long)XFS_MAX_AGNUMBER + 1);
> @@ -1674,15 +1669,12 @@ main(
>  	int			argc,
>  	char			**argv)
>  {
> -	uint64_t		agcount;
>  	xfs_agf_t		*agf;
>  	xfs_agi_t		*agi;
>  	xfs_agnumber_t		agno;
> -	uint64_t		agsize;
>  	xfs_alloc_rec_t		*arec;
>  	struct xfs_btree_block	*block;
>  	int			blflag;
> -	int			blocklog;
>  	int			bsflag;
>  	int			bsize;
>  	xfs_buf_t		*buf;
> @@ -1693,11 +1685,6 @@ main(
>  	char			*dfile;
>  	int			dirblocklog;
>  	int			dirblocksize;
> -	uint64_t		dbytes;
> -	int			dsu;
> -	int			dsw;
> -	int			dsunit;
> -	int			dswidth;
>  	int			dsflag;
>  	bool			force_overwrite;
>  	struct fsxattr		fsx;
> @@ -1735,7 +1722,6 @@ main(
>  	xfs_mount_t		mbuf;
>  	xfs_extlen_t		nbmblocks;
>  	int			nlflag;
> -	int			nodsflag;
>  	int			norsflag;
>  	xfs_alloc_rec_t		*nrec;
>  	int			nsflag;
> @@ -1753,7 +1739,6 @@ main(
>  	uint64_t		rtextbytes;
>  	char			*rtfile;
>  	xfs_sb_t		*sbp;
> -	int			sectorlog;
>  	uint64_t		sector_mask;
>  	int			slflag;
>  	int			ssflag;
> @@ -1786,12 +1771,11 @@ main(
>  	textdomain(PACKAGE);
>  
>  	blflag = bsflag = slflag = ssflag = lslflag = lssflag = 0;
> -	blocklog = blocksize = 0;
> -	sectorlog = lsectorlog = 0;
> -	sectorsize = lsectorsize = 0;
> -	agsize = daflag = dasize = dblocks = 0;
> -	ilflag = imflag = ipflag = isflag = 0;
> -	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = 0;
> +	lsectorlog = 0;
> +	lsectorsize = 0;
> +	dasize = dblocks = 0;
> +	daflag = ilflag = imflag = ipflag = isflag = false;
> +	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
>  	loginternal = 1;
>  	logagno = logblocks = rtblocks = rtextblocks = 0;
>  	Nflag = nlflag = nsflag = nvflag = 0;
> @@ -1800,10 +1784,10 @@ main(
>  	imaxpct = inodelog = inopblock = isize = 0;
>  	dfile = logfile = rtfile = NULL;
>  	protofile = NULL;
> -	rtbytes = rtextbytes = logbytes = dbytes = 0;
> -	dsu = dsw = dsunit = dswidth = lalign = lsu = lsunit = 0;
> -	dsflag = nodsflag = norsflag = 0;
> -	force_overwrite = 0;
> +	rtbytes = rtextbytes = logbytes = 0;
> +	lalign = lsu = lsunit = 0;
> +	dsflag = norsflag = false;
> +	force_overwrite = false;
>  	worst_freelist = 0;
>  	memset(&fsx, 0, sizeof(fsx));
>  
> @@ -1826,16 +1810,13 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case B_LOG:
> -					blocklog = parse_conf_val(OPT_B, B_LOG,
> -								  value);
> -					blocksize = 1 << blocklog;
> +					parse_conf_val(OPT_B, B_LOG,
> +							     value);
>  					blflag = 1;
>  					break;
>  				case B_SIZE:
> -					blocksize = parse_conf_val(OPT_B,
> -								   B_SIZE,
> -								   value);
> -					blocklog = libxfs_highbit32(blocksize);
> +					parse_conf_val(OPT_B, B_SIZE,
> +							     value);
>  					bsflag = 1;
>  					break;
>  				default:
> @@ -1852,15 +1833,12 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case D_AGCOUNT:
> -					agcount = parse_conf_val(OPT_D,
> -								 D_AGCOUNT,
> -								 value);
> +					parse_conf_val(OPT_D, D_AGCOUNT,
> +						       value);
>  					daflag = 1;
>  					break;
>  				case D_AGSIZE:
> -					agsize = parse_conf_val(OPT_D,
> -								D_AGSIZE,
> -								value);
> +					parse_conf_val(OPT_D, D_AGSIZE, value);
>  					dasize = 1;
>  					break;
>  				case D_FILE:
> @@ -1874,48 +1852,36 @@ main(
>  					set_conf_val(OPT_D, D_NAME,  1);
>  					break;
>  				case D_SIZE:
> -					dbytes = parse_conf_val(OPT_D, D_SIZE,
> -								value);
> +					parse_conf_val(OPT_D, D_SIZE, value);
>  					break;
>  				case D_SUNIT:
> -					dsunit = parse_conf_val(OPT_D, D_SUNIT,
> -								value);
> +					parse_conf_val(OPT_D, D_SUNIT, value);
>  					dsflag = 1;
>  					break;
>  				case D_SWIDTH:
> -					dswidth = parse_conf_val(OPT_D,
> -								 D_SWIDTH,
> -								 value);
> +					parse_conf_val(OPT_D, D_SWIDTH, value);
>  					dsflag = 1;
>  					break;
>  				case D_SU:
> -					dsu = parse_conf_val(OPT_D, D_SU,
> -							     value);
> +					parse_conf_val(OPT_D, D_SU, value);
>  					dsflag = 1;
>  					break;
>  				case D_SW:
> -					dsw = parse_conf_val(OPT_D, D_SW,
> -							     value);
> +					parse_conf_val(OPT_D, D_SW, value);
>  					dsflag = 1;
>  					break;
>  				case D_NOALIGN:
> -					nodsflag = parse_conf_val(OPT_D,
> -								  D_NOALIGN,
> -								  value);
> +					parse_conf_val(OPT_D, D_NOALIGN,
> +						       value);
>  					break;
>  				case D_SECTLOG:
> -					sectorlog = parse_conf_val(OPT_D,
> -								   D_SECTLOG,
> -								   value);
> -					sectorsize = 1 << sectorlog;
> +					parse_conf_val(OPT_D, D_SECTLOG,
> +							     value);
>  					slflag = 1;
>  					break;
>  				case D_SECTSIZE:
> -					sectorsize = parse_conf_val(OPT_D,
> -								    D_SECTSIZE,
> -								    value);
> -					sectorlog =
> -						libxfs_highbit32(sectorsize);
> +					parse_conf_val(OPT_D, D_SECTSIZE,
> +							     value);
>  					ssflag = 1;
>  					break;
>  				case D_RTINHERIT:
> @@ -2245,6 +2211,7 @@ main(
>  				char	**subopts =
>  						(char **)opts[OPT_S].subopts;
>  				char	*value;
> +				uint64_t tmp;
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case S_LOG:
> @@ -2253,12 +2220,12 @@ main(
>  						conflict('s', subopts,
>  							 S_SECTSIZE,
>  							 S_SECTLOG);
> -					sectorlog = parse_conf_val(OPT_S,
> +					tmp = parse_conf_val(OPT_S,
>  								   S_SECTLOG,
>  								   value);
> -					lsectorlog = sectorlog;
> -					sectorsize = 1 << sectorlog;
> -					lsectorsize = sectorsize;
> +
> +					lsectorlog = tmp;
> +					lsectorsize = tmp;
>  					lslflag = slflag = 1;
>  					break;
>  				case S_SIZE:
> @@ -2267,13 +2234,12 @@ main(
>  						conflict('s', subopts,
>  							 S_SECTLOG,
>  							 S_SECTSIZE);
> -					sectorsize = parse_conf_val(OPT_S,
> +					tmp = parse_conf_val(OPT_S,
>  								    S_SECTSIZE,
>  								    value);
> -					lsectorsize = sectorsize;
> -					sectorlog =
> -						libxfs_highbit32(sectorsize);
> -					lsectorlog = sectorlog;
> +
> +					lsectorlog = libxfs_highbit32(tmp);
> +					lsectorsize = tmp;
>  					lssflag = ssflag = 1;
>  					break;
>  				default:
> @@ -2298,19 +2264,22 @@ main(
>  		dfile = xi.dname;
>  
>  	/*
> -	 * Blocksize and sectorsize first, other things depend on them
> +	 * Blocksize and D_SECTSIZE 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) {
> -		blocklog = XFS_DFL_BLOCKSIZE_LOG;
> -		blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
> +		set_conf_val(OPT_B, B_LOG, XFS_DFL_BLOCKSIZE_LOG);
> +		set_conf_val(OPT_B, B_SIZE, 1 << XFS_DFL_BLOCKSIZE_LOG);
>  	}
> -	if (blocksize < XFS_MIN_BLOCKSIZE || blocksize > XFS_MAX_BLOCKSIZE) {
> -		fprintf(stderr, _("illegal block size %d\n"), blocksize);
> +	if (get_conf_val(OPT_B, B_SIZE) < XFS_MIN_BLOCKSIZE ||
> +	    get_conf_val(OPT_B, B_SIZE) > XFS_MAX_BLOCKSIZE) {
> +		fprintf(stderr, _("illegal block size %lld\n"),
> +			get_conf_val(OPT_B, B_SIZE));
>  		usage();
>  	}
> -	if (sb_feat.crcs_enabled && blocksize < XFS_MIN_CRC_BLOCKSIZE) {
> +	if (sb_feat.crcs_enabled &&
> +	    get_conf_val(OPT_B, B_SIZE) < XFS_MIN_CRC_BLOCKSIZE) {
>  		fprintf(stderr,
>  _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  			XFS_MIN_CRC_BLOCKSIZE);
> @@ -2322,12 +2291,12 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  	}
>  
>  	if (!slflag && !ssflag) {
> -		sectorlog = XFS_MIN_SECTORSIZE_LOG;
> -		sectorsize = XFS_MIN_SECTORSIZE;
> +		set_conf_val(OPT_D, D_SECTLOG, XFS_MIN_SECTORSIZE_LOG);
> +		set_conf_val(OPT_D, D_SECTSIZE, XFS_MIN_SECTORSIZE);
>  	}
>  	if (!lslflag && !lssflag) {
> -		lsectorlog = sectorlog;
> -		lsectorsize = sectorsize;
> +		lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
> +		lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
>  	}
>  
>  	/*
> @@ -2337,7 +2306,8 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  	 * sector size mismatches between the new filesystem and the underlying
>  	 * host filesystem.
>  	 */
> -	check_device_type(dfile, &xi.disfile, !dbytes, !dfile,
> +	check_device_type(dfile, &xi.disfile, !get_conf_val(OPT_D, D_SIZE),
> +			  !dfile,
>  			  Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
>  	if (!loginternal)
>  		check_device_type(xi.logname, &xi.lisfile, !logbytes,
> @@ -2366,50 +2336,58 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  		if (!ft.psectorsize)
>  			ft.psectorsize = ft.lsectorsize;
>  
> -		sectorsize = ft.psectorsize ? ft.psectorsize :
> -					      XFS_MIN_SECTORSIZE;
> +		set_conf_val(OPT_D, D_SECTSIZE,
> +			     ft.psectorsize ? ft.psectorsize :
> +					      XFS_MIN_SECTORSIZE);
>  
> -		if ((blocksize < sectorsize) && (blocksize >= ft.lsectorsize)) {
> +		if ((get_conf_val(OPT_B, B_SIZE) <
> +		     get_conf_val(OPT_D, D_SECTSIZE)) &&
> +		    (get_conf_val(OPT_B, B_SIZE) >= ft.lsectorsize)) {
>  			fprintf(stderr,
> -_("specified blocksize %d is less than device physical sector size %d\n"),
> -				blocksize, ft.psectorsize);
> +_("specified blocksize %lld is less than device physical sector size %d\n"),
> +				get_conf_val(OPT_B, B_SIZE), ft.psectorsize);
>  			fprintf(stderr,
>  _("switching to logical sector size %d\n"),
>  				ft.lsectorsize);
> -			sectorsize = ft.lsectorsize ? ft.lsectorsize :
> -						      XFS_MIN_SECTORSIZE;
> +			set_conf_val(OPT_D, D_SECTSIZE,
> +				     ft.lsectorsize ? ft.lsectorsize :
> +						      XFS_MIN_SECTORSIZE);
>  		}
>  	}
>  
>  	if (!ssflag) {
> -		sectorlog = libxfs_highbit32(sectorsize);
> +		set_conf_val(OPT_D, D_SECTLOG,
> +			     libxfs_highbit32(get_conf_val(OPT_D, D_SECTSIZE)));
>  		if (loginternal) {
> -			lsectorsize = sectorsize;
> -			lsectorlog = sectorlog;
> +			lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
> +			lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
>  		}
>  	}
>  
> -	if (sectorsize < XFS_MIN_SECTORSIZE ||
> -	    sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
> +	if (get_conf_val(OPT_D, D_SECTSIZE) < XFS_MIN_SECTORSIZE ||
> +	    get_conf_val(OPT_D, D_SECTSIZE) > XFS_MAX_SECTORSIZE ||
> +	    get_conf_val(OPT_D, D_SECTSIZE) > get_conf_val(OPT_B, B_SIZE)) {
>  		if (ssflag)
> -			fprintf(stderr, _("illegal sector size %d\n"), sectorsize);
> +			fprintf(stderr, _("illegal sector size %lld\n"),
> +				get_conf_val(OPT_D, D_SECTSIZE));
>  		else
>  			fprintf(stderr,
> -_("block size %d cannot be smaller than logical sector size %d\n"),
> -				blocksize, ft.lsectorsize);
> +_("block size %lld cannot be smaller than logical sector size %d\n"),
> +				get_conf_val(OPT_B, B_SIZE), ft.lsectorsize);
>  		usage();
>  	}
> -	if (sectorsize < ft.lsectorsize) {
> -		fprintf(stderr, _("illegal sector size %d; hw sector is %d\n"),
> -			sectorsize, ft.lsectorsize);
> +	if (get_conf_val(OPT_D, D_SECTSIZE) < ft.lsectorsize) {
> +		fprintf(stderr, _("illegal sector size %lld; hw sector is %d\n"),
> +			get_conf_val(OPT_D, D_SECTSIZE), ft.lsectorsize);
>  		usage();
>  	}
>  	if (lsectorsize < XFS_MIN_SECTORSIZE ||
> -	    lsectorsize > XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {
> +	    lsectorsize > XFS_MAX_SECTORSIZE ||
> +	    lsectorsize > get_conf_val(OPT_B, B_SIZE)) {
>  		fprintf(stderr, _("illegal log sector size %d\n"), lsectorsize);
>  		usage();
>  	} else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
> -		lsu = blocksize;
> +		lsu = get_conf_val(OPT_B, B_SIZE);
>  		sb_feat.log_version = 2;
>  	}
>  
> @@ -2511,37 +2489,41 @@ _("rmapbt not supported with realtime devices\n"));
>  	}
>  
>  	if (nsflag || nlflag) {
> -		if (dirblocksize < blocksize ||
> +		if (dirblocksize < get_conf_val(OPT_B, B_SIZE) ||
>  					dirblocksize > XFS_MAX_BLOCKSIZE) {
>  			fprintf(stderr, _("illegal directory block size %d\n"),
>  				dirblocksize);
>  			usage();
>  		}
>  	} else {
> -		if (blocksize < (1 << XFS_MIN_REC_DIRSIZE))
> +		if (get_conf_val(OPT_B, B_SIZE) < (1 << XFS_MIN_REC_DIRSIZE))
>  			dirblocklog = XFS_MIN_REC_DIRSIZE;
>  		else
> -			dirblocklog = blocklog;
> +			dirblocklog = get_conf_val(OPT_B, B_LOG);
>  		dirblocksize = 1 << dirblocklog;
>  	}
>  
>  
> -	if (dbytes) {
> -		if (dbytes % XFS_MIN_BLOCKSIZE) {
> +	if (get_conf_val(OPT_D, D_SIZE)) {
> +		if (get_conf_val(OPT_D, D_SIZE) % XFS_MIN_BLOCKSIZE) {
>  			fprintf(stderr,
>  			_("illegal data length %lld, not a multiple of %d\n"),
> -				(long long)dbytes, XFS_MIN_BLOCKSIZE);
> +				get_conf_val(OPT_D, D_SIZE), XFS_MIN_BLOCKSIZE);
>  			usage();
>  		}
> -		dblocks = (xfs_rfsblock_t)(dbytes >> blocklog);
> -		if (dbytes % blocksize)
> +		dblocks = (xfs_rfsblock_t)(get_conf_val(OPT_D, D_SIZE) >>
> +					   get_conf_val(OPT_B, B_LOG));
> +		if (get_conf_val(OPT_D, D_SIZE) % get_conf_val(OPT_B, B_SIZE))
>  			fprintf(stderr, _("warning: "
> -	"data length %lld not a multiple of %d, truncated to %lld\n"),
> -				(long long)dbytes, blocksize,
> -				(long long)(dblocks << blocklog));
> +	"data length %lld not a multiple of %lld, truncated to %lld\n"),
> +				get_conf_val(OPT_D, D_SIZE),
> +				get_conf_val(OPT_B, B_SIZE),
> +				(long long)(dblocks <<
> +					   get_conf_val(OPT_B, B_LOG)));
>  	}
>  	if (ipflag) {
> -		inodelog = blocklog - libxfs_highbit32(inopblock);
> +		inodelog = get_conf_val(OPT_B, B_LOG) -
> +			libxfs_highbit32(inopblock);

Indentation problem here (two tabs, not one).

Otherwise looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  		isize = 1 << inodelog;
>  	} else if (!ilflag && !isflag) {
>  		inodelog = sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
> @@ -2562,12 +2544,14 @@ _("rmapbt not supported with realtime devices\n"));
>  				(long long)logbytes, XFS_MIN_BLOCKSIZE);
>  			usage();
>  		}
> -		logblocks = (xfs_rfsblock_t)(logbytes >> blocklog);
> -		if (logbytes % blocksize)
> +		logblocks = (xfs_rfsblock_t)(logbytes >>
> +					     get_conf_val(OPT_B, B_LOG));
> +		if (logbytes % get_conf_val(OPT_B, B_SIZE))
>  			fprintf(stderr,
> -	_("warning: log length %lld not a multiple of %d, truncated to %lld\n"),
> -				(long long)logbytes, blocksize,
> -				(long long)(logblocks << blocklog));
> +	_("warning: log length %lld not a multiple of %lld, truncated to %lld\n"),
> +				(long long)logbytes, get_conf_val(OPT_B, B_SIZE),
> +				(long long)(logblocks <<
> +					   get_conf_val(OPT_B, B_LOG)));
>  	}
>  	if (rtbytes) {
>  		if (rtbytes % XFS_MIN_BLOCKSIZE) {
> @@ -2576,24 +2560,27 @@ _("rmapbt not supported with realtime devices\n"));
>  				(long long)rtbytes, XFS_MIN_BLOCKSIZE);
>  			usage();
>  		}
> -		rtblocks = (xfs_rfsblock_t)(rtbytes >> blocklog);
> -		if (rtbytes % blocksize)
> +		rtblocks = (xfs_rfsblock_t)(rtbytes >>
> +					    get_conf_val(OPT_B, B_LOG));
> +		if (rtbytes % get_conf_val(OPT_B, B_SIZE))
>  			fprintf(stderr,
> -	_("warning: rt length %lld not a multiple of %d, truncated to %lld\n"),
> -				(long long)rtbytes, blocksize,
> -				(long long)(rtblocks << blocklog));
> +	_("warning: rt length %lld not a multiple of %lld, truncated to %lld\n"),
> +				(long long)rtbytes, get_conf_val(OPT_B, B_SIZE),
> +				(long long)(rtblocks <<
> +					   get_conf_val(OPT_B, B_LOG)));
>  	}
>  	/*
>  	 * If specified, check rt extent size against its constraints.
>  	 */
>  	if (rtextbytes) {
> -		if (rtextbytes % blocksize) {
> +		if (rtextbytes % get_conf_val(OPT_B, B_SIZE)) {
>  			fprintf(stderr,
> -		_("illegal rt extent size %lld, not a multiple of %d\n"),
> -				(long long)rtextbytes, blocksize);
> +		_("illegal rt extent size %lld, not a multiple of %lld\n"),
> +				(long long)rtextbytes, get_conf_val(OPT_B, B_SIZE));
>  			usage();
>  		}
> -		rtextblocks = (xfs_extlen_t)(rtextbytes >> blocklog);
> +		rtextblocks = (xfs_extlen_t)(rtextbytes >>
> +					     get_conf_val(OPT_B, B_LOG));
>  	} else {
>  		/*
>  		 * If realtime extsize has not been specified by the user,
> @@ -2608,18 +2595,21 @@ _("rmapbt not supported with realtime devices\n"));
>  		else
>  			rswidth = 0;
>  
> -		/* check that rswidth is a multiple of fs blocksize */
> -		if (!norsflag && rswidth && !(BBTOB(rswidth) % blocksize)) {
> +		/* check that rswidth is a multiple of fs B_SIZE */
> +		if (!norsflag && rswidth &&
> +		    !(BBTOB(rswidth) % get_conf_val(OPT_B, B_SIZE))) {
>  			rswidth = DTOBT(rswidth);
> -			rtextbytes = rswidth << blocklog;
> +			rtextbytes = rswidth << get_conf_val(OPT_B, B_LOG);
>  			if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
>  			    (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
>  				rtextblocks = rswidth;
>  			}
>  		}
>  		if (!rtextblocks) {
> -			rtextblocks = (blocksize < XFS_MIN_RTEXTSIZE) ?
> -					XFS_MIN_RTEXTSIZE >> blocklog : 1;
> +			rtextblocks = (get_conf_val(OPT_B, B_SIZE) <
> +				       XFS_MIN_RTEXTSIZE) ?
> +				       XFS_MIN_RTEXTSIZE >>
> +				       get_conf_val(OPT_B, B_LOG) : 1;
>  		}
>  	}
>  	ASSERT(rtextblocks);
> @@ -2627,22 +2617,25 @@ _("rmapbt not supported with realtime devices\n"));
>  	/*
>  	 * Check some argument sizes against mins, maxes.
>  	 */
> -	if (isize > blocksize / XFS_MIN_INODE_PERBLOCK ||
> +	if (isize > get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
>  	    isize < XFS_DINODE_MIN_SIZE ||
>  	    isize > XFS_DINODE_MAX_SIZE) {
>  		int	maxsz;
>  
>  		fprintf(stderr, _("illegal inode size %d\n"), isize);
> -		maxsz = MIN(blocksize / XFS_MIN_INODE_PERBLOCK,
> +		maxsz = MIN(get_conf_val(OPT_B, B_SIZE) /
> +			    XFS_MIN_INODE_PERBLOCK,
>  			    XFS_DINODE_MAX_SIZE);
>  		if (XFS_DINODE_MIN_SIZE == maxsz)
>  			fprintf(stderr,
> -			_("allowable inode size with %d byte blocks is %d\n"),
> -				blocksize, XFS_DINODE_MIN_SIZE);
> +			_("allowable inode size with %lld byte blocks is %d\n"),
> +				get_conf_val(OPT_B, B_SIZE),
> +				XFS_DINODE_MIN_SIZE);
>  		else
>  			fprintf(stderr,
> -	_("allowable inode size with %d byte blocks is between %d and %d\n"),
> -				blocksize, XFS_DINODE_MIN_SIZE, maxsz);
> +	_("allowable inode size with %lld byte blocks is between %d and %d\n"),
> +				get_conf_val(OPT_B, B_SIZE),
> +				XFS_DINODE_MIN_SIZE, maxsz);
>  		exit(1);
>  	}
>  
> @@ -2653,14 +2646,24 @@ _("rmapbt not supported with realtime devices\n"));
>  		sb_feat.log_version = 2;
>  	}
>  
> -	calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize,
> +	int dsunit = get_conf_val(OPT_D, D_SUNIT);
> +	int dswidth = get_conf_val(OPT_D, D_SWIDTH);
> +
> +	calc_stripe_factors(get_conf_val(OPT_D, D_SU),
> +			    get_conf_val(OPT_D, D_SW),
> +			    get_conf_val(OPT_D, D_SECTSIZE),
> +			    lsu,
> +			    lsectorsize,
>  				&dsunit, &dswidth, &lsunit);
>  
>  	/* If sunit & swidth were manually specified as 0, same as noalign */
>  	if (dsflag && !dsunit && !dswidth)
> -		nodsflag = 1;
> +		set_conf_val(OPT_D, D_NOALIGN, 1);
> +
> +	set_conf_val(OPT_D, D_SUNIT, dsunit);
> +	set_conf_val(OPT_D, D_SWIDTH, dswidth);
>  
> -	xi.setblksize = sectorsize;
> +	xi.setblksize = get_conf_val(OPT_D, D_SECTSIZE);
>  
>  	/*
>  	 * Initialize.  This will open the log and rt devices as well.
> @@ -2683,7 +2686,8 @@ _("rmapbt not supported with realtime devices\n"));
>  	 * multiple of the sector size, or 1024, whichever is larger.
>  	 */
>  
> -	sector_mask = (uint64_t)-1 << (MAX(sectorlog, 10) - BBSHIFT);
> +	sector_mask = (uint64_t)-1 <<
> +		(MAX(get_conf_val(OPT_D, D_SECTLOG), 10) - BBSHIFT);
>  	xi.dsize &= sector_mask;
>  	xi.rtsize &= sector_mask;
>  	xi.logBBsize &= (uint64_t)-1 << (MAX(lsectorlog, 10) - BBSHIFT);
> @@ -2718,16 +2722,17 @@ _("rmapbt not supported with realtime devices\n"));
>  		rtfile = _("volume rt");
>  	else if (!xi.rtdev)
>  		rtfile = _("none");
> -	if (dbytes && xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
> +	if (get_conf_val(OPT_D, D_SIZE) &&
> +	    xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
>  		fprintf(stderr,
>  			_("size %s specified for data subvolume is too large, "
>  			"maximum is %lld blocks\n"),
>  			get_conf_raw_safe(OPT_D, D_SIZE),
>  			(long long)DTOBT(xi.dsize));
>  		usage();
> -	} else if (!dbytes && xi.dsize > 0)
> +	} else if (!get_conf_val(OPT_D, D_SIZE) && xi.dsize > 0)
>  		dblocks = DTOBT(xi.dsize);
> -	else if (!dbytes) {
> +	else if (!get_conf_val(OPT_D, D_SIZE)) {
>  		fprintf(stderr, _("can't get size of data subvolume\n"));
>  		usage();
>  	}
> @@ -2742,17 +2747,18 @@ _("rmapbt not supported with realtime devices\n"));
>  		fprintf(stderr,
>  			_("can't have both external and internal logs\n"));
>  		usage();
> -	} else if (loginternal && sectorsize != lsectorsize) {
> +	} else if (loginternal &&
> +		   get_conf_val(OPT_D, D_SECTSIZE) != lsectorsize) {
>  		fprintf(stderr,
>  	_("data and log sector sizes must be equal for internal logs\n"));
>  		usage();
>  	}
>  
> -	if (xi.dbsize > sectorsize) {
> +	if (xi.dbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
>  		fprintf(stderr, _(
> -"Warning: the data subvolume sector size %u is less than the sector size \n\
> +"Warning: the data subvolume sector size %lld is less than the sector size \n\
>  reported by the device (%u).\n"),
> -			sectorsize, xi.dbsize);
> +			get_conf_val(OPT_D, D_SECTSIZE), xi.dbsize);
>  	}
>  	if (!loginternal && xi.lbsize > lsectorsize) {
>  		fprintf(stderr, _(
> @@ -2760,11 +2766,12 @@ reported by the device (%u).\n"),
>  reported by the device (%u).\n"),
>  			lsectorsize, xi.lbsize);
>  	}
> -	if (rtbytes && xi.rtsize > 0 && xi.rtbsize > sectorsize) {
> +	if (rtbytes && xi.rtsize > 0 &&
> +	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
>  		fprintf(stderr, _(
> -"Warning: the realtime subvolume sector size %u is less than the sector size\n\
> +"Warning: the realtime subvolume sector size %lld is less than the sector size\n\
>  reported by the device (%u).\n"),
> -			sectorsize, xi.rtbsize);
> +			get_conf_val(OPT_D, D_SECTSIZE), xi.rtbsize);
>  	}
>  
>  	if (rtbytes && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
> @@ -2783,119 +2790,175 @@ reported by the device (%u).\n"),
>  	}
>  	if (xi.rtdev) {
>  		rtextents = rtblocks / rtextblocks;
> -		nbmblocks = (xfs_extlen_t)howmany(rtextents, NBBY * blocksize);
> +		nbmblocks = (xfs_extlen_t)howmany(rtextents, NBBY *
> +						  get_conf_val(OPT_B, B_SIZE));
>  	} else {
>  		rtextents = rtblocks = 0;
>  		nbmblocks = 0;
>  	}
>  
> -	if (!nodsflag) {
> -		if (dsunit) {
> -			if (ft.dsunit && ft.dsunit != dsunit) {
> +	if (!get_conf_val(OPT_D, D_NOALIGN)) {
> +		if (get_conf_val(OPT_D, D_SUNIT)) {
> +			if (ft.dsunit &&
> +			    ft.dsunit != get_conf_val(OPT_D, D_SUNIT)) {
>  				fprintf(stderr,
> -					_("%s: Specified data stripe unit %d "
> +					_("%s: Specified data stripe unit %lld "
>  					"is not the same as the volume stripe "
>  					"unit %d\n"),
> -					progname, dsunit, ft.dsunit);
> +					progname,
> +					get_conf_val(OPT_D, D_SUNIT),
> +					ft.dsunit);
>  			}
> -			if (ft.dswidth && ft.dswidth != dswidth) {
> +			if (ft.dswidth &&
> +			    ft.dswidth != get_conf_val(OPT_D, D_SWIDTH)) {
>  				fprintf(stderr,
> -					_("%s: Specified data stripe width %d "
> +					_("%s: Specified data stripe width %lld "
>  					"is not the same as the volume stripe "
>  					"width %d\n"),
> -					progname, dswidth, ft.dswidth);
> +					progname,
> +					get_conf_val(OPT_D, D_SWIDTH),
> +					ft.dswidth);
>  			}
>  		} else {
> -			dsunit = ft.dsunit;
> -			dswidth = ft.dswidth;
> -			nodsflag = 1;
> +			set_conf_val(OPT_D, D_SUNIT, ft.dsunit);
> +			set_conf_val(OPT_D, D_SWIDTH, ft.dswidth);
> +			set_conf_val(OPT_D, D_NOALIGN, 1);
>  		}
> -	} /* else dsunit & dswidth can't be set if nodsflag is set */
> +	} /* else D_SUNIT & D_SWIDTH can't be set if D_NOALIGN is set */
>  
>  	if (dasize) {		/* User-specified AG size */
>  		/*
> -		 * Check specified agsize is a multiple of blocksize.
> +		 * Check specified D_AGSIZE is a multiple of B_SIZE.
>  		 */
> -		if (agsize % blocksize) {
> +		if (get_conf_val(OPT_D, D_AGSIZE) %
> +		    get_conf_val(OPT_B, B_SIZE)) {
>  			fprintf(stderr,
> -		_("agsize (%lld) not a multiple of fs blk size (%d)\n"),
> -				(long long)agsize, blocksize);
> +		_("agsize (%lld) not a multiple of fs blk size (%lld)\n"),
> +				get_conf_val(OPT_D, D_AGSIZE),
> +				get_conf_val(OPT_B, B_SIZE));
>  			usage();
>  		}
> -		agsize /= blocksize;
> -		agcount = dblocks / agsize + (dblocks % agsize != 0);
> +		set_conf_val(OPT_D, D_AGSIZE,
> +			     get_conf_val(OPT_D, D_AGSIZE) /
> +			     get_conf_val(OPT_B, B_SIZE));
> +		set_conf_val(OPT_D, D_AGCOUNT,
> +			     dblocks / get_conf_val(OPT_D, D_AGSIZE) +
> +			     (dblocks % get_conf_val(OPT_D, D_AGSIZE) != 0));
>  
>  	} else if (daflag) {	/* User-specified AG count */
> -		agsize = dblocks / agcount + (dblocks % agcount != 0);
> +		set_conf_val(OPT_D, D_AGSIZE,
> +			     dblocks / get_conf_val(OPT_D, D_AGCOUNT) +
> +			     (dblocks % get_conf_val(OPT_D, D_AGCOUNT) != 0));
>  	} else {
> -		calc_default_ag_geometry(blocklog, dblocks,
> -				dsunit | dswidth, &agsize, &agcount);
> +		/* TODO change the calc_... function so it accepts opts
> +		 * directly, without the need to pass all the values. */
> +		uint64_t agcount = get_conf_val(OPT_D, D_AGCOUNT);
> +		uint64_t agsize = get_conf_val(OPT_D, D_AGSIZE);
> +
> +		calc_default_ag_geometry(get_conf_val(OPT_B, B_LOG),
> +					 dblocks, get_conf_val(OPT_D, D_SUNIT)
> +					 | get_conf_val(OPT_D, D_SWIDTH),
> +					 &agsize, &agcount);
> +		set_conf_val(OPT_D, D_AGCOUNT, agcount);
> +		set_conf_val(OPT_D, D_AGSIZE, agsize);
>  	}
>  
>  	/*
> -	 * If dsunit is a multiple of fs blocksize, then check that is a
> -	 * multiple of the agsize too
> +	 * If D_SUNIT is a multiple of fs B_SIZE,
> +	 * then check that is a multiple of the D_AGSIZE too
>  	 */
> -	if (dsunit && !(BBTOB(dsunit) % blocksize) &&
> -	    dswidth && !(BBTOB(dswidth) % blocksize)) {
> -
> -		/* convert from 512 byte blocks to fs blocksize */
> -		dsunit = DTOBT(dsunit);
> -		dswidth = DTOBT(dswidth);
> +	if (get_conf_val(OPT_D, D_SUNIT) &&
> +	    !(BBTOB(get_conf_val(OPT_D, D_SUNIT)) %
> +	      get_conf_val(OPT_B, B_SIZE)) &&
> +	    get_conf_val(OPT_D, D_SWIDTH) &&
> +	    !(BBTOB(get_conf_val(OPT_D, D_SWIDTH)) %
> +	      get_conf_val(OPT_B, B_SIZE))) {
> +
> +		/* convert from 512 byte blocks to fs B_SIZE
> +		 */
> +		set_conf_val(OPT_D, D_SUNIT,
> +			     DTOBT(get_conf_val(OPT_D, D_SUNIT)));
> +		set_conf_val(OPT_D, D_SWIDTH,
> +			     DTOBT(get_conf_val(OPT_D, D_SWIDTH)));
>  
>  		/*
> -		 * agsize is not a multiple of dsunit
> +		 * D_AGSIZE is not a multiple of D_SUNIT
>  		 */
> -		if ((agsize % dsunit) != 0) {
> +		if ((get_conf_val(OPT_D, D_AGSIZE) %
> +		     get_conf_val(OPT_D, D_SUNIT)) != 0) {
>  			/*
>  			 * Round up to stripe unit boundary. Also make sure
> -			 * that agsize is still larger than
> -			 * XFS_AG_MIN_BLOCKS(blocklog)
> +			 * that D_AGSIZE is still larger than
> +			 * XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))
>  		 	 */
> -			tmp_agsize = ((agsize + (dsunit - 1))/ dsunit) * dsunit;
> +			tmp_agsize = ((get_conf_val(OPT_D, D_AGSIZE) +
> +				       (get_conf_val(OPT_D, D_SUNIT) - 1)) /
> +				      get_conf_val(OPT_D, D_SUNIT)) *
> +				get_conf_val(OPT_D, D_SUNIT);
>  			/*
>  			 * Round down to stripe unit boundary if rounding up
>  			 * created an AG size that is larger than the AG max.
>  			 */
> -			if (tmp_agsize > XFS_AG_MAX_BLOCKS(blocklog))
> -				tmp_agsize = ((agsize) / dsunit) * dsunit;
> -
> -			if ((tmp_agsize >= XFS_AG_MIN_BLOCKS(blocklog)) &&
> -			    (tmp_agsize <= XFS_AG_MAX_BLOCKS(blocklog))) {
> -				agsize = tmp_agsize;
> +			if (tmp_agsize >
> +			    XFS_AG_MAX_BLOCKS(get_conf_val(OPT_B, B_LOG)))
> +				tmp_agsize = ((get_conf_val(OPT_D, D_AGSIZE)) /
> +					      get_conf_val(OPT_D, D_SUNIT)) *
> +					get_conf_val(OPT_D, D_SUNIT);
> +
> +			if ((tmp_agsize >=
> +			     XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))) &&
> +			    (tmp_agsize <=
> +			     XFS_AG_MAX_BLOCKS(get_conf_val(OPT_B, B_LOG)))) {
> +				set_conf_val(OPT_D, D_AGSIZE, tmp_agsize);
>  				if (!daflag)
> -					agcount = dblocks/agsize +
> -						(dblocks % agsize != 0);
> +					set_conf_val(OPT_D, D_AGCOUNT,
> +						dblocks /
> +						get_conf_val(OPT_D, D_AGSIZE) +
> +						(dblocks %
> +						 get_conf_val(OPT_D, D_AGSIZE)
> +						!= 0));
>  				if (dasize)
>  					fprintf(stderr,
> -				_("agsize rounded to %lld, swidth = %d\n"),
> -						(long long)agsize, dswidth);
> +				_("agsize rounded to %lld, swidth = %lld\n"),
> +						get_conf_val(OPT_D, D_AGSIZE),
> +						get_conf_val(OPT_D, D_SWIDTH));
>  			} else {
> -				if (nodsflag) {
> -					dsunit = dswidth = 0;
> +				if (get_conf_val(OPT_D, D_NOALIGN)) {
> +					set_conf_val(OPT_D, D_SUNIT, 0);
> +					set_conf_val(OPT_D, D_SWIDTH, 0);
>  				} else {
>  					/*
> -					 * agsize is out of bounds, this will
> +					 * D_AGSIZE is out of bounds, this will
>  					 * print nice details & exit.
>  					 */
> -					validate_ag_geometry(blocklog, dblocks,
> -							    agsize, agcount);
> +					validate_ag_geometry(
> +						get_conf_val(OPT_B, B_LOG),
> +						dblocks,
> +						get_conf_val(OPT_D, D_AGSIZE),
> +						get_conf_val(OPT_D, D_AGCOUNT));
>  					exit(1);
>  				}
>  			}
>  		}
> -		if (dswidth && ((agsize % dswidth) == 0) && (agcount > 1)) {
> +		if (get_conf_val(OPT_D, D_SWIDTH) &&
> +		    ((get_conf_val(OPT_D, D_AGSIZE) %
> +		      get_conf_val(OPT_D, D_SWIDTH)) == 0) &&
> +		    (get_conf_val(OPT_D, D_AGCOUNT) > 1)) {
>  			/* This is a non-optimal configuration because all AGs
>  			 * start on the same disk in the stripe.  Changing
>  			 * the AG size by one sunit will guarantee that this
>  			 * does not happen.
>  			 */
> -			tmp_agsize = agsize - dsunit;
> -			if (tmp_agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
> -				tmp_agsize = agsize + dsunit;
> -				if (dblocks < agsize) {
> +			tmp_agsize = get_conf_val(OPT_D, D_AGSIZE) -
> +				get_conf_val(OPT_D, D_SUNIT);
> +			if (tmp_agsize <
> +			    XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))) {
> +				tmp_agsize = get_conf_val(OPT_D, D_AGSIZE) +
> +					get_conf_val(OPT_D, D_SUNIT);
> +				if (dblocks < get_conf_val(OPT_D, D_AGSIZE)) {
>  					/* oh well, nothing to do */
> -					tmp_agsize = agsize;
> +					tmp_agsize =
> +						get_conf_val(OPT_D, D_AGSIZE);
>  				}
>  			}
>  			if (daflag || dasize) {
> @@ -2905,30 +2968,46 @@ problems by aligning all AGs on the same disk.  To avoid this, run mkfs with\n\
>  an AG size that is one stripe unit smaller, for example %llu.\n"),
>  					(unsigned long long)tmp_agsize);
>  			} else {
> -				agsize = tmp_agsize;
> -				agcount = dblocks/agsize + (dblocks % agsize != 0);
> +				set_conf_val(OPT_D, D_AGSIZE, tmp_agsize);
> +				set_conf_val(OPT_D, D_AGCOUNT,
> +					dblocks/get_conf_val(OPT_D, D_AGSIZE) +
> +					     (dblocks %
> +					      get_conf_val(OPT_D, D_AGSIZE)
> +					      != 0));
>  				/*
>  				 * If the last AG is too small, reduce the
>  				 * filesystem size and drop the blocks.
>  				 */
> -				if ( dblocks % agsize != 0 &&
> -				    (dblocks % agsize <
> -				    XFS_AG_MIN_BLOCKS(blocklog))) {
> -					dblocks = (xfs_rfsblock_t)((agcount - 1) * agsize);
> -					agcount--;
> -					ASSERT(agcount != 0);
> +				if (dblocks % get_conf_val(OPT_D, D_AGSIZE)
> +				    != 0 &&
> +				    (dblocks % get_conf_val(OPT_D, D_AGSIZE) <
> +				    XFS_AG_MIN_BLOCKS(
> +					get_conf_val(OPT_B, B_LOG)))) {
> +
> +					dblocks = (xfs_rfsblock_t)(
> +						(get_conf_val(OPT_D, D_AGCOUNT)
> +						 - 1) *
> +						get_conf_val(OPT_D, D_AGSIZE));
> +					set_conf_val(OPT_D, D_AGCOUNT,
> +						get_conf_val(OPT_D, D_AGCOUNT)
> +						- 1);
> +					ASSERT(get_conf_val(OPT_D, D_AGCOUNT)
> +					       != 0);
>  				}
>  			}
>  		}
>  	} else {
> -		if (nodsflag)
> -			dsunit = dswidth = 0;
> -		else {
> +		if (get_conf_val(OPT_D, D_NOALIGN)) {
> +			set_conf_val(OPT_D, D_SWIDTH, 0);
> +			set_conf_val(OPT_D, D_SUNIT, 0);
> +		} else {
>  			fprintf(stderr,
> -				_("%s: Stripe unit(%d) or stripe width(%d) is "
> -				"not a multiple of the block size(%d)\n"),
> -				progname, BBTOB(dsunit), BBTOB(dswidth),
> -				blocksize);
> +				_("%s: Stripe unit(%lld) or stripe width(%lld) is "
> +				"not a multiple of the block size(%lld)\n"),
> +				progname,
> +				BBTOB(get_conf_val(OPT_D, D_SUNIT)),
> +				BBTOB(get_conf_val(OPT_D, D_SWIDTH)),
> +				get_conf_val(OPT_B, B_SIZE));
>  			exit(1);
>  		}
>  	}
> @@ -2937,53 +3016,69 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  	 * If the last AG is too small, reduce the filesystem size
>  	 * and drop the blocks.
>  	 */
> -	if ( dblocks % agsize != 0 &&
> -	     (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) {
> +	if (dblocks % get_conf_val(OPT_D, D_AGSIZE) != 0 &&
> +	     (dblocks % get_conf_val(OPT_D, D_AGSIZE) <
> +	      XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG)))) {
>  		ASSERT(!daflag);
> -		dblocks = (xfs_rfsblock_t)((agcount - 1) * agsize);
> -		agcount--;
> -		ASSERT(agcount != 0);
> +		dblocks = (xfs_rfsblock_t)(
> +				(get_conf_val(OPT_D, D_AGCOUNT) - 1) *
> +				get_conf_val(OPT_D, D_AGSIZE));
> +		set_conf_val(OPT_D, D_AGCOUNT,
> +			     get_conf_val(OPT_D, D_AGCOUNT) - 1);
> +		ASSERT(get_conf_val(OPT_D, D_AGCOUNT) != 0);
>  	}
>  
> -	validate_ag_geometry(blocklog, dblocks, agsize, agcount);
> +	validate_ag_geometry(get_conf_val(OPT_B, B_LOG),
> +			     dblocks,
> +			     get_conf_val(OPT_D, D_AGSIZE),
> +			     get_conf_val(OPT_D, D_AGCOUNT));
>  
>  	if (!imflag)
> -		imaxpct = calc_default_imaxpct(blocklog, dblocks);
> +		imaxpct = calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
> +					       dblocks);
>  
>  	/*
> -	 * check that log sunit is modulo fsblksize or default it to dsunit.
> +	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
>  	 */
>  
>  	if (lsunit) {
>  		/* convert from 512 byte blocks to fs blocks */
>  		lsunit = DTOBT(lsunit);
> -	} else if (sb_feat.log_version == 2 && loginternal && dsunit) {
> -		/* lsunit and dsunit now in fs blocks */
> -		lsunit = dsunit;
> +	} else if (sb_feat.log_version == 2 &&
> +		   loginternal &&
> +		   get_conf_val(OPT_D, D_SUNIT)) {
> +		/* lsunit and get_conf_val(OPT_D, D_SUNIT) now in fs blocks */
> +		lsunit = get_conf_val(OPT_D, D_SUNIT);
>  	}
>  
> -	if (sb_feat.log_version == 2 && (lsunit * blocksize) > 256 * 1024) {
> +	if (sb_feat.log_version == 2 &&
> +	    (lsunit * get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
>  		/* Warn only if specified on commandline */
>  		if (lsuflag || lsunitflag) {
>  			fprintf(stderr,
> -	_("log stripe unit (%d bytes) is too large (maximum is 256KiB)\n"),
> -				(lsunit * blocksize));
> +	_("log stripe unit (%lld bytes) is too large (maximum is 256KiB)\n"),
> +				(lsunit * get_conf_val(OPT_B, B_SIZE)));
>  			fprintf(stderr,
>  	_("log stripe unit adjusted to 32KiB\n"));
>  		}
> -		lsunit = (32 * 1024) >> blocklog;
> +		lsunit = (32 * 1024) >> get_conf_val(OPT_B, B_LOG);
>  	}
>  
> -	min_logblocks = max_trans_res(agsize,
> +	min_logblocks = max_trans_res(get_conf_val(OPT_D, D_AGSIZE),
>  				   sb_feat.crcs_enabled, sb_feat.dir_version,
> -				   sectorlog, blocklog, inodelog, dirblocklog,
> +				   get_conf_val(OPT_D, D_SECTLOG),
> +				   get_conf_val(OPT_B, B_LOG),
> +				   inodelog, dirblocklog,
>  				   sb_feat.log_version, lsunit, sb_feat.finobt,
>  				   sb_feat.rmapbt, sb_feat.reflink,
>  				   sb_feat.inode_align);
>  	ASSERT(min_logblocks);
>  	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
> -	if (!logbytes && dblocks >= (1024*1024*1024) >> blocklog)
> -		min_logblocks = MAX(min_logblocks, XFS_MIN_LOG_BYTES>>blocklog);
> +	if (!logbytes &&
> +	    dblocks >= (1024*1024*1024) >> get_conf_val(OPT_B, B_LOG))
> +		min_logblocks = MAX(min_logblocks,
> +				    XFS_MIN_LOG_BYTES >>
> +				    get_conf_val(OPT_B, B_LOG));
>  	if (logbytes && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
>  		fprintf(stderr,
>  _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
> @@ -3004,17 +3099,19 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		logblocks = 0;
>  	} else if (loginternal && !logbytes) {
>  
> -		if (dblocks < GIGABYTES(1, blocklog)) {
> +		if (dblocks < GIGABYTES(1, get_conf_val(OPT_B, B_LOG))) {
>  			/* tiny filesystems get minimum sized logs. */
>  			logblocks = min_logblocks;
> -		} else if (dblocks < GIGABYTES(16, blocklog)) {
> +		} else if (dblocks <
> +			   GIGABYTES(16, get_conf_val(OPT_B, B_LOG))) {
>  
>  			/*
>  			 * For small filesystems, we want to use the
>  			 * XFS_MIN_LOG_BYTES for filesystems smaller than 16G if
>  			 * at all possible, ramping up to 128MB at 256GB.
>  			 */
> -			logblocks = MIN(XFS_MIN_LOG_BYTES >> blocklog,
> +			logblocks = MIN(XFS_MIN_LOG_BYTES >>
> +					get_conf_val(OPT_B, B_LOG),
>  					min_logblocks * XFS_DFL_LOG_FACTOR);
>  		} else {
>  			/*
> @@ -3023,34 +3120,38 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  			 * max log size of 128M at 256GB fs size. IOWs,
>  			 * the ratio of fs size to log size is 2048:1.
>  			 */
> -			logblocks = (dblocks << blocklog) / 2048;
> -			logblocks = logblocks >> blocklog;
> +			logblocks = (dblocks <<
> +				     get_conf_val(OPT_B, B_LOG)) / 2048;
> +			logblocks = logblocks >> get_conf_val(OPT_B, B_LOG);
>  		}
>  
>  		/* Ensure the chosen size meets minimum log size requirements */
>  		logblocks = MAX(min_logblocks, logblocks);
>  
>  		/* make sure the log fits wholly within an AG */
> -		if (logblocks >= agsize)
> +		if (logblocks >= get_conf_val(OPT_D, D_AGSIZE))
>  			logblocks = min_logblocks;
>  
>  		/* and now clamp the size to the maximum supported size */
>  		logblocks = MIN(logblocks, XFS_MAX_LOG_BLOCKS);
> -		if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES)
> -			logblocks = XFS_MAX_LOG_BYTES >> blocklog;
> +		if ((logblocks << get_conf_val(OPT_B, B_LOG)) >
> +		    XFS_MAX_LOG_BYTES)
> +			logblocks = XFS_MAX_LOG_BYTES >>
> +				get_conf_val(OPT_B, B_LOG);
>  
>  	}
> -	validate_log_size(logblocks, blocklog, min_logblocks);
> +	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
>  
>  	protostring = setup_proto(protofile);
> -	bsize = 1 << (blocklog - BBSHIFT);
> +	bsize = 1 << (get_conf_val(OPT_B, B_LOG) - BBSHIFT);
>  	mp = &mbuf;
>  	sbp = &mp->m_sb;
>  	memset(mp, 0, sizeof(xfs_mount_t));
> -	sbp->sb_blocklog = (uint8_t)blocklog;
> -	sbp->sb_sectlog = (uint8_t)sectorlog;
> -	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup((unsigned int)agsize);
> -	sbp->sb_agblocks = (xfs_agblock_t)agsize;
> +	sbp->sb_blocklog = (uint8_t)get_conf_val(OPT_B, B_LOG);
> +	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
> +	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup(
> +				(unsigned int)get_conf_val(OPT_D, D_AGSIZE));
> +	sbp->sb_agblocks = (xfs_agblock_t)get_conf_val(OPT_D, D_AGSIZE);
>  	mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
>  	mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
>  
> @@ -3058,7 +3159,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	 * sb_versionnum, finobt and rmapbt flags must be set before we use
>  	 * libxfs_prealloc_blocks().
>  	 */
> -	sb_set_features(&mp->m_sb, &sb_feat, sectorsize, lsectorsize, dsunit);
> +	sb_set_features(&mp->m_sb, &sb_feat,
> +			get_conf_val(OPT_D, D_SECTSIZE),
> +			lsectorsize,
> +			get_conf_val(OPT_D, D_SUNIT));
>  
>  
>  	if (loginternal) {
> @@ -3071,9 +3175,12 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  					libxfs_alloc_ag_max_usable(mp));
>  
>  			/* revalidate the log size is valid if we changed it */
> -			validate_log_size(logblocks, blocklog, min_logblocks);
> +			validate_log_size(logblocks,
> +					  get_conf_val(OPT_B, B_LOG),
> +					  min_logblocks);
>  		}
> -		if (logblocks > agsize - libxfs_prealloc_blocks(mp)) {
> +		if (logblocks > get_conf_val(OPT_D, D_AGSIZE) -
> +		    libxfs_prealloc_blocks(mp)) {
>  			fprintf(stderr,
>  	_("internal log size %lld too large, must fit in allocation group\n"),
>  				(long long)logblocks);
> @@ -3081,14 +3188,16 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		}
>  
>  		if (laflag) {
> -			if (logagno >= agcount) {
> +			if (logagno >= get_conf_val(OPT_D, D_AGCOUNT)) {
>  				fprintf(stderr,
>  		_("log ag number %d too large, must be less than %lld\n"),
> -					logagno, (long long)agcount);
> +					logagno,
> +					get_conf_val(OPT_D, D_AGCOUNT));
>  				usage();
>  			}
>  		} else
> -			logagno = (xfs_agnumber_t)(agcount / 2);
> +			logagno = (xfs_agnumber_t)(
> +					get_conf_val(OPT_D, D_AGCOUNT) / 2);
>  
>  		logstart = XFS_AGB_TO_FSB(mp, logagno, libxfs_prealloc_blocks(mp));
>  		/*
> @@ -3096,45 +3205,53 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		 */
>  		if (lsunit) {
>  			logstart = fixup_internal_log_stripe(mp,
> -					lsflag, logstart, agsize, lsunit,
> -					&logblocks, blocklog, &lalign);
> -		} else if (dsunit) {
> +					lsflag, logstart,
> +					get_conf_val(OPT_D, D_AGSIZE), lsunit,
> +					&logblocks,
> +					get_conf_val(OPT_B, B_LOG), &lalign);
> +		} else if (get_conf_val(OPT_D, D_SUNIT)) {
>  			logstart = fixup_internal_log_stripe(mp,
> -					lsflag, logstart, agsize, dsunit,
> -					&logblocks, blocklog, &lalign);
> +					lsflag, logstart,
> +					get_conf_val(OPT_D, D_AGSIZE),
> +					get_conf_val(OPT_D, D_SUNIT),
> +					&logblocks,
> +					get_conf_val(OPT_B, B_LOG), &lalign);
>  		}
>  	} else {
>  		logstart = 0;
>  		if (lsunit)
>  			fixup_log_stripe_unit(lsflag, lsunit,
> -					&logblocks, blocklog);
> +					&logblocks, get_conf_val(OPT_B, B_LOG));
>  	}
> -	validate_log_size(logblocks, blocklog, min_logblocks);
> +	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
>  
>  	if (!qflag || Nflag) {
>  		printf(_(
>  		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
> -		   "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
> +		   "         =%-22s sectsz=%-5lld attr=%u, projid32bit=%u\n"
>  		   "         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u, reflink=%u\n"
> -		   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
> -		   "         =%-22s sunit=%-6u swidth=%u blks\n"
> +		   "data     =%-22s bsize=%-6lld blocks=%llu, imaxpct=%u\n"
> +		   "         =%-22s sunit=%-6lld swidth=%lld blks\n"
>  		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
>  		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
>  		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
>  		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
> -			dfile, isize, (long long)agcount, (long long)agsize,
> -			"", sectorsize, sb_feat.attr_version,
> +			dfile, isize, get_conf_val(OPT_D, D_AGCOUNT),
> +			get_conf_val(OPT_D, D_AGSIZE),
> +			"", get_conf_val(OPT_D, D_SECTSIZE),
> +			sb_feat.attr_version,
>  				    !sb_feat.projid16bit,
>  			"", sb_feat.crcs_enabled, sb_feat.finobt, sb_feat.spinodes,
>  			sb_feat.rmapbt, sb_feat.reflink,
> -			"", blocksize, (long long)dblocks, imaxpct,
> -			"", dsunit, dswidth,
> +			"", get_conf_val(OPT_B, B_SIZE), (long long)dblocks, imaxpct,
> +			"", get_conf_val(OPT_D, D_SUNIT),
> +			get_conf_val(OPT_D, D_SWIDTH),
>  			sb_feat.dir_version, dirblocksize, sb_feat.nci,
>  				sb_feat.dirftype,
> -			logfile, 1 << blocklog, (long long)logblocks,
> +			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
>  			sb_feat.log_version, "", lsectorsize, lsunit,
>  				sb_feat.lazy_sb_counters,
> -			rtfile, rtextblocks << blocklog,
> +			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
>  			(long long)rtblocks, (long long)rtextents);
>  		if (Nflag)
>  			exit(0);
> @@ -3143,7 +3260,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	if (label)
>  		strncpy(sbp->sb_fname, label, sizeof(sbp->sb_fname));
>  	sbp->sb_magicnum = XFS_SB_MAGIC;
> -	sbp->sb_blocksize = blocksize;
> +	sbp->sb_blocksize = get_conf_val(OPT_B, B_SIZE);
>  	sbp->sb_dblocks = dblocks;
>  	sbp->sb_rblocks = rtblocks;
>  	sbp->sb_rextents = rtextents;
> @@ -3153,15 +3270,15 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_logstart = logstart;
>  	sbp->sb_rootino = sbp->sb_rbmino = sbp->sb_rsumino = NULLFSINO;
>  	sbp->sb_rextsize = rtextblocks;
> -	sbp->sb_agcount = (xfs_agnumber_t)agcount;
> +	sbp->sb_agcount = (xfs_agnumber_t)get_conf_val(OPT_D, D_AGCOUNT);
>  	sbp->sb_rbmblocks = nbmblocks;
>  	sbp->sb_logblocks = (xfs_extlen_t)logblocks;
> -	sbp->sb_sectsize = (uint16_t)sectorsize;
> +	sbp->sb_sectsize = (uint16_t)get_conf_val(OPT_D, D_SECTSIZE);
>  	sbp->sb_inodesize = (uint16_t)isize;
> -	sbp->sb_inopblock = (uint16_t)(blocksize / isize);
> -	sbp->sb_sectlog = (uint8_t)sectorlog;
> +	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) / isize);
> +	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
>  	sbp->sb_inodelog = (uint8_t)inodelog;
> -	sbp->sb_inopblog = (uint8_t)(blocklog - inodelog);
> +	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) - inodelog);
>  	sbp->sb_rextslog =
>  		(uint8_t)(rtextents ?
>  			libxfs_highbit32((unsigned int)rtextents) : 0);
> @@ -3169,14 +3286,15 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_imax_pct = imaxpct;
>  	sbp->sb_icount = 0;
>  	sbp->sb_ifree = 0;
> -	sbp->sb_fdblocks = dblocks - agcount * libxfs_prealloc_blocks(mp) -
> +	sbp->sb_fdblocks = dblocks -
> +		get_conf_val(OPT_D, D_AGCOUNT) * libxfs_prealloc_blocks(mp) -
>  		(loginternal ? logblocks : 0);
>  	sbp->sb_frextents = 0;	/* will do a free later */
>  	sbp->sb_uquotino = sbp->sb_gquotino = sbp->sb_pquotino = 0;
>  	sbp->sb_qflags = 0;
> -	sbp->sb_unit = dsunit;
> -	sbp->sb_width = dswidth;
> -	sbp->sb_dirblklog = dirblocklog - blocklog;
> +	sbp->sb_unit = get_conf_val(OPT_D, D_SUNIT);
> +	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
> +	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
>  	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
>  		lsunit = (lsunit == 0) ? 1 : XFS_FSB_TO_B(mp, lsunit);
>  		sbp->sb_logsunit = lsunit;
> @@ -3186,11 +3304,12 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		int	cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
>  		if (sb_feat.crcs_enabled)
>  			cluster_size *= isize / XFS_DINODE_MIN_SIZE;
> -		sbp->sb_inoalignmt = cluster_size >> blocklog;
> +		sbp->sb_inoalignmt = cluster_size >> get_conf_val(OPT_B, B_LOG);
>  		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
>  	} else
>  		sbp->sb_inoalignmt = 0;
> -	if (lsectorsize != BBSIZE || sectorsize != BBSIZE) {
> +	if (lsectorsize != BBSIZE ||
> +	    get_conf_val(OPT_D, D_SECTSIZE) != BBSIZE) {
>  		sbp->sb_logsectlog = (uint8_t)lsectorlog;
>  		sbp->sb_logsectsize = (uint16_t)lsectorsize;
>  	} else {
> @@ -3198,7 +3317,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		sbp->sb_logsectsize = 0;
>  	}
>  
> -	sb_set_features(&mp->m_sb, &sb_feat, sectorsize, lsectorsize, dsunit);
> +	sb_set_features(&mp->m_sb, &sb_feat,
> +			get_conf_val(OPT_D, D_SECTSIZE),
> +			lsectorsize,
> +			get_conf_val(OPT_D, D_SUNIT));
>  
>  	if (force_overwrite)
>  		zero_old_xfs_structures(&xi, sbp);
> @@ -3218,7 +3340,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	/* OK, now write the superblock */
>  	buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
>  	buf->b_ops = &xfs_sb_buf_ops;
> -	memset(XFS_BUF_PTR(buf), 0, sectorsize);
> +	memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_D, D_SECTSIZE));
>  	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
>  	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  	libxfs_purgebuf(buf);
> @@ -3228,8 +3350,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	 * if needed so that the reads for the end of the device in the mount
>  	 * code will succeed.
>  	 */
> -	if (xi.disfile && xi.dsize * xi.dbsize < dblocks * blocksize) {
> -		if (ftruncate(xi.dfd, dblocks * blocksize) < 0) {
> +	if (xi.disfile &&
> +	    xi.dsize * xi.dbsize < dblocks * get_conf_val(OPT_B, B_SIZE)) {
> +		if (ftruncate(xi.dfd,
> +			     dblocks * get_conf_val(OPT_B, B_SIZE)) < 0) {
>  			fprintf(stderr,
>  				_("%s: Growing the data section failed\n"),
>  				progname);
> @@ -3271,7 +3395,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	 * These initialisations should be pulled into libxfs to keep the
>  	 * kernel/userspace header initialisation code the same.
>  	 */
> -	for (agno = 0; agno < agcount; agno++) {
> +	for (agno = 0; agno < get_conf_val(OPT_D, D_AGCOUNT); agno++) {
>  		struct xfs_agfl	*agfl;
>  		int		bucket;
>  		struct xfs_perag *pag = libxfs_perag_get(mp, agno);
> @@ -3283,7 +3407,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
>  				XFS_FSS_TO_BB(mp, 1));
>  		buf->b_ops = &xfs_sb_buf_ops;
> -		memset(XFS_BUF_PTR(buf), 0, sectorsize);
> +		memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_D, D_SECTSIZE));
>  		libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
>  		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  
> @@ -3295,13 +3419,17 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				XFS_FSS_TO_BB(mp, 1));
>  		buf->b_ops = &xfs_agf_buf_ops;
>  		agf = XFS_BUF_TO_AGF(buf);
> -		memset(agf, 0, sectorsize);
> -		if (agno == agcount - 1)
> -			agsize = dblocks - (xfs_rfsblock_t)(agno * agsize);
> +		memset(agf, 0, get_conf_val(OPT_D, D_SECTSIZE));
> +		if (agno == get_conf_val(OPT_D, D_AGCOUNT) - 1)
> +			set_conf_val(OPT_D, D_AGSIZE,
> +				dblocks -
> +				(xfs_rfsblock_t)(agno *
> +					get_conf_val(OPT_D, D_AGSIZE)));
> +
>  		agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
>  		agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
>  		agf->agf_seqno = cpu_to_be32(agno);
> -		agf->agf_length = cpu_to_be32(agsize);
> +		agf->agf_length = cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE));
>  		agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp));
>  		agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
>  		agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
> @@ -3323,7 +3451,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		agf->agf_flfirst = 0;
>  		agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
>  		agf->agf_flcount = 0;
> -		nbmblocks = (xfs_extlen_t)(agsize - libxfs_prealloc_blocks(mp));
> +		nbmblocks = (xfs_extlen_t)(get_conf_val(OPT_D, D_AGSIZE) -
> +					   libxfs_prealloc_blocks(mp));
>  		agf->agf_freeblks = cpu_to_be32(nbmblocks);
>  		agf->agf_longest = cpu_to_be32(nbmblocks);
>  		if (xfs_sb_version_hascrc(&mp->m_sb))
> @@ -3331,7 +3460,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  
>  		if (loginternal && agno == logagno) {
>  			be32_add_cpu(&agf->agf_freeblks, -logblocks);
> -			agf->agf_longest = cpu_to_be32(agsize -
> +			agf->agf_longest =
> +				cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
>  				XFS_FSB_TO_AGBNO(mp, logstart) - logblocks);
>  		}
>  		if (libxfs_alloc_min_freelist(mp, pag) > worst_freelist)
> @@ -3347,7 +3477,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		buf->b_ops = &xfs_agfl_buf_ops;
>  		agfl = XFS_BUF_TO_AGFL(buf);
>  		/* setting to 0xff results in initialisation to NULLAGBLOCK */
> -		memset(agfl, 0xff, sectorsize);
> +		memset(agfl, 0xff, get_conf_val(OPT_D, D_SECTSIZE));
>  		if (xfs_sb_version_hascrc(&mp->m_sb)) {
>  			agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC);
>  			agfl->agfl_seqno = cpu_to_be32(agno);
> @@ -3366,11 +3496,13 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				XFS_FSS_TO_BB(mp, 1));
>  		agi = XFS_BUF_TO_AGI(buf);
>  		buf->b_ops = &xfs_agi_buf_ops;
> -		memset(agi, 0, sectorsize);
> +		memset(agi, 0, get_conf_val(OPT_D, D_SECTSIZE));
>  		agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
>  		agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
>  		agi->agi_seqno = cpu_to_be32(agno);
> -		agi->agi_length = cpu_to_be32((xfs_agblock_t)agsize);
> +		agi->agi_length =
> +			cpu_to_be32(
> +				(xfs_agblock_t)get_conf_val(OPT_D, D_AGSIZE));
>  		agi->agi_count = 0;
>  		agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp));
>  		agi->agi_level = cpu_to_be32(1);
> @@ -3395,7 +3527,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				bsize);
>  		buf->b_ops = &xfs_allocbt_buf_ops;
>  		block = XFS_BUF_TO_BLOCK(buf);
> -		memset(block, 0, blocksize);
> +		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
>  		libxfs_btree_init_block(mp, buf, XFS_BTNUM_BNO, 0, 1, agno, 0);
>  
>  		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
> @@ -3430,7 +3562,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		 * so, reset the record count to 0 to avoid exposure of an invalid
>  		 * record start block.
>  		 */
> -		arec->ar_blockcount = cpu_to_be32(agsize -
> +		arec->ar_blockcount =
> +			cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
>  					be32_to_cpu(arec->ar_startblock));
>  		if (!arec->ar_blockcount)
>  			block->bb_numrecs = 0;
> @@ -3445,7 +3578,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				bsize);
>  		buf->b_ops = &xfs_allocbt_buf_ops;
>  		block = XFS_BUF_TO_BLOCK(buf);
> -		memset(block, 0, blocksize);
> +		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
>  		libxfs_btree_init_block(mp, buf, XFS_BTNUM_CNT, 0, 1, agno, 0);
>  
>  		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
> @@ -3470,7 +3603,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		 * so, reset the record count to 0 to avoid exposure of an invalid
>  		 * record start block.
>  		 */
> -		arec->ar_blockcount = cpu_to_be32(agsize -
> +		arec->ar_blockcount =
> +			cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
>  					be32_to_cpu(arec->ar_startblock));
>  		if (!arec->ar_blockcount)
>  			block->bb_numrecs = 0;
> @@ -3488,7 +3622,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  			buf->b_ops = &xfs_refcountbt_buf_ops;
>  
>  			block = XFS_BUF_TO_BLOCK(buf);
> -			memset(block, 0, blocksize);
> +			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
>  			libxfs_btree_init_block(mp, buf, XFS_BTNUM_REFC, 0,
>  						0, agno, 0);
>  
> @@ -3503,7 +3637,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				bsize);
>  		buf->b_ops = &xfs_inobt_buf_ops;
>  		block = XFS_BUF_TO_BLOCK(buf);
> -		memset(block, 0, blocksize);
> +		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
>  		libxfs_btree_init_block(mp, buf, XFS_BTNUM_INO, 0, 0, agno, 0);
>  		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  
> @@ -3516,7 +3650,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  					bsize);
>  			buf->b_ops = &xfs_inobt_buf_ops;
>  			block = XFS_BUF_TO_BLOCK(buf);
> -			memset(block, 0, blocksize);
> +			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
>  			libxfs_btree_init_block(mp, buf, XFS_BTNUM_FINO, 0, 0, agno, 0);
>  			libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  		}
> @@ -3530,7 +3664,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  				bsize);
>  			buf->b_ops = &xfs_rmapbt_buf_ops;
>  			block = XFS_BUF_TO_BLOCK(buf);
> -			memset(block, 0, blocksize);
> +			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
>  
>  			libxfs_btree_init_block(mp, buf, XFS_BTNUM_RMAP, 0, 0, agno, 0);
>  
> @@ -3606,7 +3740,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	 */
>  	buf = libxfs_getbuf(mp->m_ddev_targp,
>  		(xfs_daddr_t)XFS_FSB_TO_BB(mp, dblocks - 1LL), bsize);
> -	memset(XFS_BUF_PTR(buf), 0, blocksize);
> +	memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_B, B_SIZE));
>  	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  
>  	/*
> @@ -3615,14 +3749,14 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	if (mp->m_rtdev_targp->dev && rtblocks > 0) {
>  		buf = libxfs_getbuf(mp->m_rtdev_targp,
>  				XFS_FSB_TO_BB(mp, rtblocks - 1LL), bsize);
> -		memset(XFS_BUF_PTR(buf), 0, blocksize);
> +		memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_B, B_SIZE));
>  		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  	}
>  
>  	/*
>  	 * BNO, CNT free block list
>  	 */
> -	for (agno = 0; agno < agcount; agno++) {
> +	for (agno = 0; agno < get_conf_val(OPT_D, D_AGCOUNT); agno++) {
>  		xfs_alloc_arg_t	args;
>  		xfs_trans_t	*tp;
>  		struct xfs_trans_res tres = {0};
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] mkfs: replace variables with opts table: -i options
  2017-08-11 12:30 ` [PATCH 3/6] mkfs: replace variables with opts table: -i options Jan Tulak
@ 2017-08-14 23:31   ` Darrick J. Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2017-08-14 23:31 UTC (permalink / raw)
  To: Jan Tulak; +Cc: linux-xfs

On Fri, Aug 11, 2017 at 02:30:55PM +0200, Jan Tulak wrote:
> Remove variables that can be replaced with a direct access to the opts
> table, so we have it all in a single place, accessible from anywhere.
> 
> In future, we can remove some instances where we are passing values as
> arguments to helper functions, when we have the values in the opts
> struct and could pass only the struct.  But for now, limit the changes
> to simple replacement without any change in the logic.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  mkfs/xfs_mkfs.c | 96 +++++++++++++++++++++++++++++----------------------------
>  1 file changed, 49 insertions(+), 47 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 7f7f4554..66ba2869 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1689,13 +1689,9 @@ main(
>  	bool			force_overwrite;
>  	struct fsxattr		fsx;
>  	int			ilflag;
> -	int			imaxpct;
>  	int			imflag;
> -	int			inodelog;
> -	int			inopblock;
>  	int			ipflag;
>  	int			isflag;
> -	int			isize;
>  	char			*label = NULL;
>  	int			laflag;
>  	int			lalign;
> @@ -1780,8 +1776,7 @@ main(
>  	logagno = logblocks = rtblocks = rtextblocks = 0;
>  	Nflag = nlflag = nsflag = nvflag = 0;
>  	dirblocklog = dirblocksize = 0;
> -	qflag = 0;
> -	imaxpct = inodelog = inopblock = isize = 0;
> +	qflag = false;
>  	dfile = logfile = rtfile = NULL;
>  	protofile = NULL;
>  	rtbytes = rtextbytes = logbytes = 0;
> @@ -1926,27 +1921,22 @@ main(
>  							       value);
>  					break;
>  				case I_LOG:
> -					inodelog = parse_conf_val(OPT_I, I_LOG,
> -								  value);
> -					isize = 1 << inodelog;
> +					parse_conf_val(OPT_I, I_LOG,
> +							     value);
>  					ilflag = 1;
>  					break;
>  				case I_MAXPCT:
> -					imaxpct = parse_conf_val(OPT_I,
> -								 I_MAXPCT,
> -								 value);
> +					parse_conf_val(OPT_I, I_MAXPCT, value);
>  					imflag = 1;
>  					break;
>  				case I_PERBLOCK:
> -					inopblock = parse_conf_val(OPT_I,
> -								   I_PERBLOCK,
> -								   value);
> +					parse_conf_val(OPT_I, I_PERBLOCK,
> +						       value);
>  					ipflag = 1;
>  					break;
>  				case I_SIZE:
> -					isize = parse_conf_val(OPT_I, I_SIZE,
> +					parse_conf_val(OPT_I, I_SIZE,
>  							       value);
> -					inodelog = libxfs_highbit32(isize);
>  					isflag = 1;
>  					break;
>  				case I_ATTR:
> @@ -2398,7 +2388,8 @@ _("block size %lld cannot be smaller than logical sector size %d\n"),
>  	 */
>  	if (sb_feat.crcs_enabled) {
>  		/* minimum inode size is 512 bytes, ipflag checked later */
> -		if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) {
> +		if ((isflag || ilflag) &&
> +		    get_conf_val(OPT_I, I_LOG) < XFS_DINODE_DFL_CRC_LOG) {
>  			fprintf(stderr,
>  _("Minimum inode size for CRCs is %d bytes\n"),
>  				1 << XFS_DINODE_DFL_CRC_LOG);
> @@ -2522,15 +2513,17 @@ _("rmapbt not supported with realtime devices\n"));
>  					   get_conf_val(OPT_B, B_LOG)));
>  	}
>  	if (ipflag) {
> -		inodelog = get_conf_val(OPT_B, B_LOG) -
> -			libxfs_highbit32(inopblock);
> -		isize = 1 << inodelog;
> +		set_conf_val(OPT_I, I_LOG, get_conf_val(OPT_B, B_LOG) -
> +			libxfs_highbit32(get_conf_val(OPT_I, I_PERBLOCK)));
> +		set_conf_val(OPT_I, I_SIZE, 1 << get_conf_val(OPT_I, I_LOG));
>  	} else if (!ilflag && !isflag) {
> -		inodelog = sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
> -						: XFS_DINODE_DFL_LOG;
> -		isize = 1 << inodelog;
> +		set_conf_val(OPT_I, I_LOG,
> +			     sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
> +						: XFS_DINODE_DFL_LOG);
> +		set_conf_val(OPT_I, I_SIZE, 1 << get_conf_val(OPT_I, I_LOG));
>  	}
> -	if (sb_feat.crcs_enabled && inodelog < XFS_DINODE_DFL_CRC_LOG) {
> +	if (sb_feat.crcs_enabled && get_conf_val(OPT_I, I_LOG) <
> +	    XFS_DINODE_DFL_CRC_LOG) {
>  		fprintf(stderr,
>  		_("Minimum inode size for CRCs is %d bytes\n"),
>  			1 << XFS_DINODE_DFL_CRC_LOG);
> @@ -2617,12 +2610,14 @@ _("rmapbt not supported with realtime devices\n"));
>  	/*
>  	 * Check some argument sizes against mins, maxes.
>  	 */
> -	if (isize > get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
> -	    isize < XFS_DINODE_MIN_SIZE ||
> -	    isize > XFS_DINODE_MAX_SIZE) {
> +	if (get_conf_val(OPT_I, I_SIZE) >
> +	    get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
> +	    get_conf_val(OPT_I, I_SIZE) < XFS_DINODE_MIN_SIZE ||
> +	    get_conf_val(OPT_I, I_SIZE) > XFS_DINODE_MAX_SIZE) {
>  		int	maxsz;
>  
> -		fprintf(stderr, _("illegal inode size %d\n"), isize);
> +		fprintf(stderr, _("illegal inode size %lld\n"),
> +			get_conf_val(OPT_I, I_SIZE));
>  		maxsz = MIN(get_conf_val(OPT_B, B_SIZE) /
>  			    XFS_MIN_INODE_PERBLOCK,
>  			    XFS_DINODE_MAX_SIZE);
> @@ -3034,8 +3029,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  			     get_conf_val(OPT_D, D_AGCOUNT));
>  
>  	if (!imflag)
> -		imaxpct = calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
> -					       dblocks);
> +		set_conf_val(OPT_I, I_MAXPCT,
> +			     calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
> +					       dblocks));
>  
>  	/*
>  	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
> @@ -3068,7 +3064,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  				   sb_feat.crcs_enabled, sb_feat.dir_version,
>  				   get_conf_val(OPT_D, D_SECTLOG),
>  				   get_conf_val(OPT_B, B_LOG),
> -				   inodelog, dirblocklog,
> +				   get_conf_val(OPT_I, I_LOG), dirblocklog,
>  				   sb_feat.log_version, lsunit, sb_feat.finobt,
>  				   sb_feat.rmapbt, sb_feat.reflink,
>  				   sb_feat.inode_align);
> @@ -3227,29 +3223,32 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  
>  	if (!qflag || Nflag) {
>  		printf(_(
> -		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
> +		   "meta-data=%-22s isize=%-6lld agcount=%lld, agsize=%lld blks\n"
>  		   "         =%-22s sectsz=%-5lld attr=%u, projid32bit=%u\n"
>  		   "         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u, reflink=%u\n"
> -		   "data     =%-22s bsize=%-6lld blocks=%llu, imaxpct=%u\n"
> -		   "         =%-22s sunit=%-6lld swidth=%lld blks\n"
> -		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
> +		   "data     =%-22s bsize=%-6llu blocks=%lld, imaxpct=%lld\n"
> +		   "         =%-22s sunit=%-6llu swidth=%lld blks\n"
> +		   "naming   =version %-14u bsize=%-6llu ascii-ci=%d ftype=%d\n"
>  		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
> -		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
> +		   "         =%-22s sectsz=%-5lld sunit=%lld blks, lazy-count=%d\n"
>  		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
> -			dfile, isize, get_conf_val(OPT_D, D_AGCOUNT),
> +			dfile, get_conf_val(OPT_I, I_SIZE),
> +			get_conf_val(OPT_D, D_AGCOUNT),
>  			get_conf_val(OPT_D, D_AGSIZE),
>  			"", get_conf_val(OPT_D, D_SECTSIZE),
>  			sb_feat.attr_version,
>  				    !sb_feat.projid16bit,
>  			"", sb_feat.crcs_enabled, sb_feat.finobt, sb_feat.spinodes,
>  			sb_feat.rmapbt, sb_feat.reflink,
> -			"", get_conf_val(OPT_B, B_SIZE), (long long)dblocks, imaxpct,
> +			"", get_conf_val(OPT_B, B_SIZE),
> +			(long long)dblocks,
> +			get_conf_val(OPT_I, I_MAXPCT),
>  			"", get_conf_val(OPT_D, D_SUNIT),
>  			get_conf_val(OPT_D, D_SWIDTH),
> -			sb_feat.dir_version, dirblocksize, sb_feat.nci,
> +			sb_feat.dir_version, (long long)dirblocksize, sb_feat.nci,
>  				sb_feat.dirftype,
>  			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
> -			sb_feat.log_version, "", lsectorsize, lsunit,
> +			sb_feat.log_version, "", (long long)lsectorsize, (long long)lsunit,
>  				sb_feat.lazy_sb_counters,
>  			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
>  			(long long)rtblocks, (long long)rtextents);
> @@ -3274,16 +3273,18 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_rbmblocks = nbmblocks;
>  	sbp->sb_logblocks = (xfs_extlen_t)logblocks;
>  	sbp->sb_sectsize = (uint16_t)get_conf_val(OPT_D, D_SECTSIZE);
> -	sbp->sb_inodesize = (uint16_t)isize;
> -	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) / isize);
> +	sbp->sb_inodesize = (uint16_t)get_conf_val(OPT_I, I_SIZE);
> +	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) /
> +					 get_conf_val(OPT_I, I_SIZE));
>  	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
> -	sbp->sb_inodelog = (uint8_t)inodelog;
> -	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) - inodelog);
> +	sbp->sb_inodelog = (uint8_t)get_conf_val(OPT_I, I_LOG);
> +	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) -
> +				       get_conf_val(OPT_I, I_LOG));
>  	sbp->sb_rextslog =
>  		(uint8_t)(rtextents ?
>  			libxfs_highbit32((unsigned int)rtextents) : 0);
>  	sbp->sb_inprogress = 1;	/* mkfs is in progress */
> -	sbp->sb_imax_pct = imaxpct;
> +	sbp->sb_imax_pct = get_conf_val(OPT_I, I_MAXPCT);
>  	sbp->sb_icount = 0;
>  	sbp->sb_ifree = 0;
>  	sbp->sb_fdblocks = dblocks -
> @@ -3303,7 +3304,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	if (sb_feat.inode_align) {
>  		int	cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
>  		if (sb_feat.crcs_enabled)
> -			cluster_size *= isize / XFS_DINODE_MIN_SIZE;
> +			cluster_size *= get_conf_val(OPT_I, I_SIZE) /
> +				XFS_DINODE_MIN_SIZE;
>  		sbp->sb_inoalignmt = cluster_size >> get_conf_val(OPT_B, B_LOG);
>  		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
>  	} else
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] mkfs: replace variables with opts table: -l options
  2017-08-11 12:30 ` [PATCH 4/6] mkfs: replace variables with opts table: -l options Jan Tulak
@ 2017-08-14 23:34   ` Darrick J. Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2017-08-14 23:34 UTC (permalink / raw)
  To: Jan Tulak; +Cc: linux-xfs

On Fri, Aug 11, 2017 at 02:30:56PM +0200, Jan Tulak wrote:
> Remove variables that can be replaced with a direct access to the opts
> table, so we have it all in a single place, accessible from anywhere.
> 
> In future, we can remove some instances where we are passing values as
> arguments to helper functions, when we have the values in the opts
> struct and could pass only the struct.  But for now, limit the changes
> to simple replacement without any change in the logic.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  mkfs/xfs_mkfs.c | 258 +++++++++++++++++++++++++++++---------------------------
>  1 file changed, 134 insertions(+), 124 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 66ba2869..4e85694f 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -448,6 +448,7 @@ struct opt_params {
>  			  .minval = 0,
>  			  .maxval = 1,
>  			  .flagval = 1,
> +			  .value = 1,
>  			},
>  			{ .index = L_SIZE,
>  			  .conflicts = { LAST_CONFLICT },
> @@ -1121,7 +1122,8 @@ parse_conf_val(int opt, int subopt, char *value)
>  }
>  
>  /*
> - * Convert lsu to lsunit for 512 bytes blocks and check validity of the values.
> + * Convert L_SU to L_SUNIT for 512 bytes blocks and check validity of the
> + * values.
>   */
>  static void
>  calc_stripe_factors(
> @@ -1173,7 +1175,7 @@ calc_stripe_factors(
>  	if (lsu)
>  		*lsunit = (int)BTOBBT(lsu);
>  
> -	/* verify if lsu/lsunit is a multiple block size */
> +	/* verify if L_SU/L_SUNIT is a multiple block size */
>  	if (lsu % get_conf_val(OPT_B, B_SIZE) != 0) {
>  		fprintf(stderr,
>  _("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
> @@ -1697,22 +1699,15 @@ main(
>  	int			lalign;
>  	int			ldflag;
>  	int			liflag;
> -	xfs_agnumber_t		logagno;
>  	xfs_rfsblock_t		logblocks;
>  	char			*logfile;
> -	int			loginternal;
> -	uint64_t		logbytes;
>  	xfs_fsblock_t		logstart;
>  	int			lvflag;
>  	int			lsflag;
>  	int			lsuflag;
>  	int			lsunitflag;
> -	int			lsectorlog;
> -	int			lsectorsize;
>  	int			lslflag;
>  	int			lssflag;
> -	int			lsu;
> -	int			lsunit;
>  	int			min_logblocks;
>  	xfs_mount_t		*mp;
>  	xfs_mount_t		mbuf;
> @@ -1767,20 +1762,17 @@ main(
>  	textdomain(PACKAGE);
>  
>  	blflag = bsflag = slflag = ssflag = lslflag = lssflag = 0;
> -	lsectorlog = 0;
> -	lsectorsize = 0;
>  	dasize = dblocks = 0;
>  	daflag = ilflag = imflag = ipflag = isflag = false;
>  	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
> -	loginternal = 1;
> -	logagno = logblocks = rtblocks = rtextblocks = 0;
> -	Nflag = nlflag = nsflag = nvflag = 0;
> +	logblocks = rtblocks = rtextblocks = 0;
> +	Nflag = nlflag = nsflag = nvflag = false;
>  	dirblocklog = dirblocksize = 0;
>  	qflag = false;
>  	dfile = logfile = rtfile = NULL;
>  	protofile = NULL;
> -	rtbytes = rtextbytes = logbytes = 0;
> -	lalign = lsu = lsunit = 0;
> +	rtbytes = rtextbytes = 0;
> +	lalign = 0;
>  	dsflag = norsflag = false;
>  	force_overwrite = false;
>  	worst_freelist = 0;
> @@ -1969,9 +1961,7 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case L_AGNUM:
> -					logagno = parse_conf_val(OPT_L,
> -								 L_AGNUM,
> -								 value);
> +					parse_conf_val(OPT_L, L_AGNUM, value);
>  					laflag = 1;
>  					break;
>  				case L_FILE:
> @@ -1980,20 +1970,16 @@ main(
>  								    value);
>  					break;
>  				case L_INTERNAL:
> -					loginternal =
> -						parse_conf_val(OPT_L,
> -							       L_INTERNAL,
> -							       value);
> +					parse_conf_val(OPT_L, L_INTERNAL,
> +						       value);
>  					liflag = 1;
>  					break;
>  				case L_SU:
> -					lsu = parse_conf_val(OPT_L, L_SU,
> -							     value);
> +					parse_conf_val(OPT_L, L_SU, value);
>  					lsuflag = 1;
>  					break;
>  				case L_SUNIT:
> -					lsunit = parse_conf_val(OPT_L, L_SUNIT,
> -								value);
> +					parse_conf_val(OPT_L, L_SUNIT, value);
>  					lsunitflag = 1;
>  					break;
>  				case L_NAME:
> @@ -2002,7 +1988,7 @@ main(
>  								L_NAME);
>  					xi.logname = logfile;
>  					ldflag = 1;
> -					loginternal = 0;
> +					set_conf_val(OPT_L, L_INTERNAL, 0);
>  					set_conf_val(OPT_L, L_NAME, 1);
>  					set_conf_val(OPT_L, L_DEV, 1);
>  					break;
> @@ -2014,24 +2000,18 @@ main(
>  					lvflag = 1;
>  					break;
>  				case L_SIZE:
> -					logbytes = parse_conf_val(OPT_L,
> -								  L_SIZE,
> -								  value);
> +					parse_conf_val(OPT_L, L_SIZE, value);
>  					break;
>  				case L_SECTLOG:
> -					lsectorlog = parse_conf_val(OPT_L,
> +					parse_conf_val(OPT_L,
>  								    L_SECTLOG,
>  								    value);
> -					lsectorsize = 1 << lsectorlog;
>  					lslflag = 1;
>  					break;
>  				case L_SECTSIZE:
> -					lsectorsize =
>  						parse_conf_val(OPT_L,
>  							       L_SECTSIZE,
>  							       value);
> -					lsectorlog =
> -						libxfs_highbit32(lsectorsize);
>  					lssflag = 1;
>  					break;
>  				case L_LAZYSBCNTR:
> @@ -2201,7 +2181,6 @@ main(
>  				char	**subopts =
>  						(char **)opts[OPT_S].subopts;
>  				char	*value;
> -				uint64_t tmp;
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case S_LOG:
> @@ -2210,12 +2189,8 @@ main(
>  						conflict('s', subopts,
>  							 S_SECTSIZE,
>  							 S_SECTLOG);
> -					tmp = parse_conf_val(OPT_S,
> -								   S_SECTLOG,
> -								   value);
> -
> -					lsectorlog = tmp;
> -					lsectorsize = tmp;
> +					parse_conf_val(OPT_S, S_SECTLOG,
> +							value);
>  					lslflag = slflag = 1;
>  					break;
>  				case S_SIZE:
> @@ -2224,12 +2199,8 @@ main(
>  						conflict('s', subopts,
>  							 S_SECTLOG,
>  							 S_SECTSIZE);
> -					tmp = parse_conf_val(OPT_S,
> -								    S_SECTSIZE,
> -								    value);
> -
> -					lsectorlog = libxfs_highbit32(tmp);
> -					lsectorsize = tmp;
> +					parse_conf_val(OPT_S, S_SECTSIZE,
> +							value);
>  					lssflag = ssflag = 1;
>  					break;
>  				default:
> @@ -2285,8 +2256,9 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  		set_conf_val(OPT_D, D_SECTSIZE, XFS_MIN_SECTORSIZE);
>  	}
>  	if (!lslflag && !lssflag) {
> -		lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
> -		lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
> +		set_conf_val(OPT_L, L_SECTLOG, get_conf_val(OPT_D, D_SECTLOG));
> +		set_conf_val(OPT_L, L_SECTSIZE,
> +			     get_conf_val(OPT_D, D_SECTSIZE));
>  	}
>  
>  	/*
> @@ -2299,8 +2271,9 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  	check_device_type(dfile, &xi.disfile, !get_conf_val(OPT_D, D_SIZE),
>  			  !dfile,
>  			  Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
> -	if (!loginternal)
> -		check_device_type(xi.logname, &xi.lisfile, !logbytes,
> +	if (!get_conf_val(OPT_L, L_INTERNAL))
> +		check_device_type(xi.logname, &xi.lisfile,
> +				  !get_conf_val(OPT_L, L_SIZE),
>  				  !xi.logname, Nflag ? NULL : &xi.lcreat,
>  				  force_overwrite, "l");
>  	if (xi.rtname)
> @@ -2348,9 +2321,11 @@ _("switching to logical sector size %d\n"),
>  	if (!ssflag) {
>  		set_conf_val(OPT_D, D_SECTLOG,
>  			     libxfs_highbit32(get_conf_val(OPT_D, D_SECTSIZE)));
> -		if (loginternal) {
> -			lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
> -			lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
> +		if (get_conf_val(OPT_L, L_INTERNAL)) {
> +			set_conf_val(OPT_L, L_SECTSIZE,
> +				     get_conf_val(OPT_D, D_SECTSIZE));
> +			set_conf_val(OPT_L, L_SECTLOG,
> +				     get_conf_val(OPT_D, D_SECTLOG));
>  		}
>  	}
>  
> @@ -2371,13 +2346,16 @@ _("block size %lld cannot be smaller than logical sector size %d\n"),
>  			get_conf_val(OPT_D, D_SECTSIZE), ft.lsectorsize);
>  		usage();
>  	}
> -	if (lsectorsize < XFS_MIN_SECTORSIZE ||
> -	    lsectorsize > XFS_MAX_SECTORSIZE ||
> -	    lsectorsize > get_conf_val(OPT_B, B_SIZE)) {
> -		fprintf(stderr, _("illegal log sector size %d\n"), lsectorsize);
> +	if (get_conf_val(OPT_L, L_SECTSIZE) < XFS_MIN_SECTORSIZE ||
> +	    get_conf_val(OPT_L, L_SECTSIZE) > XFS_MAX_SECTORSIZE ||
> +	    get_conf_val(OPT_L, L_SECTSIZE) > get_conf_val(OPT_B, B_SIZE)) {
> +		fprintf(stderr, _("illegal log sector size %lld\n"),
> +			get_conf_val(OPT_L, L_SECTSIZE));
>  		usage();
> -	} else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
> -		lsu = get_conf_val(OPT_B, B_SIZE);
> +	} else if (get_conf_val(OPT_L, L_SECTSIZE) > XFS_MIN_SECTORSIZE &&
> +		   !get_conf_val(OPT_L, L_SU) &&
> +		   !get_conf_val(OPT_L, L_SUNIT)) {
> +		set_conf_val(OPT_L, L_SU, get_conf_val(OPT_B, B_SIZE));
>  		sb_feat.log_version = 2;
>  	}
>  
> @@ -2530,19 +2508,20 @@ _("rmapbt not supported with realtime devices\n"));
>  		usage();
>  	}
>  
> -	if (logbytes) {
> -		if (logbytes % XFS_MIN_BLOCKSIZE) {
> +	if (get_conf_val(OPT_L, L_SIZE)) {
> +		if (get_conf_val(OPT_L, L_SIZE) % XFS_MIN_BLOCKSIZE) {
>  			fprintf(stderr,
>  			_("illegal log length %lld, not a multiple of %d\n"),
> -				(long long)logbytes, XFS_MIN_BLOCKSIZE);
> +				get_conf_val(OPT_L, L_SIZE), XFS_MIN_BLOCKSIZE);
>  			usage();
>  		}
> -		logblocks = (xfs_rfsblock_t)(logbytes >>
> +		logblocks = (xfs_rfsblock_t)(get_conf_val(OPT_L, L_SIZE) >>
>  					     get_conf_val(OPT_B, B_LOG));
> -		if (logbytes % get_conf_val(OPT_B, B_SIZE))
> +		if (get_conf_val(OPT_L, L_SIZE) % get_conf_val(OPT_B, B_SIZE))
>  			fprintf(stderr,
>  	_("warning: log length %lld not a multiple of %lld, truncated to %lld\n"),
> -				(long long)logbytes, get_conf_val(OPT_B, B_SIZE),
> +				get_conf_val(OPT_L, L_SIZE),
> +				get_conf_val(OPT_B, B_SIZE),
>  				(long long)(logblocks <<
>  					   get_conf_val(OPT_B, B_LOG)));
>  	}
> @@ -2634,8 +2613,9 @@ _("rmapbt not supported with realtime devices\n"));
>  		exit(1);
>  	}
>  
> -	/* if lsu or lsunit was specified, automatically use v2 logs */
> -	if ((lsu || lsunit) && sb_feat.log_version == 1) {
> +	/* if L_SU or L_SUNIT was specified, automatically use v2 logs */
> +	if ((get_conf_val(OPT_L, L_SU) ||
> +	     get_conf_val(OPT_L, L_SUNIT)) && sb_feat.log_version == 1) {
>  		fprintf(stderr,
>  			_("log stripe unit specified, using v2 logs\n"));
>  		sb_feat.log_version = 2;
> @@ -2643,13 +2623,14 @@ _("rmapbt not supported with realtime devices\n"));
>  
>  	int dsunit = get_conf_val(OPT_D, D_SUNIT);
>  	int dswidth = get_conf_val(OPT_D, D_SWIDTH);
> +	int lsunit = get_conf_val(OPT_L, L_SUNIT);
>  
>  	calc_stripe_factors(get_conf_val(OPT_D, D_SU),
>  			    get_conf_val(OPT_D, D_SW),
>  			    get_conf_val(OPT_D, D_SECTSIZE),
> -			    lsu,
> -			    lsectorsize,
> -				&dsunit, &dswidth, &lsunit);
> +			    get_conf_val(OPT_L, L_SU),
> +			    get_conf_val(OPT_L, L_SECTSIZE),
> +			    &dsunit, &dswidth, &lsunit);
>  
>  	/* If sunit & swidth were manually specified as 0, same as noalign */
>  	if (dsflag && !dsunit && !dswidth)
> @@ -2657,6 +2638,7 @@ _("rmapbt not supported with realtime devices\n"));
>  
>  	set_conf_val(OPT_D, D_SUNIT, dsunit);
>  	set_conf_val(OPT_D, D_SWIDTH, dswidth);
> +	set_conf_val(OPT_L, L_SUNIT, lsunit);
>  
>  	xi.setblksize = get_conf_val(OPT_D, D_SECTSIZE);
>  
> @@ -2685,7 +2667,8 @@ _("rmapbt not supported with realtime devices\n"));
>  		(MAX(get_conf_val(OPT_D, D_SECTLOG), 10) - BBSHIFT);
>  	xi.dsize &= sector_mask;
>  	xi.rtsize &= sector_mask;
> -	xi.logBBsize &= (uint64_t)-1 << (MAX(lsectorlog, 10) - BBSHIFT);
> +	xi.logBBsize &= (uint64_t)-1 << (MAX(get_conf_val(OPT_L, L_SECTLOG),
> +					     10) - BBSHIFT);
>  
>  
>  	/* don't do discards on print-only runs or on files */
> @@ -2699,10 +2682,10 @@ _("rmapbt not supported with realtime devices\n"));
>  	}
>  
>  	if (!liflag && !ldflag)
> -		loginternal = xi.logdev == 0;
> +		set_conf_val(OPT_L, L_INTERNAL, xi.logdev == 0);
>  	if (xi.logname)
>  		logfile = xi.logname;
> -	else if (loginternal)
> +	else if (get_conf_val(OPT_L, L_INTERNAL))
>  		logfile = _("internal log");
>  	else if (xi.volname && xi.logdev)
>  		logfile = _("volume log");
> @@ -2738,12 +2721,13 @@ _("rmapbt not supported with realtime devices\n"));
>  		usage();
>  	}
>  
> -	if (loginternal && xi.logdev) {
> +	if (get_conf_val(OPT_L, L_INTERNAL) && xi.logdev) {
>  		fprintf(stderr,
>  			_("can't have both external and internal logs\n"));
>  		usage();
> -	} else if (loginternal &&
> -		   get_conf_val(OPT_D, D_SECTSIZE) != lsectorsize) {
> +	} else if (get_conf_val(OPT_L, L_INTERNAL) &&
> +		   get_conf_val(OPT_D, D_SECTSIZE) !=
> +		   get_conf_val(OPT_L, L_SECTSIZE)) {
>  		fprintf(stderr,
>  	_("data and log sector sizes must be equal for internal logs\n"));
>  		usage();
> @@ -2755,11 +2739,12 @@ _("rmapbt not supported with realtime devices\n"));
>  reported by the device (%u).\n"),
>  			get_conf_val(OPT_D, D_SECTSIZE), xi.dbsize);
>  	}
> -	if (!loginternal && xi.lbsize > lsectorsize) {
> +	if (!get_conf_val(OPT_L, L_INTERNAL) &&
> +	    xi.lbsize > get_conf_val(OPT_L, L_SECTSIZE)) {
>  		fprintf(stderr, _(
> -"Warning: the log subvolume sector size %u is less than the sector size\n\
> +"Warning: the log subvolume sector size %lld is less than the sector size\n\
>  reported by the device (%u).\n"),
> -			lsectorsize, xi.lbsize);
> +			get_conf_val(OPT_L, L_SECTSIZE), xi.lbsize);
>  	}
>  	if (rtbytes && xi.rtsize > 0 &&
>  	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
> @@ -3037,27 +3022,31 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
>  	 */
>  
> -	if (lsunit) {
> +	if (get_conf_val(OPT_L, L_SUNIT)) {
>  		/* convert from 512 byte blocks to fs blocks */
> -		lsunit = DTOBT(lsunit);
> +		set_conf_val(OPT_L, L_SUNIT,
> +			     DTOBT(get_conf_val(OPT_L, L_SUNIT)));
>  	} else if (sb_feat.log_version == 2 &&
> -		   loginternal &&
> +		   get_conf_val(OPT_L, L_INTERNAL) &&
>  		   get_conf_val(OPT_D, D_SUNIT)) {
> -		/* lsunit and get_conf_val(OPT_D, D_SUNIT) now in fs blocks */
> -		lsunit = get_conf_val(OPT_D, D_SUNIT);
> +		/* L_SUNIT and D_SUNIT now in fs blocks */
> +		set_conf_val(OPT_L, L_SUNIT, get_conf_val(OPT_D, D_SUNIT));
>  	}
>  
>  	if (sb_feat.log_version == 2 &&
> -	    (lsunit * get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
> +	    (get_conf_val(OPT_L, L_SUNIT) *
> +	     get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
>  		/* Warn only if specified on commandline */
>  		if (lsuflag || lsunitflag) {
>  			fprintf(stderr,
>  	_("log stripe unit (%lld bytes) is too large (maximum is 256KiB)\n"),
> -				(lsunit * get_conf_val(OPT_B, B_SIZE)));
> +				(get_conf_val(OPT_L, L_SUNIT) *
> +				 get_conf_val(OPT_B, B_SIZE)));
>  			fprintf(stderr,
>  	_("log stripe unit adjusted to 32KiB\n"));
>  		}
> -		lsunit = (32 * 1024) >> get_conf_val(OPT_B, B_LOG);
> +		set_conf_val(OPT_L, L_SUNIT,
> +			     (32 * 1024) >> get_conf_val(OPT_B, B_LOG));
>  	}
>  
>  	min_logblocks = max_trans_res(get_conf_val(OPT_D, D_AGSIZE),
> @@ -3065,35 +3054,41 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  				   get_conf_val(OPT_D, D_SECTLOG),
>  				   get_conf_val(OPT_B, B_LOG),
>  				   get_conf_val(OPT_I, I_LOG), dirblocklog,
> -				   sb_feat.log_version, lsunit, sb_feat.finobt,
> +				   sb_feat.log_version,
> +				   get_conf_val(OPT_L, L_SUNIT),
> +				   sb_feat.finobt,
>  				   sb_feat.rmapbt, sb_feat.reflink,
>  				   sb_feat.inode_align);
>  	ASSERT(min_logblocks);
>  	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
> -	if (!logbytes &&
> +	if (!get_conf_val(OPT_L, L_SIZE) &&
>  	    dblocks >= (1024*1024*1024) >> get_conf_val(OPT_B, B_LOG))
>  		min_logblocks = MAX(min_logblocks,
>  				    XFS_MIN_LOG_BYTES >>
>  				    get_conf_val(OPT_B, B_LOG));
> -	if (logbytes && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
> +	if (get_conf_val(OPT_L, L_SIZE) && xi.logBBsize > 0 &&
> +	    logblocks > DTOBT(xi.logBBsize)) {
>  		fprintf(stderr,
>  _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  			get_conf_raw_safe(OPT_L, L_SIZE),
>  			(long long)DTOBT(xi.logBBsize));
>  		usage();
> -	} else if (!logbytes && xi.logBBsize > 0) {
> +	} else if (!get_conf_val(OPT_L, L_SIZE) && xi.logBBsize > 0) {
>  		logblocks = DTOBT(xi.logBBsize);
> -	} else if (logbytes && !xi.logdev && !loginternal) {
> +	} else if (get_conf_val(OPT_L, L_SIZE) && !xi.logdev &&
> +		   !get_conf_val(OPT_L, L_INTERNAL)) {
>  		fprintf(stderr,
>  			_("size specified for non-existent log subvolume\n"));
>  		usage();
> -	} else if (loginternal && logbytes && logblocks >= dblocks) {
> +	} else if (get_conf_val(OPT_L, L_INTERNAL) &&
> +		   get_conf_val(OPT_L, L_SIZE) && logblocks >= dblocks) {
>  		fprintf(stderr, _("size %lld too large for internal log\n"),
>  			(long long)logblocks);
>  		usage();
> -	} else if (!loginternal && !xi.logdev) {
> +	} else if (!get_conf_val(OPT_L, L_INTERNAL) && !xi.logdev) {
>  		logblocks = 0;
> -	} else if (loginternal && !logbytes) {
> +	} else if (get_conf_val(OPT_L, L_INTERNAL) &&
> +		   !get_conf_val(OPT_L, L_SIZE)) {
>  
>  		if (dblocks < GIGABYTES(1, get_conf_val(OPT_B, B_LOG))) {
>  			/* tiny filesystems get minimum sized logs. */
> @@ -3157,16 +3152,16 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	 */
>  	sb_set_features(&mp->m_sb, &sb_feat,
>  			get_conf_val(OPT_D, D_SECTSIZE),
> -			lsectorsize,
> +			get_conf_val(OPT_L, L_SECTSIZE),
>  			get_conf_val(OPT_D, D_SUNIT));
>  
>  
> -	if (loginternal) {
> +	if (get_conf_val(OPT_L, L_INTERNAL)) {
>  		/*
>  		 * Readjust the log size to fit within an AG if it was sized
>  		 * automatically.
>  		 */
> -		if (!logbytes) {
> +		if (!get_conf_val(OPT_L, L_SIZE)) {
>  			logblocks = MIN(logblocks,
>  					libxfs_alloc_ag_max_usable(mp));
>  
> @@ -3184,25 +3179,28 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		}
>  
>  		if (laflag) {
> -			if (logagno >= get_conf_val(OPT_D, D_AGCOUNT)) {
> +			if (get_conf_val(OPT_L, L_AGNUM) >=
> +			    get_conf_val(OPT_D, D_AGCOUNT)) {
>  				fprintf(stderr,
> -		_("log ag number %d too large, must be less than %lld\n"),
> -					logagno,
> +	_("log ag number %lld too large, must be less than %lld\n"),
> +					get_conf_val(OPT_L, L_AGNUM),
>  					get_conf_val(OPT_D, D_AGCOUNT));
>  				usage();
>  			}
>  		} else
> -			logagno = (xfs_agnumber_t)(
> -					get_conf_val(OPT_D, D_AGCOUNT) / 2);
> +			set_conf_val(OPT_L, L_AGNUM, (xfs_agnumber_t)(
> +					get_conf_val(OPT_D, D_AGCOUNT) / 2));
>  
> -		logstart = XFS_AGB_TO_FSB(mp, logagno, libxfs_prealloc_blocks(mp));
> +		logstart = XFS_AGB_TO_FSB(mp, get_conf_val(OPT_L, L_AGNUM),
> +					  libxfs_prealloc_blocks(mp));
>  		/*
>  		 * Align the logstart at stripe unit boundary.
>  		 */
> -		if (lsunit) {
> +		if (get_conf_val(OPT_L, L_SUNIT)) {
>  			logstart = fixup_internal_log_stripe(mp,
>  					lsflag, logstart,
> -					get_conf_val(OPT_D, D_AGSIZE), lsunit,
> +					get_conf_val(OPT_D, D_AGSIZE),
> +					get_conf_val(OPT_L, L_SUNIT),
>  					&logblocks,
>  					get_conf_val(OPT_B, B_LOG), &lalign);
>  		} else if (get_conf_val(OPT_D, D_SUNIT)) {
> @@ -3215,8 +3213,9 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		}
>  	} else {
>  		logstart = 0;
> -		if (lsunit)
> -			fixup_log_stripe_unit(lsflag, lsunit,
> +		if (get_conf_val(OPT_L, L_SUNIT))
> +			fixup_log_stripe_unit(lsflag,
> +					      get_conf_val(OPT_L, L_SUNIT),
>  					&logblocks, get_conf_val(OPT_B, B_LOG));
>  	}
>  	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
> @@ -3248,7 +3247,9 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  			sb_feat.dir_version, (long long)dirblocksize, sb_feat.nci,
>  				sb_feat.dirftype,
>  			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
> -			sb_feat.log_version, "", (long long)lsectorsize, (long long)lsunit,
> +			sb_feat.log_version, "",
> +			get_conf_val(OPT_L, L_SECTSIZE),
> +			get_conf_val(OPT_L, L_SUNIT),
>  				sb_feat.lazy_sb_counters,
>  			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
>  			(long long)rtblocks, (long long)rtextents);
> @@ -3289,7 +3290,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_ifree = 0;
>  	sbp->sb_fdblocks = dblocks -
>  		get_conf_val(OPT_D, D_AGCOUNT) * libxfs_prealloc_blocks(mp) -
> -		(loginternal ? logblocks : 0);
> +		(get_conf_val(OPT_L, L_INTERNAL) ? logblocks : 0);
>  	sbp->sb_frextents = 0;	/* will do a free later */
>  	sbp->sb_uquotino = sbp->sb_gquotino = sbp->sb_pquotino = 0;
>  	sbp->sb_qflags = 0;
> @@ -3297,8 +3298,11 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
>  	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
>  	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
> -		lsunit = (lsunit == 0) ? 1 : XFS_FSB_TO_B(mp, lsunit);
> -		sbp->sb_logsunit = lsunit;
> +		set_conf_val(OPT_L, L_SUNIT,
> +			     (get_conf_val(OPT_L, L_SUNIT) == 0) ?
> +			     1 : XFS_FSB_TO_B(mp,
> +					      get_conf_val(OPT_L, L_SUNIT)));
> +		sbp->sb_logsunit = get_conf_val(OPT_L, L_SUNIT);
>  	} else
>  		sbp->sb_logsunit = 0;
>  	if (sb_feat.inode_align) {
> @@ -3310,10 +3314,11 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
>  	} else
>  		sbp->sb_inoalignmt = 0;
> -	if (lsectorsize != BBSIZE ||
> +	if (get_conf_val(OPT_L, L_SECTSIZE) != BBSIZE ||
>  	    get_conf_val(OPT_D, D_SECTSIZE) != BBSIZE) {
> -		sbp->sb_logsectlog = (uint8_t)lsectorlog;
> -		sbp->sb_logsectsize = (uint16_t)lsectorsize;
> +		sbp->sb_logsectlog = (uint8_t)get_conf_val(OPT_L, L_SECTLOG);
> +		sbp->sb_logsectsize =
> +			(uint16_t)get_conf_val(OPT_L, L_SECTSIZE);
>  	} else {
>  		sbp->sb_logsectlog = 0;
>  		sbp->sb_logsectsize = 0;
> @@ -3321,7 +3326,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  
>  	sb_set_features(&mp->m_sb, &sb_feat,
>  			get_conf_val(OPT_D, D_SECTSIZE),
> -			lsectorsize,
> +			get_conf_val(OPT_L, L_SECTSIZE),
>  			get_conf_val(OPT_D, D_SUNIT));
>  
>  	if (force_overwrite)
> @@ -3383,7 +3388,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	libxfs_log_clear(mp->m_logdev_targp, NULL,
>  		XFS_FSB_TO_DADDR(mp, logstart),
>  		(xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
> -		&sbp->sb_uuid, sb_feat.log_version, lsunit, XLOG_FMT, XLOG_INIT_CYCLE, false);
> +		&sbp->sb_uuid, sb_feat.log_version,
> +		get_conf_val(OPT_L, L_SUNIT), XLOG_FMT, XLOG_INIT_CYCLE, false);
>  
>  	mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 0);
>  	if (mp == NULL) {
> @@ -3460,7 +3466,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  		if (xfs_sb_version_hascrc(&mp->m_sb))
>  			platform_uuid_copy(&agf->agf_uuid, &mp->m_sb.sb_uuid);
>  
> -		if (loginternal && agno == logagno) {
> +		if (get_conf_val(OPT_L, L_INTERNAL) &&
> +		    agno == get_conf_val(OPT_L, L_AGNUM)) {
>  			be32_add_cpu(&agf->agf_freeblks, -logblocks);
>  			agf->agf_longest =
>  				cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
> @@ -3534,7 +3541,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  
>  		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
>  		arec->ar_startblock = cpu_to_be32(libxfs_prealloc_blocks(mp));
> -		if (loginternal && agno == logagno) {
> +		if (get_conf_val(OPT_L, L_INTERNAL) &&
> +		    agno == get_conf_val(OPT_L, L_AGNUM)) {
>  			if (lalign) {
>  				/*
>  				 * Have to insert two records
> @@ -3585,7 +3593,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  
>  		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
>  		arec->ar_startblock = cpu_to_be32(libxfs_prealloc_blocks(mp));
> -		if (loginternal && agno == logagno) {
> +		if (get_conf_val(OPT_L, L_INTERNAL) &&
> +		    agno == get_conf_val(OPT_L, L_AGNUM)) {
>  			if (lalign) {
>  				arec->ar_blockcount = cpu_to_be32(
>  					XFS_FSB_TO_AGBNO(mp, logstart) -
> @@ -3720,7 +3729,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  			}
>  
>  			/* account for the log space */
> -			if (loginternal && agno == logagno) {
> +			if (get_conf_val(OPT_L, L_INTERNAL) && agno ==
> +			    get_conf_val(OPT_L, L_AGNUM)) {
>  				rrec = XFS_RMAP_REC_ADDR(block,
>  					be16_to_cpu(block->bb_numrecs) + 1);
>  				rrec->rm_startblock = cpu_to_be32(
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/6] mkfs: replace variables with opts table: -n options
  2017-08-11 12:30 ` [PATCH 5/6] mkfs: replace variables with opts table: -n options Jan Tulak
@ 2017-08-14 23:34   ` Darrick J. Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2017-08-14 23:34 UTC (permalink / raw)
  To: Jan Tulak; +Cc: linux-xfs

On Fri, Aug 11, 2017 at 02:30:57PM +0200, Jan Tulak wrote:
> Remove variables that can be replaced with a direct access to the opts
> table, so we have it all in a single place, accessible from anywhere.
> 
> In future, we can remove some instances where we are passing values as
> arguments to helper functions, when we have the values in the opts
> struct and could pass only the struct.  But for now, limit the changes
> to simple replacement without any change in the logic.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  mkfs/xfs_mkfs.c | 34 ++++++++++++++++------------------
>  1 file changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 4e85694f..51c1a794 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1685,8 +1685,6 @@ main(
>  	int			dasize;
>  	xfs_rfsblock_t		dblocks;
>  	char			*dfile;
> -	int			dirblocklog;
> -	int			dirblocksize;
>  	int			dsflag;
>  	bool			force_overwrite;
>  	struct fsxattr		fsx;
> @@ -1767,7 +1765,6 @@ main(
>  	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
>  	logblocks = rtblocks = rtextblocks = 0;
>  	Nflag = nlflag = nsflag = nvflag = false;
> -	dirblocklog = dirblocksize = 0;
>  	qflag = false;
>  	dfile = logfile = rtfile = NULL;
>  	protofile = NULL;
> @@ -2082,18 +2079,15 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case N_LOG:
> -					dirblocklog = parse_conf_val(OPT_N,
> +					parse_conf_val(OPT_N,
>  								     N_LOG,
>  								     value);
> -					dirblocksize = 1 << dirblocklog;
>  					nlflag = 1;
>  					break;
>  				case N_SIZE:
> -					dirblocksize = parse_conf_val(OPT_N,
> +					parse_conf_val(OPT_N,
>  								      N_SIZE,
>  								      value);
> -					dirblocklog =
> -						libxfs_highbit32(dirblocksize);
>  					nsflag = 1;
>  					break;
>  				case N_VERSION:
> @@ -2458,18 +2452,19 @@ _("rmapbt not supported with realtime devices\n"));
>  	}
>  
>  	if (nsflag || nlflag) {
> -		if (dirblocksize < get_conf_val(OPT_B, B_SIZE) ||
> -					dirblocksize > XFS_MAX_BLOCKSIZE) {
> -			fprintf(stderr, _("illegal directory block size %d\n"),
> -				dirblocksize);
> +		if (get_conf_val(OPT_N, N_SIZE) <
> +		    get_conf_val(OPT_B, B_SIZE) ||
> +		    get_conf_val(OPT_N, N_SIZE) > XFS_MAX_BLOCKSIZE) {
> +			fprintf(stderr, _("illegal directory block size %lld\n"),
> +				get_conf_val(OPT_N, N_SIZE));
>  			usage();
>  		}
>  	} else {
>  		if (get_conf_val(OPT_B, B_SIZE) < (1 << XFS_MIN_REC_DIRSIZE))
> -			dirblocklog = XFS_MIN_REC_DIRSIZE;
> +			set_conf_val(OPT_N, N_LOG, XFS_MIN_REC_DIRSIZE);
>  		else
> -			dirblocklog = get_conf_val(OPT_B, B_LOG);
> -		dirblocksize = 1 << dirblocklog;
> +			set_conf_val(OPT_N, N_LOG, get_conf_val(OPT_B, B_LOG));
> +		set_conf_val(OPT_N, N_SIZE, 1 << get_conf_val(OPT_N, N_LOG));
>  	}
>  
>  
> @@ -3053,7 +3048,8 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  				   sb_feat.crcs_enabled, sb_feat.dir_version,
>  				   get_conf_val(OPT_D, D_SECTLOG),
>  				   get_conf_val(OPT_B, B_LOG),
> -				   get_conf_val(OPT_I, I_LOG), dirblocklog,
> +				   get_conf_val(OPT_I, I_LOG),
> +				   get_conf_val(OPT_N, N_LOG),
>  				   sb_feat.log_version,
>  				   get_conf_val(OPT_L, L_SUNIT),
>  				   sb_feat.finobt,
> @@ -3244,7 +3240,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  			get_conf_val(OPT_I, I_MAXPCT),
>  			"", get_conf_val(OPT_D, D_SUNIT),
>  			get_conf_val(OPT_D, D_SWIDTH),
> -			sb_feat.dir_version, (long long)dirblocksize, sb_feat.nci,
> +			sb_feat.dir_version,
> +			get_conf_val(OPT_N, N_SIZE), sb_feat.nci,
>  				sb_feat.dirftype,
>  			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
>  			sb_feat.log_version, "",
> @@ -3296,7 +3293,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
>  	sbp->sb_qflags = 0;
>  	sbp->sb_unit = get_conf_val(OPT_D, D_SUNIT);
>  	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
> -	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
> +	sbp->sb_dirblklog = get_conf_val(OPT_N, N_LOG) -
> +		get_conf_val(OPT_B, B_LOG);
>  	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
>  		set_conf_val(OPT_L, L_SUNIT,
>  			     (get_conf_val(OPT_L, L_SUNIT) == 0) ?
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] mkfs: replace variables with opts table: -r options
  2017-08-11 12:30 ` [PATCH 6/6] mkfs: replace variables with opts table: -r options Jan Tulak
@ 2017-08-14 23:35   ` Darrick J. Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2017-08-14 23:35 UTC (permalink / raw)
  To: Jan Tulak; +Cc: linux-xfs

On Fri, Aug 11, 2017 at 02:30:58PM +0200, Jan Tulak wrote:
> Remove variables that can be replaced with a direct access to the opts
> table, so we have it all in a single place, accessible from anywhere.
> 
> In future, we can remove some instances where we are passing values as
> arguments to helper functions, when we have the values in the opts
> struct and could pass only the struct.  But for now, limit the changes
> to simple replacement without any change in the logic.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

Assuming this whole series isn't causing xfstest failures or build problems,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  mkfs/xfs_mkfs.c | 71 ++++++++++++++++++++++++++++++---------------------------
>  1 file changed, 37 insertions(+), 34 deletions(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 51c1a794..aeb62589 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1711,7 +1711,6 @@ main(
>  	xfs_mount_t		mbuf;
>  	xfs_extlen_t		nbmblocks;
>  	int			nlflag;
> -	int			norsflag;
>  	xfs_alloc_rec_t		*nrec;
>  	int			nsflag;
>  	int			nvflag;
> @@ -1722,10 +1721,8 @@ main(
>  	char			*protostring;
>  	int			qflag;
>  	xfs_rfsblock_t		rtblocks;
> -	uint64_t		rtbytes;
>  	xfs_extlen_t		rtextblocks;
>  	xfs_rtblock_t		rtextents;
> -	uint64_t		rtextbytes;
>  	char			*rtfile;
>  	xfs_sb_t		*sbp;
>  	uint64_t		sector_mask;
> @@ -1768,9 +1765,8 @@ main(
>  	qflag = false;
>  	dfile = logfile = rtfile = NULL;
>  	protofile = NULL;
> -	rtbytes = rtextbytes = 0;
>  	lalign = 0;
> -	dsflag = norsflag = false;
> +	dsflag = false;
>  	force_overwrite = false;
>  	worst_freelist = 0;
>  	memset(&fsx, 0, sizeof(fsx));
> @@ -2139,9 +2135,8 @@ main(
>  
>  				switch (getsubopt(&p, subopts, &value)) {
>  				case R_EXTSIZE:
> -					rtextbytes = parse_conf_val(OPT_R,
> -								    R_EXTSIZE,
> -								    value);
> +					parse_conf_val(OPT_R, R_EXTSIZE,
> +						       value);
>  					break;
>  				case R_FILE:
>  					xi.risfile = parse_conf_val(OPT_R,
> @@ -2156,13 +2151,11 @@ main(
>  					set_conf_val(OPT_R, R_DEV, 1);
>  					break;
>  				case R_SIZE:
> -					rtbytes = parse_conf_val(OPT_R, R_SIZE,
> -								 value);
> +					parse_conf_val(OPT_R, R_SIZE, value);
>  					break;
>  				case R_NOALIGN:
> -					norsflag = parse_conf_val(OPT_R,
> -								  R_NOALIGN,
> -								  value);
> +					parse_conf_val(OPT_R, R_NOALIGN,
> +						       value);
>  					break;
>  				default:
>  					unknown('r', value);
> @@ -2271,7 +2264,10 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
>  				  !xi.logname, Nflag ? NULL : &xi.lcreat,
>  				  force_overwrite, "l");
>  	if (xi.rtname)
> -		check_device_type(xi.rtname, &xi.risfile, !rtbytes, !xi.rtname,
> +		check_device_type(xi.rtname,
> +				  &xi.risfile,
> +				  !get_conf_val(OPT_R, R_SIZE),
> +				  !xi.rtname,
>  				  Nflag ? NULL : &xi.rcreat,
>  				  force_overwrite, "r");
>  	if (xi.disfile || xi.lisfile || xi.risfile)
> @@ -2520,33 +2516,36 @@ _("rmapbt not supported with realtime devices\n"));
>  				(long long)(logblocks <<
>  					   get_conf_val(OPT_B, B_LOG)));
>  	}
> -	if (rtbytes) {
> -		if (rtbytes % XFS_MIN_BLOCKSIZE) {
> +	if (get_conf_val(OPT_R, R_SIZE)) {
> +		if (get_conf_val(OPT_R, R_SIZE) % XFS_MIN_BLOCKSIZE) {
>  			fprintf(stderr,
>  			_("illegal rt length %lld, not a multiple of %d\n"),
> -				(long long)rtbytes, XFS_MIN_BLOCKSIZE);
> +				get_conf_val(OPT_R, R_SIZE), XFS_MIN_BLOCKSIZE);
>  			usage();
>  		}
> -		rtblocks = (xfs_rfsblock_t)(rtbytes >>
> +		rtblocks = (xfs_rfsblock_t)(get_conf_val(OPT_R, R_SIZE) >>
>  					    get_conf_val(OPT_B, B_LOG));
> -		if (rtbytes % get_conf_val(OPT_B, B_SIZE))
> +		if (get_conf_val(OPT_R, R_SIZE) % get_conf_val(OPT_B, B_SIZE))
>  			fprintf(stderr,
>  	_("warning: rt length %lld not a multiple of %lld, truncated to %lld\n"),
> -				(long long)rtbytes, get_conf_val(OPT_B, B_SIZE),
> +				get_conf_val(OPT_R, R_SIZE),
> +				get_conf_val(OPT_B, B_SIZE),
>  				(long long)(rtblocks <<
>  					   get_conf_val(OPT_B, B_LOG)));
>  	}
>  	/*
>  	 * If specified, check rt extent size against its constraints.
>  	 */
> -	if (rtextbytes) {
> -		if (rtextbytes % get_conf_val(OPT_B, B_SIZE)) {
> +	if (get_conf_val(OPT_R, R_EXTSIZE)) {
> +		if (get_conf_val(OPT_R, R_EXTSIZE) %
> +		    get_conf_val(OPT_B, B_SIZE)) {
>  			fprintf(stderr,
>  		_("illegal rt extent size %lld, not a multiple of %lld\n"),
> -				(long long)rtextbytes, get_conf_val(OPT_B, B_SIZE));
> +				get_conf_val(OPT_R, R_EXTSIZE),
> +				get_conf_val(OPT_B, B_SIZE));
>  			usage();
>  		}
> -		rtextblocks = (xfs_extlen_t)(rtextbytes >>
> +		rtextblocks = (xfs_extlen_t)(get_conf_val(OPT_R, R_EXTSIZE) >>
>  					     get_conf_val(OPT_B, B_LOG));
>  	} else {
>  		/*
> @@ -2555,20 +2554,23 @@ _("rmapbt not supported with realtime devices\n"));
>  		 * to the stripe width.
>  		 */
>  		uint64_t	rswidth;
> -		uint64_t	rtextbytes;
>  
> -		if (!norsflag && !xi.risfile && !(!rtbytes && xi.disfile))
> +		if (!get_conf_val(OPT_R, R_NOALIGN) && !xi.risfile &&
> +		    !(!get_conf_val(OPT_R, R_SIZE) && xi.disfile))
>  			rswidth = ft.rtswidth;
>  		else
>  			rswidth = 0;
>  
>  		/* check that rswidth is a multiple of fs B_SIZE */
> -		if (!norsflag && rswidth &&
> +		if (!get_conf_val(OPT_R, R_NOALIGN) && rswidth &&
>  		    !(BBTOB(rswidth) % get_conf_val(OPT_B, B_SIZE))) {
>  			rswidth = DTOBT(rswidth);
> -			rtextbytes = rswidth << get_conf_val(OPT_B, B_LOG);
> -			if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
> -			    (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
> +			set_conf_val(OPT_R, R_EXTSIZE,
> +				     rswidth << get_conf_val(OPT_B, B_LOG));
> +			if (XFS_MIN_RTEXTSIZE <=
> +			    get_conf_val(OPT_R, R_EXTSIZE) &&
> +			    (get_conf_val(OPT_R, R_EXTSIZE) <=
> +			     XFS_MAX_RTEXTSIZE)) {
>  				rtextblocks = rswidth;
>  			}
>  		}
> @@ -2741,7 +2743,7 @@ reported by the device (%u).\n"),
>  reported by the device (%u).\n"),
>  			get_conf_val(OPT_L, L_SECTSIZE), xi.lbsize);
>  	}
> -	if (rtbytes && xi.rtsize > 0 &&
> +	if (get_conf_val(OPT_R, R_SIZE) && xi.rtsize > 0 &&
>  	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
>  		fprintf(stderr, _(
>  "Warning: the realtime subvolume sector size %lld is less than the sector size\n\
> @@ -2749,16 +2751,17 @@ reported by the device (%u).\n"),
>  			get_conf_val(OPT_D, D_SECTSIZE), xi.rtbsize);
>  	}
>  
> -	if (rtbytes && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
> +	if (get_conf_val(OPT_R, R_SIZE) && xi.rtsize > 0 &&
> +	    rtblocks > DTOBT(xi.rtsize)) {
>  		fprintf(stderr,
>  			_("size %s specified for rt subvolume is too large, "
>  			"maximum is %lld blocks\n"),
>  			get_conf_raw_safe(OPT_R, R_SIZE),
>  			(long long)DTOBT(xi.rtsize));
>  		usage();
> -	} else if (!rtbytes && xi.rtsize > 0)
> +	} else if (!get_conf_val(OPT_R, R_SIZE) && xi.rtsize > 0)
>  		rtblocks = DTOBT(xi.rtsize);
> -	else if (rtbytes && !xi.rtdev) {
> +	else if (get_conf_val(OPT_R, R_SIZE) && !xi.rtdev) {
>  		fprintf(stderr,
>  			_("size specified for non-existent rt subvolume\n"));
>  		usage();
> -- 
> 2.13.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/6 v2] mkfs: replace variables with opts table: -b,d,s options
  2017-08-11 12:30 ` [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
  2017-08-14 23:30   ` Darrick J. Wong
@ 2017-08-15 15:00   ` Jan Tulak
  1 sibling, 0 replies; 14+ messages in thread
From: Jan Tulak @ 2017-08-15 15:00 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jan Tulak

Remove variables that can be replaced with a direct access to the opts
table, so we have it all in a single place, acessible from anywhere.

In future, we can remove some instances where we are passing values as
arguments to helper functions, when we have the values in the opts
struct and could pass only the struct.  But for now, limit the changes
to simple replacement without any change in the logic.

This is first of multiple similar patches that do the same, but for
other options.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

---
CHANGE:
* indentation change mentioned by Darrick with reviewed-by
---
 mkfs/xfs_mkfs.c | 792 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 463 insertions(+), 329 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 951fc9cc..d3f2db15 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -32,13 +32,6 @@ static void respec(char opt, char *tab[], int idx);
 static void unknown(char opt, char *s);
 static int  ispow2(unsigned int i);
 
-/*
- * The configured block and sector sizes are defined as global variables so
- * that they don't need to be passed to functions that require them.
- */
-unsigned int		blocksize;
-unsigned int		sectorsize;
-
 #define MAX_OPTS	16
 #define MAX_SUBOPTS	16
 #define SUBOPT_NEEDS_VAL	(-1LL)
@@ -740,7 +733,8 @@ struct opt_params {
 /*
  * Use this macro before we have superblock and mount structure
  */
-#define	DTOBT(d)	((xfs_rfsblock_t)((d) >> (blocklog - BBSHIFT)))
+#define	DTOBT(d) \
+	((xfs_rfsblock_t)((d) >> (get_conf_val(OPT_B, B_LOG) - BBSHIFT)))
 
 /*
  * Use this for block reservations needed for mkfs's conditions
@@ -1093,7 +1087,8 @@ getnum(
 	 * number.
 	 */
 	if (sp->convert)
-		c = cvtnum(blocksize, sectorsize, str);
+		c = cvtnum(get_conf_val(OPT_B, B_SIZE),
+			   get_conf_val(OPT_D, D_SECTSIZE), str);
 	else {
 		char		*str_end;
 
@@ -1180,16 +1175,16 @@ calc_stripe_factors(
 		*lsunit = (int)BTOBBT(lsu);
 
 	/* verify if lsu/lsunit is a multiple block size */
-	if (lsu % blocksize != 0) {
+	if (lsu % get_conf_val(OPT_B, B_SIZE) != 0) {
 		fprintf(stderr,
-_("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
-		lsu, blocksize);
+_("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
+		lsu, get_conf_val(OPT_B, B_SIZE));
 		exit(1);
 	}
-	if ((BBTOB(*lsunit) % blocksize != 0)) {
+	if ((BBTOB(*lsunit) % get_conf_val(OPT_B, B_SIZE) != 0)) {
 		fprintf(stderr,
-_("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
-		BBTOB(*lsunit), blocksize);
+_("log stripe unit (%d) must be a multiple of the block size (%lld)\n"),
+		BBTOB(*lsunit), get_conf_val(OPT_B, B_SIZE));
 		exit(1);
 	}
 }
@@ -1345,7 +1340,7 @@ validate_log_size(uint64_t logblocks, int blocklog, int min_logblocks)
 			(long long)logblocks, XFS_MAX_LOG_BLOCKS);
 		usage();
 	}
-	if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
+	if ((logblocks << get_conf_val(OPT_B, B_LOG)) > XFS_MAX_LOG_BYTES) {
 		fprintf(stderr,
 	_("log size %lld bytes too large, maximum size is %lld bytes\n"),
 			(long long)(logblocks << blocklog), XFS_MAX_LOG_BYTES);
@@ -1439,9 +1434,9 @@ validate_ag_geometry(
 	}
 
 	/*
-	 * If agcount is too large, make it smaller.
+	 * If D_AGCOUNT is too large, make it smaller.
 	 */
-	if (agcount > XFS_MAX_AGNUMBER + 1) {
+	if (get_conf_val(OPT_D, D_AGCOUNT) > XFS_MAX_AGNUMBER + 1) {
 		fprintf(stderr,
 	_("%lld allocation groups is too many, maximum is %lld\n"),
 			(long long)agcount, (long long)XFS_MAX_AGNUMBER + 1);
@@ -1675,15 +1670,12 @@ main(
 	int			argc,
 	char			**argv)
 {
-	uint64_t		agcount;
 	xfs_agf_t		*agf;
 	xfs_agi_t		*agi;
 	xfs_agnumber_t		agno;
-	uint64_t		agsize;
 	xfs_alloc_rec_t		*arec;
 	struct xfs_btree_block	*block;
 	int			blflag;
-	int			blocklog;
 	int			bsflag;
 	int			bsize;
 	xfs_buf_t		*buf;
@@ -1694,11 +1686,6 @@ main(
 	char			*dfile;
 	int			dirblocklog;
 	int			dirblocksize;
-	uint64_t		dbytes;
-	int			dsu;
-	int			dsw;
-	int			dsunit;
-	int			dswidth;
 	int			dsflag;
 	bool			force_overwrite;
 	struct fsxattr		fsx;
@@ -1736,7 +1723,6 @@ main(
 	xfs_mount_t		mbuf;
 	xfs_extlen_t		nbmblocks;
 	int			nlflag;
-	int			nodsflag;
 	int			norsflag;
 	xfs_alloc_rec_t		*nrec;
 	int			nsflag;
@@ -1754,7 +1740,6 @@ main(
 	uint64_t		rtextbytes;
 	char			*rtfile;
 	xfs_sb_t		*sbp;
-	int			sectorlog;
 	uint64_t		sector_mask;
 	int			slflag;
 	int			ssflag;
@@ -1787,12 +1772,11 @@ main(
 	textdomain(PACKAGE);
 
 	blflag = bsflag = slflag = ssflag = lslflag = lssflag = 0;
-	blocklog = blocksize = 0;
-	sectorlog = lsectorlog = 0;
-	sectorsize = lsectorsize = 0;
-	agsize = daflag = dasize = dblocks = 0;
-	ilflag = imflag = ipflag = isflag = 0;
-	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = 0;
+	lsectorlog = 0;
+	lsectorsize = 0;
+	dasize = dblocks = 0;
+	daflag = ilflag = imflag = ipflag = isflag = false;
+	liflag = laflag = lsflag = lsuflag = lsunitflag = ldflag = lvflag = false;
 	loginternal = 1;
 	logagno = logblocks = rtblocks = rtextblocks = 0;
 	Nflag = nlflag = nsflag = nvflag = 0;
@@ -1801,10 +1785,10 @@ main(
 	imaxpct = inodelog = inopblock = isize = 0;
 	dfile = logfile = rtfile = NULL;
 	protofile = NULL;
-	rtbytes = rtextbytes = logbytes = dbytes = 0;
-	dsu = dsw = dsunit = dswidth = lalign = lsu = lsunit = 0;
-	dsflag = nodsflag = norsflag = 0;
-	force_overwrite = 0;
+	rtbytes = rtextbytes = logbytes = 0;
+	lalign = lsu = lsunit = 0;
+	dsflag = norsflag = false;
+	force_overwrite = false;
 	worst_freelist = 0;
 	memset(&fsx, 0, sizeof(fsx));
 
@@ -1827,16 +1811,13 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case B_LOG:
-					blocklog = parse_conf_val(OPT_B, B_LOG,
-								  value);
-					blocksize = 1 << blocklog;
+					parse_conf_val(OPT_B, B_LOG,
+							     value);
 					blflag = 1;
 					break;
 				case B_SIZE:
-					blocksize = parse_conf_val(OPT_B,
-								   B_SIZE,
-								   value);
-					blocklog = libxfs_highbit32(blocksize);
+					parse_conf_val(OPT_B, B_SIZE,
+							     value);
 					bsflag = 1;
 					break;
 				default:
@@ -1853,15 +1834,12 @@ main(
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case D_AGCOUNT:
-					agcount = parse_conf_val(OPT_D,
-								 D_AGCOUNT,
-								 value);
+					parse_conf_val(OPT_D, D_AGCOUNT,
+						       value);
 					daflag = 1;
 					break;
 				case D_AGSIZE:
-					agsize = parse_conf_val(OPT_D,
-								D_AGSIZE,
-								value);
+					parse_conf_val(OPT_D, D_AGSIZE, value);
 					dasize = 1;
 					break;
 				case D_FILE:
@@ -1875,48 +1853,36 @@ main(
 					set_conf_val(OPT_D, D_NAME,  1);
 					break;
 				case D_SIZE:
-					dbytes = parse_conf_val(OPT_D, D_SIZE,
-								value);
+					parse_conf_val(OPT_D, D_SIZE, value);
 					break;
 				case D_SUNIT:
-					dsunit = parse_conf_val(OPT_D, D_SUNIT,
-								value);
+					parse_conf_val(OPT_D, D_SUNIT, value);
 					dsflag = 1;
 					break;
 				case D_SWIDTH:
-					dswidth = parse_conf_val(OPT_D,
-								 D_SWIDTH,
-								 value);
+					parse_conf_val(OPT_D, D_SWIDTH, value);
 					dsflag = 1;
 					break;
 				case D_SU:
-					dsu = parse_conf_val(OPT_D, D_SU,
-							     value);
+					parse_conf_val(OPT_D, D_SU, value);
 					dsflag = 1;
 					break;
 				case D_SW:
-					dsw = parse_conf_val(OPT_D, D_SW,
-							     value);
+					parse_conf_val(OPT_D, D_SW, value);
 					dsflag = 1;
 					break;
 				case D_NOALIGN:
-					nodsflag = parse_conf_val(OPT_D,
-								  D_NOALIGN,
-								  value);
+					parse_conf_val(OPT_D, D_NOALIGN,
+						       value);
 					break;
 				case D_SECTLOG:
-					sectorlog = parse_conf_val(OPT_D,
-								   D_SECTLOG,
-								   value);
-					sectorsize = 1 << sectorlog;
+					parse_conf_val(OPT_D, D_SECTLOG,
+							     value);
 					slflag = 1;
 					break;
 				case D_SECTSIZE:
-					sectorsize = parse_conf_val(OPT_D,
-								    D_SECTSIZE,
-								    value);
-					sectorlog =
-						libxfs_highbit32(sectorsize);
+					parse_conf_val(OPT_D, D_SECTSIZE,
+							     value);
 					ssflag = 1;
 					break;
 				case D_RTINHERIT:
@@ -2246,6 +2212,7 @@ main(
 				char	**subopts =
 						(char **)opts[OPT_S].subopts;
 				char	*value;
+				uint64_t tmp;
 
 				switch (getsubopt(&p, subopts, &value)) {
 				case S_LOG:
@@ -2254,12 +2221,12 @@ main(
 						conflict('s', subopts,
 							 S_SECTSIZE,
 							 S_SECTLOG);
-					sectorlog = parse_conf_val(OPT_S,
+					tmp = parse_conf_val(OPT_S,
 								   S_SECTLOG,
 								   value);
-					lsectorlog = sectorlog;
-					sectorsize = 1 << sectorlog;
-					lsectorsize = sectorsize;
+
+					lsectorlog = tmp;
+					lsectorsize = tmp;
 					lslflag = slflag = 1;
 					break;
 				case S_SIZE:
@@ -2268,13 +2235,12 @@ main(
 						conflict('s', subopts,
 							 S_SECTLOG,
 							 S_SECTSIZE);
-					sectorsize = parse_conf_val(OPT_S,
+					tmp = parse_conf_val(OPT_S,
 								    S_SECTSIZE,
 								    value);
-					lsectorsize = sectorsize;
-					sectorlog =
-						libxfs_highbit32(sectorsize);
-					lsectorlog = sectorlog;
+
+					lsectorlog = libxfs_highbit32(tmp);
+					lsectorsize = tmp;
 					lssflag = ssflag = 1;
 					break;
 				default:
@@ -2299,19 +2265,22 @@ main(
 		dfile = xi.dname;
 
 	/*
-	 * Blocksize and sectorsize first, other things depend on them
+	 * Blocksize and D_SECTSIZE 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) {
-		blocklog = XFS_DFL_BLOCKSIZE_LOG;
-		blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
+		set_conf_val(OPT_B, B_LOG, XFS_DFL_BLOCKSIZE_LOG);
+		set_conf_val(OPT_B, B_SIZE, 1 << XFS_DFL_BLOCKSIZE_LOG);
 	}
-	if (blocksize < XFS_MIN_BLOCKSIZE || blocksize > XFS_MAX_BLOCKSIZE) {
-		fprintf(stderr, _("illegal block size %d\n"), blocksize);
+	if (get_conf_val(OPT_B, B_SIZE) < XFS_MIN_BLOCKSIZE ||
+	    get_conf_val(OPT_B, B_SIZE) > XFS_MAX_BLOCKSIZE) {
+		fprintf(stderr, _("illegal block size %lld\n"),
+			get_conf_val(OPT_B, B_SIZE));
 		usage();
 	}
-	if (sb_feat.crcs_enabled && blocksize < XFS_MIN_CRC_BLOCKSIZE) {
+	if (sb_feat.crcs_enabled &&
+	    get_conf_val(OPT_B, B_SIZE) < XFS_MIN_CRC_BLOCKSIZE) {
 		fprintf(stderr,
 _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 			XFS_MIN_CRC_BLOCKSIZE);
@@ -2323,12 +2292,12 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 	}
 
 	if (!slflag && !ssflag) {
-		sectorlog = XFS_MIN_SECTORSIZE_LOG;
-		sectorsize = XFS_MIN_SECTORSIZE;
+		set_conf_val(OPT_D, D_SECTLOG, XFS_MIN_SECTORSIZE_LOG);
+		set_conf_val(OPT_D, D_SECTSIZE, XFS_MIN_SECTORSIZE);
 	}
 	if (!lslflag && !lssflag) {
-		lsectorlog = sectorlog;
-		lsectorsize = sectorsize;
+		lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
+		lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
 	}
 
 	/*
@@ -2338,7 +2307,8 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 	 * sector size mismatches between the new filesystem and the underlying
 	 * host filesystem.
 	 */
-	check_device_type(dfile, &xi.disfile, !dbytes, !dfile,
+	check_device_type(dfile, &xi.disfile, !get_conf_val(OPT_D, D_SIZE),
+			  !dfile,
 			  Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
 	if (!loginternal)
 		check_device_type(xi.logname, &xi.lisfile, !logbytes,
@@ -2367,50 +2337,58 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 		if (!ft.psectorsize)
 			ft.psectorsize = ft.lsectorsize;
 
-		sectorsize = ft.psectorsize ? ft.psectorsize :
-					      XFS_MIN_SECTORSIZE;
+		set_conf_val(OPT_D, D_SECTSIZE,
+			     ft.psectorsize ? ft.psectorsize :
+					      XFS_MIN_SECTORSIZE);
 
-		if ((blocksize < sectorsize) && (blocksize >= ft.lsectorsize)) {
+		if ((get_conf_val(OPT_B, B_SIZE) <
+		     get_conf_val(OPT_D, D_SECTSIZE)) &&
+		    (get_conf_val(OPT_B, B_SIZE) >= ft.lsectorsize)) {
 			fprintf(stderr,
-_("specified blocksize %d is less than device physical sector size %d\n"),
-				blocksize, ft.psectorsize);
+_("specified blocksize %lld is less than device physical sector size %d\n"),
+				get_conf_val(OPT_B, B_SIZE), ft.psectorsize);
 			fprintf(stderr,
 _("switching to logical sector size %d\n"),
 				ft.lsectorsize);
-			sectorsize = ft.lsectorsize ? ft.lsectorsize :
-						      XFS_MIN_SECTORSIZE;
+			set_conf_val(OPT_D, D_SECTSIZE,
+				     ft.lsectorsize ? ft.lsectorsize :
+						      XFS_MIN_SECTORSIZE);
 		}
 	}
 
 	if (!ssflag) {
-		sectorlog = libxfs_highbit32(sectorsize);
+		set_conf_val(OPT_D, D_SECTLOG,
+			     libxfs_highbit32(get_conf_val(OPT_D, D_SECTSIZE)));
 		if (loginternal) {
-			lsectorsize = sectorsize;
-			lsectorlog = sectorlog;
+			lsectorsize = get_conf_val(OPT_D, D_SECTSIZE);
+			lsectorlog = get_conf_val(OPT_D, D_SECTLOG);
 		}
 	}
 
-	if (sectorsize < XFS_MIN_SECTORSIZE ||
-	    sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
+	if (get_conf_val(OPT_D, D_SECTSIZE) < XFS_MIN_SECTORSIZE ||
+	    get_conf_val(OPT_D, D_SECTSIZE) > XFS_MAX_SECTORSIZE ||
+	    get_conf_val(OPT_D, D_SECTSIZE) > get_conf_val(OPT_B, B_SIZE)) {
 		if (ssflag)
-			fprintf(stderr, _("illegal sector size %d\n"), sectorsize);
+			fprintf(stderr, _("illegal sector size %lld\n"),
+				get_conf_val(OPT_D, D_SECTSIZE));
 		else
 			fprintf(stderr,
-_("block size %d cannot be smaller than logical sector size %d\n"),
-				blocksize, ft.lsectorsize);
+_("block size %lld cannot be smaller than logical sector size %d\n"),
+				get_conf_val(OPT_B, B_SIZE), ft.lsectorsize);
 		usage();
 	}
-	if (sectorsize < ft.lsectorsize) {
-		fprintf(stderr, _("illegal sector size %d; hw sector is %d\n"),
-			sectorsize, ft.lsectorsize);
+	if (get_conf_val(OPT_D, D_SECTSIZE) < ft.lsectorsize) {
+		fprintf(stderr, _("illegal sector size %lld; hw sector is %d\n"),
+			get_conf_val(OPT_D, D_SECTSIZE), ft.lsectorsize);
 		usage();
 	}
 	if (lsectorsize < XFS_MIN_SECTORSIZE ||
-	    lsectorsize > XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {
+	    lsectorsize > XFS_MAX_SECTORSIZE ||
+	    lsectorsize > get_conf_val(OPT_B, B_SIZE)) {
 		fprintf(stderr, _("illegal log sector size %d\n"), lsectorsize);
 		usage();
 	} else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
-		lsu = blocksize;
+		lsu = get_conf_val(OPT_B, B_SIZE);
 		sb_feat.log_version = 2;
 	}
 
@@ -2512,37 +2490,41 @@ _("rmapbt not supported with realtime devices\n"));
 	}
 
 	if (nsflag || nlflag) {
-		if (dirblocksize < blocksize ||
+		if (dirblocksize < get_conf_val(OPT_B, B_SIZE) ||
 					dirblocksize > XFS_MAX_BLOCKSIZE) {
 			fprintf(stderr, _("illegal directory block size %d\n"),
 				dirblocksize);
 			usage();
 		}
 	} else {
-		if (blocksize < (1 << XFS_MIN_REC_DIRSIZE))
+		if (get_conf_val(OPT_B, B_SIZE) < (1 << XFS_MIN_REC_DIRSIZE))
 			dirblocklog = XFS_MIN_REC_DIRSIZE;
 		else
-			dirblocklog = blocklog;
+			dirblocklog = get_conf_val(OPT_B, B_LOG);
 		dirblocksize = 1 << dirblocklog;
 	}
 
 
-	if (dbytes) {
-		if (dbytes % XFS_MIN_BLOCKSIZE) {
+	if (get_conf_val(OPT_D, D_SIZE)) {
+		if (get_conf_val(OPT_D, D_SIZE) % XFS_MIN_BLOCKSIZE) {
 			fprintf(stderr,
 			_("illegal data length %lld, not a multiple of %d\n"),
-				(long long)dbytes, XFS_MIN_BLOCKSIZE);
+				get_conf_val(OPT_D, D_SIZE), XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		dblocks = (xfs_rfsblock_t)(dbytes >> blocklog);
-		if (dbytes % blocksize)
+		dblocks = (xfs_rfsblock_t)(get_conf_val(OPT_D, D_SIZE) >>
+					   get_conf_val(OPT_B, B_LOG));
+		if (get_conf_val(OPT_D, D_SIZE) % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr, _("warning: "
-	"data length %lld not a multiple of %d, truncated to %lld\n"),
-				(long long)dbytes, blocksize,
-				(long long)(dblocks << blocklog));
+	"data length %lld not a multiple of %lld, truncated to %lld\n"),
+				get_conf_val(OPT_D, D_SIZE),
+				get_conf_val(OPT_B, B_SIZE),
+				(long long)(dblocks <<
+					   get_conf_val(OPT_B, B_LOG)));
 	}
 	if (ipflag) {
-		inodelog = blocklog - libxfs_highbit32(inopblock);
+		inodelog = get_conf_val(OPT_B, B_LOG) -
+				libxfs_highbit32(inopblock);
 		isize = 1 << inodelog;
 	} else if (!ilflag && !isflag) {
 		inodelog = sb_feat.crcs_enabled ? XFS_DINODE_DFL_CRC_LOG
@@ -2563,12 +2545,14 @@ _("rmapbt not supported with realtime devices\n"));
 				(long long)logbytes, XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		logblocks = (xfs_rfsblock_t)(logbytes >> blocklog);
-		if (logbytes % blocksize)
+		logblocks = (xfs_rfsblock_t)(logbytes >>
+					     get_conf_val(OPT_B, B_LOG));
+		if (logbytes % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr,
-	_("warning: log length %lld not a multiple of %d, truncated to %lld\n"),
-				(long long)logbytes, blocksize,
-				(long long)(logblocks << blocklog));
+	_("warning: log length %lld not a multiple of %lld, truncated to %lld\n"),
+				(long long)logbytes, get_conf_val(OPT_B, B_SIZE),
+				(long long)(logblocks <<
+					   get_conf_val(OPT_B, B_LOG)));
 	}
 	if (rtbytes) {
 		if (rtbytes % XFS_MIN_BLOCKSIZE) {
@@ -2577,24 +2561,27 @@ _("rmapbt not supported with realtime devices\n"));
 				(long long)rtbytes, XFS_MIN_BLOCKSIZE);
 			usage();
 		}
-		rtblocks = (xfs_rfsblock_t)(rtbytes >> blocklog);
-		if (rtbytes % blocksize)
+		rtblocks = (xfs_rfsblock_t)(rtbytes >>
+					    get_conf_val(OPT_B, B_LOG));
+		if (rtbytes % get_conf_val(OPT_B, B_SIZE))
 			fprintf(stderr,
-	_("warning: rt length %lld not a multiple of %d, truncated to %lld\n"),
-				(long long)rtbytes, blocksize,
-				(long long)(rtblocks << blocklog));
+	_("warning: rt length %lld not a multiple of %lld, truncated to %lld\n"),
+				(long long)rtbytes, get_conf_val(OPT_B, B_SIZE),
+				(long long)(rtblocks <<
+					   get_conf_val(OPT_B, B_LOG)));
 	}
 	/*
 	 * If specified, check rt extent size against its constraints.
 	 */
 	if (rtextbytes) {
-		if (rtextbytes % blocksize) {
+		if (rtextbytes % get_conf_val(OPT_B, B_SIZE)) {
 			fprintf(stderr,
-		_("illegal rt extent size %lld, not a multiple of %d\n"),
-				(long long)rtextbytes, blocksize);
+		_("illegal rt extent size %lld, not a multiple of %lld\n"),
+				(long long)rtextbytes, get_conf_val(OPT_B, B_SIZE));
 			usage();
 		}
-		rtextblocks = (xfs_extlen_t)(rtextbytes >> blocklog);
+		rtextblocks = (xfs_extlen_t)(rtextbytes >>
+					     get_conf_val(OPT_B, B_LOG));
 	} else {
 		/*
 		 * If realtime extsize has not been specified by the user,
@@ -2609,18 +2596,21 @@ _("rmapbt not supported with realtime devices\n"));
 		else
 			rswidth = 0;
 
-		/* check that rswidth is a multiple of fs blocksize */
-		if (!norsflag && rswidth && !(BBTOB(rswidth) % blocksize)) {
+		/* check that rswidth is a multiple of fs B_SIZE */
+		if (!norsflag && rswidth &&
+		    !(BBTOB(rswidth) % get_conf_val(OPT_B, B_SIZE))) {
 			rswidth = DTOBT(rswidth);
-			rtextbytes = rswidth << blocklog;
+			rtextbytes = rswidth << get_conf_val(OPT_B, B_LOG);
 			if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
 			    (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
 				rtextblocks = rswidth;
 			}
 		}
 		if (!rtextblocks) {
-			rtextblocks = (blocksize < XFS_MIN_RTEXTSIZE) ?
-					XFS_MIN_RTEXTSIZE >> blocklog : 1;
+			rtextblocks = (get_conf_val(OPT_B, B_SIZE) <
+				       XFS_MIN_RTEXTSIZE) ?
+				       XFS_MIN_RTEXTSIZE >>
+				       get_conf_val(OPT_B, B_LOG) : 1;
 		}
 	}
 	ASSERT(rtextblocks);
@@ -2628,22 +2618,25 @@ _("rmapbt not supported with realtime devices\n"));
 	/*
 	 * Check some argument sizes against mins, maxes.
 	 */
-	if (isize > blocksize / XFS_MIN_INODE_PERBLOCK ||
+	if (isize > get_conf_val(OPT_B, B_SIZE) / XFS_MIN_INODE_PERBLOCK ||
 	    isize < XFS_DINODE_MIN_SIZE ||
 	    isize > XFS_DINODE_MAX_SIZE) {
 		int	maxsz;
 
 		fprintf(stderr, _("illegal inode size %d\n"), isize);
-		maxsz = MIN(blocksize / XFS_MIN_INODE_PERBLOCK,
+		maxsz = MIN(get_conf_val(OPT_B, B_SIZE) /
+			    XFS_MIN_INODE_PERBLOCK,
 			    XFS_DINODE_MAX_SIZE);
 		if (XFS_DINODE_MIN_SIZE == maxsz)
 			fprintf(stderr,
-			_("allowable inode size with %d byte blocks is %d\n"),
-				blocksize, XFS_DINODE_MIN_SIZE);
+			_("allowable inode size with %lld byte blocks is %d\n"),
+				get_conf_val(OPT_B, B_SIZE),
+				XFS_DINODE_MIN_SIZE);
 		else
 			fprintf(stderr,
-	_("allowable inode size with %d byte blocks is between %d and %d\n"),
-				blocksize, XFS_DINODE_MIN_SIZE, maxsz);
+	_("allowable inode size with %lld byte blocks is between %d and %d\n"),
+				get_conf_val(OPT_B, B_SIZE),
+				XFS_DINODE_MIN_SIZE, maxsz);
 		exit(1);
 	}
 
@@ -2654,14 +2647,24 @@ _("rmapbt not supported with realtime devices\n"));
 		sb_feat.log_version = 2;
 	}
 
-	calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize,
+	int dsunit = get_conf_val(OPT_D, D_SUNIT);
+	int dswidth = get_conf_val(OPT_D, D_SWIDTH);
+
+	calc_stripe_factors(get_conf_val(OPT_D, D_SU),
+			    get_conf_val(OPT_D, D_SW),
+			    get_conf_val(OPT_D, D_SECTSIZE),
+			    lsu,
+			    lsectorsize,
 				&dsunit, &dswidth, &lsunit);
 
 	/* If sunit & swidth were manually specified as 0, same as noalign */
 	if (dsflag && !dsunit && !dswidth)
-		nodsflag = 1;
+		set_conf_val(OPT_D, D_NOALIGN, 1);
 
-	xi.setblksize = sectorsize;
+	set_conf_val(OPT_D, D_SUNIT, dsunit);
+	set_conf_val(OPT_D, D_SWIDTH, dswidth);
+
+	xi.setblksize = get_conf_val(OPT_D, D_SECTSIZE);
 
 	/*
 	 * Initialize.  This will open the log and rt devices as well.
@@ -2684,7 +2687,8 @@ _("rmapbt not supported with realtime devices\n"));
 	 * multiple of the sector size, or 1024, whichever is larger.
 	 */
 
-	sector_mask = (uint64_t)-1 << (MAX(sectorlog, 10) - BBSHIFT);
+	sector_mask = (uint64_t)-1 <<
+		(MAX(get_conf_val(OPT_D, D_SECTLOG), 10) - BBSHIFT);
 	xi.dsize &= sector_mask;
 	xi.rtsize &= sector_mask;
 	xi.logBBsize &= (uint64_t)-1 << (MAX(lsectorlog, 10) - BBSHIFT);
@@ -2719,16 +2723,17 @@ _("rmapbt not supported with realtime devices\n"));
 		rtfile = _("volume rt");
 	else if (!xi.rtdev)
 		rtfile = _("none");
-	if (dbytes && xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
+	if (get_conf_val(OPT_D, D_SIZE) &&
+	    xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
 		fprintf(stderr,
 			_("size %s specified for data subvolume is too large, "
 			"maximum is %lld blocks\n"),
 			get_conf_raw_safe(OPT_D, D_SIZE),
 			(long long)DTOBT(xi.dsize));
 		usage();
-	} else if (!dbytes && xi.dsize > 0)
+	} else if (!get_conf_val(OPT_D, D_SIZE) && xi.dsize > 0)
 		dblocks = DTOBT(xi.dsize);
-	else if (!dbytes) {
+	else if (!get_conf_val(OPT_D, D_SIZE)) {
 		fprintf(stderr, _("can't get size of data subvolume\n"));
 		usage();
 	}
@@ -2743,17 +2748,18 @@ _("rmapbt not supported with realtime devices\n"));
 		fprintf(stderr,
 			_("can't have both external and internal logs\n"));
 		usage();
-	} else if (loginternal && sectorsize != lsectorsize) {
+	} else if (loginternal &&
+		   get_conf_val(OPT_D, D_SECTSIZE) != lsectorsize) {
 		fprintf(stderr,
 	_("data and log sector sizes must be equal for internal logs\n"));
 		usage();
 	}
 
-	if (xi.dbsize > sectorsize) {
+	if (xi.dbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
 		fprintf(stderr, _(
-"Warning: the data subvolume sector size %u is less than the sector size \n\
+"Warning: the data subvolume sector size %lld is less than the sector size \n\
 reported by the device (%u).\n"),
-			sectorsize, xi.dbsize);
+			get_conf_val(OPT_D, D_SECTSIZE), xi.dbsize);
 	}
 	if (!loginternal && xi.lbsize > lsectorsize) {
 		fprintf(stderr, _(
@@ -2761,11 +2767,12 @@ reported by the device (%u).\n"),
 reported by the device (%u).\n"),
 			lsectorsize, xi.lbsize);
 	}
-	if (rtbytes && xi.rtsize > 0 && xi.rtbsize > sectorsize) {
+	if (rtbytes && xi.rtsize > 0 &&
+	    xi.rtbsize > get_conf_val(OPT_D, D_SECTSIZE)) {
 		fprintf(stderr, _(
-"Warning: the realtime subvolume sector size %u is less than the sector size\n\
+"Warning: the realtime subvolume sector size %lld is less than the sector size\n\
 reported by the device (%u).\n"),
-			sectorsize, xi.rtbsize);
+			get_conf_val(OPT_D, D_SECTSIZE), xi.rtbsize);
 	}
 
 	if (rtbytes && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
@@ -2784,119 +2791,175 @@ reported by the device (%u).\n"),
 	}
 	if (xi.rtdev) {
 		rtextents = rtblocks / rtextblocks;
-		nbmblocks = (xfs_extlen_t)howmany(rtextents, NBBY * blocksize);
+		nbmblocks = (xfs_extlen_t)howmany(rtextents, NBBY *
+						  get_conf_val(OPT_B, B_SIZE));
 	} else {
 		rtextents = rtblocks = 0;
 		nbmblocks = 0;
 	}
 
-	if (!nodsflag) {
-		if (dsunit) {
-			if (ft.dsunit && ft.dsunit != dsunit) {
+	if (!get_conf_val(OPT_D, D_NOALIGN)) {
+		if (get_conf_val(OPT_D, D_SUNIT)) {
+			if (ft.dsunit &&
+			    ft.dsunit != get_conf_val(OPT_D, D_SUNIT)) {
 				fprintf(stderr,
-					_("%s: Specified data stripe unit %d "
+					_("%s: Specified data stripe unit %lld "
 					"is not the same as the volume stripe "
 					"unit %d\n"),
-					progname, dsunit, ft.dsunit);
+					progname,
+					get_conf_val(OPT_D, D_SUNIT),
+					ft.dsunit);
 			}
-			if (ft.dswidth && ft.dswidth != dswidth) {
+			if (ft.dswidth &&
+			    ft.dswidth != get_conf_val(OPT_D, D_SWIDTH)) {
 				fprintf(stderr,
-					_("%s: Specified data stripe width %d "
+					_("%s: Specified data stripe width %lld "
 					"is not the same as the volume stripe "
 					"width %d\n"),
-					progname, dswidth, ft.dswidth);
+					progname,
+					get_conf_val(OPT_D, D_SWIDTH),
+					ft.dswidth);
 			}
 		} else {
-			dsunit = ft.dsunit;
-			dswidth = ft.dswidth;
-			nodsflag = 1;
+			set_conf_val(OPT_D, D_SUNIT, ft.dsunit);
+			set_conf_val(OPT_D, D_SWIDTH, ft.dswidth);
+			set_conf_val(OPT_D, D_NOALIGN, 1);
 		}
-	} /* else dsunit & dswidth can't be set if nodsflag is set */
+	} /* else D_SUNIT & D_SWIDTH can't be set if D_NOALIGN is set */
 
 	if (dasize) {		/* User-specified AG size */
 		/*
-		 * Check specified agsize is a multiple of blocksize.
+		 * Check specified D_AGSIZE is a multiple of B_SIZE.
 		 */
-		if (agsize % blocksize) {
+		if (get_conf_val(OPT_D, D_AGSIZE) %
+		    get_conf_val(OPT_B, B_SIZE)) {
 			fprintf(stderr,
-		_("agsize (%lld) not a multiple of fs blk size (%d)\n"),
-				(long long)agsize, blocksize);
+		_("agsize (%lld) not a multiple of fs blk size (%lld)\n"),
+				get_conf_val(OPT_D, D_AGSIZE),
+				get_conf_val(OPT_B, B_SIZE));
 			usage();
 		}
-		agsize /= blocksize;
-		agcount = dblocks / agsize + (dblocks % agsize != 0);
+		set_conf_val(OPT_D, D_AGSIZE,
+			     get_conf_val(OPT_D, D_AGSIZE) /
+			     get_conf_val(OPT_B, B_SIZE));
+		set_conf_val(OPT_D, D_AGCOUNT,
+			     dblocks / get_conf_val(OPT_D, D_AGSIZE) +
+			     (dblocks % get_conf_val(OPT_D, D_AGSIZE) != 0));
 
 	} else if (daflag) {	/* User-specified AG count */
-		agsize = dblocks / agcount + (dblocks % agcount != 0);
+		set_conf_val(OPT_D, D_AGSIZE,
+			     dblocks / get_conf_val(OPT_D, D_AGCOUNT) +
+			     (dblocks % get_conf_val(OPT_D, D_AGCOUNT) != 0));
 	} else {
-		calc_default_ag_geometry(blocklog, dblocks,
-				dsunit | dswidth, &agsize, &agcount);
+		/* TODO change the calc_... function so it accepts opts
+		 * directly, without the need to pass all the values. */
+		uint64_t agcount = get_conf_val(OPT_D, D_AGCOUNT);
+		uint64_t agsize = get_conf_val(OPT_D, D_AGSIZE);
+
+		calc_default_ag_geometry(get_conf_val(OPT_B, B_LOG),
+					 dblocks, get_conf_val(OPT_D, D_SUNIT)
+					 | get_conf_val(OPT_D, D_SWIDTH),
+					 &agsize, &agcount);
+		set_conf_val(OPT_D, D_AGCOUNT, agcount);
+		set_conf_val(OPT_D, D_AGSIZE, agsize);
 	}
 
 	/*
-	 * If dsunit is a multiple of fs blocksize, then check that is a
-	 * multiple of the agsize too
+	 * If D_SUNIT is a multiple of fs B_SIZE,
+	 * then check that is a multiple of the D_AGSIZE too
 	 */
-	if (dsunit && !(BBTOB(dsunit) % blocksize) &&
-	    dswidth && !(BBTOB(dswidth) % blocksize)) {
-
-		/* convert from 512 byte blocks to fs blocksize */
-		dsunit = DTOBT(dsunit);
-		dswidth = DTOBT(dswidth);
+	if (get_conf_val(OPT_D, D_SUNIT) &&
+	    !(BBTOB(get_conf_val(OPT_D, D_SUNIT)) %
+	      get_conf_val(OPT_B, B_SIZE)) &&
+	    get_conf_val(OPT_D, D_SWIDTH) &&
+	    !(BBTOB(get_conf_val(OPT_D, D_SWIDTH)) %
+	      get_conf_val(OPT_B, B_SIZE))) {
+
+		/* convert from 512 byte blocks to fs B_SIZE
+		 */
+		set_conf_val(OPT_D, D_SUNIT,
+			     DTOBT(get_conf_val(OPT_D, D_SUNIT)));
+		set_conf_val(OPT_D, D_SWIDTH,
+			     DTOBT(get_conf_val(OPT_D, D_SWIDTH)));
 
 		/*
-		 * agsize is not a multiple of dsunit
+		 * D_AGSIZE is not a multiple of D_SUNIT
 		 */
-		if ((agsize % dsunit) != 0) {
+		if ((get_conf_val(OPT_D, D_AGSIZE) %
+		     get_conf_val(OPT_D, D_SUNIT)) != 0) {
 			/*
 			 * Round up to stripe unit boundary. Also make sure
-			 * that agsize is still larger than
-			 * XFS_AG_MIN_BLOCKS(blocklog)
+			 * that D_AGSIZE is still larger than
+			 * XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))
 		 	 */
-			tmp_agsize = ((agsize + (dsunit - 1))/ dsunit) * dsunit;
+			tmp_agsize = ((get_conf_val(OPT_D, D_AGSIZE) +
+				       (get_conf_val(OPT_D, D_SUNIT) - 1)) /
+				      get_conf_val(OPT_D, D_SUNIT)) *
+				get_conf_val(OPT_D, D_SUNIT);
 			/*
 			 * Round down to stripe unit boundary if rounding up
 			 * created an AG size that is larger than the AG max.
 			 */
-			if (tmp_agsize > XFS_AG_MAX_BLOCKS(blocklog))
-				tmp_agsize = ((agsize) / dsunit) * dsunit;
-
-			if ((tmp_agsize >= XFS_AG_MIN_BLOCKS(blocklog)) &&
-			    (tmp_agsize <= XFS_AG_MAX_BLOCKS(blocklog))) {
-				agsize = tmp_agsize;
+			if (tmp_agsize >
+			    XFS_AG_MAX_BLOCKS(get_conf_val(OPT_B, B_LOG)))
+				tmp_agsize = ((get_conf_val(OPT_D, D_AGSIZE)) /
+					      get_conf_val(OPT_D, D_SUNIT)) *
+					get_conf_val(OPT_D, D_SUNIT);
+
+			if ((tmp_agsize >=
+			     XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))) &&
+			    (tmp_agsize <=
+			     XFS_AG_MAX_BLOCKS(get_conf_val(OPT_B, B_LOG)))) {
+				set_conf_val(OPT_D, D_AGSIZE, tmp_agsize);
 				if (!daflag)
-					agcount = dblocks/agsize +
-						(dblocks % agsize != 0);
+					set_conf_val(OPT_D, D_AGCOUNT,
+						dblocks /
+						get_conf_val(OPT_D, D_AGSIZE) +
+						(dblocks %
+						 get_conf_val(OPT_D, D_AGSIZE)
+						!= 0));
 				if (dasize)
 					fprintf(stderr,
-				_("agsize rounded to %lld, swidth = %d\n"),
-						(long long)agsize, dswidth);
+				_("agsize rounded to %lld, swidth = %lld\n"),
+						get_conf_val(OPT_D, D_AGSIZE),
+						get_conf_val(OPT_D, D_SWIDTH));
 			} else {
-				if (nodsflag) {
-					dsunit = dswidth = 0;
+				if (get_conf_val(OPT_D, D_NOALIGN)) {
+					set_conf_val(OPT_D, D_SUNIT, 0);
+					set_conf_val(OPT_D, D_SWIDTH, 0);
 				} else {
 					/*
-					 * agsize is out of bounds, this will
+					 * D_AGSIZE is out of bounds, this will
 					 * print nice details & exit.
 					 */
-					validate_ag_geometry(blocklog, dblocks,
-							    agsize, agcount);
+					validate_ag_geometry(
+						get_conf_val(OPT_B, B_LOG),
+						dblocks,
+						get_conf_val(OPT_D, D_AGSIZE),
+						get_conf_val(OPT_D, D_AGCOUNT));
 					exit(1);
 				}
 			}
 		}
-		if (dswidth && ((agsize % dswidth) == 0) && (agcount > 1)) {
+		if (get_conf_val(OPT_D, D_SWIDTH) &&
+		    ((get_conf_val(OPT_D, D_AGSIZE) %
+		      get_conf_val(OPT_D, D_SWIDTH)) == 0) &&
+		    (get_conf_val(OPT_D, D_AGCOUNT) > 1)) {
 			/* This is a non-optimal configuration because all AGs
 			 * start on the same disk in the stripe.  Changing
 			 * the AG size by one sunit will guarantee that this
 			 * does not happen.
 			 */
-			tmp_agsize = agsize - dsunit;
-			if (tmp_agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
-				tmp_agsize = agsize + dsunit;
-				if (dblocks < agsize) {
+			tmp_agsize = get_conf_val(OPT_D, D_AGSIZE) -
+				get_conf_val(OPT_D, D_SUNIT);
+			if (tmp_agsize <
+			    XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG))) {
+				tmp_agsize = get_conf_val(OPT_D, D_AGSIZE) +
+					get_conf_val(OPT_D, D_SUNIT);
+				if (dblocks < get_conf_val(OPT_D, D_AGSIZE)) {
 					/* oh well, nothing to do */
-					tmp_agsize = agsize;
+					tmp_agsize =
+						get_conf_val(OPT_D, D_AGSIZE);
 				}
 			}
 			if (daflag || dasize) {
@@ -2906,30 +2969,46 @@ problems by aligning all AGs on the same disk.  To avoid this, run mkfs with\n\
 an AG size that is one stripe unit smaller, for example %llu.\n"),
 					(unsigned long long)tmp_agsize);
 			} else {
-				agsize = tmp_agsize;
-				agcount = dblocks/agsize + (dblocks % agsize != 0);
+				set_conf_val(OPT_D, D_AGSIZE, tmp_agsize);
+				set_conf_val(OPT_D, D_AGCOUNT,
+					dblocks/get_conf_val(OPT_D, D_AGSIZE) +
+					     (dblocks %
+					      get_conf_val(OPT_D, D_AGSIZE)
+					      != 0));
 				/*
 				 * If the last AG is too small, reduce the
 				 * filesystem size and drop the blocks.
 				 */
-				if ( dblocks % agsize != 0 &&
-				    (dblocks % agsize <
-				    XFS_AG_MIN_BLOCKS(blocklog))) {
-					dblocks = (xfs_rfsblock_t)((agcount - 1) * agsize);
-					agcount--;
-					ASSERT(agcount != 0);
+				if (dblocks % get_conf_val(OPT_D, D_AGSIZE)
+				    != 0 &&
+				    (dblocks % get_conf_val(OPT_D, D_AGSIZE) <
+				    XFS_AG_MIN_BLOCKS(
+					get_conf_val(OPT_B, B_LOG)))) {
+
+					dblocks = (xfs_rfsblock_t)(
+						(get_conf_val(OPT_D, D_AGCOUNT)
+						 - 1) *
+						get_conf_val(OPT_D, D_AGSIZE));
+					set_conf_val(OPT_D, D_AGCOUNT,
+						get_conf_val(OPT_D, D_AGCOUNT)
+						- 1);
+					ASSERT(get_conf_val(OPT_D, D_AGCOUNT)
+					       != 0);
 				}
 			}
 		}
 	} else {
-		if (nodsflag)
-			dsunit = dswidth = 0;
-		else {
+		if (get_conf_val(OPT_D, D_NOALIGN)) {
+			set_conf_val(OPT_D, D_SWIDTH, 0);
+			set_conf_val(OPT_D, D_SUNIT, 0);
+		} else {
 			fprintf(stderr,
-				_("%s: Stripe unit(%d) or stripe width(%d) is "
-				"not a multiple of the block size(%d)\n"),
-				progname, BBTOB(dsunit), BBTOB(dswidth),
-				blocksize);
+				_("%s: Stripe unit(%lld) or stripe width(%lld) is "
+				"not a multiple of the block size(%lld)\n"),
+				progname,
+				BBTOB(get_conf_val(OPT_D, D_SUNIT)),
+				BBTOB(get_conf_val(OPT_D, D_SWIDTH)),
+				get_conf_val(OPT_B, B_SIZE));
 			exit(1);
 		}
 	}
@@ -2938,53 +3017,69 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 	 * If the last AG is too small, reduce the filesystem size
 	 * and drop the blocks.
 	 */
-	if ( dblocks % agsize != 0 &&
-	     (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) {
+	if (dblocks % get_conf_val(OPT_D, D_AGSIZE) != 0 &&
+	     (dblocks % get_conf_val(OPT_D, D_AGSIZE) <
+	      XFS_AG_MIN_BLOCKS(get_conf_val(OPT_B, B_LOG)))) {
 		ASSERT(!daflag);
-		dblocks = (xfs_rfsblock_t)((agcount - 1) * agsize);
-		agcount--;
-		ASSERT(agcount != 0);
+		dblocks = (xfs_rfsblock_t)(
+				(get_conf_val(OPT_D, D_AGCOUNT) - 1) *
+				get_conf_val(OPT_D, D_AGSIZE));
+		set_conf_val(OPT_D, D_AGCOUNT,
+			     get_conf_val(OPT_D, D_AGCOUNT) - 1);
+		ASSERT(get_conf_val(OPT_D, D_AGCOUNT) != 0);
 	}
 
-	validate_ag_geometry(blocklog, dblocks, agsize, agcount);
+	validate_ag_geometry(get_conf_val(OPT_B, B_LOG),
+			     dblocks,
+			     get_conf_val(OPT_D, D_AGSIZE),
+			     get_conf_val(OPT_D, D_AGCOUNT));
 
 	if (!imflag)
-		imaxpct = calc_default_imaxpct(blocklog, dblocks);
+		imaxpct = calc_default_imaxpct(get_conf_val(OPT_B, B_LOG),
+					       dblocks);
 
 	/*
-	 * check that log sunit is modulo fsblksize or default it to dsunit.
+	 * check that log sunit is modulo fsblksize or default it to D_SUNIT.
 	 */
 
 	if (lsunit) {
 		/* convert from 512 byte blocks to fs blocks */
 		lsunit = DTOBT(lsunit);
-	} else if (sb_feat.log_version == 2 && loginternal && dsunit) {
-		/* lsunit and dsunit now in fs blocks */
-		lsunit = dsunit;
+	} else if (sb_feat.log_version == 2 &&
+		   loginternal &&
+		   get_conf_val(OPT_D, D_SUNIT)) {
+		/* lsunit and get_conf_val(OPT_D, D_SUNIT) now in fs blocks */
+		lsunit = get_conf_val(OPT_D, D_SUNIT);
 	}
 
-	if (sb_feat.log_version == 2 && (lsunit * blocksize) > 256 * 1024) {
+	if (sb_feat.log_version == 2 &&
+	    (lsunit * get_conf_val(OPT_B, B_SIZE)) > 256 * 1024) {
 		/* Warn only if specified on commandline */
 		if (lsuflag || lsunitflag) {
 			fprintf(stderr,
-	_("log stripe unit (%d bytes) is too large (maximum is 256KiB)\n"),
-				(lsunit * blocksize));
+	_("log stripe unit (%lld bytes) is too large (maximum is 256KiB)\n"),
+				(lsunit * get_conf_val(OPT_B, B_SIZE)));
 			fprintf(stderr,
 	_("log stripe unit adjusted to 32KiB\n"));
 		}
-		lsunit = (32 * 1024) >> blocklog;
+		lsunit = (32 * 1024) >> get_conf_val(OPT_B, B_LOG);
 	}
 
-	min_logblocks = max_trans_res(agsize,
+	min_logblocks = max_trans_res(get_conf_val(OPT_D, D_AGSIZE),
 				   sb_feat.crcs_enabled, sb_feat.dir_version,
-				   sectorlog, blocklog, inodelog, dirblocklog,
+				   get_conf_val(OPT_D, D_SECTLOG),
+				   get_conf_val(OPT_B, B_LOG),
+				   inodelog, dirblocklog,
 				   sb_feat.log_version, lsunit, sb_feat.finobt,
 				   sb_feat.rmapbt, sb_feat.reflink,
 				   sb_feat.inode_align);
 	ASSERT(min_logblocks);
 	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
-	if (!logbytes && dblocks >= (1024*1024*1024) >> blocklog)
-		min_logblocks = MAX(min_logblocks, XFS_MIN_LOG_BYTES>>blocklog);
+	if (!logbytes &&
+	    dblocks >= (1024*1024*1024) >> get_conf_val(OPT_B, B_LOG))
+		min_logblocks = MAX(min_logblocks,
+				    XFS_MIN_LOG_BYTES >>
+				    get_conf_val(OPT_B, B_LOG));
 	if (logbytes && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
 		fprintf(stderr,
 _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
@@ -3005,17 +3100,19 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		logblocks = 0;
 	} else if (loginternal && !logbytes) {
 
-		if (dblocks < GIGABYTES(1, blocklog)) {
+		if (dblocks < GIGABYTES(1, get_conf_val(OPT_B, B_LOG))) {
 			/* tiny filesystems get minimum sized logs. */
 			logblocks = min_logblocks;
-		} else if (dblocks < GIGABYTES(16, blocklog)) {
+		} else if (dblocks <
+			   GIGABYTES(16, get_conf_val(OPT_B, B_LOG))) {
 
 			/*
 			 * For small filesystems, we want to use the
 			 * XFS_MIN_LOG_BYTES for filesystems smaller than 16G if
 			 * at all possible, ramping up to 128MB at 256GB.
 			 */
-			logblocks = MIN(XFS_MIN_LOG_BYTES >> blocklog,
+			logblocks = MIN(XFS_MIN_LOG_BYTES >>
+					get_conf_val(OPT_B, B_LOG),
 					min_logblocks * XFS_DFL_LOG_FACTOR);
 		} else {
 			/*
@@ -3024,34 +3121,38 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			 * max log size of 128M at 256GB fs size. IOWs,
 			 * the ratio of fs size to log size is 2048:1.
 			 */
-			logblocks = (dblocks << blocklog) / 2048;
-			logblocks = logblocks >> blocklog;
+			logblocks = (dblocks <<
+				     get_conf_val(OPT_B, B_LOG)) / 2048;
+			logblocks = logblocks >> get_conf_val(OPT_B, B_LOG);
 		}
 
 		/* Ensure the chosen size meets minimum log size requirements */
 		logblocks = MAX(min_logblocks, logblocks);
 
 		/* make sure the log fits wholly within an AG */
-		if (logblocks >= agsize)
+		if (logblocks >= get_conf_val(OPT_D, D_AGSIZE))
 			logblocks = min_logblocks;
 
 		/* and now clamp the size to the maximum supported size */
 		logblocks = MIN(logblocks, XFS_MAX_LOG_BLOCKS);
-		if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES)
-			logblocks = XFS_MAX_LOG_BYTES >> blocklog;
+		if ((logblocks << get_conf_val(OPT_B, B_LOG)) >
+		    XFS_MAX_LOG_BYTES)
+			logblocks = XFS_MAX_LOG_BYTES >>
+				get_conf_val(OPT_B, B_LOG);
 
 	}
-	validate_log_size(logblocks, blocklog, min_logblocks);
+	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
 
 	protostring = setup_proto(protofile);
-	bsize = 1 << (blocklog - BBSHIFT);
+	bsize = 1 << (get_conf_val(OPT_B, B_LOG) - BBSHIFT);
 	mp = &mbuf;
 	sbp = &mp->m_sb;
 	memset(mp, 0, sizeof(xfs_mount_t));
-	sbp->sb_blocklog = (uint8_t)blocklog;
-	sbp->sb_sectlog = (uint8_t)sectorlog;
-	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup((unsigned int)agsize);
-	sbp->sb_agblocks = (xfs_agblock_t)agsize;
+	sbp->sb_blocklog = (uint8_t)get_conf_val(OPT_B, B_LOG);
+	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
+	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup(
+				(unsigned int)get_conf_val(OPT_D, D_AGSIZE));
+	sbp->sb_agblocks = (xfs_agblock_t)get_conf_val(OPT_D, D_AGSIZE);
 	mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
 	mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
 
@@ -3059,7 +3160,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 * sb_versionnum, finobt and rmapbt flags must be set before we use
 	 * libxfs_prealloc_blocks().
 	 */
-	sb_set_features(&mp->m_sb, &sb_feat, sectorsize, lsectorsize, dsunit);
+	sb_set_features(&mp->m_sb, &sb_feat,
+			get_conf_val(OPT_D, D_SECTSIZE),
+			lsectorsize,
+			get_conf_val(OPT_D, D_SUNIT));
 
 
 	if (loginternal) {
@@ -3072,9 +3176,12 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 					libxfs_alloc_ag_max_usable(mp));
 
 			/* revalidate the log size is valid if we changed it */
-			validate_log_size(logblocks, blocklog, min_logblocks);
+			validate_log_size(logblocks,
+					  get_conf_val(OPT_B, B_LOG),
+					  min_logblocks);
 		}
-		if (logblocks > agsize - libxfs_prealloc_blocks(mp)) {
+		if (logblocks > get_conf_val(OPT_D, D_AGSIZE) -
+		    libxfs_prealloc_blocks(mp)) {
 			fprintf(stderr,
 	_("internal log size %lld too large, must fit in allocation group\n"),
 				(long long)logblocks);
@@ -3082,14 +3189,16 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		}
 
 		if (laflag) {
-			if (logagno >= agcount) {
+			if (logagno >= get_conf_val(OPT_D, D_AGCOUNT)) {
 				fprintf(stderr,
 		_("log ag number %d too large, must be less than %lld\n"),
-					logagno, (long long)agcount);
+					logagno,
+					get_conf_val(OPT_D, D_AGCOUNT));
 				usage();
 			}
 		} else
-			logagno = (xfs_agnumber_t)(agcount / 2);
+			logagno = (xfs_agnumber_t)(
+					get_conf_val(OPT_D, D_AGCOUNT) / 2);
 
 		logstart = XFS_AGB_TO_FSB(mp, logagno, libxfs_prealloc_blocks(mp));
 		/*
@@ -3097,45 +3206,53 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		 */
 		if (lsunit) {
 			logstart = fixup_internal_log_stripe(mp,
-					lsflag, logstart, agsize, lsunit,
-					&logblocks, blocklog, &lalign);
-		} else if (dsunit) {
+					lsflag, logstart,
+					get_conf_val(OPT_D, D_AGSIZE), lsunit,
+					&logblocks,
+					get_conf_val(OPT_B, B_LOG), &lalign);
+		} else if (get_conf_val(OPT_D, D_SUNIT)) {
 			logstart = fixup_internal_log_stripe(mp,
-					lsflag, logstart, agsize, dsunit,
-					&logblocks, blocklog, &lalign);
+					lsflag, logstart,
+					get_conf_val(OPT_D, D_AGSIZE),
+					get_conf_val(OPT_D, D_SUNIT),
+					&logblocks,
+					get_conf_val(OPT_B, B_LOG), &lalign);
 		}
 	} else {
 		logstart = 0;
 		if (lsunit)
 			fixup_log_stripe_unit(lsflag, lsunit,
-					&logblocks, blocklog);
+					&logblocks, get_conf_val(OPT_B, B_LOG));
 	}
-	validate_log_size(logblocks, blocklog, min_logblocks);
+	validate_log_size(logblocks, get_conf_val(OPT_B, B_LOG), min_logblocks);
 
 	if (!qflag || Nflag) {
 		printf(_(
 		   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
-		   "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
+		   "         =%-22s sectsz=%-5lld attr=%u, projid32bit=%u\n"
 		   "         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u, reflink=%u\n"
-		   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
-		   "         =%-22s sunit=%-6u swidth=%u blks\n"
+		   "data     =%-22s bsize=%-6lld blocks=%llu, imaxpct=%u\n"
+		   "         =%-22s sunit=%-6lld swidth=%lld blks\n"
 		   "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
 		   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
 		   "         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
 		   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
-			dfile, isize, (long long)agcount, (long long)agsize,
-			"", sectorsize, sb_feat.attr_version,
+			dfile, isize, get_conf_val(OPT_D, D_AGCOUNT),
+			get_conf_val(OPT_D, D_AGSIZE),
+			"", get_conf_val(OPT_D, D_SECTSIZE),
+			sb_feat.attr_version,
 				    !sb_feat.projid16bit,
 			"", sb_feat.crcs_enabled, sb_feat.finobt, sb_feat.spinodes,
 			sb_feat.rmapbt, sb_feat.reflink,
-			"", blocksize, (long long)dblocks, imaxpct,
-			"", dsunit, dswidth,
+			"", get_conf_val(OPT_B, B_SIZE), (long long)dblocks, imaxpct,
+			"", get_conf_val(OPT_D, D_SUNIT),
+			get_conf_val(OPT_D, D_SWIDTH),
 			sb_feat.dir_version, dirblocksize, sb_feat.nci,
 				sb_feat.dirftype,
-			logfile, 1 << blocklog, (long long)logblocks,
+			logfile, 1 << get_conf_val(OPT_B, B_LOG), (long long)logblocks,
 			sb_feat.log_version, "", lsectorsize, lsunit,
 				sb_feat.lazy_sb_counters,
-			rtfile, rtextblocks << blocklog,
+			rtfile, rtextblocks << get_conf_val(OPT_B, B_LOG),
 			(long long)rtblocks, (long long)rtextents);
 		if (Nflag)
 			exit(0);
@@ -3144,7 +3261,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	if (label)
 		strncpy(sbp->sb_fname, label, sizeof(sbp->sb_fname));
 	sbp->sb_magicnum = XFS_SB_MAGIC;
-	sbp->sb_blocksize = blocksize;
+	sbp->sb_blocksize = get_conf_val(OPT_B, B_SIZE);
 	sbp->sb_dblocks = dblocks;
 	sbp->sb_rblocks = rtblocks;
 	sbp->sb_rextents = rtextents;
@@ -3154,15 +3271,15 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_logstart = logstart;
 	sbp->sb_rootino = sbp->sb_rbmino = sbp->sb_rsumino = NULLFSINO;
 	sbp->sb_rextsize = rtextblocks;
-	sbp->sb_agcount = (xfs_agnumber_t)agcount;
+	sbp->sb_agcount = (xfs_agnumber_t)get_conf_val(OPT_D, D_AGCOUNT);
 	sbp->sb_rbmblocks = nbmblocks;
 	sbp->sb_logblocks = (xfs_extlen_t)logblocks;
-	sbp->sb_sectsize = (uint16_t)sectorsize;
+	sbp->sb_sectsize = (uint16_t)get_conf_val(OPT_D, D_SECTSIZE);
 	sbp->sb_inodesize = (uint16_t)isize;
-	sbp->sb_inopblock = (uint16_t)(blocksize / isize);
-	sbp->sb_sectlog = (uint8_t)sectorlog;
+	sbp->sb_inopblock = (uint16_t)(get_conf_val(OPT_B, B_SIZE) / isize);
+	sbp->sb_sectlog = (uint8_t)get_conf_val(OPT_D, D_SECTLOG);
 	sbp->sb_inodelog = (uint8_t)inodelog;
-	sbp->sb_inopblog = (uint8_t)(blocklog - inodelog);
+	sbp->sb_inopblog = (uint8_t)(get_conf_val(OPT_B, B_LOG) - inodelog);
 	sbp->sb_rextslog =
 		(uint8_t)(rtextents ?
 			libxfs_highbit32((unsigned int)rtextents) : 0);
@@ -3170,14 +3287,15 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	sbp->sb_imax_pct = imaxpct;
 	sbp->sb_icount = 0;
 	sbp->sb_ifree = 0;
-	sbp->sb_fdblocks = dblocks - agcount * libxfs_prealloc_blocks(mp) -
+	sbp->sb_fdblocks = dblocks -
+		get_conf_val(OPT_D, D_AGCOUNT) * libxfs_prealloc_blocks(mp) -
 		(loginternal ? logblocks : 0);
 	sbp->sb_frextents = 0;	/* will do a free later */
 	sbp->sb_uquotino = sbp->sb_gquotino = sbp->sb_pquotino = 0;
 	sbp->sb_qflags = 0;
-	sbp->sb_unit = dsunit;
-	sbp->sb_width = dswidth;
-	sbp->sb_dirblklog = dirblocklog - blocklog;
+	sbp->sb_unit = get_conf_val(OPT_D, D_SUNIT);
+	sbp->sb_width = get_conf_val(OPT_D, D_SWIDTH);
+	sbp->sb_dirblklog = dirblocklog - get_conf_val(OPT_B, B_LOG);
 	if (sb_feat.log_version == 2) {	/* This is stored in bytes */
 		lsunit = (lsunit == 0) ? 1 : XFS_FSB_TO_B(mp, lsunit);
 		sbp->sb_logsunit = lsunit;
@@ -3187,11 +3305,12 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		int	cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
 		if (sb_feat.crcs_enabled)
 			cluster_size *= isize / XFS_DINODE_MIN_SIZE;
-		sbp->sb_inoalignmt = cluster_size >> blocklog;
+		sbp->sb_inoalignmt = cluster_size >> get_conf_val(OPT_B, B_LOG);
 		sb_feat.inode_align = sbp->sb_inoalignmt != 0;
 	} else
 		sbp->sb_inoalignmt = 0;
-	if (lsectorsize != BBSIZE || sectorsize != BBSIZE) {
+	if (lsectorsize != BBSIZE ||
+	    get_conf_val(OPT_D, D_SECTSIZE) != BBSIZE) {
 		sbp->sb_logsectlog = (uint8_t)lsectorlog;
 		sbp->sb_logsectsize = (uint16_t)lsectorsize;
 	} else {
@@ -3199,7 +3318,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		sbp->sb_logsectsize = 0;
 	}
 
-	sb_set_features(&mp->m_sb, &sb_feat, sectorsize, lsectorsize, dsunit);
+	sb_set_features(&mp->m_sb, &sb_feat,
+			get_conf_val(OPT_D, D_SECTSIZE),
+			lsectorsize,
+			get_conf_val(OPT_D, D_SUNIT));
 
 	if (force_overwrite)
 		zero_old_xfs_structures(&xi, sbp);
@@ -3219,7 +3341,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	/* OK, now write the superblock */
 	buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
 	buf->b_ops = &xfs_sb_buf_ops;
-	memset(XFS_BUF_PTR(buf), 0, sectorsize);
+	memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_D, D_SECTSIZE));
 	libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	libxfs_purgebuf(buf);
@@ -3229,8 +3351,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 * if needed so that the reads for the end of the device in the mount
 	 * code will succeed.
 	 */
-	if (xi.disfile && xi.dsize * xi.dbsize < dblocks * blocksize) {
-		if (ftruncate(xi.dfd, dblocks * blocksize) < 0) {
+	if (xi.disfile &&
+	    xi.dsize * xi.dbsize < dblocks * get_conf_val(OPT_B, B_SIZE)) {
+		if (ftruncate(xi.dfd,
+			     dblocks * get_conf_val(OPT_B, B_SIZE)) < 0) {
 			fprintf(stderr,
 				_("%s: Growing the data section failed\n"),
 				progname);
@@ -3272,7 +3396,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 * These initialisations should be pulled into libxfs to keep the
 	 * kernel/userspace header initialisation code the same.
 	 */
-	for (agno = 0; agno < agcount; agno++) {
+	for (agno = 0; agno < get_conf_val(OPT_D, D_AGCOUNT); agno++) {
 		struct xfs_agfl	*agfl;
 		int		bucket;
 		struct xfs_perag *pag = libxfs_perag_get(mp, agno);
@@ -3284,7 +3408,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
 				XFS_FSS_TO_BB(mp, 1));
 		buf->b_ops = &xfs_sb_buf_ops;
-		memset(XFS_BUF_PTR(buf), 0, sectorsize);
+		memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_D, D_SECTSIZE));
 		libxfs_sb_to_disk((void *)XFS_BUF_PTR(buf), sbp);
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
@@ -3296,13 +3420,17 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				XFS_FSS_TO_BB(mp, 1));
 		buf->b_ops = &xfs_agf_buf_ops;
 		agf = XFS_BUF_TO_AGF(buf);
-		memset(agf, 0, sectorsize);
-		if (agno == agcount - 1)
-			agsize = dblocks - (xfs_rfsblock_t)(agno * agsize);
+		memset(agf, 0, get_conf_val(OPT_D, D_SECTSIZE));
+		if (agno == get_conf_val(OPT_D, D_AGCOUNT) - 1)
+			set_conf_val(OPT_D, D_AGSIZE,
+				dblocks -
+				(xfs_rfsblock_t)(agno *
+					get_conf_val(OPT_D, D_AGSIZE)));
+
 		agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
 		agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
 		agf->agf_seqno = cpu_to_be32(agno);
-		agf->agf_length = cpu_to_be32(agsize);
+		agf->agf_length = cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE));
 		agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp));
 		agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
 		agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
@@ -3324,7 +3452,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		agf->agf_flfirst = 0;
 		agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
 		agf->agf_flcount = 0;
-		nbmblocks = (xfs_extlen_t)(agsize - libxfs_prealloc_blocks(mp));
+		nbmblocks = (xfs_extlen_t)(get_conf_val(OPT_D, D_AGSIZE) -
+					   libxfs_prealloc_blocks(mp));
 		agf->agf_freeblks = cpu_to_be32(nbmblocks);
 		agf->agf_longest = cpu_to_be32(nbmblocks);
 		if (xfs_sb_version_hascrc(&mp->m_sb))
@@ -3332,7 +3461,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
 		if (loginternal && agno == logagno) {
 			be32_add_cpu(&agf->agf_freeblks, -logblocks);
-			agf->agf_longest = cpu_to_be32(agsize -
+			agf->agf_longest =
+				cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
 				XFS_FSB_TO_AGBNO(mp, logstart) - logblocks);
 		}
 		if (libxfs_alloc_min_freelist(mp, pag) > worst_freelist)
@@ -3348,7 +3478,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		buf->b_ops = &xfs_agfl_buf_ops;
 		agfl = XFS_BUF_TO_AGFL(buf);
 		/* setting to 0xff results in initialisation to NULLAGBLOCK */
-		memset(agfl, 0xff, sectorsize);
+		memset(agfl, 0xff, get_conf_val(OPT_D, D_SECTSIZE));
 		if (xfs_sb_version_hascrc(&mp->m_sb)) {
 			agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC);
 			agfl->agfl_seqno = cpu_to_be32(agno);
@@ -3367,11 +3497,13 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				XFS_FSS_TO_BB(mp, 1));
 		agi = XFS_BUF_TO_AGI(buf);
 		buf->b_ops = &xfs_agi_buf_ops;
-		memset(agi, 0, sectorsize);
+		memset(agi, 0, get_conf_val(OPT_D, D_SECTSIZE));
 		agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
 		agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
 		agi->agi_seqno = cpu_to_be32(agno);
-		agi->agi_length = cpu_to_be32((xfs_agblock_t)agsize);
+		agi->agi_length =
+			cpu_to_be32(
+				(xfs_agblock_t)get_conf_val(OPT_D, D_AGSIZE));
 		agi->agi_count = 0;
 		agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp));
 		agi->agi_level = cpu_to_be32(1);
@@ -3396,7 +3528,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 		buf->b_ops = &xfs_allocbt_buf_ops;
 		block = XFS_BUF_TO_BLOCK(buf);
-		memset(block, 0, blocksize);
+		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_btree_init_block(mp, buf, XFS_BTNUM_BNO, 0, 1, agno, 0);
 
 		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
@@ -3431,7 +3563,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		 * so, reset the record count to 0 to avoid exposure of an invalid
 		 * record start block.
 		 */
-		arec->ar_blockcount = cpu_to_be32(agsize -
+		arec->ar_blockcount =
+			cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
 					be32_to_cpu(arec->ar_startblock));
 		if (!arec->ar_blockcount)
 			block->bb_numrecs = 0;
@@ -3446,7 +3579,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 		buf->b_ops = &xfs_allocbt_buf_ops;
 		block = XFS_BUF_TO_BLOCK(buf);
-		memset(block, 0, blocksize);
+		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_btree_init_block(mp, buf, XFS_BTNUM_CNT, 0, 1, agno, 0);
 
 		arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
@@ -3471,7 +3604,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 		 * so, reset the record count to 0 to avoid exposure of an invalid
 		 * record start block.
 		 */
-		arec->ar_blockcount = cpu_to_be32(agsize -
+		arec->ar_blockcount =
+			cpu_to_be32(get_conf_val(OPT_D, D_AGSIZE) -
 					be32_to_cpu(arec->ar_startblock));
 		if (!arec->ar_blockcount)
 			block->bb_numrecs = 0;
@@ -3489,7 +3623,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 			buf->b_ops = &xfs_refcountbt_buf_ops;
 
 			block = XFS_BUF_TO_BLOCK(buf);
-			memset(block, 0, blocksize);
+			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 			libxfs_btree_init_block(mp, buf, XFS_BTNUM_REFC, 0,
 						0, agno, 0);
 
@@ -3504,7 +3638,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 		buf->b_ops = &xfs_inobt_buf_ops;
 		block = XFS_BUF_TO_BLOCK(buf);
-		memset(block, 0, blocksize);
+		memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_btree_init_block(mp, buf, XFS_BTNUM_INO, 0, 0, agno, 0);
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
@@ -3517,7 +3651,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 					bsize);
 			buf->b_ops = &xfs_inobt_buf_ops;
 			block = XFS_BUF_TO_BLOCK(buf);
-			memset(block, 0, blocksize);
+			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 			libxfs_btree_init_block(mp, buf, XFS_BTNUM_FINO, 0, 0, agno, 0);
 			libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 		}
@@ -3531,7 +3665,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 				bsize);
 			buf->b_ops = &xfs_rmapbt_buf_ops;
 			block = XFS_BUF_TO_BLOCK(buf);
-			memset(block, 0, blocksize);
+			memset(block, 0, get_conf_val(OPT_B, B_SIZE));
 
 			libxfs_btree_init_block(mp, buf, XFS_BTNUM_RMAP, 0, 0, agno, 0);
 
@@ -3607,7 +3741,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	 */
 	buf = libxfs_getbuf(mp->m_ddev_targp,
 		(xfs_daddr_t)XFS_FSB_TO_BB(mp, dblocks - 1LL), bsize);
-	memset(XFS_BUF_PTR(buf), 0, blocksize);
+	memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_B, B_SIZE));
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 	/*
@@ -3616,14 +3750,14 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 	if (mp->m_rtdev_targp->dev && rtblocks > 0) {
 		buf = libxfs_getbuf(mp->m_rtdev_targp,
 				XFS_FSB_TO_BB(mp, rtblocks - 1LL), bsize);
-		memset(XFS_BUF_PTR(buf), 0, blocksize);
+		memset(XFS_BUF_PTR(buf), 0, get_conf_val(OPT_B, B_SIZE));
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 	}
 
 	/*
 	 * BNO, CNT free block list
 	 */
-	for (agno = 0; agno < agcount; agno++) {
+	for (agno = 0; agno < get_conf_val(OPT_D, D_AGCOUNT); agno++) {
 		xfs_alloc_arg_t	args;
 		xfs_trans_t	*tp;
 		struct xfs_trans_res tres = {0};
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-08-15 15:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-11 12:30 [PATCH 0/6 v2] mkfs: use user values saved in opts table Jan Tulak
2017-08-11 12:30 ` [PATCH 1/6] mkfs: save user input values into opts Jan Tulak
2017-08-14 23:21   ` Darrick J. Wong
2017-08-11 12:30 ` [PATCH 2/6] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
2017-08-14 23:30   ` Darrick J. Wong
2017-08-15 15:00   ` [PATCH 2/6 v2] " Jan Tulak
2017-08-11 12:30 ` [PATCH 3/6] mkfs: replace variables with opts table: -i options Jan Tulak
2017-08-14 23:31   ` Darrick J. Wong
2017-08-11 12:30 ` [PATCH 4/6] mkfs: replace variables with opts table: -l options Jan Tulak
2017-08-14 23:34   ` Darrick J. Wong
2017-08-11 12:30 ` [PATCH 5/6] mkfs: replace variables with opts table: -n options Jan Tulak
2017-08-14 23:34   ` Darrick J. Wong
2017-08-11 12:30 ` [PATCH 6/6] mkfs: replace variables with opts table: -r options Jan Tulak
2017-08-14 23:35   ` Darrick J. Wong

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.