[parted-devel] [PATCH 06/11] libparted: respect optimal IO alignment

Phillip Susi psusi at ubuntu.com
Mon Jan 7 04:44:31 UTC 2013


If the optimal IO size provided by the kernel was less than 1 MiB
or not an even power of two, parted ignored it and used 1 MiB
instead.  Values less than 1 MiB or not an even power of two are
common with raid arrays, so respect the kernel supplied value.
Regular disks will still use 1 MiB since the kernel returns a
value of zero.
---
 NEWS                     |    6 ++++++
 libparted/arch/linux.c   |   11 +----------
 tests/t9020-alignment.sh |    2 +-
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/NEWS b/NEWS
index a5e34d2..cd12cec 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,12 @@ GNU parted NEWS                                    -*- outline -*-
 
 ** Changes in behavior
 
+  libparted: fix optimal alignment.  Previously if the kernel
+  indicated an optimal alignment for a device was less than
+  1 MiB or not an even power of two, parted would disregard that
+  value and use 1 MiB for the optimal alignment.  It will now use
+  the kernel supplied value.
+
   libparted: set dmraid partition uuid.  When dmraid creates the
   partition devices, it assigns them a UUID in the form of
   "DMRAID-XXXXX".  When kpartx creates the partitions, it assigns
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4339b7f..d360400 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2977,16 +2977,7 @@ linux_get_optimum_alignment(const PedDevice *dev)
            If one or the other will not divide evenly, fall through to
            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);
diff --git a/tests/t9020-alignment.sh b/tests/t9020-alignment.sh
index 482202f..1a2e629 100755
--- a/tests/t9020-alignment.sh
+++ b/tests/t9020-alignment.sh
@@ -26,7 +26,7 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
 
 cat <<EOF > exp || framework_failure
 minimum: 7 8
-optimal: 7 2048
+optimal: 7 64
 partition alignment: 0 1
 EOF
 
-- 
1.7.10.4




More information about the parted-devel mailing list