From d315f17effc33ff6ab4c2ef5c03ef1d64842fc2d Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Tue, 17 Jan 2017 18:46:39 +0100 Subject: [PATCH] Work around LVM related race condition when using --force with LVM If an "lvremove" is immediately followed by an "lvcreate" for an LV with the same name, "mkswap" (and maybe other commands) occasionally fail with "Device or resource busy". Work around it by using sync and sleep. --- NEWS.markdown | 5 +++++ bin/xen-create-image | 4 ++++ debian/changelog | 1 + 3 files changed, 10 insertions(+) diff --git a/NEWS.markdown b/NEWS.markdown index ee1dc7e..6fd8a81 100644 --- a/NEWS.markdown +++ b/NEWS.markdown @@ -23,6 +23,11 @@ Bug Fixes Thanks Santiago Vila for the bug report and patch! (Closes Debian bug report #764625) * Fixes typo found by Lintian. +* Work around LVM related race condition when using --force with LVM: + If an "lvremove" is immediately followed by an "lvcreate" for an LV + with the same name, "mkswap" (and maybe other commands) occasionally + fail with "Device or resource busy". Work around it by using sync + and sleep. Distribution Releases Changes ----------------------------- diff --git a/bin/xen-create-image b/bin/xen-create-image index 3c77856..be1b7dc 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -3066,6 +3066,10 @@ sub createLVMBits logprint( "Removing $lvm_disk - since we're forcing the install\n"); runCommand("lvremove --force $lvm_disk", \%CONFIG); + runCommand("sync", \%CONFIG); + logprint( + "Sleeping a few seconds to avoid LVM race conditions...\n"); + sleep(3); } else { fail("ERROR: Xen guest $CONFIG{'hostname'} appears to be running.\nAborting.\n"); } diff --git a/debian/changelog b/debian/changelog index d1742a9..05d5dc3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ xen-tools (4.6.3~dev-1) UNRELEASED; urgency=medium + Support situations where distributions (e.g. Squeeze) might be EoL, but its archive signing key is still not removed from the default keyring. + + Workaround LVM related race condition when using --force with LVM. * Declare compliance with Debian Policy 3.9.8. (No changes needed.) * Use NEWS.markdown as upstream changelog, don't install it as docs. * Switch many URLs (upstream and in packaging) to https:// and update