ctdb shortcut locking

tridge at samba.org tridge at samba.org
Mon Apr 16 06:09:20 GMT 2007


Volker and Ronnie,

I've just checked in some very strange code! Have a look at
tests/lockwait.c in my bzr ctdb tree.

Basically it shows how we can do event driven tdb, with basically zero
overhead (at least for the common uncontended case).  This solves the
problem of how we can handle waiting on a tdb lock in the ctdb daemon.

Internally, it uses fork()+lock on the contended path, but its wrapped
in a little bit of magic that turns this into a event in our event
system, so basically the caller does a non-blocking tdb_chainlock(),
then if it blocks they use the lockwait() code to trigger an event
when the lock becomes available. When the callback happens the
tdb_chainlock() can be retried.

What I really like about this is we only pay a price in the contended
case, which I expect to be very rare. We also send no extra messages
over the unix domain socket.

What do you think?

Cheers, Tridge


More information about the samba-technical mailing list