Implement the flag SNAPSHOT_SHARED on segments. Signed-off-by: Mikulas Patocka --- lib/format1/import-export.c | 2 +- lib/metadata/lv_alloc.h | 3 ++- lib/metadata/lv_manip.c | 9 ++++++--- lib/metadata/metadata-exported.h | 4 +++- lib/metadata/snapshot_manip.c | 6 ++++-- lib/multisnapshot/multisnapshot.c | 2 ++ tools/lvconvert.c | 3 ++- 7 files changed, 20 insertions(+), 9 deletions(-) Index: LVM2.2.02.54/lib/metadata/lv_alloc.h =================================================================== --- LVM2.2.02.54.orig/lib/metadata/lv_alloc.h 2008-12-19 16:24:53.000000000 +0100 +++ LVM2.2.02.54/lib/metadata/lv_alloc.h 2009-10-29 17:45:03.000000000 +0100 @@ -29,7 +29,8 @@ struct lv_segment *alloc_lv_segment(stru uint32_t extents_copied); struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv, - uint32_t status, uint32_t old_le_count); + uint32_t status, uint32_t old_le_count, + uint32_t snapshot_flags); int set_lv_segment_area_pv(struct lv_segment *seg, uint32_t area_num, struct physical_volume *pv, uint32_t pe); Index: LVM2.2.02.54/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.54.orig/lib/metadata/lv_manip.c 2009-10-29 17:44:39.000000000 +0100 +++ LVM2.2.02.54/lib/metadata/lv_manip.c 2009-10-29 17:45:03.000000000 +0100 @@ -215,12 +215,14 @@ struct lv_segment *alloc_lv_segment(stru } struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv, - uint32_t status, uint32_t old_le_count) + uint32_t status, uint32_t old_le_count, + uint32_t snapshot_flags) { struct lv_segment *seg; const struct segment_type *segtype; - segtype = get_segtype_from_string(lv->vg->cmd, "snapshot"); + segtype = get_segtype_from_string(lv->vg->cmd, + snapshot_flags & SNAPSHOT_SHARED ? "multisnapshot" : "snapshot"); if (!segtype) { log_error("Failed to find snapshot segtype"); return NULL; @@ -3123,7 +3125,8 @@ int lv_create_single(struct volume_group if (!vg_add_snapshot(org, lv, NULL, org->le_count, lp->shared_store, - lp->chunk_size)) { + lp->chunk_size, + lp->shared_store ? SNAPSHOT_SHARED : 0)) { log_error("Couldn't create snapshot."); goto deactivate_and_revert_new_lv; } Index: LVM2.2.02.54/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.54.orig/lib/metadata/metadata-exported.h 2009-10-29 17:39:16.000000000 +0100 +++ LVM2.2.02.54/lib/metadata/metadata-exported.h 2009-10-29 17:45:03.000000000 +0100 @@ -60,6 +60,7 @@ //#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */ //#define PRECOMMITTED 0x00200000U /* VG - internal use only */ #define CONVERTING 0x00400000U /* LV */ +#define SNAPSHOT_SHARED 0x02000000U /* SEG */ #define MISSING_PV 0x00800000U /* PV */ #define PARTIAL_LV 0x01000000U /* LV - derived flag, not @@ -631,7 +632,8 @@ int init_snapshot_seg(struct lv_segment int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow, union lvid *lvid, uint32_t extent_count, - const char *exception_store, uint32_t chunk_size); + const char *exception_store, uint32_t chunk_size, + unsigned snapshot_flags); int vg_remove_snapshot(struct logical_volume *cow); Index: LVM2.2.02.54/lib/metadata/snapshot_manip.c =================================================================== --- LVM2.2.02.54.orig/lib/metadata/snapshot_manip.c 2009-10-29 17:38:51.000000000 +0100 +++ LVM2.2.02.54/lib/metadata/snapshot_manip.c 2009-10-29 17:45:03.000000000 +0100 @@ -98,7 +98,7 @@ int init_snapshot_seg(struct lv_segment int vg_add_snapshot(struct logical_volume *origin, struct logical_volume *cow, union lvid *lvid, uint32_t extent_count, const char *exception_store, - uint32_t chunk_size) + uint32_t chunk_size, unsigned snapshot_flags) { struct logical_volume *snap; struct lv_segment *seg; @@ -123,9 +123,11 @@ int vg_add_snapshot(struct logical_volum snap->le_count = extent_count; - if (!(seg = alloc_snapshot_seg(snap, 0, 0))) + if (!(seg = alloc_snapshot_seg(snap, 0, 0, snapshot_flags))) return_0; + seg->status |= snapshot_flags & SNAPSHOT_SHARED; + return init_snapshot_seg(seg, origin, cow, exception_store, chunk_size); } Index: LVM2.2.02.54/lib/multisnapshot/multisnapshot.c =================================================================== --- LVM2.2.02.54.orig/lib/multisnapshot/multisnapshot.c 2009-10-29 17:42:32.000000000 +0100 +++ LVM2.2.02.54/lib/multisnapshot/multisnapshot.c 2009-10-29 17:45:03.000000000 +0100 @@ -52,6 +52,8 @@ static int _multisnapshot_text_import(st struct logical_volume *org, *cow; int old_suppress; + seg->status |= SNAPSHOT_SHARED; + if (!get_config_uint32(sn, "chunk_size", &chunk_size)) { log_error("Couldn't read chunk size for snapshot."); return 0; Index: LVM2.2.02.54/lib/format1/import-export.c =================================================================== --- LVM2.2.02.54.orig/lib/format1/import-export.c 2009-10-29 17:38:51.000000000 +0100 +++ LVM2.2.02.54/lib/format1/import-export.c 2009-10-29 17:45:03.000000000 +0100 @@ -612,7 +612,7 @@ int import_snapshots(struct dm_pool *mem /* insert the snapshot */ if (!vg_add_snapshot(org, cow, NULL, org->le_count, NULL, - lvd->lv_chunk_size)) { + lvd->lv_chunk_size, 0)) { log_error("Couldn't add snapshot."); return 0; } Index: LVM2.2.02.54/tools/lvconvert.c =================================================================== --- LVM2.2.02.54.orig/tools/lvconvert.c 2009-10-29 17:38:52.000000000 +0100 +++ LVM2.2.02.54/tools/lvconvert.c 2009-10-29 17:45:03.000000000 +0100 @@ -865,7 +865,8 @@ static int lvconvert_snapshot(struct cmd return 0; } - if (!vg_add_snapshot(org, lv, NULL, org->le_count, NULL, lp->chunk_size)) { + if (!vg_add_snapshot(org, lv, NULL, org->le_count, NULL, + lp->chunk_size, 0)) { log_error("Couldn't create snapshot."); return 0; }