Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dcf8f3111aea1179be108…
Commit: dcf8f3111aea1179be1083ace772f3108b06c508
Parent: ece0b131e51154253e14a938e6c24f4983e77bec
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 13 17:10:49 2019 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Mar 7 11:07:27 2019 -0600
pvscan: lvmetad init should set updating before scanning
When pvscan needs to initialize lvmetad (e.g. lvmetad has just
started and is empty), it should set the lvmetad state to "updating"
before it scans any devices. Otherwise, many parallel pvscans
will try to initialize lvmetad, and in some cases earlier pvscans
with fewer devices information may replace newer pvscans with
more recent information.
---
lib/cache/lvmetad.c | 34 +++++++++++++++++++++-------------
tools/pvscan.c | 9 ++++-----
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index f068fc6..86a880a 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -313,6 +313,7 @@ retry:
* The caller should do a disk scan to populate lvmetad.
*/
if (!strcmp(daemon_token, "none")) {
+ log_debug_lvmetad("lvmetad initialization needed.");
ret = 0;
goto out;
}
@@ -324,10 +325,16 @@ retry:
* our global filter.
*/
if (strcmp(daemon_token, _lvmetad_token)) {
+ log_debug_lvmetad("lvmetad initialization needed for different filter.");
ret = 0;
goto out;
}
+ if (wait_start)
+ log_debug_lvmetad("lvmetad initialized during wait.");
+ else
+ log_debug_lvmetad("lvmetad initialized previously.");
+
out:
daemon_reply_destroy(reply);
return ret;
@@ -2353,23 +2360,11 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
replacing_other_update = 1;
}
- label_scan_pvscan_all(cmd, &scan_devs);
-
- lvmcache_pvscan_duplicate_check(cmd);
-
- if (lvmcache_found_duplicate_pvs()) {
- log_warn("WARNING: Scan found duplicate PVs.");
- return 0;
- }
-
- log_verbose("Scanning metadata from %d devices to update lvmetad.",
- dm_list_size(&scan_devs));
-
future_token = _lvmetad_token;
_lvmetad_token = (char *) LVMETAD_TOKEN_UPDATE_IN_PROGRESS;
if (!_token_update(&replaced_update)) {
- log_error("Failed to update lvmetad which had an update in progress.");
+ log_error("Failed to start lvmetad update.");
_lvmetad_token = future_token;
return 0;
}
@@ -2393,6 +2388,10 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
return 0;
}
+ log_verbose("Scanning all devices to initialize lvmetad.");
+
+ label_scan_pvscan_all(cmd, &scan_devs);
+
log_debug_lvmetad("Telling lvmetad to clear its cache");
reply = _lvmetad_send(cmd, "pv_clear_all", NULL);
if (!_lvmetad_handle_reply(reply, "pv_clear_all", "", NULL))
@@ -2402,6 +2401,8 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
was_silent = silent_mode();
init_silent(1);
+ log_debug_lvmetad("Sending %d devices to lvmetad.", dm_list_size(&scan_devs));
+
dm_list_iterate_items_safe(devl, devl2, &scan_devs) {
if (sigint_caught()) {
ret = 0;
@@ -2442,6 +2443,13 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, int do_wait)
return 0;
}
+ /* This will disable lvmetad if label scan found duplicates. */
+ lvmcache_pvscan_duplicate_check(cmd);
+ if (lvmcache_found_duplicate_pvs()) {
+ log_warn("WARNING: Scan found duplicate PVs.");
+ return 0;
+ }
+
/*
* If lvmetad is disabled, and no duplicate PVs were seen, then re-enable lvmetad.
*/
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 5587928..daac88f 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -381,7 +381,7 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
all_vgs = 1;
goto activate;
}
-
+
/*
* FIXME: when specific devs are named, we generally don't want to scan
* any other devs, but if lvmetad is not yet populated, the first
@@ -390,11 +390,10 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
* never scan any devices other than those specified.
*/
if (!lvmetad_token_matches(cmd)) {
- log_verbose("Scanning all devices to initialize lvmetad.");
-
if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, 0)) {
- log_warn("WARNING: Not using lvmetad because cache update failed.");
- lvmetad_make_unused(cmd);
+ log_warn("WARNING: Not updating lvmetad because cache update failed.");
+ ret = ECMD_FAILED;
+ goto out;
}
if (lvmetad_used() && lvmetad_is_disabled(cmd, &reason)) {
log_warn("WARNING: Not using lvmetad because %s.", reason);
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7f757ab6166074dd32869…
Commit: 7f757ab6166074dd3286983c05a30623095845ff
Parent: 5139e5f1b3b26ae89a6e1415dd994a3ea33c460e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jan 26 01:36:07 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:39:11 2019 +0100
tests: vdo caching tests
---
test/shell/lvconvert-cache-vdo.sh | 61 +++++++++++++++++++++++++++++++++++++
test/shell/lvcreate-vdo-cache.sh | 55 +++++++++++++++++++++++++++++++++
2 files changed, 116 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-cache-vdo.sh b/test/shell/lvconvert-cache-vdo.sh
new file mode 100644
index 0000000..8e28948
--- /dev/null
+++ b/test/shell/lvconvert-cache-vdo.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2014 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
+
+# Exercise usage of stacked cache volume used in thin pool volumes
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_vdo 6 2 0 || skip
+aux have_cache 1 3 0 || skip
+
+aux prepare_vg 1 9000
+
+lvcreate -L10 -n cpool $vg
+lvcreate -L4G -n vpool $vg
+
+# Cache volume
+lvconvert --yes --cache --cachepool cpool $vg/vpool
+
+# Stack cached LV as VDODataLV for VDOPoolLV
+lvconvert --yes --type vdo-pool -V50M --name $lv1 $vg/vpool
+
+aux mkdev_md5sum $vg $lv1
+
+lvconvert --splitcache $vg/vpool
+
+check dev_md5sum $vg $lv1
+lvchange -an $vg
+lvchange -ay $vg
+check dev_md5sum $vg $lv1
+
+lvconvert --yes --cache --cachepool cpool $vg/vpool
+lvconvert --splitcache $vg/vpool
+
+lvs -a $vg
+
+lvconvert --yes --cache --cachepool cpool $vg/$lv1
+check dev_md5sum $vg $lv1
+lvchange -an $vg
+lvchange -ay $vg
+check dev_md5sum $vg $lv1
+
+lvs -a $vg
+not lvconvert --splitcache $vg/vpool
+lvconvert --splitcache $vg/$lv1
+lvs -a $vg
+
+# Also check, removal of cached VDO LV works
+lvconvert --yes --cache --cachepool cpool $vg/$lv1
+vgremove -f $vg
diff --git a/test/shell/lvcreate-vdo-cache.sh b/test/shell/lvcreate-vdo-cache.sh
new file mode 100644
index 0000000..c3d3ed0
--- /dev/null
+++ b/test/shell/lvcreate-vdo-cache.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2017 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
+
+# Exercise caching vdo and vdo-pool's data LV
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+#
+# Main
+#
+aux have_vdo 6 2 0 || skip
+aux have_cache 1 3 0 || skip
+
+which mkfs.ext4 || skip
+export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
+
+aux prepare_vg 1 9000
+
+lvcreate --vdo -L4G -V2G --name $lv1 $vg/vpool
+
+# Test caching VDOPoolLV
+lvcreate -H -L10 $vg/vpool
+
+mkfs.ext4 -E nodiscard "$DM_DEV_DIR/$vg/$lv1"
+
+lvconvert --uncache $vg/vpool
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+
+lvcreate -H -L10 $vg/vpool_vdata
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+lvs -a $vg
+lvconvert --uncache $vg/vpool_vdata
+
+
+# Test caching VDOLV
+lvcreate -H -L10 $vg/$lv1
+
+lvconvert --uncache $vg/$lv1
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+
+lvs -a $vg
+
+vgremove -ff $vg
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5139e5f1b3b26ae89a6e1…
Commit: 5139e5f1b3b26ae89a6e1415dd994a3ea33c460e
Parent: 1117f1d46f9cbc4a0a29a975ab5c5588d63a2feb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 24 14:16:18 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:39:11 2019 +0100
tests: vdo dmevent autoresize
---
test/shell/vdo-autoumount-dmeventd.sh | 121 +++++++++++++++++++++++++++++++++
1 files changed, 121 insertions(+), 0 deletions(-)
diff --git a/test/shell/vdo-autoumount-dmeventd.sh b/test/shell/vdo-autoumount-dmeventd.sh
new file mode 100644
index 0000000..0d0747a
--- /dev/null
+++ b/test/shell/vdo-autoumount-dmeventd.sh
@@ -0,0 +1,121 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2019 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
+
+# no automatic extensions, just umount
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+mntdir="${PREFIX}mnt with space"
+PERCENT=70
+
+cleanup_mounted_and_teardown()
+{
+ test -z "$PID_SLEEP" || { kill "$PID_SLEEP" || true ; }
+ umount "$mntdir" 2>/dev/null || true
+ vgremove -ff $vg
+ aux teardown
+}
+
+is_lv_opened_()
+{
+ test "$(get lv_field "$1" lv_device_open --binary)" = 1
+}
+
+#
+# Main
+#
+which mkfs.ext4 || skip
+export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
+
+aux have_vdo 6 2 0 || skip
+
+# Simple implementation of umount when lvextend fails
+cat <<- EOF >testcmd.sh
+#!/bin/sh
+
+echo "VDO Pool: \$DMEVENTD_VDO_POOL"
+
+"$TESTDIR/lib/lvextend" --use-policies \$1 || {
+ umount "$mntdir" || true
+ return 0
+}
+test "\$($TESTDIR/lib/lvs -o selected -S "data_percent>=$PERCENT" --noheadings \$1)" -eq 0 || {
+ umount "$mntdir" || true
+ return 0
+}
+EOF
+chmod +x testcmd.sh
+# Show prepared script
+cat testcmd.sh
+
+# Use autoextend percent 0 - so extension fails and triggers umount...
+aux lvmconf "activation/vdo_pool_autoextend_percent = 0" \
+ "activation/vdo_pool_autoextend_threshold = $PERCENT" \
+ "dmeventd/vdo_command = \"/$PWD/testcmd.sh\"" \
+ "allocation/vdo_slab_size_mb = 128"
+
+aux prepare_dmeventd
+
+aux prepare_vg 1 9000
+
+lvcreate --vdo -L4G -V2G -n $lv1 $vg/vpool
+
+mkfs.ext4 -E nodiscard "$DM_DEV_DIR/$vg/$lv1"
+
+lvchange --monitor y $vg/vpool
+
+mkdir "$mntdir"
+trap 'cleanup_mounted_and_teardown' EXIT
+mount "$DM_DEV_DIR/$vg/$lv1" "$mntdir"
+
+# Check both LV is opened (~mounted)
+is_lv_opened_ "$vg/$lv1"
+
+touch "$mntdir/file$$"
+sync
+
+# Running 'keeper' process sleep holds the block device still in use
+sleep 60 < "$mntdir/file$$" >/dev/null 2>&1 &
+PID_SLEEP=$!
+
+lvs -a $vg
+# Fill pool above 95% (to cause 'forced lazy umount)
+dd if=/dev/urandom of="$mntdir/file$$" bs=256K count=200 conv=fdatasync
+
+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 :(
+for i in $(seq 1 12) ; do
+ is_lv_opened_ "$vg/$lv1" || break
+ sleep 1
+done
+
+test "$i" -eq 12 || die "$mntdir should NOT have been unmounted by dmeventd!"
+
+lvs -a $vg
+
+# Kill device holding process - umount should work now
+kill "$PID_SLEEP"
+PID_SLEEP=
+wait
+
+# Could loop here for a few secs so dmeventd can do some work
+# In the worst case check only happens every 10 seconds :(
+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!"
+ sleep 1
+done
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1117f1d46f9cbc4a0a29a…
Commit: 1117f1d46f9cbc4a0a29a975ab5c5588d63a2feb
Parent: 597113646d10e14044e0b89712342ae73b77b697
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 23 22:51:00 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:39:11 2019 +0100
man: dmeventd vdo plugin
---
man/dmeventd.8_main | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/man/dmeventd.8_main b/man/dmeventd.8_main
index 06f8f58..dc4abf6 100644
--- a/man/dmeventd.8_main
+++ b/man/dmeventd.8_main
@@ -125,6 +125,36 @@ To see the fullness of a thin pool command may check these
two environmental variables
\fBDMEVENTD_THIN_POOL_DATA\fP and \fBDMEVENTD_THIN_POOL_METADATA\fP.
Command can also read status with tools like \fBlvs\fP(8).
+
+.HP
+.BR Vdo
+.br
+Monitors how full a VDO pool data is becoming and emits
+a warning to syslog when it exceeds 80% full.
+The warning is repeated when more then 85%, 90% and 95%
+of the VDO pool is filled. See
+.BR lvm.conf (5).
+When a VDO pool fills over 50% vdo plugin calls
+configured \fIdmeventd/vdo_command\fP with every 5% increase.
+With default setting it calls internal
+\fBlvm lvextend --use-policies\fP to resize VDO pool
+when it's been filled above the configured threshold
+\fIactivation/vdo_pool_autoextend_threshold\fP.
+If the command fails, dmeventd vdo plugin will keep
+retrying execution with increasing time delay between
+retries upto 42 minutes.
+User may also configure external command to support more advanced
+maintenance operations of a VDO pool.
+Such external command can e.g. remove some unneeded space
+with \fBfstrim\fP(8),
+but also can use \fBlvextend --use-policies\fP if other actions
+have not released enough space.
+Command is executed with environmental variable
+\fBLVM_RUN_BY_DMEVENTD=1\fP so any lvm2 command executed
+in this environment will not try to interact with dmeventd.
+To see the fullness of a VDO pool command may check this
+environmental variable \fBDMEVENTD_VDO_POOL\fP.
+Command can also read status with tools like \fBlvs\fP(8).
.
.SH ENVIRONMENT VARIABLES
.
@@ -139,10 +169,15 @@ Variable is set by thin plugin and is available to executed program. Value prese
actual usage of thin pool metadata volume. Variable is not set when error event
is processed.
.TP
+.B DMEVENTD_VDO_POOL
+Variable is set by vdo plugin and is available to executed program. Value present
+actual usage of VDO pool data volume. Variable is not set when error event
+is processed.
+.TP
.B LVM_RUN_BY_DMEVENTD
-Variable is set by thin plugin to prohibit recursive interation
+Variable is set by thin and vdo plugin to prohibit recursive interation
with dmeventd by any executed lvm2 command from
-a thin_command environment.
+a thin_command, vdo_command environment.
.
.SH SEE ALSO
.
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4411fe2ba855b9c42b5d1…
Commit: 4411fe2ba855b9c42b5d1393fc08faf01b1d2636
Parent: 677aa84be3b41e94514aa5c1560e987e7763b294
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 6 12:37:47 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:39:09 2019 +0100
activation: synchronize before removing devices
Udev is running udev-rule action upon 'resume'.
However lvm2 in special case is doing replacement of
'soon-to-be-removed' device with 'error' target for resuming
and then follows actual removal - the sequence is usually quick,
so when udev start action - it can result in 'strange' error
message in kernel log like:
Process '/usr/sbin/dmsetup info -j 253 -m 17 -c --nameprefixes --noheadings --rows -o name,uuid,suspended' failed with exit code 1.
To avoid this - we need to ensure there is synchronization wait for udev
between 'resume' and 'remove' part of this process.
However existing code put strict requirement to avoid synchronizing with
udev inside critical section - but this originally came from requirement
to not do anything special while there could be devices in
suspend-state. Now we are able to see differnce between critical section
with or without suspended devices. For udev synchronization only
suspended devices are prohibited to be there - so slightly relax
condition and allow calling and using 'fs_sync()' even inside critical
section - but there must not be any suspended device.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 13 +++++++++++++
lib/activate/fs.c | 3 ++-
3 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 18733b1..0f1fe1b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Add synchronization with udev before removing cached devices.
Add support for caching VDO LVs and VDOPOOL LVs.
Add support for vgsplit with cached devices.
Query mpath device only once per command for its state.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 09fca63..981f467 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -3716,6 +3716,19 @@ int dev_manager_activate(struct dev_manager *dm, const struct logical_volume *lv
if (!_tree_action(dm, lv, laopts, ACTIVATE))
return_0;
+ /*
+ * When lvm2 resumes a device and shortly after that it removes it,
+ * udevd rule will try to blindly call 'dmsetup info' on already removed
+ * device leaving the trace inside syslog about failing operation.
+ *
+ * TODO: It's not completely clear this call here is the best fix.
+ * Maybe there can be a better sequence, but ATM we do usually resume
+ * error device i.e. on cache deletion and remove it.
+ * TODO2: there could be more similar cases!
+ */
+ if (!dm_list_empty(&dm->pending_delete))
+ fs_unlock();
+
if (!_tree_action(dm, lv, laopts, CLEAN))
return_0;
diff --git a/lib/activate/fs.c b/lib/activate/fs.c
index 87bc724..b2c99fc 100644
--- a/lib/activate/fs.c
+++ b/lib/activate/fs.c
@@ -487,7 +487,8 @@ int fs_rename_lv(const struct logical_volume *lv, const char *dev,
void fs_unlock(void)
{
- if (!prioritized_section()) {
+ /* Do not allow syncing device name with suspended devices */
+ if (!dm_get_suspended_counter()) {
log_debug_activation("Syncing device names");
/* Wait for all processed udev devices */
if (!dm_udev_wait(_fs_cookie))