summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-06-03 09:56:48 -0500
committerDavid Teigland <teigland@redhat.com>2016-06-03 09:56:48 -0500
commitb321d2b1b9a3b6a1f8d67888a04c7318aa3148c2 (patch)
treea0a0217837ae1c267e893bc9c4311e107324fb85
parent68e097972462e3c7c208ac34c62e737b161dd3c4 (diff)
downloadlvm2-b321d2b1b9a3b6a1f8d67888a04c7318aa3148c2.tar.gz
pvmove: disallow tag args
pvmove began processing tags unintentionally from commit, 6d7dc87cb pvmove: use toollib pvmove works on a single PV, but tags can match multiple PVs. If we allowed tags, but processed only the first matching PV, then the resulting PV would be unpredictable. Also, the current processing code does not allow us to simply report an error and do nothing if more than one PV matches the tag, because the command starts processing PVs as they are found, so it's too late to do nothing if a second PV matches.
-rw-r--r--tools/commands.h4
-rw-r--r--tools/toollib.c5
-rw-r--r--tools/tools.h2
3 files changed, 10 insertions, 1 deletions
diff --git a/tools/commands.h b/tools/commands.h
index da432a708..888f3a279 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -874,9 +874,11 @@ xx(pvdisplay,
select_ARG, separator_ARG, shared_ARG, short_ARG, sort_ARG, unbuffered_ARG,
units_ARG)
+/* ALL_VGS_IS_DEFAULT is for polldaemon to find pvmoves in-progress using process_each_vg. */
+
xx(pvmove,
"Move extents from one physical volume to another",
- ALL_VGS_IS_DEFAULT, /* For polldaemon to find pvmoves in-progress using process_each_vg. */
+ ALL_VGS_IS_DEFAULT | DISALLOW_TAG_ARGS,
"pvmove\n"
"\t[--abort]\n"
"\t[--alloc AllocationPolicy]\n"
diff --git a/tools/toollib.c b/tools/toollib.c
index 0de6ee847..0563fea6c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3375,6 +3375,11 @@ int process_each_pv(struct cmd_context *cmd,
return ret;
}
+ if ((cmd->command->flags & DISALLOW_TAG_ARGS) && !dm_list_empty(&arg_tags)) {
+ log_error("Tags cannot be used with this command.");
+ return ECMD_FAILED;
+ }
+
orphans_locked = lvmcache_vgname_is_locked(VG_ORPHANS);
process_all_pvs = dm_list_empty(&arg_pvnames) && dm_list_empty(&arg_tags);
diff --git a/tools/tools.h b/tools/tools.h
index 2abc75032..8704749b1 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -114,6 +114,8 @@ struct arg_value_group_list {
#define NO_LVMETAD_AUTOSCAN 0x00000200
/* Command should process unused duplicate devices. */
#define ENABLE_DUPLICATE_DEVS 0x00000400
+/* Command does not accept tags as args. */
+#define DISALLOW_TAG_ARGS 0x00000800
/* a register of the lvm commands */
struct command {