summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-06-14 11:17:30 +0200
committerSimon Rettberg2024-06-14 11:17:30 +0200
commitf41856349c99cf7ad6fd926b85fe6d025a045b5c (patch)
tree350e69f5e76204204dc3e8899be60e458bee6e70
parent[slx-dmsetup] busybox mktemp needs AT LEAST 6 X -.- (diff)
downloadsystemd-init-f41856349c99cf7ad6fd926b85fe6d025a045b5c.tar.gz
systemd-init-f41856349c99cf7ad6fd926b85fe6d025a045b5c.tar.xz
systemd-init-f41856349c99cf7ad6fd926b85fe6d025a045b5c.zip
[slx-dmsetup] Try to fix some snapshot brain damage
create_snapshot was always using hard-coded $writable_device, but surrounding code at one callsite suggested it was expected to use $scratch_device - this would at least explain why we could end up with overlapping dm targets... -.-
-rwxr-xr-xmodules.d/slx-dmsetup/hooks/dmsetup-slx-device18
1 files changed, 8 insertions, 10 deletions
diff --git a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
index 9fde7e3e..8e3b50ca 100755
--- a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
+++ b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
@@ -191,13 +191,13 @@ encrypt_device() {
fi
return 0
}
-# create_snapshot "<name> <persist>"
+# create_snapshot "<name> <persist>" "cow_device"
create_snapshot() {
modprobe dm-snapshot || echo "$0: dm-snapshot loading failed, maybe builtin?"
- read -r name persist ignore <<< "$1"
+ read -r name persist _ <<< "$1"
if ! dmsetup_create_noudevsync "$name" \
- "0 $read_only_device_sz snapshot $read_only_device $writable_device ${persist:-N} 8"; then
- echo "$0: Failed to create snapshot on '$writable_device' for '$read_only_device'."
+ "0 $read_only_device_sz snapshot $read_only_device $2 ${persist:-N} 8"; then
+ echo "$0: Failed to create snapshot on '$2' for '$read_only_device'."
return 1
fi
return 0
@@ -245,7 +245,7 @@ ramdisk_fallback() {
fi
# create sparse file there
- local file="$cow_tmpfs/thinpool.meta"
+ local file="$cow_tmpfs/tmpfs-snapshot"
if ! truncate -s "$(( read_only_device_sz * 512 ))" "$file" \
&& ! dd if=/dev/null of="$file" seek="$read_only_device_sz" bs=512; then
emergency_shell "Failed to allocate RAMdisk CoW file $file."
@@ -255,7 +255,7 @@ ramdisk_fallback() {
while [ -b "/dev/mapper/$cow_device_candidate" ]; do
cow_device_candidate="root.$RANDOM"
done
- if [ -z "$writable_device" ] || ! create_snapshot "$cow_device_candidate N"; then
+ if [ -z "$writable_device" ] || ! create_snapshot "$cow_device_candidate N" "$writable_device"; then
emergency_shell "CRITICAL: failed to setup RAMdisk fallback."
exit 1
fi
@@ -824,11 +824,9 @@ fi
## SNAPSHOT (OLD FUNCTIONALITY)
###
if [ -n "$snapshot" ] && require_exact_scratch_size; then
- read -r name crypt min max ignore <<< "$snapshot"
+ read -r name crypt min max _ <<< "$snapshot"
[ -n "$id44_crypted" ] && crypt=0
- if ! create_snapshot "$name $persist"; then
- echo "Failed to create regular snapshot for '$read_only_device' on '$scratch_device'."
- else
+ if create_snapshot "$name N" "$scratch_device"; then
finish_setup "$name" "1" "$scratch_device_sz"
fi
fi