Extend virtual segments rather than creating new segments. If we extend the virtual snapshot, LVM attempts to create a new segment. This causes crash because the new segment is not initialized. Change lv_extend function to extend the last segment instead of creating new. Signed-off-by: Mikulas Patocka --- lib/metadata/lv_manip.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: lvm2/lib/metadata/lv_manip.c =================================================================== --- lvm2.orig/lib/metadata/lv_manip.c +++ lvm2/lib/metadata/lv_manip.c @@ -1755,8 +1755,17 @@ int lv_extend(struct logical_volume *lv, int r = 1; struct alloc_handle *ah; - if (segtype_is_virtual(segtype)) + if (segtype_is_virtual(segtype)) { + struct lv_segment *seg = last_seg(lv); + if (seg && seg->segtype == segtype) { + seg->area_len += extents; + seg->len += extents; + lv->le_count += extents; + lv->size += (uint64_t) extents * lv->vg->extent_size; + return 1; + } return lv_add_virtual_segment(lv, status, extents, segtype); + } if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors, 0, 0, extents, allocatable_pvs, alloc, NULL)))