From: Darrick J. Wong Date: Wed, 18 May 2022 02:48:13 +0000 (-0400) Subject: mkfs: improve log extent validation X-Git-Tag: v5.18.0-rc1~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93a199f21dd12fdef4cbcb6821e58e2c301727e2;p=thirdparty%2Fxfsprogs-dev.git mkfs: improve log extent validation 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 Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 8abbd2310..370ad8b38 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -208,6 +208,7 @@ #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 diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 0b1fb7467..b932acaae 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -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;