Blame SOURCES/xfsprogs-5.9.0-mkfs.xfs-fix-ASSERT-on-too-small-device-with-stripe.patch

48cf7c
From 97a4059660b27a9b0e3d8cdde5dbef8712685865 Mon Sep 17 00:00:00 2001
48cf7c
From: Pavel Reichl <preichl@redhat.com>
48cf7c
Date: Mon, 28 Sep 2020 17:31:18 -0400
48cf7c
Subject: [PATCH] mkfs.xfs: fix ASSERT on too-small device with stripe geometry
48cf7c
48cf7c
When a too-small device is created with stripe geometry, we hit an
48cf7c
assert in align_ag_geometry():
48cf7c
48cf7c
mkfs.xfs: xfs_mkfs.c:2834: align_ag_geometry: Assertion `cfg->agcount != 0' failed.
48cf7c
48cf7c
This is because align_ag_geometry() finds that the size of the last
48cf7c
(only) AG is too small, and attempts to trim it off.  Obviously 0
48cf7c
AGs is invalid, and we hit the ASSERT.
48cf7c
48cf7c
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
48cf7c
Suggested-by: Dave Chinner <dchinner@redhat.com>
48cf7c
Signed-off-by: Pavel Reichl <preichl@redhat.com>
48cf7c
Reviewed-by: Christoph Hellwig <hch@lst.de>
48cf7c
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
48cf7c
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
48cf7c
---
48cf7c
 include/xfs_multidisk.h | 14 +++++++-------
48cf7c
 mkfs/xfs_mkfs.c         |  6 +++---
48cf7c
 2 files changed, 10 insertions(+), 10 deletions(-)
48cf7c
48cf7c
Index: xfsprogs-5.0.0/include/xfs_multidisk.h
48cf7c
===================================================================
48cf7c
--- xfsprogs-5.0.0.orig/include/xfs_multidisk.h
48cf7c
+++ xfsprogs-5.0.0/include/xfs_multidisk.h
48cf7c
@@ -14,7 +14,6 @@
48cf7c
 #define	XFS_DFL_BLOCKSIZE_LOG	12		/* 4096 byte blocks */
48cf7c
 #define	XFS_DINODE_DFL_LOG	8		/* 256 byte inodes */
48cf7c
 #define	XFS_DINODE_DFL_CRC_LOG	9		/* 512 byte inodes for CRCs */
48cf7c
-#define	XFS_MIN_DATA_BLOCKS	100
48cf7c
 #define	XFS_MIN_INODE_PERBLOCK	2		/* min inodes per block */
48cf7c
 #define	XFS_DFL_IMAXIMUM_PCT	25		/* max % of space for inodes */
48cf7c
 #define	XFS_MIN_REC_DIRSIZE	12		/* 4096 byte dirblocks (V2) */
48cf7c
@@ -25,13 +24,14 @@
48cf7c
 						 * accept w/o warnings
48cf7c
 						 */
48cf7c
 
48cf7c
-#define XFS_AG_BYTES(bblog)	((long long)BBSIZE << (bblog))
48cf7c
-#define	XFS_AG_MIN_BYTES	((XFS_AG_BYTES(15)))	/* 16 MB */
48cf7c
-#define	XFS_AG_MAX_BYTES	((XFS_AG_BYTES(31)))	/* 1 TB */
48cf7c
-#define XFS_AG_MIN_BLOCKS(blog)	(XFS_AG_MIN_BYTES >> (blog))
48cf7c
-#define XFS_AG_MAX_BLOCKS(blog)	((XFS_AG_MAX_BYTES - 1) >> (blog))
48cf7c
+#define XFS_AG_BYTES(bblog)		((long long)BBSIZE << (bblog))
48cf7c
+#define	XFS_MIN_DATA_BLOCKS(cfg)	(XFS_AG_MIN_BLOCKS((cfg)->blocklog))
48cf7c
+#define	XFS_AG_MIN_BYTES		((XFS_AG_BYTES(15)))	/* 16 MB */
48cf7c
+#define	XFS_AG_MAX_BYTES		((XFS_AG_BYTES(31)))	/* 1 TB */
48cf7c
+#define XFS_AG_MIN_BLOCKS(blog)		(XFS_AG_MIN_BYTES >> (blog))
48cf7c
+#define XFS_AG_MAX_BLOCKS(blog)		((XFS_AG_MAX_BYTES - 1) >> (blog))
48cf7c
 
48cf7c
-#define XFS_MAX_AGNUMBER	((xfs_agnumber_t)(NULLAGNUMBER - 1))
48cf7c
+#define XFS_MAX_AGNUMBER		((xfs_agnumber_t)(NULLAGNUMBER - 1))
48cf7c
 
48cf7c
 /*
48cf7c
  * These values define what we consider a "multi-disk" filesystem. That is, a
48cf7c
Index: xfsprogs-5.0.0/mkfs/xfs_mkfs.c
48cf7c
===================================================================
48cf7c
--- xfsprogs-5.0.0.orig/mkfs/xfs_mkfs.c
48cf7c
+++ xfsprogs-5.0.0/mkfs/xfs_mkfs.c
48cf7c
@@ -2581,10 +2581,10 @@ _("size %s specified for data subvolume
48cf7c
 		cfg->dblocks = DTOBT(xi->dsize, cfg->blocklog);
48cf7c
 	}
48cf7c
 
48cf7c
-	if (cfg->dblocks < XFS_MIN_DATA_BLOCKS) {
48cf7c
+	if (cfg->dblocks < XFS_MIN_DATA_BLOCKS(cfg)) {
48cf7c
 		fprintf(stderr,
48cf7c
-_("size %lld of data subvolume is too small, minimum %d blocks\n"),
48cf7c
-			(long long)cfg->dblocks, XFS_MIN_DATA_BLOCKS);
48cf7c
+_("size %lld of data subvolume is too small, minimum %lld blocks\n"),
48cf7c
+			(long long)cfg->dblocks, XFS_MIN_DATA_BLOCKS(cfg));
48cf7c
 		usage();
48cf7c
 	}
48cf7c