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>
This commit is contained in:
parent
dde32b6ccd
commit
df68ccd8b8
|
@ -107,10 +107,11 @@ struct fdisk_context {
|
||||||
char *dev_path; /* device path */
|
char *dev_path; /* device path */
|
||||||
|
|
||||||
/* topology */
|
/* topology */
|
||||||
unsigned long io_size;
|
unsigned long io_size; /* I/O size used by fdisk */
|
||||||
unsigned long min_io_size;
|
unsigned long optimal_io_size; /* optional I/O returned by device */
|
||||||
unsigned long phy_sector_size; /* physical size */
|
unsigned long min_io_size; /* minimal I/O size */
|
||||||
unsigned long sector_size; /* logical size */
|
unsigned long phy_sector_size; /* physical size */
|
||||||
|
unsigned long sector_size; /* logical size */
|
||||||
unsigned long alignment_offset;
|
unsigned long alignment_offset;
|
||||||
|
|
||||||
/* geometry */
|
/* geometry */
|
||||||
|
|
|
@ -61,10 +61,12 @@ static int __discover_topology(struct fdisk_context *cxt)
|
||||||
|
|
||||||
if (tp) {
|
if (tp) {
|
||||||
cxt->min_io_size = blkid_topology_get_minimum_io_size(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->phy_sector_size = blkid_topology_get_physical_sector_size(tp);
|
||||||
cxt->alignment_offset = blkid_topology_get_alignment_offset(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)
|
if (!cxt->io_size)
|
||||||
/* optimal IO is optional, default to minimum IO */
|
/* optimal IO is optional, default to minimum IO */
|
||||||
cxt->io_size = cxt->min_io_size;
|
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
|
* optimal_io_size is set or alignment_offset is set or
|
||||||
* minimum_io_size is not power of 2.
|
* minimum_io_size is not power of 2.
|
||||||
*/
|
*/
|
||||||
if (cxt->io_size || cxt->alignment_offset ||
|
if (cxt->optimal_io_size || cxt->alignment_offset ||
|
||||||
(cxt->min_io_size & (cxt->min_io_size - 1)))
|
!is_power_of_2(cxt->min_io_size))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue