stable-2.02 - pvscan: lvmetad init should set updating before scanning
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dcf8f3111aea1179be1...
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);
5 years
master - tests: vdo caching tests
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7f757ab6166074dd328...
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
5 years
master - tests: vdo dmevent autoresize
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5139e5f1b3b26ae89a6...
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
5 years
master - man: dmeventd vdo plugin
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1117f1d46f9cbc4a0a2...
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
.
5 years
master - man: basic vdo stacking support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=597113646d10e14044e...
Commit: 597113646d10e14044e0b89712342ae73b77b697
Parent: 4411fe2ba855b9c42b5d1393fc08faf01b1d2636
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 24 14:57:36 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:39:11 2019 +0100
man: basic vdo stacking support
Document some basic lvconvert stacking posibilities.
---
man/lvconvert.8_pregen | 8 ++++----
man/lvmvdo.7_main | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/man/lvconvert.8_pregen b/man/lvconvert.8_pregen
index 26bcf5f..842be37 100644
--- a/man/lvconvert.8_pregen
+++ b/man/lvconvert.8_pregen
@@ -570,7 +570,7 @@ Convert LV to a thin LV, using the original LV as an external origin.
Attach a cache to an LV, converts the LV to type cache.
.br
.P
-\fBlvconvert\fP \fB--type\fP \fBcache\fP \fB--cachepool\fP \fILV\fP \fILV\fP\fI_linear_striped_thinpool_raid\fP
+\fBlvconvert\fP \fB--type\fP \fBcache\fP \fB--cachepool\fP \fILV\fP \fILV\fP\fI_linear_striped_thinpool_vdo_vdopool_vdopooldata_raid\fP
.br
.RS 4
.ad l
@@ -783,7 +783,7 @@ Convert LV to type vdopool.
Detach a cache from an LV.
.br
.P
-\fBlvconvert\fP \fB--splitcache\fP \fILV\fP\fI_thinpool_cache_cachepool_writecache\fP
+\fBlvconvert\fP \fB--splitcache\fP \fILV\fP\fI_thinpool_cache_cachepool_vdopool_writecache\fP
.br
.RS 4
[ COMMON_OPTIONS ]
@@ -1692,7 +1692,7 @@ Convert LV to a thin LV, using the original LV as an external origin
Attach a cache to an LV (infers --type cache).
.br
.P
-\fBlvconvert\fP \fB-H\fP|\fB--cache\fP \fB--cachepool\fP \fILV\fP \fILV\fP\fI_linear_striped_thinpool_raid\fP
+\fBlvconvert\fP \fB-H\fP|\fB--cache\fP \fB--cachepool\fP \fILV\fP \fILV\fP\fI_linear_striped_thinpool_vdo_vdopool_vdopooldata_raid\fP
.br
.RS 4
.ad l
@@ -1782,7 +1782,7 @@ Convert LV to type vdopool.
Detach and delete a cache from an LV.
.br
.P
-\fBlvconvert\fP \fB--uncache\fP \fILV\fP\fI_thinpool_cache_writecache\fP
+\fBlvconvert\fP \fB--uncache\fP \fILV\fP\fI_thinpool_cache_vdopool_writecache\fP
.br
.RS 4
[ COMMON_OPTIONS ]
diff --git a/man/lvmvdo.7_main b/man/lvmvdo.7_main
index 2572b46..d42c1bd 100644
--- a/man/lvmvdo.7_main
+++ b/man/lvmvdo.7_main
@@ -276,6 +276,48 @@ be activated. User has to deactivate VDODataLV first to continue to use VDOPoolL
.SH VDO Topics
+
+.SS 1. Stacking VDO
+
+User can convert/stack VDO with existing volumes.
+
+.SS 2. VDO on top of raid
+
+Using Raid type LV for VDO Data LV.
+
+.I Example
+.br
+.nf
+# lvcreate --type raid1 -L 5G -n vpool vg
+# lvconvert --type vdo-pool -V 10G vg/vpool
+.fi
+
+.SS 3. Caching VDODataLV, VDOPoolLV
+
+Cache VDO Data LV (accepts also VDOPoolLV.
+
+.I Example
+.br
+.nf
+# lvcreate -L 5G -V 10G -n vdo1 vg/vpool
+# lvcreate --type cache-pool -L 1G -n cpool vg
+# lvconvert --cache --cachepool vg/cpool vg/vpool
+# lvconvert --uncache vg/vpool
+.fi
+
+.SS 3. Caching VDOLV
+
+Cache VDO LV.
+
+.I Example
+.br
+.nf
+# lvcreate -L 5G -V 10G -n vdo1 vg/vpool
+# lvcreate --type cache-pool -L 1G -n cpool vg
+# lvconvert --cache --cachepool vg/cpool vg/vdo1
+# lvconvert --uncache vg/vdo1
+.fi
+
.br
\&
5 years
master - activation: synchronize before removing devices
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4411fe2ba855b9c42b5...
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))
5 years
master - vdo: enable caching for vdopool LV and vdo LV
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=677aa84be3b41e94514...
Commit: 677aa84be3b41e94514aa5c1560e987e7763b294
Parent: 0db22c5f81986d9573e0a704397a6de779fb832e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 24 14:12:26 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:38:31 2019 +0100
vdo: enable caching for vdopool LV and vdo LV
Allow using caching with VDO.
User can either cache a single vdopool or
a vdo LV - difference when the caching is put-in depends on a use-case
and it's upto user to decide which kind of speed is expected.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 9 ++++++---
lib/metadata/lv_manip.c | 4 ++--
tools/command-lines.in | 8 ++++----
tools/lvchange.c | 3 +++
tools/lvconvert.c | 6 ++++++
6 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5ffef3b..18733b1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ 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.
Use device INFO instead of STATUS when checking for mpath device uuid.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 20deda3..7ea2c0e 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -369,7 +369,9 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
}
/* For now we only support conversion of thin pool data volume */
- if (!lv_is_visible(origin_lv) && !lv_is_thin_pool_data(origin_lv)) {
+ if (!lv_is_visible(origin_lv) &&
+ !lv_is_thin_pool_data(origin_lv) &&
+ !lv_is_vdo_pool_data(origin_lv)) {
log_error("Can't convert internal LV %s.", display_lvname(origin_lv));
return 0;
}
@@ -383,7 +385,8 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
lv_is_thin_volume(origin_lv) || lv_is_thin_pool_metadata(origin_lv) ||
lv_is_merging_origin(origin_lv) ||
lv_is_cow(origin_lv) || lv_is_merging_cow(origin_lv) ||
- lv_is_virtual(origin_lv)) {
+ /* TODO: think about enabling caching of a single thin volume */
+ (lv_is_virtual(origin_lv) && !lv_is_vdo(origin_lv))) {
log_error("Cache is not supported with %s segment type of the original logical volume %s.",
lvseg_name(first_seg(origin_lv)), display_lvname(origin_lv));
return 0;
@@ -438,7 +441,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
!validate_lv_cache_create_origin(cache_lv))
return_NULL;
- if (lv_is_thin_pool(cache_lv))
+ if (lv_is_thin_pool(cache_lv) || lv_is_vdo_pool(cache_lv))
cache_lv = seg_lv(first_seg(cache_lv), 0); /* cache _tdata */
if (!(segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_CACHE)))
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a2f7d74..e128336 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6828,7 +6828,7 @@ int move_lv_segments(struct logical_volume *lv_to,
struct logical_volume *lv_from,
uint64_t set_status, uint64_t reset_status)
{
- const uint64_t MOVE_BITS = (RAID | MIRROR | THIN_VOLUME);
+ const uint64_t MOVE_BITS = (RAID | MIRROR | THIN_VOLUME | CACHE | LV_VDO);
struct lv_segment *seg;
dm_list_iterate_items(seg, &lv_to->segments)
@@ -6869,7 +6869,7 @@ int move_lv_segments(struct logical_volume *lv_to,
int remove_layer_from_lv(struct logical_volume *lv,
struct logical_volume *layer_lv)
{
- static const char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
+ static const char _suffixes[][8] = { "_tdata", "_cdata", "_corig", "_vdata" };
struct logical_volume *parent_lv;
struct lv_segment *parent_seg;
struct segment_type *segtype;
diff --git a/tools/command-lines.in b/tools/command-lines.in
index bf9d7df..0de3de7 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -451,7 +451,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long
---
-lvconvert --type cache --cachepool LV LV_linear_striped_raid_thinpool
+lvconvert --type cache --cachepool LV LV_linear_striped_raid_thinpool_vdo_vdopool_vdopooldata
OO: --cache, OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_cache_with_cachepool
DESC: Attach a cache pool to an LV, converts the LV to type cache.
@@ -459,7 +459,7 @@ RULE: all and lv_is_visible
RULE: --poolmetadata not --readahead --stripesize --stripes_long
# alternate form of lvconvert --type cache
-lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool
+lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool_vdo_vdopool_vdopooldata
OO: --type cache, OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_cache_with_cachepool
DESC: Attach a cache pool to an LV (infers --type cache).
@@ -589,14 +589,14 @@ FLAGS: SECONDARY_SYNTAX
---
-lvconvert --splitcache LV_cachepool_cache_thinpool_writecache
+lvconvert --splitcache LV_cachepool_cache_thinpool_vdopool_writecache
OO: OO_LVCONVERT
ID: lvconvert_split_and_keep_cache
DESC: Detach a cache from an LV.
---
-lvconvert --uncache LV_cache_thinpool_writecache
+lvconvert --uncache LV_cache_thinpool_vdopool_writecache
OO: OO_LVCONVERT
ID: lvconvert_split_and_remove_cache
DESC: Detach and delete a cache from an LV.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index a40bfcf..ad5abdd 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1281,6 +1281,9 @@ static int _lvchange_properties_check(struct cmd_context *cmd,
if (lv_is_thin_pool_data(lv))
return 1;
+ if (lv_is_vdo_pool_data(lv))
+ return 1;
+
if (lv_is_named_arg)
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
return 0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index cd640ab..24db8d2 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4261,6 +4261,9 @@ static int _lvconvert_cachepool_attach_single(struct cmd_context *cmd,
if (lv_is_thin_pool(lv)) {
lv = seg_lv(first_seg(lv), 0);
log_verbose("Redirecting operation to data sub LV %s.", display_lvname(lv));
+ } else if (lv_is_vdo_pool(lv)) {
+ lv = seg_lv(first_seg(lv), 0);
+ log_verbose("Redirecting operation to data sub LV %s.", display_lvname(lv));
}
if (_raid_split_image_conversion(lv))
@@ -4570,6 +4573,9 @@ static int _lvconvert_split_cache_vol(struct cmd_context *cmd,
} else if (lv_is_thin_pool(lv)) {
lv_main = seg_lv(first_seg(lv), 0); /* cached _tdata */
lv_fast = first_seg(lv_main)->pool_lv;
+ } else if (lv_is_vdo_pool(lv)) {
+ lv_main = seg_lv(first_seg(lv), 0); /* cached _vdata */
+ lv_fast = first_seg(lv_main)->pool_lv;
}
if (!lv_main) {
5 years
master - lv_manip: insert remove layer skips pools
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0db22c5f81986d9573e...
Commit: 0db22c5f81986d9573e0a704397a6de779fb832e
Parent: ac31bfd6fd57a4ee281ef0c17448aae2b22eb300
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 24 14:14:31 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:38:05 2019 +0100
lv_manip: insert remove layer skips pools
Fixing renaming of subLVs when removing and inserting layers - this
got visible when using stacked VDO pools.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6360241..a2f7d74 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6954,7 +6954,7 @@ int remove_layer_from_lv(struct logical_volume *lv,
if (strstr(layer_lv->name, _suffixes[r]) == 0) {
lv_names.old = layer_lv->name;
lv_names.new = parent_lv->name;
- if (!for_each_sub_lv(parent_lv, _rename_cb, (void *) &lv_names))
+ if (!for_each_sub_lv(parent_lv, _rename_skip_pools_externals_cb, (void *) &lv_names))
return_0;
break;
}
@@ -7072,7 +7072,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
if (strcmp(layer_suffix, _suffixes[i]) == 0) {
lv_names.old = lv_where->name;
lv_names.new = layer_lv->name;
- if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
+ if (!for_each_sub_lv(layer_lv, _rename_skip_pools_externals_cb, (void *) &lv_names))
return_NULL;
break;
}
5 years
master - tests: check vgsplit works with cache
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac31bfd6fd57a4ee281...
Commit: ac31bfd6fd57a4ee281ef0c17448aae2b22eb300
Parent: 030c39073e69d51da7cdbabb78c2c544ed85f1ef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 1 23:45:12 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:38:05 2019 +0100
tests: check vgsplit works with cache
---
test/shell/vgsplit-cache.sh | 71 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/test/shell/vgsplit-cache.sh b/test/shell/vgsplit-cache.sh
new file mode 100644
index 0000000..3bbcc2d
--- /dev/null
+++ b/test/shell/vgsplit-cache.sh
@@ -0,0 +1,71 @@
+#!/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
+
+# Test vgsplit command options with cached volumes
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 3 0 || skip
+
+aux prepare_vg 7
+
+lvcreate -L5 -n $lv2 $vg "$dev2"
+lvcreate -L5 -n $lv3 $vg "$dev3"
+lvconvert -y --type cache-pool --poolmetadata $vg/$lv2 $vg/$lv3
+
+# Cannot split data and metadata from cache-pool
+fail vgsplit $vg $vg1 "$dev2" 2>&1 | tee err
+grep "Cannot split cache pool data" err
+
+fail vgsplit $vg $vg1 "$dev3" 2>&1 | tee err
+grep "Cannot split cache pool data" err
+
+# Cache $lv1
+lvcreate -L1 -n $lv1 $vg "$dev1"
+lvconvert -y --cache --cachepool $vg/$lv3 $vg/$lv1
+
+
+
+# Cannot move active cache
+fail vgsplit $vg $vg1 "$dev1" "$dev2" "$dev3" 2>&1 | tee err
+grep "must be inactive" err
+
+vgchange -an $vg
+
+
+# Try spliting component into separe VG
+fail vgsplit $vg $vg1 "$dev1" 2>&1 | tee err
+grep "Cannot split cache origin" err
+
+fail vgsplit $vg $vg1 "$dev2" 2>&1 | tee err
+grep "Cannot split cache origin" err
+
+fail vgsplit $vg $vg1 "$dev3" 2>&1 | tee err
+grep "Cannot split cache origin" err
+
+fail vgsplit $vg $vg1 "$dev1" "$dev2" 2>&1 | tee err
+grep "Cannot split cache origin" err
+
+fail vgsplit $vg $vg1 "$dev2" "$dev3" 2>&1 | tee err
+
+# Finaly something that should pass
+vgsplit $vg $vg1 "$dev1" "$dev2" "$dev3"
+
+vgs $vg $vg1
+
+test 4 -eq "$(get vg_field $vg pv_count)"
+test 3 -eq "$(get vg_field $vg1 pv_count)"
+
+vgremove -ff $vg $vg1
5 years
master - cache: support vgsplit
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=030c39073e69d51da7c...
Commit: 030c39073e69d51da7cdbabb78c2c544ed85f1ef
Parent: 1cc690e911f3caa1252cac6e19488345a0a1a4bc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 1 21:29:22 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 20 14:38:02 2019 +0100
cache: support vgsplit
Enable vgsplit to work with VG containing cached LVs.
---
WHATS_NEW | 1 +
tools/vgsplit.c | 85 ++++++++++++++++++++++++-------------------------------
2 files changed, 38 insertions(+), 48 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ad92827..5ffef3b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Add support for vgsplit with cached devices.
Query mpath device only once per command for its state.
Use device INFO instead of STATUS when checking for mpath device uuid.
Change default io_memory_size from 4 to 8 MiB.
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 7150570..e931a5c 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2009,2016 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2019 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -384,71 +384,60 @@ static int _move_cache(struct volume_group *vg_from,
dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = dm_list_item(lvh, struct lv_list)->lv;
- data = meta = orig = NULL;
seg = first_seg(lv);
if (!lv_is_cache(lv) && !lv_is_cache_pool(lv))
continue;
- /*
- * FIXME: The code seems to move cache LVs fine, but it
- * hasn't been well tested and it causes problems
- * when just splitting PVs that don't contain
- * cache LVs.
- * Waiting for next release before fixing and enabling.
- */
- log_error("Unable to split VG while it contains cache LVs");
- return 0;
-
- /* NOTREACHED */
-
if (lv_is_cache(lv) && lv_is_cache_vol(seg->pool_lv)) {
log_error("Cannot split while LV %s has cache attached.", display_lvname(lv));
return 0;
- } else if (lv_is_cache(lv)) {
- orig = seg_lv(seg, 0);
- data = seg_lv(first_seg(seg->pool_lv), 0);
- meta = first_seg(seg->pool_lv)->metadata_lv;
- /* Ensure all components are coming along */
- is_moving = _lv_is_in_vg(vg_to, orig);
- } else {
- if (!dm_list_empty(&seg->lv->segs_using_this_lv) &&
- !(cache_seg = get_only_segment_using_this_lv(seg->lv)))
- return_0;
- orig = seg_lv(cache_seg, 0);
- data = seg_lv(seg, 0);
- meta = seg->metadata_lv;
+ }
- if (_lv_is_in_vg(vg_to, data) ||
- _lv_is_in_vg(vg_to, meta))
- is_moving = 1;
+ if (lv_is_cache(lv)) {
+ orig = seg_lv(seg, 0);
+ seg = first_seg(seg->pool_lv);
+ } else { /* lv_is_cache_pool */
+ orig = NULL;
+ if (!dm_list_empty(&seg->lv->segs_using_this_lv)) {
+ if (!(cache_seg = get_only_segment_using_this_lv(seg->lv)))
+ return_0;
+ orig = seg_lv(cache_seg, 0);
+ }
}
- if (!lv_is_on_pvs(data, &vg_to->pvs))
- continue;
+ data = seg_lv(seg, 0);
+ meta = seg->metadata_lv;
- if (!lv_is_on_pvs(meta, &vg_to->pvs))
+ if ((orig && !lv_is_on_pvs(orig, &vg_to->pvs)) &&
+ !lv_is_on_pvs(data, &vg_to->pvs) &&
+ !lv_is_on_pvs(meta, &vg_to->pvs))
continue;
- if (orig && (_lv_is_in_vg(vg_to, orig) != is_moving)) {
- log_error("Can't split %s and its origin (%s)"
- " into separate VGs", lv->name, orig->name);
- return 0;
- }
+ /* Ensure all components are coming along */
+ if (orig) {
+ is_moving = _lv_is_in_vg(vg_to, orig);
- if (data && (_lv_is_in_vg(vg_to, data) != is_moving)) {
- log_error("Can't split %s and its cache pool"
- " data LV (%s) into separate VGs",
- lv->name, data->name);
- return 0;
- }
+ if (_lv_is_in_vg(vg_to, data) != is_moving) {
+ log_error("Cannot split cache origin %s and its cache pool data %s "
+ "into separate VGs.",
+ display_lvname(orig), display_lvname(data));
+ return 0;
+ }
- if (meta && (_lv_is_in_vg(vg_to, meta) != is_moving)) {
- log_error("Can't split %s and its cache pool"
- " metadata LV (%s) into separate VGs",
- lv->name, meta->name);
+ if (_lv_is_in_vg(vg_to, meta) != is_moving) {
+ log_error("Cannot split cache origin %s and its cache pool metadata %s "
+ "into separate VGs.",
+ display_lvname(orig), display_lvname(meta));
+ return 0;
+ }
+ } else if (_lv_is_in_vg(vg_to, data) != _lv_is_in_vg(vg_to, meta)) {
+ log_error("Cannot split cache pool data %s and its metadata %s "
+ "into separate VGs.",
+ display_lvname(data), display_lvname(meta));
return 0;
}
+
if (!_move_one_lv(vg_from, vg_to, lvh, &lvht))
return_0;
}
5 years