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