[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Linux-cluster] Some GDLM questions

On Thu, Jul 08, 2004 at 09:09:49AM -0400, Jeff wrote:
> Monday, July 5, 2004, 5:31:35 AM, Patrick Caulfield wrote:
> > On Sat, Jul 03, 2004 at 10:33:56AM -0400, Jeff wrote:
> >> These are from reviewing http://people.redhat.com/~teigland/sca.pdf
> >> and the CVS copy of cluster/dlm/doc/libdlm.txt.
> >> ------------------------------------------------------------------
> >> 
> >> If a program requests a lock on the AST side can it wait for
> >> the lock to complete without returning from the original AST
> >> routine?  Would it use the poll/select mechanism to do this?
> > In kernel space you shouldn't wait or do much work in the AST routine or
> > you can block the kernel's AST delivery thread. You can call dlm_lock() in an
> > AST routine though.
> > In userspace you can do pretty much what you like in the AST routine as (by
> > default) they run in a seperate thread - see libdlm for more details on this.
> Thanks for the answers. One more question about acquiring locks in
> the worker thread.
> Assuming I'm using pthreads if I want to call dlm_lock() in the worker
> thread (AST routine) and I need to wait for that dlm_lock() call to complete
> would I call dlm_get_fd() and loop calling dlm_dispatch() until I see that
> the lock completes? This involves dlm_dispatch() calling itself
> recursively which I assume is going to be ok.

That should work fine, though I must admit I haven't tried it. The routines are
all re-entrant (of course).
> Can you call dlm_pthread_init() more than once to start multiple
> service threads? I have some routines which are called
> both by the mainline code and as an AST routine. I'm wondering if I
> need them to be aware of how they're called or whether they can
> always simply open the fd and use dlm_dispatch if they need to
> issue a 'blocking' dlm_lock() call.

Currently you can't have multiple dispatch routines by using library's
pthread_init calls. 

The threads don't really care whether they are AST threads or work threads -
all they do is read data from the DLM's fd and call the routine specified by
astaddr. I suppose one hazard of issuing more lock requests in the AST routine
is that you will need to keep a track of which lock requests you have had ASTs
for - in cast mainline issues any more lock requests in the meantime. You will
have to make sure that they get dispatched as well as your nested one. If course
this will happen in dlm_dispatch() but you don't know whose lock has been
dispatched each time.

Things might be a little clearer if you had a look inside libdlm.c - it's
actually quite as simple little library. One warning...try to avoid calling the
kernel bits yourself; I don't want to change the userland/kernel API but if it
becomes necessary the library will always be modified to cope.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]