linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mkfs: avoid divide-by-zero when hardware reports optimal i/o size as 0
@ 2018-07-19 21:23 Jeff Mahoney
  2018-07-20 15:55 ` Carlos Maiolino
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jeff Mahoney @ 2018-07-19 21:23 UTC (permalink / raw)
  To: linux-xfs@vger.kernel.org, Eric Sandeen, Dave Chinner

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(+)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index a135e06e..35542e57 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2295,6 +2295,12 @@ _("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n"),
 	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 */
-- 
2.16.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-07-31  4:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-19 21:23 [PATCH] mkfs: avoid divide-by-zero when hardware reports optimal i/o size as 0 Jeff Mahoney
2018-07-20 15:55 ` Carlos Maiolino
2018-07-20 16:19   ` Darrick J. Wong
2018-07-23 12:21     ` Carlos Maiolino
2018-07-20 18:08   ` Jeff Mahoney
2018-07-31  2:10 ` Eric Sandeen
2018-07-31  2:14   ` Eric Sandeen
2018-07-31  2:57 ` [PATCH 2/1] mkfs: factor stripe geom validator & use for cli + device Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).