mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-23 21:35:29 +03:00
Default to unlimited number of LVs/PVs in lvm2 format.
This commit is contained in:
parent
752bd00674
commit
e15846bf79
@ -422,10 +422,10 @@ static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
{
|
||||
/* just check max_pv and max_lv */
|
||||
if (vg->max_lv >= MAX_LV)
|
||||
if (!vg->max_lv || vg->max_lv >= MAX_LV)
|
||||
vg->max_lv = MAX_LV - 1;
|
||||
|
||||
if (vg->max_pv >= MAX_PV)
|
||||
if (!vg->max_pv || vg->max_pv >= MAX_PV)
|
||||
vg->max_pv = MAX_PV - 1;
|
||||
|
||||
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
|
||||
|
@ -478,7 +478,7 @@ struct logical_volume *lv_create_empty(struct format_instance *fi,
|
||||
struct logical_volume *lv;
|
||||
char dname[32];
|
||||
|
||||
if (vg->max_lv == vg->lv_count) {
|
||||
if (vg->max_lv && (vg->max_lv == vg->lv_count)) {
|
||||
log_error("Maximum number of logical volumes (%u) reached "
|
||||
"in volume group %s", vg->max_lv, vg->name);
|
||||
return NULL;
|
||||
|
@ -83,7 +83,7 @@ static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->pv_count == vg->max_pv) {
|
||||
if (vg->pv_count && (vg->pv_count == vg->max_pv)) {
|
||||
log_error("No space for '%s' - volume group '%s' "
|
||||
"holds max %d physical volume(s).", pv_name,
|
||||
vg->name, vg->max_pv);
|
||||
|
@ -132,7 +132,16 @@ static int _vgchange_logicalvolume(struct cmd_context *cmd,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (max_lv < vg->lv_count) {
|
||||
if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
|
||||
if (!max_lv)
|
||||
max_lv = 255;
|
||||
else if (max_lv > 255) {
|
||||
log_error("MaxLogicalVolume limit is 255");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_lv && max_lv < vg->lv_count) {
|
||||
log_error("MaxLogicalVolume is less than the current number "
|
||||
"%d of logical volume(s) for \"%s\"", vg->lv_count,
|
||||
vg->name);
|
||||
|
@ -20,10 +20,6 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
/* FIXME From config file? */
|
||||
#define DEFAULT_PV 256
|
||||
#define DEFAULT_LV 256
|
||||
|
||||
#define DEFAULT_EXTENT 4096 /* In KB */
|
||||
|
||||
int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
@ -46,28 +42,39 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
vg_name = argv[0];
|
||||
max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, DEFAULT_LV);
|
||||
max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
|
||||
max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, 0);
|
||||
max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
|
||||
|
||||
if (!(cmd->fmt->features & FMT_UNLIMITED_VOLS)) {
|
||||
if (!max_lv)
|
||||
max_lv = 255;
|
||||
if (!max_pv)
|
||||
max_pv = 255;
|
||||
if (max_lv > 255 || max_pv > 255) {
|
||||
log_error("Number of volumes may not exceed 255");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, physicalextentsize_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Physical extent size may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, maxlogicalvolumes_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Max Logical Volumes may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_sign_value(cmd, maxphysicalvolumes_ARG, 0) == SIGN_MINUS) {
|
||||
log_error("Max Physical Volumes may not be negative");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
/* Units of 512-byte sectors */
|
||||
extent_size =
|
||||
arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
|
||||
|
||||
if (max_lv < 1) {
|
||||
log_error("maxlogicalvolumes too low");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (max_pv < 1) {
|
||||
log_error("maxphysicalvolumes too low");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (!extent_size) {
|
||||
log_error("Physical extent size may not be zero");
|
||||
return EINVALID_CMD_LINE;
|
||||
@ -94,12 +101,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
return ECMD_FAILED;
|
||||
|
||||
if (max_lv != vg->max_lv)
|
||||
log_error("Warning: Setting maxlogicalvolumes to %d",
|
||||
vg->max_lv);
|
||||
log_error("Warning: Setting maxlogicalvolumes to %d "
|
||||
"(0 means unlimited)", vg->max_lv);
|
||||
|
||||
if (max_pv != vg->max_pv)
|
||||
log_error("Warning: Setting maxphysicalvolumes to %d",
|
||||
vg->max_pv);
|
||||
log_error("Warning: Setting maxphysicalvolumes to %d "
|
||||
"(0 means unlimited)", vg->max_pv);
|
||||
|
||||
if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
|
@ -94,14 +94,16 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (vg_to->max_pv < vg_to->pv_count + vg_from->pv_count) {
|
||||
if (vg_to->max_pv &&
|
||||
(vg_to->max_pv < vg_to->pv_count + vg_from->pv_count)) {
|
||||
log_error("Maximum number of physical volumes (%d) exceeded "
|
||||
" for \"%s\" and \"%s\"", vg_to->max_pv, vg_to->name,
|
||||
vg_from->name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (vg_to->max_lv < vg_to->lv_count + vg_from->lv_count) {
|
||||
if (vg_to->max_lv &&
|
||||
(vg_to->max_lv < vg_to->lv_count + vg_from->lv_count)) {
|
||||
log_error("Maximum number of logical volumes (%d) exceeded "
|
||||
" for \"%s\" and \"%s\"", vg_to->max_lv, vg_to->name,
|
||||
vg_from->name);
|
||||
|
Loading…
Reference in New Issue
Block a user