Red Hat Bugzilla – Bug 1284535
parted does not always optimally align partitions when possible
Last modified: 2016-01-29 11:52:23 EST
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:
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.
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.