[OpenAFS] File locking in AFS

Craig_Everhart@transarc.com Craig_Everhart@transarc.com
Wed, 19 Sep 2001 09:39:16 -0400 (EDT)


Sure, read and write locks work fine with AFS with the caveat that locks
on subranges of the file don't work.  That is, if you read-lock or
write-lock the whole range of a file, that works fine, but if you
read-lock or write-lock a byte range smaller than the entire file, the
lock request is *ignored.*

The way locking works is strictly advisory: possession of locks is
independent of whether I/O may be done on the file.

On Unix@-(tm), fcntl() and/or lockf() calls may be used to set locks. 
Locks are held until released by the calling client (or by a crash or
the like), so a held read-lock is not invalidated by a write-lock
request.  Instead, the write-lock is denied.  The strategy is that
read-locks can be shared (held concurrently by multiple applications,
potentially on many clients) while write-locks are exclusive (held by at
most one application on one client at a time).  Furthermore, read-locks
and write-locks exclude one another.

		Craig