Version 2.01.01 -
===================================
+ Store snapshot and origin sizes separately.
Update vgcreate man page.
Version 2.01.00 - 17th January 2005
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);
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;
}
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;
}
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;
int persistent; /* boolean */
uint32_t chunk_size; /* in 512 byte sectors */
+ uint32_t le_count;
struct logical_volume *origin;
struct logical_volume *cow;
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);
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;
s->persistent = persistent;
s->chunk_size = chunk_size;
+ s->le_count = extent_count;
s->origin = origin;
s->cow = cow;
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;
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;
}
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);
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;
}