74 lines
2.8 KiB
Diff
74 lines
2.8 KiB
Diff
From 93a199f21dd12fdef4cbcb6821e58e2c301727e2 Mon Sep 17 00:00:00 2001
|
|
From: "Darrick J. Wong" <djwong@kernel.org>
|
|
Date: Tue, 17 May 2022 22:48:13 -0400
|
|
Subject: [PATCH] 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 <djwong@kernel.org>
|
|
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
|
---
|
|
libxfs/libxfs_api_defs.h | 1 +
|
|
mkfs/xfs_mkfs.c | 10 ++++------
|
|
2 files changed, 5 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
|
|
index 8abbd23..370ad8b 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 0b1fb74..b932aca 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;
|
|
--
|
|
1.8.3.1
|
|
|