diff options
author | David Teigland <teigland@redhat.com> | 2015-06-16 15:02:42 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2015-06-17 13:31:45 -0500 |
commit | 42a804510a1838a2496161ab7b6517aa0dff1219 (patch) | |
tree | b0dfa17e78af5ee63e96539d02107c718eb70512 | |
parent | d55163331e7489d670f032cc3f8053f8213499d0 (diff) | |
download | lvm2-42a804510a1838a2496161ab7b6517aa0dff1219.tar.gz |
Move lockd_gl calls for getting current VG list
When shared lockd_gl() is needed for reading a current
VG list, call it just before get_vgnameids() in process_each.
-rw-r--r-- | tools/lvchange.c | 7 | ||||
-rw-r--r-- | tools/lvmcmdline.c | 14 | ||||
-rw-r--r-- | tools/lvscan.c | 4 | ||||
-rw-r--r-- | tools/pvchange.c | 4 | ||||
-rw-r--r-- | tools/pvdisplay.c | 4 | ||||
-rw-r--r-- | tools/pvresize.c | 4 | ||||
-rw-r--r-- | tools/reporter.c | 7 | ||||
-rw-r--r-- | tools/toollib.c | 25 | ||||
-rw-r--r-- | tools/tools.h | 2 | ||||
-rw-r--r-- | tools/vgchange.c | 5 | ||||
-rw-r--r-- | tools/vgscan.c | 4 |
11 files changed, 21 insertions, 59 deletions
diff --git a/tools/lvchange.c b/tools/lvchange.c index 75925d307..05805b7be 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -1284,13 +1284,6 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv) if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG)) cmd->lockd_vg_default_sh = 1; - /* - * Needed for a current listing of the global VG namespace. - * (All VGs must be searched and read to match tags.) - */ - if (arg_tag_count(argc, argv) && !lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - return process_each_lv(cmd, argc, argv, update ? READ_FOR_UPDATE : 0, NULL, &_lvchange_single); diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 035fe5820..810183012 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -579,20 +579,6 @@ int string_arg(struct cmd_context *cmd __attribute__((unused)), return 1; } -int arg_tag_count(int argc, char **argv) -{ - const char *name; - int count = 0; - int i; - - for (i = 0; i < argc; i++) { - name = argv[i]; - if (*name == '@') - count++; - } - return count; -} - int tag_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { char *pos = av->value; diff --git a/tools/lvscan.c b/tools/lvscan.c index 389d960d1..e98c73d00 100644 --- a/tools/lvscan.c +++ b/tools/lvscan.c @@ -98,10 +98,6 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - /* Needed for a current listing of the global VG namespace. */ - if (!lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - return process_each_lv(cmd, argc, argv, 0, NULL, &lvscan_single); } diff --git a/tools/pvchange.c b/tools/pvchange.c index 19f993690..91e93c1e7 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -199,10 +199,6 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) goto out; } - /* Needed for a current listing of the global VG namespace. */ - if (!lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - if (!argc) { /* * Take the global lock here so the lvmcache remains diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c index abcf5dd60..2763889a9 100644 --- a/tools/pvdisplay.c +++ b/tools/pvdisplay.c @@ -107,10 +107,6 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv) } } - /* Needed for a current listing of the global VG namespace. */ - if (!lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - ret = process_each_pv(cmd, argc, argv, NULL, 0, NULL, _pvdisplay_single); diff --git a/tools/pvresize.c b/tools/pvresize.c index 375c9a631..0b055e6ef 100644 --- a/tools/pvresize.c +++ b/tools/pvresize.c @@ -84,10 +84,6 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv) handle->custom_handle = ¶ms; - /* Needed for a current listing of the global VG namespace. */ - if (!lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, handle, _pvresize_single); diff --git a/tools/reporter.c b/tools/reporter.c index 4437675b2..eb6a4ed4e 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -629,13 +629,6 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, /* Check PV specifics and do extra changes/actions if needed. */ _check_pv_list(cmd, argc, argv, &report_type, &args_are_pvs); - /* - * Needed for a current listing of the global VG namespace. - * (And all VGs must be searched and read to match tags.) - */ - if ((!argc || arg_tag_count(argc, argv)) && !lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - switch (report_type) { case DEVTYPES: keys = find_config_tree_str(cmd, report_devtypes_sort_CFG, NULL); diff --git a/tools/toollib.c b/tools/toollib.c index 39c6be380..442995e60 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1990,9 +1990,14 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, * any tags were supplied and need resolving; or * no VG names were given and the command defaults to processing all VGs. */ - if (((dm_list_empty(&arg_vgnames) && enable_all_vgs) || !dm_list_empty(&arg_tags)) && - !get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) - goto_out; + if ((dm_list_empty(&arg_vgnames) && enable_all_vgs) || !dm_list_empty(&arg_tags)) { + /* Needed for a current listing of the global VG namespace. */ + if (!lockd_gl(cmd, "sh", 0)) + goto_out; + + if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) + goto_out; + } if (dm_list_empty(&arg_vgnames) && dm_list_empty(&vgnameids_on_system)) { /* FIXME Should be log_print, but suppressed for reporting cmds */ @@ -2433,8 +2438,14 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, uint32_t fla else if (dm_list_empty(&arg_vgnames) && handle->internal_report_for_select) need_vgnameids = 1; - if (need_vgnameids && !get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) - goto_out; + if (need_vgnameids) { + /* Needed for a current listing of the global VG namespace. */ + if (!lockd_gl(cmd, "sh", 0)) + goto_out; + + if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) + goto_out; + } if (dm_list_empty(&arg_vgnames) && dm_list_empty(&vgnameids_on_system)) { /* FIXME Should be log_print, but suppressed for reporting cmds */ @@ -2923,6 +2934,10 @@ int process_each_pv(struct cmd_context *cmd, process_all_devices = process_all_pvs && (cmd->command->flags & ENABLE_ALL_DEVS) && arg_count(cmd, all_ARG); + /* Needed for a current listing of the global VG namespace. */ + if (!only_this_vgname && !lockd_gl(cmd, "sh", 0)) + return_ECMD_FAILED; + /* * Need pvid's set on all PVs before processing so that pvid's * can be compared to find duplicates while processing. diff --git a/tools/tools.h b/tools/tools.h index 66bdbb07d..943a9ddbb 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -177,8 +177,6 @@ unsigned grouped_arg_is_set(const struct arg_values *av, int a); const char *grouped_arg_str_value(const struct arg_values *av, int a, const char *def); int32_t grouped_arg_int_value(const struct arg_values *av, int a, const int32_t def); -int arg_tag_count(int argc, char **argv); - const char *command_name(struct cmd_context *cmd); int pvmove_poll(struct cmd_context *cmd, const char *pv_name, const char *uuid, diff --git a/tools/vgchange.c b/tools/vgchange.c index d739ed2a0..4e2be3452 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -1038,11 +1038,8 @@ static int lockd_vgchange(struct cmd_context *cmd, int argc, char **argv) if (arg_is_set(cmd, systemid_ARG) || arg_is_set(cmd, locktype_ARG)) cmd->command->flags &= ~ALL_VGS_IS_DEFAULT; - if (!argc || arg_tag_count(argc, argv) || arg_is_set(cmd, lockstart_ARG)) { + if (arg_is_set(cmd, lockstart_ARG)) { /* - * Needed for a current listing of the global VG namespace. - * (And all VGs must be searched and read to match tags.) - * * The lockstart condition takes the global lock to serialize * with any other host that tries to remove the VG while this * tries to start it. diff --git a/tools/vgscan.c b/tools/vgscan.c index b9e2f0f78..7328a096d 100644 --- a/tools/vgscan.c +++ b/tools/vgscan.c @@ -42,10 +42,6 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv) return ECMD_FAILED; } - /* Needed for a current listing of the global VG namespace. */ - if (!lockd_gl(cmd, "sh", 0)) - return_ECMD_FAILED; - if (cmd->filter->wipe) cmd->filter->wipe(cmd->filter); lvmcache_destroy(cmd, 1, 0); |