2ad358ee6a7616dafa40669bac94954ba734076f
[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_LOGGING 0
7 #define AFS_IS_DISCON_RW 0
8 #define AFS_IN_SYNC 0
9 #define AFS_DISCON_LOCK()
10 #define AFS_DISCON_UNLOCK()
11
12 #define AFS_DISCON_ADD_DIRTY(avc)
13
14 #else
15
16 extern afs_int32    afs_is_disconnected;
17 extern afs_int32    afs_is_logging;
18 extern afs_int32    afs_is_discon_rw;
19 extern afs_int32    afs_in_sync;
20 extern afs_rwlock_t afs_discon_lock;
21
22 extern struct vcache *afs_DDirtyVCList;
23 extern struct vcache *afs_DDirtyVCListStart;
24 extern struct vcache *afs_DDirtyVCListPrev;
25 extern afs_rwlock_t afs_DDirtyVCListLock;
26 extern afs_int32 afs_ConflictPolicy;
27
28 extern void afs_RemoveAllConns();
29 extern afs_uint32 afs_DisconVnode; /* XXX: not protected. */
30
31 /* For afs_GenFakeFid. */
32 extern struct vcache *afs_FindVCache(struct VenusFid *afid,
33                                         afs_int32 *retry,
34                                         afs_int32 flag);
35
36 extern int afs_WriteVCacheDiscon(register struct vcache *avc,
37                                         register struct AFSStoreStatus *astatus,
38                                         struct vattr *attrs);
39 extern int afs_ResyncDisconFiles(struct vrequest *areq,
40                                         struct AFS_UCRED *acred);
41 extern void afs_RemoveAllConns();
42 extern void afs_GenFakeFid(struct VenusFid *afid, afs_uint32 avtype);
43 extern void afs_GenShadowFid(struct VenusFid *afid);
44 extern void afs_GenDisconStatus(struct vcache *adp,
45                                         struct vcache *avc,
46                                         struct VenusFid *afid,
47                                         struct vattr *attrs,
48                                         struct vrequest *areq,
49                                         int file_type);
50 extern int afs_HashOutDCache(struct dcache *adc, int zap);
51 extern int afs_MakeShadowDir(struct vcache *avc);
52 extern void afs_DeleteShadowDir(struct vcache *avc);
53 extern struct dcache *afs_FindDCacheByFid(register struct VenusFid *afid);
54 extern void afs_UpdateStatus(struct vcache *avc,
55                                         struct VenusFid *afid,
56                                         struct vrequest *areq,
57                                         struct AFSFetchStatus *Outsp,
58                                         struct AFSCallBack *acb,
59                                         afs_uint32 start);
60 extern void afs_RemoveAllConns();
61
62 #define AFS_IS_DISCONNECTED (afs_is_disconnected)
63 #define AFS_IS_LOGGING (afs_is_logging)
64 #define AFS_IS_DISCON_RW (afs_is_discon_rw)
65 #define AFS_IN_SYNC (afs_in_sync)
66 #define AFS_DISCON_LOCK() ObtainReadLock(&afs_discon_lock)
67 #define AFS_DISCON_UNLOCK() ReleaseReadLock(&afs_discon_lock)
68
69 #define AFS_DISCON_ADD_DIRTY(avc)                               \
70 do {                                                            \
71     if (!afs_DDirtyVCListStart) {                               \
72         afs_DDirtyVCListStart = afs_DDirtyVCList = avc;         \
73     } else {                                                    \
74         afs_DDirtyVCList->ddirty_next = avc;                    \
75         afs_DDirtyVCList = avc;                                 \
76     }                                                           \
77 } while(0);
78
79 #endif /* AFS_DISCON_ENV */
80 #endif /* _DISCON_H */