summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmodules.d/slx-dmsetup/hooks/dmsetup-slx-device12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
index 77e51c7d..1475aea0 100755
--- a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
+++ b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
@@ -653,6 +653,8 @@ else
echo "$0: Using this client maximum scratch space ($writable_device_sz sectors)."
scratch_device_sz="$writable_device_sz"
fi
+# Round down to 4k border, so next slice won't be misaligned if we're on a 4k sector disk
+scratch_device_sz="$(( (scratch_device_sz / 8) * 8 ))"
# Create a linear target for the scratch device. This might seem superfluous,
# but it works around problems when using NVMe as pool data device directly.
@@ -668,8 +670,8 @@ save_partition_info "${scratch_device##*/}" "*" "1" "$scratch_device_sz"
# encrypt the scratch device, if configured
if [ -z "$id44_crypted" ]; then
- if [ "$crypt" -ne 0 ] && encrypt_device \
- "$scratch_device" "${scratch_device##*/}-crypt" "$scratch_device_sz"; then
+ if [ "$crypt" -ne 0 ] \
+ && encrypt_device "$scratch_device" "${scratch_device##*/}-crypt" "$scratch_device_sz"; then
scratch_device="/dev/mapper/${scratch_device##*/}-crypt"
else
echo "$0: Continuing with unencrypted scratch"
@@ -685,12 +687,14 @@ for line in "${linear[@]}"; do
[ -n "$id44_crypted" ] && crypt=0
free_space="$(( writable_device_sz - writable_device_used_sz ))"
if [ "$min" -gt "$free_space" ]; then
- echo "$0: Not enough space left for linear devices: '$line'"
+ echo "$0: Not enough space left for linear devices: '$line' - have $free_space sectors"
break
fi
# allocate its max if it fits within the free space, otherwise use the space left.
to_allocate="$max"
- [ "$to_allocate" -gt "$free_space" ] && to_allocate="$free_space"
+ (( to_allocate > free_space )) && to_allocate="$free_space"
+ # as above, round down to align on 4k sector devices
+ to_allocate="$(( (to_allocate / 8) * 8 ))"
if ! dmsetup_create_noudevsync "$name" "0 $to_allocate linear $writable_device $writable_device_used_sz"; then
echo "$0: Failed to create linear device: $line"