summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2012-06-06 11:03:23 +0200
committerKarel Zak2012-06-06 11:03:23 +0200
commitdf68ccd8b8354a84e57469a498997ab50aaa5dd3 (patch)
tree695305893795902ada81b9edb6e432695725ee9d
parentfdisk: fix compiler warning [-Wunused-variable] (diff)
downloadkernel-qcow2-util-linux-df68ccd8b8354a84e57469a498997ab50aaa5dd3.tar.gz
kernel-qcow2-util-linux-df68ccd8b8354a84e57469a498997ab50aaa5dd3.tar.xz
kernel-qcow2-util-linux-df68ccd8b8354a84e57469a498997ab50aaa5dd3.zip
fdisk: fix io_size usage in new API
properly implemented fdisk_dev_has_topology() requires optimal I/O size to detect that the device provides topology. Unfortunately, currently used cxt->io_size maybe overwritten in __discover_topology() to min_io_size. This patch introduces cxt->optimal_io_size and keeps it independent on cxt->io_size. The cxt->io_size is I/O size used by fdisk for alignment calculation. Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisk/fdisk.h9
-rw-r--r--fdisk/utils.c8
2 files changed, 10 insertions, 7 deletions
diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index d5d66d3cf..c645b24d5 100644
--- a/fdisk/fdisk.h
+++ b/fdisk/fdisk.h
@@ -107,10 +107,11 @@ struct fdisk_context {
char *dev_path; /* device path */
/* topology */
- unsigned long io_size;
- unsigned long min_io_size;
- unsigned long phy_sector_size; /* physical size */
- unsigned long sector_size; /* logical size */
+ unsigned long io_size; /* I/O size used by fdisk */
+ unsigned long optimal_io_size; /* optional I/O returned by device */
+ unsigned long min_io_size; /* minimal I/O size */
+ unsigned long phy_sector_size; /* physical size */
+ unsigned long sector_size; /* logical size */
unsigned long alignment_offset;
/* geometry */
diff --git a/fdisk/utils.c b/fdisk/utils.c
index 4d838412c..352a9346b 100644
--- a/fdisk/utils.c
+++ b/fdisk/utils.c
@@ -61,10 +61,12 @@ static int __discover_topology(struct fdisk_context *cxt)
if (tp) {
cxt->min_io_size = blkid_topology_get_minimum_io_size(tp);
- cxt->io_size = blkid_topology_get_optimal_io_size(tp);
+ cxt->optimal_io_size = blkid_topology_get_optimal_io_size(tp);
cxt->phy_sector_size = blkid_topology_get_physical_sector_size(tp);
cxt->alignment_offset = blkid_topology_get_alignment_offset(tp);
+ /* I/O size used by fdisk */
+ cxt->io_size = cxt->optimal_io_size;
if (!cxt->io_size)
/* optimal IO is optional, default to minimum IO */
cxt->io_size = cxt->min_io_size;
@@ -110,8 +112,8 @@ int fdisk_dev_has_topology(struct fdisk_context *cxt)
* optimal_io_size is set or alignment_offset is set or
* minimum_io_size is not power of 2.
*/
- if (cxt->io_size || cxt->alignment_offset ||
- (cxt->min_io_size & (cxt->min_io_size - 1)))
+ if (cxt->optimal_io_size || cxt->alignment_offset ||
+ !is_power_of_2(cxt->min_io_size))
return 1;
return 0;
}