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

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