New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disk: align LVM2 volumes to the extent size #3137
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thozza
reviewed
Nov 16, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few minor comments, otherwise this looks great!
Thanks for a quick fix.
gicmo
force-pushed
the
lvm_extent_alignment
branch
from
November 16, 2022 17:12
2c1c156
to
0d815b8
Compare
bcl
reviewed
Nov 16, 2022
gicmo
force-pushed
the
lvm_extent_alignment
branch
from
November 17, 2022 09:49
0d815b8
to
2a1ad27
Compare
Extract a `CreateLogicalVolume` method from `CreateMountpoint` and implement the latter via the former. This makes it possible to create a Logical Volume for an existing payload.
When the size of a logical volume is not aligned to the extent size of the volume group, LVM2 will automatically align it by rounding up[1]: Rounding up size to full physical extent 29.80 GiB Rounding up size to full physical extent <3.82 GiB Since we don't take that into account when we create a new volume or set the size of an existing one, the size for the whole volume group will be short by that amount and thus the creation of the last volume will fail: Volume group <uuid> has insufficient free space (975 extents): 977 required. To fix this a new `AlignUp` method is added to the `MountpointCreator` creator interface. It will align a given size to the requirements of the implementing container, like e.g. `LVMVolumeGroup`. It is then used by a new `alignEntityBranch` which takes a size and walks the entity path, calling `AlignUp` for all entities that implement said `MountpointCreator` interface; thus the resulting size should fullfil the alignment requirement for all elements in the path. NB: `PartitionTable` already had an `AlignUp` method. Add a corresponding test. [1]: https://github.com/lvmteam/lvm2/blob/868665766491d9d42b8acedaf07cafc7118d165c/lib/metadata/metadata.c#L1072 Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
gicmo
force-pushed
the
lvm_extent_alignment
branch
from
November 17, 2022 17:23
2a1ad27
to
f650fb3
Compare
achilleas-k
approved these changes
Nov 18, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the size of a logical volume is not aligned to the extent size of the volume group, LVM2 will automatically align it by rounding up (see metadata.c):
Since we don't take that into account when we create a new volume or set the size of an existing one, the size for the whole volume group will be short by that amount and thus the creation of the last volume
will fail:
To fix this a new
AlignUp
method is added to theMountpointCreator
creator interface. It will align a given size to the requirements of the implementing container, like e.g.LVMVolumeGroup
. It is then used by a newalignEntityBranch
which takes a size and walks the entity path, callingAlignUp
for all entities that implement saidMountpointCreator
interface; thus the resulting size should fullfil the alignment requirement for all elements in the path. NB:PartitionTable
already had anAlignUp
method.Add a corresponding test.