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