Date: Mon, 7 Jun 2010 20:09:04 GMT From: Gleb Kurtsou <gk@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 179301 for review Message-ID: <201006072009.o57K94ea040040@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/param.h> +#include <sys/dircache.h> #include <sys/namei.h> #include <sys/priv.h> #include <sys/proc.h> @@ -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 <sys/param.h> +#include <sys/dircache.h> #include <sys/limits.h> #include <sys/lock.h> #include <sys/mutex.h> @@ -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 <sys/param.h> +#include <sys/dircache.h> #include <sys/fcntl.h> #include <sys/lockf.h> #include <sys/namei.h> @@ -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 <bsd.kmod.mk> ==== //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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006072009.o57K94ea040040>