]> sourceware.org Git - lvm2.git/commitdiff
Store snapshot and origin sizes separately.
authorAlasdair Kergon <agk@redhat.com>
Wed, 19 Jan 2005 17:19:39 +0000 (17:19 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 19 Jan 2005 17:19:39 +0000 (17:19 +0000)
WHATS_NEW
lib/activate/dev_manager.c
lib/format1/import-export.c
lib/format_text/export.c
lib/metadata/metadata.h
lib/metadata/snapshot_manip.c
lib/snapshot/snapshot.c
tools/lvcreate.c

index 5e5af75e566de55db88fc9994596caae1c7614f7..fe1fa580709adda963f082defd2ab4444d61c973 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.01.01 - 
 ===================================
+  Store snapshot and origin sizes separately.
   Update vgcreate man page.
 
 Version 2.01.00 - 17th January 2005
index 9aa22938d88cd3bff468b02f2851daa728604bff..80b28402124f37c10e771b5546c26aae41cb763b 100644 (file)
@@ -878,6 +878,7 @@ static int _populate_snapshot(struct dev_manager *dm,
        struct snapshot *s;
        struct dev_layer *dlo, *dlc;
        char devbufo[10], devbufc[10];
+       uint64_t size;
 
        if (!(s = find_cow(dl->lv))) {
                log_error("Couldn't find snapshot for '%s'.", dl->lv->name);
@@ -925,10 +926,10 @@ static int _populate_snapshot(struct dev_manager *dm,
                return 0;
        }
 
-       log_debug("Adding target: 0 %" PRIu64 " snapshot %s",
-                 s->origin->size, params);
-       if (!dm_task_add_target
-           (dmt, UINT64_C(0), s->origin->size, "snapshot", params)) {
+       size = (uint64_t) s->le_count * s->origin->vg->extent_size;
+
+       log_debug("Adding target: 0 %" PRIu64 " snapshot %s", size, params);
+       if (!dm_task_add_target(dmt, UINT64_C(0), size, "snapshot", params)) {
                stack;
                return 0;
        }
index 92719c6e4e12b4a7604c7c4c7132bfeac54d8017..335b729fed47d51327dc091196f2fba1bd7b47f3 100644 (file)
@@ -646,7 +646,7 @@ int import_snapshots(struct pool *mem, struct volume_group *vg,
                                continue;
 
                        /* insert the snapshot */
-                       if (!vg_add_snapshot(org, cow, 1, NULL,
+                       if (!vg_add_snapshot(org, cow, 1, NULL, org->le_count, 
                                             lvd->lv_chunk_size)) {
                                log_err("Couldn't add snapshot.");
                                return 0;
index cc1351fd68f40764ecc17da0bddf0b317475955c..223191a16f72f043fe962f52f8de189f23784f85 100644 (file)
@@ -513,7 +513,7 @@ static int _print_snapshot(struct formatter *f, struct snapshot *snap,
        }
 
        seg.le = 0;
-       seg.len = snap->origin->le_count;
+       seg.len = snap->le_count;
        seg.origin = snap->origin;
        seg.cow = snap->cow;
        seg.chunk_size = snap->chunk_size;
index c30952dd4361e44ecd20f7e779019f8dd13b4d32..17c6d3e5ba5b531f8e5160f3b535e5052ffd79b8 100644 (file)
@@ -255,6 +255,7 @@ struct snapshot {
 
        int persistent;         /* boolean */
        uint32_t chunk_size;    /* in 512 byte sectors */
+       uint32_t le_count;
 
        struct logical_volume *origin;
        struct logical_volume *cow;
@@ -496,9 +497,9 @@ struct snapshot *find_cow(const struct logical_volume *lv);
 struct snapshot *find_origin(const struct logical_volume *lv);
 struct list *find_snapshots(const struct logical_volume *lv);
 
-int vg_add_snapshot(struct logical_volume *origin,
-                   struct logical_volume *cow,
-                   int persistent, struct id *id, uint32_t chunk_size);
+int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow,
+                   int persistent, struct id *id, uint32_t extent_count,
+                   uint32_t chunk_size);
 
 int vg_remove_snapshot(struct volume_group *vg, struct logical_volume *cow);
 
index 1854b51301870d081fc0699e7d6ad6831ed10776..664c73b282aeb35187a5d33766bf36f3c7852ce1 100644 (file)
@@ -104,9 +104,9 @@ struct list *find_snapshots(const struct logical_volume *lv)
        return snaplist;
 }
 
-int vg_add_snapshot(struct logical_volume *origin,
-                   struct logical_volume *cow,
-                   int persistent, struct id *id, uint32_t chunk_size)
+int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow,
+                   int persistent, struct id *id, uint32_t extent_count,
+                   uint32_t chunk_size)
 {
        struct snapshot *s;
        struct snapshot_list *sl;
@@ -127,6 +127,7 @@ int vg_add_snapshot(struct logical_volume *origin,
 
        s->persistent = persistent;
        s->chunk_size = chunk_size;
+       s->le_count = extent_count;
        s->origin = origin;
        s->cow = cow;
 
index 82e8a27e2861aa36808261a005b09f7a051b44a5..89ef65f77231a3bd2009f4b635cbb55613434736 100644 (file)
@@ -31,7 +31,7 @@ static const char *_name(const struct lv_segment *seg)
 static int _text_import(struct lv_segment *seg, const struct config_node *sn,
                        struct hash_table *pv_hash)
 {
-       uint32_t chunk_size;
+       uint32_t chunk_size, extent_count;
        const char *org_name, *cow_name;
        struct logical_volume *org, *cow;
 
@@ -70,7 +70,11 @@ static int _text_import(struct lv_segment *seg, const struct config_node *sn,
                return 0;
        }
 
-       if (!vg_add_snapshot(org, cow, 1, &seg->lv->lvid.id[1], chunk_size)) {
+       if (!get_config_uint32(sn, "extent_count", &extent_count))
+               extent_count = org->le_count;
+
+       if (!vg_add_snapshot(org, cow, 1, &seg->lv->lvid.id[1], extent_count,
+                            chunk_size)) {
                stack;
                return 0;
        }
@@ -81,6 +85,8 @@ static int _text_import(struct lv_segment *seg, const struct config_node *sn,
 static int _text_export(const struct lv_segment *seg, struct formatter *f)
 {
        outf(f, "chunk_size = %u", seg->chunk_size);
+       if (seg->len != seg->origin->le_count)
+               outf(f, "extent_count = %u", seg->len);
        outf(f, "origin = \"%s\"", seg->origin->name);
        outf(f, "cow_store = \"%s\"", seg->cow->name);
 
index 3ef022049f16a0f571b6cdbd22ee6186ba00621a..155fe7195a1925d64dc50de17b3c3b418e13ccd8 100644 (file)
@@ -609,7 +609,8 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
                        return 0;
                }
 
-               if (!vg_add_snapshot(org, lv, 1, NULL, lp->chunk_size)) {
+               if (!vg_add_snapshot(org, lv, 1, NULL, lv->le_count,
+                                    lp->chunk_size)) {
                        log_err("Couldn't create snapshot.");
                        return 0;
                }
This page took 0.046446 seconds and 5 git commands to generate.