Source-Changes-HG archive

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

[src/trunk]: src/sys/nfs don't issue VOP_GETATTR blindly in nfs_nget().



details:   https://anonhg.NetBSD.org/src/rev/713f4b06b9d9
branches:  trunk
changeset: 565369:713f4b06b9d9
user:      yamt <yamt%NetBSD.org@localhost>
date:      Mon Apr 05 10:40:56 2004 +0000

description:
don't issue VOP_GETATTR blindly in nfs_nget().
in many cases, GETATTR RPCs here is redundant because the caller has
postop_attr.  instead, make sure the resulted vnode have a valid
attribute in nfs_lookup().

diffstat:

 sys/nfs/nfs_node.c  |  12 ++++--------
 sys/nfs/nfs_vnops.c |  25 ++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 11 deletions(-)

diffs (93 lines):

diff -r bbbc9abe634b -r 713f4b06b9d9 sys/nfs/nfs_node.c
--- a/sys/nfs/nfs_node.c        Mon Apr 05 10:36:32 2004 +0000
+++ b/sys/nfs/nfs_node.c        Mon Apr 05 10:40:56 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_node.c,v 1.73 2004/03/12 16:52:37 yamt Exp $       */
+/*     $NetBSD: nfs_node.c,v 1.74 2004/04/05 10:40:56 yamt Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.73 2004/03/12 16:52:37 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.74 2004/04/05 10:40:56 yamt Exp $");
 
 #include "opt_nfs.h"
 
@@ -211,12 +211,8 @@
        crhold(np->n_wcred);
        lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL);
        lockmgr(&nfs_hashlock, LK_RELEASE, NULL);
-       error = VOP_GETATTR(vp, np->n_vattr, curproc->p_ucred, curproc);
-       if (error) {
-               vput(vp);
-               return error;
-       }
-       uvm_vnp_setsize(vp, np->n_vattr->va_size);
+       NFS_INVALIDATE_ATTRCACHE(np);
+       uvm_vnp_setsize(vp, 0);
        *npp = np;
        return (0);
 }
diff -r bbbc9abe634b -r 713f4b06b9d9 sys/nfs/nfs_vnops.c
--- a/sys/nfs/nfs_vnops.c       Mon Apr 05 10:36:32 2004 +0000
+++ b/sys/nfs/nfs_vnops.c       Mon Apr 05 10:40:56 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_vnops.c,v 1.189 2004/04/05 10:36:32 yamt Exp $     */
+/*     $NetBSD: nfs_vnops.c,v 1.190 2004/04/05 10:40:56 yamt Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.189 2004/04/05 10:36:32 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.190 2004/04/05 10:40:56 yamt Exp $");
 
 #include "opt_nfs.h"
 #include "opt_uvmhist.h"
@@ -906,6 +906,7 @@
                        if ((!lockparent || !(flags & ISLASTCN)) &&     
                             newvp != dvp)
                                VOP_UNLOCK(dvp, 0);
+                       KASSERT(newvp->v_type != VNON);
                        return (0);
                }
                cache_purge1(newvp, NULL, PURGE_PARENTS);
@@ -959,7 +960,7 @@
                        VOP_UNLOCK(dvp, 0);
                        cnp->cn_flags |= PDIRUNLOCK;
                }
-               return (0);
+               goto validate;
        }
 
        /*
@@ -1063,6 +1064,24 @@
                if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
                        cnp->cn_flags |= SAVENAME;
                *vpp = NULL;
+               return error;
+       }
+
+validate:
+       /*
+        * make sure we have valid type and size.
+        */
+
+       newvp = *vpp;
+       if (newvp->v_type == VNON) {
+               struct vattr vattr; /* dummy */
+
+               KASSERT(VTONFS(newvp)->n_attrstamp == 0);
+               error = VOP_GETATTR(newvp, &vattr, cnp->cn_cred, cnp->cn_proc);
+               if (error) {
+                       vput(newvp);
+                       *vpp = NULL;
+               }
        }
 
        return error;



Home | Main Index | Thread Index | Old Index