# HG changeset patch # User Olaf Hering <olaf@aepfle.de> # Date 1350143934 -7200 # Node ID 5aa14d5afe6b1f35b23029ae90b7edb20367bbeb # Parent e0e1350dfe9b7a6cacb1378f75d8e6536d22eb2d hotplug/Linux: close lockfd after lock attempt When a HVM guest is shutdown some of the ''remove'' events can not claim the lock for some reason. Instead they try to grab the lock in a busy loop, until udev reaps the xen-hotplug-cleanup helper. After analyzing the resulting logfile its not obvious what the cause is. The only explanation is that bash (?) gets confused if the same lockfd is opened again and again. Closing it in each iteration seem to fix the issue. This was observed with sles11sp2 and 4.2 xend. Signed-off-by: Olaf Hering <olaf@aepfle.de> diff -r e0e1350dfe9b -r 5aa14d5afe6b tools/hotplug/Linux/locking.sh --- a/tools/hotplug/Linux/locking.sh +++ b/tools/hotplug/Linux/locking.sh @@ -59,6 +59,7 @@ claim_lock() print "y\n" if $fd_inum eq $file_inum; '' "$_lockfile" ) if [ x$rightfile = xy ]; then break; fi + eval "exec $_lockfd<&-" done }
Olaf Hering
2012-Oct-13 22:35 UTC
Re: [PATCH] hotplug/Linux: close lockfd after lock attempt
On Sat, Oct 13, Olaf Hering wrote:> hotplug/Linux: close lockfd after lock attempt > > When a HVM guest is shutdown some of the ''remove'' events can not claim > the lock for some reason. Instead they try to grab the lock in a busy > loop, until udev reaps the xen-hotplug-cleanup helper. > After analyzing the resulting logfile its not obvious what the cause is. > The only explanation is that bash (?) gets confused if the same lockfd > is opened again and again. Closing it in each iteration seem to fix the > issue.Can be reproduced with this testcase on sles11sp2, not on openSuSE 11.4: # cat test.sh set -x source locking.sh l=lock claim_lock $l sleep 1 release_lock $l # bash test.sh & bash test.sh & bash test.sh & bash test.sh & Olaf
Ian Campbell
2012-Oct-15 08:01 UTC
Re: [PATCH] hotplug/Linux: close lockfd after lock attempt
On Sat, 2012-10-13 at 23:35 +0100, Olaf Hering wrote:> On Sat, Oct 13, Olaf Hering wrote: > > > hotplug/Linux: close lockfd after lock attempt > > > > When a HVM guest is shutdown some of the ''remove'' events can not claim > > the lock for some reason. Instead they try to grab the lock in a busy > > loop, until udev reaps the xen-hotplug-cleanup helper. > > After analyzing the resulting logfile its not obvious what the cause is. > > The only explanation is that bash (?) gets confused if the same lockfd > > is opened again and again. Closing it in each iteration seem to fix the > > issue. > > Can be reproduced with this testcase on sles11sp2, not on openSuSE 11.4:So this is a bash bug? Have you reported it against bash? Ian.> > # cat test.sh > set -x > source locking.sh > > l=lock > claim_lock $l > sleep 1 > release_lock $l > > > # bash test.sh & bash test.sh & bash test.sh & bash test.sh & > > > Olaf > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Olaf Hering
2012-Oct-15 08:42 UTC
Re: [PATCH] hotplug/Linux: close lockfd after lock attempt
On Mon, Oct 15, Ian Campbell wrote:> On Sat, 2012-10-13 at 23:35 +0100, Olaf Hering wrote: > > On Sat, Oct 13, Olaf Hering wrote: > > > > > hotplug/Linux: close lockfd after lock attempt > > > > > > When a HVM guest is shutdown some of the ''remove'' events can not claim > > > the lock for some reason. Instead they try to grab the lock in a busy > > > loop, until udev reaps the xen-hotplug-cleanup helper. > > > After analyzing the resulting logfile its not obvious what the cause is. > > > The only explanation is that bash (?) gets confused if the same lockfd > > > is opened again and again. Closing it in each iteration seem to fix the > > > issue. > > > > Can be reproduced with this testcase on sles11sp2, not on openSuSE 11.4: > > So this is a bash bug? Have you reported it against bash?It does not happen with a newer bash: bash 3.2 from sles11sp2 fails, bash 4.1 from openSuSE 11.4 works. Olaf
Ian Campbell
2012-Oct-18 08:35 UTC
Re: [PATCH] hotplug/Linux: close lockfd after lock attempt
On Mon, 2012-10-15 at 09:42 +0100, Olaf Hering wrote:> On Mon, Oct 15, Ian Campbell wrote: > > > On Sat, 2012-10-13 at 23:35 +0100, Olaf Hering wrote: > > > On Sat, Oct 13, Olaf Hering wrote: > > > > > > > hotplug/Linux: close lockfd after lock attempt > > > > > > > > When a HVM guest is shutdown some of the ''remove'' events can not claim > > > > the lock for some reason. Instead they try to grab the lock in a busy > > > > loop, until udev reaps the xen-hotplug-cleanup helper. > > > > After analyzing the resulting logfile its not obvious what the cause is. > > > > The only explanation is that bash (?) gets confused if the same lockfd > > > > is opened again and again. Closing it in each iteration seem to fix the > > > > issue. > > > > > > Can be reproduced with this testcase on sles11sp2, not on openSuSE 11.4: > > > > So this is a bash bug? Have you reported it against bash? > > It does not happen with a newer bash: bash 3.2 from sles11sp2 fails, > bash 4.1 from openSuSE 11.4 works.I added a comment: # Some versions of bash appear to be buggy if the same # $_lockfile is opened repeatedly. Close the current fd here. and reference to the bash version in the commit message. acked + applied. Thanks.> > Olaf