Blame SOURCES/0063-thin-fix-message-processing-on-thin-pool-extension.patch

8342e7
From 7db3a53d8a3aa7401337fb9aaf00f19cf4407e70 Mon Sep 17 00:00:00 2001
8342e7
From: Zdenek Kabelac <zkabelac@redhat.com>
8342e7
Date: Wed, 30 Mar 2022 14:16:11 +0200
8342e7
Subject: [PATCH 3/4] thin: fix message processing on thin-pool extension
8342e7
8342e7
When thin-pool had queued some delete message on extension operation
8342e7
such message has been 'lost' and thin-pool kernel metadata has been
8342e7
left with a thin volume that no longer existed for lvm2 metadata.
8342e7
8342e7
(cherry picked from commit 09371131469f7398c597a5fb30dc565859253cc2)
8342e7
---
8342e7
 WHATS_NEW                          |  4 ++
8342e7
 lib/metadata/lv_manip.c            |  2 +-
8342e7
 test/shell/lvextend-thin-adddel.sh | 78 ++++++++++++++++++++++++++++++
8342e7
 3 files changed, 83 insertions(+), 1 deletion(-)
8342e7
 create mode 100644 test/shell/lvextend-thin-adddel.sh
8342e7
8342e7
diff --git a/WHATS_NEW b/WHATS_NEW
8342e7
index e626802ec..bffd24648 100644
8342e7
--- a/WHATS_NEW
8342e7
+++ b/WHATS_NEW
8342e7
@@ -2,6 +2,10 @@ Version 2.03.17 -
8342e7
 ===============================
8342e7
   Fix lvconvert --test --type vdo-pool execution.
8342e7
 
8342e7
+Version 2.03.16 - 
8342e7
+====================================
8342e7
+  Fix lossing of delete message on thin-pool extension.
8342e7
+
8342e7
 Version 2.03.14 - 20th October 2021
8342e7
 ===================================
8342e7
   Device scanning is skipping directories on different filesystems.
8342e7
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
8342e7
index 003748d6f..9523e3e66 100644
8342e7
--- a/lib/metadata/lv_manip.c
8342e7
+++ b/lib/metadata/lv_manip.c
8342e7
@@ -6179,7 +6179,7 @@ int lv_resize(struct logical_volume *lv,
8342e7
 
8342e7
 	if (lv_is_thin_pool(lock_lv)) {
8342e7
 		/* Update lvm pool metadata (drop messages). */
8342e7
-		if (!update_pool_lv(lock_lv, 0))
8342e7
+		if (!update_pool_lv(lock_lv, 1))
8342e7
 			goto_bad;
8342e7
 	}
8342e7
 
8342e7
diff --git a/test/shell/lvextend-thin-adddel.sh b/test/shell/lvextend-thin-adddel.sh
8342e7
new file mode 100644
8342e7
index 000000000..59b1bfa41
8342e7
--- /dev/null
8342e7
+++ b/test/shell/lvextend-thin-adddel.sh
8342e7
@@ -0,0 +1,78 @@
8342e7
+#!/usr/bin/env bash
8342e7
+
8342e7
+# Copyright (C) 2022 Red Hat, Inc. All rights reserved.
8342e7
+#
8342e7
+# This copyrighted material is made available to anyone wishing to use,
8342e7
+# modify, copy, or redistribute it subject to the terms and conditions
8342e7
+# of the GNU General Public License v.2.
8342e7
+#
8342e7
+# You should have received a copy of the GNU General Public License
8342e7
+# along with this program; if not, write to the Free Software Foundation,
8342e7
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8342e7
+
8342e7
+#
8342e7
+# Play with thin-pool and thin removal and creation in corner cases
8342e7
+#
8342e7
+
8342e7
+SKIP_WITH_LVMLOCKD=1
8342e7
+SKIP_WITH_LVMPOLLD=1
8342e7
+
8342e7
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
8342e7
+
8342e7
+. lib/inittest
8342e7
+
8342e7
+aux have_thin 1 0 0 || skip
8342e7
+
8342e7
+test -n "$LVM_TEST_THIN_RESTORE_CMD" || LVM_TEST_THIN_RESTORE_CMD=$(which thin_restore) || skip
8342e7
+"$LVM_TEST_THIN_RESTORE_CMD" -V || skip
8342e7
+
8342e7
+aux have_thin 1 10 0 || skip
8342e7
+
8342e7
+aux prepare_vg 2
8342e7
+
8342e7
+lvcreate -V10 -n $lv1 -L10 -T $vg/pool
8342e7
+lvcreate -V10 -n $lv2 $vg/pool
8342e7
+
8342e7
+# Forcibly 'error' _tmeta thin-pool metadata device
8342e7
+not dmsetup remove -f $vg-pool_tmeta
8342e7
+
8342e7
+# Now try to schedule removal of thin volume id 1
8342e7
+# that will fail with errored meta device
8342e7
+not lvremove -y $vg/$lv1
8342e7
+
8342e7
+# Check we have queued 'message'
8342e7
+vgcfgbackup -f out0 $vg
8342e7
+grep "message1" out0
8342e7
+
8342e7
+vgchange -an $vg || true
8342e7
+
8342e7
+not dmsetup table ${vg}-pool-tpool
8342e7
+
8342e7
+# Reactivate thin-pool
8342e7
+vgchange -ay $vg
8342e7
+
8342e7
+# Check message is still queued there
8342e7
+vgcfgbackup -f out1 $vg
8342e7
+grep "message1" out1
8342e7
+
8342e7
+lvchange -an $vg
8342e7
+
8342e7
+lvextend -L+10 $vg/pool
8342e7
+
8342e7
+# Messages should be now processed and gone
8342e7
+vgcfgbackup -f out2 $vg
8342e7
+not grep "message1" out2
8342e7
+
8342e7
+lvchange -an $vg
8342e7
+
8342e7
+lvchange -y -ay $vg/pool_tmeta
8342e7
+
8342e7
+# Kernel metadata must not see dev_id 1 either
8342e7
+thin_dump $DM_DEV_DIR/$vg/pool_tmeta | tee meta
8342e7
+not grep 'dev_id="1"' meta
8342e7
+
8342e7
+lvremove -ff $vg
8342e7
+
8342e7
+lvs -a $vg
8342e7
+
8342e7
+vgremove -ff $vg
8342e7
-- 
8342e7
2.38.1
8342e7