diff options
author | David Teigland <teigland@redhat.com> | 2014-10-24 12:29:43 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2014-11-07 13:39:28 -0600 |
commit | 74d47116718341b5eef55b8cd93a7e70b910ae17 (patch) | |
tree | e07742c57efd6cc47395eccb2a3507ab533a44f1 | |
parent | 76e4725f479b95b7be19be7bada7be31d76d6303 (diff) | |
download | lvm2-dev-dct-lvmlockd1-systemid.tar.gz |
toollib: command should fail if ignoring named argdev-dct-lvmlockd1-systemid
If a foreign VG is ignored when it's included by "all vgs",
then the command shouldn't fail.
If a foreign VG is ignored when it's named explicitly as
a command arg, then the command should fail.
Also, remove ignore_vg from reporter functions because it
repeats what has been done in process_each given the recent
new version of process_each.
-rw-r--r-- | tools/reporter.c | 14 | ||||
-rw-r--r-- | tools/toollib.c | 25 | ||||
-rw-r--r-- | tools/toollib.h | 2 |
3 files changed, 20 insertions, 21 deletions
diff --git a/tools/reporter.c b/tools/reporter.c index 796aad9b0..a3b860676 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -217,13 +217,6 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, void *handle) { - int ret = ECMD_PROCESSED; - - if (ignore_vg(vg, vg_name, 0, &ret)) { - stack; - return ret; - } - return process_each_pv_in_vg(cmd, vg, handle, &_pvs_single); } @@ -231,13 +224,6 @@ static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, void *handle) { - int ret = ECMD_PROCESSED; - - if (ignore_vg(vg, vg_name, 0, &ret)) { - stack; - return ret; - } - return process_each_pv_in_vg(cmd, vg, handle, &_pvsegs_single); } diff --git a/tools/toollib.c b/tools/toollib.c index e307a2e5b..9291eb42a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -160,7 +160,8 @@ const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name, /* * Returns 1 if VG should be ignored. */ -int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *ret) +static int ignore_vg(struct cmd_context *cmd, struct volume_group *vg, const char *vg_name, + struct dm_list *arg_vgnames, int allow_inconsistent, int *ret) { uint32_t read_error = vg_read_error(vg); @@ -170,8 +171,21 @@ int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsiste if ((read_error == FAILED_INCONSISTENT) && allow_inconsistent) return 0; - if (read_error == FAILED_SYSTEMID) + /* + * Commands that operate on "all vgs" shouldn't be bothered by + * skipping a foreign VG, and the command shouldn't fail when + * one is skipped. But, if the command explicitly asked to + * operate on a foreign VG and it's skipped, then the command + * would expect to fail. + */ + if (read_error == FAILED_SYSTEMID) { + if (arg_vgnames && str_list_match_item(arg_vgnames, vg->name)) { + log_error("Skipping volume group %s with system id %s", + vg->name, vg->system_id); + *ret = ECMD_FAILED; + } return 1; + } if (read_error == FAILED_NOTFOUND) *ret = ECMD_FAILED; @@ -1513,9 +1527,10 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags, ret = 0; vg = vg_read(cmd, vg_name, vg_uuid, flags); - if (ignore_vg(vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) { + if (ignore_vg(cmd, vg, vg_name, arg_vgnames, flags & READ_ALLOW_INCONSISTENT, &ret)) { if (ret > ret_max) ret_max = ret; + release_vg(vg); stack; continue; @@ -1887,7 +1902,7 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t flags, } vg = vg_read(cmd, vg_name, vg_uuid, flags); - if (ignore_vg(vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) { + if (ignore_vg(cmd, vg, vg_name, arg_vgnames, flags & READ_ALLOW_INCONSISTENT, &ret)) { if (ret > ret_max) ret_max = ret; release_vg(vg); @@ -2203,7 +2218,7 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags, skip = 0; vg = vg_read(cmd, vg_name, vg_uuid, flags | READ_WARN_INCONSISTENT); - if (ignore_vg(vg, vg_name, flags & READ_ALLOW_INCONSISTENT, &ret)) { + if (ignore_vg(cmd, vg, vg_name, NULL, flags & READ_ALLOW_INCONSISTENT, &ret)) { if (ret > ret_max) ret_max = ret; skip = 1; diff --git a/tools/toollib.h b/tools/toollib.h index 03c9bdbbd..75aa4f4e4 100644 --- a/tools/toollib.h +++ b/tools/toollib.h @@ -20,8 +20,6 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm); -int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *ret); - typedef int (*process_single_vg_fn_t) (struct cmd_context * cmd, const char *vg_name, struct volume_group * vg, |