[parted-devel] [PATCH] libparted: fix optimal IO alignment

Jim Meyering jim at meyering.net
Thu Mar 1 17:50:55 UTC 2012


Phillip Susi wrote:
> There were several apparently incorrect tests that would
> cause the kernel supplied optimal io size to be discarded in
> favor of the default 1MB alignment.  As written, it would
> only accept the kernel alignment if it was both greater than
> and not an even multiple of the default.  Remove these
> tests and accept the kernel value if it is non zero.

Hi Phillip,

Can you describe, or better still, tell me how to demonstrate the
problem this is fixing?  Or can you at least give a few details, like
which kernel you used, which command invoked and which values you got
for the two *_io variables?

I think your description was somehow negated, since it's the reverse
actually: it accepts a nonzero kernel alignment A only if 2^20 % A == 0.
I.e., that requires A <= 1024^2.  A kernel alignment value larger
than 1024^2 is ignored.

Note: #define PED_DEFAULT_ALIGNMENT (1024 * 1024)

> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index e2c4139..f560451 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -2948,15 +2948,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);



More information about the parted-devel mailing list