discon needs static_inline macro
[openafs.git] / src / afs / discon.h
1 #ifndef _DISCON_H
2 #define _DISCON_H
3
4 #if !defined(inline) && !defined(__GNUC__)
5 #define inline
6 #endif
7
8 extern afs_int32    afs_is_disconnected;
9 extern afs_int32    afs_is_discon_rw;
10 extern afs_int32    afs_in_sync;
11 extern afs_rwlock_t afs_discon_lock;
12
13 extern struct afs_q afs_disconDirty;
14 extern struct afs_q afs_disconShadow;
15 extern afs_rwlock_t afs_disconDirtyLock;
16 extern afs_int32    afs_ConflictPolicy;
17
18 extern afs_uint32 afs_DisconVnode; /* XXX: not protected. */
19
20 extern int afs_WriteVCacheDiscon(register struct vcache *avc,
21                                         register struct AFSStoreStatus *astatus,
22                                         struct vattr *attrs);
23 extern int afs_ResyncDisconFiles(struct vrequest *areq,
24                                         afs_ucred_t *acred);
25 extern void afs_RemoveAllConns(void);
26 extern void afs_GenFakeFid(struct VenusFid *afid, afs_uint32 avtype, 
27                            int lock);
28 extern void afs_GenShadowFid(struct VenusFid *afid);
29 extern void afs_GenDisconStatus(struct vcache *adp,
30                                         struct vcache *avc,
31                                         struct VenusFid *afid,
32                                         struct vattr *attrs,
33                                         struct vrequest *areq,
34                                         int file_type);
35 extern int afs_MakeShadowDir(struct vcache *avc, struct dcache *adc);
36 extern void afs_DeleteShadowDir(struct vcache *avc);
37 extern struct dcache *afs_FindDCacheByFid(struct VenusFid *afid);
38 extern void afs_UpdateStatus(struct vcache *avc,
39                                         struct VenusFid *afid,
40                                         struct vrequest *areq,
41                                         struct AFSFetchStatus *Outsp,
42                                         struct AFSCallBack *acb,
43                                         afs_uint32 start);
44 extern void afs_DisconDiscardAll(afs_ucred_t *);
45
46 #define AFS_IS_DISCONNECTED (afs_is_disconnected)
47 #define AFS_IS_DISCON_RW (afs_is_discon_rw)
48 #define AFS_IN_SYNC (afs_in_sync)
49 #define AFS_DISCON_LOCK() ObtainReadLock(&afs_discon_lock)
50 #define AFS_DISCON_UNLOCK() ReleaseReadLock(&afs_discon_lock)
51
52 /* Call with avc lock held */
53 static_inline void afs_DisconAddDirty(struct vcache *avc, int operation, int lock) {
54     if (!avc->f.ddirty_flags) {
55         if (lock) 
56             ObtainWriteLock(&afs_xvcache, 702);
57         ObtainWriteLock(&afs_disconDirtyLock, 703);
58         QAdd(&afs_disconDirty, &avc->dirtyq);
59         osi_vnhold(avc, 0);
60         ReleaseWriteLock(&afs_disconDirtyLock);
61         if (lock)
62             ReleaseWriteLock(&afs_xvcache);
63     }
64     avc->f.ddirty_flags |= operation;
65
66
67 /* Call with avc lock held */
68 static_inline void afs_DisconRemoveDirty(struct vcache *avc) {
69     ObtainWriteLock(&afs_disconDirtyLock, 704);
70     QRemove(&avc->dirtyq);
71     ReleaseWriteLock(&afs_disconDirtyLock);
72     avc->f.ddirty_flags = 0;
73     afs_PutVCache(avc);
74 }
75 #endif /* _DISCON_H */