Add arguments for exception store type. Add an argument representing an exception store type to vg_add_snapshot. Add an exception_store entry to struct lv_segment. Signed-off-by: Mikulas Patocka --- lib/format1/import-export.c | 2 +- lib/metadata/lv_manip.c | 3 ++- lib/metadata/metadata-exported.h | 8 +++++--- lib/metadata/snapshot_manip.c | 24 ++++++++++++++++++------ lib/snapshot/snapshot.c | 4 +--- tools/lvconvert.c | 2 +- 6 files changed, 28 insertions(+), 15 deletions(-) Index: LVM2.2.02.73/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.73.orig/lib/metadata/lv_manip.c 2010-08-17 18:25:33.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/lv_manip.c 2010-09-10 17:44:46.000000000 +0200 @@ -3272,7 +3272,8 @@ int lv_create_single(struct volume_group /* cow LV remains active and becomes snapshot LV */ if (!vg_add_snapshot(org, lv, NULL, - org->le_count, lp->chunk_size)) { + org->le_count, lp->shared_store, + lp->chunk_size)) { log_error("Couldn't create snapshot."); goto deactivate_and_revert_new_lv; } Index: LVM2.2.02.73/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.73.orig/lib/metadata/metadata-exported.h 2010-09-10 17:44:44.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/metadata-exported.h 2010-09-10 17:44:46.000000000 +0200 @@ -378,6 +378,7 @@ struct lv_segment { uint32_t extents_copied; struct logical_volume *log_lv; struct lv_segment *pvmove_source_seg; + const char *exception_store; void *segtype_private; struct dm_list tags; @@ -733,8 +734,9 @@ struct lv_segment *find_cow(const struct /* Given a cow LV, return its origin */ struct logical_volume *origin_from_cow(const struct logical_volume *lv); -void init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin, - struct logical_volume *cow, uint32_t chunk_size, int merge); +int init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin, + struct logical_volume *cow, + const char *exception_store, uint32_t chunk_size, int merge); void init_snapshot_merge(struct lv_segment *cow_seg, struct logical_volume *origin); @@ -742,7 +744,7 @@ void clear_snapshot_merge(struct logical int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow, union lvid *lvid, uint32_t extent_count, - uint32_t chunk_size); + const char *exception_store, uint32_t chunk_size); int vg_remove_snapshot(struct logical_volume *cow); Index: LVM2.2.02.73/lib/metadata/snapshot_manip.c =================================================================== --- LVM2.2.02.73.orig/lib/metadata/snapshot_manip.c 2010-04-23 04:57:43.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/snapshot_manip.c 2010-09-10 17:44:46.000000000 +0200 @@ -84,8 +84,9 @@ struct logical_volume *origin_from_cow(c return lv->snapshot->origin; } -void init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin, - struct logical_volume *cow, uint32_t chunk_size, int merge) +int init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin, + struct logical_volume *cow, const char *exception_store, + uint32_t chunk_size, int merge) { seg->chunk_size = chunk_size; seg->origin = origin; @@ -102,10 +103,22 @@ void init_snapshot_seg(struct lv_segment origin->status |= VIRTUAL_ORIGIN; seg->lv->status |= (SNAPSHOT | VIRTUAL); + + if (exception_store) { + seg->exception_store = dm_pool_strdup(seg->lv->vg->cmd->mem, + exception_store); + if (!seg->exception_store) { + log_error("Out of memory."); + return_0; + } + } + if (merge) init_snapshot_merge(seg, origin); dm_list_add(&origin->snapshot_segs, &seg->origin_list); + + return 1; } void init_snapshot_merge(struct lv_segment *cow_seg, @@ -137,7 +150,8 @@ void clear_snapshot_merge(struct logical int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow, union lvid *lvid, - uint32_t extent_count, uint32_t chunk_size) + uint32_t extent_count, const char *exception_store, + uint32_t chunk_size) { struct logical_volume *snap; struct lv_segment *seg; @@ -165,9 +179,7 @@ int vg_add_snapshot(struct logical_volum if (!(seg = alloc_snapshot_seg(snap, 0, 0))) return_0; - init_snapshot_seg(seg, origin, cow, chunk_size, 0); - - return 1; + return init_snapshot_seg(seg, origin, cow, exception_store, chunk_size, 0); } int vg_remove_snapshot(struct logical_volume *cow) Index: LVM2.2.02.73/lib/format1/import-export.c =================================================================== --- LVM2.2.02.73.orig/lib/format1/import-export.c 2010-07-09 17:34:44.000000000 +0200 +++ LVM2.2.02.73/lib/format1/import-export.c 2010-09-10 17:44:46.000000000 +0200 @@ -609,7 +609,7 @@ int import_snapshots(struct dm_pool *mem /* insert the snapshot */ if (!vg_add_snapshot(org, cow, NULL, - org->le_count, + org->le_count, NULL, lvd->lv_chunk_size)) { log_error("Couldn't add snapshot."); return 0; Index: LVM2.2.02.73/tools/lvconvert.c =================================================================== --- LVM2.2.02.73.orig/tools/lvconvert.c 2010-09-10 17:44:30.000000000 +0200 +++ LVM2.2.02.73/tools/lvconvert.c 2010-09-10 17:44:46.000000000 +0200 @@ -1404,7 +1404,7 @@ static int lvconvert_snapshot(struct cmd return 0; } - if (!vg_add_snapshot(org, lv, NULL, org->le_count, lp->chunk_size)) { + if (!vg_add_snapshot(org, lv, NULL, org->le_count, NULL, lp->chunk_size)) { log_error("Couldn't create snapshot."); return 0; } Index: LVM2.2.02.73/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.73.orig/lib/snapshot/snapshot.c 2010-08-17 03:16:41.000000000 +0200 +++ LVM2.2.02.73/lib/snapshot/snapshot.c 2010-09-10 17:44:46.000000000 +0200 @@ -77,9 +77,7 @@ static int _snap_text_import(struct lv_s return 0; } - init_snapshot_seg(seg, org, cow, chunk_size, merge); - - return 1; + return init_snapshot_seg(seg, org, cow, NULL, chunk_size, merge); } static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)