vfs_cache.c (1817) | vfs_cache.c (3308) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)vfs_cache.c 8.1 (Berkeley) 6/10/93 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)vfs_cache.c 8.1 (Berkeley) 6/10/93 |
34 * $Id$ | 34 * $Id: vfs_cache.c,v 1.3 1994/08/02 07:43:15 davidg Exp $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/time.h> 40#include <sys/mount.h> 41#include <sys/vnode.h> 42#include <sys/namei.h> --- 113 unchanged lines hidden (view full) --- 156 } 157 158 /* 159 * Last component and we are renaming or deleting, 160 * the cache entry is invalid, or otherwise don't 161 * want cache entry to exist. 162 */ 163 /* remove from LRU chain */ | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/time.h> 40#include <sys/mount.h> 41#include <sys/vnode.h> 42#include <sys/namei.h> --- 113 unchanged lines hidden (view full) --- 156 } 157 158 /* 159 * Last component and we are renaming or deleting, 160 * the cache entry is invalid, or otherwise don't 161 * want cache entry to exist. 162 */ 163 /* remove from LRU chain */ |
164 if (ncq = ncp->nc_nxt) | 164 ncq = ncp->nc_nxt; 165 if (ncq) |
165 ncq->nc_prev = ncp->nc_prev; 166 else 167 nchtail = ncp->nc_prev; 168 *ncp->nc_prev = ncq; 169 /* remove from hash chain */ | 166 ncq->nc_prev = ncp->nc_prev; 167 else 168 nchtail = ncp->nc_prev; 169 *ncp->nc_prev = ncq; 170 /* remove from hash chain */ |
170 if (ncq = ncp->nc_forw) | 171 ncq = ncp->nc_forw; 172 if (ncq) |
171 ncq->nc_back = ncp->nc_back; 172 *ncp->nc_back = ncq; 173 /* and make a dummy hash chain */ 174 ncp->nc_forw = NULL; 175 ncp->nc_back = NULL; 176 /* insert at head of LRU list (first to grab) */ | 173 ncq->nc_back = ncp->nc_back; 174 *ncp->nc_back = ncq; 175 /* and make a dummy hash chain */ 176 ncp->nc_forw = NULL; 177 ncp->nc_back = NULL; 178 /* insert at head of LRU list (first to grab) */ |
177 if (ncq = nchhead) | 179 ncq = nchhead; 180 if (ncq) |
178 ncq->nc_prev = &ncp->nc_nxt; 179 else 180 nchtail = &ncp->nc_nxt; 181 nchhead = ncp; 182 ncp->nc_nxt = ncq; 183 ncp->nc_prev = &nchhead; 184 return (0); 185} --- 18 unchanged lines hidden (view full) --- 204 /* 205 * Free the cache slot at head of lru chain. 206 */ 207 if (numcache < desiredvnodes) { 208 ncp = (struct namecache *) 209 malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK); 210 bzero((char *)ncp, sizeof *ncp); 211 numcache++; | 181 ncq->nc_prev = &ncp->nc_nxt; 182 else 183 nchtail = &ncp->nc_nxt; 184 nchhead = ncp; 185 ncp->nc_nxt = ncq; 186 ncp->nc_prev = &nchhead; 187 return (0); 188} --- 18 unchanged lines hidden (view full) --- 207 /* 208 * Free the cache slot at head of lru chain. 209 */ 210 if (numcache < desiredvnodes) { 211 ncp = (struct namecache *) 212 malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK); 213 bzero((char *)ncp, sizeof *ncp); 214 numcache++; |
212 } else if (ncp = nchhead) { | 215 } else if (!nchhead) { 216 return; 217 } else { 218 ncp = nchhead; |
213 /* remove from lru chain */ | 219 /* remove from lru chain */ |
214 if (ncq = ncp->nc_nxt) | 220 ncq = ncp->nc_nxt; 221 if (ncq) |
215 ncq->nc_prev = ncp->nc_prev; 216 else 217 nchtail = ncp->nc_prev; 218 *ncp->nc_prev = ncq; 219 /* remove from old hash chain, if on one */ 220 if (ncp->nc_back) { | 222 ncq->nc_prev = ncp->nc_prev; 223 else 224 nchtail = ncp->nc_prev; 225 *ncp->nc_prev = ncq; 226 /* remove from old hash chain, if on one */ 227 if (ncp->nc_back) { |
221 if (ncq = ncp->nc_forw) | 228 ncq = ncp->nc_forw; 229 if (ncq) |
222 ncq->nc_back = ncp->nc_back; 223 *ncp->nc_back = ncq; 224 ncp->nc_forw = NULL; 225 ncp->nc_back = NULL; 226 } | 230 ncq->nc_back = ncp->nc_back; 231 *ncp->nc_back = ncq; 232 ncp->nc_forw = NULL; 233 ncp->nc_back = NULL; 234 } |
227 } else 228 return; | 235 } |
229 /* grab the vnode we just found */ 230 ncp->nc_vp = vp; 231 if (vp) 232 ncp->nc_vpid = vp->v_id; 233 else 234 ncp->nc_vpid = 0; 235 /* fill in cache info */ 236 ncp->nc_dvp = dvp; 237 ncp->nc_dvpid = dvp->v_id; 238 ncp->nc_nlen = cnp->cn_namelen; 239 bcopy(cnp->cn_nameptr, ncp->nc_name, (unsigned)ncp->nc_nlen); 240 /* link at end of lru chain */ 241 ncp->nc_nxt = NULL; 242 ncp->nc_prev = nchtail; 243 *nchtail = ncp; 244 nchtail = &ncp->nc_nxt; 245 /* and insert on hash chain */ 246 ncpp = &nchashtbl[cnp->cn_hash & nchash]; | 236 /* grab the vnode we just found */ 237 ncp->nc_vp = vp; 238 if (vp) 239 ncp->nc_vpid = vp->v_id; 240 else 241 ncp->nc_vpid = 0; 242 /* fill in cache info */ 243 ncp->nc_dvp = dvp; 244 ncp->nc_dvpid = dvp->v_id; 245 ncp->nc_nlen = cnp->cn_namelen; 246 bcopy(cnp->cn_nameptr, ncp->nc_name, (unsigned)ncp->nc_nlen); 247 /* link at end of lru chain */ 248 ncp->nc_nxt = NULL; 249 ncp->nc_prev = nchtail; 250 *nchtail = ncp; 251 nchtail = &ncp->nc_nxt; 252 /* and insert on hash chain */ 253 ncpp = &nchashtbl[cnp->cn_hash & nchash]; |
247 if (ncq = *ncpp) | 254 ncq = *ncpp; 255 if (ncq) |
248 ncq->nc_back = &ncp->nc_forw; 249 ncp->nc_forw = ncq; 250 ncp->nc_back = ncpp; 251 *ncpp = ncp; 252} 253 254/* 255 * Name cache initialization, from vfs_init() when we are booting --- 47 unchanged lines hidden (view full) --- 303 nxtcp = ncp->nc_nxt; 304 continue; 305 } 306 /* free the resources we had */ 307 ncp->nc_vp = NULL; 308 ncp->nc_dvp = NULL; 309 /* remove from old hash chain, if on one */ 310 if (ncp->nc_back) { | 256 ncq->nc_back = &ncp->nc_forw; 257 ncp->nc_forw = ncq; 258 ncp->nc_back = ncpp; 259 *ncpp = ncp; 260} 261 262/* 263 * Name cache initialization, from vfs_init() when we are booting --- 47 unchanged lines hidden (view full) --- 311 nxtcp = ncp->nc_nxt; 312 continue; 313 } 314 /* free the resources we had */ 315 ncp->nc_vp = NULL; 316 ncp->nc_dvp = NULL; 317 /* remove from old hash chain, if on one */ 318 if (ncp->nc_back) { |
311 if (nxtcp = ncp->nc_forw) | 319 nxtcp = ncp->nc_forw; 320 if (nxtcp) |
312 nxtcp->nc_back = ncp->nc_back; 313 *ncp->nc_back = nxtcp; 314 ncp->nc_forw = NULL; 315 ncp->nc_back = NULL; 316 } 317 /* delete this entry from LRU chain */ | 321 nxtcp->nc_back = ncp->nc_back; 322 *ncp->nc_back = nxtcp; 323 ncp->nc_forw = NULL; 324 ncp->nc_back = NULL; 325 } 326 /* delete this entry from LRU chain */ |
318 if (nxtcp = ncp->nc_nxt) | 327 nxtcp = ncp->nc_nxt; 328 if (nxtcp) |
319 nxtcp->nc_prev = ncp->nc_prev; 320 else 321 nchtail = ncp->nc_prev; 322 *ncp->nc_prev = nxtcp; 323 /* cause rescan of list, it may have altered */ 324 /* also put the now-free entry at head of LRU */ | 329 nxtcp->nc_prev = ncp->nc_prev; 330 else 331 nchtail = ncp->nc_prev; 332 *ncp->nc_prev = nxtcp; 333 /* cause rescan of list, it may have altered */ 334 /* also put the now-free entry at head of LRU */ |
325 if (nxtcp = nchhead) | 335 nxtcp = nchhead; 336 if (nxtcp) |
326 nxtcp->nc_prev = &ncp->nc_nxt; 327 else 328 nchtail = &ncp->nc_nxt; 329 nchhead = ncp; 330 ncp->nc_nxt = nxtcp; 331 ncp->nc_prev = &nchhead; 332 } 333} | 337 nxtcp->nc_prev = &ncp->nc_nxt; 338 else 339 nchtail = &ncp->nc_nxt; 340 nchhead = ncp; 341 ncp->nc_nxt = nxtcp; 342 ncp->nc_prev = &nchhead; 343 } 344} |