]> sourceware.org Git - lvm2.git/commitdiff
Tool support for multiple (striped) segments (incomplete).
authorAlasdair Kergon <agk@redhat.com>
Tue, 27 Nov 2001 13:42:37 +0000 (13:42 +0000)
committerAlasdair Kergon <agk@redhat.com>
Tue, 27 Nov 2001 13:42:37 +0000 (13:42 +0000)
tools/commands.h
tools/lvresize.c
tools/lvscan.c

index d9ac0b9054a08a0852d5b259096a07ee562daa22..46a44e2ba16b4dc7ebd2121a885744a9c975be44 100644 (file)
@@ -110,12 +110,13 @@ xx(lvextend,
    "\t[-A/--autobackup y/n]\n"
    "\t[-d/--debug]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l/--extents [+]LogicalExtentsNumber |\n"
    "\t -L/--size [+]LogicalVolumeSize[kKmMgGtT]}\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
 
-   autobackup_ARG, extents_ARG, size_ARG)
+   autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG)
 
 xx(lvmchange,
    "With the device mapper, lvmchange is obsolete and does nothing.",
@@ -205,12 +206,13 @@ xx(lvresize,
    "\t[-A/--autobackup y/n]\n"
    "\t[-d/--debug]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l/--extents [+/-]LogicalExtentsNumber |\n"
    "\t -L/--size [+/-]LogicalVolumeSize[kKmMgGtT]}\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
 
-   autobackup_ARG, extents_ARG, size_ARG)
+   autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG)
 
 xx(lvscan,
    "List all logical volumes in all volume groups",
index 60e465ed21bfc8c9613a84bd4e8148e03c749afb..f3b8a25e3e60372b1e437c8a751ca9772cc56e9d 100644 (file)
@@ -26,6 +26,9 @@ int lvresize(int argc, char **argv)
        struct logical_volume *lv;
        uint32_t extents = 0;
        uint32_t size = 0;
+       uint32_t stripes = 0, stripesize = 0;
+       uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
+       uint32_t size_rest;
        sign_t sign = SIGN_NONE;
        char *lv_name, *vg_name;
        char *st;
@@ -33,6 +36,7 @@ int lvresize(int argc, char **argv)
        const char *cmd_name;
        struct list *lvh, *pvh, *pvl;
        int opt = 0;
+       int seg;
 
        enum {
                LV_ANY = 0,
@@ -71,6 +75,14 @@ int lvresize(int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
+       if (arg_count(stripes_ARG)) {
+                log_print("Stripes not yet implemented in LVM2. Ignoring.");
+                stripes = arg_int_value(stripes_ARG, 1);
+        }
+               
+        if (arg_count(stripesize_ARG))
+                stripesize = 2 * arg_int_value(stripesize_ARG, 0);
+
        if (!argc) {
                log_error("Please provide the logical volume name");
                return EINVALID_CMD_LINE;
@@ -154,17 +166,6 @@ int lvresize(int argc, char **argv)
                extents = lv->le_count - extents;
        }
 
-/************ FIXME Stripes (lvreduce)
-                size_rest = new_size % (vg->lv[l]->lv_stripes * vg->pe_size);
-                if (size_rest != 0) {
-                        log_print
-                            ("rounding size %ld KB to stripe boundary size ",
-                             new_size / 2);
-                        new_size = new_size - size_rest;
-                        printf("%ld KB\n", new_size / 2);
-                }
-***********************/
-
        if (!extents) {
                log_error("New size of 0 not permitted");
                return EINVALID_CMD_LINE;
@@ -176,6 +177,72 @@ int lvresize(int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
+       /* If extending, find stripes, stripesize & size of last segment */
+       if (extents > lv->le_count && (!stripes || !stripesize)) {
+               for (seg = 0; seg < lv->segment_count; seg++) {
+                       uint32_t sz = lv->segments[seg]->stripesize;
+                       uint32_t str = lv->segments[seg]->stripes;
+
+                       if ((seg_stripesize && seg_stripesize != sz 
+                            && !stripesize) ||
+                           (seg_stripes && seg_stripes != str 
+                            && !stripes)) {
+                               log_error("Please specify number of "
+                                         "stripes (-i) and stripesize (-I)");
+                               return EINVALID_CMD_LINE;
+                       }
+
+                       seg_stripesize = sz;
+                       seg_stripes = str;
+               }
+
+               if (!stripesize)
+                       stripesize = seg_stripesize;
+
+               if (!stripes)
+                       stripes = seg_stripes;
+
+               seg_size = extents - lv->le_count;
+       }
+
+       /* If reducing, find stripes, stripesize & size of last segment */
+       if (extents < lv->le_count) {
+               uint32_t extents_used = 0;
+
+               if (stripes || stripesize)
+                       log_error("Ignoring stripes and stripesize arguments "
+                                 "when reducing");
+               for (seg = 0; seg < lv->segment_count; seg++) {
+                       uint32_t seg_extents = lv->segments[seg]->pe_count * 
+                                              vg->extent_size;
+
+                       seg_stripesize = lv->segments[seg]->stripesize;
+                       seg_stripes = lv->segments[seg]->stripes;
+
+                       if (extents <= extents_used + seg_extents)
+                               break;
+
+                       extents_used += seg_extents;
+               }
+
+               seg_size = extents - extents_used;
+               stripesize = seg_stripesize;
+               stripes = seg_stripes;
+       }
+
+        if ((size_rest = seg_size % (stripes * vg->extent_size))) {
+               log_print("Rounding size (%d extents) down to stripe boundary "
+                         "size of last segment (%d extents)", extents, 
+                         extents - size_rest );
+                extents = extents - size_rest;
+        }
+
+       if (extents == lv->le_count) {
+               log_error("New size (%d extents) matches existing size "
+                         "(%d extents)", extents, lv->le_count);
+               return EINVALID_CMD_LINE;
+       }
+
        if (extents < lv->le_count) {
                if (resize == LV_EXTEND) {
                        log_error("New size given (%d extents) not larger "
@@ -259,7 +326,8 @@ int lvresize(int argc, char **argv)
                log_print("Extending logical volume %s to %s", lv_name, dummy);
                dbg_free(dummy);
 
-               lv_extend(lv, extents - lv->le_count, pvh);
+               lv_extend(lv, stripes, stripesize, extents - lv->le_count, 
+                         pvh);
        }
 
 /********* FIXME Suspend lv  ***********/
index 0f0f2111fd93bdcfe6060634a649bdb00bdebd8b..27ec5a8301b093dc9460b2705a8564836cbb0d6d 100644 (file)
@@ -94,8 +94,9 @@ static int lvscan_single(struct logical_volume *lv)
        dbg_free(dummy);
 
        /* FIXME sprintf? */
-       if (lv->stripes > 1 && !(lv->status & SNAPSHOT))
-               log_print(" striped[%u]", lv->stripes);
+       /* FIXME Handle segments? */
+       if (lv->segments[0]->stripes > 1 && !(lv->status & SNAPSHOT))
+               log_print(" striped[%u]", lv->segments[0]->stripes);
 
 /******** FIXME Device number display & Snapshot
                if (arg_count(blockdevice_ARG))
This page took 0.038824 seconds and 5 git commands to generate.