Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: locked hotplug scripts



On Wed, Mar 30, 2016 at 02:45:39PM +0200, Manuel Bouyer wrote:
> On Wed, Mar 30, 2016 at 02:06:12PM +0200, Christoph Badura wrote:
> > On Wed, Mar 30, 2016 at 01:33:00PM +0200, Manuel Bouyer wrote:
> > > Even with 5 disks, I've never been able to reproduce port-xen/50659
> > > on my system. 
> > 
> > Really?  The unmodified block script would cause "xl create" to immediately
> > bomb out because of it wanted to allocate the same vnd more than once.
> > That was easily reproducible.
> 
> I guess it depends on various factors. The critical section isn't
> that long and can be executed in less than 1/hz. But if you're unlucky it will
> context-switch at the wrong place.

Maybe your test machine is too fast.  My testing is on a Core i3-2100
@ 3.1 GHz and a Xeon X3430 @ 2.4 GHz.

> I didn't pay attention to _have_lock.
> But then the release_lock() just before error() is not needed (or
> release_lock() in error() is not needed)

Yes, technically, it isn't required to release_lock() before error(), as
the cleanup code will release the lock.

However, it is good and defensive programming to release resources, and
especially locks, in an obvious way when you don't need them anymore.

Especially with locks one wants to see immediately by scanning the
code after the start of a critical section that the lock is correctly
released on all exit paths out of the critical section.  Otherwise you
go insane trying to figure out where the locks are released, if at all.

And that is I will keep the release_lock() before the error(). :-)

--chris


Home | Main Index | Thread Index | Old Index