Copyright 2000, International Business Machines Corporation and others.
All Rights Reserved.

This software has been released under the terms of the IBM Public
License.  For details, see the LICENSE file in the top-level source
directory or online at http://www.openafs.org/dl/license10.html

Locking order (in order of locking) --

1.  PVN lock in cache entry.  Locks out pvn operations on vnode from
our own layer.

2.  VCache entries.  Multiple ones can be locked, in which case
they're locked in order of vnode within the same volume.  afs_AccessOK
is called before locking other entries.

3.  VCache entry vlock (Solaris only).

4.  DCache entries.  Tentatively, multiple ones can be locked now.
Locking order between dcache entries is in increasing offset order.
However, if it turns out we never need to lock multiple dcache's,
we should just say it's not allowed, and simplify things.

5. afs_xdcache.  Protects the dcache hash tables and afs_index* in
afs_dcache.c.  As with afs_xvcache below, a newly created dcache
entries can be locked while holding afs_xdcache.

Bugs: afs_xvcache locked before afs_xdcache in afs_remove, afs_symlink,
etc in the file afs_vnodeops.c

6. afs_xvcache.  Must be able to load new cache entries while holding
locks on others.  Note this means you can't lock a cache entry while
holding either of this lock, unless, as in afs_create, the cache entry
is actually created while the afs_xvcache is held.

6a. afs_xvreclaim. Protects the lookaside reclaim list. Locked inside xvcache in FlushReclaimedVcaches via NewVCache or the 1 min loop.

7. afs_xvcb.  Volume callback lock.  Locked before afs_xserver in
afs_RemoveVCB.

8. afs_xvolume -- allows low-level server etc stuff to happen while
creating a volume?

9.  afs_xuser -- afs_xuser is locked before afs_xserver and afs_xconn
in PUnlog.

10. afs_xcell -- afs_xcell locked before afs_xserver in afs_GetCell.

11. afs_xserver -- locked before afs_xconn in afs_ResetUserConns.

12. afs_xsrvAddr -- afs_xserver locked before afs_xsrvAddr in
afs_CheckServers.

13. afs_xconn  -- see above

14. Individual volume locks.  Must be after afs_xvolume so we can
iterate over all volumes without others being inserted/deleted.  Same
hack doesn't work for cache entry locks since we need to be able to
lock multiple cache entries (but not multiple volumes) simultaneously.

15. afs_xdnlc -- locked after afs_xvcache in afs_osidnlc.c.  Shouldn't 
interact with any of the other locks. 

16. afs_xcbhash -- No code which holds xcbhash (all of it is in
afs_cbqueue.c) (note: this doesn't seem to be true -- it's used
elsewhere too) attempts to get any other locks, so it should always
be obtained last.  It is locked in afs_DequeueCallbacks which is
called from afs_FlushVCache with afs_xvcache write-locked.

17. afs_dynrootDirLock -- afs_GetDynroot returns the lock held,
afs_PutDynroot releases it.

18. Dcache entry mflock -- used to atomize accesses and updates to
dcache mflags.

19. DCache entry tlock -- used to make atomic reads or writes to
the dcache refcount.

***** RX_ENABLE_LOCKS

Many fine grained locks are used by Rx on the AIX4.1 platform.  These
need to be explained.

***** GLOBAL LOCKS

98. afs_global_lock -- This lock provides a non-preemptive environment
for the bulk of the AFS kernel code on platforms that require it.
Presently this includes SunOS5 and SGI53 systems.  This lock is dropped
and reaquired frequently, especially around calls back to the OS that
may reenter AFS such as vn_rele.

    Generally, this lock should not be used to explicitly avoid locking
data structures that need synchronization.  However, much existing code
is deficient in this regard (e.g. afs_getevent).

***** OS LOCKS

100. The vnode lock on SunOS and SGI53 protects the its reference count.

101. NETPRI/USERPRI -- These are not really locks but provide mutual
exclusion against packet and timer interrupts.
