From owner-p4-projects@FreeBSD.ORG Mon Jun 7 20:09:04 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9B30F106566C; Mon, 7 Jun 2010 20:09:04 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4759D1065676 for ; Mon, 7 Jun 2010 20:09:04 +0000 (UTC) (envelope-from gk@FreeBSD.org) Received: from repoman.freebsd.org (unknown [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3434D8FC17 for ; Mon, 7 Jun 2010 20:09:04 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o57K94IO040042 for ; Mon, 7 Jun 2010 20:09:04 GMT (envelope-from gk@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o57K94ea040040 for perforce@freebsd.org; Mon, 7 Jun 2010 20:09:04 GMT (envelope-from gk@FreeBSD.org) Date: Mon, 7 Jun 2010 20:09:04 GMT Message-Id: <201006072009.o57K94ea040040@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gk@FreeBSD.org using -f From: Gleb Kurtsou To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 179301 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2010 20:09:04 -0000 http://p4web.freebsd.org/@@179301?ac=10 Change 179301 by gk@gk_h1 on 2010/06/07 20:08:30 Import current dircache snapshot. Affected files ... .. //depot/projects/soc2010/gk_namecache/sys/fs/tmpfs/tmpfs_subr.c#2 edit .. //depot/projects/soc2010/gk_namecache/sys/fs/tmpfs/tmpfs_vfsops.c#2 edit .. //depot/projects/soc2010/gk_namecache/sys/fs/tmpfs/tmpfs_vnops.c#2 edit .. //depot/projects/soc2010/gk_namecache/sys/kern/vfs_dircache.c#1 add .. //depot/projects/soc2010/gk_namecache/sys/kern/vfs_subr.c#2 edit .. //depot/projects/soc2010/gk_namecache/sys/modules/tmpfs/Makefile#2 edit .. //depot/projects/soc2010/gk_namecache/sys/sys/dircache.h#1 add .. //depot/projects/soc2010/gk_namecache/sys/sys/mount.h#2 edit .. //depot/projects/soc2010/gk_namecache/sys/sys/vnode.h#2 edit Differences ... ==== //depot/projects/soc2010/gk_namecache/sys/fs/tmpfs/tmpfs_subr.c#2 (text+ko) ==== @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD: src/sys/fs/tmpfs/tmpfs_subr.c,v 1.26 2010/01/20 16:56:20 jh Exp $"); #include +#include #include #include #include @@ -519,6 +520,8 @@ * insert the new node into the directory, an operation that * cannot fail. */ tmpfs_dir_attach(dvp, de); + dircache_add(dvp, *vpp, cnp, DT_STRONG, node->tn_id, + tmpfs_dircookie(de)); out: @@ -585,7 +588,8 @@ tmpfs_dir_lookup(struct tmpfs_node *node, struct tmpfs_node *f, struct componentname *cnp) { - boolean_t found; + struct dircache_cursor curs; + boolean_t found, cache; struct tmpfs_dirent *de; MPASS(IMPLIES(cnp->cn_namelen == 1, cnp->cn_nameptr[0] != '.')); @@ -593,17 +597,27 @@ cnp->cn_nameptr[1] == '.'))); TMPFS_VALIDATE_DIR(node); + found = 0; + cache = dircache_beginupdate(&curs, node->tn_vnode, cnp, + DC_OP_IFPARTIAL) == 0; TAILQ_FOREACH(de, &node->tn_dir.tn_dirhead, td_entries) { + if (cache) + dircache_update(&curs, DT_STRONG, de->td_name, + de->td_namelen, de->td_node->tn_id, + tmpfs_dircookie(de)); if (f != NULL && de->td_node != f) continue; MPASS(cnp->cn_namelen < 0xffff); if (de->td_namelen == (uint16_t)cnp->cn_namelen && bcmp(de->td_name, cnp->cn_nameptr, de->td_namelen) == 0) { found = 1; - break; + if (!cache) + break; } } + if (cache) + dircache_completeupdate(&curs); node->tn_status |= TMPFS_NODE_ACCESSED; return found ? de : NULL; ==== //depot/projects/soc2010/gk_namecache/sys/fs/tmpfs/tmpfs_vfsops.c#2 (text+ko) ==== @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD: src/sys/fs/tmpfs/tmpfs_vfsops.c,v 1.25 2010/01/29 12:09:14 jh Exp $"); #include +#include #include #include #include @@ -253,6 +254,8 @@ vfs_getnewfsid(mp); vfs_mountedfrom(mp, "tmpfs"); + dircache_init(mp, root->tn_id); + return 0; } @@ -321,6 +324,9 @@ MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_LOCAL; MNT_IUNLOCK(mp); + + dircache_uninit(mp); + return 0; } ==== //depot/projects/soc2010/gk_namecache/sys/fs/tmpfs/tmpfs_vnops.c#2 (text+ko) ==== @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD: src/sys/fs/tmpfs/tmpfs_vnops.c,v 1.39 2010/05/06 18:43:19 trasz Exp $"); #include +#include #include #include #include @@ -183,8 +184,10 @@ /* Store the result of this lookup in the cache. Avoid this if the * request was for creation, as it does not improve timings on * emprical tests. */ - if ((cnp->cn_flags & MAKEENTRY) && cnp->cn_nameiop != CREATE) + if ((cnp->cn_flags & MAKEENTRY) && cnp->cn_nameiop != CREATE) { + dircache_enter(dvp, *vpp, cnp); cache_enter(dvp, *vpp, cnp); + } out: /* If there were no errors, *vpp cannot be null and it must be @@ -838,6 +841,7 @@ /* Remove the entry from the directory; as it is a file, we do not * have to change the number of hard links of the directory. */ tmpfs_dir_detach(dvp, de); + dircache_remove(dvp, vp, v->a_cnp); /* Free the directory entry we just deleted. Note that the node * referred by it will not be removed until the vnode is really @@ -909,6 +913,7 @@ /* Insert the new directory entry into the appropriate directory. */ tmpfs_dir_attach(dvp, de); + dircache_add(dvp, vp, cnp, DT_STRONG, node->tn_id, tmpfs_dircookie(de)); /* vp link count has changed, so update node times. */ node->tn_status |= TMPFS_NODE_CHANGED; @@ -1133,6 +1138,8 @@ tmpfs_free_dirent(VFS_TO_TMPFS(tvp->v_mount), de, TRUE); } + dircache_rename(fdvp, fvp, fcnp, tdvp, tvp, tcnp); + error = 0; out_locked: @@ -1227,6 +1234,7 @@ /* Detach the directory entry from the directory (dnode). */ tmpfs_dir_detach(dvp, de); + dircache_remove(dvp, vp, v->a_cnp); /* No vnode should be allocated for this entry from this point */ TMPFS_NODE_LOCK(node); @@ -1448,6 +1456,9 @@ TMPFS_NODE_UNLOCK(node); MPASS(vp->v_data == NULL); + + dircache_reclaimvnode(vp); + return 0; } @@ -1552,7 +1563,7 @@ */ struct vop_vector tmpfs_vnodeop_entries = { .vop_default = &default_vnodeops, - .vop_lookup = vfs_cache_lookup, + .vop_lookup = vfs_dircache_lookup, .vop_cachedlookup = tmpfs_lookup, .vop_create = tmpfs_create, .vop_mknod = tmpfs_mknod, ==== //depot/projects/soc2010/gk_namecache/sys/kern/vfs_subr.c#2 (text+ko) ==== @@ -863,6 +863,7 @@ VNASSERT(TAILQ_EMPTY(&vp->v_cache_dst), vp, ("vp has namecache dst")); VNASSERT(LIST_EMPTY(&vp->v_cache_src), vp, ("vp has namecache src")); VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for ..")); + VNASSERT(TAILQ_EMPTY(&vp->v_dircache), vp, ("vp has dircache refs")); VI_UNLOCK(vp); #ifdef MAC mac_vnode_destroy(vp); @@ -1007,6 +1008,7 @@ */ LIST_INIT(&vp->v_cache_src); TAILQ_INIT(&vp->v_cache_dst); + TAILQ_INIT(&vp->v_dircache); /* * Finalize various vnode identity bits. */ ==== //depot/projects/soc2010/gk_namecache/sys/modules/tmpfs/Makefile#2 (text+ko) ==== @@ -1,9 +1,10 @@ # $FreeBSD: src/sys/modules/tmpfs/Makefile,v 1.2 2007/06/29 05:23:15 delphij Exp $ .PATH: ${.CURDIR}/../../fs/tmpfs +.PATH: ${.CURDIR}/../../kern KMOD= tmpfs SRCS= vnode_if.h \ - tmpfs_vnops.c tmpfs_fifoops.c tmpfs_vfsops.c tmpfs_subr.c + tmpfs_vnops.c tmpfs_fifoops.c tmpfs_vfsops.c tmpfs_subr.c vfs_dircache.c .include ==== //depot/projects/soc2010/gk_namecache/sys/sys/mount.h#2 (text+ko) ==== @@ -127,6 +127,8 @@ long f_spare[2]; /* unused spare */ }; +struct dircache; + TAILQ_HEAD(vnodelst, vnode); /* Mount options list */ @@ -184,6 +186,7 @@ int mnt_secondary_writes; /* (i) # of secondary writes */ int mnt_secondary_accwrites;/* (i) secondary wr. starts */ struct thread *mnt_susp_owner; /* (i) thread owning suspension */ + struct dircache *mnt_dircache; /* dircache root node */ #define mnt_endzero mnt_gjprovider char *mnt_gjprovider; /* gjournal provider name */ struct lock mnt_explock; /* vfs_export walkers lock */ ==== //depot/projects/soc2010/gk_namecache/sys/sys/vnode.h#2 (text+ko) ==== @@ -60,6 +60,7 @@ * it from v_data. If non-null, this area is freed in getnewvnode(). */ +struct dircache; struct namecache; struct vpollinfo { @@ -136,6 +137,7 @@ LIST_HEAD(, namecache) v_cache_src; /* c Cache entries from us */ TAILQ_HEAD(, namecache) v_cache_dst; /* c Cache entries to us */ struct namecache *v_cache_dd; /* c Cache entry for .. vnode */ + TAILQ_HEAD(, dircache) v_dircache; /* i Dircache referencies */ /* * clustering stuff