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.85/lib/metadata/lv_alloc.h =================================================================== --- LVM2.2.02.85.orig/lib/metadata/lv_alloc.h 2011-05-20 14:57:16.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/lv_alloc.h 2011-05-23 15:59:19.000000000 +0200 @@ -30,7 +30,8 @@ struct lv_segment *alloc_lv_segment(stru struct lv_segment *pvmove_source_seg); struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv, - uint64_t status, uint32_t old_le_count); + uint64_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.85/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.85.orig/lib/metadata/lv_manip.c 2011-05-23 15:59:13.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/lv_manip.c 2011-05-23 15:59:19.000000000 +0200 @@ -252,12 +252,14 @@ struct lv_segment *alloc_lv_segment(stru } struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv, - uint64_t status, uint32_t old_le_count) + uint64_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; @@ -3768,7 +3770,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.85/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.85.orig/lib/metadata/metadata-exported.h 2011-05-23 15:59:04.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/metadata-exported.h 2011-05-23 15:59:19.000000000 +0200 @@ -65,6 +65,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 @@ -644,7 +645,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, - 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.85/lib/metadata/snapshot_manip.c =================================================================== --- LVM2.2.02.85.orig/lib/metadata/snapshot_manip.c 2011-05-23 15:59:04.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/snapshot_manip.c 2011-05-23 15:59:19.000000000 +0200 @@ -151,7 +151,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, const char *exception_store, - uint32_t chunk_size) + uint32_t chunk_size, unsigned snapshot_flags) { struct logical_volume *snap; struct lv_segment *seg; @@ -176,9 +176,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, 0); } Index: LVM2.2.02.85/lib/multisnapshot/multisnapshot.c =================================================================== --- LVM2.2.02.85.orig/lib/multisnapshot/multisnapshot.c 2011-05-23 15:59:08.000000000 +0200 +++ LVM2.2.02.85/lib/multisnapshot/multisnapshot.c 2011-05-23 15:59:19.000000000 +0200 @@ -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.85/lib/format1/import-export.c =================================================================== --- LVM2.2.02.85.orig/lib/format1/import-export.c 2011-05-23 15:59:04.000000000 +0200 +++ LVM2.2.02.85/lib/format1/import-export.c 2011-05-23 15:59:19.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, NULL, - lvd->lv_chunk_size)) { + lvd->lv_chunk_size, 0)) { 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:59:04.000000000 +0200 +++ LVM2.2.02.85/tools/lvconvert.c 2011-05-23 15:59:19.000000000 +0200 @@ -1409,7 +1409,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; }