vfs_cache.c (181793) | vfs_cache.c (182061) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Poul-Henning Kamp of the FreeBSD Project. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95 33 */ 34 35#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1989, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Poul-Henning Kamp of the FreeBSD Project. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/kern/vfs_cache.c 181793 2008-08-16 21:48:10Z alfred $"); | 36__FBSDID("$FreeBSD: head/sys/kern/vfs_cache.c 182061 2008-08-23 15:13:39Z jhb $"); |
37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/mutex.h> 43#include <sys/sysctl.h> 44#include <sys/mount.h> --- 450 unchanged lines hidden (view full) --- 495 dvp->v_dd = vp; 496 CACHE_UNLOCK(); 497 return; 498 } 499 } 500 501 hold = 0; 502 zap = 0; | 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/mutex.h> 43#include <sys/sysctl.h> 44#include <sys/mount.h> --- 450 unchanged lines hidden (view full) --- 495 dvp->v_dd = vp; 496 CACHE_UNLOCK(); 497 return; 498 } 499 } 500 501 hold = 0; 502 zap = 0; |
503 504 /* 505 * Calculate the hash key and setup as much of the new 506 * namecache entry as possible before acquiring the lock. 507 */ |
|
503 ncp = cache_alloc(cnp->cn_namelen); | 508 ncp = cache_alloc(cnp->cn_namelen); |
509 ncp->nc_vp = vp; 510 ncp->nc_dvp = dvp; 511 len = ncp->nc_nlen = cnp->cn_namelen; 512 hash = fnv_32_buf(cnp->cn_nameptr, len, FNV1_32_INIT); 513 bcopy(cnp->cn_nameptr, ncp->nc_name, len); 514 hash = fnv_32_buf(&dvp, sizeof(dvp), hash); |
|
504 CACHE_LOCK(); | 515 CACHE_LOCK(); |
516 517 /* 518 * See if this vnode is already in the cache with this name. 519 * This can happen with concurrent lookups of the same path 520 * name. 521 */ 522 if (vp) { 523 struct namecache *n2; 524 525 TAILQ_FOREACH(n2, &vp->v_cache_dst, nc_dst) { 526 if (n2->nc_dvp == dvp && 527 n2->nc_nlen == cnp->cn_namelen && 528 !bcmp(n2->nc_name, cnp->cn_nameptr, n2->nc_nlen)) { 529 CACHE_UNLOCK(); 530 cache_free(ncp); 531 return; 532 } 533 } 534 } 535 |
|
505 numcache++; 506 if (!vp) { 507 numneg++; 508 ncp->nc_flag = cnp->cn_flags & ISWHITEOUT ? NCF_WHITE : 0; 509 } else if (vp->v_type == VDIR) { 510 vp->v_dd = dvp; 511 } else { 512 vp->v_dd = NULL; 513 } 514 515 /* | 536 numcache++; 537 if (!vp) { 538 numneg++; 539 ncp->nc_flag = cnp->cn_flags & ISWHITEOUT ? NCF_WHITE : 0; 540 } else if (vp->v_type == VDIR) { 541 vp->v_dd = dvp; 542 } else { 543 vp->v_dd = NULL; 544 } 545 546 /* |
516 * Set the rest of the namecache entry elements, calculate it's 517 * hash key and insert it into the appropriate chain within 518 * the cache entries table. | 547 * Insert the new namecache entry into the appropriate chain 548 * within the cache entries table. |
519 */ | 549 */ |
520 ncp->nc_vp = vp; 521 ncp->nc_dvp = dvp; 522 len = ncp->nc_nlen = cnp->cn_namelen; 523 hash = fnv_32_buf(cnp->cn_nameptr, len, FNV1_32_INIT); 524 bcopy(cnp->cn_nameptr, ncp->nc_name, len); 525 hash = fnv_32_buf(&dvp, sizeof(dvp), hash); | |
526 ncpp = NCHHASH(hash); 527 LIST_INSERT_HEAD(ncpp, ncp, nc_hash); 528 if (LIST_EMPTY(&dvp->v_cache_src)) { 529 hold = 1; 530 numcachehv++; 531 } 532 LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src); 533 /* --- 358 unchanged lines hidden --- | 550 ncpp = NCHHASH(hash); 551 LIST_INSERT_HEAD(ncpp, ncp, nc_hash); 552 if (LIST_EMPTY(&dvp->v_cache_src)) { 553 hold = 1; 554 numcachehv++; 555 } 556 LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src); 557 /* --- 358 unchanged lines hidden --- |