Blame SOURCES/xfsprogs-5.1.0-mkfs-validate-start-and-end-of-aligned-logs.patch

14809d
From 8da52988ad210958f21c178620bb1e44f1188cd0 Mon Sep 17 00:00:00 2001
14809d
From: "Darrick J. Wong" <darrick.wong@oracle.com>
14809d
Date: Tue, 25 Jun 2019 17:04:42 -0400
14809d
Subject: [PATCH] mkfs: validate start and end of aligned logs
14809d
14809d
Validate that the start and end of the log stay within a single AG if
14809d
we adjust either end to align to stripe units.
14809d
14809d
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
14809d
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
14809d
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
14809d
---
14809d
 mkfs/xfs_mkfs.c | 15 ++++++++++++++-
14809d
 1 file changed, 14 insertions(+), 1 deletion(-)
14809d
14809d
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
14809d
index ddb25ecc..468b8fde 100644
14809d
--- a/mkfs/xfs_mkfs.c
14809d
+++ b/mkfs/xfs_mkfs.c
14809d
@@ -3033,15 +3033,28 @@ align_internal_log(
14809d
 	struct xfs_mount	*mp,
14809d
 	int			sunit)
14809d
 {
14809d
+	uint64_t		logend;
14809d
+
14809d
 	/* round up log start if necessary */
14809d
 	if ((cfg->logstart % sunit) != 0)
14809d
 		cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
14809d
 
14809d
+	/* If our log start overlaps the next AG's metadata, fail. */
14809d
+	if (!xfs_verify_fsbno(mp, cfg->logstart)) {
14809d
+			fprintf(stderr,
14809d
+_("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
14809d
+  "within an allocation group.\n"),
14809d
+			(long long) cfg->logstart);
14809d
+		usage();
14809d
+	}
14809d
+
14809d
 	/* round up/down the log size now */
14809d
 	align_log_size(cfg, sunit);
14809d
 
14809d
 	/* check the aligned log still fits in an AG. */
14809d
-	if (cfg->logblocks > cfg->agsize - XFS_FSB_TO_AGBNO(mp, cfg->logstart)) {
14809d
+	logend = cfg->logstart + cfg->logblocks - 1;
14809d
+	if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) ||
14809d
+	    !xfs_verify_fsbno(mp, logend)) {
14809d
 		fprintf(stderr,
14809d
 _("Due to stripe alignment, the internal log size (%lld) is too large.\n"
14809d
   "Must fit within an allocation group.\n"),
14809d
-- 
14809d
2.17.0
14809d