[OpenAFS] namei interface lockf buggy on Solaris (and probably HP-UX and AIX)

Rainer Toebbicke rtb@pclella.cern.ch
Mon, 11 Sep 2006 13:04:45 +0200


John Rudd wrote:
> Hm.  Your patch seems to do this:
> 
> change:
> lock/unlock from current to eof
> 
> to:
> seek 0
> lock/unlock from (current=0) to eof
> 
> 
> Which means you're potentially destroying the notion of "current" (I 
> don't know if that's important in AFS code or not, but it seems like, at 
> best, a bad idea ... and at worst, a potentially disastrous idea).
> 
> 

If you look at the code you'll see that in all cases an explicit seek 
is done before any read/write. Funny enough, usually after the lockf() 
meaning the lock wasn't on the right "section" anyway.

> I would suggest:
> 
> save current to tmp
> seek 0
> lock/unlock from (current=0) to eof
> seek tmp
> 
> 

Right, only that for a correct flock() emulation you'd also have to 
hold the necessary locks to prevent another thread from seeking away 
between the two calls... ideally something that is independent of the 
namei locking. And the code would gain in readability had the ifdefs 
been packed into a macro or subroutine.

In this precise context however, and without wiping cleaner than 
clean: why spend yet another system call on something that nobody 
cares about.


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rainer Toebbicke
European Laboratory for Particle Physics(CERN) - Geneva, Switzerland
Phone: +41 22 767 8985       Fax: +41 22 767 7155