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.73/lib/metadata/segtype.h =================================================================== --- LVM2.2.02.73.orig/lib/metadata/segtype.h 2010-09-10 17:44:50.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/segtype.h 2010-09-10 18:54:39.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.73/lib/multisnapshot/multisnapshot.c =================================================================== --- LVM2.2.02.73.orig/lib/multisnapshot/multisnapshot.c 2010-09-10 18:32:55.000000000 +0200 +++ LVM2.2.02.73/lib/multisnapshot/multisnapshot.c 2010-09-10 18:54:39.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.73/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.73.orig/lib/snapshot/snapshot.c 2010-09-10 17:44:46.000000000 +0200 +++ LVM2.2.02.73/lib/snapshot/snapshot.c 2010-09-10 18:54:39.000000000 +0200 @@ -247,7 +247,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 DMEVENTD if (_get_snapshot_dso_path(cmd)) Index: LVM2.2.02.73/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.73.orig/lib/metadata/lv_manip.c 2010-09-10 18:54:36.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/lv_manip.c 2010-09-10 18:54:39.000000000 +0200 @@ -3193,6 +3193,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->snapshot && lv_is_multisnap_origin(org)) {