mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Rename allocation policies; add --alloc to cmdline; LV inherits from VG.
This commit is contained in:
parent
b61702ce8c
commit
a0a23eff4b
@ -1,5 +1,10 @@
|
|||||||
Version 2.00.16 -
|
Version 2.00.16 -
|
||||||
=============================
|
=============================
|
||||||
|
Add --alloc argument to tools.
|
||||||
|
Rename allocation policies to contiguous, normal, anywhere, inherit.
|
||||||
|
nextfree becomes normal; anywhere isn't implemented yet.
|
||||||
|
LV inherits allocation policy from VG. Defaults: LV - inherit; VG - normal
|
||||||
|
Additional status character added to vgs to indicate allocation policy.
|
||||||
Add reset_fn to external_locking.
|
Add reset_fn to external_locking.
|
||||||
Ensure presence of virtual targets before attempting activating.
|
Ensure presence of virtual targets before attempting activating.
|
||||||
Attempt to fix resizing of snapshot origins.
|
Attempt to fix resizing of snapshot origins.
|
||||||
|
@ -27,9 +27,10 @@ static struct {
|
|||||||
const char *str;
|
const char *str;
|
||||||
} _policies[] = {
|
} _policies[] = {
|
||||||
{
|
{
|
||||||
ALLOC_NEXT_FREE, "next free"}, {
|
|
||||||
ALLOC_CONTIGUOUS, "contiguous"}, {
|
ALLOC_CONTIGUOUS, "contiguous"}, {
|
||||||
ALLOC_DEFAULT, "next free (default)"}
|
ALLOC_NORMAL, "normal"}, {
|
||||||
|
ALLOC_ANYWHERE, "anywhere"}, {
|
||||||
|
ALLOC_INHERIT, "inherit"}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int _num_policies = sizeof(_policies) / sizeof(*_policies);
|
static int _num_policies = sizeof(_policies) / sizeof(*_policies);
|
||||||
@ -122,8 +123,12 @@ alloc_policy_t get_alloc_from_string(const char *str)
|
|||||||
if (!strcmp(_policies[i].str, str))
|
if (!strcmp(_policies[i].str, str))
|
||||||
return _policies[i].alloc;
|
return _policies[i].alloc;
|
||||||
|
|
||||||
log_error("Unrecognised allocation policy - using default");
|
/* Special case for old metadata */
|
||||||
return ALLOC_DEFAULT;
|
if(!strcmp("next free", str))
|
||||||
|
return ALLOC_NORMAL;
|
||||||
|
|
||||||
|
log_error("Unrecognised allocation policy %s", str);
|
||||||
|
return ALLOC_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||||
|
@ -237,6 +237,7 @@ int import_vg(struct pool *mem,
|
|||||||
vg->free_count = vgd->pe_total - vgd->pe_allocated;
|
vg->free_count = vgd->pe_total - vgd->pe_allocated;
|
||||||
vg->max_lv = vgd->lv_max;
|
vg->max_lv = vgd->lv_max;
|
||||||
vg->max_pv = vgd->pv_max;
|
vg->max_pv = vgd->pv_max;
|
||||||
|
vg->alloc = ALLOC_NORMAL;
|
||||||
|
|
||||||
if (partial)
|
if (partial)
|
||||||
vg->status |= PARTIAL_VG;
|
vg->status |= PARTIAL_VG;
|
||||||
@ -316,7 +317,7 @@ int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd)
|
|||||||
if (lvd->lv_allocation & LV_CONTIGUOUS)
|
if (lvd->lv_allocation & LV_CONTIGUOUS)
|
||||||
lv->alloc = ALLOC_CONTIGUOUS;
|
lv->alloc = ALLOC_CONTIGUOUS;
|
||||||
else
|
else
|
||||||
lv->alloc = ALLOC_NEXT_FREE;
|
lv->alloc = ALLOC_NORMAL;
|
||||||
|
|
||||||
lv->read_ahead = lvd->lv_read_ahead;
|
lv->read_ahead = lvd->lv_read_ahead;
|
||||||
lv->size = lvd->lv_size;
|
lv->size = lvd->lv_size;
|
||||||
|
@ -307,6 +307,13 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
|||||||
outf(f, "max_lv = %u", vg->max_lv);
|
outf(f, "max_lv = %u", vg->max_lv);
|
||||||
outf(f, "max_pv = %u", vg->max_pv);
|
outf(f, "max_pv = %u", vg->max_pv);
|
||||||
|
|
||||||
|
/* Default policy is NORMAL; INHERIT is meaningless */
|
||||||
|
if (vg->alloc != ALLOC_NORMAL && vg->alloc != ALLOC_INHERIT) {
|
||||||
|
f->nl(f);
|
||||||
|
outf(f, "allocation_policy = \"%s\"",
|
||||||
|
get_alloc_string(vg->alloc));
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,9 +604,10 @@ static int _print_lvs(struct formatter *f, struct volume_group *vg)
|
|||||||
outf(f, "tags = %s", buffer);
|
outf(f, "tags = %s", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lv->alloc != ALLOC_DEFAULT)
|
if (lv->alloc != ALLOC_INHERIT)
|
||||||
outf(f, "allocation_policy = \"%s\"",
|
outf(f, "allocation_policy = \"%s\"",
|
||||||
get_alloc_string(lv->alloc));
|
get_alloc_string(lv->alloc));
|
||||||
|
|
||||||
if (lv->read_ahead)
|
if (lv->read_ahead)
|
||||||
outf(f, "read_ahead = %u", lv->read_ahead);
|
outf(f, "read_ahead = %u", lv->read_ahead);
|
||||||
if (lv->major >= 0)
|
if (lv->major >= 0)
|
||||||
|
@ -490,7 +490,7 @@ static int _read_lvnames(struct format_instance *fid, struct pool *mem,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lv->alloc = ALLOC_DEFAULT;
|
lv->alloc = ALLOC_INHERIT;
|
||||||
if ((cn = find_config_node(lvn, "allocation_policy"))) {
|
if ((cn = find_config_node(lvn, "allocation_policy"))) {
|
||||||
struct config_value *cv = cn->v;
|
struct config_value *cv = cn->v;
|
||||||
if (!cv || !cv->v.str) {
|
if (!cv || !cv->v.str) {
|
||||||
@ -499,6 +499,10 @@ static int _read_lvnames(struct format_instance *fid, struct pool *mem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
lv->alloc = get_alloc_from_string(cv->v.str);
|
lv->alloc = get_alloc_from_string(cv->v.str);
|
||||||
|
if (lv->alloc == ALLOC_INVALID) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read_ahead defaults to 0 */
|
/* read_ahead defaults to 0 */
|
||||||
@ -700,6 +704,21 @@ static struct volume_group *_read_vg(struct format_instance *fid,
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vg->alloc = ALLOC_NORMAL;
|
||||||
|
if ((cn = find_config_node(vgn, "allocation_policy"))) {
|
||||||
|
struct config_value *cv = cn->v;
|
||||||
|
if (!cv || !cv->v.str) {
|
||||||
|
log_error("allocation_policy must be a string.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vg->alloc = get_alloc_from_string(cv->v.str);
|
||||||
|
if (vg->alloc == ALLOC_INVALID) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The pv hash memoises the pv section names -> pv
|
* The pv hash memoises the pv section names -> pv
|
||||||
* structures.
|
* structures.
|
||||||
|
@ -466,6 +466,9 @@ static int _allocate(struct volume_group *vg, struct logical_volume *lv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alloc == ALLOC_INHERIT)
|
||||||
|
alloc = vg->alloc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build the sets of available areas on the pv's.
|
* Build the sets of available areas on the pv's.
|
||||||
*/
|
*/
|
||||||
@ -479,15 +482,16 @@ static int _allocate(struct volume_group *vg, struct logical_volume *lv,
|
|||||||
else if (mirrored_pv)
|
else if (mirrored_pv)
|
||||||
r = _alloc_mirrored(lv, pvms, allocated, segtype, mirrored_pv,
|
r = _alloc_mirrored(lv, pvms, allocated, segtype, mirrored_pv,
|
||||||
mirrored_pe);
|
mirrored_pe);
|
||||||
|
|
||||||
else if (alloc == ALLOC_CONTIGUOUS)
|
else if (alloc == ALLOC_CONTIGUOUS)
|
||||||
r = _alloc_contiguous(lv, pvms, allocated);
|
r = _alloc_contiguous(lv, pvms, allocated);
|
||||||
|
|
||||||
else if (alloc == ALLOC_NEXT_FREE || alloc == ALLOC_DEFAULT)
|
else if (alloc == ALLOC_NORMAL || alloc == ALLOC_ANYWHERE)
|
||||||
r = _alloc_next_free(lv, pvms, allocated);
|
r = _alloc_next_free(lv, pvms, allocated);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
log_error("Unknown allocation policy: "
|
log_error("Unrecognised allocation policy: "
|
||||||
"unable to setup logical volume.");
|
"unable to set up logical volume.");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,8 @@ const char *strip_dir(const char *vg_name, const char *dev_dir)
|
|||||||
|
|
||||||
struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||||
uint32_t extent_size, uint32_t max_pv,
|
uint32_t extent_size, uint32_t max_pv,
|
||||||
uint32_t max_lv, int pv_count, char **pv_names)
|
uint32_t max_lv, alloc_policy_t alloc,
|
||||||
|
int pv_count, char **pv_names)
|
||||||
{
|
{
|
||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
struct pool *mem = cmd->mem;
|
struct pool *mem = cmd->mem;
|
||||||
@ -211,6 +212,8 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
|||||||
vg->max_lv = max_lv;
|
vg->max_lv = max_lv;
|
||||||
vg->max_pv = max_pv;
|
vg->max_pv = max_pv;
|
||||||
|
|
||||||
|
vg->alloc = alloc;
|
||||||
|
|
||||||
vg->pv_count = 0;
|
vg->pv_count = 0;
|
||||||
list_init(&vg->pvs);
|
list_init(&vg->pvs);
|
||||||
|
|
||||||
|
@ -70,9 +70,11 @@
|
|||||||
#define FMT_ORPHAN_ALLOCATABLE 0x00000020 /* Orphan PV allocatable? */
|
#define FMT_ORPHAN_ALLOCATABLE 0x00000020 /* Orphan PV allocatable? */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ALLOC_DEFAULT,
|
ALLOC_INVALID,
|
||||||
ALLOC_NEXT_FREE,
|
ALLOC_INHERIT,
|
||||||
ALLOC_CONTIGUOUS
|
ALLOC_CONTIGUOUS,
|
||||||
|
ALLOC_NORMAL,
|
||||||
|
ALLOC_ANYWHERE
|
||||||
} alloc_policy_t;
|
} alloc_policy_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -167,6 +169,7 @@ struct volume_group {
|
|||||||
char *system_id;
|
char *system_id;
|
||||||
|
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
|
alloc_policy_t alloc;
|
||||||
|
|
||||||
uint32_t extent_size;
|
uint32_t extent_size;
|
||||||
uint32_t extent_count;
|
uint32_t extent_count;
|
||||||
@ -389,7 +392,8 @@ struct physical_volume *pv_create(const struct format_type *fmt,
|
|||||||
|
|
||||||
struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
|
struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
|
||||||
uint32_t extent_size, uint32_t max_pv,
|
uint32_t extent_size, uint32_t max_pv,
|
||||||
uint32_t max_lv, int pv_count, char **pv_names);
|
uint32_t max_lv, alloc_policy_t alloc,
|
||||||
|
int pv_count, char **pv_names);
|
||||||
int vg_remove(struct volume_group *vg);
|
int vg_remove(struct volume_group *vg);
|
||||||
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
|
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
const char *new_name);
|
const char *new_name);
|
||||||
|
@ -45,7 +45,7 @@ FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags")
|
|||||||
FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt")
|
FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt")
|
||||||
FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid")
|
FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid")
|
||||||
FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name")
|
FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name")
|
||||||
FIELD(VGS, vg, STR, "Attr", status, 4, vgstatus, "vg_attr")
|
FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr")
|
||||||
FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size")
|
FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size")
|
||||||
FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free")
|
FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free")
|
||||||
FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid")
|
FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid")
|
||||||
|
@ -98,6 +98,20 @@ struct row {
|
|||||||
struct field *(*sort_fields)[]; /* Fields in sort order */
|
struct field *(*sort_fields)[]; /* Fields in sort order */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char _alloc_policy_char(alloc_policy_t alloc)
|
||||||
|
{
|
||||||
|
switch (alloc) {
|
||||||
|
case ALLOC_CONTIGUOUS:
|
||||||
|
return 'c';
|
||||||
|
case ALLOC_NORMAL:
|
||||||
|
return 'n';
|
||||||
|
case ALLOC_ANYWHERE:
|
||||||
|
return 'a';
|
||||||
|
default:
|
||||||
|
return 'i';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data-munging functions to prepare each data type for display and sorting
|
* Data-munging functions to prepare each data type for display and sorting
|
||||||
*/
|
*/
|
||||||
@ -279,10 +293,7 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
|
|||||||
else
|
else
|
||||||
repstr[1] = 'r';
|
repstr[1] = 'r';
|
||||||
|
|
||||||
if (lv->alloc == ALLOC_CONTIGUOUS)
|
repstr[2] = _alloc_policy_char(lv->alloc);
|
||||||
repstr[2] = 'c';
|
|
||||||
else
|
|
||||||
repstr[2] = 'n';
|
|
||||||
|
|
||||||
if (lv->status & LOCKED)
|
if (lv->status & LOCKED)
|
||||||
repstr[2] = toupper(repstr[2]);
|
repstr[2] = toupper(repstr[2]);
|
||||||
@ -354,34 +365,36 @@ static int _pvstatus_disp(struct report_handle *rh, struct field *field,
|
|||||||
static int _vgstatus_disp(struct report_handle *rh, struct field *field,
|
static int _vgstatus_disp(struct report_handle *rh, struct field *field,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
const uint32_t status = *(const uint32_t *) data;
|
const struct volume_group *vg = (const struct volume_group *) data;
|
||||||
char *repstr;
|
char *repstr;
|
||||||
|
|
||||||
if (!(repstr = pool_zalloc(rh->mem, 5))) {
|
if (!(repstr = pool_zalloc(rh->mem, 6))) {
|
||||||
log_error("pool_alloc failed");
|
log_error("pool_alloc failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status & LVM_WRITE)
|
if (vg->status & LVM_WRITE)
|
||||||
repstr[0] = 'w';
|
repstr[0] = 'w';
|
||||||
else
|
else
|
||||||
repstr[0] = 'r';
|
repstr[0] = 'r';
|
||||||
|
|
||||||
if (status & RESIZEABLE_VG)
|
if (vg->status & RESIZEABLE_VG)
|
||||||
repstr[1] = 'z';
|
repstr[1] = 'z';
|
||||||
else
|
else
|
||||||
repstr[1] = '-';
|
repstr[1] = '-';
|
||||||
|
|
||||||
if (status & EXPORTED_VG)
|
if (vg->status & EXPORTED_VG)
|
||||||
repstr[2] = 'x';
|
repstr[2] = 'x';
|
||||||
else
|
else
|
||||||
repstr[2] = '-';
|
repstr[2] = '-';
|
||||||
|
|
||||||
if (status & PARTIAL_VG)
|
if (vg->status & PARTIAL_VG)
|
||||||
repstr[3] = 'p';
|
repstr[3] = 'p';
|
||||||
else
|
else
|
||||||
repstr[3] = '-';
|
repstr[3] = '-';
|
||||||
|
|
||||||
|
repstr[4] = _alloc_policy_char(vg->alloc);
|
||||||
|
|
||||||
field->report_string = repstr;
|
field->report_string = repstr;
|
||||||
field->sort_value = (const void *) field->report_string;
|
field->sort_value = (const void *) field->report_string;
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ arg(refresh_ARG, '\0', "refresh", NULL)
|
|||||||
arg(mknodes_ARG, '\0', "mknodes", NULL)
|
arg(mknodes_ARG, '\0', "mknodes", NULL)
|
||||||
arg(minor_ARG, '\0', "minor", minor_arg)
|
arg(minor_ARG, '\0', "minor", minor_arg)
|
||||||
arg(type_ARG, '\0', "type", segtype_arg)
|
arg(type_ARG, '\0', "type", segtype_arg)
|
||||||
|
arg(alloc_ARG, '\0', "alloc", alloc_arg)
|
||||||
|
|
||||||
/* Allow some variations */
|
/* Allow some variations */
|
||||||
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
|
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
|
||||||
|
@ -52,6 +52,7 @@ xx(lvchange,
|
|||||||
"\t[-A|--autobackup y|n]\n"
|
"\t[-A|--autobackup y|n]\n"
|
||||||
"\t[-a|--available y|n]\n"
|
"\t[-a|--available y|n]\n"
|
||||||
"\t[--addtag Tag]\n"
|
"\t[--addtag Tag]\n"
|
||||||
|
"\t[--alloc AllocationType]\n"
|
||||||
"\t[-C|--contiguous y|n]\n"
|
"\t[-C|--contiguous y|n]\n"
|
||||||
"\t[-d|--debug]\n"
|
"\t[-d|--debug]\n"
|
||||||
"\t[--deltag Tag]\n"
|
"\t[--deltag Tag]\n"
|
||||||
@ -68,7 +69,7 @@ xx(lvchange,
|
|||||||
"\t[--version]" "\n"
|
"\t[--version]" "\n"
|
||||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||||
|
|
||||||
autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
|
alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
|
||||||
ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG,
|
ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG,
|
||||||
persistent_ARG, readahead_ARG, refresh_ARG, addtag_ARG, deltag_ARG,
|
persistent_ARG, readahead_ARG, refresh_ARG, addtag_ARG, deltag_ARG,
|
||||||
test_ARG)
|
test_ARG)
|
||||||
@ -78,6 +79,7 @@ xx(lvcreate,
|
|||||||
"lvcreate " "\n"
|
"lvcreate " "\n"
|
||||||
"\t[-A|--autobackup {y|n}]\n"
|
"\t[-A|--autobackup {y|n}]\n"
|
||||||
"\t[--addtag Tag]\n"
|
"\t[--addtag Tag]\n"
|
||||||
|
"\t[--alloc AllocationType]\n"
|
||||||
"\t[-C|--contiguous {y|n}]\n"
|
"\t[-C|--contiguous {y|n}]\n"
|
||||||
"\t[-d|--debug]\n"
|
"\t[-d|--debug]\n"
|
||||||
"\t[-h|-?|--help]\n"
|
"\t[-h|-?|--help]\n"
|
||||||
@ -99,6 +101,7 @@ xx(lvcreate,
|
|||||||
"\t[-c|--chunksize]\n"
|
"\t[-c|--chunksize]\n"
|
||||||
"\t[-A|--autobackup {y|n}]\n"
|
"\t[-A|--autobackup {y|n}]\n"
|
||||||
"\t[--addtag Tag]\n"
|
"\t[--addtag Tag]\n"
|
||||||
|
"\t[--alloc AllocationType]\n"
|
||||||
"\t[-C|--contiguous {y|n}]\n"
|
"\t[-C|--contiguous {y|n}]\n"
|
||||||
"\t[-d|--debug]\n"
|
"\t[-d|--debug]\n"
|
||||||
"\t[-h|-?|--help]\n"
|
"\t[-h|-?|--help]\n"
|
||||||
@ -114,10 +117,10 @@ xx(lvcreate,
|
|||||||
"\t[--version]\n"
|
"\t[--version]\n"
|
||||||
"\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
|
"\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
|
||||||
|
|
||||||
autobackup_ARG, chunksize_ARG, contiguous_ARG, extents_ARG, major_ARG,
|
addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
|
||||||
minor_ARG, name_ARG, permission_ARG, persistent_ARG, readahead_ARG, size_ARG,
|
extents_ARG, major_ARG, minor_ARG, name_ARG, permission_ARG,
|
||||||
snapshot_ARG, stripes_ARG, stripesize_ARG, addtag_ARG, test_ARG, type_ARG,
|
persistent_ARG, readahead_ARG, size_ARG, snapshot_ARG, stripes_ARG,
|
||||||
zero_ARG)
|
stripesize_ARG, test_ARG, type_ARG, zero_ARG)
|
||||||
|
|
||||||
xx(lvdisplay,
|
xx(lvdisplay,
|
||||||
"Display information about a logical volume",
|
"Display information about a logical volume",
|
||||||
@ -160,6 +163,7 @@ xx(lvextend,
|
|||||||
"Add space to a logical volume",
|
"Add space to a logical volume",
|
||||||
"lvextend\n"
|
"lvextend\n"
|
||||||
"\t[-A|--autobackup y|n]\n"
|
"\t[-A|--autobackup y|n]\n"
|
||||||
|
"\t[--alloc AllocationType]\n"
|
||||||
"\t[-d|--debug]\n"
|
"\t[-d|--debug]\n"
|
||||||
"\t[-h|--help]\n"
|
"\t[-h|--help]\n"
|
||||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||||
@ -171,7 +175,7 @@ xx(lvextend,
|
|||||||
"\t[--version]" "\n"
|
"\t[--version]" "\n"
|
||||||
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
||||||
|
|
||||||
autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
|
alloc_ARG, autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
|
||||||
stripesize_ARG, test_ARG, type_ARG)
|
stripesize_ARG, test_ARG, type_ARG)
|
||||||
|
|
||||||
xx(lvmchange,
|
xx(lvmchange,
|
||||||
@ -266,6 +270,7 @@ xx(lvresize,
|
|||||||
"Resize a logical volume",
|
"Resize a logical volume",
|
||||||
"lvresize\n"
|
"lvresize\n"
|
||||||
"\t[-A|--autobackup y|n]\n"
|
"\t[-A|--autobackup y|n]\n"
|
||||||
|
"\t[--alloc AllocationType]\n"
|
||||||
"\t[-d|--debug]\n"
|
"\t[-d|--debug]\n"
|
||||||
"\t[-h|--help]\n"
|
"\t[-h|--help]\n"
|
||||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||||
@ -277,8 +282,8 @@ xx(lvresize,
|
|||||||
"\t[--version]" "\n"
|
"\t[--version]" "\n"
|
||||||
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
||||||
|
|
||||||
autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG,
|
alloc_ARG, autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
|
||||||
test_ARG, type_ARG)
|
stripesize_ARG, test_ARG, type_ARG)
|
||||||
|
|
||||||
xx(lvs,
|
xx(lvs,
|
||||||
"Display information about logical volumes",
|
"Display information about logical volumes",
|
||||||
@ -536,6 +541,7 @@ xx(vgchange,
|
|||||||
"Change volume group attributes",
|
"Change volume group attributes",
|
||||||
"vgchange" "\n"
|
"vgchange" "\n"
|
||||||
"\t[-A|--autobackup {y|n}] " "\n"
|
"\t[-A|--autobackup {y|n}] " "\n"
|
||||||
|
"\t[--alloc AllocationType] " "\n"
|
||||||
"\t[-P|--partial] " "\n"
|
"\t[-P|--partial] " "\n"
|
||||||
"\t[-d|--debug] " "\n"
|
"\t[-d|--debug] " "\n"
|
||||||
"\t[-h|--help] " "\n"
|
"\t[-h|--help] " "\n"
|
||||||
@ -551,9 +557,9 @@ xx(vgchange,
|
|||||||
"\t --deltag Tag}\n"
|
"\t --deltag Tag}\n"
|
||||||
"\t[VolumeGroupName...]\n",
|
"\t[VolumeGroupName...]\n",
|
||||||
|
|
||||||
allocation_ARG, autobackup_ARG, available_ARG, ignorelockingfailure_ARG,
|
addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG,
|
||||||
logicalvolume_ARG, partial_ARG, resizeable_ARG, resizable_ARG, deltag_ARG,
|
deltag_ARG, ignorelockingfailure_ARG, logicalvolume_ARG, partial_ARG,
|
||||||
addtag_ARG, test_ARG, uuid_ARG)
|
resizeable_ARG, resizable_ARG, test_ARG, uuid_ARG)
|
||||||
|
|
||||||
xx(vgck,
|
xx(vgck,
|
||||||
"Check the consistency of volume group(s)",
|
"Check the consistency of volume group(s)",
|
||||||
@ -586,6 +592,7 @@ xx(vgcreate,
|
|||||||
"vgcreate" "\n"
|
"vgcreate" "\n"
|
||||||
"\t[-A|--autobackup {y|n}] " "\n"
|
"\t[-A|--autobackup {y|n}] " "\n"
|
||||||
"\t[--addtag Tag] " "\n"
|
"\t[--addtag Tag] " "\n"
|
||||||
|
"\t[--alloc AllocationType] " "\n"
|
||||||
"\t[-d|--debug]" "\n"
|
"\t[-d|--debug]" "\n"
|
||||||
"\t[-h|--help]" "\n"
|
"\t[-h|--help]" "\n"
|
||||||
"\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n"
|
"\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n"
|
||||||
@ -597,8 +604,8 @@ xx(vgcreate,
|
|||||||
"\t[--version] " "\n"
|
"\t[--version] " "\n"
|
||||||
"\tVolumeGroupName PhysicalVolume [PhysicalVolume...]\n",
|
"\tVolumeGroupName PhysicalVolume [PhysicalVolume...]\n",
|
||||||
|
|
||||||
autobackup_ARG, maxlogicalvolumes_ARG, maxphysicalvolumes_ARG,
|
addtag_ARG, alloc_ARG, autobackup_ARG, maxlogicalvolumes_ARG,
|
||||||
metadatatype_ARG, physicalextentsize_ARG, addtag_ARG, test_ARG)
|
maxphysicalvolumes_ARG, metadatatype_ARG, physicalextentsize_ARG, test_ARG)
|
||||||
|
|
||||||
xx(vgdisplay,
|
xx(vgdisplay,
|
||||||
"Display volume group information",
|
"Display volume group information",
|
||||||
|
@ -117,45 +117,30 @@ static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_contiguous(struct cmd_context *cmd,
|
static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
|
||||||
struct logical_volume *lv)
|
|
||||||
{
|
{
|
||||||
int want_contiguous = 0;
|
int want_contiguous = 0;
|
||||||
|
alloc_policy_t alloc;
|
||||||
|
|
||||||
if (strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n"))
|
want_contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
|
||||||
want_contiguous = 1;
|
alloc = want_contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
||||||
|
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, alloc);
|
||||||
|
|
||||||
if (want_contiguous && lv->alloc == ALLOC_CONTIGUOUS) {
|
if (alloc == lv->alloc) {
|
||||||
log_error("Allocation policy of logical volume \"%s\" is "
|
log_error("Allocation policy of logical volume \"%s\" is "
|
||||||
"already contiguous", lv->name);
|
"already %s", lv->name, get_alloc_string(alloc));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!want_contiguous && lv->alloc != ALLOC_CONTIGUOUS) {
|
lv->alloc = alloc;
|
||||||
log_error
|
|
||||||
("Allocation policy of logical volume \"%s\" is already"
|
|
||||||
" not contiguous", lv->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******** FIXME lv_check_contiguous?
|
/* FIXME If contiguous, check existing extents already are */
|
||||||
if (want_contiguous)
|
|
||||||
&& (ret = lv_check_contiguous(vg, lv_index + 1)) == FALSE) {
|
|
||||||
log_error("No contiguous logical volume \"%s\"", lv->name);
|
|
||||||
return 0;
|
|
||||||
*********/
|
|
||||||
|
|
||||||
if (want_contiguous) {
|
log_verbose("Setting contiguous allocation policy for \"%s\" to %s",
|
||||||
lv->alloc = ALLOC_CONTIGUOUS;
|
lv->name, get_alloc_string(alloc));
|
||||||
log_verbose("Setting contiguous allocation policy for \"%s\"",
|
|
||||||
lv->name);
|
|
||||||
} else {
|
|
||||||
lv->alloc = ALLOC_DEFAULT;
|
|
||||||
log_verbose("Reverting to default allocation policy for \"%s\"",
|
|
||||||
lv->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||||
|
|
||||||
if (!vg_write(lv->vg)) {
|
if (!vg_write(lv->vg)) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
@ -170,7 +155,6 @@ static int lvchange_contiguous(struct cmd_context *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_readahead(struct cmd_context *cmd,
|
static int lvchange_readahead(struct cmd_context *cmd,
|
||||||
@ -365,7 +349,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
|
|
||||||
if (!(lv->vg->status & LVM_WRITE) &&
|
if (!(lv->vg->status & LVM_WRITE) &&
|
||||||
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
||||||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG))) {
|
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
|
||||||
|
arg_count(cmd, alloc_ARG))) {
|
||||||
log_error("Only -a permitted with read-only volume "
|
log_error("Only -a permitted with read-only volume "
|
||||||
"group \"%s\"", lv->vg->name);
|
"group \"%s\"", lv->vg->name);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
@ -373,7 +358,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
|
|
||||||
if (lv_is_origin(lv) &&
|
if (lv_is_origin(lv) &&
|
||||||
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
||||||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG))) {
|
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
|
||||||
|
arg_count(cmd, alloc_ARG))) {
|
||||||
log_error("Can't change logical volume \"%s\" under snapshot",
|
log_error("Can't change logical volume \"%s\" under snapshot",
|
||||||
lv->name);
|
lv->name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
@ -401,11 +387,11 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocation policy change */
|
/* allocation policy change */
|
||||||
if (arg_count(cmd, contiguous_ARG)) {
|
if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) {
|
||||||
if (!archived && !archive(lv->vg))
|
if (!archived && !archive(lv->vg))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
archived = 1;
|
archived = 1;
|
||||||
doit += lvchange_contiguous(cmd, lv);
|
doit += lvchange_alloc(cmd, lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read ahead sector change */
|
/* read ahead sector change */
|
||||||
@ -461,9 +447,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
&& !arg_count(cmd, permission_ARG) && !arg_count(cmd, readahead_ARG)
|
&& !arg_count(cmd, permission_ARG) && !arg_count(cmd, readahead_ARG)
|
||||||
&& !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG)
|
&& !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG)
|
||||||
&& !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG)
|
&& !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG)
|
||||||
&& !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)) {
|
&& !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)
|
||||||
|
&& !arg_count(cmd, alloc_ARG)) {
|
||||||
log_error("One or more of -a, -C, -j, -m, -M, -p, -r, "
|
log_error("One or more of -a, -C, -j, -m, -M, -p, -r, "
|
||||||
"--refresh, --addtag or --deltag required");
|
"--refresh, --alloc, --addtag or --deltag required");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +458,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
||||||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
|
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
|
||||||
arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) ||
|
arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) ||
|
||||||
arg_count(cmd, refresh_ARG))) {
|
arg_count(cmd, refresh_ARG) || arg_count(cmd, alloc_ARG))) {
|
||||||
log_error("Only -a permitted with --ignorelockingfailure");
|
log_error("Only -a permitted with --ignorelockingfailure");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
@ -492,6 +479,11 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg_count(cmd, contiguous_ARG) && arg_count(cmd, alloc_ARG)) {
|
||||||
|
log_error("Only one of --alloc and --contiguous permitted");
|
||||||
|
return EINVALID_CMD_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
|
return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
|
||||||
&lvchange_single);
|
&lvchange_single);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ struct lvcreate_params {
|
|||||||
/* flags */
|
/* flags */
|
||||||
int snapshot;
|
int snapshot;
|
||||||
int zero;
|
int zero;
|
||||||
int contiguous;
|
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
|
|
||||||
@ -43,6 +42,7 @@ struct lvcreate_params {
|
|||||||
|
|
||||||
uint32_t permission;
|
uint32_t permission;
|
||||||
uint32_t read_ahead;
|
uint32_t read_ahead;
|
||||||
|
alloc_policy_t alloc;
|
||||||
|
|
||||||
int pv_count;
|
int pv_count;
|
||||||
char **pvs;
|
char **pvs;
|
||||||
@ -217,6 +217,8 @@ static int _read_stripe_params(struct lvcreate_params *lp,
|
|||||||
static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||||
int argc, char **argv)
|
int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int contiguous;
|
||||||
|
|
||||||
memset(lp, 0, sizeof(*lp));
|
memset(lp, 0, sizeof(*lp));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -269,9 +271,18 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
|||||||
lp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
lp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Contiguous ?
|
* Alloc policy
|
||||||
*/
|
*/
|
||||||
lp->contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
|
contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
|
||||||
|
|
||||||
|
lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
|
||||||
|
|
||||||
|
lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lp->alloc);
|
||||||
|
|
||||||
|
if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) {
|
||||||
|
log_error("Conflicting contiguous and alloc arguments");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read ahead.
|
* Read ahead.
|
||||||
@ -365,16 +376,12 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
|||||||
uint32_t size_rest;
|
uint32_t size_rest;
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
uint64_t tmp_size;
|
uint64_t tmp_size;
|
||||||
alloc_policy_t alloc = ALLOC_DEFAULT;
|
|
||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
struct logical_volume *lv, *org = NULL;
|
struct logical_volume *lv, *org = NULL;
|
||||||
struct list *pvh;
|
struct list *pvh;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
int consistent = 1;
|
int consistent = 1;
|
||||||
|
|
||||||
if (lp->contiguous)
|
|
||||||
alloc = ALLOC_CONTIGUOUS;
|
|
||||||
|
|
||||||
status |= lp->permission | VISIBLE_LV;
|
status |= lp->permission | VISIBLE_LV;
|
||||||
|
|
||||||
/* does VG exist? */
|
/* does VG exist? */
|
||||||
@ -487,13 +494,13 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(lv = lv_create_empty(vg->fid, lp->lv_name, "lvol%d",
|
if (!(lv = lv_create_empty(vg->fid, lp->lv_name, "lvol%d",
|
||||||
status, alloc, vg))) {
|
status, lp->alloc, vg))) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes, lp->stripe_size,
|
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes, lp->stripe_size,
|
||||||
lp->mirrors, lp->extents, NULL, 0u, 0u, pvh, alloc)) {
|
lp->mirrors, lp->extents, NULL, 0u, 0u, pvh, lp->alloc)) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,21 @@ int permission_arg(struct cmd_context *cmd, struct arg *a)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int alloc_arg(struct cmd_context *cmd, struct arg *a)
|
||||||
|
{
|
||||||
|
alloc_policy_t alloc;
|
||||||
|
|
||||||
|
a->sign = SIGN_NONE;
|
||||||
|
|
||||||
|
alloc = get_alloc_from_string(a->value);
|
||||||
|
if (alloc == ALLOC_INVALID)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
a->ui_value = (uint32_t) alloc;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int segtype_arg(struct cmd_context *cmd, struct arg *a)
|
int segtype_arg(struct cmd_context *cmd, struct arg *a)
|
||||||
{
|
{
|
||||||
if (!(a->ptr = (void *) get_segtype_from_string(cmd, a->value)))
|
if (!(a->ptr = (void *) get_segtype_from_string(cmd, a->value)))
|
||||||
|
@ -115,6 +115,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
|||||||
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
|
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
|
||||||
uint32_t extents_used = 0;
|
uint32_t extents_used = 0;
|
||||||
uint32_t size_rest;
|
uint32_t size_rest;
|
||||||
|
alloc_policy_t alloc;
|
||||||
char *lock_lvid;
|
char *lock_lvid;
|
||||||
struct lv_list *lvl;
|
struct lv_list *lvl;
|
||||||
int consistent = 1;
|
int consistent = 1;
|
||||||
@ -170,6 +171,8 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lv->alloc);
|
||||||
|
|
||||||
if (lp->size) {
|
if (lp->size) {
|
||||||
if (lp->size % vg->extent_size) {
|
if (lp->size % vg->extent_size) {
|
||||||
if (lp->sign == SIGN_MINUS)
|
if (lp->sign == SIGN_MINUS)
|
||||||
@ -393,7 +396,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
|
|||||||
|
|
||||||
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes,
|
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes,
|
||||||
lp->stripe_size, 0u, lp->extents - lv->le_count,
|
lp->stripe_size, 0u, lp->extents - lv->le_count,
|
||||||
NULL, 0u, 0u, lp->pvh, lv->alloc)) {
|
NULL, 0u, 0u, lp->pvh, alloc)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,7 @@ int permission_arg(struct cmd_context *cmd, struct arg *a);
|
|||||||
int metadatatype_arg(struct cmd_context *cmd, struct arg *a);
|
int metadatatype_arg(struct cmd_context *cmd, struct arg *a);
|
||||||
int units_arg(struct cmd_context *cmd, struct arg *a);
|
int units_arg(struct cmd_context *cmd, struct arg *a);
|
||||||
int segtype_arg(struct cmd_context *cmd, struct arg *a);
|
int segtype_arg(struct cmd_context *cmd, struct arg *a);
|
||||||
|
int alloc_arg(struct cmd_context *cmd, struct arg *a);
|
||||||
|
|
||||||
char yes_no_prompt(const char *prompt, ...);
|
char yes_no_prompt(const char *prompt, ...);
|
||||||
|
|
||||||
|
@ -86,6 +86,40 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
return ECMD_PROCESSED;
|
return ECMD_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
|
||||||
|
{
|
||||||
|
alloc_policy_t alloc;
|
||||||
|
|
||||||
|
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
|
||||||
|
|
||||||
|
if (alloc == ALLOC_INHERIT) {
|
||||||
|
log_error("Volume Group allocation policy cannot inherit "
|
||||||
|
"from anything");
|
||||||
|
return EINVALID_CMD_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alloc == vg->alloc) {
|
||||||
|
log_error("Volume group allocation policy is already %s",
|
||||||
|
get_alloc_string(vg->alloc));
|
||||||
|
return ECMD_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!archive(vg))
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
|
vg->alloc = alloc;
|
||||||
|
|
||||||
|
if (!vg_write(vg) || !vg_commit(vg))
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
|
backup(vg);
|
||||||
|
|
||||||
|
log_print("Volume group \"%s\" successfully changed", vg->name);
|
||||||
|
|
||||||
|
return ECMD_PROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _vgchange_resizeable(struct cmd_context *cmd,
|
static int _vgchange_resizeable(struct cmd_context *cmd,
|
||||||
struct volume_group *vg)
|
struct volume_group *vg)
|
||||||
{
|
{
|
||||||
@ -280,6 +314,9 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
|
|||||||
else if (arg_count(cmd, uuid_ARG))
|
else if (arg_count(cmd, uuid_ARG))
|
||||||
r = _vgchange_uuid(cmd, vg);
|
r = _vgchange_uuid(cmd, vg);
|
||||||
|
|
||||||
|
else if (arg_count(cmd, alloc_ARG))
|
||||||
|
r = _vgchange_alloc(cmd, vg);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,17 +325,20 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if (!
|
if (!
|
||||||
(arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
(arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
||||||
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
|
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
|
||||||
arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG))) {
|
arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG) +
|
||||||
log_error("One of -a, -l, -x, --addtag, --deltag or --uuid "
|
arg_count(cmd, alloc_ARG))) {
|
||||||
"options required");
|
log_error("One of -a, -l, -x, --alloc, --addtag, --deltag "
|
||||||
|
"or --uuid required");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME Cope with several changes at once! */
|
||||||
if (arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
if (arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
||||||
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
|
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
|
||||||
arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG) > 1) {
|
arg_count(cmd, addtag_ARG) + arg_count(cmd, alloc_ARG) +
|
||||||
log_error("Only one of -a, -l, -x, --addtag, --deltag or --uuid"
|
arg_count(cmd, uuid_ARG) > 1) {
|
||||||
" options allowed");
|
log_error("Only one of -a, -l, -x, --alloc, --addtag, --deltag "
|
||||||
|
"or --uuid allowed");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
char vg_path[PATH_MAX];
|
char vg_path[PATH_MAX];
|
||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
|
alloc_policy_t alloc;
|
||||||
|
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
log_error("Please provide volume group name and "
|
log_error("Please provide volume group name and "
|
||||||
@ -40,6 +41,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
vg_name = argv[0];
|
vg_name = argv[0];
|
||||||
max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, 0);
|
max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, 0);
|
||||||
max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
|
max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
|
||||||
|
alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
|
||||||
|
|
||||||
|
if (alloc == ALLOC_INHERIT) {
|
||||||
|
log_error("Volume Group allocation policy cannot inherit "
|
||||||
|
"from anything");
|
||||||
|
return EINVALID_CMD_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(cmd->fmt->features & FMT_UNLIMITED_VOLS)) {
|
if (!(cmd->fmt->features & FMT_UNLIMITED_VOLS)) {
|
||||||
if (!max_lv)
|
if (!max_lv)
|
||||||
@ -92,7 +100,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create the new VG */
|
/* Create the new VG */
|
||||||
if (!(vg = vg_create(cmd, vg_name, extent_size, max_pv, max_lv,
|
if (!(vg = vg_create(cmd, vg_name, extent_size, max_pv, max_lv, alloc,
|
||||||
argc - 1, argv + 1)))
|
argc - 1, argv + 1)))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
|
||||||
|
@ -215,7 +215,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
/* Create new VG structure */
|
/* Create new VG structure */
|
||||||
if (!(vg_to = vg_create(cmd, vg_name_to, vg_from->extent_size,
|
if (!(vg_to = vg_create(cmd, vg_name_to, vg_from->extent_size,
|
||||||
vg_from->max_pv, vg_from->max_lv, 0, NULL)))
|
vg_from->max_pv, vg_from->max_lv,
|
||||||
|
vg_from->alloc, 0, NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Archive vg_from before changing it */
|
/* Archive vg_from before changing it */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user