summaryrefslogtreecommitdiffstats
path: root/fdisk
diff options
context:
space:
mode:
authorKarel Zak2010-02-15 16:46:05 +0100
committerKarel Zak2010-02-15 16:46:05 +0100
commita47e839cd7b5e3c032c3a6b8a96343d3ab8e1906 (patch)
tree05e07abfc300628d03c8cc3f52dbffca59a7ef74 /fdisk
parenttests: update fdisk tests (diff)
downloadkernel-qcow2-util-linux-a47e839cd7b5e3c032c3a6b8a96343d3ab8e1906.tar.gz
kernel-qcow2-util-linux-a47e839cd7b5e3c032c3a6b8a96343d3ab8e1906.tar.xz
kernel-qcow2-util-linux-a47e839cd7b5e3c032c3a6b8a96343d3ab8e1906.zip
fdisk: don't use 1MiB grain on small devices
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk')
-rw-r--r--fdisk/fdisk.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 196f76d4b..09efd1cc2 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1076,9 +1076,7 @@ update_sector_offset(void)
*
* b) or default to 1MiB (2048 sectrors, Windows Vista default)
*
- * c) or for very small devices use 1 phy.sector (small device =
- * device where the offset is quarter of of whole size
- * of the device).
+ * c) or for very small devices use 1 phy.sector
*/
unsigned long long x = 0;
@@ -1094,12 +1092,17 @@ update_sector_offset(void)
sector_offset = x / sector_size;
+ /* don't use huge offset on small devices */
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;
+
+ /* don't use huge grain on small devices */
+ if (total_number_of_sectors <= (grain * 4 / sector_size))
+ grain = phy_sector_size;
}
}