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.60/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.60.orig/lib/metadata/lv_manip.c 2010-01-20 22:53:10.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/lv_manip.c 2010-02-08 14:05:50.000000000 +0100 @@ -3129,7 +3129,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.60/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.60.orig/lib/metadata/metadata-exported.h 2010-02-08 13:51:53.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/metadata-exported.h 2010-02-08 14:05:50.000000000 +0100 @@ -300,6 +300,7 @@ struct lv_segment { uint32_t region_size; /* For mirrors - in sectors */ uint32_t extents_copied; struct logical_volume *log_lv; + const char *exception_store; void *segtype_private; struct dm_list tags; @@ -631,8 +632,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); @@ -640,7 +642,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.60/lib/metadata/snapshot_manip.c =================================================================== --- LVM2.2.02.60.orig/lib/metadata/snapshot_manip.c 2010-01-13 02:56:18.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/snapshot_manip.c 2010-02-08 14:52:35.000000000 +0100 @@ -82,8 +82,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; @@ -100,10 +101,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, @@ -135,7 +148,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; @@ -163,9 +177,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.60/lib/format1/import-export.c =================================================================== --- LVM2.2.02.60.orig/lib/format1/import-export.c 2009-09-28 19:46:16.000000000 +0200 +++ LVM2.2.02.60/lib/format1/import-export.c 2010-02-08 14:05:50.000000000 +0100 @@ -611,7 +611,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.60/tools/lvconvert.c =================================================================== --- LVM2.2.02.60.orig/tools/lvconvert.c 2010-02-08 02:05:32.000000000 +0100 +++ LVM2.2.02.60/tools/lvconvert.c 2010-02-08 14:05:50.000000000 +0100 @@ -1082,7 +1082,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.60/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.60.orig/lib/snapshot/snapshot.c 2010-01-15 18:46:08.000000000 +0100 +++ LVM2.2.02.60/lib/snapshot/snapshot.c 2010-02-08 14:05:50.000000000 +0100 @@ -80,9 +80,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)