From f41856349c99cf7ad6fd926b85fe6d025a045b5c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 14 Jun 2024 11:17:30 +0200 Subject: [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... -.- --- modules.d/slx-dmsetup/hooks/dmsetup-slx-device | 18 ++++++++---------- 1 file 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 " " +# create_snapshot " " "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 -- cgit v1.2.3-55-g7522