Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=96a1943fb8d208aa…
Commit: 96a1943fb8d208aa84c386cf48f2b62038b09e2e
Parent: 14902d173917e814061a80f16ea54435abba1f91
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 23 12:52:45 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 23 13:16:35 2016 +0100
tests: update test
lvm2 now correctly reports thin_id after action of merged thin,
but before physical metadata update as we know the merge has happened.
---
test/shell/thin-vglock.sh | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/test/shell/thin-vglock.sh b/test/shell/thin-vglock.sh
index e59636d..40f3adf 100644
--- a/test/shell/thin-vglock.sh
+++ b/test/shell/thin-vglock.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014-2016 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
@@ -37,15 +37,24 @@ check lv_field $vg/snap thin_id "3"
lvconvert --merge $vg/snap
umount mnt
+
+check lv_field $vg/$lv1 thin_id "1"
+check lv_field $vg/pool transaction_id "3"
+
vgchange -an $vg
# Check reboot case
vgchange -ay --sysinit $vg
-# Metadata are still not updated (--poll n)
-check lv_field $vg/$lv1 thin_id "1"
+
+# Check correct thin_id is shown after activation
+# even when metadata were not yet physically modified.
+# Merge take its place during activation,
+# but pool transaction_id still needs metadata update.
+check lv_field $vg/$lv1 thin_id "3"
check lv_field $vg/pool transaction_id "3"
# Check the metadata are updated after refresh
+#
vgchange --refresh $vg
check lv_field $vg/$lv1 thin_id "3"
check lv_field $vg/pool transaction_id "4"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=62be9c8de430a054…
Commit: 62be9c8de430a054d5de9b652949f58a684a0cf6
Parent: e1943fc07f81e1c824757ccdac45c1e43a57af28
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 22 23:31:22 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 22 23:37:07 2016 +0100
tests: use hold_device_open
---
test/shell/snapshot-merge-stack.sh | 4 +---
test/shell/snapshot-usage.sh | 15 +--------------
test/shell/thin-autoumount-dmeventd.sh | 6 +++---
3 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/test/shell/snapshot-merge-stack.sh b/test/shell/snapshot-merge-stack.sh
index bfafe71..2fdfaa4 100644
--- a/test/shell/snapshot-merge-stack.sh
+++ b/test/shell/snapshot-merge-stack.sh
@@ -29,9 +29,7 @@ snap_and_merge() {
sync
lvs -a $vg
- # keep device open to prevent instant merge
- sleep 20 < "$DM_DEV_DIR/$vg/$lv1" &
- SLEEP_PID=$!
+ SLEEP_PID=$(aux hold_device_open $vg $lv1 20)
# initiate background merge
lvconvert -b --merge $vg/$lv2
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index 042b4bf..a780664 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -24,16 +24,6 @@ fill() {
die "Snapshot does not fit $1"
}
-# Wait until device is opened
-wait_for_open_() {
- for i in $(seq 1 50) ; do
- test $(dmsetup info --noheadings -c -o open $1) -ne 0 && return
- sleep 0.1
- done
-
- die "$1 expected to be openned, but it's not!"
-}
-
cleanup_tail()
{
test -z "$SLEEP_PID" || kill $SLEEP_PID || true
@@ -125,10 +115,7 @@ lvchange -ay $vg1
check lv_field $vg1/$lv1 lv_active "$CHECK_ACTIVE"
# Test removal of opened (but unmounted) snapshot (device busy) for a while
-sleep 120 < "$DM_DEV_DIR/$vg1/$lv1" &
-SLEEP_PID=$!
-
-wait_for_open_ "$vg1-$lv1"
+SLEEP_PID=$(aux hold_device_open $vg1 $lv1 60)
# Opened virtual snapshot device is not removable
# it should retry device removal for a few seconds
diff --git a/test/shell/thin-autoumount-dmeventd.sh b/test/shell/thin-autoumount-dmeventd.sh
index 3729e18..40dd75f 100644
--- a/test/shell/thin-autoumount-dmeventd.sh
+++ b/test/shell/thin-autoumount-dmeventd.sh
@@ -72,18 +72,18 @@ touch "$mntusedir/file$$"
sync
# Running 'keeper' process sleep holds the block device still in use
-sleep 60 < "$mntusedir/file$$" &
+sleep 60 < "$mntusedir/file$$" >/dev/null 2>&1 &
PID_SLEEP=$!
lvs -a $vg
# Fill pool above 95% (to cause 'forced lazy umount)
dd if=/dev/zero of="$mntdir/file$$" bs=256K count=20 conv=fdatasync
-sync
+
lvs -a $vg
# Could loop here for a few secs so dmeventd can do some work
# In the worst case check only happens every 10 seconds :(
-# With low water mark it should react way faster
+# With low water mark it quickly discovers overflow and umounts $vg/$lv1
for i in $(seq 1 12) ; do
is_lv_opened_ "$vg/$lv1" || break
test $i -lt 12 || die "$mntdir should have been unmounted by dmeventd!"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e1943fc07f81e1c8…
Commit: e1943fc07f81e1c824757ccdac45c1e43a57af28
Parent: 1053d46aff11a8e592ca91ba56d6400f4693b9a5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 22 22:21:09 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 22 23:37:07 2016 +0100
tests: add device holding function
Hold device open with sleep and wait till sleep really opens
given devices.
---
test/lib/aux.sh | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index a195883..174e05e 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1491,6 +1491,27 @@ wait_pvmove_lv_ready() {
fi
}
+# Holds device open with sleep which automatically expires after given timeout
+# Prints PID of running holding sleep process in background
+hold_device_open() {
+ local vgname=$1
+ local lvname=$2
+ local sec=${3:-20} # default 20sec
+
+ sleep $sec < "$DM_DEV_DIR/$vgname/$lvname" >/dev/null 2>&1 &
+ SLEEP_PID=$!
+ # wait till device is openned
+ for i in $(seq 1 50) ; do
+ if test "$(dmsetup info --noheadings -c -o open $vgname-$lvname)" -ne 0 ; then
+ echo "$SLEEP_PID"
+ return
+ fi
+ sleep .1
+ done
+
+ die "$vgname-$lvname expected to be openned, but it's not!"
+}
+
# return total memory size in kB units
total_mem() {
while IFS=":" read -r a b ; do
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dd19b5698553b4eb…
Commit: dd19b5698553b4eb0214825a6dcb88a5330b4097
Parent: 77997c7673bfca56f51ae4eb55a50bc76e40fe79
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 22 23:28:04 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 22 23:37:07 2016 +0100
thin: refresh status when error processing fails
When thin-pool processes event and 'lvextend --use-policies' fails
rather capture up-to-date new info as the fullness percentage may
have jumped noticable. This way we could use 'more' correct numbers
when checking for thresholds.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 26 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 3f9eeac..67aed5e 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.138 -
=====================================
+ Thin dmeventd plugin reacts faster on lvextend failure path with umount.
Add dm_stats_bind_from_fd() to bind a stats handle from a file descriptor.
Do not try call callback when reverting activation on error path.
Fix file mapping for extents with physically adjacent extents.
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index 0c26baf..65de465 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -328,6 +328,7 @@ void process_event(struct dm_task *dmt,
char *params;
int needs_policy = 0;
int needs_umount = 0;
+ struct dm_task *new_dmt = NULL;
#if THIN_DEBUG
log_debug("Watch for tp-data:%.2f%% tp-metadata:%.2f%%.",
@@ -346,6 +347,28 @@ void process_event(struct dm_task *dmt,
goto out;
stack;
+
+ /*
+ * Rather update oldish status
+ * since after 'command' processing
+ * percentage info could have changed a lot.
+ * If we would get above UMOUNT_THRESH
+ * we would wait for next sigalarm.
+ */
+ if (!(new_dmt = dm_task_create(DM_DEVICE_STATUS)))
+ goto_out;
+
+ if (!dm_task_set_uuid(new_dmt, dm_task_get_uuid(dmt)))
+ goto_out;
+
+ /* Non-blocking status read */
+ if (!dm_task_no_flush(new_dmt))
+ log_warn("WARNING: Can't set no_flush for dm status.");
+
+ if (!dm_task_run(new_dmt))
+ goto_out;
+
+ dmt = new_dmt;
}
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
@@ -433,6 +456,9 @@ out:
device, state->fails);
pthread_kill(pthread_self(), SIGALRM);
}
+
+ if (new_dmt)
+ dm_task_destroy(new_dmt);
}
int register_device(const char *device,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77997c7673bfca56…
Commit: 77997c7673bfca56f51ae4eb55a50bc76e40fe79
Parent: 2aee4769b43a08eed549bd324664af5f406a25b2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 22 19:51:35 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 22 23:37:07 2016 +0100
report: show proper info for merging origin
When there is 'merging' of an origin in progress, but metadata stil
do provide both origin and snapshot, we should show data from merged
snapshot. This is important mainly for thin case, where there was
a window, where i.e. 'lvs -o+device_id' would report information
about 'already gone' origin thin LV.
This race window is usually hard to trigger but can be ocasionally hit.
Usually shortly after activation, but before polling process manages
to update metadata after merge.
---
WHATS_NEW | 1 +
tools/reporter.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index dcfd85a..e5bbfe0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Report thin LV date for merged LV when the merge is in progress.
Detect if snapshot merge really started before polling for progress.
Checking LV for merging origin requires also it has merged snapshot.
Extend validation of metadata processing.
diff --git a/tools/reporter.c b/tools/reporter.c
index fc87c06..6c5996b 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -113,6 +113,40 @@ static int _do_info_and_status(struct cmd_context *cmd,
return 1;
}
+/* Check if this is really merging origin.
+ * In such case, origin is gone, and user should see
+ * only data from merged snapshot. Important for thin. */
+static int _check_merging_origin(const struct logical_volume *lv,
+ struct lv_with_info_and_seg_status *status,
+ int *merged)
+{
+ uint32_t device_id;
+
+ *merged = 0;
+
+ switch (status->seg_status.type) {
+ case SEG_STATUS_THIN:
+ /* Get 'device_id' from active dm-table */
+ if (!lv_thin_device_id(lv, &device_id))
+ return_0;
+
+ if (lv->snapshot->device_id != device_id)
+ return 1;
+ break;
+ case SEG_STATUS_SNAPSHOT:
+ break;
+ default:
+ return 1;
+ }
+
+ /* Origin is gone */
+ log_debug_activation("Merge is progress, reporting merged LV %s.",
+ display_lvname(lv->snapshot->lv));
+ *merged = 1;
+
+ return 1;
+}
+
static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
const struct logical_volume *lv,
int do_info, int do_status,
@@ -123,10 +157,22 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
.seg_status.type = SEG_STATUS_NONE
};
int r = ECMD_FAILED;
+ int merged;
+
+ if (lv_is_merging_origin(lv))
+ /* Status is need to know which LV should be shown */
+ do_status = 1;
if (!_do_info_and_status(cmd, first_seg(lv), &status, do_info, do_status))
goto_out;
+ if (lv_is_merging_origin(lv)) {
+ if (!_check_merging_origin(lv, &status, &merged))
+ goto_out;
+ if (merged)
+ lv = lv->snapshot->lv;
+ }
+
if (!report_object(sh ? : handle->custom_handle, sh != NULL,
lv->vg, lv, NULL, NULL, NULL, &status, NULL))
goto out;
@@ -173,10 +219,22 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
.seg_status.type = SEG_STATUS_NONE
};
int r = ECMD_FAILED;
+ int merged;
+
+ if (lv_is_merging_origin(seg->lv))
+ /* Status is need to know which LV should be shown */
+ do_status = 1;
if (!_do_info_and_status(cmd, seg, &status, do_info, do_status))
goto_out;
+ if (lv_is_merging_origin(seg->lv)) {
+ if (!_check_merging_origin(seg->lv, &status, &merged))
+ goto_out;
+ if (merged)
+ seg = seg->lv->snapshot;
+ }
+
if (!report_object(sh ? : handle->custom_handle, sh != NULL,
seg->lv->vg, seg->lv, NULL, seg, NULL, &status, NULL))
goto_out;
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2aee4769b43a08ee…
Commit: 2aee4769b43a08eed549bd324664af5f406a25b2
Parent: 95e3dd5fb1297f6b1aa23cbedad1ab3dc14343a7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 22 19:46:02 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 22 23:37:07 2016 +0100
snapshot: validate merge has started
Before starting polling process, validate the merge has actually started
so there is not pointless invoke of lvmpolld.
This also fixes reported message from command, so user has
correct info whether merging has already started or
if it's delayed for next activation.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8fefe6a..dcfd85a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Detect if snapshot merge really started before polling for progress.
Checking LV for merging origin requires also it has merged snapshot.
Extend validation of metadata processing.
Enable usage of cached volumes as snapshot origin LV.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 0f0f0ad..ba8396f 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2497,8 +2497,13 @@ static int _lvconvert_merge_old_snapshot(struct cmd_context *cmd,
if (!lv_update_and_reload(origin))
return_0;
- lp->need_polling = 1;
- lp->lv_to_poll = origin;
+ if (lv_has_target_type(origin->vg->vgmem, origin, NULL,
+ TARGET_NAME_SNAPSHOT_MERGE)) {
+ lp->need_polling = 1;
+ lp->lv_to_poll = origin;
+ } else
+ /* Race during table reload prevented merging */
+ merge_on_activate = 1;
}
if (merge_on_activate)