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

Move guts of vgremove into lvm library.

Include archiver.h in metadata.c as a result of prior move.
This commit is contained in:
Dave Wysochanski 2007-08-21 17:38:20 +00:00
parent a50957443e
commit 3769425f6b
4 changed files with 71 additions and 65 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.28 -
================================
Move guts of vgremove into library.
Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.
Move guts of lvremove into library.
Allow clvmd debug to be turned on in a running daemon using clvmd -d

View File

@ -330,6 +330,9 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
uint32_t max_lv, alloc_policy_t alloc,
int pv_count, char **pv_names);
int vg_remove(struct volume_group *vg);
int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
force_t force);
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
const char *new_name);
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);

View File

@ -25,6 +25,7 @@
#include "activate.h"
#include "display.h"
#include "locking.h"
#include "archiver.h"
#include <sys/param.h>
@ -248,6 +249,72 @@ int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
return 1;
}
int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
force_t force)
{
struct physical_volume *pv;
struct pv_list *pvl;
int ret = 1;
if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
log_error("Volume group \"%s\" not found or inconsistent.",
vg_name);
log_error("Consider vgreduce --removemissing if metadata "
"is inconsistent.");
return 0;
}
if (!vg_check_status(vg, EXPORTED_VG))
return 0;
if (vg->lv_count) {
log_error("Volume group \"%s\" still contains %d "
"logical volume(s)", vg_name, vg->lv_count);
return 0;
}
if (!archive(vg))
return 0;
if (!vg_remove(vg)) {
log_error("vg_remove %s failed", vg_name);
return 0;
}
/* init physical volumes */
list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv_dev(pv)), vg_name);
pv->vg_name = ORPHAN;
pv->status = ALLOCATABLE_PV;
if (!dev_get_size(pv_dev(pv), &pv->size)) {
log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
ret = 0;
continue;
}
/* FIXME Write to same sector label was read from */
if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
dev_name(pv_dev(pv)), vg_name);
ret = 0;
}
}
backup_remove(cmd, vg_name);
if (ret)
log_print("Volume group \"%s\" successfully removed", vg_name);
else
log_error("Volume group \"%s\" not properly removed", vg_name);
return ret;
}
int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
{
int i;

View File

@ -15,71 +15,6 @@
#include "tools.h"
static int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
force_t force)
{
struct physical_volume *pv;
struct pv_list *pvl;
int ret = 1;
if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
log_error("Volume group \"%s\" not found or inconsistent.",
vg_name);
log_error("Consider vgreduce --removemissing if metadata "
"is inconsistent.");
return 0;
}
if (!vg_check_status(vg, EXPORTED_VG))
return 0;
if (vg->lv_count) {
log_error("Volume group \"%s\" still contains %d "
"logical volume(s)", vg_name, vg->lv_count);
return 0;
}
if (!archive(vg))
return 0;
if (!vg_remove(vg)) {
log_error("vg_remove %s failed", vg_name);
return 0;
}
/* init physical volumes */
list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv_dev(pv)), vg_name);
pv->vg_name = ORPHAN;
pv->status = ALLOCATABLE_PV;
if (!dev_get_size(pv_dev(pv), &pv->size)) {
log_error("%s: Couldn't get size.", dev_name(pv_dev(pv)));
ret = 0;
continue;
}
/* FIXME Write to same sector label was read from */
if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
dev_name(pv_dev(pv)), vg_name);
ret = 0;
}
}
backup_remove(cmd, vg_name);
if (ret)
log_print("Volume group \"%s\" successfully removed", vg_name);
else
log_error("Volume group \"%s\" not properly removed", vg_name);
return ret;
}
static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
void *handle __attribute((unused)))