Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3dd11d9ea8b04a47e4eab…
Commit: 3dd11d9ea8b04a47e4eab7ebdd22c34fa18d4787
Parent: 98e33ee3fbce8c43c312a2e6b8e42cddb3e6874c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 8 15:20:33 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 8 15:37:24 2020 +0200
test: repair of thin-pool used by foreign apps
---
test/shell/thin-foreign-repair.sh | 72 +++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/test/shell/thin-foreign-repair.sh b/test/shell/thin-foreign-repair.sh
new file mode 100644
index 000000000..147a9a073
--- /dev/null
+++ b/test/shell/thin-foreign-repair.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# test foreing user of thin-pool
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+cleanup_mounted_and_teardown()
+{
+ dmsetup remove $THIN || true
+ vgremove -ff $vg
+ aux teardown
+}
+
+#
+# Main
+#
+aux have_thin 1 0 0 || skip
+which mkfs.ext4 || skip
+
+# Use our mkfs config file to get approximately same results
+# TODO: maybe use it for all test via some 'prepare' function
+export MKE2FS_CONFIG="$TESTOLDPWD/lib/mke2fs.conf"
+
+aux prepare_vg 2 64
+
+# Create named pool only
+lvcreate -L2 -T $vg/pool
+
+POOL="$vg-pool"
+THIN="${PREFIX}_thin"
+
+# Foreing user is using own ioctl command to create thin devices
+dmsetup message $POOL 0 "create_thin 0"
+dmsetup message $POOL 0 "set_transaction_id 0 2"
+
+# Once the transaction id has changed, lvm2 shall not be able to create thinLV
+fail lvcreate -V10 $vg/pool
+
+trap 'cleanup_mounted_and_teardown' EXIT
+
+# 20M thin device
+dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
+
+mkfs.ext4 "$DM_DEV_DIR/mapper/$THIN"
+
+dmsetup remove "$THIN"
+
+lvchange -an $vg/pool
+
+# Repair thin-pool used by 'foreing' apps (setting their own tid)
+lvconvert --repair $vg/pool 2>&1 | tee out
+
+not grep "Transaction id" out
+
+lvchange -ay $vg/pool
+
+dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
+
+fsck -n "$DM_DEV_DIR/mapper/$THIN"
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=98e33ee3fbce8c43c312a…
Commit: 98e33ee3fbce8c43c312a2e6b8e42cddb3e6874c
Parent: 06cbe3cfc6958b016d97243b807aaf29b9908b23
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 8 11:46:42 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 8 15:22:44 2020 +0200
lvconvert: no validation for thin-pools not used by lvm2
lvm2 supports thin-pool to be later used by other tools doing
virtual volumes themself (i.e. docker) - in this case we
shall not validate transaction Id - is this is used by
other tools and lvm2 keeps value 0 - so the transationId
validation need to be skipped in this case.
---
tools/lvconvert.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index f6d9a29f6..bb40930cb 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2388,7 +2388,8 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
goto deactivate_mlv;
}
- if (thin_dump[0]) {
+ /* Check matching transactionId when thin-pool is used by lvm2 (transactionId != 0) */
+ if (first_seg(pool_lv)->transaction_id && thin_dump[0]) {
argv[0] = thin_dump;
argv[1] = pms_path;
argv[2] = NULL;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=70d2ff38c0dfb4e466481…
Commit: 70d2ff38c0dfb4e46648102ed655afa9f0929c60
Parent: 1316cafbe988307264e4f87dbcffaf56bc2ab388
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 8 15:20:33 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 8 15:31:17 2020 +0200
test: repair of thin-pool used by foreign apps
---
test/shell/thin-foreign-repair.sh | 72 +++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/test/shell/thin-foreign-repair.sh b/test/shell/thin-foreign-repair.sh
new file mode 100644
index 000000000..147a9a073
--- /dev/null
+++ b/test/shell/thin-foreign-repair.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# test foreing user of thin-pool
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+cleanup_mounted_and_teardown()
+{
+ dmsetup remove $THIN || true
+ vgremove -ff $vg
+ aux teardown
+}
+
+#
+# Main
+#
+aux have_thin 1 0 0 || skip
+which mkfs.ext4 || skip
+
+# Use our mkfs config file to get approximately same results
+# TODO: maybe use it for all test via some 'prepare' function
+export MKE2FS_CONFIG="$TESTOLDPWD/lib/mke2fs.conf"
+
+aux prepare_vg 2 64
+
+# Create named pool only
+lvcreate -L2 -T $vg/pool
+
+POOL="$vg-pool"
+THIN="${PREFIX}_thin"
+
+# Foreing user is using own ioctl command to create thin devices
+dmsetup message $POOL 0 "create_thin 0"
+dmsetup message $POOL 0 "set_transaction_id 0 2"
+
+# Once the transaction id has changed, lvm2 shall not be able to create thinLV
+fail lvcreate -V10 $vg/pool
+
+trap 'cleanup_mounted_and_teardown' EXIT
+
+# 20M thin device
+dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
+
+mkfs.ext4 "$DM_DEV_DIR/mapper/$THIN"
+
+dmsetup remove "$THIN"
+
+lvchange -an $vg/pool
+
+# Repair thin-pool used by 'foreing' apps (setting their own tid)
+lvconvert --repair $vg/pool 2>&1 | tee out
+
+not grep "Transaction id" out
+
+lvchange -ay $vg/pool
+
+dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
+
+fsck -n "$DM_DEV_DIR/mapper/$THIN"
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1316cafbe988307264e4f…
Commit: 1316cafbe988307264e4f87dbcffaf56bc2ab388
Parent: 5f766b32cf0d88644232a43a59247476a16fbc9c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 8 11:46:42 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 8 15:31:17 2020 +0200
lvconvert: no validation for thin-pools not used by lvm2
lvm2 supports thin-pool to be later used by other tools doing
virtual volumes themself (i.e. docker) - in this case we
shall not validate transaction Id - is this is used by
other tools and lvm2 keeps value 0 - so the transationId
validation need to be skipped in this case.
---
tools/lvconvert.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 677bed134..0bc1a0128 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2325,7 +2325,8 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
goto deactivate_mlv;
}
- if (thin_dump[0]) {
+ /* Check matching transactionId when thin-pool is used by lvm2 (transactionId != 0) */
+ if (first_seg(pool_lv)->transaction_id && thin_dump[0]) {
argv[0] = thin_dump;
argv[1] = pms_path;
argv[2] = NULL;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5d93892d4ae67b355ab6b…
Commit: 5d93892d4ae67b355ab6b418c0c404e1536d055f
Parent: 8f3d2d5e11305b5f3fc7ced7bd2f81412c9e7d93
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 4 15:56:09 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 8 15:22:54 2020 +0200
dmeventd: enhance time waiting loop
dmeventd is 'scanning' statuses in loop (most usually in 10sec
intervals) - and meanwhile it sleeps within:
pthread_cond_timedwait()
However this function call tends to wakeup sometimes a short amount of
time sooner - and our code still believe the 'right time' has not yet
arrived and basically for a moment 'busy-looped' on calling this
function - so for systems with 'clock_gettime()' present we obtain
time and we go 10ms to the future second - this avoids unneeded
repeated invocation of our time scheduling loop.
TODO: monitoring during 1 hour 'time-change'...
---
daemons/dmeventd/dmeventd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 8917422fc..1b84c28ba 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -752,7 +752,7 @@ static void _exit_timeout(void *unused __attribute__((unused)))
static void *_timeout_thread(void *unused __attribute__((unused)))
{
struct thread_status *thread;
- struct timespec timeout;
+ struct timespec timeout, real_time;
time_t curr_time;
int ret;
@@ -763,7 +763,16 @@ static void *_timeout_thread(void *unused __attribute__((unused)))
while (!dm_list_empty(&_timeout_registry)) {
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
+#ifndef HAVE_REALTIME
curr_time = time(NULL);
+#else
+ if (clock_gettime(CLOCK_REALTIME, &real_time)) {
+ log_error("Failed to read clock_gettime().");
+ break;
+ }
+ /* 10ms back to the future */
+ curr_time = real_time.tv_sec + ((real_time.tv_nsec > (1000000000 - 10000000)) ? 1 : 0);
+#endif
dm_list_iterate_items_gen(thread, &_timeout_registry, timeout_list) {
if (thread->next_time <= curr_time) {