summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Finnie <ryan@finnie.org>2020-12-27 10:01:26 -0800
committerKarel Zak <kzak@redhat.com>2021-02-10 10:00:00 +0100
commitec3a4a3960f05a53910d1cb956210c3fba3f3d36 (patch)
tree69a0d53d94421917f5ffd7f4dc654e541a9f6820
parent3cc000096b4559ded4f550dcc3eaf68337346e3c (diff)
downloadutil-linux-ec3a4a3960f05a53910d1cb956210c3fba3f3d36.tar.gz
libfdisk: ignore 33553920 byte optimal I/O size
A 33553920 byte optimal I/O size arises from badly-implemented USB SATA adapters reporting 0xffff 512 byte sectors (32 MiB - 512). Commit acb7651f8897ae73d0f45dd75bc87630001c61b9 indirectly addresses this by ignoring the optimal I/O size if it's not a multiple of the physical sector size. That works if the physical sector size is 4096, but 33553920 optimal is allowed for 512 physical. This commit explicitly ignores 33553920, as there is no legitimate situation where this number would be the real optimal I/O size. Signed-off-by: Ryan Finnie <ryan@finnie.org> Closes: https://github.com/karelzak/util-linux/issues/1221
-rw-r--r--libfdisk/src/alignment.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
index 3d0254634..3ae721913 100644
--- a/libfdisk/src/alignment.c
+++ b/libfdisk/src/alignment.c
@@ -541,12 +541,16 @@ int fdisk_discover_topology(struct fdisk_context *cxt)
/* optimal I/O is optional, default to minimum IO */
cxt->io_size = cxt->min_io_size;
- /* ignore optimal I/O if not aligned to phy.sector size */
- if (cxt->io_size
- && cxt->phy_sector_size
- && (cxt->io_size % cxt->phy_sector_size) != 0) {
- DBG(CXT, ul_debugobj(cxt, "ignore misaligned I/O size"));
- cxt->io_size = cxt->phy_sector_size;
+ if (cxt->io_size && cxt->phy_sector_size) {
+ if (cxt->io_size == 33553920) {
+ /* 33553920 (32 MiB - 512) is always a controller error */
+ DBG(CXT, ul_debugobj(cxt, "ignore bad I/O size 33553920"));
+ cxt->io_size = cxt->phy_sector_size;
+ } else if ((cxt->io_size % cxt->phy_sector_size) != 0) {
+ /* ignore optimal I/O if not aligned to phy.sector size */
+ DBG(CXT, ul_debugobj(cxt, "ignore misaligned I/O size"));
+ cxt->io_size = cxt->phy_sector_size;
+ }
}
}