summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2009-09-14 22:47:49 +0000
committerAlasdair Kergon <agk@redhat.com>2009-09-14 22:47:49 +0000
commit651ff9b32865373f9f6298fbe7b0ea5419da3746 (patch)
tree898c9215fdb07ca76b616f29cbcd45d3cbd74d21
parent905240f91da66571da073df8784f1f42b2888328 (diff)
downloadlvm2-651ff9b32865373f9f6298fbe7b0ea5419da3746.tar.gz
lvm2-651ff9b32865373f9f6298fbe7b0ea5419da3746.tar.xz
lvm2-651ff9b32865373f9f6298fbe7b0ea5419da3746.zip
Add lots of missing stack debug messages to tools.
Make readonly locking available as locking type 4. Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
-rw-r--r--WHATS_NEW4
-rw-r--r--lib/locking/locking.c8
-rw-r--r--lib/locking/no_locking.c5
-rw-r--r--tools/dumpconfig.c4
-rw-r--r--tools/lvchange.c48
-rw-r--r--tools/lvconvert.c16
-rw-r--r--tools/lvcreate.c9
-rw-r--r--tools/lvmcmdline.c4
-rw-r--r--tools/lvremove.c4
-rw-r--r--tools/lvrename.c1
-rw-r--r--tools/polldaemon.c8
-rw-r--r--tools/pvchange.c1
-rw-r--r--tools/pvcreate.c4
-rw-r--r--tools/pvresize.c4
-rw-r--r--tools/pvscan.c1
-rw-r--r--tools/reporter.c36
-rw-r--r--tools/toollib.c12
-rw-r--r--tools/vgcfgbackup.c7
-rw-r--r--tools/vgcfgrestore.c8
-rw-r--r--tools/vgchange.c84
-rw-r--r--tools/vgck.c12
-rw-r--r--tools/vgconvert.c12
-rw-r--r--tools/vgcreate.c10
-rw-r--r--tools/vgdisplay.c4
-rw-r--r--tools/vgexport.c10
-rw-r--r--tools/vgextend.c9
-rw-r--r--tools/vgimport.c12
-rw-r--r--tools/vgmerge.c10
-rw-r--r--tools/vgmknodes.c12
-rw-r--r--tools/vgreduce.c14
-rw-r--r--tools/vgremove.c20
-rw-r--r--tools/vgrename.c4
-rw-r--r--tools/vgscan.c4
-rw-r--r--tools/vgsplit.c20
34 files changed, 298 insertions, 123 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index a3d6e583..d268403e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.52 -
=================================
+ Add lots of missing stack debug messages to tools.
+ Make readonly locking available as locking type 4.
+ Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
Add manpage entry for dmsetup's udevcomplete_all and udevcookies commands.
Add DM_UDEV_RULES_VSN udev enviroment variable.
Check that udev is running and set internal state appropriately.
@@ -97,6 +100,7 @@ Version 2.02.50 - 28th July 2009
Version 2.02.49 - 15th July 2009
================================
+ Add readonly locking type to replace implementation of --ignorelockingfailure.
Exclude VG_GLOBAL from vg_write_lock_held so scans open devs read-only again.
Add unit test case for liblvm VG create/delete APIs.
Add liblvm APIs to implement creation and deletion of VGs.
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 12179744..9d864332 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -261,6 +261,13 @@ int init_locking(int type, struct cmd_context *cmd)
return 1;
#endif
+ case 4:
+ log_verbose("Read-only locking selected. "
+ "Only read operations permitted.");
+ if (!init_readonly_locking(&_locking, cmd))
+ break;
+ return 1;
+
default:
log_error("Unknown locking type requested.");
return 0;
@@ -280,7 +287,6 @@ int init_locking(int type, struct cmd_context *cmd)
if (!ignorelockingfailure())
return 0;
- /* FIXME Ensure only read ops are permitted */
log_verbose("Locking disabled - only read operations permitted.");
init_readonly_locking(&_locking, cmd);
diff --git a/lib/locking/no_locking.c b/lib/locking/no_locking.c
index 583ab5c2..f4a14ad6 100644
--- a/lib/locking/no_locking.c
+++ b/lib/locking/no_locking.c
@@ -71,10 +71,13 @@ static int _readonly_lock_resource(struct cmd_context *cmd,
uint32_t flags)
{
if ((flags & LCK_TYPE_MASK) == LCK_WRITE &&
- (flags & LCK_SCOPE_MASK) == LCK_VG) {
+ (flags & LCK_SCOPE_MASK) == LCK_VG &&
+ !(flags & LCK_CACHE) &&
+ strcmp(resource, VG_GLOBAL)) {
log_error("Write locks are prohibited with --ignorelockingfailure.");
return 0;
}
+
return _no_lock_resource(cmd, resource, flags);
}
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 8cf1d84b..c7c58c15 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -22,8 +22,10 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, file_ARG))
file = arg_str_value(cmd, file_ARG, "");
- if (!write_config_file(cmd->cft, file, argc, argv))
+ if (!write_config_file(cmd->cft, file, argc, argv)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/lvchange.c b/tools/lvchange.c
index b16fd14a..b9be0c2a 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -591,8 +591,10 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* access permission change */
if (arg_count(cmd, permission_ARG)) {
- if (!archive(lv->vg))
+ if (!archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
+ }
archived = 1;
doit += lvchange_permission(cmd, lv);
docmds++;
@@ -600,8 +602,10 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* allocation policy change */
if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) {
- if (!archived && !archive(lv->vg))
+ if (!archived && !archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
+ }
archived = 1;
doit += lvchange_alloc(cmd, lv);
docmds++;
@@ -609,8 +613,10 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* read ahead sector change */
if (arg_count(cmd, readahead_ARG)) {
- if (!archived && !archive(lv->vg))
+ if (!archived && !archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
+ }
archived = 1;
doit += lvchange_readahead(cmd, lv);
docmds++;
@@ -618,19 +624,25 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* read ahead sector change */
if (arg_count(cmd, persistent_ARG)) {
- if (!archived && !archive(lv->vg))
+ if (!archived && !archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
+ }
archived = 1;
doit += lvchange_persistent(cmd, lv);
docmds++;
- if (sigint_caught())
+ if (sigint_caught()) {
+ stack;
return ECMD_FAILED;
+ }
}
/* add tag */
if (arg_count(cmd, addtag_ARG)) {
- if (!archived && !archive(lv->vg))
+ if (!archived && !archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
+ }
archived = 1;
doit += lvchange_tag(cmd, lv, addtag_ARG);
docmds++;
@@ -638,8 +650,10 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* del tag */
if (arg_count(cmd, deltag_ARG)) {
- if (!archived && !archive(lv->vg))
+ if (!archived && !archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
+ }
archived = 1;
doit += lvchange_tag(cmd, lv, deltag_ARG);
docmds++;
@@ -649,28 +663,38 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
log_print("Logical volume \"%s\" changed", lv->name);
if (arg_count(cmd, resync_ARG))
- if (!lvchange_resync(cmd, lv))
+ if (!lvchange_resync(cmd, lv)) {
+ stack;
return ECMD_FAILED;
+ }
/* availability change */
if (arg_count(cmd, available_ARG)) {
- if (!lvchange_availability(cmd, lv))
+ if (!lvchange_availability(cmd, lv)) {
+ stack;
return ECMD_FAILED;
+ }
}
if (arg_count(cmd, refresh_ARG))
- if (!lvchange_refresh(cmd, lv))
+ if (!lvchange_refresh(cmd, lv)) {
+ stack;
return ECMD_FAILED;
+ }
if (!arg_count(cmd, available_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, monitor_ARG)) {
- if (!lvchange_monitoring(cmd, lv))
+ if (!lvchange_monitoring(cmd, lv)) {
+ stack;
return ECMD_FAILED;
+ }
}
- if (doit != docmds)
+ if (doit != docmds) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index b3deebcd..79a459cd 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -904,15 +904,23 @@ static int lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name);
return ECMD_FAILED;
}
- if (!archive(lv->vg))
+ if (!archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
- if (!lvconvert_snapshot(cmd, lv, lp))
+ }
+ if (!lvconvert_snapshot(cmd, lv, lp)) {
+ stack;
return ECMD_FAILED;
+ }
} else if (arg_count(cmd, mirrors_ARG) || (lv->status & MIRRORED)) {
- if (!archive(lv->vg))
+ if (!archive(lv->vg)) {
+ stack;
return ECMD_FAILED;
- if (!_lvconvert_mirrors(cmd, lv, lp))
+ }
+ if (!_lvconvert_mirrors(cmd, lv, lp)) {
+ stack;
return ECMD_FAILED;
+ }
}
return ECMD_PROCESSED;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 53943d7b..be6b5cce 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -586,14 +586,19 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
if (vg_read_error(vg)) {
vg_release(vg);
+ stack;
return ECMD_FAILED;
}
- if (!_update_extents_params(vg, &lp, &lcp))
+ if (!_update_extents_params(vg, &lp, &lcp)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!lv_create_single(vg, &lp))
+ if (!lv_create_single(vg, &lp)) {
+ stack;
r = ECMD_FAILED;
+ }
unlock_and_release_vg(cmd, vg, lp.vg_name);
return r;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index d13c57c0..80c1a469 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -963,8 +963,10 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
/* each command should start out with sigint flag cleared */
sigint_clear();
- if (!(cmd->cmd_line = _copy_command_line(cmd, argc, argv)))
+ if (!(cmd->cmd_line = _copy_command_line(cmd, argc, argv))) {
+ stack;
return ECMD_FAILED;
+ }
log_debug("Parsing: %s", cmd->cmd_line);
diff --git a/tools/lvremove.c b/tools/lvremove.c
index be2107a0..fd8a677c 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -26,8 +26,10 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
lv = origin;
- if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG)))
+ if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG))) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/lvrename.c b/tools/lvrename.c
index 74118546..2342ad0e 100644
--- a/tools/lvrename.c
+++ b/tools/lvrename.c
@@ -105,6 +105,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, vg_name, NULL, 0);
if (vg_read_error(vg)) {
vg_release(vg);
+ stack;
return ECMD_FAILED;
}
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 4dcbc22e..bd2ac20f 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -185,8 +185,10 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
const char *name;
int finished;
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
dm_list_iterate_items(lvl, &vg->lvs) {
lv_mirr = lvl->lv;
@@ -253,8 +255,10 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
}
if (name) {
- if (!_wait_for_single_mirror(cmd, name, uuid, &parms))
+ if (!_wait_for_single_mirror(cmd, name, uuid, &parms)) {
+ stack;
return ECMD_FAILED;
+ }
} else
_poll_for_all_vgs(cmd, &parms);
diff --git a/tools/pvchange.c b/tools/pvchange.c
index def78cc2..cba9dd25 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -274,6 +274,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
} else {
log_verbose("Scanning for physical volume names");
if (!(pvslist = get_pvs(cmd))) {
+ stack;
return ECMD_FAILED;
}
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index a22190d7..99496319 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -195,8 +195,10 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- if (!pvcreate_single(cmd, argv[i], &pp))
+ if (!pvcreate_single(cmd, argv[i], &pp)) {
+ stack;
ret = ECMD_FAILED;
+ }
unlock_vg(cmd, VG_ORPHANS);
if (sigint_caught())
diff --git a/tools/pvresize.c b/tools/pvresize.c
index eafbd56d..7a911ac8 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -176,8 +176,10 @@ static int _pvresize_single(struct cmd_context *cmd,
params->total++;
- if (!_pv_resize_single(cmd, vg, pv, params->new_size))
+ if (!_pv_resize_single(cmd, vg, pv, params->new_size)) {
+ stack;
return ECMD_FAILED;
+ }
params->done++;
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 494af3d9..775ba291 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -135,6 +135,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
log_verbose("Walking through all physical volumes");
if (!(pvslist = get_pvs(cmd))) {
unlock_vg(cmd, VG_GLOBAL);
+ stack;
return ECMD_FAILED;
}
diff --git a/tools/reporter.c b/tools/reporter.c
index e391ee20..b200a964 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -20,11 +20,15 @@ static int _vgs_single(struct cmd_context *cmd __attribute((unused)),
const char *vg_name, struct volume_group *vg,
void *handle)
{
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!report_object(handle, vg, NULL, NULL, NULL, NULL))
+ if (!report_object(handle, vg, NULL, NULL, NULL, NULL)) {
+ stack;
return ECMD_FAILED;
+ }
check_current_backup(vg);
@@ -37,8 +41,10 @@ static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
- if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL))
+ if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
@@ -46,8 +52,10 @@ static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
static int _segs_single(struct cmd_context *cmd __attribute((unused)),
struct lv_segment *seg, void *handle)
{
- if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL))
+ if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
@@ -102,8 +110,10 @@ static int _pvsegs_sub_single(struct cmd_context *cmd,
dm_list_init(&_free_logical_volume.snapshot_segs);
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
- seg ? : &_free_lv_segment, pvseg))
+ seg ? : &_free_lv_segment, pvseg)) {
+ stack;
ret = ECMD_FAILED;
+ }
return ret;
}
@@ -155,8 +165,10 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
pv = pvl->pv;
}
- if (!report_object(handle, vg, NULL, pv, NULL, NULL))
+ if (!report_object(handle, vg, NULL, pv, NULL, NULL)) {
+ stack;
ret = ECMD_FAILED;
+ }
out:
if (vg_name)
@@ -171,8 +183,10 @@ out:
static int _label_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv, void *handle)
{
- if (!report_object(handle, vg, NULL, pv, NULL, NULL))
+ if (!report_object(handle, vg, NULL, pv, NULL, NULL)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
@@ -181,8 +195,10 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle)
{
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single);
}
@@ -191,8 +207,10 @@ static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle)
{
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single);
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 54539ee2..d45e3a01 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -293,7 +293,8 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
if (ret_max < ECMD_FAILED) {
log_error("Skipping volume group %s", vgname);
ret_max = ECMD_FAILED;
- }
+ } else
+ stack;
continue;
}
@@ -431,9 +432,10 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
log_verbose("Finding volume group \"%s\"", vg_name);
vg = vg_read(cmd, vg_name, vgid, flags);
- if (vg_read_error(vg) == FAILED_ALLOCATION ||
- vg_read_error(vg) == FAILED_NOTFOUND) {
+ /* Allow FAILED_INCONSISTENT through only for vgcfgrestore */
+ if (vg_read_error(vg) && (vg_read_error(vg) != FAILED_INCONSISTENT)) {
vg_release(vg);
+ stack;
return ECMD_FAILED;
}
@@ -445,9 +447,8 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
}
if ((ret = process_single(cmd, vg_name, vg,
- handle)) > ret_max) {
+ handle)) > ret_max)
ret_max = ret;
- }
out:
unlock_and_release_vg(cmd, vg, vg_name);
@@ -728,6 +729,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
if (vg_read_error(vg)) {
ret_max = ECMD_FAILED;
vg_release(vg);
+ stack;
continue;
}
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index 2491b8ce..4c61714e 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -54,9 +54,6 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
char **last_filename = (char **)handle;
char *filename;
- if (vg_read_error(vg) && (vg_read_error(vg) != FAILED_INCONSISTENT))
- return ECMD_FAILED;
-
if (arg_count(cmd, file_ARG)) {
if (!(filename = _expand_filename(arg_value(cmd, file_ARG),
vg->name, last_filename))) {
@@ -64,8 +61,10 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- if (!backup_to_file(filename, vg->cmd->cmd_line, vg))
+ if (!backup_to_file(filename, vg->cmd->cmd_line, vg)) {
+ stack;
return ECMD_FAILED;
+ }
} else {
if (vg_read_error(vg) == FAILED_INCONSISTENT) {
log_error("No backup taken: specify filename with -f "
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index dda22bea..90e15174 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -36,10 +36,12 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
*/
if (arg_count(cmd, list_ARG)) {
if (!(arg_count(cmd,file_ARG) ?
- archive_display_file(cmd,
- arg_str_value(cmd, file_ARG, "")) :
- archive_display(cmd, vg_name)))
+ archive_display_file(cmd,
+ arg_str_value(cmd, file_ARG, "")) :
+ archive_display(cmd, vg_name))) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/vgchange.c b/tools/vgchange.c
index b3177eb4..8a3c2031 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -179,8 +179,10 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
/* FIXME: make consistent with vg_set_alloc_policy() */
if (alloc == vg->alloc) {
@@ -188,11 +190,15 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
get_alloc_string(vg->alloc));
return ECMD_FAILED;
}
- if (!vg_set_alloc_policy(vg, alloc))
+ if (!vg_set_alloc_policy(vg, alloc)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -218,16 +224,20 @@ static int _vgchange_resizeable(struct cmd_context *cmd,
return ECMD_FAILED;
}
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
if (resizeable)
vg->status |= RESIZEABLE_VG;
else
vg->status &= ~RESIZEABLE_VG;
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -265,16 +275,20 @@ static int _vgchange_clustered(struct cmd_context *cmd,
}
}
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
if (clustered)
vg->status |= CLUSTERED;
else
vg->status &= ~CLUSTERED;
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -288,14 +302,20 @@ static int _vgchange_logicalvolume(struct cmd_context *cmd,
{
uint32_t max_lv = arg_uint_value(cmd, logicalvolume_ARG, 0);
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_set_max_lv(vg, max_lv))
+ if (!vg_set_max_lv(vg, max_lv)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -314,14 +334,20 @@ static int _vgchange_physicalvolumes(struct cmd_context *cmd,
return EINVALID_CMD_LINE;
}
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_set_max_pv(vg, max_pv))
+ if (!vg_set_max_pv(vg, max_pv)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -347,16 +373,20 @@ static int _vgchange_pesize(struct cmd_context *cmd, struct volume_group *vg)
return ECMD_PROCESSED;
}
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
if (!vg_set_extent_size(vg, extent_size)) {
stack;
return EINVALID_CMD_LINE;
}
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -380,8 +410,10 @@ static int _vgchange_tag(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED;
}
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
if ((arg == addtag_ARG)) {
if (!str_list_add(cmd->mem, &vg->tags, tag)) {
@@ -397,8 +429,10 @@ static int _vgchange_tag(struct cmd_context *cmd, struct volume_group *vg,
}
}
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -417,8 +451,10 @@ static int _vgchange_uuid(struct cmd_context *cmd __attribute((unused)),
return ECMD_FAILED;
}
- if (!archive(vg))
+ if (!archive(vg)) {
+ stack;
return ECMD_FAILED;
+ }
if (!id_create(&vg->id)) {
log_error("Failed to generate new random UUID for VG %s.",
@@ -430,8 +466,10 @@ static int _vgchange_uuid(struct cmd_context *cmd __attribute((unused)),
memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id));
}
- if (!vg_write(vg) || !vg_commit(vg))
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ stack;
return ECMD_FAILED;
+ }
backup(vg);
@@ -444,8 +482,10 @@ static int _vgchange_refresh(struct cmd_context *cmd, struct volume_group *vg)
{
log_verbose("Refreshing volume group \"%s\"", vg->name);
- if (!vg_refresh_visible(cmd, vg))
+ if (!vg_refresh_visible(cmd, vg)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
@@ -456,8 +496,10 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
{
int r = ECMD_FAILED;
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
if (vg_is_exported(vg)) {
log_error("Volume group \"%s\" is exported", vg_name);
diff --git a/tools/vgck.c b/tools/vgck.c
index 0c867ce6..690e48d6 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -21,14 +21,20 @@ static int vgck_single(struct cmd_context *cmd __attribute((unused)),
struct volume_group *vg,
void *handle __attribute((unused)))
{
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_check_status(vg, EXPORTED_VG))
+ if (!vg_check_status(vg, EXPORTED_VG)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_validate(vg))
+ if (!vg_validate(vg)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index d24b010f..2263baa4 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -32,11 +32,15 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
struct lvinfo info;
int active = 0;
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
+ if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG)) {
+ stack;
return ECMD_FAILED;
+ }
if (vg->fid->fmt == cmd->fmt) {
log_error("Volume group \"%s\" already uses format %s",
@@ -111,8 +115,10 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
}
}
- if (active)
+ if (active) {
+ stack;
return ECMD_FAILED;
+ }
dm_list_iterate_items(pvl, &vg->pvs) {
existing_pv = pvl->pv;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index dff3a5d1..2100877c 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -102,14 +102,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
clustered_message = "Non-clustered ";
}
- if (!archive(vg)) {
- goto bad;
- }
+ if (!archive(vg))
+ goto_bad;
/* Store VG on disk(s) */
- if (!vg_write(vg) || !vg_commit(vg)) {
- goto bad;
- }
+ if (!vg_write(vg) || !vg_commit(vg))
+ goto_bad;
unlock_vg(cmd, VG_ORPHANS);
unlock_vg(cmd, vp_new.vg_name);
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index bbabceef..3876d351 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -20,8 +20,10 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
void *handle __attribute((unused)))
{
/* FIXME Do the active check here if activevolumegroups_ARG ? */
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
vg_check_status(vg, EXPORTED_VG);
diff --git a/tools/vgexport.c b/tools/vgexport.c
index 59627b97..e3b1890e 100644
--- a/tools/vgexport.c
+++ b/tools/vgexport.c
@@ -24,16 +24,16 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
struct physical_volume *pv;
if (vg_read_error(vg))
- goto error;
+ goto_bad;
if (lvs_in_vg_activated(vg)) {
log_error("Volume group \"%s\" has active logical volumes",
vg_name);
- goto error;
+ goto bad;
}
if (!archive(vg))
- goto error;
+ goto_bad;
vg->status |= EXPORTED_VG;
@@ -43,7 +43,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
}
if (!vg_write(vg) || !vg_commit(vg))
- goto error;
+ goto_bad;
backup(vg);
@@ -51,7 +51,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
return ECMD_PROCESSED;
- error:
+bad:
return ECMD_FAILED;
}
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 20c05c3d..b659492e 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -40,6 +40,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, vg_name, NULL, 0);
if (vg_read_error(vg)) {
vg_release(vg);
+ stack;
return ECMD_FAILED;
}
@@ -50,11 +51,11 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
}
if (!archive(vg))
- goto error;
+ goto_bad;
/* extend vg */
if (!vg_extend(vg, argc, argv))
- goto error;
+ goto_bad;
/* ret > 0 */
log_verbose("Volume group \"%s\" will be extended by %d new "
@@ -62,13 +63,13 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
/* store vg on disk(s) */
if (!vg_write(vg) || !vg_commit(vg))
- goto error;
+ goto_bad;
backup(vg);
log_print("Volume group \"%s\" successfully extended", vg_name);
r = ECMD_PROCESSED;
-error:
+bad:
unlock_vg(cmd, VG_ORPHANS);
unlock_and_release_vg(cmd, vg, vg_name);
return r;
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 5161b623..7eeb5db3 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -24,20 +24,20 @@ static int vgimport_single(struct cmd_context *cmd __attribute((unused)),
struct physical_volume *pv;
if (vg_read_error(vg))
- goto error;
+ goto_bad;
if (!vg_is_exported(vg)) {
log_error("Volume group \"%s\" is not exported", vg_name);
- goto error;
+ goto bad;
}
if (vg_status(vg) & PARTIAL_VG) {
log_error("Volume group \"%s\" is partially missing", vg_name);
- goto error;
+ goto bad;
}
if (!archive(vg))
- goto error;
+ goto_bad;
vg->status &= ~EXPORTED_VG;
@@ -47,7 +47,7 @@ static int vgimport_single(struct cmd_context *cmd __attribute((unused)),
}
if (!vg_write(vg) || !vg_commit(vg))
- goto error;
+ goto_bad;
backup(vg);
@@ -55,7 +55,7 @@ static int vgimport_single(struct cmd_context *cmd __attribute((unused)),
return ECMD_PROCESSED;
- error:
+bad:
return ECMD_FAILED;
}
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index e147d27b..4a6721d1 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -46,20 +46,26 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
if (lock_vg_from_first) {
vg_from = _vgmerge_vg_read(cmd, vg_name_from);
- if (!vg_from)
+ if (!vg_from) {
+ stack;
return ECMD_FAILED;
+ }
vg_to = _vgmerge_vg_read(cmd, vg_name_to);
if (!vg_to) {
+ stack;
unlock_and_release_vg(cmd, vg_from, vg_name_from);
return ECMD_FAILED;
}
} else {
vg_to = _vgmerge_vg_read(cmd, vg_name_to);
- if (!vg_to)
+ if (!vg_to) {
+ stack;
return ECMD_FAILED;
+ }
vg_from = _vgmerge_vg_read(cmd, vg_name_from);
if (!vg_from) {
+ stack;
unlock_and_release_vg(cmd, vg_to, vg_name_to);
return ECMD_FAILED;
}
diff --git a/tools/vgmknodes.c b/tools/vgmknodes.c
index fce925b4..f62b5893 100644
--- a/tools/vgmknodes.c
+++ b/tools/vgmknodes.c
@@ -19,19 +19,25 @@ static int _vgmknodes_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute((unused)))
{
if (arg_count(cmd, refresh_ARG) && lv_is_visible(lv))
- if (!lv_refresh(cmd, lv))
+ if (!lv_refresh(cmd, lv)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!lv_mknodes(cmd, lv))
+ if (!lv_mknodes(cmd, lv)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
int vgmknodes(struct cmd_context *cmd, int argc, char **argv)
{
- if (!lv_mknodes(cmd, NULL))
+ if (!lv_mknodes(cmd, NULL)) {
+ stack;
return ECMD_FAILED;
+ }
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
&_vgmknodes_single);
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 8b66a992..e80fa9ad 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -404,7 +404,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
pvl = find_pv_in_vg(vg, name);
if (!archive(vg))
- goto bad;
+ goto_bad;
log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name);
@@ -512,12 +512,12 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED);
if (vg_read_error(vg) == FAILED_ALLOCATION ||
vg_read_error(vg) == FAILED_NOTFOUND)
- goto out;
+ goto_out;
/* FIXME We want to allow read-only VGs to be changed here? */
if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
&& !arg_count(cmd, removemissing_ARG))
- goto out;
+ goto_out;
if (repairing) {
if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
@@ -536,14 +536,14 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
&& vg_read_error(vg) != FAILED_INCONSISTENT)
- goto out;
+ goto_out;
if (!archive(vg))
- goto out;
+ goto_out;
if (arg_count(cmd, force_ARG)) {
if (!_make_vg_consistent(cmd, vg))
- goto out;
+ goto_out;
} else
fixed = _consolidate_vg(cmd, vg);
@@ -563,7 +563,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
} else {
if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG))
- goto out;
+ goto_out;
/* FIXME: Pass private struct through to all these functions */
/* and update in batch here? */
diff --git a/tools/vgremove.c b/tools/vgremove.c
index abcd9400..c5b5dcfe 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -22,11 +22,15 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
unsigned lv_count;
force_t force;
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_check_status(vg, EXPORTED_VG))
+ if (!vg_check_status(vg, EXPORTED_VG)) {
+ stack;
return ECMD_FAILED;
+ }
lv_count = vg_visible_lvs(vg);
@@ -40,15 +44,21 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
log_print("Volume group \"%s\" not removed", vg_name);
return ECMD_FAILED;
}
- if (!remove_lvs_in_vg(cmd, vg, force))
+ if (!remove_lvs_in_vg(cmd, vg, force)) {
+ stack;
return ECMD_FAILED;
+ }
}
- if (!vg_remove_check(vg))
+ if (!vg_remove_check(vg)) {
+ stack;
return ECMD_FAILED;
+ }
- if (!vg_remove(vg))
+ if (!vg_remove(vg)) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/vgrename.c b/tools/vgrename.c
index e6f12b46..f1c47799 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -206,8 +206,10 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (!vg_rename_path(cmd, argv[0], argv[1]))
+ if (!vg_rename_path(cmd, argv[0], argv[1])) {
+ stack;
return ECMD_FAILED;
+ }
return ECMD_PROCESSED;
}
diff --git a/tools/vgscan.c b/tools/vgscan.c
index a7aef5f0..c0f07908 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -19,8 +19,10 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle __attribute((unused)))
{
- if (vg_read_error(vg))
+ if (vg_read_error(vg)) {
+ stack;
return ECMD_FAILED;
+ }
log_print("Found %svolume group \"%s\" using metadata type %s",
vg_is_exported(vg) ? "exported " : "", vg_name,
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 751c970d..c00561bb 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -319,8 +319,10 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (lock_vg_from_first) {
vg_from = _vgsplit_from(cmd, vg_name_from);
- if (!vg_from)
+ if (!vg_from) {
+ stack;
return ECMD_FAILED;
+ }
/*
* Set metadata format of original VG.
* NOTE: We must set the format before calling vg_create()
@@ -331,15 +333,19 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg);
if (!vg_to) {
unlock_and_release_vg(cmd, vg_from, vg_name_from);
+ stack;
return ECMD_FAILED;
}
} else {
vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg);
- if (!vg_to)
+ if (!vg_to) {
+ stack;
return ECMD_FAILED;
+ }
vg_from = _vgsplit_from(cmd, vg_name_from);
if (!vg_from) {
unlock_and_release_vg(cmd, vg_to, vg_name_to);
+ stack;
return ECMD_FAILED;
}
@@ -355,7 +361,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (new_vg_option_specified(cmd)) {
log_error("Volume group \"%s\" exists, but new VG "
"option specified", vg_name_to);
- goto_bad;
+ goto bad;
}
if (!vgs_are_compatible(cmd, vg_from,vg_to))
goto_bad;
@@ -369,12 +375,12 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (fill_vg_create_params(cmd, vg_name_to, &vp_new, &vp_def)) {
r = EINVALID_CMD_LINE;
- goto bad;
+ goto_bad;
}
if (validate_vg_create_params(cmd, &vp_new)) {
r = EINVALID_CMD_LINE;
- goto bad;
+ goto_bad;
}
if (!vg_set_extent_size(vg_to, vp_new.extent_size) ||
@@ -416,7 +422,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
/* Split metadata areas and check if both vgs have at least one area */
if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) {
log_error("Cannot split: Nowhere to store metadata for new Volume Group");
- goto_bad;
+ goto bad;
}
/* Set proper name for all PVs in new VG */
@@ -465,7 +471,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (vg_read_error(vg_to)) {
log_error("Volume group \"%s\" became inconsistent: "
"please fix manually", vg_name_to);
- goto_bad;
+ goto bad;
}
}