2018-09-11 11:46:02 +02:00
|
|
|
From 99a3f52e337d9c785315e64a599755bc6f7b2118 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jeff Mahoney <jeffm@suse.com>
|
|
|
|
Date: Wed, 1 Aug 2018 17:06:45 -0500
|
2018-07-20 02:13:50 +02:00
|
|
|
Subject: [PATCH] mkfs: avoid divide-by-zero when hardware reports optimal i/o
|
|
|
|
size as 0
|
|
|
|
References: bsc#1089777
|
2018-09-11 11:46:02 +02:00
|
|
|
Patch-mainline: v4.18.0-rc1
|
|
|
|
Git-commit: 99a3f52e337d9c785315e64a599755bc6f7b2118
|
2018-07-20 02:13:50 +02:00
|
|
|
|
|
|
|
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
|
2018-09-11 11:46:02 +02:00
|
|
|
treats as broken and zeros out the optimal i/o size.
|
2018-07-20 02:13:50 +02:00
|
|
|
|
2018-09-11 11:46:02 +02:00
|
|
|
To resolve this we can check the topology before consuming it, and
|
|
|
|
ignore the bad stripe geometry.
|
2018-07-20 02:13:50 +02:00
|
|
|
|
|
|
|
Fixes: 051b4e37f5e (mkfs: factor AG alignment)
|
|
|
|
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
|
2018-09-11 11:46:02 +02:00
|
|
|
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
|
|
|
|
[sandeen: remove guessing heuristic, just warn and ignore bad data.]
|
|
|
|
Reviewed-by: Jeff Mahoney <jeffm@suse.com>
|
|
|
|
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
2018-07-20 02:13:50 +02:00
|
|
|
---
|
2018-09-11 11:46:02 +02:00
|
|
|
mkfs/xfs_mkfs.c | 17 +++++++++++++----
|
|
|
|
1 file changed, 13 insertions(+), 4 deletions(-)
|
2018-07-20 02:13:50 +02:00
|
|
|
|
|
|
|
--- a/mkfs/xfs_mkfs.c
|
|
|
|
+++ b/mkfs/xfs_mkfs.c
|
2018-09-11 11:46:02 +02:00
|
|
|
@@ -2292,11 +2292,20 @@ _("data stripe width (%d) must be a mult
|
|
|
|
|
|
|
|
/* if no stripe config set, use the device default */
|
2018-07-20 02:13:50 +02:00
|
|
|
if (!dsunit) {
|
2018-09-11 11:46:02 +02:00
|
|
|
- dsunit = ft->dsunit;
|
|
|
|
- dswidth = ft->dswidth;
|
|
|
|
- use_dev = true;
|
|
|
|
+ /* Ignore nonsense from device. XXX add more validation */
|
|
|
|
+ if (ft->dsunit && ft->dswidth == 0) {
|
2018-07-20 02:13:50 +02:00
|
|
|
+ fprintf(stderr,
|
2018-09-11 11:46:02 +02:00
|
|
|
+_("%s: Volume reports stripe unit of %d bytes and stripe width of 0, ignoring.\n"),
|
|
|
|
+ progname, BBTOB(ft->dsunit));
|
|
|
|
+ ft->dsunit = 0;
|
|
|
|
+ ft->dswidth = 0;
|
|
|
|
+ } else {
|
|
|
|
+ dsunit = ft->dsunit;
|
|
|
|
+ dswidth = ft->dswidth;
|
|
|
|
+ use_dev = true;
|
2018-07-20 02:13:50 +02:00
|
|
|
+ }
|
|
|
|
} else {
|
2018-09-11 11:46:02 +02:00
|
|
|
- /* check and warn is alignment is sub-optimal */
|
|
|
|
+ /* check and warn if user-specified alignment is sub-optimal */
|
|
|
|
if (ft->dsunit && ft->dsunit != dsunit) {
|
|
|
|
fprintf(stderr,
|
|
|
|
_("%s: Specified data stripe unit %d is not the same as the volume stripe unit %d\n"),
|