From f3d6ee090e91ef1173eff08d7a49fb8b26860400 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Mon, 2 Nov 1998 02:36:16 +0000 Subject: [PATCH] Only do one VOP_ACCESS() per open() instead of two. This should reduce the NFSv3 ACCESS RPC problems a little for busy clients that do a lot of open/close. The nfs code could probably cache the results, but I'm not sure whether this would be legal or useful. The problem is that with a CPU farm, on each open there would be a lookup, getattr then access RPC then the read/write RPC activity. Caching the access results probably isn't going to help much if the clients access lots of files. Having the nfs_access() routine interpret the getattr results is a bit of a hack, but it's how NFSv2 is done and it might be OK for a mount attribute for v3. --- sys/kern/vfs_vnops.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 41e8cbb15dde..2b73bcc9c65a 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 - * $Id: vfs_vnops.c,v 1.58 1998/06/07 17:11:48 dfr Exp $ + * $Id: vfs_vnops.c,v 1.59 1998/06/27 06:43:09 phk Exp $ */ #include @@ -78,7 +78,7 @@ vn_open(ndp, fmode, cmode) register struct ucred *cred = p->p_ucred; struct vattr vat; struct vattr *vap = &vat; - int error; + int mode, error; if (fmode & O_CREAT) { ndp->ni_cnd.cn_nameiop = CREATE; @@ -136,11 +136,7 @@ vn_open(ndp, fmode, cmode) goto bad; } if ((fmode & O_CREAT) == 0) { - if (fmode & FREAD) { - error = VOP_ACCESS(vp, VREAD, cred, p); - if (error) - goto bad; - } + mode = 0; if (fmode & (FWRITE | O_TRUNC)) { if (vp->v_type == VDIR) { error = EISDIR; @@ -149,7 +145,12 @@ vn_open(ndp, fmode, cmode) error = vn_writechk(vp); if (error) goto bad; - error = VOP_ACCESS(vp, VWRITE, cred, p); + mode |= VWRITE; + } + if (fmode & FREAD) + mode |= VREAD; + if (mode) { + error = VOP_ACCESS(vp, mode, cred, p); if (error) goto bad; }