]> sourceware.org Git - lvm2.git/commitdiff
Default to unlimited number of LVs/PVs in lvm2 format.
authorAlasdair Kergon <agk@redhat.com>
Thu, 6 Nov 2003 20:33:34 +0000 (20:33 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 6 Nov 2003 20:33:34 +0000 (20:33 +0000)
lib/format1/format1.c
lib/metadata/lv_manip.c
lib/metadata/metadata.c
tools/vgchange.c
tools/vgcreate.c
tools/vgmerge.c

index 254b787df5a57656b61f6d20a83a4c7aad8cabd0..bd618a73e6d05c3321f8294f6c850ba50afbb04f 100644 (file)
@@ -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) {
index 1ea2a83cb3df736fe148536525c67d6a40ba80c0..e72abae12e4a73dc8706227a02bb0b29d99f2248 100644 (file)
@@ -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;
index 50f7be41150dd20337525e5dd8ac842b9976bfcb..bf92ec13983e5fdc58bf2c2e943c297db042a972 100644 (file)
@@ -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);
index 2f0640ab779ae6a9cedeeaa3cfac2e61c7d1eb79..412dbf3bd20d221784764fed915076b158d0d186 100644 (file)
@@ -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);
index bba795fc5f422320fe08c22279e8d501baa3ac36..0530b1e37b60667e8ea63071e0f3ed35c1b33910 100644 (file)
 
 #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,36 +42,47 @@ 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);
-
-       if (arg_sign_value(cmd, physicalextentsize_ARG, 0) == SIGN_MINUS) {
-               log_error("Physical extent size 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;
-       }
+       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 (!extent_size) {
                log_error("Physical extent size may not be zero");
                return EINVALID_CMD_LINE;
        }
 
-       /* Strip dev_dir if present */
-       if (!strncmp(vg_name, cmd->dev_dir, strlen(cmd->dev_dir)))
-               vg_name += strlen(cmd->dev_dir);
+       /* Strip dev_dir if present */
+       if (!strncmp(vg_name, cmd->dev_dir, strlen(cmd->dev_dir)))
+               vg_name += strlen(cmd->dev_dir);
 
        snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
        if (path_exists(vg_path)) {
@@ -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");
index 6efe163e913200d8458087e9bab898eb1698daa0..dc85fb92231bef6c4868ac910ac634902c912dd5 100644 (file)
@@ -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);
This page took 0.048334 seconds and 5 git commands to generate.