]> err.no Git - util-linux/commitdiff
fdisk: use 1MiB offset and grain always when possible
authorKarel Zak <kzak@redhat.com>
Mon, 15 Feb 2010 14:55:22 +0000 (15:55 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Feb 2010 15:08:02 +0000 (16:08 +0100)
It would be nice to minimize dependence between the disk layout and
disk topology. We have to follow disk topology for alignment_offset
and huge (> 1MiB) I/O sizes only. For all others disks we can use 1MiB
grain and 1MiB offset.

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisk.c

index b752d9b98cc0c6b444c0c8a1977f2b2f60668897..196f76d4b72edefc88ee178224516368fae7eb0d 100644 (file)
@@ -1080,17 +1080,26 @@ update_sector_offset(void)
                 *    device where the offset is quarter of of whole size
                 *    of the device).
                 */
-               unsigned long long x;
+               unsigned long long x = 0;
 
-               if (has_topology)
-                       x = alignment_offset ? alignment_offset : io_size;
-               else
-                       x = grain = 2048 * 512;
+               if (has_topology) {
+                       if (alignment_offset)
+                               x = alignment_offset;
+                       else if (io_size > 2048 * 512)
+                               x = io_size;
+               }
+               /* default to 1MiB */
+               if (!x)
+                       x = 2048 * 512;
 
                sector_offset = x / sector_size;
 
                if (total_number_of_sectors <= sector_offset * 4)
                        sector_offset = phy_sector_size / sector_size;
+
+               /* use 1MiB grain always when possible */
+               if (grain < 2048 * 512)
+                       grain = 2048 * 512;
        }
 }