diff options
author | Karel Zak | 2015-06-18 11:55:29 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-18 11:55:29 +0200 |
commit | acb7651f8897ae73d0f45dd75bc87630001c61b9 (patch) | |
tree | 656e32f6363e93b66fc99b4d6c76a8921d525e71 /libfdisk/src/alignment.c | |
parent | sfdisk: improve some formatting and wording in the man page (diff) | |
download | kernel-qcow2-util-linux-acb7651f8897ae73d0f45dd75bc87630001c61b9.tar.gz kernel-qcow2-util-linux-acb7651f8897ae73d0f45dd75bc87630001c61b9.tar.xz kernel-qcow2-util-linux-acb7651f8897ae73d0f45dd75bc87630001c61b9.zip |
libfdisk: ignore misaligned optimal I/O size
For example:
# modprobe scsi_debug dev_size_mb=1000 opt_blks=65535 physblk_exp=3
creates a disk with:
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
where 33553920 % 4096 != 0, it means that use Optimal I/O size to
align partition results that partition is not aligned to physical
sector boundary.
Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/alignment.c')
-rw-r--r-- | libfdisk/src/alignment.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c index c658a5bee..1e1d07cfa 100644 --- a/libfdisk/src/alignment.c +++ b/libfdisk/src/alignment.c @@ -291,7 +291,7 @@ int fdisk_save_user_geometry(struct fdisk_context *cxt, * * Save user defined sector sizes to use it for partitioning. * - * The user properties are applied by fdisk_assign_device() or + * The user properties are applied by fdisk_assign_device() or * fdisk_reset_device_properties(). * * Returns: <0 on error, 0 on success. @@ -475,8 +475,17 @@ int fdisk_discover_topology(struct fdisk_context *cxt) /* I/O size used by fdisk */ cxt->io_size = cxt->optimal_io_size; if (!cxt->io_size) - /* optimal IO is optional, default to minimum IO */ + /* 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; + } + } } blkid_free_probe(pr); @@ -494,7 +503,7 @@ int fdisk_discover_topology(struct fdisk_context *cxt) DBG(CXT, ul_debugobj(cxt, "result: log/phy sector size: %ld/%ld", cxt->sector_size, cxt->phy_sector_size)); - DBG(CXT, ul_debugobj(cxt, "result: fdisk/min/optimal io: %ld/%ld/%ld", + DBG(CXT, ul_debugobj(cxt, "result: fdisk/optimal/minimal io: %ld/%ld/%ld", cxt->io_size, cxt->optimal_io_size, cxt->min_io_size)); return 0; } |