1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

cleanup: introduce return_ECMD_FAILED macro

Use shortening macro for common code sequence
stack;
return ECMD_FAILED;
This commit is contained in:
Zdenek Kabelac 2013-07-01 11:27:22 +02:00
parent 4d9ed81075
commit b90450b8a0
24 changed files with 181 additions and 339 deletions

View File

@ -109,6 +109,7 @@
#define return_0 do { stack; return 0; } while (0) #define return_0 do { stack; return 0; } while (0)
#define return_NULL do { stack; return NULL; } while (0) #define return_NULL do { stack; return NULL; } while (0)
#define return_ECMD_FAILED do { stack; return ECMD_FAILED; } while (0)
#define goto_out do { stack; goto out; } while (0) #define goto_out do { stack; goto out; } while (0)
#define goto_bad do { stack; goto bad; } while (0) #define goto_bad do { stack; goto bad; } while (0)

View File

@ -950,84 +950,66 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* access permission change */ /* access permission change */
if (arg_count(cmd, permission_ARG)) { if (arg_count(cmd, permission_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_permission(cmd, lv); doit += lvchange_permission(cmd, lv);
docmds++; docmds++;
} }
/* allocation policy change */ /* allocation policy change */
if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) { if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_alloc(cmd, lv); doit += lvchange_alloc(cmd, lv);
docmds++; docmds++;
} }
/* read ahead sector change */ /* read ahead sector change */
if (arg_count(cmd, readahead_ARG)) { if (arg_count(cmd, readahead_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_readahead(cmd, lv); doit += lvchange_readahead(cmd, lv);
docmds++; docmds++;
} }
/* persistent device number change */ /* persistent device number change */
if (arg_count(cmd, persistent_ARG)) { if (arg_count(cmd, persistent_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_persistent(cmd, lv); doit += lvchange_persistent(cmd, lv);
docmds++; docmds++;
if (sigint_caught()) { if (sigint_caught())
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
} }
if (arg_count(cmd, discards_ARG) || if (arg_count(cmd, discards_ARG) ||
arg_count(cmd, zero_ARG)) { arg_count(cmd, zero_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_pool_update(cmd, lv); doit += lvchange_pool_update(cmd, lv);
docmds++; docmds++;
} }
/* add tag */ /* add tag */
if (arg_count(cmd, addtag_ARG)) { if (arg_count(cmd, addtag_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_tag(cmd, lv, addtag_ARG); doit += lvchange_tag(cmd, lv, addtag_ARG);
docmds++; docmds++;
} }
/* del tag */ /* del tag */
if (arg_count(cmd, deltag_ARG)) { if (arg_count(cmd, deltag_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_tag(cmd, lv, deltag_ARG); doit += lvchange_tag(cmd, lv, deltag_ARG);
docmds++; docmds++;
} }
/* change writemostly/writebehind */ /* change writemostly/writebehind */
if (arg_count(cmd, writemostly_ARG) || arg_count(cmd, writebehind_ARG)) { if (arg_count(cmd, writemostly_ARG) || arg_count(cmd, writebehind_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_writemostly(lv); doit += lvchange_writemostly(lv);
docmds++; docmds++;
} }
@ -1035,10 +1017,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* change [min|max]_recovery_rate */ /* change [min|max]_recovery_rate */
if (arg_count(cmd, minrecoveryrate_ARG) || if (arg_count(cmd, minrecoveryrate_ARG) ||
arg_count(cmd, maxrecoveryrate_ARG)) { arg_count(cmd, maxrecoveryrate_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
doit += lvchange_recovery_rate(lv); doit += lvchange_recovery_rate(lv);
docmds++; docmds++;
} }
@ -1046,55 +1026,33 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (doit) if (doit)
log_print_unless_silent("Logical volume \"%s\" changed.", lv->name); log_print_unless_silent("Logical volume \"%s\" changed.", lv->name);
if (arg_count(cmd, resync_ARG)) if (arg_count(cmd, resync_ARG) &&
if (!lvchange_resync(cmd, lv)) { !lvchange_resync(cmd, lv))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (arg_count(cmd, syncaction_ARG)) { if (arg_count(cmd, syncaction_ARG) &&
if (!lv_raid_message(lv, arg_str_value(cmd, syncaction_ARG, NULL))) { !lv_raid_message(lv, arg_str_value(cmd, syncaction_ARG, NULL)))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
}
/* activation change */ /* activation change */
if (arg_count(cmd, activate_ARG)) { if (arg_count(cmd, activate_ARG)) {
if (!_lvchange_activate(cmd, lv)) { if (!_lvchange_activate(cmd, lv))
stack; return_ECMD_FAILED;
return ECMD_FAILED; } else if (arg_count(cmd, refresh_ARG)) {
} if (!lvchange_refresh(cmd, lv))
return_ECMD_FAILED;
} else {
if (arg_count(cmd, monitor_ARG) &&
!lvchange_monitoring(cmd, lv))
return_ECMD_FAILED;
if (arg_count(cmd, poll_ARG) &&
!lvchange_background_polling(cmd, lv))
return_ECMD_FAILED;
} }
if (arg_count(cmd, refresh_ARG)) if (doit != docmds)
if (!lvchange_refresh(cmd, lv)) { return_ECMD_FAILED;
stack;
return ECMD_FAILED;
}
if (!arg_count(cmd, activate_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, monitor_ARG)) {
if (!lvchange_monitoring(cmd, lv)) {
stack;
return ECMD_FAILED;
}
}
if (!arg_count(cmd, activate_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, poll_ARG)) {
if (!lvchange_background_polling(cmd, lv)) {
stack;
return ECMD_FAILED;
}
}
if (doit != docmds) {
stack;
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -2303,10 +2303,9 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
log_error("Unable to merge invalidated snapshot LV \"%s\"", lv->name); log_error("Unable to merge invalidated snapshot LV \"%s\"", lv->name);
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!lvconvert_merge(cmd, lv, lp)) { if (!lvconvert_merge(cmd, lv, lp)) {
log_error("Unable to merge LV \"%s\" into its origin.", lv->name); log_error("Unable to merge LV \"%s\" into its origin.", lv->name);
return ECMD_FAILED; return ECMD_FAILED;
@ -2316,38 +2315,29 @@ 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); log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name);
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} if (!lvconvert_snapshot(cmd, lv, lp))
if (!lvconvert_snapshot(cmd, lv, lp)) { return_ECMD_FAILED;
stack;
return ECMD_FAILED;
}
} else if (arg_count(cmd, thinpool_ARG)) { } else if (arg_count(cmd, thinpool_ARG)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} if (!_lvconvert_thinpool(cmd, lv, lp))
if (!_lvconvert_thinpool(cmd, lv, lp)) { return_ECMD_FAILED;
stack;
return ECMD_FAILED;
}
} else if (segtype_is_raid(lp->segtype) || } else if (segtype_is_raid(lp->segtype) ||
(lv->status & RAID) || lp->merge_mirror) { (lv->status & RAID) || lp->merge_mirror) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!lvconvert_raid(lv, lp)) {
stack;
return ECMD_FAILED;
}
if (!(failed_pvs = _failed_pv_list(lv->vg))) { if (!lvconvert_raid(lv, lp))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} if (!(failed_pvs = _failed_pv_list(lv->vg)))
return_ECMD_FAILED;
/* If repairing and using policies, remove missing PVs from VG */ /* If repairing and using policies, remove missing PVs from VG */
if (arg_count(cmd, repair_ARG) && arg_count(cmd, use_policies_ARG)) if (arg_count(cmd, repair_ARG) && arg_count(cmd, use_policies_ARG))
@ -2355,19 +2345,14 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
} else if (arg_count(cmd, mirrors_ARG) || } else if (arg_count(cmd, mirrors_ARG) ||
arg_count(cmd, splitmirrors_ARG) || arg_count(cmd, splitmirrors_ARG) ||
(lv->status & MIRRORED)) { (lv->status & MIRRORED)) {
if (!archive(lv->vg)) { if (!archive(lv->vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!_lvconvert_mirrors(cmd, lv, lp)) {
stack;
return ECMD_FAILED;
}
if (!(failed_pvs = _failed_pv_list(lv->vg))) { if (!_lvconvert_mirrors(cmd, lv, lp))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} if (!(failed_pvs = _failed_pv_list(lv->vg)))
return_ECMD_FAILED;
/* If repairing and using policies, remove missing PVs from VG */ /* If repairing and using policies, remove missing PVs from VG */
if (arg_count(cmd, repair_ARG) && arg_count(cmd, use_policies_ARG)) if (arg_count(cmd, repair_ARG) && arg_count(cmd, use_policies_ARG))

View File

@ -1057,8 +1057,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0); vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
if (vg_read_error(vg)) { if (vg_read_error(vg)) {
release_vg(vg); release_vg(vg);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
if (lp.snapshot && lp.origin && !_determine_snapshot_type(vg, &lp)) { if (lp.snapshot && lp.origin && !_determine_snapshot_type(vg, &lp)) {

View File

@ -1057,10 +1057,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
/* each command should start out with sigint flag cleared */ /* each command should start out with sigint flag cleared */
sigint_clear(); 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;
return ECMD_FAILED;
}
log_debug("Parsing: %s", cmd->cmd_line); log_debug("Parsing: %s", cmd->cmd_line);

View File

@ -26,10 +26,8 @@ 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))) if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
lv = origin; lv = origin;
if (!lv_remove_with_dependencies(cmd, lv, (force_t) arg_count(cmd, force_ARG), 0)) { if (!lv_remove_with_dependencies(cmd, lv, (force_t) arg_count(cmd, force_ARG), 0))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -85,10 +85,8 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!apply_lvname_restrictions(lv_name_new)) { if (!apply_lvname_restrictions(lv_name_new))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!validate_name(lv_name_new)) { if (!validate_name(lv_name_new)) {
log_error("New logical volume name \"%s\" is invalid", log_error("New logical volume name \"%s\" is invalid",
@ -105,8 +103,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, vg_name, NULL, 0); vg = vg_read_for_update(cmd, vg_name, NULL, 0);
if (vg_read_error(vg)) { if (vg_read_error(vg)) {
release_vg(vg); release_vg(vg);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
if (!(lvl = find_lv_in_vg(vg, lv_name_old))) { if (!(lvl = find_lv_in_vg(vg, lv_name_old))) {

View File

@ -533,7 +533,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!_adjust_policy_params(cmd, lv, lp)) if (!_adjust_policy_params(cmd, lv, lp))
return ECMD_FAILED; return_ECMD_FAILED;
} }
if (!lv_is_visible(lv) && if (!lv_is_visible(lv) &&
@ -576,10 +576,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
} }
if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc, if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc,
lp->argv, 1) : &vg->pvs)) { lp->argv, 1) : &vg->pvs))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (lp->sizeargs) { /* TODO: reindent or move to function */ if (lp->sizeargs) { /* TODO: reindent or move to function */
@ -891,10 +889,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
/* Request confirmation before operations that are often mistakes. */ /* Request confirmation before operations that are often mistakes. */
if ((lp->resizefs || (lp->resize == LV_REDUCE)) && if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
!_request_confirmation(cmd, vg, lv, lp)) { !_request_confirmation(cmd, vg, lv, lp))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (lp->resizefs) { if (lp->resizefs) {
if (!lp->nofsck && if (!lp->nofsck &&
@ -913,10 +909,8 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
} }
} }
if (!archive(vg)) { if (!archive(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
log_print_unless_silent("%sing logical volume %s to %s", log_print_unless_silent("%sing logical volume %s to %s",
(lp->resize == LV_REDUCE) ? "Reduc" : "Extend", (lp->resize == LV_REDUCE) ? "Reduc" : "Extend",
@ -924,19 +918,15 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
display_size(cmd, (uint64_t) lp->extents * vg->extent_size)); display_size(cmd, (uint64_t) lp->extents * vg->extent_size));
if (lp->resize == LV_REDUCE) { if (lp->resize == LV_REDUCE) {
if (!lv_reduce(lv, lv->le_count - lp->extents)) { if (!lv_reduce(lv, lv->le_count - lp->extents))
stack;
return ECMD_FAILED; return ECMD_FAILED;
}
} else if ((lp->extents > lv->le_count) && /* Ensure we extend */ } else if ((lp->extents > lv->le_count) && /* Ensure we extend */
!lv_extend(lv, lp->segtype, !lv_extend(lv, lp->segtype,
lp->stripes, lp->stripe_size, lp->stripes, lp->stripe_size,
lp->mirrors, first_seg(lv)->region_size, lp->mirrors, first_seg(lv)->region_size,
lp->extents - lv->le_count, NULL, lp->extents - lv->le_count, NULL,
pvh, alloc)) { pvh, alloc))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
/* If thin metadata, must suspend thin pool */ /* If thin metadata, must suspend thin pool */
if (lv_is_thin_pool_metadata(lv)) { if (lv_is_thin_pool_metadata(lv)) {
@ -952,10 +942,9 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
if (lp->poolmetadatasize) { if (lp->poolmetadatasize) {
metadata_resize: metadata_resize:
if (!(status = _lvresize_poolmetadata(cmd, vg, lp, lv, pvh, alloc))) { if (!(status = _lvresize_poolmetadata(cmd, vg, lp, lv, pvh, alloc)))
stack; return_ECMD_FAILED;
return ECMD_FAILED; else if ((status == 2) && !lp->sizeargs)
} else if ((status == 2) && !lp->sizeargs)
return ECMD_PROCESSED; return ECMD_PROCESSED;
lock_lv = lv; lock_lv = lv;
} }
@ -964,10 +953,8 @@ metadata_resize:
return ECMD_PROCESSED; /* Nothing to do */ return ECMD_PROCESSED; /* Nothing to do */
/* store vg on disk(s) */ /* store vg on disk(s) */
if (!vg_write(vg)) { if (!vg_write(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!suspend_lv(cmd, lock_lv)) { if (!suspend_lv(cmd, lock_lv)) {
log_error("Failed to suspend %s", lock_lv->name); log_error("Failed to suspend %s", lock_lv->name);
@ -1005,18 +992,14 @@ metadata_resize:
* FIXME: Activate only when thin volume is active * FIXME: Activate only when thin volume is active
*/ */
if (lv_is_thin_pool(lv) && if (lv_is_thin_pool(lv) &&
!update_pool_lv(lv, !lv_is_active(lv))) { !update_pool_lv(lv, !lv_is_active(lv)))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
log_print_unless_silent("Logical volume %s successfully resized", lp->lv_name); log_print_unless_silent("Logical volume %s successfully resized", lp->lv_name);
if (lp->resizefs && (lp->resize == LV_EXTEND) && if (lp->resizefs && (lp->resize == LV_EXTEND) &&
!_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL)) { !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
@ -1034,8 +1017,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0); vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
if (vg_read_error(vg)) { if (vg_read_error(vg)) {
release_vg(vg); release_vg(vg);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
if (!(r = _lvresize(cmd, vg, &lp))) if (!(r = _lvresize(cmd, vg, &lp)))

View File

@ -527,8 +527,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
vg = _get_vg(cmd, pv_vg_name(pv)); vg = _get_vg(cmd, pv_vg_name(pv));
if (vg_read_error(vg)) { if (vg_read_error(vg)) {
release_vg(vg); release_vg(vg);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
exclusive = _pvmove_is_exclusive(cmd, vg); exclusive = _pvmove_is_exclusive(cmd, vg);

View File

@ -142,11 +142,9 @@ static int _pvresize_single(struct cmd_context *cmd,
params->total++; 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;
return ECMD_FAILED;
}
params->done++; params->done++;
return ECMD_PROCESSED; return ECMD_PROCESSED;

View File

@ -304,8 +304,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
log_verbose("Walking through all physical volumes"); log_verbose("Walking through all physical volumes");
if (!(pvslist = get_pvs(cmd))) { if (!(pvslist = get_pvs(cmd))) {
unlock_vg(cmd, VG_GLOBAL); unlock_vg(cmd, VG_GLOBAL);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
/* eliminate exported/new if required */ /* eliminate exported/new if required */

View File

@ -20,10 +20,8 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name, struct volume_group *vg, const char *vg_name, struct volume_group *vg,
void *handle) void *handle)
{ {
if (!report_object(handle, vg, NULL, NULL, NULL, NULL)) { if (!report_object(handle, vg, NULL, NULL, NULL, NULL))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
check_current_backup(vg); check_current_backup(vg);
@ -33,10 +31,8 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv, static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle) void *handle)
{ {
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_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
@ -44,10 +40,8 @@ static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
static int _segs_single(struct cmd_context *cmd __attribute__((unused)), static int _segs_single(struct cmd_context *cmd __attribute__((unused)),
struct lv_segment *seg, void *handle) 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_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
@ -190,10 +184,8 @@ out:
static int _label_single(struct cmd_context *cmd, struct volume_group *vg, static int _label_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv, void *handle) 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_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
@ -202,10 +194,8 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, struct volume_group *vg,
void *handle) void *handle)
{ {
if (vg_read_error(vg)) { if (vg_read_error(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single); return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single);
} }
@ -214,10 +204,8 @@ static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, struct volume_group *vg,
void *handle) void *handle)
{ {
if (vg_read_error(vg)) { if (vg_read_error(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single); return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single);
} }
@ -334,8 +322,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
columns_as_rows))) { columns_as_rows))) {
if (!strcasecmp(options, "help") || !strcmp(options, "?")) if (!strcasecmp(options, "help") || !strcmp(options, "?"))
return r; return r;
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
/* Ensure options selected are compatible */ /* Ensure options selected are compatible */

View File

@ -321,10 +321,8 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
vgname = strl->str; vgname = strl->str;
dm_list_init(&cmd_vgs); dm_list_init(&cmd_vgs);
if (!(cvl_vg = cmd_vg_add(cmd->mem, &cmd_vgs, if (!(cvl_vg = cmd_vg_add(cmd->mem, &cmd_vgs,
vgname, NULL, flags))) { vgname, NULL, flags)))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!cmd_vg_read(cmd, &cmd_vgs)) { if (!cmd_vg_read(cmd, &cmd_vgs)) {
free_cmd_vgs(&cmd_vgs); free_cmd_vgs(&cmd_vgs);

View File

@ -56,15 +56,11 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
if (arg_count(cmd, file_ARG)) { if (arg_count(cmd, file_ARG)) {
if (!(filename = _expand_filename(arg_value(cmd, file_ARG), if (!(filename = _expand_filename(arg_value(cmd, file_ARG),
vg->name, last_filename))) { vg->name, last_filename)))
stack; return_ECMD_FAILED;
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;
return ECMD_FAILED;
}
} else { } else {
if (vg_read_error(vg) == FAILED_INCONSISTENT) { if (vg_read_error(vg) == FAILED_INCONSISTENT) {
log_error("No backup taken: specify filename with -f " log_error("No backup taken: specify filename with -f "
@ -75,10 +71,8 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
/* just use the normal backup code */ /* just use the normal backup code */
backup_enable(cmd, 1); /* force a backup */ backup_enable(cmd, 1); /* force a backup */
if (!backup(vg)) { if (!backup(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
} }
log_print_unless_silent("Volume group \"%s\" successfully backed up.", vg_name); log_print_unless_silent("Volume group \"%s\" successfully backed up.", vg_name);

View File

@ -38,10 +38,9 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
if (!(arg_count(cmd,file_ARG) ? if (!(arg_count(cmd,file_ARG) ?
archive_display_file(cmd, archive_display_file(cmd,
arg_str_value(cmd, file_ARG, "")) : arg_str_value(cmd, file_ARG, "")) :
archive_display(cmd, vg_name))) { archive_display(cmd, vg_name)))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -464,22 +464,16 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
for (i = 0; _vgchange_args[i].arg >= 0; i++) { for (i = 0; _vgchange_args[i].arg >= 0; i++) {
if (arg_count(cmd, _vgchange_args[i].arg)) { if (arg_count(cmd, _vgchange_args[i].arg)) {
if (!archive(vg)) { if (!archive(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED; if (!_vgchange_args[i].fn(cmd, vg))
} return_ECMD_FAILED;
if (!_vgchange_args[i].fn(cmd, vg)) {
stack;
return ECMD_FAILED;
}
} }
} }
if (vg_is_archived(vg)) { if (vg_is_archived(vg)) {
if (!vg_write(vg) || !vg_commit(vg)) { if (!vg_write(vg) || !vg_commit(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
backup(vg); backup(vg);
@ -489,13 +483,13 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (arg_count(cmd, activate_ARG)) { if (arg_count(cmd, activate_ARG)) {
if (!vgchange_activate(cmd, vg, (activation_change_t) if (!vgchange_activate(cmd, vg, (activation_change_t)
arg_uint_value(cmd, activate_ARG, CHANGE_AY))) arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
return ECMD_FAILED; return_ECMD_FAILED;
} }
if (arg_count(cmd, refresh_ARG)) { if (arg_count(cmd, refresh_ARG)) {
/* refreshes the visible LVs (which starts polling) */ /* refreshes the visible LVs (which starts polling) */
if (!_vgchange_refresh(cmd, vg)) if (!_vgchange_refresh(cmd, vg))
return ECMD_FAILED; return_ECMD_FAILED;
} }
if (!arg_count(cmd, activate_ARG) && if (!arg_count(cmd, activate_ARG) &&
@ -503,13 +497,13 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
arg_count(cmd, monitor_ARG)) { arg_count(cmd, monitor_ARG)) {
/* -ay* will have already done monitoring changes */ /* -ay* will have already done monitoring changes */
if (!_vgchange_monitoring(cmd, vg)) if (!_vgchange_monitoring(cmd, vg))
return ECMD_FAILED; return_ECMD_FAILED;
} }
if (!arg_count(cmd, refresh_ARG) && if (!arg_count(cmd, refresh_ARG) &&
background_polling()) background_polling())
if (!_vgchange_background_polling(cmd, vg)) if (!_vgchange_background_polling(cmd, vg))
return ECMD_FAILED; return_ECMD_FAILED;
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -21,15 +21,11 @@ static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
struct volume_group *vg, struct volume_group *vg,
void *handle __attribute__((unused))) void *handle __attribute__((unused)))
{ {
if (!vg_check_status(vg, EXPORTED_VG)) { if (!vg_check_status(vg, EXPORTED_VG))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!vg_validate(vg)) { if (!vg_validate(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (vg_missing_pv_count(vg)) { if (vg_missing_pv_count(vg)) {
log_error("The volume group is missing %d physical volumes.", log_error("The volume group is missing %d physical volumes.",

View File

@ -30,10 +30,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
struct lvinfo info; struct lvinfo info;
int active = 0; int active = 0;
if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG)) { if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (vg->fid->fmt == cmd->fmt) { if (vg->fid->fmt == cmd->fmt) {
log_error("Volume group \"%s\" already uses format %s", log_error("Volume group \"%s\" already uses format %s",
@ -113,10 +111,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
} }
} }
if (active) { if (active)
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
dm_list_iterate_items(pvl, &vg->pvs) { dm_list_iterate_items(pvl, &vg->pvs) {
existing_pv = pvl->pv; existing_pv = pvl->pv;

View File

@ -78,8 +78,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
vg = vg_read_for_update(cmd, vg_name, NULL, 0); vg = vg_read_for_update(cmd, vg_name, NULL, 0);
if (vg_read_error(vg)) { if (vg_read_error(vg)) {
release_vg(vg); release_vg(vg);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
if (!archive(vg)) if (!archive(vg))

View File

@ -46,29 +46,19 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
lock_vg_from_first = 1; lock_vg_from_first = 1;
if (lock_vg_from_first) { if (lock_vg_from_first) {
vg_from = _vgmerge_vg_read(cmd, vg_name_from); if (!(vg_from = _vgmerge_vg_read(cmd, vg_name_from)))
if (!vg_from) { return_ECMD_FAILED;
stack; if (!(vg_to = _vgmerge_vg_read(cmd, vg_name_to))) {
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); unlock_and_release_vg(cmd, vg_from, vg_name_from);
return ECMD_FAILED; return_ECMD_FAILED;
} }
} else { } else {
vg_to = _vgmerge_vg_read(cmd, vg_name_to); if (!(vg_to = _vgmerge_vg_read(cmd, vg_name_to)))
if (!vg_to) { return_ECMD_FAILED;
stack;
return ECMD_FAILED;
}
vg_from = _vgmerge_vg_read(cmd, vg_name_from); if (!(vg_from = _vgmerge_vg_read(cmd, vg_name_from))) {
if (!vg_from) {
stack;
unlock_and_release_vg(cmd, vg_to, vg_name_to); unlock_and_release_vg(cmd, vg_to, vg_name_to);
return ECMD_FAILED; return_ECMD_FAILED;
} }
} }

View File

@ -19,25 +19,19 @@ static int _vgmknodes_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute__((unused))) void *handle __attribute__((unused)))
{ {
if (arg_count(cmd, refresh_ARG) && lv_is_visible(lv)) if (arg_count(cmd, refresh_ARG) && lv_is_visible(lv))
if (!lv_refresh(cmd, lv)) { if (!lv_refresh(cmd, lv))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
if (!lv_mknodes(cmd, lv)) { if (!lv_mknodes(cmd, lv))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
int vgmknodes(struct cmd_context *cmd, int argc, char **argv) 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 ECMD_FAILED;
}
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL, return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
&_vgmknodes_single); &_vgmknodes_single);

View File

@ -22,10 +22,8 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
unsigned lv_count, missing; unsigned lv_count, missing;
force_t force; force_t force;
if (!vg_check_status(vg, EXPORTED_VG)) { if (!vg_check_status(vg, EXPORTED_VG))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
lv_count = vg_visible_lvs(vg); lv_count = vg_visible_lvs(vg);
@ -43,23 +41,17 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED; return ECMD_FAILED;
} }
} }
if (!remove_lvs_in_vg(cmd, vg, force)) { if (!remove_lvs_in_vg(cmd, vg, force))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
} }
if (!force && !vg_remove_check(vg)) { if (!force && !vg_remove_check(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
vg_remove_pvs(vg); vg_remove_pvs(vg);
if (!vg_remove(vg)) { if (!vg_remove(vg))
stack; return_ECMD_FAILED;
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -205,10 +205,8 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE; 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_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -384,11 +384,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
lock_vg_from_first = 0; lock_vg_from_first = 0;
if (lock_vg_from_first) { if (lock_vg_from_first) {
vg_from = _vgsplit_from(cmd, vg_name_from); if (!(vg_from = _vgsplit_from(cmd, vg_name_from)))
if (!vg_from) { return_ECMD_FAILED;
stack;
return ECMD_FAILED;
}
/* /*
* Set metadata format of original VG. * Set metadata format of original VG.
* NOTE: We must set the format before calling vg_create() * NOTE: We must set the format before calling vg_create()
@ -396,23 +393,17 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
*/ */
cmd->fmt = vg_from->fid->fmt; cmd->fmt = vg_from->fid->fmt;
vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg); if (!(vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg))) {
if (!vg_to) {
unlock_and_release_vg(cmd, vg_from, vg_name_from); unlock_and_release_vg(cmd, vg_from, vg_name_from);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
} else { } else {
vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg); if (!(vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg)))
if (!vg_to) { return_ECMD_FAILED;
stack;
return ECMD_FAILED; if (!(vg_from = _vgsplit_from(cmd, vg_name_from))) {
}
vg_from = _vgsplit_from(cmd, vg_name_from);
if (!vg_from) {
unlock_and_release_vg(cmd, vg_to, vg_name_to); unlock_and_release_vg(cmd, vg_to, vg_name_to);
stack; return_ECMD_FAILED;
return ECMD_FAILED;
} }
if (cmd->fmt != vg_from->fid->fmt) { if (cmd->fmt != vg_from->fid->fmt) {