summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-01-12 11:51:12 -0600
committerDavid Teigland <teigland@redhat.com>2016-01-12 11:53:33 -0600
commit0c6946b4ce2fc664a66cd68a4fb2324bfb69b5ab (patch)
tree34f67916da567a177b81d181efd0ed1db72c6241
parent176b4aaebeb8b885d5df16172a5bc32481beda59 (diff)
downloadlvm2-0c6946b4ce2fc664a66cd68a4fb2324bfb69b5ab.tar.gz
pvmove: disallow moving PVs under sanlock leases
Fail with an error message if pvmove tries to move PVs under the lvmlock LV.
-rw-r--r--tools/pvmove.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/pvmove.c b/tools/pvmove.c
index a7943faab..d3eb1ab5f 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -643,6 +643,28 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
goto out_ret;
}
+ /*
+ * We cannot move blocks from under the sanlock leases, so disallow
+ * pvmoving any PVs used by the lvmlock LV.
+ */
+ 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_dev_name(pv));
+ goto out;
+ }
+ }
+ }
+ }
+ }
+
exclusive = _pvmove_is_exclusive(cmd, vg);
if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
@@ -894,6 +916,12 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
+ /*
+ * FIXME: use process_each_pv() where the "single" function
+ * depends on the abort arg. The single functions would not
+ * need to use find_pv_by_name() (which includes a hidden
+ * equivalent of process_each_pv), or vg_read().
+ */
if (!arg_count(cmd, abort_ARG)) {
if ((ret = _set_up_pvmove(cmd, pv_name, argc, argv, lvid, &vg_name, &lv_name)) != ECMD_PROCESSED) {
stack;