File xfsprogs-mkfs-avoid-divide-by-zero-when-hardware-reports-opti.patch of Package xfsprogs.35286

From: Jeffrey Mahoney <jeffm@suse.com>
Subject: [PATCH] mkfs: avoid divide-by-zero when hardware reports optimal i/o size as 0
Patch-mainline: Submitted to linux-xfs, 19 Jul 2018
References: bsc#1089777

Commit 051b4e37f5e (mkfs: factor AG alignment) factored out the
AG alignment code into a separate function.  It got rid of
redundant checks for dswidth != 0 since calc_stripe_factors was
supposed to guarantee that if dsunit is non-zero dswidth will be
as well.  Unfortunately, there's hardware out there that reports its
optimal i/o size as larger than the maximum i/o size, which the kernel
treats as broken and zeros out the optimal i/o size.  We'll accept
the multi-sector dsunit but have a zero dswidth and hit a divide-by-zero
in align_ag_geometry.

To resolve this we can check the topology before consuming it, default
to using the stripe unit as the stripe width, and warn the user about it.

Fixes: 051b4e37f5e (mkfs: factor AG alignment)
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 mkfs/xfs_mkfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

Index: xfsprogs-4.15.0/mkfs/xfs_mkfs.c
===================================================================
--- xfsprogs-4.15.0.orig/mkfs/xfs_mkfs.c
+++ xfsprogs-4.15.0/mkfs/xfs_mkfs.c
@@ -2294,6 +2294,12 @@ _("data stripe width (%d) must be a mult
 	if (!dsunit) {
 		dsunit = ft->dsunit;
 		dswidth = ft->dswidth;
+		if (dsunit && dswidth == 0) {
+			fprintf(stderr,
+_("%s: Volume reports stripe unit of %d bytes but stripe width of 0.  Using stripe width of %d bytes, which may not be optimal.\n"),
+				progname, dsunit << 9, dsunit << 9);
+			dswidth = dsunit;
+		}
 		use_dev = true;
 	} else {
 		/* check and warn is alignment is sub-optimal */
openSUSE Build Service is sponsored by