From: Nickolai Zeldovich Date: Mon, 12 Aug 2002 22:32:39 +0000 (+0000) Subject: Fix a vcache refcount leak in afs_root() on all platforms. X-Git-Tag: openafs-devel_1_3_3~13 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7dc3c1a6eaea17ab38b86233c4438e1a6096c334;p=packages%2Fo%2Fopenafs.git Fix a vcache refcount leak in afs_root() on all platforms. --- diff --git a/src/afs/AIX/osi_vfsops.c b/src/afs/AIX/osi_vfsops.c index e8712f9da..ac8985771 100644 --- a/src/afs/AIX/osi_vfsops.c +++ b/src/afs/AIX/osi_vfsops.c @@ -110,6 +110,10 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp) tvp = afs_globalVp; } else { struct ucred *credp; + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } credp = crref(); if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) { diff --git a/src/afs/DARWIN/osi_vfsops.c b/src/afs/DARWIN/osi_vfsops.c index 785e8cec6..2c32894b0 100644 --- a/src/afs/DARWIN/osi_vfsops.c +++ b/src/afs/DARWIN/osi_vfsops.c @@ -123,7 +123,11 @@ afs_root(struct mount *mp, tvp = afs_globalVp; error=0; } else { - + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(error = afs_InitReq(&treq, &cr)) && !(error = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/DUX/osi_vfsops.c b/src/afs/DUX/osi_vfsops.c index c5e4a04a7..c1199dd17 100644 --- a/src/afs/DUX/osi_vfsops.c +++ b/src/afs/DUX/osi_vfsops.c @@ -136,6 +136,11 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, u.u_cred)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c index 605e399f7..faa0fb72f 100644 --- a/src/afs/FBSD/osi_vfsops.c +++ b/src/afs/FBSD/osi_vfsops.c @@ -122,7 +122,11 @@ afs_root(struct mount *mp, tvp = afs_globalVp; error=0; } else { - + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(error = afs_InitReq(&treq, &cr)) && !(error = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/HPUX/osi_vfsops.c b/src/afs/HPUX/osi_vfsops.c index 26624c3b5..189202ebe 100644 --- a/src/afs/HPUX/osi_vfsops.c +++ b/src/afs/HPUX/osi_vfsops.c @@ -78,6 +78,11 @@ int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1) if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, p_cred(u.u_procp))) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/IRIX/osi_vfsops.c b/src/afs/IRIX/osi_vfsops.c index e93fe01bb..5c6caf9d6 100644 --- a/src/afs/IRIX/osi_vfsops.c +++ b/src/afs/IRIX/osi_vfsops.c @@ -277,6 +277,11 @@ afs_root (OSI_VFS_ARG(afsp), avpp) if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED())) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index fd200623e..ba3064875 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -122,7 +122,12 @@ static int afs_root(struct super_block *afsp) tvp = afs_globalVp; } else { cred_t *credp = crref(); - afs_globalVp = 0; + + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/NBSD/osi_vfsops.c b/src/afs/NBSD/osi_vfsops.c index 2157691bd..efe15c003 100644 --- a/src/afs/NBSD/osi_vfsops.c +++ b/src/afs/NBSD/osi_vfsops.c @@ -136,6 +136,11 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, cred)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index 0707ca1e4..8a3087884 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -110,6 +110,12 @@ int afs_root (struct vfs *afsp, struct vnode **avpp) locked = 1; mutex_exit(&vp->v_lock); } + + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, proc->p_cred)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0, diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c index 8d945364e..6c9e2ce7f 100644 --- a/src/afs/UKERNEL/osi_vfsops.c +++ b/src/afs/UKERNEL/osi_vfsops.c @@ -78,6 +78,11 @@ afs_root (OSI_VFS_ARG(afsp), avpp) if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { + if (afs_globalVp) { + afs_PutVCache(afs_globalVp); + afs_globalVp = NULL; + } + if (!(code = afs_InitReq(&treq, u.u_cred)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,