]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: validate start and end of aligned logs
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)
committerEric Sandeen <sandeen@redhat.com>
Tue, 25 Jun 2019 21:04:42 +0000 (17:04 -0400)
Validate that the start and end of the log stay within a single AG if
we adjust either end to align to stripe units.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
mkfs/xfs_mkfs.c

index ddb25ecc57462f86cf84f9ff13515ed638022be9..468b8fdead0f6479777ac3692305ece97c0467ea 100644 (file)
@@ -3033,15 +3033,28 @@ align_internal_log(
        struct xfs_mount        *mp,
        int                     sunit)
 {
+       uint64_t                logend;
+
        /* round up log start if necessary */
        if ((cfg->logstart % sunit) != 0)
                cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
 
+       /* If our log start overlaps the next AG's metadata, fail. */
+       if (!xfs_verify_fsbno(mp, cfg->logstart)) {
+                       fprintf(stderr,
+_("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
+  "within an allocation group.\n"),
+                       (long long) cfg->logstart);
+               usage();
+       }
+
        /* round up/down the log size now */
        align_log_size(cfg, sunit);
 
        /* check the aligned log still fits in an AG. */
-       if (cfg->logblocks > cfg->agsize - XFS_FSB_TO_AGBNO(mp, cfg->logstart)) {
+       logend = cfg->logstart + cfg->logblocks - 1;
+       if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) ||
+           !xfs_verify_fsbno(mp, logend)) {
                fprintf(stderr,
 _("Due to stripe alignment, the internal log size (%lld) is too large.\n"
   "Must fit within an allocation group.\n"),