1 Copyright 2000, International Business Machines Corporation and others.
4 This software has been released under the terms of the IBM Public
5 License. For details, see the LICENSE file in the top-level source
6 directory or online at http://www.openafs.org/dl/license10.html
8 Locking order (in order of locking) --
10 1. PVN lock in cache entry. Locks out pvn operations on vnode from
13 2. VCache entries. Multiple ones can be locked, in which case
14 they're locked in order of vnode within the same volume. afs_AccessOK
15 is called before locking other entries.
17 3. VCache entry vlock (Solaris only).
19 4. DCache entries. Tentatively, multiple ones can be locked now.
20 Locking order between dcache entries is in increasing offset order.
21 However, if it turns out we never need to lock multiple dcache's,
22 we should just say it's not allowed, and simplify things.
24 5. afs_xdcache. Protects the dcache hash tables and afs_index* in
25 afs_dcache.c. As with afs_xvcache below, a newly created dcache
26 entries can be locked while holding afs_xdcache.
28 Bugs: afs_xvcache locked before afs_xdcache in afs_remove, afs_symlink,
29 etc in the file afs_vnodeops.c
31 6. afs_xvcache. Must be able to load new cache entries while holding
32 locks on others. Note this means you can't lock a cache entry while
33 holding either of this lock, unless, as in afs_create, the cache entry
34 is actually created while the afs_xvcache is held.
36 6a. afs_xvreclaim. Protects the lookaside reclaim list. Locked inside xvcache in FlushReclaimedVcaches via NewVCache or the 1 min loop.
38 7. afs_xvcb. Volume callback lock. Locked before afs_xserver in
41 8. afs_xvolume -- allows low-level server etc stuff to happen while
44 9. afs_xuser -- afs_xuser is locked before afs_xserver and afs_xconn
47 10. afs_xcell -- afs_xcell locked before afs_xserver in afs_GetCell.
49 11. afs_xserver -- locked before afs_xconn in afs_ResetUserConns.
51 12. afs_xsrvAddr -- afs_xserver locked before afs_xsrvAddr in
54 13. afs_xconn -- see above
56 14. Individual volume locks. Must be after afs_xvolume so we can
57 iterate over all volumes without others being inserted/deleted. Same
58 hack doesn't work for cache entry locks since we need to be able to
59 lock multiple cache entries (but not multiple volumes) simultaneously.
61 15. afs_xdnlc -- locked after afs_xvcache in afs_osidnlc.c. Shouldn't
62 interact with any of the other locks.
64 16. afs_xcbhash -- No code which holds xcbhash (all of it is in
65 afs_cbqueue.c) (note: this doesn't seem to be true -- it's used
66 elsewhere too) attempts to get any other locks, so it should always
67 be obtained last. It is locked in afs_DequeueCallbacks which is
68 called from afs_FlushVCache with afs_xvcache write-locked.
70 17. afs_dynrootDirLock -- afs_GetDynroot returns the lock held,
71 afs_PutDynroot releases it.
73 18. Dcache entry mflock -- used to atomize accesses and updates to
76 19. DCache entry tlock -- used to make atomic reads or writes to
81 Many fine grained locks are used by Rx on the AIX4.1 platform. These
86 98. afs_global_lock -- This lock provides a non-preemptive environment
87 for the bulk of the AFS kernel code on platforms that require it.
88 Presently this includes SunOS5 and SGI53 systems. This lock is dropped
89 and reaquired frequently, especially around calls back to the OS that
90 may reenter AFS such as vn_rele.
92 Generally, this lock should not be used to explicitly avoid locking
93 data structures that need synchronization. However, much existing code
94 is deficient in this regard (e.g. afs_getevent).
98 100. The vnode lock on SunOS and SGI53 protects the its reference count.
100 101. NETPRI/USERPRI -- These are not really locks but provide mutual
101 exclusion against packet and timer interrupts.