From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9053 invoked by alias); 13 Jan 2010 01:47:19 -0000 Received: (qmail 9032 invoked by uid 9805); 13 Jan 2010 01:47:18 -0000 Date: Wed, 13 Jan 2010 01:47:00 -0000 Message-ID: <20100113014718.9030.qmail@sourceware.org> From: snitzer@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/tools lvconvert.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00068.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-01-13 01:47:18 Modified files: tools : lvconvert.c Log message: Do not allow merging over mounted logical volumes. When preserving origin, check that the snapshot is not mounted. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111 --- LVM2/tools/lvconvert.c 2010/01/13 01:45:16 1.110 +++ LVM2/tools/lvconvert.c 2010/01/13 01:47:18 1.111 @@ -1058,6 +1058,7 @@ int r = 0; struct logical_volume *origin = origin_from_cow(lv); struct lv_segment *cow_seg = find_cow(lv); + struct lvinfo info; /* Check if merge is possible */ if (cow_seg->status & SNAPSHOT_MERGE) { @@ -1070,6 +1071,27 @@ return 0; } + /* + * Prevent merge with open device(s) as it would likely lead + * to application/filesystem failure. + * + * FIXME testing open_count is racey; snapshot-merge target's + * constructor and DM should prevent appropriate devices from + * being open. + */ + if (lv_info(cmd, origin, &info, 1, 0)) { + if (info.open_count) { + log_error("Can't merge over open origin volume"); + return 0; + } + } + if (lv_info(cmd, lv, &info, 1, 0)) { + if (info.open_count) { + log_error("Can't merge when snapshot is open"); + return 0; + } + } + init_snapshot_merge(cow_seg, origin); /* store vg on disk(s) */