From: Jim Rees Date: Thu, 30 Jan 2003 21:43:54 +0000 (+0000) Subject: openbsd-20030130 X-Git-Tag: openafs-devel-1_3_50~408 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=74737891ae205f95d84be185ff84aff844dc4edd openbsd-20030130 Don't lock against myself in reclaim vnodeop. ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== Various stability fixes: Call vgone() instead of afs_FlushVCache() when freeing vcache Acquire AFS_GLOCK in VOP_INACTIVE Don't bother calling cache_purge() or uvm_vnp_uncache() in reclaim(); vclean() already does this Acquire xvcache lock in reclaim() --- diff --git a/src/afs/OBSD/osi_vnodeops.c b/src/afs/OBSD/osi_vnodeops.c index 43756f4..342c4f9 100644 --- a/src/afs/OBSD/osi_vnodeops.c +++ b/src/afs/OBSD/osi_vnodeops.c @@ -525,10 +525,10 @@ afs_nbsd_select(ap) struct proc *a_p; } */ *ap; { - /* - * We should really check to see if I/O is possible. - */ - return (1); + /* + * We should really check to see if I/O is possible. + */ + return (1); } int @@ -864,14 +864,18 @@ afs_nbsd_inactive(ap) { struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(vp); + int haveGlock = ISAFS_GLOCK(); AFS_STATCNT(afs_inactive); if (prtactive && vp->v_usecount != 0) vprint("afs_nbsd_inactive(): pushing active", vp); - vc->states &= ~CMAPPED; - vc->states &= ~CDirty; + if (!haveGlock) + AFS_GLOCK(); + afs_InactiveVCache(vc, 0); /* decrs ref counts */ + if (!haveGlock) + AFS_GUNLOCK(); lockinit(&vc->rwlock, PINOD, "vcache", 0, 0); return 0; @@ -886,24 +890,23 @@ afs_nbsd_reclaim(ap) int code, slept; struct vnode *vp = ap->a_vp; struct vcache *avc = VTOAFS(vp); + int haveGlock = ISAFS_GLOCK(); + int haveVlock = CheckLock(&afs_xvcache); - cache_purge(vp); /* just in case... */ -#ifdef UVM - uvm_vnp_uncache(vp); -#else - vnode_pager_uncache(vp); -#endif - - AFS_GLOCK(); + if (!haveGlock) + AFS_GLOCK(); + if (!haveVlock) + ObtainWriteLock(&afs_xvcache, 901); #ifndef AFS_DISCON_ENV code = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */ #else /* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */ code = afs_FlushVS(avc); #endif - AFS_GUNLOCK(); - if (!code && vp->v_data) - panic("afs_reclaim: vnode not cleaned"); + if (!haveVlock) + ReleaseWriteLock(&afs_xvcache); + if (!haveGlock) + AFS_GUNLOCK(); return code; } @@ -918,10 +921,8 @@ afs_nbsd_lock(ap) struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(vp); -#ifdef DIAGNOSTIC if (!vc) panic("afs_nbsd_lock: null vcache"); -#endif return lockmgr(&vc->rwlock, ap->a_flags | LK_CANRECURSE, &vp->v_interlock, ap->a_p); } @@ -936,10 +937,8 @@ afs_nbsd_unlock(ap) struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(vp); -#ifdef DIAGNOSTIC if (!vc) panic("afs_nbsd_unlock: null vcache"); -#endif return lockmgr(&vc->rwlock, ap->a_flags | LK_RELEASE, &vp->v_interlock, ap->a_p); } @@ -1038,25 +1037,25 @@ afs_nbsd_pathconf(ap) { AFS_STATCNT(afs_cntl); switch (ap->a_name) { - case _PC_LINK_MAX: + case _PC_LINK_MAX: *ap->a_retval = LINK_MAX; break; - case _PC_NAME_MAX: + case _PC_NAME_MAX: *ap->a_retval = NAME_MAX; break; - case _PC_PATH_MAX: + case _PC_PATH_MAX: *ap->a_retval = PATH_MAX; break; - case _PC_CHOWN_RESTRICTED: + case _PC_CHOWN_RESTRICTED: *ap->a_retval = 1; break; - case _PC_NO_TRUNC: + case _PC_NO_TRUNC: *ap->a_retval = 1; break; - case _PC_PIPE_BUF: + case _PC_PIPE_BUF: return EINVAL; break; - default: + default: return EINVAL; } return 0; diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 03b2c7f..df9f5d1 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -793,7 +793,18 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) if (VREFCOUNT(tvc) == 0 && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) { +#ifdef AFS_OBSD_ENV + /* + * vgone() reclaims the vnode, which calls afs_FlushVCache(), + * then it puts the vnode on the free list. + * If we don't do this we end up with a cleaned vnode that's + * not on the free list. + */ + vgone(AFSTOV(tvc)); + code = fv_slept = 0; +#else code = afs_FlushVCache(tvc, &fv_slept); +#endif if (code == 0) { anumber--; }