disk: align LVM2 volumes to the extent size
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]: 8686657664/lib/metadata/metadata.c (L1072)
Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
93875576e9
commit
9ea58d1486
5 changed files with 135 additions and 10 deletions
|
|
@ -120,6 +120,10 @@ type Mountable interface {
|
|||
// returns the entity that represents the new mountpoint.
|
||||
type MountpointCreator interface {
|
||||
CreateMountpoint(mountpoint string, size uint64) (Entity, error)
|
||||
|
||||
// AlignUp will align the given bytes according to the
|
||||
// requirements of the container type.
|
||||
AlignUp(size uint64) uint64
|
||||
}
|
||||
|
||||
// A UniqueEntity is an entity that can be uniquely identified via a UUID.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue