From d95dc0f4b90de16168c533e495c5ee1e012e41fd Mon Sep 17 00:00:00 2001
From: John Garry <john.g.garry@oracle.com>
Date: Thu, 21 Mar 2024 12:20:37 +0000
Subject: [PATCH 11/11] mkfs: Ensure extsize aligned to stripe unit for
 forcealign

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 mkfs/xfs_mkfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 5169255..cf0852f 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2754,6 +2754,16 @@ _("%s: Stripe unit(%d) or stripe width(%d) is not a multiple of the block size(%
 	cfg->dsunit = DTOBT(dsunit, cfg->blocklog);
 	cfg->dswidth = DTOBT(dswidth, cfg->blocklog);
 
+	if (cli->fsx.fsx_xflags & FS_XFLAG_FORCEALIGN) {
+		if ((cfg->dsunit % cli->fsx.fsx_extsize) ||
+		    (cfg->dswidth % cli->fsx.fsx_extsize)) {
+			fprintf(stderr,
+		_("Stripe unit(%d) or stripe width(%d) is not a multiple of the extsize (%d) for forcealign\n"),
+				cfg->dsunit, cfg->dswidth, cli->fsx.fsx_extsize);
+			usage();
+		}
+	}
+
 check_lsunit:
 	/* log sunit options */
 	if (cli_opt_set(&lopts, L_SUNIT))
-- 
2.33.0

