[OpenAFS-devel] crfree() and locking

chas williams - CONTRACTOR chas@cmf.nrl.navy.mil
Fri, 07 Dec 2007 09:54:11 -0500


In message <47591319.1010700@pclella.cern.ch>,Rainer Toebbicke writes:
>I'm currently looking into locking issues in some high-frequency paths 
>in osi_vnodeops.c causing major performance drops on multi-way nodes.

linux?

>What I get confused about is crfree(): it is frequently (almost 
>systematically) called after releasing the AFS global lock, mimicking 
>crref() which obviously is better outside the global lock.
>
>Is this actually correct? The creds are passed to higher level 
>routines. What if any of those increments the reference count and 
>correspondingly cares about a crfree() later which would decrement the 
>reference count? Then we could be faced with a counter being 
>decremented outside a lock - I don't see how this could be guaranteed 
>to happen only sequentially.

yes, this does seem like a bit of a flaw.  i certainly see a potential for
racing considering this code doesnt use decrement and test.  the cred_t
implementation is somewhat linux specific given that they dont have a
bsd-like implementation for their filesystem code.  i guess that afs
glock tends to serialize operations but given the usage of crfree
and crhold it might be better to be safe than sorry.