mkfs: custom agcount that renders AG size < XFS_AG_MIN_BYTES gives "Assertion failed. Aborted"
PATCH 1/1 mkfs: custom agcount that renders AG size < XFS_AG_MIN_BYTES gives "Assertion failed. Aborted"
For a 2GB FS we have
$ mkfs.xfs -f -d agcount=129 test.img mkfs.xfs: xfs_mkfs.c:3021: align_ag_geometry: Assertion `!cli_opt_set(&dopts, D_AGCOUNT)' failed. Aborted
With this change we have
$ mkfs.xfs -f -d agcount=129 test.img Invalid value 129 for -d agcount option. Value is too large.
--- mkfs/xfs_mkfs.c | 7 +++++++ 1 file changed, 7 insertions(+)
mkfs/xfs_mkfs.c +7 -0
@@ -2897,6 +2897,13 @@ _("agsize (%s) not a multiple of fs blk size (%d)\n"), cfg->agcount = cli->agcount; cfg->agsize = cfg->dblocks / cfg->agcount + (cfg->dblocks % cfg->agcount !=0 ); +if (cfg->agsize <XFS_AG_MIN_BYTES >> cfg->blocklog) + { +fprintf (stderr, +_ ("Invalid value %lld for -d agcount option. Value is too large.\n" ), + (long long )cli->agcount); +usage (); + } }else { calc_default_ag_geometry(cfg->blocklog, cfg->dblocks, cfg->dsunit, &cfg->agsize,
Signature · 1 line
2.25.1
Quoted 4 lines · Srikanth C S
For a 2GB FS we have
$ mkfs.xfs -f -d agcount=129 test.img mkfs.xfs: xfs_mkfs.c:3021: align_ag_geometry: Assertion `!cli_opt_set(&dopts, D_AGCOUNT)' failed. Aborted
Ok, that's because the size of the last AG is too small when trying to align the AG size to stripe geometry. It fails an assert that says "we should not get here if the agcount was specified on the CLI".
Quoted 4 lines
With this change we have
$ mkfs.xfs -f -d agcount=129 test.img Invalid value 129 for -d agcount option. Value is too large.
OK, but....
Quoted 11 lines
Signed-off-by Srikanth C S <[email protected]>--- mkfs/xfs_mkfs.c | 7 +++++++ 1 file changed, 7 insertions(+)mkfs/xfs_mkfs.c +0
-0
mkfs/xfs_mkfs.c _("agsize (%s) not a multiple of fs blk size (%d)\n"), · line 2906
Quoted 10 lines
mkfs/xfs_mkfs.c +7
-0@@ -2897,6 +2897,13 @@ _("agsize (%s) not a multiple of fs blk size (%d)\n"), cfg->agcount = cli->agcount; cfg->agsize = cfg->dblocks / cfg->agcount + (cfg->dblocks % cfg->agcount !=0 ); +if (cfg->agsize <XFS_AG_MIN_BYTES >> cfg->blocklog) + { +fprintf (stderr, +_ ("Invalid value %lld for -d agcount option. Value is too large.\n" ), + (long long )cli->agcount); +usage (); + }
.... that's not where we validate the calculated ag size. That happens via align_ag_geometry() -> validate_ag_geometry(). i.e. we can't reject an AG specification until after we've applied all the necessary modifiers to it first (such as stripe alignment requirements).
IOWs, we do actually check for valid AG sizes, it's just that this specific case hit an ASSERT() check before we got to validating the AG size. I'm pretty sure just removing the ASSERT - which assumes that "-d agcount=xxx" is not so large that it produces undersized AGs - will fix the problem and result in the correct error message being returned.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 6 lines · Dave Chinner
Quoted 4 lines · Srikanth C S
For a 2GB FS we have
$ mkfs.xfs -f -d agcount=129 test.img mkfs.xfs: xfs_mkfs.c:3021: align_ag_geometry: Assertion `!cli_opt_set(&dopts, D_AGCOUNT)' failed. Aborted
Quoted 9 lines
Ok, that's because the size of the last AG is too small when trying to align the AG size to stripe geometry. It fails an assert that says "we should not get here if the agcount was specified on the CLI".
Quoted 4 lines
With this change we have
$ mkfs.xfs -f -d agcount=129 test.img Invalid value 129 for -d agcount option. Value is too large.
What version of mkfs is this?
$ truncate -s 2g /tmp/a $ mkfs.xfs -V mkfs.xfs version 5.18.0 $ mkfs.xfs -f -d agcount=129 /tmp/a agsize (4065 blocks) too small, need at least 4096 blocks
Quoted 30 lines
OK, but....
Quoted 11 lines
Signed-off-by Srikanth C S <[email protected]>--- mkfs/xfs_mkfs.c | 7 +++++++ 1 file changed, 7 insertions(+)mkfs/xfs_mkfs.c +0
-0mkfs/xfs_mkfs.c _("agsize (%s) not a multiple of fs blk size (%d)\n"), · line 2906
Quoted 10 lines
mkfs/xfs_mkfs.c +7
-0@@ -2897,6 +2897,13 @@ _("agsize (%s) not a multiple of fs blk size (%d)\n"), cfg->agcount = cli->agcount; cfg->agsize = cfg->dblocks / cfg->agcount + (cfg->dblocks % cfg->agcount !=0 ); +if (cfg->agsize <XFS_AG_MIN_BYTES >> cfg->blocklog) + { +fprintf (stderr, +_ ("Invalid value %lld for -d agcount option. Value is too large.\n" ), + (long long )cli->agcount); +usage (); + }.... that's not where we validate the calculated ag size. That happens via
align_ag_geometry()->validate_ag_geometry(). i.e. we can't reject an AG specification until after we've applied all the necessary modifiers to it first (such as stripe alignment requirements).
Quoted 6 lines
IOWs, we do actually check for valid AG sizes, it's just that this specific case hit an
ASSERT()check before we got to validating the AG size. I'm pretty sure just removing the ASSERT - which assumes that "-d agcount=xxx" is not so large that it produces undersized AGs - will fix the problem and result in the correct error message being returned.
(Agreed.)
--D
Quoted 7 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 19 lines · Dave Chinner
Quoted 4 lines · Srikanth C S
Quoted 3 lines
For a 2GB FS we have
$ mkfs.xfs -f -d agcount=129 test.img mkfs.xfs: xfs_mkfs.c:3021: align_ag_geometry: Assertion`!cli_opt_set(&dopts,
D_AGCOUNT)' failed.Quoted 10 lines
Quoted 1 line
Aborted
Ok, that's because the size of the last AG is too small when trying to align the AG size to stripe geometry. It fails an assert that says "we should not get here if the agcount was specified on the CLI".
Quoted 4 lines
With this change we have
$ mkfs.xfs -f -d agcount=129 test.img Invalid value 129 for -d agcount option. Value is too large.
Quoted 8 lines
What version of mkfs is this?
$ truncate -s 2g /tmp/a $ mkfs.xfs -V mkfs.xfs version 5.18.0 $ mkfs.xfs -f -d agcount=129 /tmp/a agsize (4065 blocks) too small, need at least 4096 blocks
For the same version I get Assertion failed
$ truncate -s 2g /tmp/a $ mkfs.xfs -V mkfs.xfs version 5.18.0 $ mkfs.xfs -f -d agcount=129 /tmp/a mkfs.xfs: xfs_mkfs.c:3033: align_ag_geometry: Assertion `!cli_opt_set(&dopts, D_AGCOUNT)' failed. Aborted (core dumped)
Quoted 48 lines
Quoted 8 lines
OK, but....
Quoted 6 lines
Signed-off-by Srikanth C S <[email protected]>--- mkfs/xfs_mkfs.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 5 lines
mkfs/xfs_mkfs.c _("agsize (%s) not a multiple of fs blk size
Quoted 5 lines
mkfs/xfs_mkfs.c index renamed from mkfs/xfs_mkfs.c +0
-0
057b3b09..32dcbfff100644mkfs/xfs_mkfs.c +0
-0@@ -2897,6 +2897,13 @@ _("agsize (%s) not a multiple of fs blk size(%d)\n"),
Quoted 16 lines
mkfs/xfs_mkfs.c _("agsize (%s) not a multiple of fs blk size (%d)\n"), · line 2906
Quoted 10 lines
mkfs/xfs_mkfs.c +7
-0cfg->agcount = cli->agcount; cfg->agsize = cfg->dblocks / cfg->agcount + (cfg->dblocks % cfg->agcount !=0 ); +if (cfg->agsize <XFS_AG_MIN_BYTES >> cfg->blocklog) + { +fprintf (stderr, +_ ("Invalid value %lld for -d agcount option. Value is too large.\n" ), + (long long )cli->agcount); +usage (); + }.... that's not where we validate the calculated ag size. That happens via
align_ag_geometry()->validate_ag_geometry(). i.e. we can't reject an AG specification until after we've applied all the necessary modifiers to it first (such as stripe alignment requirements).Quoted 6 lines
IOWs, we do actually check for valid AG sizes, it's just that this specific case hit an
ASSERT()check before we got to validating the AG size. I'm pretty sure just removing the ASSERT - which assumes that "-d agcount=xxx" is not so large that it produces undersized AGs - will fix the problem and result in the correct error message being returned.(Agreed.)
--D
Quoted 7 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]
Quoted 28 lines · Srikanth C S
Quoted 19 lines · Dave Chinner
Quoted 4 lines · Srikanth C S
Quoted 3 lines
For a 2GB FS we have
$ mkfs.xfs -f -d agcount=129 test.img mkfs.xfs: xfs_mkfs.c:3021: align_ag_geometry: Assertion`!cli_opt_set(&dopts,
D_AGCOUNT)' failed.Quoted 10 lines
Quoted 1 line
Aborted
Ok, that's because the size of the last AG is too small when trying to align the AG size to stripe geometry. It fails an assert that says "we should not get here if the agcount was specified on the CLI".
Quoted 4 lines
With this change we have
$ mkfs.xfs -f -d agcount=129 test.img Invalid value 129 for -d agcount option. Value is too large.Quoted 8 lines
What version of mkfs is this?
$ truncate -s 2g /tmp/a $ mkfs.xfs -V mkfs.xfs version 5.18.0 $ mkfs.xfs -f -d agcount=129 /tmp/a agsize (4065 blocks) too small, need at least 4096 blocks
Quoted 7 lines
For the same version I get Assertion failed
$ truncate -s 2g /tmp/a $ mkfs.xfs -V mkfs.xfs version 5.18.0 $ mkfs.xfs -f -d agcount=129 /tmp/a mkfs.xfs: xfs_mkfs.c:3033: align_ag_geometry: Assertion `!cli_opt_set(&dopts, D_AGCOUNT)' failed. Aborted (core dumped)
ahaha, the distro package got built with -DNDEBUG, which turned off ASSERTions. With my upstream tot build I see this problem too...
Quoted 30 lines
Quoted 30 lines
Quoted 8 lines
OK, but....
Quoted 6 lines
Signed-off-by Srikanth C S <[email protected]>--- mkfs/xfs_mkfs.c | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 5 lines
mkfs/xfs_mkfs.c _("agsize (%s) not a multiple of fs blk size
Quoted 5 lines
mkfs/xfs_mkfs.c index renamed from mkfs/xfs_mkfs.c +0
-0
057b3b09..32dcbfff100644mkfs/xfs_mkfs.c +0
-0@@ -2897,6 +2897,13 @@ _("agsize (%s) not a multiple of fs blk size(%d)\n"),
Quoted 16 lines
mkfs/xfs_mkfs.c _("agsize (%s) not a multiple of fs blk size (%d)\n"), · line 2906
Quoted 10 lines
mkfs/xfs_mkfs.c +7
-0cfg->agcount = cli->agcount; cfg->agsize = cfg->dblocks / cfg->agcount + (cfg->dblocks % cfg->agcount !=0 ); +if (cfg->agsize <XFS_AG_MIN_BYTES >> cfg->blocklog) + { +fprintf (stderr, +_ ("Invalid value %lld for -d agcount option. Value is too large.\n" ), + (long long )cli->agcount); +usage (); + }.... that's not where we validate the calculated ag size. That happens via
align_ag_geometry()->validate_ag_geometry(). i.e. we can't reject an AG specification until after we've applied all the necessary modifiers to it first (such as stripe alignment requirements).
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
IOWs, we do actually check for valid AG sizes, it's just that this specific case hit an
ASSERT()check before we got to validating the AG size. I'm pretty sure just removing the ASSERT - which assumes that "-d agcount=xxx" is not so large that it produces undersized AGs - will fix the problem and result in the correct error message being returned.
...so yeah, what Dave said. :)
--D
Quoted 12 lines
Quoted 12 lines
(Agreed.)
--D
Quoted 7 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]