Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7fa0d5226297a9ef57b8b…
Commit: 7fa0d5226297a9ef57b8bce986e7a17ce948beb3
Parent: 9f34125d5d6f0755af8b99ec9ca04495cf8d8df6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Sep 21 13:39:52 2017 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Sep 21 17:10:15 2017 +0200
blkdeactivate: fix blkdeactivate regression with failing DM/MD devs deactivation
Revert dc50f2f4a03dd50c5e2411a258095484555421e9.
We're canonicalizing/escaping the names here and we're reusing the
variable name so the code doesn't need to use extra variables and
further assignments that may confuse us. Let's keep the code simple.
The
local name=(...$name)
is not the same as
local name
name=(...$name)
(I know various code-checking tools fuss about this and recommend
the 2nd way, but let's ignore those tools' nitpicking here please.)
---
WHATS_NEW_DM | 1 +
scripts/blkdeactivate.sh.in | 8 ++------
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 2060ada..576e308 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.144 -
======================================
+ Fix blkdeactivate regression with failing DM/MD devs deactivation (1.02.142).
Fix typo in blkdeactivate's '--{dm,lvm,mpath}options' option name.
Correct return value testing when get reserved values for reporting.
Take -S with dmsetup suspend/resume/clear/wipe_table/remove/deps/status/table.
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index 61c7a86..a7606b5 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -205,9 +205,7 @@ deactivate_holders () {
}
deactivate_dm () {
- local name
-
- name=$(printf "%s" "$name")
+ local name=$(printf "%s" "$name")
test -b "$DEV_DIR/mapper/$name" || return 0
test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
@@ -276,9 +274,7 @@ deactivate_lvm () {
}
deactivate_md () {
- local name
-
- name=$(printf "%s" "$name")
+ local name=$(printf "%s" "$name")
test -b "$DEV_DIR/$name" || return 0
test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f2ee0e7aca6020cf273f2…
Commit: f2ee0e7aca6020cf273f22dc5bca20bfa3c89051
Parent: 518a8e8cfbb672c2bf5e3455f1fe7cd8d94eb5b0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 19 13:08:41 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Sep 20 09:56:51 2017 -0500
pvmove: require LV name in a shared VG
In a shared VG, only allow pvmove with a named LV,
so that only PE's used by the LV will be moved.
The LV is then activated exclusively, ensuring that
the PE's being moved are not used from another host.
Previously, pvmove was mistakenly allowed on a full PV.
This won't work when LVs using that PV are active on
other hosts.
---
WHATS_NEW | 1 +
lib/metadata/mirror.c | 2 +-
man/lvmlockd.8_main | 3 +++
tools/pvmove.c | 42 ++++++++++++++++++++++++------------------
4 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6d820bd..6b88fc4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.175 -
======================================
+ Require LV name with pvmove in a shared VG.
Allow shared active mirror LVs with lvmlockd, dlm, and cmirrord.
Support lvconvert --repair with cache and cachepool volumes.
lvconvert --repair respects --poolmetadataspare option.
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index e775495..238ce37 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -2145,7 +2145,7 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "dlm")) {
+ if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "dlm") && cmd->lockd_lv_sh) {
if (!cluster_mirror_is_available(cmd)) {
log_error("Shared cluster mirrors are not available.");
return 0;
diff --git a/man/lvmlockd.8_main b/man/lvmlockd.8_main
index 067c60d..b7eba1a 100644
--- a/man/lvmlockd.8_main
+++ b/man/lvmlockd.8_main
@@ -826,6 +826,9 @@ using external origins for thin LVs
splitting mirrors and snapshots from LVs
.br
\[bu]
+pvmove of entire PVs, or under LVs activated with shared locks
+.br
+\[bu]
vgsplit
.br
\[bu]
diff --git a/tools/pvmove.c b/tools/pvmove.c
index eef5cc1..750f08e 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -480,7 +480,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
* If the VG is clustered, we are unable to handle
* snapshots, origins, thin types, RAID or mirror
*/
- if (vg_is_clustered(vg) &&
+ if ((vg_is_clustered(vg) || is_lockd_type(vg->lock_type)) &&
(lv_is_origin(lv) || lv_is_cow(lv) ||
lv_is_thin_type(lv) || lv_is_raid_type(lv))) {
log_print_unless_silent("Skipping %s LV %s",
@@ -692,6 +692,7 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
struct dm_list *allocatable_pvs;
struct dm_list *lvs_changed;
struct logical_volume *lv_mirr;
+ struct logical_volume *lv = NULL;
const char *pv_name = pv_dev_name(pv);
unsigned flags = PVMOVE_FIRST_TIME;
unsigned exclusive;
@@ -712,27 +713,32 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
pp->setup_result = EINVALID_CMD_LINE;
return ECMD_FAILED;
}
+
+ if (!(lv = find_lv(vg, lv_name))) {
+ log_error("Failed to find LV with name %s", lv_name);
+ return ECMD_FAILED;
+ }
}
/*
- * We cannot move blocks from under the sanlock leases, so disallow
- * pvmoving any PVs used by the lvmlock LV.
+ * We would need to avoid any PEs used by LVs that are active (ex) on
+ * other hosts. For LVs that are active on multiple hosts (sh), we
+ * would need to used cluster mirrors.
*/
- if (vg->lock_type && !strcmp(vg->lock_type, "sanlock")) {
- struct lv_segment *lvseg;
- struct physical_volume *sanlock_pv;
- unsigned s;
-
- dm_list_iterate_items(lvseg, &vg->sanlock_lv->segments) {
- for (s = 0; s < lvseg->area_count; s++) {
- if (seg_type(lvseg, s) == AREA_PV) {
- sanlock_pv = seg_pv(lvseg, s);
- if (sanlock_pv->dev == pv->dev) {
- log_error("Cannot pvmove device %s used for sanlock leases.", pv_name);
- return ECMD_FAILED;
- }
- }
- }
+ if (is_lockd_type(vg->lock_type)) {
+ if (!lv) {
+ log_error("pvmove in a shared VG requires a named LV.");
+ return ECMD_FAILED;
+ }
+
+ if (lv_is_lockd_sanlock_lv(lv)) {
+ log_error("pvmove not allowed on internal sanlock LV.");
+ return ECMD_FAILED;
+ }
+
+ if (!lockd_lv(cmd, lv, "ex", LDLV_PERSISTENT)) {
+ log_error("pvmove in a shared VG requires exclusive lock on named LV.");
+ return ECMD_FAILED;
}
}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=518a8e8cfbb672c2bf5e3…
Commit: 518a8e8cfbb672c2bf5e3455f1fe7cd8d94eb5b0
Parent: d9f9ce126856245541a66492f35422ab060a837e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 19 11:52:36 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Sep 20 09:55:34 2017 -0500
lvmlockd: activate mirror LVs in shared mode with cmirrord
Previously lvmlockd disallowed mirror LVs to be activated
in shared mode.
---
WHATS_NEW | 1 +
lib/commands/toolcontext.h | 1 +
lib/locking/lvmlockd.c | 38 +++++++++++++++++++++++++++++++++++++-
lib/metadata/mirror.c | 12 ++++++++++++
lib/mirror/mirrored.c | 9 +++++++++
man/lvmlockd.8_main | 6 ++++--
6 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7927673..6d820bd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.175 -
======================================
+ Allow shared active mirror LVs with lvmlockd, dlm, and cmirrord.
Support lvconvert --repair with cache and cachepool volumes.
lvconvert --repair respects --poolmetadataspare option.
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 20b24f9..bf2b251 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -160,6 +160,7 @@ struct cmd_context {
unsigned lockd_vg_rescan:1;
unsigned lockd_vg_default_sh:1;
unsigned lockd_vg_enforce_sh:1;
+ unsigned lockd_lv_sh:1;
unsigned vg_notify:1;
unsigned lv_notify:1;
unsigned pv_notify:1;
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 058d4b5..0f2b160 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2042,6 +2042,15 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
+ /*
+ * This is a hack for mirror LVs which need to know at a very low level
+ * which lock mode the LV is being activated with so that it can pick
+ * a mirror log type during activation. Do not use this for anything
+ * else.
+ */
+ if (mode && !strcmp(mode, "sh"))
+ cmd->lockd_lv_sh = 1;
+
if (!mode)
mode = "ex";
@@ -2160,6 +2169,31 @@ static int _lockd_lv_thin(struct cmd_context *cmd, struct logical_volume *lv,
}
/*
+ * Only the combination of dlm + corosync + cmirrord allows
+ * mirror LVs to be activated in shared mode on multiple nodes.
+ */
+static int _lockd_lv_mirror(struct cmd_context *cmd, struct logical_volume *lv,
+ const char *def_mode, uint32_t flags)
+{
+ if (!strcmp(lv->vg->lock_type, "sanlock"))
+ flags |= LDLV_MODE_NO_SH;
+
+ else if (!strcmp(lv->vg->lock_type, "dlm") && def_mode && !strcmp(def_mode, "sh")) {
+#ifdef CMIRRORD_PIDFILE
+ if (!cmirrord_is_running()) {
+ log_error("cmirrord must be running to activate an LV in shared mode.");
+ return 0;
+ }
+#else
+ flags |= LDLV_MODE_NO_SH;
+#endif
+ }
+
+ return lockd_lv_name(cmd, lv->vg, lv->name, &lv->lvid.id[1],
+ lv->lock_args, def_mode, flags);
+}
+
+/*
* If the VG has no lock_type, then this function can return immediately.
* The LV itself may have no lock (NULL lv->lock_args), but the lock request
* may be directed to another lock, e.g. the pool LV lock in _lockd_lv_thin.
@@ -2212,12 +2246,14 @@ int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv,
*/
if (lv_is_external_origin(lv) ||
lv_is_thin_type(lv) ||
- lv_is_mirror_type(lv) ||
lv_is_raid_type(lv) ||
lv_is_cache_type(lv)) {
flags |= LDLV_MODE_NO_SH;
}
+ if (lv_is_mirror_type(lv))
+ return _lockd_lv_mirror(cmd, lv, def_mode, flags);
+
return lockd_lv_name(cmd, lv->vg, lv->name, &lv->lvid.id[1],
lv->lock_args, def_mode, flags);
}
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 7496ddc..e775495 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -2145,6 +2145,18 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
}
}
+ if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "dlm")) {
+ if (!cluster_mirror_is_available(cmd)) {
+ log_error("Shared cluster mirrors are not available.");
+ return 0;
+ }
+
+ if (log_count > 1) {
+ log_error("Log type, \"mirrored\", is unavailable to cluster mirrors.");
+ return 0;
+ }
+ }
+
/* For corelog mirror, activation code depends on
* the global mirror_in_sync status. As we are adding
* a new mirror, it should be set as 'out-of-sync'
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index f4c1567..4891fb7 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -285,6 +285,15 @@ static int _add_log(struct dm_pool *mem, struct lv_segment *seg,
if (!laopts->exclusive && vg_is_clustered(seg->lv->vg))
clustered = 1;
+ else if (seg->lv->vg->lock_type && !strcmp(seg->lv->vg->lock_type, "dlm")) {
+ /*
+ * If shared lock was used due to -asy, then we set clustered
+ * to use a clustered mirror log with cmirrod.
+ */
+ if (seg->lv->vg->cmd->lockd_lv_sh)
+ clustered = 1;
+ }
+
if (seg->log_lv) {
/* If disk log, use its UUID */
if (!(log_dlid = build_dm_uuid(mem, seg->log_lv, NULL))) {
diff --git a/man/lvmlockd.8_main b/man/lvmlockd.8_main
index 1dbdaf9..067c60d 100644
--- a/man/lvmlockd.8_main
+++ b/man/lvmlockd.8_main
@@ -601,9 +601,11 @@ report an error and fail.
The shared mode is intended for a multi-host/cluster application or
file system.
LV types that cannot be used concurrently
-from multiple hosts include thin, cache, raid, mirror, and snapshot.
+from multiple hosts include thin, cache, raid, and snapshot.
lvextend on LV with shared locks is not yet allowed. The LV must be
-deactivated, or activated exclusively to run lvextend.
+deactivated, or activated exclusively to run lvextend. (LVs with
+the mirror type can be activated in shared mode from multiple hosts
+when using the dlm lock type and cmirrord.)
.IP \fBn\fP
The command deactivates the LV. After deactivating the LV, the command
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2fd2b197ab5962bc0a1e7…
Commit: 2fd2b197ab5962bc0a1e7eb25bba120d7501032f
Parent: a02db1c45ab571d0c614d269a713b56cd47c2e1e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 11 14:33:07 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 20 15:14:16 2017 +0200
tests: check for free space in test dir
Avoid starting test, when test dir has less then 50M of free space.
Better to crash early before letting die machine on weird crash
in OOM cases...
Also show free disk space when test starts
---
test/lib/inittest.sh | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index d5ca6fd..7b0bc13 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -124,11 +124,17 @@ fi
echo "$TESTNAME" >TESTNAME
+# Require 50M of free space in testdir
+test $(df -k . | awk '/\// {print $4}') -gt 51200 ||
+ die "Testing requires more then 50M of free space in directory $TESTDIR!\n$(df -H)"
+
echo "Kernel is $(uname -a)"
# Report SELinux mode
echo "Selinux mode is $(getenforce 2>/dev/null || echo not installed)."
free -m || true
+df -h || true
+
# Set vars from utils now that we have TESTDIR/PREFIX/...
prepare_test_vars