mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-23 21:35:29 +03:00
o Basic support for exporting (but importing not completed yet).
o When volume group does not have write flag set, prevent changes to it. o Preparation for partial activation (not completed yet).
This commit is contained in:
parent
f9aa2941cf
commit
6435b49153
@ -257,6 +257,26 @@ static int _read_extents(struct disk_list *data)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If exported, remove "PV_EXP" from end of VG name
|
||||
*/
|
||||
static void _munge_exported_vg(struct disk_list *data)
|
||||
{
|
||||
int l, s;
|
||||
|
||||
/* Return if PV not in a VG or VG not exported */
|
||||
if ((!*data->pvd.vg_name) ||
|
||||
!(data->vgd.vg_status & VG_EXPORTED))
|
||||
return;
|
||||
|
||||
l = strlen(data->pvd.vg_name);
|
||||
s = sizeof(EXPORTED_TAG);
|
||||
if (!strncmp(data->pvd.vg_name + l - s + 1, EXPORTED_TAG, s))
|
||||
data->pvd.vg_name[l - s + 1] = '\0';
|
||||
|
||||
data->pvd.pv_status |= VG_EXPORTED;
|
||||
}
|
||||
|
||||
static struct disk_list *__read_disk(struct device *dev, struct pool *mem,
|
||||
const char *vg_name)
|
||||
{
|
||||
@ -278,21 +298,16 @@ static struct disk_list *__read_disk(struct device *dev, struct pool *mem,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/* Update VG cache with whatever we found */
|
||||
vgcache_add(data->pvd.vg_name, dev);
|
||||
|
||||
/*
|
||||
* is it an orphan ?
|
||||
*/
|
||||
if (!*data->pvd.vg_name) {
|
||||
log_very_verbose("%s is not a member of any VG", name);
|
||||
return (vg_name) ? NULL : data;
|
||||
}
|
||||
|
||||
if (vg_name && strcmp(vg_name, data->pvd.vg_name)) {
|
||||
log_very_verbose("%s is not a member of the VG %s",
|
||||
name, vg_name);
|
||||
goto bad;
|
||||
/* Update VG cache */
|
||||
vgcache_add(data->pvd.vg_name, dev);
|
||||
|
||||
return (vg_name) ? NULL : data;
|
||||
}
|
||||
|
||||
if (!_read_vgd(data)) {
|
||||
@ -300,6 +315,18 @@ static struct disk_list *__read_disk(struct device *dev, struct pool *mem,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/* If VG is exported, set VG name back to the real name */
|
||||
_munge_exported_vg(data);
|
||||
|
||||
/* Update VG cache with what we found */
|
||||
vgcache_add(data->pvd.vg_name, dev);
|
||||
|
||||
if (vg_name && strcmp(vg_name, data->pvd.vg_name)) {
|
||||
log_very_verbose("%s is not a member of the VG %s",
|
||||
name, vg_name);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!_read_uuids(data)) {
|
||||
log_error("Failed to read PV uuid list from %s", name);
|
||||
goto bad;
|
||||
@ -315,7 +342,9 @@ static struct disk_list *__read_disk(struct device *dev, struct pool *mem,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
log_very_verbose("Found %s in VG %s", name, data->pvd.vg_name);
|
||||
log_very_verbose("Found %s in %sVG %s", name,
|
||||
(data->vgd.vg_status & VG_EXPORTED) ? "exported " : "",
|
||||
data->pvd.vg_name);
|
||||
|
||||
return data;
|
||||
|
||||
@ -515,7 +544,7 @@ static int _write_pvd(struct disk_list *data)
|
||||
ulong size = data->pvd.pv_on_disk.size;
|
||||
|
||||
if(size < sizeof(struct pv_disk)) {
|
||||
log_err("Invalid PV size.");
|
||||
log_error("Invalid PV structure size.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,9 @@
|
||||
#define PV_ACTIVE 0x01 /* pv_status */
|
||||
#define PV_ALLOCATABLE 0x02 /* pv_allocatable */
|
||||
|
||||
#define EXPORTED_TAG "PV_EXP" /* Identifier for exported PV */
|
||||
#define IMPORTED_TAG "PV_IMP" /* Identifier for imported PV */
|
||||
|
||||
|
||||
struct data_area {
|
||||
uint32_t base;
|
||||
@ -197,11 +200,14 @@ int write_disks(struct list *pvds);
|
||||
* core structures.
|
||||
*/
|
||||
int import_pv(struct pool *mem, struct device *dev,
|
||||
struct volume_group *vg,
|
||||
struct physical_volume *pv, struct pv_disk *pvd);
|
||||
int export_pv(struct pv_disk *pvd, struct physical_volume *pv);
|
||||
int export_pv(struct pool *mem, struct volume_group *vg,
|
||||
struct pv_disk *pvd, struct physical_volume *pv);
|
||||
|
||||
int import_vg(struct pool *mem,
|
||||
struct volume_group *vg, struct disk_list *dl);
|
||||
struct volume_group *vg, struct disk_list *dl,
|
||||
int partial);
|
||||
int export_vg(struct vg_disk *vgd, struct volume_group *vg);
|
||||
|
||||
int import_lv(struct pool *mem, struct logical_volume *lv,
|
||||
@ -215,8 +221,8 @@ int export_extents(struct disk_list *dl, int lv_num,
|
||||
struct logical_volume *lv,
|
||||
struct physical_volume *pv);
|
||||
|
||||
int import_pvs(struct pool *mem, struct list *pvds,
|
||||
struct list *results, int *count);
|
||||
int import_pvs(struct pool *mem, struct volume_group *vg,
|
||||
struct list *pvds, struct list *results, int *count);
|
||||
|
||||
int import_lvs(struct pool *mem, struct volume_group *vg,
|
||||
struct list *pvds);
|
||||
|
@ -13,34 +13,69 @@
|
||||
#include "display.h"
|
||||
|
||||
/* VG consistency checks */
|
||||
static int _check_vgs(struct list *pvs)
|
||||
static int _check_vgs(struct list *pvs, int *partial)
|
||||
{
|
||||
struct list *pvh;
|
||||
struct list *pvh, *t;
|
||||
struct disk_list *dl = NULL;
|
||||
struct disk_list *first = NULL;
|
||||
|
||||
int pv_count = 0;
|
||||
int exported = -1;
|
||||
|
||||
/* check all the vg's are the same */
|
||||
*partial = 0;
|
||||
|
||||
/*
|
||||
* If there are exported and unexported PVs, ignore exported ones.
|
||||
* This means an active VG won't be affected if disks are inserted
|
||||
* bearing an exported VG with the same name.
|
||||
*/
|
||||
list_iterate(pvh, pvs) {
|
||||
dl = list_item(pvh, struct disk_list);
|
||||
|
||||
if (exported < 0) {
|
||||
exported = dl->pvd.pv_status & VG_EXPORTED;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (exported != (dl->pvd.pv_status & VG_EXPORTED)) {
|
||||
/* Remove exported PVs */
|
||||
list_iterate_safe(pvh, t, pvs) {
|
||||
dl = list_item(pvh, struct disk_list);
|
||||
if (dl->pvd.pv_status & VG_EXPORTED)
|
||||
list_del(pvh);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Remove any PVs with VG structs that differ from the first */
|
||||
list_iterate_safe(pvh, t, pvs) {
|
||||
dl = list_item(pvh, struct disk_list);
|
||||
|
||||
if (!first)
|
||||
first = dl;
|
||||
|
||||
else if (memcmp(&first->vgd, &dl->vgd, sizeof(first->vgd))) {
|
||||
log_error("VG data differs between PVs %s and %s",
|
||||
dev_name(first->dev), dev_name(dl->dev));
|
||||
list_del(pvh);
|
||||
if (partial_mode()) {
|
||||
*partial = 1;
|
||||
continue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
pv_count++;
|
||||
}
|
||||
|
||||
/* On entry to fn, list known to be non-empty */
|
||||
if (!(pv_count == dl->vgd.pv_cur)) {
|
||||
log_error("Only %d out of %d PV(s) found for VG %s",
|
||||
pv_count, dl->vgd.pv_cur, dl->pvd.vg_name);
|
||||
if (pv_count != dl->vgd.pv_cur) {
|
||||
log_error("%d PV(s) found for VG %s: expected %d",
|
||||
pv_count, dl->pvd.vg_name, dl->vgd.pv_cur);
|
||||
if (!partial_mode())
|
||||
return 0;
|
||||
*partial = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -50,6 +85,7 @@ static struct volume_group *_build_vg(struct pool *mem, struct list *pvs)
|
||||
{
|
||||
struct volume_group *vg = pool_alloc(mem, sizeof(*vg));
|
||||
struct disk_list *dl;
|
||||
int partial;
|
||||
|
||||
if (!vg)
|
||||
goto bad;
|
||||
@ -57,20 +93,20 @@ static struct volume_group *_build_vg(struct pool *mem, struct list *pvs)
|
||||
if (list_empty(pvs))
|
||||
goto bad;
|
||||
|
||||
dl = list_item(pvs->n, struct disk_list);
|
||||
|
||||
memset(vg, 0, sizeof(*vg));
|
||||
|
||||
list_init(&vg->pvs);
|
||||
list_init(&vg->lvs);
|
||||
|
||||
if (!_check_vgs(pvs))
|
||||
if (!_check_vgs(pvs, &partial))
|
||||
goto bad;
|
||||
|
||||
if (!import_vg(mem, vg, dl))
|
||||
dl = list_item(pvs->n, struct disk_list);
|
||||
|
||||
if (!import_vg(mem, vg, dl, partial))
|
||||
goto bad;
|
||||
|
||||
if (!import_pvs(mem, pvs, &vg->pvs, &vg->pv_count))
|
||||
if (!import_pvs(mem, vg, pvs, &vg->pvs, &vg->pv_count))
|
||||
goto bad;
|
||||
|
||||
if (!import_lvs(mem, vg, pvs))
|
||||
@ -137,7 +173,7 @@ static struct disk_list *_flatten_pv(struct pool *mem, struct volume_group *vg,
|
||||
list_init(&dl->uuids);
|
||||
list_init(&dl->lvds);
|
||||
|
||||
if (!export_pv(&dl->pvd, pv) ||
|
||||
if (!export_pv(mem, vg, &dl->pvd, pv) ||
|
||||
!export_vg(&dl->vgd, vg) ||
|
||||
!export_uuids(dl, vg) ||
|
||||
!export_lvs(dl, vg, pv, dev_dir) ||
|
||||
@ -191,6 +227,12 @@ static int _vg_write(struct format_instance *fi, struct volume_group *vg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->status & PARTIAL_VG) {
|
||||
log_error("Cannot change metadata for partial volume group %s",
|
||||
vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_init(&pvds);
|
||||
|
||||
r = (_flatten_vg(mem, vg, &pvds, fi->cmd->dev_dir, fi->cmd->filter) &&
|
||||
@ -229,7 +271,7 @@ static struct physical_volume *_pv_read(struct format_instance *fi,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!import_pv(fi->cmd->mem, dl->dev, pv, &dl->pvd)) {
|
||||
if (!import_pv(fi->cmd->mem, dl->dev, NULL, pv, &dl->pvd)) {
|
||||
stack;
|
||||
pool_free(fi->cmd->mem, pv);
|
||||
pv = NULL;
|
||||
@ -265,7 +307,7 @@ static struct list *_get_pvs(struct format_instance *fi)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!import_pvs(fi->cmd->mem, &pvs, results, &count)) {
|
||||
if (!import_pvs(fi->cmd->mem, NULL, &pvs, results, &count)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
@ -396,7 +438,7 @@ static int _pv_write(struct format_instance *fi, struct physical_volume *pv)
|
||||
dl->mem = mem;
|
||||
dl->dev = pv->dev;
|
||||
|
||||
if (!export_pv(&dl->pvd, pv)) {
|
||||
if (!export_pv(mem, NULL, &dl->pvd, pv)) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "hash.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "lvm-string.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
@ -37,6 +38,7 @@ static char *_create_lv_name(struct pool *mem, const char *full_name)
|
||||
}
|
||||
|
||||
int import_pv(struct pool *mem, struct device *dev,
|
||||
struct volume_group *vg,
|
||||
struct physical_volume *pv, struct pv_disk *pvd)
|
||||
{
|
||||
memset(pv, 0, sizeof(*pv));
|
||||
@ -48,6 +50,26 @@ int import_pv(struct pool *mem, struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Store system_id if PV belongs to a VG */
|
||||
if (vg && !vg->system_id &&
|
||||
!(vg->system_id = pool_strdup(mem, pvd->system_id))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg && vg->system_id &&
|
||||
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id)))
|
||||
log_very_verbose("System ID %s on %s differs from %s for "
|
||||
"volume group", pvd->system_id,
|
||||
dev_name(pv->dev), vg->system_id);
|
||||
|
||||
/*
|
||||
* If exported, we still need to flag in pv->status too because
|
||||
* we don't always have a struct volume_group when we need this.
|
||||
*/
|
||||
if (pvd->pv_status & VG_EXPORTED)
|
||||
pv->status |= EXPORTED_VG;
|
||||
|
||||
if (pvd->pv_allocatable)
|
||||
pv->status |= ALLOCATABLE_PV;
|
||||
|
||||
@ -60,7 +82,7 @@ int import_pv(struct pool *mem, struct device *dev,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _system_id(char *system_id)
|
||||
int _system_id(char *s, const char *prefix)
|
||||
{
|
||||
struct utsname uts;
|
||||
|
||||
@ -69,11 +91,17 @@ static int _system_id(char *system_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(system_id, "%s%lu", uts.nodename, time(NULL));
|
||||
if (lvm_snprintf(s, NAME_LEN, "%s%s%lu",
|
||||
prefix, uts.nodename, time(NULL)) < 0) {
|
||||
log_error("Generated system_id too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int export_pv(struct pv_disk *pvd, struct physical_volume *pv)
|
||||
int export_pv(struct pool *mem, struct volume_group *vg,
|
||||
struct pv_disk *pvd, struct physical_volume *pv)
|
||||
{
|
||||
memset(pvd, 0, sizeof(*pvd));
|
||||
|
||||
@ -93,6 +121,54 @@ int export_pv(struct pv_disk *pvd, struct physical_volume *pv)
|
||||
if (pv->vg_name)
|
||||
strncpy(pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
|
||||
|
||||
/* Preserve existing system_id if it exists */
|
||||
if (vg && vg->system_id)
|
||||
strncpy(pvd->system_id, vg->system_id, sizeof(pvd->system_id));
|
||||
|
||||
/* Is VG already exported or being exported? */
|
||||
if (vg && (vg->status & EXPORTED_VG)) {
|
||||
/* Does system_id need setting? */
|
||||
if (!vg->system_id ||
|
||||
strncmp(vg->system_id, EXPORTED_TAG,
|
||||
sizeof(EXPORTED_TAG))) {
|
||||
if (!_system_id(pvd->system_id, EXPORTED_TAG)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (strlen(pvd->vg_name) + sizeof(EXPORTED_TAG) >
|
||||
sizeof(pvd->vg_name)) {
|
||||
log_error("Volume group name %s too long to export",
|
||||
pvd->vg_name);
|
||||
return 0;
|
||||
}
|
||||
strcat(pvd->vg_name, EXPORTED_TAG);
|
||||
}
|
||||
|
||||
/* Is VG being imported? */
|
||||
if (vg && !(vg->status & EXPORTED_VG) && vg->system_id &&
|
||||
!strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG))) {
|
||||
if (!_system_id(pvd->system_id, IMPORTED_TAG)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate system_id if PV is in VG */
|
||||
if (!pvd->system_id || !*pvd->system_id)
|
||||
if (!_system_id(pvd->system_id, "")) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Update internal system_id if we changed it */
|
||||
if (vg &&
|
||||
(!vg->system_id ||
|
||||
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id)))) {
|
||||
if (!(vg->system_id = pool_strdup(mem, pvd->system_id)))
|
||||
log_error("System ID update failed");
|
||||
}
|
||||
|
||||
//pvd->pv_major = MAJOR(pv->dev);
|
||||
|
||||
if (pv->status & ALLOCATABLE_PV)
|
||||
@ -105,16 +181,12 @@ int export_pv(struct pv_disk *pvd, struct physical_volume *pv)
|
||||
pvd->pe_allocated = pv->pe_allocated;
|
||||
pvd->pe_start = pv->pe_start;
|
||||
|
||||
if (!_system_id(pvd->system_id)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int import_vg(struct pool *mem,
|
||||
struct volume_group *vg, struct disk_list *dl)
|
||||
struct volume_group *vg, struct disk_list *dl,
|
||||
int partial)
|
||||
{
|
||||
struct vg_disk *vgd = &dl->vgd;
|
||||
memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
|
||||
@ -135,10 +207,10 @@ int import_vg(struct pool *mem,
|
||||
if (vgd->vg_status & VG_EXTENDABLE)
|
||||
vg->status |= RESIZEABLE_VG;
|
||||
|
||||
if (vgd->vg_access & VG_READ)
|
||||
if (partial || (vgd->vg_access & VG_READ))
|
||||
vg->status |= LVM_READ;
|
||||
|
||||
if (vgd->vg_access & VG_WRITE)
|
||||
if (!partial && (vgd->vg_access & VG_WRITE))
|
||||
vg->status |= LVM_WRITE;
|
||||
|
||||
if (vgd->vg_access & VG_CLUSTERED)
|
||||
@ -152,6 +224,10 @@ int import_vg(struct pool *mem,
|
||||
vg->free_count = vgd->pe_total - vgd->pe_allocated;
|
||||
vg->max_lv = vgd->lv_max;
|
||||
vg->max_pv = vgd->pv_max;
|
||||
|
||||
if (partial)
|
||||
vg->status |= PARTIAL_VG;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -307,8 +383,8 @@ int export_extents(struct disk_list *dl, int lv_num,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int import_pvs(struct pool *mem, struct list *pvds,
|
||||
struct list *results, int *count)
|
||||
int import_pvs(struct pool *mem, struct volume_group *vg,
|
||||
struct list *pvds, struct list *results, int *count)
|
||||
{
|
||||
struct list *pvdh;
|
||||
struct disk_list *dl;
|
||||
@ -325,7 +401,7 @@ int import_pvs(struct pool *mem, struct list *pvds,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!import_pv(mem, dl->dev, pvl->pv, &dl->pvd)) {
|
||||
if (!import_pv(mem, dl->dev, vg, pvl->pv, &dl->pvd)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
@ -349,6 +349,7 @@ int import_extents(struct pool *mem, struct volume_group *vg, struct list *pvds)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* FIXME Support partial activation if (vg->status & PARTIAL_VG) */
|
||||
if (!_check_maps_are_complete(maps)) {
|
||||
stack;
|
||||
goto out;
|
||||
|
@ -201,6 +201,8 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
}
|
||||
|
||||
_out(f, "status = %s", buffer);
|
||||
if (vg->system_id && *vg->system_id)
|
||||
_out(f, "system_id = \"%s\"", vg->system_id);
|
||||
_out_size(f, vg->extent_size, "extent_size = %u", vg->extent_size);
|
||||
_out(f, "max_lv = %u", vg->max_lv);
|
||||
_out(f, "max_pv = %u", vg->max_pv);
|
||||
|
@ -21,6 +21,7 @@ struct flag {
|
||||
static struct flag _vg_flags[] = {
|
||||
{EXPORTED_VG, "EXPORTED"},
|
||||
{RESIZEABLE_VG, "RESIZEABLE"},
|
||||
{PARTIAL_VG, "PARTIAL"},
|
||||
{LVM_READ, "READ"},
|
||||
{LVM_WRITE, "WRITE"},
|
||||
{CLUSTERED, "CLUSTERED"},
|
||||
@ -30,6 +31,7 @@ static struct flag _vg_flags[] = {
|
||||
|
||||
static struct flag _pv_flags[] = {
|
||||
{ALLOCATABLE_PV, "ALLOCATABLE"},
|
||||
{EXPORTED_VG, "EXPORTED"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
@ -117,9 +119,8 @@ int print_flags(uint32_t status, int type, char *buffer, size_t size)
|
||||
return 0;
|
||||
|
||||
if (status)
|
||||
/* FIXME: agk is this the correct log level ? */
|
||||
log_print("Not all flags were successfully exported, "
|
||||
"possible bug.");
|
||||
log_error("Metadata inconsistency: Not all flags successfully "
|
||||
"exported.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ static FILE *_log = 0;
|
||||
|
||||
static int _verbose_level = 0;
|
||||
static int _test = 0;
|
||||
static int _partial = 0;
|
||||
static int _debug_level = 0;
|
||||
static int _syslog = 0;
|
||||
static int _indent = 1;
|
||||
@ -48,6 +49,14 @@ void init_test(int level) {
|
||||
log_print("Test mode. Metadata will NOT be updated.");
|
||||
}
|
||||
|
||||
void init_partial(int level) {
|
||||
_partial = level;
|
||||
if (_partial)
|
||||
log_print("Partial mode. Incomplete volume groups will "
|
||||
"be activated read-only.");
|
||||
|
||||
}
|
||||
|
||||
void init_cmd_name(int status) {
|
||||
_log_cmd_name = status;
|
||||
}
|
||||
@ -72,6 +81,10 @@ int test_mode() {
|
||||
return _test;
|
||||
}
|
||||
|
||||
int partial_mode() {
|
||||
return _partial;
|
||||
}
|
||||
|
||||
void init_debug(int level) {
|
||||
_debug_level = level;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ void fin_syslog(void);
|
||||
|
||||
void init_verbose(int level);
|
||||
void init_test(int level);
|
||||
void init_partial(int level);
|
||||
void init_debug(int level);
|
||||
void init_cmd_name(int status);
|
||||
void init_msg_prefix(const char *prefix);
|
||||
@ -56,6 +57,7 @@ void init_indent(int indent);
|
||||
void set_cmd_name(const char *cmd_name);
|
||||
|
||||
int test_mode(void);
|
||||
int partial_mode(void);
|
||||
int debug_level(void);
|
||||
|
||||
void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
|
@ -39,9 +39,6 @@ int _add_pv_to_vg(struct format_instance *fi, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME check this */
|
||||
pv->exported = NULL;
|
||||
|
||||
if (!(pv->vg_name = pool_strdup(mem, vg->name))) {
|
||||
log_error("vg->name allocation failed for '%s'", pv_name);
|
||||
return 0;
|
||||
@ -132,10 +129,12 @@ struct volume_group *vg_create(struct format_instance *fi, const char *vg_name,
|
||||
}
|
||||
|
||||
/* is this vg name already in use ? */
|
||||
init_partial(1);
|
||||
if (fi->ops->vg_read(fi, vg_name)) {
|
||||
log_err("A volume group called '%s' already exists.", vg_name);
|
||||
goto bad;
|
||||
}
|
||||
init_partial(0);
|
||||
|
||||
if (!id_create(&vg->id)) {
|
||||
log_err("Couldn't create uuid for volume group '%s'.",
|
||||
@ -154,6 +153,7 @@ struct volume_group *vg_create(struct format_instance *fi, const char *vg_name,
|
||||
}
|
||||
|
||||
vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
|
||||
vg->system_id = NULL;
|
||||
|
||||
vg->extent_size = extent_size;
|
||||
vg->extent_count = 0;
|
||||
@ -213,7 +213,6 @@ struct physical_volume *pv_create(struct format_instance *fi,
|
||||
}
|
||||
|
||||
*pv->vg_name = 0;
|
||||
pv->exported = NULL;
|
||||
pv->status = ALLOCATABLE_PV;
|
||||
|
||||
if (!dev_get_size(pv->dev, &pv->size)) {
|
||||
|
@ -27,8 +27,9 @@
|
||||
/* Various flags */
|
||||
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
|
||||
|
||||
#define EXPORTED_VG 0x00000002 /* VG */
|
||||
#define EXPORTED_VG 0x00000002 /* VG PV */
|
||||
#define RESIZEABLE_VG 0x00000004 /* VG */
|
||||
#define PARTIAL_VG 0x00000040 /* VG */
|
||||
|
||||
/* May any free extents on this PV be used or must they be left free? */
|
||||
#define ALLOCATABLE_PV 0x00000008 /* PV */
|
||||
@ -52,14 +53,10 @@
|
||||
#define SNAPSHOT_ORG 0x00020000 /* LV */
|
||||
|
||||
|
||||
#define EXPORTED_TAG "PV_EXP" /* Identifier of exported PV */
|
||||
#define IMPORTED_TAG "PV_IMP" /* Identifier of imported PV */
|
||||
|
||||
struct physical_volume {
|
||||
struct id id;
|
||||
struct device *dev;
|
||||
char *vg_name;
|
||||
char *exported;
|
||||
|
||||
uint32_t status;
|
||||
uint64_t size;
|
||||
@ -78,6 +75,7 @@ struct volume_group {
|
||||
|
||||
struct id id;
|
||||
char *name;
|
||||
char *system_id;
|
||||
|
||||
uint32_t status;
|
||||
|
||||
|
@ -44,6 +44,7 @@ SOURCES=\
|
||||
vgck.c \
|
||||
vgcreate.c \
|
||||
vgdisplay.c \
|
||||
vgexport.c \
|
||||
vgextend.c \
|
||||
vgmerge.c \
|
||||
vgreduce.c \
|
||||
|
@ -51,6 +51,7 @@ arg(nofsck_ARG, 'n', "nofsck", NULL)
|
||||
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL)
|
||||
arg(permission_ARG, 'p', "permission", permission_arg)
|
||||
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg)
|
||||
arg(partial_ARG, 'P', "partial", NULL)
|
||||
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL)
|
||||
arg(readahead_ARG, 'r', "readahead", int_arg)
|
||||
arg(reset_ARG, 'R', "reset", NULL)
|
||||
|
@ -53,13 +53,14 @@ xx(lvchange,
|
||||
"\t[-C/--contiguous y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-P/--partial] " "\n"
|
||||
"\t[-p/--permission r/rw]\n"
|
||||
"\t[-r/--readahead ReadAheadSectors]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||
|
||||
autobackup_ARG, available_ARG, contiguous_ARG,
|
||||
autobackup_ARG, available_ARG, contiguous_ARG, partial_ARG,
|
||||
permission_ARG, readahead_ARG, test_ARG)
|
||||
|
||||
xx(lvcreate,
|
||||
@ -358,6 +359,7 @@ xx(vgchange,
|
||||
"Change volume group attributes",
|
||||
"vgchange" "\n"
|
||||
"\t[-A|--autobackup {y|n}] " "\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-t|--test]" "\n"
|
||||
@ -368,7 +370,7 @@ xx(vgchange,
|
||||
"\t -l|--logicalvolume MaxLogicalVolumes}" "\n"
|
||||
"\t[VolumeGroupName...]\n",
|
||||
|
||||
autobackup_ARG, available_ARG, logicalvolume_ARG,
|
||||
autobackup_ARG, available_ARG, logicalvolume_ARG, partial_ARG,
|
||||
resizeable_ARG, resizable_ARG, allocation_ARG,
|
||||
test_ARG)
|
||||
|
||||
|
@ -47,6 +47,14 @@ static int lvchange_single(struct logical_volume *lv)
|
||||
int doit = 0;
|
||||
int archived = 0;
|
||||
|
||||
if ((lv->vg->status & PARTIAL_VG) &&
|
||||
(arg_count(contiguous_ARG) || arg_count(permission_ARG) ||
|
||||
arg_count(readahead_ARG))) {
|
||||
log_error("Only -a permitted with partial volume group %s",
|
||||
lv->vg->name);
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (lv->status & SNAPSHOT_ORG) {
|
||||
log_error("Can't change logical volume %s under snapshot",
|
||||
lv->name);
|
||||
|
@ -122,6 +122,16 @@ int lvcreate(int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_name && find_lv_in_vg(vg, lv_name)) {
|
||||
log_error("Logical volume %s already exists in "
|
||||
"volume group %s", lv_name, vg_name);
|
||||
|
@ -132,6 +132,8 @@ int main(int argc, char **argv)
|
||||
|
||||
namebase = strdup(argv[0]);
|
||||
base = basename(namebase);
|
||||
while (*base == '/')
|
||||
base++;
|
||||
if (strcmp(base, "lvm"))
|
||||
alias = 1;
|
||||
free(namebase);
|
||||
@ -611,6 +613,11 @@ static int process_common_commands(struct command *com)
|
||||
_current_settings.backup = 1;
|
||||
}
|
||||
|
||||
if (arg_count(partial_ARG))
|
||||
init_partial(1);
|
||||
else
|
||||
init_partial(0);
|
||||
|
||||
/* Handle synonyms */
|
||||
if (!merge_synonym(resizable_ARG, resizeable_ARG) ||
|
||||
!merge_synonym(allocation_ARG, allocatable_ARG) ||
|
||||
|
@ -39,6 +39,11 @@ static int lvremove_single(struct logical_volume *lv)
|
||||
|
||||
vg = lv->vg;
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv->status & SNAPSHOT_ORG) {
|
||||
log_error("Can't remove logical volume %s under snapshot",
|
||||
lv->name);
|
||||
|
@ -90,6 +90,16 @@ int lvrename(int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (find_lv_in_vg(vg, lv_name_new)) {
|
||||
log_error("Logical volume %s already exists in "
|
||||
"volume group %s", lv_name_new, vg_name);
|
||||
|
@ -110,6 +110,16 @@ int lvresize(int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
/* does LV exist? */
|
||||
if (!(lvl = find_lv_in_vg(vg, lv_name))) {
|
||||
log_error("Logical volume %s not found in volume group %s",
|
||||
|
@ -88,8 +88,7 @@ int pvchange_single(struct physical_volume *pv)
|
||||
|
||||
int allocatable = !strcmp(arg_str_value(allocatable_ARG, "n"), "y");
|
||||
|
||||
/* If in a VG, must change using volume group. Pointless. */
|
||||
/* FIXME: Provide a direct pv_write_pv that *only* touches PV structs*/
|
||||
/* If in a VG, must change using volume group. */
|
||||
if (*pv->vg_name) {
|
||||
log_verbose("Finding volume group of physical volume %s",
|
||||
pv_name);
|
||||
@ -97,6 +96,17 @@ int pvchange_single(struct physical_volume *pv)
|
||||
log_error("Unable to find volume group of %s", pv_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
|
||||
log_error("Unable to find %s in volume group %s",
|
||||
pv_name, vg->name);
|
||||
|
@ -150,7 +150,8 @@ void pvscan_display_single(struct physical_volume *pv)
|
||||
/* FIXME As per pv_display! Drop through for now. */
|
||||
/* pv_show(pv); */
|
||||
|
||||
log_print("System Id %s", pv->exported);
|
||||
/* FIXME - Moved to Volume Group structure */
|
||||
/* log_print("System Id %s", pv->vg->system_id); */
|
||||
|
||||
/* log_print(" "); */
|
||||
/* return; */
|
||||
@ -158,7 +159,7 @@ void pvscan_display_single(struct physical_volume *pv)
|
||||
|
||||
memset(pv_tmp_name, 0, sizeof (pv_tmp_name));
|
||||
|
||||
vg_name_len = strlen(pv->vg_name) - sizeof (EXPORTED_TAG) + 1;
|
||||
vg_name_len = strlen(pv->vg_name) + 1;
|
||||
|
||||
if (arg_count(uuid_ARG)) {
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
@ -181,9 +182,9 @@ void pvscan_display_single(struct physical_volume *pv)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(&pv->vg_name[vg_name_len], EXPORTED_TAG) == 0) {
|
||||
if (pv->status & EXPORTED_VG) {
|
||||
strncpy(vg_name_this, pv->vg_name, vg_name_len);
|
||||
log_print("PV %-*s is in EXPORTED VG %s [%s / %s free]",
|
||||
log_print("PV %-*s is in exported VG %s [%s / %s free]",
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_name_this, (s1 =
|
||||
display_size(pv->pe_count *
|
||||
|
@ -10,7 +10,6 @@ int lvmsadc(int argc, char **argv) {return 1;}
|
||||
int lvmsar(int argc, char **argv) {return 1;}
|
||||
int pvdata(int argc, char **argv) {return 1;}
|
||||
int pvmove(int argc, char **argv) {return 1;}
|
||||
int vgexport(int argc, char **argv) {return 1;}
|
||||
int vgimport(int argc, char **argv) {return 1;}
|
||||
int vgmknodes(int argc, char **argv) {return 1;}
|
||||
int vgsplit(int argc, char **argv) {return 1;}
|
||||
|
@ -15,7 +15,7 @@ int check_dir(const char *dir)
|
||||
if (!*dir)
|
||||
return 1;
|
||||
|
||||
if (stat(dir, &info) != -1 ) {
|
||||
if (stat(dir, &info) != -1) {
|
||||
log_error("%s exists", dir);
|
||||
return 0;
|
||||
}
|
||||
@ -30,9 +30,9 @@ int create_dir(const char *dir)
|
||||
if (!*dir)
|
||||
return 1;
|
||||
|
||||
if (stat(dir, &info) < 0 ) {
|
||||
if (stat(dir, &info) < 0) {
|
||||
log_verbose("Creating directory %s", dir);
|
||||
if (!mkdir(dir, 0777));
|
||||
if (!mkdir(dir, 0777))
|
||||
return 1;
|
||||
log_sys_error("mkdir", dir);
|
||||
return 0;
|
||||
@ -45,7 +45,6 @@ int create_dir(const char *dir)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int process_each_lv_in_vg(struct volume_group *vg,
|
||||
int (*process_single) (struct logical_volume *lv))
|
||||
{
|
||||
@ -55,11 +54,11 @@ int process_each_lv_in_vg(struct volume_group *vg,
|
||||
struct list *lvh;
|
||||
struct logical_volume *lv;
|
||||
|
||||
/* FIXME Export-handling */
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
list_iterate(lvh, &vg->lvs) {
|
||||
lv = list_item(lvh, struct lv_list)->lv;
|
||||
ret = process_single(lv);
|
||||
@ -72,7 +71,7 @@ int process_each_lv_in_vg(struct volume_group *vg,
|
||||
}
|
||||
|
||||
int process_each_lv(int argc, char **argv,
|
||||
int (*process_single) (struct logical_volume * lv))
|
||||
int (*process_single) (struct logical_volume *lv))
|
||||
{
|
||||
int opt = 0;
|
||||
int ret_max = 0;
|
||||
@ -107,6 +106,12 @@ int process_each_lv(int argc, char **argv,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported",
|
||||
vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(lvl = find_lv_in_vg(vg, lv_name))) {
|
||||
log_error("Can't find logical volume %s "
|
||||
"in volume group %s",
|
||||
@ -179,8 +184,8 @@ int process_each_vg(int argc, char **argv,
|
||||
}
|
||||
|
||||
int process_each_pv_in_vg(struct volume_group *vg,
|
||||
int (*process_single) (struct volume_group * vg,
|
||||
struct physical_volume * pv))
|
||||
int (*process_single) (struct volume_group *vg,
|
||||
struct physical_volume *pv))
|
||||
{
|
||||
int ret_max = 0;
|
||||
int ret = 0;
|
||||
@ -198,8 +203,8 @@ int process_each_pv_in_vg(struct volume_group *vg,
|
||||
}
|
||||
|
||||
int process_each_pv(int argc, char **argv, struct volume_group *vg,
|
||||
int (*process_single) (struct volume_group * vg,
|
||||
struct physical_volume * pv))
|
||||
int (*process_single) (struct volume_group *vg,
|
||||
struct physical_volume *pv))
|
||||
{
|
||||
int opt = 0;
|
||||
int ret_max = 0;
|
||||
@ -301,8 +306,7 @@ char *default_vgname(struct format_instance *fi)
|
||||
}
|
||||
|
||||
struct list *create_pv_list(struct pool *mem,
|
||||
struct volume_group *vg,
|
||||
int argc, char **argv)
|
||||
struct volume_group *vg, int argc, char **argv)
|
||||
{
|
||||
struct list *r;
|
||||
struct pv_list *pvl, *new_pvl;
|
||||
@ -338,5 +342,5 @@ struct list *create_pv_list(struct pool *mem,
|
||||
list_add(r, &new_pvl->list);
|
||||
}
|
||||
|
||||
return list_empty(r) ? NULL: r;
|
||||
return list_empty(r) ? NULL : r;
|
||||
}
|
||||
|
@ -56,6 +56,11 @@ static int vgchange_single(const char *vg_name)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE) && !arg_count(available_ARG)) {
|
||||
log_error("Volume group %s is read-only", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg_name);
|
||||
return ECMD_FAILED;
|
||||
|
68
tools/vgexport.c
Normal file
68
tools/vgexport.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Sistina Software
|
||||
*
|
||||
* LVM is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* LVM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LVM; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
static int vgexport_single(const char *vg_name);
|
||||
|
||||
int vgexport(int argc, char **argv)
|
||||
{
|
||||
return process_each_vg(argc, argv, &vgexport_single);
|
||||
}
|
||||
|
||||
static int vgexport_single(const char *vg_name)
|
||||
{
|
||||
struct volume_group *vg;
|
||||
|
||||
if (!(vg = fid->ops->vg_read(fid, vg_name))) {
|
||||
log_error("Unable to find volume group %s", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is already exported", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lvs_in_vg_activated(vg)) {
|
||||
log_error("Volume group %s has active logical volumes",
|
||||
vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!archive(vg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
vg->status |= EXPORTED_VG;
|
||||
|
||||
if (!fid->ops->vg_write(fid,vg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
backup(vg);
|
||||
|
||||
log_print("Volume group %s successfully exported", vg->name);
|
||||
|
||||
return 0;
|
||||
}
|
@ -46,6 +46,16 @@ int vgextend(int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group '%s' is not resizeable.", vg_name);
|
||||
return ECMD_FAILED;
|
||||
|
@ -63,12 +63,32 @@ int vgmerge_single(const char *vg_name_to, const char *vg_name_from)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg_to->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg_to->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg_to->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_to->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
log_verbose("Checking for volume group %s", vg_name_from);
|
||||
if (!(vg_from = fid->ops->vg_read(fid, vg_name_from))) {
|
||||
log_error("Volume group %s doesn't exist", vg_name_from);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg_from->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg_from->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg_from->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_from->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if ((active = lvs_in_vg_activated(vg_from))) {
|
||||
log_error("Logical volumes in %s must be inactive",
|
||||
vg_name_from);
|
||||
|
@ -54,6 +54,16 @@ int vgreduce(int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group %s is not reducable", vg_name);
|
||||
return ECMD_FAILED;
|
||||
|
@ -40,6 +40,16 @@ static int vgremove_single(const char *vg_name)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & PARTIAL_VG) {
|
||||
log_error("Cannot remove partial volume group %s", vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->lv_count) {
|
||||
log_error("Volume group %s still contains %d logical volume(s)",
|
||||
vg_name, vg->lv_count);
|
||||
|
@ -73,6 +73,16 @@ int vgrename(int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg_old->status & EXPORTED_VG) {
|
||||
log_error("Volume group %s is exported", vg_old->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg_old->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg_old->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lvs_in_vg_activated(vg_old)) {
|
||||
log_error("Volume group %s still has active LVs", vg_name_old);
|
||||
/***** FIXME Handle this with multiple LV renames!
|
||||
|
@ -50,7 +50,9 @@ static int vgscan_single(const char *vg_name)
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
log_print("Found volume group %s", vg_name);
|
||||
log_print("Found %svolume group %s",
|
||||
(vg->status & EXPORTED_VG) ? "exported " : "",
|
||||
vg_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user