From b009e2235e45e2a212853907e42689471bd8e7d9 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 28 Feb 2012 18:08:08 +0000 Subject: [PATCH] Check return values after calling new lvmetad fns (Haven't checked error path handling though) --- tools/commands.h | 2 +- tools/pvremove.c | 13 +++++++------ tools/pvscan.c | 4 +++- tools/toollib.c | 6 ++++-- tools/vgrename.c | 4 +++- tools/vgscan.c | 5 ++++- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/tools/commands.h b/tools/commands.h index 3557c3bcd..3a968bde2 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -670,7 +670,7 @@ xx(pvscan, "\t[-P|--partial] " "\n" "\t[-s|--short] " "\n" "\t[-u|--uuid] " "\n" - "\t[--lvmetad DEVICE] " "\n" + "\t[--lvmetad DevicePath] " "\n" "\t[-v|--verbose] " "\n" "\t[--version]\n", diff --git a/tools/pvremove.c b/tools/pvremove.c index 655214e0a..4c3628b7a 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -107,35 +107,36 @@ static int pvremove_single(struct cmd_context *cmd, const char *pv_name, } if (!pvremove_check(cmd, pv_name)) - goto error; + goto out; if (!(dev = dev_cache_get(pv_name, cmd->filter))) { log_error("%s: Couldn't find device. Check your filters?", pv_name); - goto error; + goto out; } if (!dev_test_excl(dev)) { /* FIXME Detect whether device-mapper is still using the device */ log_error("Can't open %s exclusively - not removing. " "Mounted filesystem?", dev_name(dev)); - goto error; + goto out; } /* Wipe existing label(s) */ if (!label_remove(dev)) { log_error("Failed to wipe existing label(s) on %s", pv_name); - goto error; + goto out; } - lvmetad_pv_gone(dev->dev); + if (!lvmetad_pv_gone(dev->dev)) + goto_out; log_print("Labels on physical volume \"%s\" successfully wiped", pv_name); ret = ECMD_PROCESSED; - error: +out: unlock_vg(cmd, VG_ORPHANS); return ret; diff --git a/tools/pvscan.c b/tools/pvscan.c index 42d494020..7cc9d433f 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -116,8 +116,10 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv) vg_max_name_len = 0; if (arg_count(cmd, lvmetad_ARG)) { - if (!pvscan_lvmetad(cmd, argc, argv)) + if (!pvscan_lvmetad(cmd, argc, argv)) { + stack; return ECMD_FAILED; + } return ECMD_PROCESSED; } diff --git a/tools/toollib.c b/tools/toollib.c index d68624998..f49512e9a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -305,7 +305,8 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, if (!argc || !dm_list_empty(&tags)) { log_verbose("Finding all logical volumes"); - lvmetad_vg_list_to_lvmcache(cmd); + if (!lvmetad_vg_list_to_lvmcache(cmd)) + stack; if (!(vgnames = get_vgnames(cmd, 0)) || dm_list_empty(vgnames)) { log_error("No volume groups found"); return ret_max; @@ -582,7 +583,8 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, if (!argc || !dm_list_empty(&tags)) { log_verbose("Finding all volume groups"); - lvmetad_vg_list_to_lvmcache(cmd); + if (!lvmetad_vg_list_to_lvmcache(cmd)) + stack; if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) { log_error("No volume groups found"); return ret_max; diff --git a/tools/vgrename.c b/tools/vgrename.c index c3e71cefb..acd5da3c2 100644 --- a/tools/vgrename.c +++ b/tools/vgrename.c @@ -79,7 +79,9 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, log_verbose("Checking for existing volume group \"%s\"", vg_name_old); - lvmetad_vg_list_to_lvmcache(cmd); /* populate lvmcache */ + /* populate lvmcache */ + if (!lvmetad_vg_list_to_lvmcache(cmd)) + stack; /* Avoid duplicates */ if (!(vgids = get_vgids(cmd, 0)) || dm_list_empty(vgids)) { diff --git a/tools/vgscan.c b/tools/vgscan.c index df0486f24..a353c4325 100644 --- a/tools/vgscan.c +++ b/tools/vgscan.c @@ -24,7 +24,10 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name, vg->fid->fmt->name); check_current_backup(vg); - lvmetad_vg_update(vg); /* keep lvmetad up to date */ + + /* keep lvmetad up to date */ + if (!lvmetad_vg_update(vg)) + stack; return ECMD_PROCESSED; }