]> git.ipfire.org Git - thirdparty/systemd.git/commit
repart: don't distribute space after unaligned partitions
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Nov 2021 15:25:24 +0000 (16:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 9 Nov 2021 15:25:24 +0000 (16:25 +0100)
commit0b7f574f72c72afb9384d7ea11b324ead067c8d1
tree88440b92e79ae63bc5701b709bbbac76cc034ed5
parentae0613c6c4cf8aa2d924c9468e8dac1e792a4e71
repart: don't distribute space after unaligned partitions

If we operate on a disk that has a pre-existing unaligned partition
(i.e. one that doesn't start on multiple of 4K, or doesn't have a size
of multiple 4K), then the amount of space after it to distribute among
partitions isn't a multiple of 4K either.  So far we might end up
passing the remaining fraction to any partition that wanted it, which
was usually the first one after it that is newly defined. This then
confused the later placement algorithm, since it assumed all partitions
we newly allocate were properly aligned but by being extended by the
fractional space they wouldn't be anymore.

Let's hence fix that by ensuring we never pass space to later partitions
so that things wouldn't be aligned anymore.

Anything that is left-over then at the very end (i.e. typically exactly
the remaining fraction) is added as padding to the existing, unaligned
partition, so that it can't confuse anyone.

Fixes: #20622
src/partition/repart.c