]> sourceware.org Git - lvm2.git/commitdiff
o Tool support for segments.
authorAlasdair Kergon <agk@redhat.com>
Wed, 28 Nov 2001 13:45:50 +0000 (13:45 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 28 Nov 2001 13:45:50 +0000 (13:45 +0000)
o vgmerge working.

lib/datastruct/list.h
lib/display/display.c
lib/format1/import-extents.c
lib/metadata/lv_manip.c
lib/metadata/metadata.c
libdm/datastruct/list.h
make.tmpl.in
tools/lvresize.c
tools/lvscan.c
tools/vgmerge.c

index 1c4a791c7bab617c6d4fb46b4bf66845c1b64683..cfda137ab83830c335bfec818e2c325fbbf98d7d 100644 (file)
@@ -49,6 +49,16 @@ static inline int list_empty(struct list *head) {
 #define list_iterate(v, head) \
     for (v = (head)->n; v != head; v = v->n)
 
+static inline int list_size(struct list *head) {
+       int s = 0;
+       struct list *v;
+
+       list_iterate(v, head)
+               s++;
+
+       return s;
+}
+
 #define list_item(v, t) \
     ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
 
index 84617410adbc2be2f035b46467a90efb9bc3995e..89f576aa6856f0c871cd870c3b4d0de2290adf5d 100644 (file)
@@ -359,12 +359,11 @@ int lvdisplay_full(struct logical_volume *lv)
     }
 ******************/
 
-       if (lv->stripes > 1) {
-               log_print("Stripes                %u", lv->stripes);
-/*********** FIXME stripesize 
+       log_print("Segments               %u", list_size(&lv->segments));
+
+/********* FIXME Stripes & stripesize for each segment
        log_print("Stripe size (KByte)    %u", lv->stripesize / 2);
 ***********/
-       }
 
 /**************
 #ifdef LVM_FUTURE
@@ -417,6 +416,7 @@ void lvdisplay_extents(struct logical_volume *lv)
                    "volumes  ---");
        log_verbose("PV Name                  PE on PV     ");
 
+/********* FIXME Segments & Stripes
        list_iterate(pvh, &lv->vg->pvs) {
                int count = 0;
                pv = &list_item(pvh, struct pv_list)->pv;
@@ -427,6 +427,7 @@ void lvdisplay_extents(struct logical_volume *lv)
                        log_verbose("%-25s %d", dev_name(pv->dev), count);
        }
 
+**********/
 /********* FIXME "reads      writes" 
 
           
@@ -439,10 +440,12 @@ void lvdisplay_extents(struct logical_volume *lv)
        log_verbose("--- Logical extents ---");
        log_verbose("LE    PV                        PE");
 
+/******** FIXME Segments & Stripes
        for (le = 0; le < lv->le_count; le++) {
                log_verbose("%05d %-25s %05u  ", le,
                            dev_name(lv->map[le].pv->dev), lv->map[le].pe);
        }
+******/
 
        log_verbose(" ");
 
index 7bcd96341c218e9e0c58cda74208c0b7dcdb361e..5cef7c67095fb87f7fdb8d30882742eb92098c53 100644 (file)
@@ -80,13 +80,13 @@ static int _fill_lv_array(struct lv_map **lvs,
 {
        struct list *lvh;
        struct lv_map *lvm;
-       int i = 0;
 
        memset(lvs, 0, sizeof(*lvs) * MAX_LV);
        list_iterate(lvh, &dl->lvds) {
                struct lvd_list *ll = list_item(lvh, struct lvd_list);
 
-               if (!(lvm = hash_lookup(maps, ll->lvd.lv_name))) {
+               if (!(lvm = hash_lookup(maps, strrchr(ll->lvd.lv_name, '/')
+                                             + 1 ))) {
                        log_err("Physical volume (%s) contains an "
                                "unknown logical volume (%s).",
                                dev_name(dl->dev), ll->lvd.lv_name);
@@ -128,8 +128,7 @@ static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
 
                        if (lv_num == UNMAPPED_EXTENT)
                                continue;
-
-                       } else {
+                       else {
                                lv_num--;
                                lvm = lvms[lv_num];
 
index 8af91ced9904af93124d3c625c99358aa1f1e726..6b3d1a35758cefc6e16330b7366afbcba2a91c26 100644 (file)
@@ -319,6 +319,7 @@ struct logical_volume *lv_create(const char *name,
        lv->read_ahead = 0;
        lv->size = extents * vg->extent_size;
        lv->le_count = extents;
+       lv->vg = vg;
        list_init(&lv->segments);
 
        if (!_allocate(vg, lv, acceptable_pvs, 0u, stripes, stripe_size)) {
@@ -328,7 +329,6 @@ struct logical_volume *lv_create(const char *name,
 
        vg->lv_count++;
        list_add(&vg->lvs, &ll->list);
-       lv->vg = vg;
 
        return lv;
 
index 304b8642adf917e5db9f7f5b41bacc4f11075f69..e462f63c09c00f243311a6e9bb2e852b3676e0f9 100644 (file)
@@ -274,7 +274,7 @@ struct logical_volume *find_lv(struct volume_group *vg, const char *lv_name)
                return NULL;
 }
 
-struct physical_volume *_find_pv(struct volume_group *vg, struct device *dev)
+struct physical_volume *find_pv(struct volume_group *vg, struct device *dev)
 {
        struct list *pvh;
        struct physical_volume *pv;
index 1c4a791c7bab617c6d4fb46b4bf66845c1b64683..cfda137ab83830c335bfec818e2c325fbbf98d7d 100644 (file)
@@ -49,6 +49,16 @@ static inline int list_empty(struct list *head) {
 #define list_iterate(v, head) \
     for (v = (head)->n; v != head; v = v->n)
 
+static inline int list_size(struct list *head) {
+       int s = 0;
+       struct list *v;
+
+       list_iterate(v, head)
+               s++;
+
+       return s;
+}
+
 #define list_item(v, t) \
     ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
 
index c4e1aecc8240d0efe49b5a69bb75cf807b399eb9..6465dec88ef3a402f4b418abbcdb0c4739f7fa54 100644 (file)
@@ -58,7 +58,7 @@ CFLAGS+=-g -fno-omit-frame-pointer
 #CFLAGS+=-pg
 #LD_FLAGS=-pg
 
-CFLAGS+=-DDEBUG_MEM -DDEBUG -DDEBUG_POOL
+CFLAGS+=-DDEBUG_MEM -DDEBUG #-DDEBUG_POOL
 #CFLAGS+=-DBOUNDS_CHECK
 
 INCLUDES+=-I. -I$(top_srcdir)/include
index 3ed903f15554b30d2a1df4b320b1307cbaff1eed..45a21f29e77a6fa381b728dd4ae88338cb015781 100644 (file)
@@ -34,9 +34,8 @@ int lvresize(int argc, char **argv)
        char *st;
        char *dummy;
        const char *cmd_name;
-       struct list *lvh, *pvh, *pvl;
+       struct list *lvh, *pvh, *pvl, *segh;
        int opt = 0;
-       int seg;
 
        enum {
                LV_ANY = 0,
@@ -179,9 +178,13 @@ int lvresize(int argc, char **argv)
 
        /* 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;
+               list_iterate(segh, &lv->segments) {
+                       struct stripe_segment *seg;
+                       uint32_t sz, str;
+
+                       seg = list_item(segh, struct stripe_segment);
+                       sz = seg->stripe_size;
+                       str = seg->stripes;
 
                        if ((seg_stripesize && seg_stripesize != sz
                             && !stripesize) ||
@@ -211,12 +214,16 @@ int lvresize(int argc, char **argv)
                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;
+               list_iterate(segh, &lv->segments) {
+                       struct stripe_segment *seg;
+                       uint32_t seg_extents;
+
+                       seg = list_item(segh, struct stripe_segment);
+                       seg_extents = seg->len;
+
+                       seg_stripesize = seg->stripe_size;
+                       seg_stripes = seg->stripes;
 
                        if (extents <= extents_used + seg_extents)
                                break;
index 27ec5a8301b093dc9460b2705a8564836cbb0d6d..13f8979d90b5bfc68a965781b73a0a114a9cb366 100644 (file)
@@ -94,9 +94,11 @@ static int lvscan_single(struct logical_volume *lv)
        dbg_free(dummy);
 
        /* FIXME sprintf? */
-       /* FIXME Handle segments? */
+       
+/*********** 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))
index 289c718e69f7640b0b94600e0c91c968c20605d9..b3a490432794dd3f5b2093e03f56c4674d87f40c 100644 (file)
@@ -116,14 +116,22 @@ int vgmerge_single(const char *vg_name_to, const char *vg_name_from)
 
        /* Merge volume groups */
        while (!list_empty(&vg_from->pvs)) {
-               list_del(&vg_from->pvs);
-               list_add(&vg_to->pvs, &vg_from->pvs);
+               struct list *pvh = vg_from->pvs.n;
+               struct physical_volume *pv;
+
+               list_del(pvh);
+               list_add(&vg_to->pvs, pvh);
+
+               pv = &list_item(pvh, struct pv_list)->pv;
+               pv->vg_name = pool_strdup(fid->cmd->mem, vg_to->name);
        }
        vg_to->pv_count += vg_from->pv_count;
 
        while (!list_empty(&vg_from->lvs)) {
-               list_del(&vg_from->lvs);
-               list_add(&vg_to->lvs, &vg_from->lvs);
+               struct list *lvh = vg_from->lvs.n;
+
+               list_del(lvh);
+               list_add(&vg_to->lvs, lvh);
        }
        vg_to->lv_count += vg_from->lv_count;
 
This page took 0.044917 seconds and 5 git commands to generate.