#include "afsincludes.h" /*AFS-based standard headers */
int
-osi_TryEvictVCache(struct vcache *avc, int *slept) {
-
- /*
- * essentially all we want to do here is check that the
- * vcache is not in use, then call vgone() (which will call
- * inactive and reclaim as needed). This requires some
- * kind of complicated locking, which we already need to implement
- * for FlushVCache, so just call that routine here and check
- * its return value for whether the vcache was evict-able.
- */
- if (osi_VM_FlushVCache(avc, slept) != 0)
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
+ struct vnode *vp;
+ int code;
+
+ vp = AFSTOV(avc);
+
+ if (!VI_TRYLOCK(vp))
+ return 0;
+ code = osi_fbsd_checkinuse(avc);
+ if (code != 0) {
+ VI_UNLOCK(vp);
return 0;
- else
+ }
+
+ if ((vp->v_iflag & VI_DOOMED) != 0) {
+ VI_UNLOCK(vp);
return 1;
+ }
+
+ /* must hold the vnode before calling vgone()
+ * This code largely copied from vfs_subr.c:vlrureclaim() */
+ vholdl(vp);
+
+ ReleaseWriteLock(&afs_xvcache);
+ AFS_GUNLOCK();
+
+ *slept = 1;
+ /* use the interlock while locking, so no one else can DOOM this */
+ vn_lock(vp, LK_INTERLOCK|LK_EXCLUSIVE|LK_RETRY);
+ vgone(vp);
+ VOP_UNLOCK(vp, 0);
+ vdrop(vp);
+
+ AFS_GLOCK();
+ ObtainWriteLock(&afs_xvcache, 340);
+ return 1;
}
struct vcache *
osi_NewVnode(void) {
struct vcache *tvc;
- tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
+ tvc = afs_osi_Alloc(sizeof(struct vcache));
tvc->v = NULL; /* important to clean this, or use memset 0 */
return tvc;
ReleaseWriteLock(&afs_xvcache);
AFS_GUNLOCK();
-#if defined(AFS_FBSD60_ENV)
if (getnewvnode(MOUNT_AFS, afs_globalVFS, &afs_vnodeops, &vp))
-#else
- if (getnewvnode(MOUNT_AFS, afs_globalVFS, afs_vnodeop_p, &vp))
-#endif
panic("afs getnewvnode"); /* can't happen */
-#ifdef AFS_FBSD70_ENV
/* XXX verified on 80--TODO check on 7x */
if (!vp->v_mount) {
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* !glocked */
insmntque(vp, afs_globalVFS);
VOP_UNLOCK(vp, 0);
}
-#endif
AFS_GLOCK();
ObtainWriteLock(&afs_xvcache,339);
if (avc->v != NULL) {