[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH parted 4/7] ped_device_get_constraint: return constraint without
Hans de Goede
[PATCH parted 4/7] ped_device_get_constraint: return constraint without alignment
Fri, 30 Oct 2009 12:59:02 +0100
In libparted-1.9 ped_device_get_constraint() would always return a constraint
without any start / end aligning (grain_size == 1). Now that we are starting to
support disks with a physical sector size other then 512, the old
ped_device_get_constraint() code may actually start returning constrains
with alignment info with a grain_size != 1.
Since this is a behavior change and since the old code does not take a possible
alignment info into account, this patch removes the aligning code from
ped_device_get_constraint(), so that its behavior is unchanged.
This patch also updates the functions doxygen documentation to reflect what
it has actually done all these years.
libparted/device.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/libparted/device.c b/libparted/device.c
index 4fec1a9..483011a 100644
@@ -416,31 +416,32 @@ ped_device_sync_fast (PedDevice* dev)
- * Get a constraint that represents hardware requirements on alignment and
- * geometry.
- * This is, for example, important for media that have a physical sector
- * size that is a multiple of the logical sector size.
+ * Get a constraint that represents hardware requirements on geometry.
+ * This function will return a constraint representing the limits imposed
+ * by the size of the disk, it will *not* provide any alignment constraints.
- * \warning This function is experimental for physical sector sizes not equal
- * 2^9.
+ * Alignment constraints may be desirable when using media that have a physical
+ * sector size that is a multiple of the logical sector size, as in this case
+ * proper partition alignment can benefit disk performance signigicantly.
+ * When you want a constraint with alignment info, use
+ * ped_device_get_minimal_aligned_constraint() or
+ * ped_device_get_optimal_aligned_constraint().
+ * \return NULL on error, otherwise a pointer to a dynamically allocated
+ * constraint.
ped_device_get_constraint (PedDevice* dev)
- int multiplier = dev->phys_sector_size / dev->sector_size;
- PedAlignment* start_align = ped_alignment_new (multiplier, multiplier);
PedGeometry *s, *e;
PedConstraint* c = ped_constraint_new (
- start_align, ped_alignment_any,
+ ped_alignment_any, ped_alignment_any,
s = ped_geometry_new (dev, 0, dev->length),
e = ped_geometry_new (dev, 0, dev->length),
- free (start_align);
Re: [PATCH parted 1/7] libparted: add ped_device_get_xxx_alignment() functions, Jim Meyering, 2009/10/29
[PATCH parted 1/7] libparted: add ped_device_get_xxx_alignment() functions, Hans de Goede, 2009/10/30
- [PATCH parted 3/7] linux.c: add get_minimum_alignment() and get_optimum_alignment() functions, (continued)