1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Clarify terminology:

VG is resizeable  - PVs can be added or removed
  PV is allocatable - free extents on it may be allocated to LVs
This commit is contained in:
Alasdair Kergon 2002-01-10 15:09:51 +00:00
parent fc63d04f42
commit b80f32dd0a
15 changed files with 62 additions and 56 deletions

View File

@ -107,7 +107,7 @@ void pvdisplay_colons(struct physical_volume *pv)
dev_name(pv->dev), pv->vg_name, pv->size,
/* FIXME pv->pv_number, Derive or remove? */
pv->status, /* FIXME Support old or new format here? */
pv->status & ALLOCATED_PV, /* FIXME Remove? */
pv->status & ALLOCATABLE_PV, /* FIXME remove? */
/* FIXME pv->lv_cur, Remove? */
pv->pe_size / 2,
pv->pe_count,
@ -161,7 +161,7 @@ void pvdisplay_full(struct physical_volume *pv)
(pv->status & ACTIVE) ? "" : "NOT ");
pe_free = pv->pe_count - pv->pe_allocated;
if (pv->pe_count && (pv->status & ALLOCATED_PV))
if (pv->pe_count && (pv->status & ALLOCATABLE_PV))
log_print("Allocatable yes %s",
(!pe_free && pv->pe_count) ? "(but full)" : "");
else
@ -196,7 +196,7 @@ int pvdisplay_short(struct volume_group *vg, struct physical_volume *pv)
/* FIXME pv->pv_number); */
log_print("PV Status %savailable / %sallocatable",
(pv->status & ACTIVE) ? "" : "NOT ",
(pv->status & ALLOCATED_PV) ? "" : "NOT ");
(pv->status & ALLOCATABLE_PV) ? "" : "NOT ");
log_print("Total PE / Free PE %u / %u",
pv->pe_count, pv->pe_count - pv->pe_allocated);
@ -205,7 +205,6 @@ int pvdisplay_short(struct volume_group *vg, struct physical_volume *pv)
}
void lvdisplay_colons(struct logical_volume *lv)
{
int inkernel;
@ -474,7 +473,7 @@ void vgdisplay_full(struct volume_group *vg)
log_print("VG Status %savailable%s/%sresizable",
vg->status & ACTIVE ? "" : "NOT ",
vg->status & EXPORTED_VG ? "/exported" : "",
vg->status & EXTENDABLE_VG ? "" : "NOT ");
vg->status & RESIZEABLE_VG ? "" : "NOT ");
/******* FIXME vg number
log_print ("VG # %u\n", vg->vg_number);
********/

View File

@ -371,7 +371,7 @@ static int _pv_write(struct format_instance *fi, struct physical_volume *pv)
/* Ensure any residual PE structure is gone */
pv->pe_size = pv->pe_count = pv->pe_start = 0;
pv->status &= ~ALLOCATED_PV;
pv->status &= ~ALLOCATABLE_PV;
if (!(mem = pool_create(1024))) {
stack;

View File

@ -52,7 +52,7 @@ int import_pv(struct pool *mem, struct device *dev,
pv->status |= ACTIVE;
if (pvd->pv_allocatable)
pv->status |= ALLOCATED_PV;
pv->status |= ALLOCATABLE_PV;
pv->size = pvd->pv_size;
pv->pe_size = pvd->pe_size;
@ -101,7 +101,7 @@ int export_pv(struct pv_disk *pvd, struct physical_volume *pv)
if (pv->status & ACTIVE)
pvd->pv_status |= PV_ACTIVE;
if (pv->status & ALLOCATED_PV)
if (pv->status & ALLOCATABLE_PV)
pvd->pv_allocatable = PV_ALLOCATABLE;
pvd->pv_size = pv->size;
@ -142,7 +142,7 @@ int import_vg(struct pool *mem,
vg->status |= EXPORTED_VG;
if (vgd->vg_status & VG_EXTENDABLE)
vg->status |= EXTENDABLE_VG;
vg->status |= RESIZEABLE_VG;
if (vgd->vg_access & VG_READ)
vg->status |= LVM_READ;
@ -187,7 +187,7 @@ int export_vg(struct vg_disk *vgd, struct volume_group *vg)
if (vg->status & EXPORTED_VG)
vgd->vg_status |= VG_EXPORTED;
if (vg->status & EXTENDABLE_VG)
if (vg->status & RESIZEABLE_VG)
vgd->vg_status |= VG_EXTENDABLE;
vgd->lv_max = vg->max_lv;

View File

@ -21,7 +21,7 @@ struct flag {
static struct flag _vg_flags[] = {
{ACTIVE, "ACTIVE"},
{EXPORTED_VG, "EXPORTED"},
{EXTENDABLE_VG, "EXTENDABLE"},
{RESIZEABLE_VG, "RESIZEABLE"},
{CLUSTERED, "CLUSTERED"},
{SHARED, "SHARED"},
{0, NULL}
@ -29,7 +29,7 @@ static struct flag _vg_flags[] = {
static struct flag _pv_flags[] = {
{ACTIVE, "ACTIVE"},
{ALLOCATED_PV, "ALLOCATED"},
{ALLOCATABLE_PV, "ALLOCATABLE"},
{0, NULL}
};

View File

@ -39,9 +39,6 @@ int _add_pv_to_vg(struct format_instance *fi, struct volume_group *vg,
return 0;
}
/* FIXME For LVM2, set on PV creation instead of here? */
pv->status |= ALLOCATED_PV;
/* FIXME check this */
pv->exported = NULL;
@ -159,7 +156,7 @@ struct volume_group *vg_create(struct format_instance *fi, const char *vg_name,
goto bad;
}
vg->status = (ACTIVE | EXTENDABLE_VG | LVM_READ | LVM_WRITE);
vg->status = (ACTIVE | RESIZEABLE_VG | LVM_READ | LVM_WRITE);
vg->extent_size = extent_size;
vg->extent_count = 0;
@ -214,7 +211,7 @@ struct physical_volume *pv_create(struct format_instance *fi, const char *name)
*pv->vg_name = 0;
pv->exported = NULL;
pv->status = 0;
pv->status = ALLOCATABLE_PV;
if (!dev_get_size(pv->dev, &pv->size)) {
log_err("Couldn't get size of device '%s'", name);

View File

@ -29,10 +29,10 @@
#define ACTIVE 0x00000001 /* PV VG LV */
#define EXPORTED_VG 0x00000002 /* VG */ /* And PV too perhaps? */
#define EXTENDABLE_VG 0x00000004 /* VG */
#define RESIZEABLE_VG 0x00000004 /* VG */
/* FIXME: What does this mean ? */
#define ALLOCATED_PV 0x00000008 /* PV */
/* May any free extents on this PV be used or must they be left free? */
#define ALLOCATABLE_PV 0x00000008 /* PV */
#define SPINDOWN_LV 0x00000010 /* LV */
#define BADBLOCK_ON 0x00000020 /* LV */

View File

@ -19,6 +19,9 @@ static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
list_iterate(tmp, pvs) {
pv = &(list_item(tmp, struct pv_list)->pv);
if (!(pv->status & ALLOCATABLE_PV))
continue;
if (!(pvm = pool_zalloc(mem, sizeof(*pvm)))) {
stack;
return 0;

View File

@ -4,7 +4,7 @@ pvchange \- change attributes of a physical volume
.SH SYNOPSIS
.B pvchange
[\-A/\-\-autobackup y/n] [\-d/\-\-debug] [\-h/\-?/\-\-help]
[\-v/\-\-verbose] [\-a/\-\-all] [\-x/\-\-allocation y/n] [PhysicalVolumePath...]
[\-v/\-\-verbose] [\-a/\-\-all] [\-x/\-\-allocatable y/n] [PhysicalVolumePath...]
.SH DESCRIPTION
pvchange allows you to change the allocation permissions of one or
more physical volumes.
@ -20,7 +20,7 @@ Controls automatic backup of VG metadata after the change ( see
If PhysicalVolumePath is not specified on the command line all
physical volumes are searched for and used.
.TP
.I \-x, \-\-allocation y/n
.I \-x, \-\-allocatable y/n
Enable or disable allocation of physical extents on this physical volume.
.SH Example
"pvchange -x n /dev/sdk1" disallows the allocation of physical extents

View File

@ -11,7 +11,7 @@ vgchange \- change attributes of a volume group
.IR MaxLogicalVolumes ]
.RB [ \-v | \-\-verbose ]
.RB [ \-\-version ]
.RB [\-x | \-\-allocation " {" y | n }]
.RB [\-x | \-\-resizeable " {" y | n }]
.RI [ VolumeGroupName ...]
.SH DESCRIPTION
.B vgchange
@ -42,7 +42,7 @@ In other words: makes a volume group known/unknown to the kernel.
Changes the maximum logical volume number of an existing inactive
volume group.
.TP
.BR \-x ", " \-\-allocation { y | n }
.BR \-x ", " \-\-resizeable { y | n }
Enables or disables the extension/reduction of this volume group
with/by physical volumes.
.SH EXAMPLES

View File

@ -11,6 +11,10 @@
arg(version_ARG, '\0', "version", NULL)
arg(quiet_ARG, '\0', "quiet", NULL)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
arg(allocation_ARG, '\0', "allocation", yes_no_arg)
/*
* ... and now the short args.
*/
@ -59,7 +63,8 @@ arg(uuid_ARG, 'u', "uuid", NULL)
arg(uuidlist_ARG, 'U', "uuidlist", NULL)
arg(verbose_ARG, 'v', "verbose", NULL)
arg(volumegroup_ARG, 'V', "volumegroup", NULL)
arg(allocation_ARG, 'x', "allocation", yes_no_arg)
arg(allocatable_ARG, 'x', "allocatable", yes_no_arg)
arg(resizeable_ARG, 'x', "resizeable", yes_no_arg)
arg(yes_ARG, 'y', "yes", NULL)
arg(zero_ARG, 'Z', "zero", yes_no_arg)
arg(suspend_ARG, 'z', "suspend", NULL)

View File

@ -248,10 +248,10 @@ xx(pvchange,
"\t[-v/--verbose]\n"
"\t[-a/--all]\n"
"\t[-t|--test]\n"
"\t[-x/--allocation y/n]\n"
"\t[-x/--allocatable y/n]\n"
"\t[PhysicalVolumePath...]\n",
all_ARG, autobackup_ARG, allocation_ARG, test_ARG)
all_ARG, autobackup_ARG, allocatable_ARG, allocation_ARG, test_ARG)
xx(pvcreate,
"Initialize physical volume(s) for use by LVM",
@ -366,11 +366,12 @@ xx(vgchange,
"\t[-v|--verbose] " "\n"
"\t[--version]" "\n"
"\t{-a|--available {y|n} |" "\n"
"\t -x|--allocation {y|n} |" "\n"
"\t -x|--resizeable {y|n} |" "\n"
"\t -l|--logicalvolume MaxLogicalVolumes}" "\n"
"\t[VolumeGroupName...]\n",
autobackup_ARG, available_ARG, logicalvolume_ARG, allocation_ARG,
autobackup_ARG, available_ARG, logicalvolume_ARG,
resizeable_ARG, resizable_ARG, allocation_ARG,
test_ARG)
xx(vgck,

View File

@ -33,7 +33,7 @@ int pvchange(int argc, char **argv)
struct list *pvh, *pvs;
if (arg_count(allocation_ARG) == 0) {
if (arg_count(allocatable_ARG) == 0) {
log_error("Please give the x option");
return EINVALID_CMD_LINE;
}
@ -86,7 +86,7 @@ int pvchange_single(struct physical_volume *pv)
const char *pv_name = dev_name(pv->dev);
int allocation = !strcmp(arg_str_value(allocation_ARG, "n"), "y");
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*/
@ -108,24 +108,24 @@ int pvchange_single(struct physical_volume *pv)
}
/* change allocatability for a PV */
if (allocation && (pv->status & ALLOCATED_PV)) {
if (allocatable && (pv->status & ALLOCATABLE_PV)) {
log_error("Physical volume %s is already allocatable", pv_name);
return 0;
}
if (!allocation && !(pv->status & ALLOCATED_PV)) {
if (!allocatable && !(pv->status & ALLOCATABLE_PV)) {
log_error("Physical volume %s is already unallocatable",
pv_name);
return 0;
}
if (allocation) {
if (allocatable) {
log_verbose("Setting physical volume %s allocatable", pv_name);
pv->status |= ALLOCATED_PV;
pv->status |= ALLOCATABLE_PV;
} else {
log_verbose("Setting physical volume %s NOT allocatable",
pv_name);
pv->status &= ~ALLOCATED_PV;
pv->status &= ~ALLOCATABLE_PV;
}
/******* Ignore active

View File

@ -22,19 +22,19 @@
static int vgchange_single(const char *vg_name);
void vgchange_available(struct volume_group *vg);
void vgchange_allocation(struct volume_group *vg);
void vgchange_resizeable(struct volume_group *vg);
void vgchange_logicalvolume(struct volume_group *vg);
int vgchange(int argc, char **argv)
{
if (!(arg_count(available_ARG) + arg_count(logicalvolume_ARG) +
arg_count(allocation_ARG))) {
arg_count(resizeable_ARG))) {
log_error("One of -a, -l or -x options required");
return EINVALID_CMD_LINE;
}
if (arg_count(available_ARG) + arg_count(logicalvolume_ARG) +
arg_count(allocation_ARG) > 1) {
arg_count(resizeable_ARG) > 1) {
log_error("Only one of -a, -l or -x options allowed");
return EINVALID_CMD_LINE;
}
@ -56,15 +56,16 @@ static int vgchange_single(const char *vg_name)
return ECMD_FAILED;
}
if (vg->status & EXPORTED_VG)
if (vg->status & EXPORTED_VG) {
log_error("Volume group %s is exported", vg_name);
return ECMD_FAILED;
}
if (arg_count(available_ARG))
vgchange_available(vg);
if (arg_count(allocation_ARG))
vgchange_allocation(vg);
if (arg_count(resizeable_ARG))
vgchange_resizeable(vg);
if (arg_count(logicalvolume_ARG))
vgchange_logicalvolume(vg);
@ -131,17 +132,17 @@ void vgchange_available(struct volume_group *vg)
return;
}
void vgchange_allocation(struct volume_group *vg)
void vgchange_resizeable(struct volume_group *vg)
{
int extendable = !strcmp(arg_str_value(allocation_ARG, "n"), "y");
int resizeable = !strcmp(arg_str_value(resizeable_ARG, "n"), "y");
if (extendable && (vg->status & EXTENDABLE_VG)) {
log_error("Volume group %s is already extendable", vg->name);
if (resizeable && (vg->status & RESIZEABLE_VG)) {
log_error("Volume group %s is already resizeable", vg->name);
return;
}
if (!extendable && !(vg->status & EXTENDABLE_VG)) {
log_error("Volume group %s is already not extendable",
if (!resizeable && !(vg->status & RESIZEABLE_VG)) {
log_error("Volume group %s is already not resizeable",
vg->name);
return;
}
@ -149,10 +150,10 @@ void vgchange_allocation(struct volume_group *vg)
if (!archive(vg))
return;
if (extendable)
vg->status |= EXTENDABLE_VG;
if (resizeable)
vg->status |= RESIZEABLE_VG;
else
vg->status &= ~EXTENDABLE_VG;
vg->status &= ~RESIZEABLE_VG;
if (!fid->ops->vg_write(fid, vg))
return;
@ -174,8 +175,8 @@ void vgchange_logicalvolume(struct volume_group *vg)
return;
}
if (!(vg->status & EXTENDABLE_VG)) {
log_error("Volume group '%s' must be extendable "
if (!(vg->status & RESIZEABLE_VG)) {
log_error("Volume group '%s' must be resizeable "
"to change MaxLogicalVolume", vg->name);
return;
}

View File

@ -51,8 +51,8 @@ int vgextend(int argc, char **argv)
log_error("Volume group '%s' is not active.", vg_name);
********/
if (!(vg->status & EXTENDABLE_VG)) {
log_error("Volume group '%s' is not extendable.", vg_name);
if (!(vg->status & RESIZEABLE_VG)) {
log_error("Volume group '%s' is not resizeable.", vg_name);
return ECMD_FAILED;
}

View File

@ -61,7 +61,7 @@ int vgreduce(int argc, char **argv)
}
*******/
if (!(vg->status & EXTENDABLE_VG)) {
if (!(vg->status & RESIZEABLE_VG)) {
log_error("Volume group %s is not reducable", vg_name);
return ECMD_FAILED;
}