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.60/lib/metadata/segtype.h =================================================================== --- LVM2.2.02.60.orig/lib/metadata/segtype.h 2010-02-08 14:54:22.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/segtype.h 2010-02-08 20:30:03.000000000 +0100 @@ -35,6 +35,7 @@ struct dev_manager; #define SEG_VIRTUAL 0x00000020U #define SEG_CANNOT_BE_ZEROED 0x00000040U #define SEG_MONITORED 0x00000080U +#define SEG_NOEXPLICIT 0x00000100U #define SEG_UNKNOWN 0x80000000U #define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0) Index: LVM2.2.02.60/lib/multisnapshot/multisnapshot.c =================================================================== --- LVM2.2.02.60.orig/lib/multisnapshot/multisnapshot.c 2010-02-08 20:15:25.000000000 +0100 +++ LVM2.2.02.60/lib/multisnapshot/multisnapshot.c 2010-02-08 20:30:03.000000000 +0100 @@ -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.60/lib/snapshot/snapshot.c =================================================================== --- LVM2.2.02.60.orig/lib/snapshot/snapshot.c 2010-02-08 14:05:50.000000000 +0100 +++ LVM2.2.02.60/lib/snapshot/snapshot.c 2010-02-08 20:30:03.000000000 +0100 @@ -344,7 +344,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, &dso)) Index: LVM2.2.02.60/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.60.orig/lib/metadata/lv_manip.c 2010-02-08 20:29:18.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/lv_manip.c 2010-02-08 20:30:03.000000000 +0100 @@ -3052,6 +3052,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)) {