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

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