Introduce a SEG_NOEXPLICIT flag. The flag means that the segment cannot be explicitly created with lvcreate --type. It is used on shared snapshots, to prevent a crash when the user uses "multisnapshot" or "multisnap-snap" segment type. I also added it to legacy snapshots, but it is not needed there (the create routine already converts "snapshots" type to "striped"). Signed-off-by: Mikulas Patocka --- lib/metadata/lv_manip.c | 5 +++++ lib/metadata/segtype.h | 1 + lib/multisnapshot/multisnapshot.c | 4 ++-- lib/snapshot/snapshot.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) Index: LVM2.2.02.85/lib/metadata/segtype.h =================================================================== --- LVM2.2.02.85.orig/lib/metadata/segtype.h 2011-06-24 18:57:32.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/segtype.h 2011-06-24 18:58:40.000000000 +0200 @@ -37,6 +37,7 @@ struct dev_manager; #define SEG_MONITORED 0x00000080U #define SEG_REPLICATOR 0x00000100U #define SEG_REPLICATOR_DEV 0x00000200U +#define SEG_NOEXPLICIT 0x00000400U #define SEG_UNKNOWN 0x80000000U #define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0) Index: LVM2.2.02.85/lib/multisnapshot/multisnapshot.c =================================================================== --- LVM2.2.02.85.orig/lib/multisnapshot/multisnapshot.c 2011-06-24 18:57:32.000000000 +0200 +++ LVM2.2.02.85/lib/multisnapshot/multisnapshot.c 2011-06-24 18:58:40.000000000 +0200 @@ -255,7 +255,7 @@ int init_multiple_segtypes(struct cmd_co segtype->ops = &_multisnapshot_ops; segtype->name = "multisnapshot"; segtype->private = NULL; - segtype->flags = SEG_SNAPSHOT; + segtype->flags = SEG_SNAPSHOT | SEG_NOEXPLICIT; if (!lvm_register_segtype(lib, segtype)) return 0; @@ -270,7 +270,7 @@ int init_multiple_segtypes(struct cmd_co segtype->ops = &_multisnap_snap_ops; segtype->name = "multisnap-snap"; segtype->private = NULL; - segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED; + segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED | SEG_NOEXPLICIT; if (!lvm_register_segtype(lib, segtype)) return 0; Index: LVM2.2.02.85/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.85.orig/lib/snapshot/snapshot.c 2011-06-24 18:57:32.000000000 +0200 +++ LVM2.2.02.85/lib/snapshot/snapshot.c 2011-06-24 18:58:40.000000000 +0200 @@ -256,7 +256,7 @@ struct segment_type *init_segtype(struct segtype->ops = &_snapshot_ops; segtype->name = "snapshot"; segtype->private = NULL; - segtype->flags = SEG_SNAPSHOT; + segtype->flags = SEG_SNAPSHOT | SEG_NOEXPLICIT; #ifdef DEVMAPPER_SUPPORT # ifdef DMEVENTD Index: LVM2.2.02.85/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.85.orig/lib/metadata/lv_manip.c 2011-06-24 18:58:37.000000000 +0200 +++ LVM2.2.02.85/lib/metadata/lv_manip.c 2011-06-24 18:58:40.000000000 +0200 @@ -3672,6 +3672,11 @@ again: if (!(lp->segtype = get_segtype_from_string(cmd, "multisnap-snap"))) return_0; } + } else { + if (lp->segtype->flags & SEG_NOEXPLICIT) { + log_error("This type of segment cannot be explicitly created"); + return 0; + } } if (!lp->extents) {