]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: improve log extent validation
authorDarrick J. Wong <djwong@kernel.org>
Wed, 18 May 2022 02:48:13 +0000 (22:48 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 18 May 2022 02:48:13 +0000 (22:48 -0400)
Use the standard libxfs fsblock verifiers to check the start and end of
the internal log.  The current code does not catch the case of a
(segmented) fsblock that is beyond agf_blocks but not so large to change
the agno part of the segmented fsblock.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
mkfs/xfs_mkfs.c

index 8abbd2310acd54e1e13aa4bb83dc4cb3f14a5c72..370ad8b3822037058156ad1c1aeeeffa52e54df0 100644 (file)
 #define xfs_verify_agino               libxfs_verify_agino
 #define xfs_verify_cksum               libxfs_verify_cksum
 #define xfs_verify_dir_ino             libxfs_verify_dir_ino
+#define xfs_verify_fsbext              libxfs_verify_fsbext
 #define xfs_verify_fsbno               libxfs_verify_fsbno
 #define xfs_verify_ino                 libxfs_verify_ino
 #define xfs_verify_rtbno               libxfs_verify_rtbno
index 0b1fb746796dec7141f2c62b8b83cc064591ae8f..b932acaae2f9a7d8fbf36b2d2ef535875ff4bbd2 100644 (file)
@@ -3218,15 +3218,13 @@ align_internal_log(
        int                     sunit,
        int                     max_logblocks)
 {
-       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_FSB_TO_AGBNO(mp, cfg->logstart) <= XFS_AGFL_BLOCK(mp)) {
-                       fprintf(stderr,
+       if (!libxfs_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);
@@ -3237,8 +3235,7 @@ _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
        align_log_size(cfg, sunit, max_logblocks);
 
        /* check the aligned log still starts and ends in the same AG. */
-       logend = cfg->logstart + cfg->logblocks - 1;
-       if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend)) {
+       if (!libxfs_verify_fsbext(mp, cfg->logstart, cfg->logblocks)) {
                fprintf(stderr,
 _("Due to stripe alignment, the internal log size (%lld) is too large.\n"
   "Must fit within an allocation group.\n"),
@@ -3465,6 +3462,7 @@ start_superblock_setup(
        sbp->sb_agblocks = (xfs_agblock_t)cfg->agsize;
        sbp->sb_agblklog = (uint8_t)log2_roundup(cfg->agsize);
        sbp->sb_agcount = (xfs_agnumber_t)cfg->agcount;
+       sbp->sb_dblocks = (xfs_rfsblock_t)cfg->dblocks;
 
        sbp->sb_inodesize = (uint16_t)cfg->inodesize;
        sbp->sb_inodelog = (uint8_t)cfg->inodelog;