diff options
author | phk <phk@FreeBSD.org> | 1997-08-26 07:32:51 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-08-26 07:32:51 +0000 |
commit | fddfc9d5bb4c35d88417fa80a062219876186593 (patch) | |
tree | 7f29931e5661e3731f6b972dc3a9508534617833 /sys/ufs | |
parent | f320b3a30651cae7b34067561adb48f2b6f57621 (diff) | |
download | FreeBSD-src-fddfc9d5bb4c35d88417fa80a062219876186593.zip FreeBSD-src-fddfc9d5bb4c35d88417fa80a062219876186593.tar.gz |
Uncut&paste cache_lookup().
This unifies several times in theory indentical 50 lines of code.
The filesystems have a new method: vop_cachedlookup, which is the
meat of the lookup, and use vfs_cache_lookup() for their vop_lookup
method. vfs_cache_lookup() will check the namecache and pass on
to the vop_cachedlookup method in case of a miss.
It's still the task of the individual filesystems to populate the
namecache with cache_enter().
Filesystems that do not use the namecache will just provide the
vop_lookup method as usual.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_vnops.c | 5 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_extern.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_lookup.c | 55 |
3 files changed, 7 insertions, 57 deletions
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 341a428..35274bf 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vnops.c 8.15 (Berkeley) 5/14/95 - * $Id: ffs_vnops.c,v 1.25 1997/03/22 06:53:30 bde Exp $ + * $Id: ffs_vnops.c,v 1.26 1997/08/25 08:18:23 kato Exp $ */ #include <sys/param.h> @@ -78,7 +78,8 @@ static int ffs_write __P((struct vop_write_args *)); vop_t **ffs_vnodeop_p; static struct vnodeopv_entry_desc ffs_vnodeop_entries[] = { { &vop_default_desc, (vop_t *)vn_default_error }, - { &vop_lookup_desc, (vop_t *)ufs_lookup }, /* lookup */ + { &vop_lookup_desc, (vop_t *)vfs_cache_lookup },/* lookup */ + { &vop_cachedlookup_desc, (vop_t *)ufs_lookup },/* cachedlookup */ { &vop_create_desc, (vop_t *)ufs_create }, /* create */ { &vop_whiteout_desc, (vop_t *)ufs_whiteout }, /* whiteout */ { &vop_mknod_desc, (vop_t *)ufs_mknod }, /* mknod */ diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index e1f38af..690e31c 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 - * $Id: ufs_extern.h,v 1.14 1997/02/22 09:47:46 peter Exp $ + * $Id: ufs_extern.h,v 1.15 1997/08/16 19:16:26 wollman Exp $ */ #ifndef _UFS_UFS_EXTERN_H_ @@ -93,7 +93,7 @@ int ufs_islocked __P((struct vop_islocked_args *)); #endif int ufs_link __P((struct vop_link_args *)); int ufs_lock __P((struct vop_lock_args *)); -int ufs_lookup __P((struct vop_lookup_args *)); +int ufs_lookup __P((struct vop_cachedlookup_args *)); int ufs_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *)); int ufs_mkdir __P((struct vop_mkdir_args *)); int ufs_mknod __P((struct vop_mknod_args *)); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index c5ccbbe..3d32aa8 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_lookup.c 8.15 (Berkeley) 6/16/95 - * $Id: ufs_lookup.c,v 1.13 1997/03/09 06:10:33 mpp Exp $ + * $Id: ufs_lookup.c,v 1.14 1997/03/31 12:02:49 peter Exp $ */ #include <sys/param.h> @@ -97,7 +97,7 @@ int dirchk = 0; */ int ufs_lookup(ap) - struct vop_lookup_args /* { + struct vop_cachedlookup_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; @@ -153,57 +153,6 @@ ufs_lookup(ap) /* * We now have a segment name to search for, and a directory to search. * - * Before tediously performing a linear scan of the directory, - * check the name cache to see if the directory/name pair - * we are looking for is known already. - */ - error = cache_lookup(vdp, vpp, cnp); - if (error) { - int vpid; /* capability number of vnode */ - - if (error == ENOENT) - return (error); - /* - * Get the next vnode in the path. - * See comment below starting `Step through' for - * an explaination of the locking protocol. - */ - pdp = vdp; - dp = VTOI(*vpp); - vdp = *vpp; - vpid = vdp->v_id; - if (pdp == vdp) { /* lookup on "." */ - VREF(vdp); - error = 0; - } else if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp, 0, p); - error = vget(vdp, LK_EXCLUSIVE, p); - if (!error && lockparent && (flags & ISLASTCN)) - error = vn_lock(pdp, LK_EXCLUSIVE, p); - } else { - error = vget(vdp, LK_EXCLUSIVE, p); - if (!lockparent || error || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp, 0, p); - } - /* - * Check that the capability number did not change - * while we were waiting for the lock. - */ - if (!error) { - if (vpid == vdp->v_id) - return (0); - vput(vdp); - if (lockparent && pdp != vdp && (flags & ISLASTCN)) - VOP_UNLOCK(pdp, 0, p); - } - if (error = vn_lock(pdp, LK_EXCLUSIVE, p)) - return (error); - vdp = pdp; - dp = VTOI(pdp); - *vpp = NULL; - } - - /* * Suppress search for slots unless creating * file and at end of pathname, in which case * we watch for a place to put the new file in |