1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Check return values after calling new lvmetad fns

(Haven't checked error path handling though)
This commit is contained in:
Alasdair Kergon 2012-02-28 18:08:08 +00:00
parent 7a3de26248
commit b009e2235e
6 changed files with 22 additions and 12 deletions

View File

@ -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",

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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)) {

View File

@ -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;
}