[buildd-tools-devel] Bug#674682: schroot: Unable to remove LVM snapshots

Daniel Dehennin daniel.dehennin at baby-gnu.org
Sat May 26 18:08:16 UTC 2012


Package: schroot
Version: 1.4.26-1
Severity: important

Dear Maintainer,

I was unable to use sbuild with LVM schroots because of failures to
remove LVM snapshots with the following errors:

#+begin_src
Purging /«BUILDDIR»
Not cleaning session: cloned chroot in use
E: 05lvm:   Unable to deactivate open hati-sid--amd64--sbuild--ae3ae89c--e79c--4ce1--a4fd--8c70400724c2-cow (254:11)
E: 05lvm:   Failed to resume sid-amd64-sbuild-ae3ae89c-e79c-4ce1-a4fd-8c70400724c2.
E: 05lvm:   libdevmapper exiting with 1 device(s) still suspended.
#+end_src

A workaround is to remove the device mapper and the -cow with "dmsetup
remove"[1].

Here is a pull request and a patch to implement it.

Regards.

The following changes since commit 183821e17e600dd8a012d12600130181bc4d8fc2:

  po: Update (2012-05-23 23:49:48 +0100)

are available in the git repository at:

  git://git.baby-gnu.net/schroot.git tags/dad/fix-lvremove-troubles

for you to fetch changes up to a25a770a29421348928a5a89cf608053937e38ad:

  LVM snapshots are not always removed. (2012-05-26 20:06:42 +0200)

----------------------------------------------------------------
Add a workaround to avoid errors when removing snapshots.

Before the patch my system always fails to remove snapshots, with this
patch I do not experiment the failure anymore.

----------------------------------------------------------------
Daniel Dehennin (1):
      LVM snapshots are not always removed.

 etc/setup.d/05lvm |    6 ++++++
 1 file changed, 6 insertions(+)


From a25a770a29421348928a5a89cf608053937e38ad Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehennin at baby-gnu.org>
Date: Sat, 26 May 2012 19:51:27 +0200
Subject: [PATCH] LVM snapshots are not always removed.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On my system, "lvremove -f <SNAPSHOT>" always fails the first time,
making "sbuild" unusable since snapshots are left around.

-----
Purging /«BUILDDIR»
Not cleaning session: cloned chroot in use
E: 05lvm:   Unable to deactivate open hati-sid--amd64--sbuild--ae3ae89c--e79c--4ce1--a4fd--8c70400724c2-cow (254:11)
E: 05lvm:   Failed to resume sid-amd64-sbuild-ae3ae89c-e79c-4ce1-a4fd-8c70400724c2.
E: 05lvm:   libdevmapper exiting with 1 device(s) still suspended.
-----

This make LVM commands hangs until I do "dmsetup resume <ORIGINAL>".

I found several sources[1][2][3] about this troubles, one of the workaround
is to make direct calls to "dmsetup remove" before "lvremove".

This works great on my system.

* etc/setup.d/05lvm: Use dmsetup to remove the mapper device and the -cow
  before calling lvremove.

Footnotes:
[1]  http://bugs.debian.org/549691

[2]  https://bugzilla.redhat.com/show_bug.cgi?id=577798

[3]  https://www.redhat.com/archives/linux-lvm/2010-August/msg00029.html
---
 etc/setup.d/05lvm |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/etc/setup.d/05lvm b/etc/setup.d/05lvm
index 2ae7bd1..c3357cb 100755
--- a/etc/setup.d/05lvm
+++ b/etc/setup.d/05lvm
@@ -55,9 +55,15 @@ if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
 		--device="$CHROOT_LVM_SNAPSHOT_DEVICE" \
 		--pid=$PID || true
 
+	    
+	    MAPPER_DEVICE=`dmsetup info --noheadings -c -o name $CHROOT_LVM_SNAPSHOT_DEVICE`
 	    if [ "$VERBOSE" = "verbose" ]; then
+                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}" || true
+                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}-cow" || true
 		lvremove $LVM_VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" || true
 	    else
+                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}" > /dev/null || true
+                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}-cow"  > /dev/null || true
 		lvremove $LVM_VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" > /dev/null || true
 	    fi
 	else
-- 
1.7.10


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (90, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.4.0+hati.2 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages schroot depends on:
ii  libboost-filesystem1.49.0       1.49.0-3
ii  libboost-program-options1.49.0  1.49.0-3
ii  libboost-regex1.49.0            1.49.0-3
ii  libboost-system1.49.0           1.49.0-3
ii  libc6                           2.13-32
ii  libgcc1                         1:4.7.0-9
ii  liblockdev1                     1.0.3-1.4+b2
ii  libpam0g                        1.1.3-7.1
ii  libstdc++6                      4.7.0-9
ii  libuuid1                        2.20.1-5
ii  schroot-common                  1.4.26-1

schroot recommends no packages.

Versions of packages schroot suggests:
ii  aufs-modules | unionfs-modules  <none>
ii  btrfs-tools                     0.19+20120328-2
ii  debootstrap                     1.0.40
ii  lvm2                            2.02.95-3

-- Configuration Files:
/etc/schroot/sbuild/fstab changed:
/proc		/proc		none    rw,bind        0       0
/sys		/sys		none    rw,bind        0       0
/dev/pts	/dev/pts	none	rw,bind		0	0
tmpfs		/dev/shm	tmpfs	defaults	0	0
/var/lib/sbuild/build	/build	none	rw,bind	0	0
/var/cache/apt/archives /var/cache/apt/archives none rw,bind 0 0

/etc/schroot/setup.d/05lvm changed:
set -e
. "$SETUP_DATA_DIR/common-data"
. "$SETUP_DATA_DIR/common-functions"
if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
    . "$CHROOT_SCRIPT_CONFIG"
elif [ "$STATUS" = "ok" ]; then
    fatal "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist"
fi
if [ "$VERBOSE" = "verbose" ]; then
    LVM_VERBOSE="-v"
fi
if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
    if [ $STAGE = "setup-start" ]; then
	if [ ! "$DEVTYPE" "$CHROOT_DEVICE" ]; then
	    fatal "Device '$CHROOT_DEVICE' does not exist"
	fi
	if [ "$VERBOSE" = "verbose" ]; then
	    lvcreate $LVM_VERBOSE --snapshot --name "$CHROOT_LVM_SNAPSHOT_NAME" \
		"$CHROOT_DEVICE" $CHROOT_LVM_SNAPSHOT_OPTIONS
	else
	    lvcreate $LVM_VERBOSE --snapshot --name "$CHROOT_LVM_SNAPSHOT_NAME" \
		"$CHROOT_DEVICE" $CHROOT_LVM_SNAPSHOT_OPTIONS > /dev/null
	fi
    elif [ $STAGE = "setup-stop" ]; then
	if [ "$DEVTYPE" "$CHROOT_LVM_SNAPSHOT_DEVICE" ]; then
            # The lock needs to be dropped immediately before
            # destroying the device.  There is a small race here, but
            # the lock can't be dropped once the device has been
            # removed.
	    info "Removing device lock for $CHROOT_LVM_SNAPSHOT_DEVICE, owned by pid $PID"
            "$LIBEXEC_DIR/schroot-releaselock" \
		--device="$CHROOT_LVM_SNAPSHOT_DEVICE" \
		--pid=$PID || true
	    MAPPER_DEVICE=`dmsetup info --noheadings -c -o name $CHROOT_LVM_SNAPSHOT_DEVICE`
	    if [ "$VERBOSE" = "verbose" ]; then
                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}" || true
                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}-cow" || true
		lvremove $LVM_VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" || true
	    else
                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}" > /dev/null || true
                dmsetup remove -f "/dev/mapper/${MAPPER_DEVICE}-cow" > /dev/null || true
		lvremove $LVM_VERBOSE -f "$CHROOT_LVM_SNAPSHOT_DEVICE" > /dev/null || true
	    fi
	else
	    # The block device no longer exists, or was never created,
	    # for example on lvcreate failure.
	    warn "$CHROOT_LVM_SNAPSHOT_DEVICE does not exist (it may have been removed previously)"
	fi
    fi
fi


-- no debconf information


Footnotes: 
[1]  http://bugs.debian.org/549691#57

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20120526/72e9506a/attachment.pgp>


More information about the Buildd-tools-devel mailing list