summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-10-02 09:47:14 +0200
committerSimon Rettberg2020-10-02 09:47:14 +0200
commit32975ce2970fee62b6d5884889b64f8953e9c11d (patch)
treea57ba8ba7cfd7fd5d95cb30c4809712a7c5a7012
parent[slx-dmsetup] Use _sz for sizes expressed in 512b sectors (diff)
downloadsystemd-init-32975ce2970fee62b6d5884889b64f8953e9c11d.tar.gz
systemd-init-32975ce2970fee62b6d5884889b64f8953e9c11d.tar.xz
systemd-init-32975ce2970fee62b6d5884889b64f8953e9c11d.zip
[slx-dmsetup] Add overprovisioning formula for CoW volume
-rwxr-xr-xmodules.d/slx-dmsetup/scripts/dmsetup-slx-device28
1 files changed, 16 insertions, 12 deletions
diff --git a/modules.d/slx-dmsetup/scripts/dmsetup-slx-device b/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
index f890cd44..ff25e167 100755
--- a/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
+++ b/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
@@ -566,18 +566,22 @@ if [ -n "$thin_snapshot" ] || [ -n "$thin_volume" ]; then
# create thin-snapshot, use first one
read -r name crypt min max ignore <<< "$thin_snapshot"
# min/max was used for the pool data device, ignore it here!
- # NOTE: the filesystem will most likely malfunction if the size of the
- # thin-snapshot is smaller than what it was upon creation.
- # As such, the size of the thin-snapshot can only be $scratch_device_sz
- # if it is larger than $read_only_device_sz, otherwise we should only
- # use $read_only_device_sz. While live-shrinking the filesystem might be
- # an option, it is not supported throughout all fileystems (xfs can't).
- if (( scratch_device_sz >= read_only_device_sz )); then
- thin_snapshot_sz="$scratch_device_sz"
- else
- thin_snapshot_sz="$read_only_device_sz"
- fi
- # For later on-demand growing
+ # Calculate how much of the CoW space we reserve for changes in the base
+ # system. Usually all the files in the base system should be static, but
+ # if someone decided to run apt dist-upgrade, this would change a lot of
+ # existing blocks, which is bad.
+ # Use MIN( readonly_size / 2, scratch_size / 10 )
+ # until we come up with anything better.
+ # Given an RO image of 10GB, this gives us:
+ # 40GB scratch -> 46GB, so initially 36GB free space
+ # 5GB scratch -> 14.5GB, initially 4.5GB free space
+ declare -r max_reserved_sz="$(( scratch_device_sz / 10 ))"
+ reserved_sz="$(( read_only_device_sz / 2 ))"
+ (( reserved_sz > max_reserved_sz )) && reserved_sz="$max_reserved_sz"
+ thin_snapshot_sz="$(( scratch_device_sz + read_only_device_sz - reserved_sz ))"
+ # For later on-demand growing, overprovision by free space we found on
+ # clean NTFS volumes. This requires a user-space helper to listen for
+ # dm events in stage4, which should in turn add that free space to the pool-data
if (( root_ntfs_extra > 0 )); then
thin_snapshot_sz="$(( thin_snapshot_sz + root_ntfs_extra ))"
fi