[parted-devel] [PATCH 6/6] libparted: fix optimal IO alignment
Jim Meyering
jim at meyering.net
Sun Dec 16 01:44:38 UTC 2012
Phillip Susi wrote:
> There were several apparently incorrect tests that would
> cause certain kernel supplied optimal io size to be discarded in
> favor of the default 1MB alignment, such as 1.5 MB. Remove these
> tests and accept the kernel value if it is non zero.
> ---
> libparted/arch/linux.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index fd4ba32..bbb346a 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -2986,15 +2986,7 @@ linux_get_optimum_alignment(const PedDevice *dev)
> previous logic. */
> unsigned long optimal_io = blkid_topology_get_optimal_io_size(tp);
> unsigned long minimum_io = blkid_topology_get_minimum_io_size(tp);
> - if (
> - (!optimal_io && !minimum_io)
> - || (optimal_io && PED_DEFAULT_ALIGNMENT % optimal_io == 0
> - && minimum_io && PED_DEFAULT_ALIGNMENT % minimum_io == 0)
> - || (!minimum_io && optimal_io
> - && PED_DEFAULT_ALIGNMENT % optimal_io == 0)
> - || (!optimal_io && minimum_io
> - && PED_DEFAULT_ALIGNMENT % minimum_io == 0)
> - ) {
> + if (!optimal_io) {
> /* DASD needs to use minimum alignment */
> if (dev->type == PED_DEVICE_DASD)
> return linux_get_minimum_alignment(dev);
That code seems to be trying to exclude opt/min values that
do not evenly divide PED_DEFAULT_ALIGNMENT. That makes sense
only when they're no larger than PED_DEFAULT_ALIGNMENT.
How about keeping the sanity-check, but applying it only
when those values are no larger? I.e.,
if (
(!optimal_io && !minimum_io)
|| (optimal_io <= PED_DEFAULT_ALIGNMENT
&& PED_DEFAULT_ALIGNMENT % optimal_io == 0
&& minimum_io <= PED_DEFAULT_ALIGNMENT
&& PED_DEFAULT_ALIGNMENT % minimum_io == 0)
|| (!minimum_io && optimal_io <= PED_DEFAULT_ALIGNMENT
&& PED_DEFAULT_ALIGNMENT % optimal_io == 0)
|| (!optimal_io && minimum_io <= PED_DEFAULT_ALIGNMENT
&& PED_DEFAULT_ALIGNMENT % minimum_io == 0)
) {
More information about the parted-devel
mailing list