[Parted-maintainers] Bug#579948: Some debugging info

Colin Watson cjwatson at debian.org
Mon Jun 14 12:06:09 UTC 2010


[Background for parted-devel: the Debian installer is using optimal
alignment by default now.  However, on Sun labels, this produces crazy
start alignments: the user asked for a partition starting at around
10MB, and got one starting at around 16.8GB.]

On Mon, Jun 07, 2010 at 03:41:34PM +0100, Jurij Smakov wrote:
> 1. ped_disk_add_partition() is called to add the partition. The 
> constraint which is passed to it is computed in  
> ped_device_get_optimum_alignment():
> 
> /* Align to a grain of 1MiB (like vista / win7) */
> align = ped_alignment_new(0, 1048576 / dev->sector_size);
> 
> As dev->sector_size is 512, we end up with alignment of offset 0 and 
> grain_size 2048, and the resulting constraint passed to 
> ped_disk_add_partition() has start_align set to {offset = 0; 
> grain_size=2048} and end_align set to {offset = 2047, grain_size = 
> 2048). That looks normal.
> 
> 2. _partition_align() is called to align the partition with this 
> constraint. This simply calls the disk-specific partition_align 
> function, in this case sun_partition_align().
> 
> 3. In sun_partition_align: disk_specific->cylinder_alignment is set to 
> 1, so the final alignment will be an intersection of our initial 
> constraint and _get_strict_constraint(part->disk).

disk_specific->cylinder_alignment is set to 0 by parted_server's
set_disk_named function, which turns off the PED_DISK_CYLINDER_ALIGNMENT
flag.  You should be going through _get_lax_constraint, not
_get_strict_constraint.

> 4. In _get_strict_constraint() the alignment is determined by a 
> product of dev->bios_geom.sectors and dev->bios_geom.heads. In my case 
> the former is 63 and the latter is 255, so the resulting strict 
> alignment will enforce partition alignment to 63 * 255 = 16065 
> sectors. 
> 
> 5. An intersection of two constraints, one aligning to 2048 and 
> another aligning to 16065 sectors, is computed. The least common 
> multiple of those two happens to be their product, so a combined 
> constraint ends up to be forcing the alignment to 2048 * 16065 = 
> 32901120 sectors, or 16.8G (!). Looking at the debugging dump, the 
> second partition during my install was placed at 16845373440, which is 
> exactly 2048 * 16065 * 512, which confirms the alignment issue.

_get_lax_constraint still aligns the *start* position to sectors *
heads, though.  That would explain why you have a sensible end alignment
on the first partition, but a silly start alignment on the second.

parted-devel, can anyone comment on this?  It seems to me that either
(a) _get_lax_constraint should be using ped_alignment_any for its start
alignment, rather than aligning to sectors * heads boundaries, or (b)
Sun labels really and truly require cylinder alignment, in which case
requests to use optimal alignment shouldn't be honoured.

Based on the fact that there seems to be some effort here to support
non-cylinder alignment, I'm guessing that (a) is closer to the real
situation, but I don't know these systems very well.

Thanks,

-- 
Colin Watson                                       [cjwatson at debian.org]





More information about the Parted-maintainers mailing list