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.85/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.85.orig/lib/metadata/lv_manip.c 2011-05-20 14:57:25.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/lv_manip.c 2011-05-23 15:59:04.000000000 +0200 @@ -3755,7 +3755,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.85/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.85.orig/lib/metadata/metadata-exported.h 2011-05-23 15:59:00.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/metadata-exported.h 2011-05-23 15:59:04.000000000 +0200 @@ -304,6 +304,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; @@ -633,8 +634,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); @@ -642,7 +644,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.85/lib/metadata/snapshot_manip.c =================================================================== --- LVM2.2.02.85.orig/lib/metadata/snapshot_manip.c 2011-05-20 14:57:22.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/snapshot_manip.c 2011-05-23 15:59:04.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.85/lib/format1/import-export.c =================================================================== --- LVM2.2.02.85.orig/lib/format1/import-export.c 2011-05-20 14:57:06.000000000 +0200 +++ LVM2.2.02.85/lib/format1/import-export.c 2011-05-23 15:59:04.000000000 +0200 @@ -608,7 +608,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.85/tools/lvconvert.c =================================================================== --- LVM2.2.02.85.orig/tools/lvconvert.c 2011-05-23 15:57:56.000000000 +0200 +++ LVM2.2.02.85/tools/lvconvert.c 2011-05-23 15:59:04.000000000 +0200 @@ -1409,7 +1409,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.85/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.85.orig/lib/snapshot/snapshot.c 2011-05-20 14:56:52.000000000 +0200 +++ LVM2.2.02.85/lib/snapshot/snapshot.c 2011-05-23 15:59:04.000000000 +0200 @@ -85,9 +85,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)