lvm2/0021-tests-check-conversion-of-in-use-volume.patch
Marian Csontos 4857646a28 Additional patches for 9.6.0 lvm2
Resolves: RHEL-53866 RHEL-65845 RHEL-60943
2025-01-09 19:04:38 +01:00

52 lines
1.7 KiB
Diff

From 41aaea4349ff2ef9b80de285e72ba7b94adfcf1a Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 19 Dec 2024 14:50:32 +0100
Subject: [PATCH 21/27] tests: check conversion of in-use volume
Thin-pool conversion fails early when trying to convert
volume which is in use (simulated by sleep <)
(cherry picked from commit 3e641578d80bc7a28bcb451115b06da87d232b3a)
---
test/shell/lvconvert-thin-vdo.sh | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/test/shell/lvconvert-thin-vdo.sh b/test/shell/lvconvert-thin-vdo.sh
index d61126276..5b4fe9d97 100644
--- a/test/shell/lvconvert-thin-vdo.sh
+++ b/test/shell/lvconvert-thin-vdo.sh
@@ -34,11 +34,29 @@ which mkfs.ext4 || skip
aux prepare_vg 4 6400
-# convert to thin-pool with VDO backend from existing VG/LV
+# Convert to thin-pool with VDO backend from existing VG/LV
lvcreate -L5G --name $lv1 $vg
+
+# Keep volume in use for 6 seconds
+# - lvm retries for ~5sec to deactivate
+sleep 6 < "$DM_DEV_DIR/$vg/$lv1" &
+
+# Volume in use cannot be converted
+fail lvconvert -y --type thin-pool $vg/$lv1 --pooldatavdo y
+
+# Wait for sleep to not use LV anymore
+wait
+
+# No extra volume should appear in VG after failure
+test "$(get vg_field $vg lv_count)" -eq "1"
+
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
# Conversion caught present filesystem and should fail
fail lvconvert -Wy --type thin-pool -c 256K --deduplication n --pooldatavdo y $vg/$lv1
+
+# No extra volume should appear in VG after failure
+test "$(get vg_field $vg lv_count)" -eq "1"
+
# With --yes it should work over prompt
lvconvert --yes -Wy --type thin-pool -c 256K --deduplication n --pooldatavdo y $vg/$lv1
--
2.47.1