[libvirt] [PATCH] storage: Wait udev events are handled before removing lvm vol

Related #BZ: https://bugzilla.redhat.com/show_bug.cgi?id=702260. There are two problems described in the BZ: 1) "Can't remove open logical volume". 2) "Unable to deactivate logical volume "foo"" This patch just intends to fix 2), as 1) is expected if the vol is still used by something, and you never known if "lvchange -an" will fail or not either (sometime, it will succeed, sometimes not). We'd better not look for trouble, :-) For 2), that's caused by race between lvremove and udev event handling, the only workable way now is to wait the events handling are finished, though it might introduce latencies, as "udevadmin settle" exits after *all* events are handled, it's the only way we can fix the racing in libvirt layer. See https://bugzilla.redhat.com/show_bug.cgi?id=570359 for more details. --- src/storage/storage_backend_logical.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 4f42047..23d80cb 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -686,6 +686,8 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, virCheckFlags(0, -1); + virFileWaitForDevices(); + if (virRun(cmdargv, NULL) < 0) return -1; -- 1.7.6

On 09/21/2011 12:52 AM, Osier Yang wrote:
Related #BZ: https://bugzilla.redhat.com/show_bug.cgi?id=702260.
There are two problems described in the BZ: 1) "Can't remove open logical volume". 2) "Unable to deactivate logical volume "foo""
This patch just intends to fix 2), as 1) is expected if the vol is still used by something, and you never known if "lvchange -an" will fail or not either (sometime, it will succeed, sometimes not). We'd better not look for trouble, :-)
For 2), that's caused by race between lvremove and udev event handling, the only workable way now is to wait the events handling are finished, though it might introduce latencies, as "udevadmin settle" exits after *all* events are handled, it's the only way we can fix the racing in libvirt layer.
See https://bugzilla.redhat.com/show_bug.cgi?id=570359 for more details.
In particular, https://bugzilla.redhat.com/show_bug.cgi?id=570359#c28 is the recommendation to use 'udevadm settle' prior to lvremove. ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2011年09月21日 23:18, Eric Blake 写道:
On 09/21/2011 12:52 AM, Osier Yang wrote:
Related #BZ: https://bugzilla.redhat.com/show_bug.cgi?id=702260.
There are two problems described in the BZ: 1) "Can't remove open logical volume". 2) "Unable to deactivate logical volume "foo""
This patch just intends to fix 2), as 1) is expected if the vol is still used by something, and you never known if "lvchange -an" will fail or not either (sometime, it will succeed, sometimes not). We'd better not look for trouble, :-)
For 2), that's caused by race between lvremove and udev event handling, the only workable way now is to wait the events handling are finished, though it might introduce latencies, as "udevadmin settle" exits after *all* events are handled, it's the only way we can fix the racing in libvirt layer.
See https://bugzilla.redhat.com/show_bug.cgi?id=570359 for more details.
In particular, https://bugzilla.redhat.com/show_bug.cgi?id=570359#c28 is the recommendation to use 'udevadm settle' prior to lvremove.
ACK.
Pushed Osier
participants (2)
-
Eric Blake
-
Osier Yang