summaryrefslogtreecommitdiff
path: root/tools/lvremove.c
diff options
context:
space:
mode:
authorDave Wysochanski <dwysocha@redhat.com>2007-08-20 17:04:53 +0000
committerDave Wysochanski <dwysocha@redhat.com>2007-08-20 17:04:53 +0000
commitcc78b9800d4b3ad7748b05b0f2bcaa4239a09d1d (patch)
tree108465d2554fee04d21a8605d6f8dc4ee4d165a1 /tools/lvremove.c
parent9eb05d9761cde7151c1d07b76b0a92551310e8e3 (diff)
downloadlvm2-cc78b9800d4b3ad7748b05b0f2bcaa4239a09d1d.tar.gz
Move lv_remove_single() into library (lv_manip.c, metadata-exported.h).
Move yes_no_prompt() into library (display.c, display.h). Fixup includes as a result of movement of prior two functions. Fixup force_t enum to be more descriptive.
Diffstat (limited to 'tools/lvremove.c')
-rw-r--r--tools/lvremove.c116
1 files changed, 2 insertions, 114 deletions
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 9dfd1b47f..8d0e1a370 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -15,125 +15,13 @@
#include "tools.h"
-/* TODO: Next checkin, move to lvm library (lv_manip.c, metadata-exported.h) */
-static int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
- force_t force)
-{
- struct volume_group *vg;
- struct lvinfo info;
- struct logical_volume *origin = NULL;
-
- vg = lv->vg;
-
- if (!vg_check_status(vg, LVM_WRITE))
- return 0;
-
- if (lv_is_origin(lv)) {
- log_error("Can't remove logical volume \"%s\" under snapshot",
- lv->name);
- return 0;
- }
-
- if (lv->status & MIRROR_IMAGE) {
- log_error("Can't remove logical volume %s used by a mirror",
- lv->name);
- return 0;
- }
-
- if (lv->status & MIRROR_LOG) {
- log_error("Can't remove logical volume %s used as mirror log",
- lv->name);
- return 0;
- }
-
- if (lv->status & LOCKED) {
- log_error("Can't remove locked LV %s", lv->name);
- return 0;
- }
-
- /* FIXME Ensure not referred to by another existing LVs */
-
- if (lv_info(cmd, lv, &info, 1)) {
- if (info.open_count) {
- log_error("Can't remove open logical volume \"%s\"",
- lv->name);
- return 0;
- }
-
- if (info.exists && (force == DONT_FORCE)) {
- if (yes_no_prompt("Do you really want to remove active "
- "logical volume \"%s\"? [y/n]: ",
- lv->name) == 'n') {
- log_print("Logical volume \"%s\" not removed",
- lv->name);
- return 0;
- }
- }
- }
-
- if (!archive(vg))
- return 0;
-
- /* If the VG is clustered then make sure no-one else is using the LV
- we are about to remove */
- if (vg_status(vg) & CLUSTERED) {
- if (!activate_lv_excl(cmd, lv)) {
- log_error("Can't get exclusive access to volume \"%s\"",
- lv->name);
- return 0;
- }
- }
-
- /* FIXME Snapshot commit out of sequence if it fails after here? */
- if (!deactivate_lv(cmd, lv)) {
- log_error("Unable to deactivate logical volume \"%s\"",
- lv->name);
- return 0;
- }
-
- if (lv_is_cow(lv)) {
- origin = origin_from_cow(lv);
- log_verbose("Removing snapshot %s", lv->name);
- if (!vg_remove_snapshot(lv)) {
- stack;
- return 0;
- }
- }
-
- log_verbose("Releasing logical volume \"%s\"", lv->name);
- if (!lv_remove(lv)) {
- log_error("Error releasing logical volume \"%s\"", lv->name);
- return 0;
- }
-
- /* store it on disks */
- if (!vg_write(vg))
- return 0;
-
- backup(vg);
-
- if (!vg_commit(vg))
- return 0;
-
- /* If no snapshots left, reload without -real. */
- if (origin && !lv_is_origin(origin)) {
- if (!suspend_lv(cmd, origin))
- log_error("Failed to refresh %s without snapshot.", origin->name);
- else if (!resume_lv(cmd, origin))
- log_error("Failed to resume %s.", origin->name);
- }
-
- log_print("Logical volume \"%s\" successfully removed", lv->name);
- return 1;
-}
-
static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute((unused)))
{
if (!lv_remove_single(cmd, lv, arg_count(cmd, force_ARG)))
return ECMD_FAILED;
- else
- return ECMD_PROCESSED;
+
+ return ECMD_PROCESSED;
}
int lvremove(struct cmd_context *cmd, int argc, char **argv)