pseudofs_vncache.c (93818) | pseudofs_vncache.c (97940) |
---|---|
1/*- 2 * Copyright (c) 2001 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 2001 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/fs/pseudofs/pseudofs_vncache.c 93818 2002-04-04 21:03:38Z jhb $ | 28 * $FreeBSD: head/sys/fs/pseudofs/pseudofs_vncache.c 97940 2002-06-06 16:59:24Z des $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/systm.h> 34#include <sys/lock.h> 35#include <sys/malloc.h> 36#include <sys/mutex.h> --- 66 unchanged lines hidden (view full) --- 103int 104pfs_vncache_alloc(struct mount *mp, struct vnode **vpp, 105 struct pfs_node *pn, pid_t pid) 106{ 107 struct pfs_vdata *pvd; 108 int error; 109 110 /* | 29 */ 30 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/systm.h> 34#include <sys/lock.h> 35#include <sys/malloc.h> 36#include <sys/mutex.h> --- 66 unchanged lines hidden (view full) --- 103int 104pfs_vncache_alloc(struct mount *mp, struct vnode **vpp, 105 struct pfs_node *pn, pid_t pid) 106{ 107 struct pfs_vdata *pvd; 108 int error; 109 110 /* |
111 * See if the vnode is in the cache. | 111 * See if the vnode is in the cache. |
112 * XXX linear search is not very efficient. 113 */ 114 mtx_lock(&pfs_vncache_mutex); 115 for (pvd = pfs_vncache; pvd; pvd = pvd->pvd_next) { 116 if (pvd->pvd_pn == pn && pvd->pvd_pid == pid) { 117 if (vget(pvd->pvd_vnode, 0, curthread) == 0) { 118 ++pfs_vncache_hits; 119 *vpp = pvd->pvd_vnode; --- 58 unchanged lines hidden (view full) --- 178 * Free a vnode 179 */ 180int 181pfs_vncache_free(struct vnode *vp) 182{ 183 struct pfs_vdata *pvd; 184 185 cache_purge(vp); | 112 * XXX linear search is not very efficient. 113 */ 114 mtx_lock(&pfs_vncache_mutex); 115 for (pvd = pfs_vncache; pvd; pvd = pvd->pvd_next) { 116 if (pvd->pvd_pn == pn && pvd->pvd_pid == pid) { 117 if (vget(pvd->pvd_vnode, 0, curthread) == 0) { 118 ++pfs_vncache_hits; 119 *vpp = pvd->pvd_vnode; --- 58 unchanged lines hidden (view full) --- 178 * Free a vnode 179 */ 180int 181pfs_vncache_free(struct vnode *vp) 182{ 183 struct pfs_vdata *pvd; 184 185 cache_purge(vp); |
186 | 186 |
187 mtx_lock(&pfs_vncache_mutex); 188 pvd = (struct pfs_vdata *)vp->v_data; 189 KASSERT(pvd != NULL, ("pfs_vncache_free(): no vnode data\n")); 190 if (pvd->pvd_next) 191 pvd->pvd_next->pvd_prev = pvd->pvd_prev; 192 if (pvd->pvd_prev) 193 pvd->pvd_prev->pvd_next = pvd->pvd_next; 194 else --- 35 unchanged lines hidden (view full) --- 230 231/* 232 * Disable a pseudofs node, and free all vnodes associated with it 233 */ 234int 235pfs_disable(struct pfs_node *pn) 236{ 237 struct pfs_vdata *pvd, *prev; | 187 mtx_lock(&pfs_vncache_mutex); 188 pvd = (struct pfs_vdata *)vp->v_data; 189 KASSERT(pvd != NULL, ("pfs_vncache_free(): no vnode data\n")); 190 if (pvd->pvd_next) 191 pvd->pvd_next->pvd_prev = pvd->pvd_prev; 192 if (pvd->pvd_prev) 193 pvd->pvd_prev->pvd_next = pvd->pvd_next; 194 else --- 35 unchanged lines hidden (view full) --- 230 231/* 232 * Disable a pseudofs node, and free all vnodes associated with it 233 */ 234int 235pfs_disable(struct pfs_node *pn) 236{ 237 struct pfs_vdata *pvd, *prev; |
238 | 238 |
239 if (pn->pn_flags & PFS_DISABLED) 240 return (0); 241 mtx_lock(&pfs_vncache_mutex); 242 pn->pn_flags |= PFS_DISABLED; 243 /* see the comment about the double loop in pfs_exit() */ 244 /* XXX linear search... not very efficient */ 245 for (pvd = pfs_vncache; pvd != NULL; pvd = pvd->pvd_next) { 246 while (pvd != NULL && pvd->pvd_pn == pn) { --- 20 unchanged lines hidden --- | 239 if (pn->pn_flags & PFS_DISABLED) 240 return (0); 241 mtx_lock(&pfs_vncache_mutex); 242 pn->pn_flags |= PFS_DISABLED; 243 /* see the comment about the double loop in pfs_exit() */ 244 /* XXX linear search... not very efficient */ 245 for (pvd = pfs_vncache; pvd != NULL; pvd = pvd->pvd_next) { 246 while (pvd != NULL && pvd->pvd_pn == pn) { --- 20 unchanged lines hidden --- |