Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Adapt to cache_lookup() changes.



details:   https://anonhg.NetBSD.org/src/rev/c9991784f369
branches:  trunk
changeset: 476090:c9991784f369
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Sep 05 14:26:32 1999 +0000

description:
Adapt to cache_lookup() changes.

Tested by: jdolecek
Rewieved by: wrstuden

diffstat:

 sys/adosfs/adlookup.c            |  47 +++--------------------------
 sys/filecorefs/filecore_lookup.c |  61 +-------------------------------------
 sys/msdosfs/msdosfs_lookup.c     |  62 +--------------------------------------
 sys/ntfs/ntfs_vnops.c            |  60 +------------------------------------
 sys/ufs/ext2fs/ext2fs_lookup.c   |  57 +----------------------------------
 sys/ufs/ufs/ufs_lookup.c         |  57 +----------------------------------
 6 files changed, 21 insertions(+), 323 deletions(-)

diffs (truncated from 429 to 300 lines):

diff -r a0530dd86a18 -r c9991784f369 sys/adosfs/adlookup.c
--- a/sys/adosfs/adlookup.c     Sun Sep 05 14:22:34 1999 +0000
+++ b/sys/adosfs/adlookup.c     Sun Sep 05 14:26:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adlookup.c,v 1.23 1999/07/08 01:05:58 wrstuden Exp $   */
+/*     $NetBSD: adlookup.c,v 1.24 1999/09/05 14:26:32 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -109,47 +109,12 @@
                return (EROFS);
 
        /*
-        * cache lookup algorithm borrowed from ufs_lookup()
-        * its not consistent with otherthings in this function..
+        * 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.
         */
-       if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
-               if (error == ENOENT)
-                       return (error);
-
-               vpid = (*vpp)->v_id;
-               if (vdp == *vpp) {
-                       VREF(vdp);
-                       error = 0;
-               } else if (flags & ISDOTDOT) {
-                       VOP_UNLOCK(vdp, 0);     /* race */
-                       cnp->cn_flags |= PDIRUNLOCK;
-                       error = vget(*vpp, LK_EXCLUSIVE);
-                       if (error == 0 && lockp && last) {
-                               if ((error = vn_lock(vdp, LK_EXCLUSIVE)))
-                                       cnp->cn_flags &= ~PDIRUNLOCK;
-                       }
-               } else {
-                       error = vget(*vpp, LK_EXCLUSIVE);
-                       /* if (lockp == 0 || error || last) */
-                       if (lockp == 0 || error || last == 0) {
-                               VOP_UNLOCK(vdp, 0);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               if (error == 0) {
-                       if (vpid == vdp->v_id)
-                               return (0);
-                       vput(*vpp);
-                       if (lockp && vdp != *vpp && last) {
-                               VOP_UNLOCK(vdp, 0);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               *vpp = NULL;
-               if ((error = vn_lock(vdp, LK_EXCLUSIVE)) != 0)
-                       return (error);
-               cnp->cn_flags &= ~PDIRUNLOCK;
-       }
+       if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
+               return (error);
 
        /*
         * fake a '.'
diff -r a0530dd86a18 -r c9991784f369 sys/filecorefs/filecore_lookup.c
--- a/sys/filecorefs/filecore_lookup.c  Sun Sep 05 14:22:34 1999 +0000
+++ b/sys/filecorefs/filecore_lookup.c  Sun Sep 05 14:26:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_lookup.c,v 1.7 1999/08/18 22:01:53 mark Exp $ */
+/*     $NetBSD: filecore_lookup.c,v 1.8 1999/09/05 14:26:33 jdolecek Exp $     */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -143,63 +143,8 @@
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
-       if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
-               int vpid;       /* capability number of vnode */
-
-               if (error == ENOENT)
-                       return (error);
-#ifdef PARANOID
-               if ((vdp->v_flag & VROOT) && (flags & ISDOTDOT))
-                       panic("filecore_lookup: .. through root");
-#endif
-               /*
-                * 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) {
-                       VREF(vdp);
-                       error = 0;
-               } else if (flags & ISDOTDOT) {
-                       VOP_UNLOCK(pdp, 0);
-                       cnp->cn_flags |= PDIRUNLOCK;
-                       error = vget(vdp, LK_EXCLUSIVE);
-                       if (!error && lockparent && (flags & ISLASTCN)) {
-                               error = vn_lock(pdp, LK_EXCLUSIVE);
-                               if (error == 0)
-                                       cnp->cn_flags &= ~PDIRUNLOCK;
-                       }
-               } else {
-                       error = vget(vdp, LK_EXCLUSIVE);
-                       if (!lockparent || error || !(flags & ISLASTCN)) {
-                               VOP_UNLOCK(pdp, 0);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               /*
-                * 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);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
-                       return (error);
-               cnp->cn_flags &= ~PDIRUNLOCK;
-               vdp = pdp;
-               dp = VTOI(pdp);
-               *vpp = NULL;
-       }
+       if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
+               return (error);
        
        name = cnp->cn_nameptr;
        namelen = cnp->cn_namelen;
diff -r a0530dd86a18 -r c9991784f369 sys/msdosfs/msdosfs_lookup.c
--- a/sys/msdosfs/msdosfs_lookup.c      Sun Sep 05 14:22:34 1999 +0000
+++ b/sys/msdosfs/msdosfs_lookup.c      Sun Sep 05 14:26:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_lookup.c,v 1.41 1999/08/04 18:40:48 wrstuden Exp $     */
+/*     $NetBSD: msdosfs_lookup.c,v 1.42 1999/09/05 14:26:33 jdolecek Exp $     */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -147,64 +147,8 @@
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
-       if ((error = cache_lookup(vdp, vpp, cnp)) != 0) {
-               int vpid;
-
-               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 = VTODE(*vpp);
-               vdp = *vpp;
-               vpid = vdp->v_id;
-               if (pdp == vdp) {   /* lookup on "." */
-                       VREF(vdp);
-                       error = 0;
-               } else if (flags & ISDOTDOT) {
-                       VOP_UNLOCK(pdp, 0);
-                       cnp->cn_flags |= PDIRUNLOCK;
-                       error = vget(vdp, LK_EXCLUSIVE);
-                       if (!error && lockparent && (flags & ISLASTCN)){
-                               error = vn_lock(pdp, LK_EXCLUSIVE);
-                               if (error == 0)
-                                       cnp->cn_flags &= ~PDIRUNLOCK;
-                       }
-               } else {
-                       error = vget(vdp, LK_EXCLUSIVE);
-                       if (!lockparent || error || !(flags & ISLASTCN)) {
-                               VOP_UNLOCK(pdp, 0);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               /*
-                * Check that the capability number did not change
-                * while we were waiting for the lock.
-                */
-               if (!error) {
-                       if (vpid == vdp->v_id) {
-#ifdef MSDOSFS_DEBUG
-                               printf("msdosfs_lookup(): cache hit, vnode %p, file %s\n",
-                                      vdp, dp->de_Name);
-#endif
-                               return (0);
-                       }
-                       vput(vdp);
-                       if (lockparent && pdp != vdp && (flags & ISLASTCN)) {
-                               VOP_UNLOCK(pdp, 0);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
-                       return (error);
-               cnp->cn_flags &= ~PDIRUNLOCK;
-               vdp = pdp;
-               dp = VTODE(vdp);
-               *vpp = NULL;
-       }
+       if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
+               return (error);
 
        /*
         * If they are going after the . or .. entry in the root directory,
diff -r a0530dd86a18 -r c9991784f369 sys/ntfs/ntfs_vnops.c
--- a/sys/ntfs/ntfs_vnops.c     Sun Sep 05 14:22:34 1999 +0000
+++ b/sys/ntfs/ntfs_vnops.c     Sun Sep 05 14:26:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vnops.c,v 1.11 1999/09/05 11:09:03 jdolecek Exp $ */
+/*     $NetBSD: ntfs_vnops.c,v 1.12 1999/09/05 14:26:33 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -898,62 +898,8 @@
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
-       if ((error = cache_lookup(ap->a_dvp, ap->a_vpp, cnp)) != 0) {
-               int vpid;
-               struct vnode *pdp, *vdp = ap->a_dvp;
-               struct vnode **vpp = ap->a_vpp;
-               u_long flags = cnp->cn_flags;
-
-               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;
-               vdp = *vpp;
-               vpid = vdp->v_id;
-               if (pdp == vdp) {   /* lookup on "." */
-                       VREF(vdp);
-                       error = 0;
-               } else if (flags & ISDOTDOT) {
-                       VOP_UNLOCK(pdp, 0);
-                       cnp->cn_flags |= PDIRUNLOCK;
-                       error = vget(vdp, LK_EXCLUSIVE);
-                       if (!error && lockparent && (flags & ISLASTCN)){
-                               error = vn_lock(pdp, LK_EXCLUSIVE);
-                               if (error == 0)
-                                       cnp->cn_flags &= ~PDIRUNLOCK;
-                       }
-               } else {
-                       error = vget(vdp, LK_EXCLUSIVE);
-                       if (!lockparent || error || !(flags & ISLASTCN)) {
-                               VOP_UNLOCK(pdp, 0);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               /*
-                * 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);
-                               cnp->cn_flags |= PDIRUNLOCK;
-                       }
-               }
-               if ((error = vn_lock(pdp, LK_EXCLUSIVE)) != 0)
-                       return (error);
-               cnp->cn_flags &= ~PDIRUNLOCK;
-               vdp = pdp;
-               *vpp = NULL;
-       }
+       if ((error = cache_lookup(ap->a_dvp, ap->a_vpp, cnp)) >= 0)
+               return (error);
 #endif
 
        if(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
diff -r a0530dd86a18 -r c9991784f369 sys/ufs/ext2fs/ext2fs_lookup.c
--- a/sys/ufs/ext2fs/ext2fs_lookup.c    Sun Sep 05 14:22:34 1999 +0000
+++ b/sys/ufs/ext2fs/ext2fs_lookup.c    Sun Sep 05 14:26:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_lookup.c,v 1.11 1999/08/04 18:40:47 wrstuden Exp $      */
+/*     $NetBSD: ext2fs_lookup.c,v 1.12 1999/09/05 14:26:34 jdolecek Exp $      */
 
 /* 
  * Modified for NetBSD 1.2E
@@ -316,59 +316,8 @@
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */



Home | Main Index | Thread Index | Old Index