Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / doc / txt / afs_rwlocks
CommitLineData
805e021f
CE
1Copyright 2000, International Business Machines Corporation and others.
2All Rights Reserved.
3
4This software has been released under the terms of the IBM Public
5License. For details, see the LICENSE file in the top-level source
6directory or online at http://www.openafs.org/dl/license10.html
7
8Locking order (in order of locking) --
9
100.1 afs_discon_lock. Locks the current disconnected state, so it
11 can't be changed under active operations
12
131. PVN lock in cache entry. Locks out pvn operations on vnode from
14our own layer.
15
162. VCache entries. Multiple ones can be locked, in which case
17they're locked in order of vnode within the same volume. afs_AccessOK
18is called before locking other entries.
19
203. VCache entry vlock (Solaris only).
21
224. DCache entries. Tentatively, multiple ones can be locked now.
23Locking order between dcache entries is in increasing offset order.
24However, if it turns out we never need to lock multiple dcache's,
25we should just say it's not allowed, and simplify things.
26
275. afs_xdcache. Protects the dcache hash tables and afs_index* in
28afs_dcache.c. As with afs_xvcache below, a newly created dcache
29entries can be locked while holding afs_xdcache.
30
31Bugs: afs_xvcache locked before afs_xdcache in afs_remove, afs_symlink,
32etc in the file afs_vnodeops.c
33
345.1. unixusers. unixuser structs are locked before afs_xvcache in PSetTokens
35via afs_NotifyUser and via afs_ResetUserConns. They are also locked before
36afs_xvcache in afs_Analyze via afs_BlackListOnce.
37
386. afs_xvcache. Must be able to load new cache entries while holding
39locks on others. Note this means you can't lock a cache entry while
40holding either of this lock, unless, as in afs_create, the cache entry
41is actually created while the afs_xvcache is held.
42
436a. afs_disconDirtyLock. Protects the disconnected dirty and shadow
44vcache queues. Must be after afs_xvcache, because we lock this whilst
45hold xvcache in afs_create.
46
476b. afs_xvreclaim. Protects the lookaside reclaim list. Locked inside
48xvcache in FlushReclaimedVcaches via NewVCache or the 1 min loop.
49
507. afs_xvcb. Volume callback lock. Locked before afs_xserver in
51afs_RemoveVCB.
52
538. afs_xvolume -- allows low-level server etc stuff to happen while
54creating a volume?
55
569. afs_xuser -- afs_xuser is locked before afs_xserver and afs_xconn
57in PUnlog.
58
5910. afs_xcell -- afs_xcell locked before afs_xserver in afs_GetCell.
60
6111. afs_xserver -- locked before afs_xconn in afs_ResetUserConns.
62
6312. afs_xsrvAddr -- afs_xserver locked before afs_xsrvAddr in
64afs_CheckServers.
65
6613. afs_xconn -- see above
67
6814. Individual volume locks. Must be after afs_xvolume so we can
69iterate over all volumes without others being inserted/deleted. Same
70hack doesn't work for cache entry locks since we need to be able to
71lock multiple cache entries (but not multiple volumes) simultaneously.
72
73In practice this appears to only be used to protect the status, name,
74and root vnode and uniq. other users are not excluded, although
75exclusion of multiple installs of a volume entry have been poorly done.
76
7715. afs_xdnlc -- locked after afs_xvcache in afs_osidnlc.c. Shouldn't
78interact with any of the other locks.
79
8016. afs_xcbhash -- No code which holds xcbhash (all of it is in
81afs_cbqueue.c) (note: this doesn't seem to be true -- it's used
82elsewhere too) attempts to get any other locks, so it should always
83be obtained last. It is locked in afs_DequeueCallbacks which is
84called from afs_FlushVCache with afs_xvcache write-locked.
85
8617. afs_dynrootDirLock -- afs_GetDynroot returns the lock held,
87afs_PutDynroot releases it.
88
8918. Dcache entry mflock -- used to atomize accesses and updates to
90dcache mflags.
91
9219. DCache entry tlock -- used to make atomic reads or writes to
93the dcache refcount.
94
95***** RX_ENABLE_LOCKS
96
97Many fine grained locks are used by Rx on the AIX4.1 platform. These
98need to be explained.
99
100***** GLOBAL LOCKS
101
10298. afs_global_lock -- This lock provides a non-preemptive environment
103for the bulk of the AFS kernel code on platforms that require it.
104Presently this includes SunOS5 and SGI53 systems. This lock is dropped
105and reaquired frequently, especially around calls back to the OS that
106may reenter AFS such as vn_rele.
107
108 Generally, this lock should not be used to explicitly avoid locking
109data structures that need synchronization. However, much existing code
110is deficient in this regard (e.g. afs_getevent).
111
112***** OS LOCKS
113
114100. The vnode lock on SunOS and SGI53 protects the its reference count.
115
116101. NETPRI/USERPRI -- These are not really locks but provide mutual
117exclusion against packet and timer interrupts.