Bug 1284535

Summary: parted does not always optimally align partitions when possible
Product: Red Hat Enterprise Linux 7 Reporter: Matthew Whitehead <mwhitehe>
Component: partedAssignee: Brian Lane <bcl>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.1CC: fhirtz, mwhitehe
Target Milestone: pre-dev-freeze   
Target Release: 7.3   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-29 16:52:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Matthew Whitehead 2015-11-23 14:33:01 UTC
Description of problem: parted makes a very simple attempt to align partitions to a multiple of /sys/block/sda/queue/optimal_io_size. It often fails to align but does not report this.

Version-Release number of selected component (if applicable): parted-2.1-17


How reproducible: 100%


Steps to Reproduce:
1. On a system with a 2.5MiB (1310720 bytes) optimal_io_size create a partition with parted.
2. type 'units MiB'
3. type 'mkpart primary 1MiB 100%

Actual results: It will not align at 2.5MiB, nor print an error.


Expected results: It should align to optimal_io_size of 2.5MiB.


Additional info: There is a patch that prints out when parted fails to align: 

https://github.com/bcl/parted/commit/94071357e18435002f4465e42bffcb471553d166.patch

The root cause seems to be the rounding functions in libparted/cs/natmath.c, called in  _closest_inside_geometry().

If the units are not large enough (using 'KiB' or'MiB' instead of 'GiB' or 'cyl'), it doesn't have enough room for the ped_round_up_to() calls to align cleanly.

Using larger units does align, but wastes space.

Comment 2 Brian Lane 2015-11-23 17:45:27 UTC
This doesn't match what I remember from our IRC conversations. I thought the 1MiB was working and the problem was 1024KiB didn't align correctly.

Please paste the text from a session using the patch that prints the alignment math, this is difficult to duplicate without this specific device.

The only behavior here that I would consider a bug is if it doesn't align AND doesn't tell you that it couldn't align. Also, 1310720 bytes isn't 2.5MiB.

Comment 3 Red Hat Bugzilla 2023-09-14 03:13:33 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days