* [PATCH 0/5] mkfs: use user values saved in opts table
@ 2017-07-20 9:51 Jan Tulak
2017-07-20 9:51 ` [PATCH 1/5] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-20 9:51 UTC (permalink / raw)
To: linux-xfs; +Cc: Jan Tulak
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.
Description of all commits is updated.
Jan Tulak (5):
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 | 1219 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 718 insertions(+), 501 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/5] mkfs: replace variables with opts table: -b,d,s options
2017-07-20 9:51 [PATCH 0/5] mkfs: use user values saved in opts table Jan Tulak
@ 2017-07-20 9:51 ` Jan Tulak
2017-07-21 12:34 ` [PATCH 1/5 v2] " Jan Tulak
2017-07-20 9:51 ` [PATCH 2/5] mkfs: replace variables with opts table: -i options Jan Tulak
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Jan Tulak @ 2017-07-20 9:51 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.
This is first of multiple similar patches that do the same, but for
other options.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 872 ++++++++++++++++++++++++++++++++++----------------------
1 file changed, 532 insertions(+), 340 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index bf480efe..27043684 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
@@ -760,14 +754,14 @@ struct opt_params {
/*
* Get and set values to the opts table.
*/
-static inline uint64_t
+static inline long long
get_conf_val(int opt, int subopt)
{
return opts[opt].subopt_params[subopt].value;
}
static void
-set_conf_val(int opt, int subopt, uint64_t val)
+set_conf_val(int opt, int subopt, long long val)
{
struct subopt_param *sp = &opts[opt].subopt_params[subopt];
@@ -883,7 +877,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;
@@ -907,7 +902,7 @@ getnum(
/*
* A wrapper for getnum and set_conf_val.
*/
-static inline uint64_t
+static inline long long
parse_conf_val(int opt, int subopt, char *value)
{
uint64_t num = getnum(value, &opts[opt], subopt);
@@ -970,16 +965,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);
}
}
@@ -1135,7 +1130,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);
@@ -1229,9 +1224,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);
@@ -1465,15 +1460,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;
@@ -1484,11 +1476,6 @@ main(
char *dfile;
int dirblocklog;
int dirblocksize;
- int dbytes;
- int dsu;
- int dsw;
- int dsunit;
- int dswidth;
bool force_overwrite;
struct fsxattr fsx;
int ilflag;
@@ -1525,7 +1512,6 @@ main(
xfs_mount_t mbuf;
xfs_extlen_t nbmblocks;
int nlflag;
- int nodsflag;
int norsflag;
xfs_alloc_rec_t *nrec;
int nsflag;
@@ -1543,7 +1529,6 @@ main(
int rtextbytes;
char *rtfile;
xfs_sb_t *sbp;
- int sectorlog;
__uint64_t sector_mask;
int slflag;
int ssflag;
@@ -1576,12 +1561,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;
@@ -1590,10 +1574,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;
- nodsflag = norsflag = 0;
- force_overwrite = 0;
+ rtbytes = rtextbytes = logbytes = 0;
+ lalign = lsu = lsunit = 0;
+ norsflag = false;
+ force_overwrite = false;
worst_freelist = 0;
memset(&fsx, 0, sizeof(fsx));
@@ -1609,6 +1593,7 @@ main(
break;
case 'b':
p = optarg;
+ uint64_t tmp;
while (*p != '\0') {
char **subopts =
(char **)opts[OPT_B].subopts;
@@ -1616,19 +1601,17 @@ main(
switch (getsubopt(&p, subopts, &value)) {
case B_LOG:
- blocklog = parse_conf_val(OPT_B, B_LOG,
- value);
- blocksize = 1 << blocklog;
+ tmp = parse_conf_val(OPT_B, B_LOG,
+ value);
+ set_conf_val(OPT_B, B_SIZE, 1 << tmp);
blflag = 1;
- set_conf_val(OPT_B, B_SIZE, blocksize);
break;
case B_SIZE:
- blocksize = parse_conf_val(OPT_B,
- B_SIZE,
- value);
- blocklog = libxfs_highbit32(blocksize);
+ tmp = parse_conf_val(OPT_B, B_SIZE,
+ value);
+ set_conf_val(OPT_B, B_LOG,
+ libxfs_highbit32(tmp));
bsflag = 1;
- set_conf_val(OPT_B, B_LOG, blocklog);
break;
default:
unknown('b', value);
@@ -1641,18 +1624,17 @@ main(
char **subopts =
(char **)opts[OPT_D].subopts;
char *value;
+ uint64_t tmp;
+
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:
@@ -1666,49 +1648,70 @@ 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);
break;
case D_SWIDTH:
- dswidth = parse_conf_val(OPT_D,
- D_SWIDTH,
- value);
+ parse_conf_val(OPT_D, D_SWIDTH, value);
break;
case D_SU:
- dsu = parse_conf_val(OPT_D, D_SU,
- value);
+ parse_conf_val(OPT_D, D_SU, value);
break;
case D_SW:
- dsw = parse_conf_val(OPT_D, D_SW,
- value);
+ parse_conf_val(OPT_D, D_SW, value);
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;
- slflag = 1;
+ /*
+ * we can set sector size both as
+ * -d sectsize/sectlog and as -s option.
+ * Thus we need to fill the same value
+ * into multiple options to make sure
+ * that we are doing the parsing right.
+ * Only D_SECTSIZE/D_SECTLOG is used
+ * later in the code, though.
+ */
+ tmp = parse_conf_val(OPT_D, D_SECTLOG,
+ value);
+
+ set_conf_val(OPT_S, S_LOG, tmp);
+ set_conf_val(OPT_S, S_SECTLOG, tmp);
set_conf_val(OPT_D, D_SECTSIZE,
- sectorsize);
+ 1 << tmp);
+ set_conf_val(OPT_S, S_SECTSIZE,
+ 1 << tmp);
+ set_conf_val(OPT_S, S_SIZE,
+ 1 << tmp);
+ slflag = 1;
break;
case D_SECTSIZE:
- sectorsize = parse_conf_val(OPT_D,
- D_SECTSIZE,
- value);
- sectorlog =
- libxfs_highbit32(sectorsize);
- ssflag = 1;
+ /*
+ * we can set sector size both as
+ * -d sectsize/sectlog and as -s option.
+ * Thus we need to fill the same value
+ * into multiple options to make sure
+ * that we are doing the parsing right.
+ * Only D_SECTSIZE/D_SECTLOG is used
+ * later in the code, though.
+ */
+ tmp = parse_conf_val(OPT_D, D_SECTSIZE,
+ value);
+
+ set_conf_val(OPT_S, S_SIZE, tmp);
+ set_conf_val(OPT_S, S_SECTSIZE, tmp);
set_conf_val(OPT_D, D_SECTLOG,
- sectorlog);
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_LOG,
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_SECTLOG,
+ libxfs_highbit32(tmp));
+
+ ssflag = 1;
break;
case D_RTINHERIT:
c = parse_conf_val(OPT_D, D_RTINHERIT,
@@ -2053,6 +2056,16 @@ main(
char **subopts =
(char **)opts[OPT_S].subopts;
char *value;
+ uint64_t tmp;
+ /*
+ * we can set sector size both as
+ * -d sectsize/sectlog and as -s option.
+ * Thus we need to fill the same value
+ * into multiple options to make sure
+ * that we are doing the parsing right.
+ * Only D_SECTSIZE/D_SECTLOG is used
+ * later in the code, though.
+ */
switch (getsubopt(&p, subopts, &value)) {
case S_LOG:
@@ -2061,14 +2074,21 @@ 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;
+
+ set_conf_val(OPT_S, S_LOG, tmp);
+ set_conf_val(OPT_D, D_SECTLOG, tmp);
+ lsectorlog = tmp;
+ set_conf_val(OPT_D, D_SECTSIZE,
+ 1 << tmp);
+ set_conf_val(OPT_S, S_SIZE, 1 << tmp);
+ set_conf_val(OPT_S, S_SECTSIZE,
+ 1 << tmp);
+
+ lsectorsize = tmp;
lslflag = slflag = 1;
- set_conf_val(OPT_S, S_LOG, sectorsize);
break;
case S_SIZE:
case S_SECTSIZE:
@@ -2076,16 +2096,22 @@ 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;
+
+ set_conf_val(OPT_S, S_SIZE, tmp);
+ set_conf_val(OPT_D, D_SECTSIZE, tmp);
+ lsectorsize = tmp;
+ set_conf_val(OPT_D, D_SECTLOG,
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_LOG,
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_SECTLOG,
+ libxfs_highbit32(tmp));
+ lsectorlog = libxfs_highbit32(tmp);
+
lssflag = ssflag = 1;
- set_conf_val(OPT_S,
- S_SIZE, sectorlog);
break;
default:
unknown('s', value);
@@ -2109,19 +2135,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);
@@ -2133,12 +2162,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);
}
/*
@@ -2148,7 +2177,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,
@@ -2177,50 +2207,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;
}
@@ -2322,37 +2360,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
@@ -2373,12 +2415,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) {
@@ -2387,24 +2431,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,
@@ -2419,18 +2466,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);
@@ -2438,22 +2488,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);
}
@@ -2464,10 +2517,20 @@ _("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);
- 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.
@@ -2490,7 +2553,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);
@@ -2525,16 +2589,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(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();
}
@@ -2549,17 +2614,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, _(
@@ -2567,11 +2633,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)) {
@@ -2590,119 +2657,173 @@ 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);
+ 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) {
@@ -2712,30 +2833,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);
}
}
@@ -2744,53 +2881,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"),
@@ -2811,17 +2964,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 {
/*
@@ -2830,34 +2985,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;
@@ -2865,7 +3024,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) {
@@ -2878,9 +3040,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);
@@ -2888,14 +3053,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));
/*
@@ -2903,45 +3070,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);
@@ -2950,7 +3125,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;
@@ -2960,15 +3135,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);
@@ -2976,14 +3151,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;
@@ -2993,11 +3169,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 {
@@ -3005,7 +3182,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);
@@ -3025,7 +3205,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);
@@ -3035,8 +3215,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);
@@ -3078,7 +3260,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);
@@ -3090,7 +3272,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);
@@ -3102,13 +3284,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);
@@ -3130,7 +3316,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))
@@ -3138,7 +3325,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)
@@ -3154,7 +3342,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);
@@ -3173,11 +3361,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);
@@ -3202,7 +3392,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);
@@ -3237,7 +3427,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;
@@ -3252,7 +3443,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);
@@ -3277,7 +3468,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;
@@ -3295,7 +3487,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);
@@ -3310,7 +3502,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);
@@ -3323,7 +3515,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);
}
@@ -3337,7 +3529,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);
@@ -3413,7 +3605,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);
/*
@@ -3422,14 +3614,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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/5] mkfs: replace variables with opts table: -i options
2017-07-20 9:51 [PATCH 0/5] mkfs: use user values saved in opts table Jan Tulak
2017-07-20 9:51 ` [PATCH 1/5] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
@ 2017-07-20 9:51 ` Jan Tulak
2017-07-20 9:51 ` [PATCH 3/5] mkfs: replace variables with opts table: -l options Jan Tulak
` (2 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-20 9:51 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 | 102 +++++++++++++++++++++++++++++---------------------------
1 file changed, 53 insertions(+), 49 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 27043684..8778d27a 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1479,13 +1479,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;
@@ -1570,8 +1566,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;
@@ -1747,6 +1742,7 @@ main(
char **subopts =
(char **)opts[OPT_I].subopts;
char *value;
+ uint64_t tmp;
switch (getsubopt(&p, subopts, &value)) {
case I_ALIGN:
@@ -1755,30 +1751,26 @@ main(
value);
break;
case I_LOG:
- inodelog = parse_conf_val(OPT_I, I_LOG,
- value);
- isize = 1 << inodelog;
+ tmp = parse_conf_val(OPT_I, I_LOG,
+ value);
+ set_conf_val(OPT_I, I_SIZE, 1 << tmp);
ilflag = 1;
- set_conf_val(OPT_I, I_SIZE, isize);
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,
+ tmp = parse_conf_val(OPT_I, I_SIZE,
value);
- inodelog = libxfs_highbit32(isize);
+ set_conf_val(OPT_I, I_LOG,
+ libxfs_highbit32(tmp));
isflag = 1;
- set_conf_val(OPT_I, I_LOG, inodelog);
break;
case I_ATTR:
sb_feat.attr_version =
@@ -2269,7 +2261,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);
@@ -2393,15 +2386,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);
@@ -2488,12 +2483,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);
@@ -2899,8 +2896,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.
@@ -2933,7 +2931,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);
@@ -3092,29 +3090,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);
@@ -3139,16 +3140,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 -
@@ -3168,7 +3171,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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/5] mkfs: replace variables with opts table: -l options
2017-07-20 9:51 [PATCH 0/5] mkfs: use user values saved in opts table Jan Tulak
2017-07-20 9:51 ` [PATCH 1/5] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
2017-07-20 9:51 ` [PATCH 2/5] mkfs: replace variables with opts table: -i options Jan Tulak
@ 2017-07-20 9:51 ` Jan Tulak
2017-07-21 12:35 ` [PATCH 3/5 v2] " Jan Tulak
2017-07-20 9:51 ` [PATCH 4/5] mkfs: replace variables with opts table: -n options Jan Tulak
2017-07-20 9:51 ` [PATCH 5/5] mkfs: replace variables with opts table: -r options Jan Tulak
4 siblings, 1 reply; 13+ messages in thread
From: Jan Tulak @ 2017-07-20 9:51 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 | 259 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 140 insertions(+), 119 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 8778d27a..1bc3351f 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 },
@@ -912,7 +913,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(
@@ -964,7 +966,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"),
@@ -1487,22 +1489,15 @@ main(
int lalign;
int ldflag;
int liflag;
- xfs_agnumber_t logagno;
xfs_rfsblock_t logblocks;
char *logfile;
- int loginternal;
- int 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;
@@ -1557,20 +1552,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;
norsflag = false;
force_overwrite = false;
worst_freelist = 0;
@@ -1804,9 +1796,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:
@@ -1815,20 +1805,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:
@@ -1837,7 +1823,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;
@@ -1851,29 +1837,24 @@ main(
sb_feat.log_version);
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,
+ tmp = parse_conf_val(OPT_L,
L_SECTLOG,
value);
- lsectorsize = 1 << lsectorlog;
- lslflag = 1;
set_conf_val(OPT_L, L_SECTSIZE,
- lsectorsize);
+ 1 << tmp);
+ lslflag = 1;
break;
case L_SECTSIZE:
- lsectorsize =
+ tmp =
parse_conf_val(OPT_L,
L_SECTSIZE,
value);
- lsectorlog =
- libxfs_highbit32(lsectorsize);
- lssflag = 1;
set_conf_val(OPT_L, L_SECTLOG,
- lsectorlog);
+ libxfs_highbit32(tmp));
+ lssflag = 1;
break;
case L_LAZYSBCNTR:
sb_feat.lazy_sb_counters =
@@ -2072,14 +2053,14 @@ main(
set_conf_val(OPT_S, S_LOG, tmp);
set_conf_val(OPT_D, D_SECTLOG, tmp);
- lsectorlog = tmp;
+ set_conf_val(OPT_L, L_SECTLOG, tmp);
set_conf_val(OPT_D, D_SECTSIZE,
1 << tmp);
set_conf_val(OPT_S, S_SIZE, 1 << tmp);
set_conf_val(OPT_S, S_SECTSIZE,
1 << tmp);
- lsectorsize = tmp;
+ set_conf_val(OPT_L, L_SECTSIZE, tmp);
lslflag = slflag = 1;
break;
case S_SIZE:
@@ -2094,14 +2075,15 @@ main(
set_conf_val(OPT_S, S_SIZE, tmp);
set_conf_val(OPT_D, D_SECTSIZE, tmp);
- lsectorsize = tmp;
+ set_conf_val(OPT_L, L_SECTSIZE, tmp);
+ set_conf_val(OPT_L, L_SECTLOG,
+ libxfs_highbit32(tmp));
set_conf_val(OPT_D, D_SECTLOG,
libxfs_highbit32(tmp));
set_conf_val(OPT_S, S_LOG,
libxfs_highbit32(tmp));
set_conf_val(OPT_S, S_SECTLOG,
libxfs_highbit32(tmp));
- lsectorlog = libxfs_highbit32(tmp);
lssflag = ssflag = 1;
break;
@@ -2158,8 +2140,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));
}
/*
@@ -2172,8 +2155,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)
@@ -2221,9 +2205,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));
}
}
@@ -2244,13 +2230,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;
}
@@ -2403,19 +2392,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)));
}
@@ -2507,8 +2497,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;
@@ -2516,16 +2507,18 @@ _("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);
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);
@@ -2554,7 +2547,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 */
@@ -2568,10 +2562,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");
@@ -2607,12 +2601,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();
@@ -2624,11 +2619,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)) {
@@ -2904,27 +2900,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),
@@ -2932,35 +2932,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(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. */
@@ -3024,16 +3030,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));
@@ -3051,25 +3057,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)) {
@@ -3082,8 +3091,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);
@@ -3115,7 +3125,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);
@@ -3156,7 +3168,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;
@@ -3164,8 +3176,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) {
@@ -3177,10 +3192,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;
@@ -3188,7 +3204,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)
@@ -3250,7 +3266,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) {
@@ -3327,7 +3344,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) -
@@ -3401,7 +3419,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
@@ -3452,7 +3471,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) -
@@ -3587,7 +3607,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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/5] mkfs: replace variables with opts table: -n options
2017-07-20 9:51 [PATCH 0/5] mkfs: use user values saved in opts table Jan Tulak
` (2 preceding siblings ...)
2017-07-20 9:51 ` [PATCH 3/5] mkfs: replace variables with opts table: -l options Jan Tulak
@ 2017-07-20 9:51 ` Jan Tulak
2017-07-20 9:51 ` [PATCH 5/5] mkfs: replace variables with opts table: -r options Jan Tulak
4 siblings, 0 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-20 9:51 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 | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 1bc3351f..8c582b87 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1476,8 +1476,6 @@ main(
int dasize;
xfs_rfsblock_t dblocks;
char *dfile;
- int dirblocklog;
- int dirblocksize;
bool force_overwrite;
struct fsxattr fsx;
int ilflag;
@@ -1557,7 +1555,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;
@@ -1923,26 +1920,23 @@ main(
char **subopts =
(char **)opts[OPT_N].subopts;
char *value;
+ uint64_t tmp;
switch (getsubopt(&p, subopts, &value)) {
case N_LOG:
- dirblocklog = parse_conf_val(OPT_N,
+ tmp = parse_conf_val(OPT_N,
N_LOG,
value);
- dirblocksize = 1 << dirblocklog;
+ set_conf_val(OPT_N, N_SIZE, 1 << tmp);
nlflag = 1;
- set_conf_val(OPT_N, N_SIZE,
- dirblocksize);
break;
case N_SIZE:
- dirblocksize = parse_conf_val(OPT_N,
+ tmp = parse_conf_val(OPT_N,
N_SIZE,
value);
- dirblocklog =
- libxfs_highbit32(dirblocksize);
- nsflag = 1;
set_conf_val(OPT_N, N_LOG,
- dirblocklog);
+ libxfs_highbit32(tmp));
+ nsflag = 1;
break;
case N_VERSION:
value = getstr(value, &opts[OPT_N],
@@ -2342,18 +2336,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));
}
@@ -2931,7 +2926,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,
@@ -3122,7 +3118,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, "",
@@ -3174,7 +3171,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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/5] mkfs: replace variables with opts table: -r options
2017-07-20 9:51 [PATCH 0/5] mkfs: use user values saved in opts table Jan Tulak
` (3 preceding siblings ...)
2017-07-20 9:51 ` [PATCH 4/5] mkfs: replace variables with opts table: -n options Jan Tulak
@ 2017-07-20 9:51 ` Jan Tulak
2017-07-21 12:36 ` [PATCH 5/5 v2] " Jan Tulak
4 siblings, 1 reply; 13+ messages in thread
From: Jan Tulak @ 2017-07-20 9:51 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 | 70 +++++++++++++++++++++++++++++----------------------------
1 file changed, 36 insertions(+), 34 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 8c582b87..27b476d2 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1501,7 +1501,6 @@ main(
xfs_mount_t mbuf;
xfs_extlen_t nbmblocks;
int nlflag;
- int norsflag;
xfs_alloc_rec_t *nrec;
int nsflag;
int nvflag;
@@ -1512,10 +1511,8 @@ main(
char *protostring;
int qflag;
xfs_rfsblock_t rtblocks;
- int rtbytes;
xfs_extlen_t rtextblocks;
xfs_rtblock_t rtextents;
- int rtextbytes;
char *rtfile;
xfs_sb_t *sbp;
__uint64_t sector_mask;
@@ -1558,9 +1555,7 @@ main(
qflag = false;
dfile = logfile = rtfile = NULL;
protofile = NULL;
- rtbytes = rtextbytes = 0;
lalign = 0;
- norsflag = false;
force_overwrite = false;
worst_freelist = 0;
memset(&fsx, 0, sizeof(fsx));
@@ -1987,9 +1982,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,
@@ -2004,13 +1998,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);
@@ -2155,7 +2147,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)
@@ -2404,33 +2399,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 {
/*
@@ -2439,20 +2437,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;
}
}
@@ -2621,7 +2622,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\
@@ -2629,16 +2630,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(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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 1/5 v2] mkfs: replace variables with opts table: -b,d,s options
2017-07-20 9:51 ` [PATCH 1/5] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
@ 2017-07-21 12:34 ` Jan Tulak
2017-07-27 16:39 ` Luis R. Rodriguez
0 siblings, 1 reply; 13+ messages in thread
From: Jan Tulak @ 2017-07-21 12:34 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>
---
UPDATE:
* just rebase and solve conflict against "mkfs: remove intermediate getstr
followed by getnum"
---
mkfs/xfs_mkfs.c | 872 ++++++++++++++++++++++++++++++++++----------------------
1 file changed, 532 insertions(+), 340 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 3f508a55..1bce66f9 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
@@ -760,14 +754,14 @@ struct opt_params {
/*
* Get and set values to the opts table.
*/
-static inline uint64_t
+static inline long long
get_conf_val(int opt, int subopt)
{
return opts[opt].subopt_params[subopt].value;
}
static void
-set_conf_val(int opt, int subopt, uint64_t val)
+set_conf_val(int opt, int subopt, long long val)
{
struct subopt_param *sp = &opts[opt].subopt_params[subopt];
@@ -883,7 +877,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;
@@ -907,7 +902,7 @@ getnum(
/*
* A wrapper for getnum and set_conf_val.
*/
-static inline uint64_t
+static inline long long
parse_conf_val(int opt, int subopt, char *value)
{
uint64_t num = getnum(value, &opts[opt], subopt);
@@ -970,16 +965,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);
}
}
@@ -1135,7 +1130,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);
@@ -1229,9 +1224,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);
@@ -1465,15 +1460,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;
@@ -1484,11 +1476,6 @@ main(
char *dfile;
int dirblocklog;
int dirblocksize;
- uint64_t dbytes;
- int dsu;
- int dsw;
- int dsunit;
- int dswidth;
bool force_overwrite;
struct fsxattr fsx;
int ilflag;
@@ -1525,7 +1512,6 @@ main(
xfs_mount_t mbuf;
xfs_extlen_t nbmblocks;
int nlflag;
- int nodsflag;
int norsflag;
xfs_alloc_rec_t *nrec;
int nsflag;
@@ -1543,7 +1529,6 @@ main(
uint64_t rtextbytes;
char *rtfile;
xfs_sb_t *sbp;
- int sectorlog;
__uint64_t sector_mask;
int slflag;
int ssflag;
@@ -1576,12 +1561,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;
@@ -1590,10 +1574,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;
- nodsflag = norsflag = 0;
- force_overwrite = 0;
+ rtbytes = rtextbytes = logbytes = 0;
+ lalign = lsu = lsunit = 0;
+ norsflag = false;
+ force_overwrite = false;
worst_freelist = 0;
memset(&fsx, 0, sizeof(fsx));
@@ -1609,6 +1593,7 @@ main(
break;
case 'b':
p = optarg;
+ uint64_t tmp;
while (*p != '\0') {
char **subopts =
(char **)opts[OPT_B].subopts;
@@ -1616,19 +1601,17 @@ main(
switch (getsubopt(&p, subopts, &value)) {
case B_LOG:
- blocklog = parse_conf_val(OPT_B, B_LOG,
- value);
- blocksize = 1 << blocklog;
+ tmp = parse_conf_val(OPT_B, B_LOG,
+ value);
+ set_conf_val(OPT_B, B_SIZE, 1 << tmp);
blflag = 1;
- set_conf_val(OPT_B, B_SIZE, blocksize);
break;
case B_SIZE:
- blocksize = parse_conf_val(OPT_B,
- B_SIZE,
- value);
- blocklog = libxfs_highbit32(blocksize);
+ tmp = parse_conf_val(OPT_B, B_SIZE,
+ value);
+ set_conf_val(OPT_B, B_LOG,
+ libxfs_highbit32(tmp));
bsflag = 1;
- set_conf_val(OPT_B, B_LOG, blocklog);
break;
default:
unknown('b', value);
@@ -1641,18 +1624,17 @@ main(
char **subopts =
(char **)opts[OPT_D].subopts;
char *value;
+ uint64_t tmp;
+
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:
@@ -1666,49 +1648,70 @@ 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);
break;
case D_SWIDTH:
- dswidth = parse_conf_val(OPT_D,
- D_SWIDTH,
- value);
+ parse_conf_val(OPT_D, D_SWIDTH, value);
break;
case D_SU:
- dsu = parse_conf_val(OPT_D, D_SU,
- value);
+ parse_conf_val(OPT_D, D_SU, value);
break;
case D_SW:
- dsw = parse_conf_val(OPT_D, D_SW,
- value);
+ parse_conf_val(OPT_D, D_SW, value);
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;
- slflag = 1;
+ /*
+ * we can set sector size both as
+ * -d sectsize/sectlog and as -s option.
+ * Thus we need to fill the same value
+ * into multiple options to make sure
+ * that we are doing the parsing right.
+ * Only D_SECTSIZE/D_SECTLOG is used
+ * later in the code, though.
+ */
+ tmp = parse_conf_val(OPT_D, D_SECTLOG,
+ value);
+
+ set_conf_val(OPT_S, S_LOG, tmp);
+ set_conf_val(OPT_S, S_SECTLOG, tmp);
set_conf_val(OPT_D, D_SECTSIZE,
- sectorsize);
+ 1 << tmp);
+ set_conf_val(OPT_S, S_SECTSIZE,
+ 1 << tmp);
+ set_conf_val(OPT_S, S_SIZE,
+ 1 << tmp);
+ slflag = 1;
break;
case D_SECTSIZE:
- sectorsize = parse_conf_val(OPT_D,
- D_SECTSIZE,
- value);
- sectorlog =
- libxfs_highbit32(sectorsize);
- ssflag = 1;
+ /*
+ * we can set sector size both as
+ * -d sectsize/sectlog and as -s option.
+ * Thus we need to fill the same value
+ * into multiple options to make sure
+ * that we are doing the parsing right.
+ * Only D_SECTSIZE/D_SECTLOG is used
+ * later in the code, though.
+ */
+ tmp = parse_conf_val(OPT_D, D_SECTSIZE,
+ value);
+
+ set_conf_val(OPT_S, S_SIZE, tmp);
+ set_conf_val(OPT_S, S_SECTSIZE, tmp);
set_conf_val(OPT_D, D_SECTLOG,
- sectorlog);
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_LOG,
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_SECTLOG,
+ libxfs_highbit32(tmp));
+
+ ssflag = 1;
break;
case D_RTINHERIT:
c = parse_conf_val(OPT_D, D_RTINHERIT,
@@ -2053,6 +2056,16 @@ main(
char **subopts =
(char **)opts[OPT_S].subopts;
char *value;
+ uint64_t tmp;
+ /*
+ * we can set sector size both as
+ * -d sectsize/sectlog and as -s option.
+ * Thus we need to fill the same value
+ * into multiple options to make sure
+ * that we are doing the parsing right.
+ * Only D_SECTSIZE/D_SECTLOG is used
+ * later in the code, though.
+ */
switch (getsubopt(&p, subopts, &value)) {
case S_LOG:
@@ -2061,14 +2074,21 @@ 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;
+
+ set_conf_val(OPT_S, S_LOG, tmp);
+ set_conf_val(OPT_D, D_SECTLOG, tmp);
+ lsectorlog = tmp;
+ set_conf_val(OPT_D, D_SECTSIZE,
+ 1 << tmp);
+ set_conf_val(OPT_S, S_SIZE, 1 << tmp);
+ set_conf_val(OPT_S, S_SECTSIZE,
+ 1 << tmp);
+
+ lsectorsize = tmp;
lslflag = slflag = 1;
- set_conf_val(OPT_S, S_LOG, sectorsize);
break;
case S_SIZE:
case S_SECTSIZE:
@@ -2076,16 +2096,22 @@ 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;
+
+ set_conf_val(OPT_S, S_SIZE, tmp);
+ set_conf_val(OPT_D, D_SECTSIZE, tmp);
+ lsectorsize = tmp;
+ set_conf_val(OPT_D, D_SECTLOG,
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_LOG,
+ libxfs_highbit32(tmp));
+ set_conf_val(OPT_S, S_SECTLOG,
+ libxfs_highbit32(tmp));
+ lsectorlog = libxfs_highbit32(tmp);
+
lssflag = ssflag = 1;
- set_conf_val(OPT_S,
- S_SIZE, sectorlog);
break;
default:
unknown('s', value);
@@ -2109,19 +2135,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);
@@ -2133,12 +2162,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);
}
/*
@@ -2148,7 +2177,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,
@@ -2177,50 +2207,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;
}
@@ -2322,37 +2360,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
@@ -2373,12 +2415,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) {
@@ -2387,24 +2431,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,
@@ -2419,18 +2466,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);
@@ -2438,22 +2488,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);
}
@@ -2464,10 +2517,20 @@ _("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);
- 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.
@@ -2490,7 +2553,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);
@@ -2525,16 +2589,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(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();
}
@@ -2549,17 +2614,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, _(
@@ -2567,11 +2633,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)) {
@@ -2590,119 +2657,173 @@ 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);
+ 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) {
@@ -2712,30 +2833,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);
}
}
@@ -2744,53 +2881,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"),
@@ -2811,17 +2964,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 {
/*
@@ -2830,34 +2985,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;
@@ -2865,7 +3024,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) {
@@ -2878,9 +3040,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);
@@ -2888,14 +3053,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));
/*
@@ -2903,45 +3070,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);
@@ -2950,7 +3125,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;
@@ -2960,15 +3135,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);
@@ -2976,14 +3151,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;
@@ -2993,11 +3169,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 {
@@ -3005,7 +3182,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);
@@ -3025,7 +3205,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);
@@ -3035,8 +3215,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);
@@ -3078,7 +3260,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);
@@ -3090,7 +3272,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);
@@ -3102,13 +3284,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);
@@ -3130,7 +3316,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))
@@ -3138,7 +3325,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)
@@ -3154,7 +3342,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);
@@ -3173,11 +3361,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);
@@ -3202,7 +3392,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);
@@ -3237,7 +3427,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;
@@ -3252,7 +3443,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);
@@ -3277,7 +3468,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;
@@ -3295,7 +3487,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);
@@ -3310,7 +3502,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);
@@ -3323,7 +3515,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);
}
@@ -3337,7 +3529,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);
@@ -3413,7 +3605,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);
/*
@@ -3422,14 +3614,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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/5 v2] mkfs: replace variables with opts table: -l options
2017-07-20 9:51 ` [PATCH 3/5] mkfs: replace variables with opts table: -l options Jan Tulak
@ 2017-07-21 12:35 ` Jan Tulak
0 siblings, 0 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-21 12:35 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>
---
UPDATE:
* just rebase and solve conflict against "mkfs: remove intermediate getstr
followed by getnum"
---
mkfs/xfs_mkfs.c | 259 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 140 insertions(+), 119 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index de6d0ed0..e43bb2e0 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 },
@@ -912,7 +913,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(
@@ -964,7 +966,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"),
@@ -1487,22 +1489,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;
@@ -1557,20 +1552,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;
norsflag = false;
force_overwrite = false;
worst_freelist = 0;
@@ -1804,9 +1796,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:
@@ -1815,20 +1805,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:
@@ -1837,7 +1823,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;
@@ -1851,29 +1837,24 @@ main(
sb_feat.log_version);
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,
+ tmp = parse_conf_val(OPT_L,
L_SECTLOG,
value);
- lsectorsize = 1 << lsectorlog;
- lslflag = 1;
set_conf_val(OPT_L, L_SECTSIZE,
- lsectorsize);
+ 1 << tmp);
+ lslflag = 1;
break;
case L_SECTSIZE:
- lsectorsize =
+ tmp =
parse_conf_val(OPT_L,
L_SECTSIZE,
value);
- lsectorlog =
- libxfs_highbit32(lsectorsize);
- lssflag = 1;
set_conf_val(OPT_L, L_SECTLOG,
- lsectorlog);
+ libxfs_highbit32(tmp));
+ lssflag = 1;
break;
case L_LAZYSBCNTR:
sb_feat.lazy_sb_counters =
@@ -2072,14 +2053,14 @@ main(
set_conf_val(OPT_S, S_LOG, tmp);
set_conf_val(OPT_D, D_SECTLOG, tmp);
- lsectorlog = tmp;
+ set_conf_val(OPT_L, L_SECTLOG, tmp);
set_conf_val(OPT_D, D_SECTSIZE,
1 << tmp);
set_conf_val(OPT_S, S_SIZE, 1 << tmp);
set_conf_val(OPT_S, S_SECTSIZE,
1 << tmp);
- lsectorsize = tmp;
+ set_conf_val(OPT_L, L_SECTSIZE, tmp);
lslflag = slflag = 1;
break;
case S_SIZE:
@@ -2094,14 +2075,15 @@ main(
set_conf_val(OPT_S, S_SIZE, tmp);
set_conf_val(OPT_D, D_SECTSIZE, tmp);
- lsectorsize = tmp;
+ set_conf_val(OPT_L, L_SECTSIZE, tmp);
+ set_conf_val(OPT_L, L_SECTLOG,
+ libxfs_highbit32(tmp));
set_conf_val(OPT_D, D_SECTLOG,
libxfs_highbit32(tmp));
set_conf_val(OPT_S, S_LOG,
libxfs_highbit32(tmp));
set_conf_val(OPT_S, S_SECTLOG,
libxfs_highbit32(tmp));
- lsectorlog = libxfs_highbit32(tmp);
lssflag = ssflag = 1;
break;
@@ -2158,8 +2140,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));
}
/*
@@ -2172,8 +2155,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)
@@ -2221,9 +2205,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));
}
}
@@ -2244,13 +2230,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;
}
@@ -2403,19 +2392,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)));
}
@@ -2507,8 +2497,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;
@@ -2516,16 +2507,18 @@ _("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);
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);
@@ -2554,7 +2547,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 */
@@ -2568,10 +2562,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");
@@ -2607,12 +2601,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();
@@ -2624,11 +2619,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)) {
@@ -2904,27 +2900,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),
@@ -2932,35 +2932,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(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. */
@@ -3024,16 +3030,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));
@@ -3051,25 +3057,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)) {
@@ -3082,8 +3091,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);
@@ -3115,7 +3125,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);
@@ -3156,7 +3168,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;
@@ -3164,8 +3176,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) {
@@ -3177,10 +3192,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;
@@ -3188,7 +3204,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)
@@ -3250,7 +3266,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) {
@@ -3327,7 +3344,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) -
@@ -3401,7 +3419,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
@@ -3452,7 +3471,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) -
@@ -3587,7 +3607,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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/5 v2] mkfs: replace variables with opts table: -r options
2017-07-20 9:51 ` [PATCH 5/5] mkfs: replace variables with opts table: -r options Jan Tulak
@ 2017-07-21 12:36 ` Jan Tulak
0 siblings, 0 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-21 12:36 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>
---
UPDATE:
* just rebase and solve conflict against "mkfs: remove intermediate getstr
followed by getnum"
---
mkfs/xfs_mkfs.c | 70 +++++++++++++++++++++++++++++----------------------------
1 file changed, 36 insertions(+), 34 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index fd678bba..27b476d2 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1501,7 +1501,6 @@ main(
xfs_mount_t mbuf;
xfs_extlen_t nbmblocks;
int nlflag;
- int norsflag;
xfs_alloc_rec_t *nrec;
int nsflag;
int nvflag;
@@ -1512,10 +1511,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;
@@ -1558,9 +1555,7 @@ main(
qflag = false;
dfile = logfile = rtfile = NULL;
protofile = NULL;
- rtbytes = rtextbytes = 0;
lalign = 0;
- norsflag = false;
force_overwrite = false;
worst_freelist = 0;
memset(&fsx, 0, sizeof(fsx));
@@ -1987,9 +1982,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,
@@ -2004,13 +1998,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);
@@ -2155,7 +2147,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)
@@ -2404,33 +2399,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 {
/*
@@ -2439,20 +2437,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;
}
}
@@ -2621,7 +2622,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\
@@ -2629,16 +2630,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(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.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5 v2] mkfs: replace variables with opts table: -b,d,s options
2017-07-21 12:34 ` [PATCH 1/5 v2] " Jan Tulak
@ 2017-07-27 16:39 ` Luis R. Rodriguez
2017-07-28 2:18 ` Eric Sandeen
2017-07-28 14:44 ` Jan Tulak
0 siblings, 2 replies; 13+ messages in thread
From: Luis R. Rodriguez @ 2017-07-27 16:39 UTC (permalink / raw)
To: Jan Tulak; +Cc: linux-xfs
On Fri, Jul 21, 2017 at 02:34:48PM +0200, Jan Tulak wrote:
> @@ -1609,6 +1593,7 @@ main(
> break;
> case 'b':
> p = optarg;
> + uint64_t tmp;
Note:
An extra variable added, just so we can get the current value parsed
so we can then convert it to also set similar collateral variables.
> while (*p != '\0') {
> char **subopts =
> (char **)opts[OPT_B].subopts;
> @@ -1616,19 +1601,17 @@ main(
>
> switch (getsubopt(&p, subopts, &value)) {
> case B_LOG:
> - blocklog = parse_conf_val(OPT_B, B_LOG,
> - value);
> - blocksize = 1 << blocklog;
> + tmp = parse_conf_val(OPT_B, B_LOG,
> + value);
> + set_conf_val(OPT_B, B_SIZE, 1 << tmp);
So here when BLOG is set we update B_SIZE as collateral.
> blflag = 1;
> - set_conf_val(OPT_B, B_SIZE, blocksize);
> break;
> case B_SIZE:
> - blocksize = parse_conf_val(OPT_B,
> - B_SIZE,
> - value);
> - blocklog = libxfs_highbit32(blocksize);
> + tmp = parse_conf_val(OPT_B, B_SIZE,
> + value);
> + set_conf_val(OPT_B, B_LOG,
> + libxfs_highbit32(tmp));
Here is the reverse, when B_SIZE is set we set B_LOG as well.
> bsflag = 1;
> - set_conf_val(OPT_B, B_LOG, blocklog);
> break;
> default:
> unknown('b', value);
> @@ -1641,18 +1624,17 @@ main(
> char **subopts =
> (char **)opts[OPT_D].subopts;
> char *value;
> + uint64_t tmp;
> +
>
> 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);
If parse_conf_val() could just update the collateral values for us then main()
would be much cleaner.
Here parse_conf_val() is used only to update D_AGCOUNT based on the parsed
value. But note that the return value is ignored. In some other places the
return value is used. This is inconsistent, and I realize that the reason
we ignore errors is that getnum() is used, however now is a good time to
consider if we should just allow the caller to check the error value and
return a proper error message and bail on their own. This would allow for
better contextual error messages as the code grows. We can discuss this in
the patch that adds parse_conf_val().
> @@ -2464,10 +2517,20 @@ _("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);
Is int proper here?
Luis
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5 v2] mkfs: replace variables with opts table: -b,d,s options
2017-07-27 16:39 ` Luis R. Rodriguez
@ 2017-07-28 2:18 ` Eric Sandeen
2017-07-28 14:43 ` Jan Tulak
2017-07-28 14:44 ` Jan Tulak
1 sibling, 1 reply; 13+ messages in thread
From: Eric Sandeen @ 2017-07-28 2:18 UTC (permalink / raw)
To: Luis R. Rodriguez, Jan Tulak; +Cc: linux-xfs
On 7/27/17 11:39 AM, Luis R. Rodriguez wrote:
> On Fri, Jul 21, 2017 at 02:34:48PM +0200, Jan Tulak wrote:
>> @@ -1609,6 +1593,7 @@ main(
>> break;
>> case 'b':
>> p = optarg;
>> + uint64_t tmp;
> Note:
>
> An extra variable added, just so we can get the current value parsed
> so we can then convert it to also set similar collateral variables.
Also, please don't declare variables in the middle of code like this,
we generally stick to C89 rules.
Thanks,
-Eric
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5 v2] mkfs: replace variables with opts table: -b,d,s options
2017-07-28 2:18 ` Eric Sandeen
@ 2017-07-28 14:43 ` Jan Tulak
0 siblings, 0 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-28 14:43 UTC (permalink / raw)
To: Eric Sandeen, Luis R. Rodriguez; +Cc: linux-xfs
On 28/07/2017 04:18, Eric Sandeen wrote:
> On 7/27/17 11:39 AM, Luis R. Rodriguez wrote:
>> On Fri, Jul 21, 2017 at 02:34:48PM +0200, Jan Tulak wrote:
>>> @@ -1609,6 +1593,7 @@ main(
>>> break;
>>> case 'b':
>>> p = optarg;
>>> + uint64_t tmp;
>> Note:
>>
>> An extra variable added, just so we can get the current value parsed
>> so we can then convert it to also set similar collateral variables.
> Also, please don't declare variables in the middle of code like this,
> we generally stick to C89 rules.
>
> Thanks,
> -Eric
OK
Jan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5 v2] mkfs: replace variables with opts table: -b,d,s options
2017-07-27 16:39 ` Luis R. Rodriguez
2017-07-28 2:18 ` Eric Sandeen
@ 2017-07-28 14:44 ` Jan Tulak
1 sibling, 0 replies; 13+ messages in thread
From: Jan Tulak @ 2017-07-28 14:44 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: linux-xfs
On 27/07/2017 18:39, Luis R. Rodriguez wrote:
> On Fri, Jul 21, 2017 at 02:34:48PM +0200, Jan Tulak wrote:
>> @@ -1609,6 +1593,7 @@ main(
>> break;
>> case 'b':
>> p = optarg;
>> + uint64_t tmp;
> Note:
>
> An extra variable added, just so we can get the current value parsed
> so we can then convert it to also set similar collateral variables.
>
>> while (*p != '\0') {
>> char **subopts =
>> (char **)opts[OPT_B].subopts;
>> @@ -1616,19 +1601,17 @@ main(
>>
>> switch (getsubopt(&p, subopts, &value)) {
>> case B_LOG:
>> - blocklog = parse_conf_val(OPT_B, B_LOG,
>> - value);
>> - blocksize = 1 << blocklog;
>> + tmp = parse_conf_val(OPT_B, B_LOG,
>> + value);
>> + set_conf_val(OPT_B, B_SIZE, 1 << tmp);
> So here when BLOG is set we update B_SIZE as collateral.
>
>> blflag = 1;
>> - set_conf_val(OPT_B, B_SIZE, blocksize);
>> break;
>> case B_SIZE:
>> - blocksize = parse_conf_val(OPT_B,
>> - B_SIZE,
>> - value);
>> - blocklog = libxfs_highbit32(blocksize);
>> + tmp = parse_conf_val(OPT_B, B_SIZE,
>> + value);
>> + set_conf_val(OPT_B, B_LOG,
>> + libxfs_highbit32(tmp));
> Here is the reverse, when B_SIZE is set we set B_LOG as well.
>
>> bsflag = 1;
>> - set_conf_val(OPT_B, B_LOG, blocklog);
>> break;
>> default:
>> unknown('b', value);
>> @@ -1641,18 +1624,17 @@ main(
>> char **subopts =
>> (char **)opts[OPT_D].subopts;
>> char *value;
>> + uint64_t tmp;
>> +
>>
>> 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);
> If parse_conf_val() could just update the collateral values for us then main()
> would be much cleaner.
It didn't occurred to me that these collaterals could be put into
parse_conf_val(). That would certainly help both with the main and with
spotting bugs where some collateral is not set correctly in all cases.
It seems there should be no issue with that, so I will try to change it
in the next revision of this set.
> Here parse_conf_val() is used only to update D_AGCOUNT based on the parsed
> value. But note that the return value is ignored. In some other places the
> return value is used. This is inconsistent, and I realize that the reason
> we ignore errors is that getnum() is used, however now is a good time to
> consider if we should just allow the caller to check the error value and
> return a proper error message and bail on their own. This would allow for
> better contextual error messages as the code grows. We can discuss this in
> the patch that adds parse_conf_val().
The returned value is used to shorter parse_conf_val(X); tmp =
get_conf_val(X); to just tmp = parse_conf_val();, not for testing for
errors.
>
>> @@ -2464,10 +2517,20 @@ _("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);
> Is int proper here?
>
calc_stripe_factors() has all arguments as int since 2002, so I see no
issue here - it doesn't change anything.
Jan
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-07-28 14:44 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20 9:51 [PATCH 0/5] mkfs: use user values saved in opts table Jan Tulak
2017-07-20 9:51 ` [PATCH 1/5] mkfs: replace variables with opts table: -b,d,s options Jan Tulak
2017-07-21 12:34 ` [PATCH 1/5 v2] " Jan Tulak
2017-07-27 16:39 ` Luis R. Rodriguez
2017-07-28 2:18 ` Eric Sandeen
2017-07-28 14:43 ` Jan Tulak
2017-07-28 14:44 ` Jan Tulak
2017-07-20 9:51 ` [PATCH 2/5] mkfs: replace variables with opts table: -i options Jan Tulak
2017-07-20 9:51 ` [PATCH 3/5] mkfs: replace variables with opts table: -l options Jan Tulak
2017-07-21 12:35 ` [PATCH 3/5 v2] " Jan Tulak
2017-07-20 9:51 ` [PATCH 4/5] mkfs: replace variables with opts table: -n options Jan Tulak
2017-07-20 9:51 ` [PATCH 5/5] mkfs: replace variables with opts table: -r options Jan Tulak
2017-07-21 12:36 ` [PATCH 5/5 v2] " Jan Tulak
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.