update of July 5th from Rick Macklem
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 7 Jul 1989 08:42:37 +0000 (00:42 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 7 Jul 1989 08:42:37 +0000 (00:42 -0800)
SCCS-vsn: sys/nfs/nfs.h 7.2
SCCS-vsn: sys/nfs/nfs_vnops.c 7.2
SCCS-vsn: sys/nfs/nfs_node.c 7.3
SCCS-vsn: sys/nfs/nfs_serv.c 7.3
SCCS-vsn: sys/nfs/nfs_socket.c 7.2
SCCS-vsn: sys/nfs/nfs_subs.c 7.3
SCCS-vsn: sys/nfs/nfs_vfsops.c 7.2
SCCS-vsn: sys/nfs/nfsm_subs.h 7.2

usr/src/sys/nfs/nfs.h
usr/src/sys/nfs/nfs_node.c
usr/src/sys/nfs/nfs_serv.c
usr/src/sys/nfs/nfs_socket.c
usr/src/sys/nfs/nfs_subs.c
usr/src/sys/nfs/nfs_vfsops.c
usr/src/sys/nfs/nfs_vnops.c
usr/src/sys/nfs/nfsm_subs.h

index cd913ef..1755509 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs.h       7.1 (Berkeley) %G%
+ *     @(#)nfs.h       7.2 (Berkeley) %G%
  */
 
 /*
  * Tunable constants for nfs
  */
 #define        MAX_IOVEC       10
  */
 
 /*
  * Tunable constants for nfs
  */
 #define        MAX_IOVEC       10
-#define        NFS_TIMEO       10      /* Timeout in .01 sec intervals */
+#define        NFS_TIMEO       10      /* Timeout in .1 sec intervals */
+#define        NFS_MAXTIMEO    600     /* Max timeout to backoff too in .1 sec */
 #define        NFS_ATTRTIMEO   5       /* Attribute cache timeout in sec */
 #define        NFS_RETRANS     10      /* Num of retrans for soft mounts */
 #define        NFS_ATTRTIMEO   5       /* Attribute cache timeout in sec */
 #define        NFS_RETRANS     10      /* Num of retrans for soft mounts */
-#define        NFS_WSIZE       8196    /* Max. write data size <= 8192 */
-#define        NFS_RSIZE       8196    /* Max. read data size <= 8192 */
+#define        NFS_WSIZE       8192    /* Max. write data size <= 8192 */
+#define        NFS_RSIZE       8192    /* Max. read data size <= 8192 */
 #define        MAX_READDIR     NFS_RSIZE       /* Max. size of directory read */
 
 /*
 #define        MAX_READDIR     NFS_RSIZE       /* Max. size of directory read */
 
 /*
index bd23d2a..9824bb1 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs_node.c  7.2 (Berkeley) %G%
+ *     @(#)nfs_node.c  7.3 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -26,7 +26,7 @@
 #include "proc.h"
 #include "mount.h"
 #include "vnode.h"
 #include "proc.h"
 #include "mount.h"
 #include "vnode.h"
-#include "dir.h"
+#include "../ufs/dir.h"
 #include "namei.h"
 #include "errno.h"
 #include "nfsv2.h"
 #include "namei.h"
 #include "errno.h"
 #include "nfsv2.h"
@@ -137,7 +137,7 @@ loop:
                                np->n_freeb = NULL;
                        }
                        np->n_flag |= NLOCKED;
                                np->n_freeb = NULL;
                        }
                        np->n_flag |= NLOCKED;
-                       vp->v_count++;
+                       VREF(vp);
                        *npp = np;
                        return(0);
                }
                        *npp = np;
                        return(0);
                }
@@ -208,7 +208,7 @@ nfs_ngrab(np)
                np->n_freef = NULL;
                np->n_freeb = NULL;
        }
                np->n_freef = NULL;
                np->n_freeb = NULL;
        }
-       vp->v_count++;
+       VREF(vp);
        np->n_flag |= NLOCKED;
 }
 
        np->n_flag |= NLOCKED;
 }
 
index c80e631..28a26fd 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs_serv.c  7.2 (Berkeley) %G%
+ *     @(#)nfs_serv.c  7.3 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
  * - these routines generally have 3 phases
  *   1 - break down and validate rpc request in mbuf list
  *   2 - do the vnode ops for the request
  * - these routines generally have 3 phases
  *   1 - break down and validate rpc request in mbuf list
  *   2 - do the vnode ops for the request
- *      (surprisingly ?? many are very similar to syscalls in vfs_syscalls.c)
+ *       (surprisingly ?? many are very similar to syscalls in vfs_syscalls.c)
  *   3 - build the rpc reply in an mbuf list
  *   nb:
  *     - do not mix the phases, since the nfsm_?? macros can return failures
  *       on mbuf exhaustion or similar and do not do any vrele() or vput()'s
  *
  *   3 - build the rpc reply in an mbuf list
  *   nb:
  *     - do not mix the phases, since the nfsm_?? macros can return failures
  *       on mbuf exhaustion or similar and do not do any vrele() or vput()'s
  *
- *     - the nfsm_reply() macro generates an nfs rpc reply with the nfs
+ *      - the nfsm_reply() macro generates an nfs rpc reply with the nfs
  *     error number iff error != 0 whereas
  *     error number iff error != 0 whereas
- *      nfsm_srverr simply drops the mbufs and gives up
- *      (==> nfsm_srverr implies an error here at the server, usually mbuf
+ *       nfsm_srverr simply drops the mbufs and gives up
+ *       (==> nfsm_srverr implies an error here at the server, usually mbuf
  *       exhaustion)
  */
 
  *       exhaustion)
  */
 
@@ -59,8 +59,8 @@
 #include "nfsm_subs.h"
 
 /* Defs */
 #include "nfsm_subs.h"
 
 /* Defs */
-#define TRUE   1
-#define FALSE  0
+#define        TRUE    1
+#define        FALSE   0
 
 /* Global vars */
 extern u_long nfs_procids[NFS_NPROCS];
 
 /* Global vars */
 extern u_long nfs_procids[NFS_NPROCS];
@@ -152,8 +152,9 @@ nfsrv_setattr(mrep, md, dpos, cred, xid, mrq)
                vap->va_uid = fxdr_unsigned(uid_t, *p);
        if (*++p != nfs_xdrneg1)
                vap->va_gid = fxdr_unsigned(gid_t, *p);
                vap->va_uid = fxdr_unsigned(uid_t, *p);
        if (*++p != nfs_xdrneg1)
                vap->va_gid = fxdr_unsigned(gid_t, *p);
-       if (*++p != nfs_xdrneg1)
+       if (*++p != nfs_xdrneg1) {
                vap->va_size = fxdr_unsigned(u_long, *p);
                vap->va_size = fxdr_unsigned(u_long, *p);
+       }
        if (*++p != nfs_xdrneg1)
                fxdr_time(p, &(vap->va_atime));
        p += 2;
        if (*++p != nfs_xdrneg1)
                fxdr_time(p, &(vap->va_atime));
        p += 2;
@@ -210,7 +211,6 @@ nfsrv_lookup(mrep, md, dpos, cred, xid, mrq)
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = LOOKUP | LOCKLEAF;
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = LOOKUP | LOCKLEAF;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vp = ndp->ni_vp;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vp = ndp->ni_vp;
@@ -572,7 +572,6 @@ nfsrv_create(mrep, md, dpos, cred, xid, mrq)
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT | LOCKLEAF;
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT | LOCKLEAF;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vattr_null(vap);
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vattr_null(vap);
@@ -587,15 +586,15 @@ nfsrv_create(mrep, md, dpos, cred, xid, mrq)
                vap->va_mode = nfstov_mode(*p++);
                if (error = VOP_CREATE(ndp, vap))
                        nfsm_reply(0);
                vap->va_mode = nfstov_mode(*p++);
                if (error = VOP_CREATE(ndp, vap))
                        nfsm_reply(0);
+               vp = ndp->ni_vp;
        } else {
        } else {
+               vp = ndp->ni_vp;
+               ndp->ni_vp = (struct vnode *)0;
+               VOP_ABORTOP(ndp);
                vap->va_size = 0;
                vap->va_size = 0;
-               if (error = VOP_SETATTR(ndp->ni_vp, vap, cred)) {
-                       VOP_ABORTOP(ndp);
+               if (error = VOP_SETATTR(vp, vap, cred))
                        nfsm_reply(0);
                        nfsm_reply(0);
-               }
-               vput(ndp->ni_dvp);
        }
        }
-       vp = ndp->ni_vp;
        bzero((caddr_t)fhp, sizeof(nfh));
        fhp->fh_fsid = vp->v_mount->m_fsid;
        if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) {
        bzero((caddr_t)fhp, sizeof(nfh));
        fhp->fh_fsid = vp->v_mount->m_fsid;
        if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) {
@@ -650,7 +649,6 @@ nfsrv_remove(mrep, md, dpos, cred, xid, mrq)
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vp = ndp->ni_vp;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vp = ndp->ni_vp;
@@ -677,7 +675,6 @@ out:
 
 /*
  * nfs rename service
 
 /*
  * nfs rename service
- * malloc() the tond structure to avoid blowing the kernel stack
  */
 nfsrv_rename(mrep, md, dpos, cred, xid, mrq)
        struct mbuf *mrep, *md, **mrq;
  */
 nfsrv_rename(mrep, md, dpos, cred, xid, mrq)
        struct mbuf *mrep, *md, **mrq;
@@ -685,18 +682,17 @@ nfsrv_rename(mrep, md, dpos, cred, xid, mrq)
        struct ucred *cred;
        long xid;
 {
        struct ucred *cred;
        long xid;
 {
-       struct nameidata *nam, *tond;
+       register struct nameidata *ndp;
        nfsm_srvars;
        nfsm_srvars;
+       struct nameidata tond;
        struct vnode *fvp, *tvp, *tdvp;
        nfsv2fh_t fnfh, tnfh;
        fhandle_t *ffhp, *tfhp;
        long len, len2;
        int rootflg = 0;
 
        struct vnode *fvp, *tvp, *tdvp;
        nfsv2fh_t fnfh, tnfh;
        fhandle_t *ffhp, *tfhp;
        long len, len2;
        int rootflg = 0;
 
-       nam = &u.u_nd;
-       MALLOC(tond, struct nameidata *, sizeof(*tond), M_TEMP, M_WAITOK);
-       ndinit(tond);
-       nam->ni_vp = nam->ni_dvp = (struct vnode *)0;
+       ndp = &u.u_nd;
+       ndp->ni_vp = ndp->ni_dvp = (struct vnode *)0;
        ffhp = &fnfh.fh_generic;
        tfhp = &tnfh.fh_generic;
        nfsm_srvmtofh(ffhp);
        ffhp = &fnfh.fh_generic;
        tfhp = &tnfh.fh_generic;
        nfsm_srvmtofh(ffhp);
@@ -707,23 +703,20 @@ nfsrv_rename(mrep, md, dpos, cred, xid, mrq)
         */
        if (cred->cr_uid == 0)
                rootflg++;
         */
        if (cred->cr_uid == 0)
                rootflg++;
-       nam->ni_cred = cred;
-       nam->ni_nameiop = DELETE | WANTPARENT;
-       nam->ni_segflg = UIO_SYSSPACE;
-       if (error = nfs_namei(nam, ffhp, len, &md, &dpos))
+       ndp->ni_cred = cred;
+       ndp->ni_nameiop = DELETE | WANTPARENT;
+       if (error = nfs_namei(ndp, ffhp, len, &md, &dpos))
                nfsm_reply(0);
                nfsm_reply(0);
+       fvp = ndp->ni_vp;
        nfsm_srvmtofh(tfhp);
        nfsm_srvstrsiz(len2, NFS_MAXNAMLEN);
        if (rootflg)
                cred->cr_uid = 0;
        nfsm_srvmtofh(tfhp);
        nfsm_srvstrsiz(len2, NFS_MAXNAMLEN);
        if (rootflg)
                cred->cr_uid = 0;
-       tond->ni_cred = cred;
-       crhold(cred);
-       tond->ni_nameiop = RENAME | LOCKPARENT | LOCKLEAF | NOCACHE;
-       tond->ni_segflg = UIO_SYSSPACE;
-       error = nfs_namei(tond, tfhp, len2, &md, &dpos);
-       fvp = nam->ni_vp;
-       tdvp = tond->ni_dvp;
-       tvp = tond->ni_vp;
+       nddup(ndp, &tond);
+       tond.ni_nameiop = RENAME | LOCKPARENT | LOCKLEAF | NOCACHE;
+       error = nfs_namei(&tond, tfhp, len2, &md, &dpos);
+       tdvp = tond.ni_dvp;
+       tvp = tond.ni_vp;
        if (tvp != NULL) {
                if (fvp->v_type == VDIR && tvp->v_type != VDIR) {
                        error = EISDIR;
        if (tvp != NULL) {
                if (fvp->v_type == VDIR && tvp->v_type != VDIR) {
                        error = EISDIR;
@@ -734,7 +727,7 @@ nfsrv_rename(mrep, md, dpos, cred, xid, mrq)
                }
        }
        if (error) {
                }
        }
        if (error) {
-               VOP_ABORTOP(nam);
+               VOP_ABORTOP(ndp);
                goto out1;
        }
        if (fvp->v_mount != tdvp->v_mount) {
                goto out1;
        }
        if (fvp->v_mount != tdvp->v_mount) {
@@ -745,19 +738,17 @@ nfsrv_rename(mrep, md, dpos, cred, xid, mrq)
                error = EINVAL;
 out:
        if (error) {
                error = EINVAL;
 out:
        if (error) {
-               VOP_ABORTOP(tond);
-               VOP_ABORTOP(nam);
+               VOP_ABORTOP(&tond);
+               VOP_ABORTOP(ndp);
        } else {
        } else {
-               error = VOP_RENAME(nam, tond);
+               error = VOP_RENAME(ndp, &tond);
        }
 out1:
        }
 out1:
-       crfree(tond->ni_cred);
-       FREE((caddr_t)tond, M_TEMP);
+       ndrele(&tond);
        nfsm_reply(0);
        return (error);
 nfsmout:
        nfsm_reply(0);
        return (error);
 nfsmout:
-       VOP_ABORTOP(nam);
-       free((caddr_t)tond, M_TEMP);
+       VOP_ABORTOP(ndp);
        return (error);
 }
 
        return (error);
 }
 
@@ -788,7 +779,6 @@ nfsrv_link(mrep, md, dpos, cred, xid, mrq)
                goto out1;
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
                goto out1;
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, dfhp, len, &md, &dpos))
                goto out1;
        xp = ndp->ni_vp;
        if (error = nfs_namei(ndp, dfhp, len, &md, &dpos))
                goto out1;
        xp = ndp->ni_vp;
@@ -834,7 +824,6 @@ nfsrv_symlink(mrep, md, dpos, cred, xid, mrq)
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                goto out1;
        nfsm_srvstrsiz(len2, NFS_MAXPATHLEN);
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                goto out1;
        nfsm_srvstrsiz(len2, NFS_MAXPATHLEN);
@@ -890,7 +879,6 @@ nfsrv_mkdir(mrep, md, dpos, cred, xid, mrq)
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        nfsm_disect(p, u_long *, NFSX_UNSIGNED);
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        nfsm_disect(p, u_long *, NFSX_UNSIGNED);
@@ -960,7 +948,6 @@ nfsrv_rmdir(mrep, md, dpos, cred, xid, mrq)
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
        nfsm_srvstrsiz(len, NFS_MAXNAMLEN);
        ndp->ni_cred = cred;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
-       ndp->ni_segflg = UIO_SYSSPACE;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vp = ndp->ni_vp;
        if (error = nfs_namei(ndp, fhp, len, &md, &dpos))
                nfsm_reply(0);
        vp = ndp->ni_vp;
@@ -992,30 +979,30 @@ out:
 /*
  * nfs readdir service
  * - mallocs what it thinks is enough to read
 /*
  * nfs readdir service
  * - mallocs what it thinks is enough to read
- *      count rounded up to a multiple of DIRBLKSIZ <= MAX_READDIR
+ *     count rounded up to a multiple of DIRBLKSIZ <= MAX_READDIR
  * - calls VOP_READDIR()
  * - loops arround building the reply
  * - calls VOP_READDIR()
  * - loops arround building the reply
- *      if the output generated exceeds count break out of loop
- *      The nfsm_clget macro is used here so that the reply will be packed
- *      tightly in mbuf clusters.
+ *     if the output generated exceeds count break out of loop
+ *     The nfsm_clget macro is used here so that the reply will be packed
+ *     tightly in mbuf clusters.
  * - it only knows that it has encountered eof when the VOP_READDIR()
  * - it only knows that it has encountered eof when the VOP_READDIR()
- *      reads nothing
+ *     reads nothing
  * - as such one readdir rpc will return eof false although you are there
  * - as such one readdir rpc will return eof false although you are there
- *      and then the next will return eof
+ *     and then the next will return eof
  * - it trims out records with d_ino == 0
  * - it trims out records with d_ino == 0
- *      this doesn't matter for Unix clients, but they might confuse clients
- *      for other os'.
+ *     this doesn't matter for Unix clients, but they might confuse clients
+ *     for other os'.
  * NB: It is tempting to set eof to true if the VOP_READDIR() reads less
  * NB: It is tempting to set eof to true if the VOP_READDIR() reads less
- *      than requested, but this may not apply to all filesystems. For
- *      example, client NFS does not { although it is never remote mounted
- *      anyhow }
+ *     than requested, but this may not apply to all filesystems. For
+ *     example, client NFS does not { although it is never remote mounted
+ *     anyhow }
  * PS: The NFS protocol spec. does not clarify what the "count" byte
  * PS: The NFS protocol spec. does not clarify what the "count" byte
- *      argument is a count of.. just name strings and file id's or the
- *      entire reply rpc or ...
- *      I tried just file name and id sizes and it confused the Sun client,
- *      so I am using the full rpc size now. The "paranoia.." comment refers
- *      to including the status longwords that are not a part of the dir.
- *      "entry" structures, but are in the rpc.
+ *     argument is a count of.. just name strings and file id's or the
+ *     entire reply rpc or ...
+ *     I tried just file name and id sizes and it confused the Sun client,
+ *     so I am using the full rpc size now. The "paranoia.." comment refers
+ *     to including the status longwords that are not a part of the dir.
+ *     "entry" structures, but are in the rpc.
  */
 nfsrv_readdir(mrep, md, dpos, cred, xid, mrq)
        struct mbuf **mrq;
  */
 nfsrv_readdir(mrep, md, dpos, cred, xid, mrq)
        struct mbuf **mrq;
@@ -1106,7 +1093,7 @@ again:
                goto again;
        }
        vrele(vp);
                goto again;
        }
        vrele(vp);
-       len = 3*NFSX_UNSIGNED;  /* paranoia, probably can be 0 */
+       len = 3*NFSX_UNSIGNED;  /* paranoia, probably can be 0 */
        bp = be = (caddr_t)0;
        mp3 = (struct mbuf *)0;
        nfsm_reply(siz);
        bp = be = (caddr_t)0;
        mp3 = (struct mbuf *)0;
        nfsm_reply(siz);
@@ -1116,7 +1103,7 @@ again:
                if (dp->d_ino != 0) {
                        nlen = dp->d_namlen;
                        rem = nfsm_rndup(nlen)-nlen;
                if (dp->d_ino != 0) {
                        nlen = dp->d_namlen;
                        rem = nfsm_rndup(nlen)-nlen;
-
+       
                        /*
                         * As noted above, the NFS spec. is not clear about what
                         * should be included in "count" as totalled up here in
                        /*
                         * As noted above, the NFS spec. is not clear about what
                         * should be included in "count" as totalled up here in
@@ -1125,7 +1112,7 @@ again:
                        len += (4*NFSX_UNSIGNED+nlen+rem);
                        if (len > cnt)
                                break;
                        len += (4*NFSX_UNSIGNED+nlen+rem);
                        if (len > cnt)
                                break;
-
+       
                        /* Build the directory record xdr from the direct entry */
                        nfsm_clget;
                        *p = nfs_true;
                        /* Build the directory record xdr from the direct entry */
                        nfsm_clget;
                        *p = nfs_true;
@@ -1136,7 +1123,7 @@ again:
                        nfsm_clget;
                        *p = txdr_unsigned(nlen);
                        bp += NFSX_UNSIGNED;
                        nfsm_clget;
                        *p = txdr_unsigned(nlen);
                        bp += NFSX_UNSIGNED;
-
+       
                        /* And loop arround copying the name */
                        xfer = nlen;
                        cp = dp->d_name;
                        /* And loop arround copying the name */
                        xfer = nlen;
                        cp = dp->d_name;
@@ -1156,7 +1143,7 @@ again:
                        for (i = 0; i < rem; i++)
                                *bp++ = '\0';
                        nfsm_clget;
                        for (i = 0; i < rem; i++)
                                *bp++ = '\0';
                        nfsm_clget;
-
+       
                        /* Finish off the record */
                        toff += dp->d_reclen;
                        *p = txdr_unsigned(toff);
                        /* Finish off the record */
                        toff += dp->d_reclen;
                        *p = txdr_unsigned(toff);
@@ -1205,7 +1192,7 @@ nfsrv_statfs(mrep, md, dpos, cred, xid, mrq)
        vput(vp);
        nfsm_reply(NFSX_STATFS);
        nfsm_build(p, u_long *, NFSX_STATFS);
        vput(vp);
        nfsm_reply(NFSX_STATFS);
        nfsm_build(p, u_long *, NFSX_STATFS);
-       *p++ = txdr_unsigned(sf->f_bsize);
+       *p++ = txdr_unsigned(NFS_MAXDATA);
        *p++ = txdr_unsigned(sf->f_fsize);
        *p++ = txdr_unsigned(sf->f_blocks);
        *p++ = txdr_unsigned(sf->f_bfree);
        *p++ = txdr_unsigned(sf->f_fsize);
        *p++ = txdr_unsigned(sf->f_blocks);
        *p++ = txdr_unsigned(sf->f_bfree);
@@ -1246,3 +1233,4 @@ nfsrv_noop(mrep, md, dpos, cred, xid, mrq)
        nfsm_reply(0);
        nfsm_srvdone;
 }
        nfsm_reply(0);
        nfsm_srvdone;
 }
+
index 00a53d1..cc7b3b4 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs_socket.c        7.1 (Berkeley) %G%
+ *     @(#)nfs_socket.c        7.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -688,6 +688,9 @@ nfs_timer()
                                m = NFSMCOPY(rep->r_mreq, 0, M_COPYALL, M_DONTWAIT);
                                if (m != NULL) {
                                        nfsstats.rpcretries++;
                                m = NFSMCOPY(rep->r_mreq, 0, M_COPYALL, M_DONTWAIT);
                                if (m != NULL) {
                                        nfsstats.rpcretries++;
+                                       rep->r_timeout <<= 2; /* x4 backoff */
+                                       if (rep->r_timeout > NFS_MAXTIMEO)
+                                               rep->r_timeout = NFS_MAXTIMEO;
                                        rep->r_timer = rep->r_timeout;
                                        if (rep->r_retry != VNOVAL)
                                                rep->r_retry--;
                                        rep->r_timer = rep->r_timeout;
                                        if (rep->r_retry != VNOVAL)
                                                rep->r_retry--;
@@ -703,7 +706,7 @@ nfs_timer()
                rep = rep->r_next;
        }
        splx(s);
                rep = rep->r_next;
        }
        splx(s);
-       timeout(nfs_timer, (caddr_t)0, hz);
+       timeout(nfs_timer, (caddr_t)0, hz/10);
 }
 
 /*
 }
 
 /*
index 13ef5e0..b359849 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs_subs.c  7.2 (Berkeley) %G%
+ *     @(#)nfs_subs.c  7.3 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -29,7 +29,7 @@
 #include "types.h"
 #include "param.h"
 #include "mount.h"
 #include "types.h"
 #include "param.h"
 #include "mount.h"
-#include "dir.h"
+#include "../ufs/dir.h"
 #include "time.h"
 #include "errno.h"
 #include "kernel.h"
 #include "time.h"
 #include "errno.h"
 #include "kernel.h"
@@ -95,7 +95,11 @@ struct mbuf *nfsm_reqh(prog, vers, proc, cred, hsiz, bpos, mb, retxid)
 
        NFSMGETHDR(mreq);
        asiz = (((cred->cr_ngroups > 10) ? 10 : cred->cr_ngroups)<<2);
 
        NFSMGETHDR(mreq);
        asiz = (((cred->cr_ngroups > 10) ? 10 : cred->cr_ngroups)<<2);
+#ifdef FILLINHOST
        asiz += nfsm_rndup(hostnamelen)+(9*NFSX_UNSIGNED);
        asiz += nfsm_rndup(hostnamelen)+(9*NFSX_UNSIGNED);
+#else
+       asiz += 9*NFSX_UNSIGNED;
+#endif
 
        /* If we need a lot, alloc a cluster ?? */
        if ((asiz+hsiz+RPC_SIZ) > MHLEN)
 
        /* If we need a lot, alloc a cluster ?? */
        if ((asiz+hsiz+RPC_SIZ) > MHLEN)
@@ -511,17 +515,25 @@ static char *nfs_unixauth(cr)
 
        /* Maybe someday there should be a cache of AUTH_SHORT's */
        if ((p = rpc_uidp) == NULL) {
 
        /* Maybe someday there should be a cache of AUTH_SHORT's */
        if ((p = rpc_uidp) == NULL) {
+#ifdef FILLINHOST
                i = nfsm_rndup(hostnamelen)+(19*NFSX_UNSIGNED);
                i = nfsm_rndup(hostnamelen)+(19*NFSX_UNSIGNED);
+#else
+               i = 19*NFSX_UNSIGNED;
+#endif
                MALLOC(p, u_long *, i, M_TEMP, M_WAITOK);
                bzero((caddr_t)p, i);
                rpc_unixauth = (caddr_t)p;
                *p++ = txdr_unsigned(RPCAUTH_UNIX);
                p++;    /* Fill in size later */
                *p++ = hostid;
                MALLOC(p, u_long *, i, M_TEMP, M_WAITOK);
                bzero((caddr_t)p, i);
                rpc_unixauth = (caddr_t)p;
                *p++ = txdr_unsigned(RPCAUTH_UNIX);
                p++;    /* Fill in size later */
                *p++ = hostid;
+#ifdef FILLINHOST
                *p++ = txdr_unsigned(hostnamelen);
                i = nfsm_rndup(hostnamelen);
                bcopy(hostname, (caddr_t)p, hostnamelen);
                p += (i>>2);
                *p++ = txdr_unsigned(hostnamelen);
                i = nfsm_rndup(hostnamelen);
                bcopy(hostname, (caddr_t)p, hostnamelen);
                p += (i>>2);
+#else
+               *p++ = 0;
+#endif
                rpc_uidp = p;
        }
        *p++ = txdr_unsigned(cr->cr_uid);
                rpc_uidp = p;
        }
        *p++ = txdr_unsigned(cr->cr_uid);
@@ -619,10 +631,6 @@ nfs_getattrcache(vp, vap)
        }
 }
 
        }
 }
 
-#ifndef OPFLAG
-#define        OPFLAG  (CREATE | DELETE | LOOKUP)
-#endif
-
 /*
  * nfs_namei - a liitle like namei(), but for one element only
  *     essentially look up file handle, fill in ndp and call VOP_LOOKUP()
 /*
  * nfs_namei - a liitle like namei(), but for one element only
  *     essentially look up file handle, fill in ndp and call VOP_LOOKUP()
@@ -687,7 +695,7 @@ nfs_namei(ndp, fhp, len, mdp, dposp)
        ndp->ni_namelen = i;
        ndp->ni_dent.d_namlen = i;
        ndp->ni_dent.d_name[i] = '\0';
        ndp->ni_namelen = i;
        ndp->ni_dent.d_namlen = i;
        ndp->ni_dent.d_name[i] = '\0';
-       ndp->ni_pathlen = 0;
+       ndp->ni_pathlen = 1;
        ndp->ni_dirp = ndp->ni_ptr = &ndp->ni_dent.d_name[0];
        ndp->ni_next = &ndp->ni_dent.d_name[i];
        ndp->ni_loopcnt = 0;    /* Not actually used for now */
        ndp->ni_dirp = ndp->ni_ptr = &ndp->ni_dent.d_name[0];
        ndp->ni_next = &ndp->ni_dent.d_name[i];
        ndp->ni_loopcnt = 0;    /* Not actually used for now */
@@ -699,44 +707,25 @@ nfs_namei(ndp, fhp, len, mdp, dposp)
        ndp->ni_isdotdot = (i == 2 && 
                ndp->ni_dent.d_name[1] == '.' && ndp->ni_dent.d_name[0] == '.');
 
        ndp->ni_isdotdot = (i == 2 && 
                ndp->ni_dent.d_name[1] == '.' && ndp->ni_dent.d_name[0] == '.');
 
-       /*
-        * Must remember if this is root so that cr_uid can be set to
-        * mp->m_exroot at mount points
-        * Then call nfsrv_fhtovp() to get the locked directory vnode
-        */
-       if (ndp->ni_cred->cr_uid == 0)
-               rootflg++;
        if (error = nfsrv_fhtovp(fhp, TRUE, &dp, ndp->ni_cred))
                return (error);
        if (error = nfsrv_fhtovp(fhp, TRUE, &dp, ndp->ni_cred))
                return (error);
+       if (dp->v_type != VDIR) {
+               vput(dp);
+               return (ENOTDIR);
+       }
+       ndp->ni_cdir = dp;
+       ndp->ni_rdir = (struct vnode *)0;
 
        /*
 
        /*
-        * Handle "..": two special cases.
-        * 1. If at root directory (e.g. after chroot)
-        *    then ignore it so can't get out.
-        * 2. If this vnode is the root of a mounted
-        *    file system, then replace it with the
-        *    vnode which was mounted on so we take the
-        *    .. in the other file system.
+        * Handle "..":
+        * If this vnode is the root of the mounted
+        *    file system, then ignore it so can't get out
         */
         */
-       if (ndp->ni_isdotdot) {
-               for (;;) {
-                       if (dp == rootdir) {
-                               ndp->ni_dvp = dp;
-                               dp->v_count++;
-                               goto nextname;
-                       }
-                       if ((dp->v_flag & VROOT) == 0)
-                               break;
-                       tdp = dp;
-                       dp = dp->v_mount->m_vnodecovered;
-                       vput(tdp);
-                       if ((dp->v_mount->m_flag & M_EXPORTED) == 0)
-                               return (EACCES);
-                       VOP_LOCK(dp);
-                       dp->v_count++;
-                       if (rootflg)
-                               ndp->ni_cred->cr_uid = dp->v_mount->m_exroot;
-               }
+       if (ndp->ni_isdotdot && (dp->v_flag & VROOT)) {
+               ndp->ni_dvp = dp;
+               ndp->ni_vp = dp;
+               VREF(dp);
+               goto nextname;
        }
 
        /*
        }
 
        /*
@@ -761,77 +750,12 @@ nfs_namei(ndp, fhp, len, mdp, dposp)
                return (0);     /* should this be ENOENT? */
        }
 
                return (0);     /* should this be ENOENT? */
        }
 
-       /*
-        * Check for symbolic link
-        */
        dp = ndp->ni_vp;
        dp = ndp->ni_vp;
-#ifdef notdef
-       if ((dp->v_type == VLNK) &&
-           (ndp->ni_nameiop & FOLLOW)) {
-               struct iovec aiov;
-               struct uio auio;
-               int linklen;
-
-               if (++ndp->ni_loopcnt > MAXSYMLINKS) {
-                       error = ELOOP;
-                       goto bad2;
-               }
-               MALLOC(cp, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
-               aiov.iov_base = cp;
-               aiov.iov_len = MAXPATHLEN;
-               auio.uio_iov = &aiov;
-               auio.uio_iovcnt = 1;
-               auio.uio_offset = 0;
-               auio.uio_rw = UIO_READ;
-               auio.uio_segflg = UIO_SYSSPACE;
-               auio.uio_resid = MAXPATHLEN;
-               if (error = VOP_READLINK(dp, &auio, ndp->ni_cred)) {
-                       free(cp, M_NAMEI);
-                       goto bad2;
-               }
-               linklen = MAXPATHLEN - auio.uio_resid;
-               if (linklen + ndp->ni_pathlen >= MAXPATHLEN) {
-                       free(cp, M_NAMEI);
-                       error = ENAMETOOLONG;
-                       goto bad2;
-               }
-               bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen);
-               ndp->ni_pnbuf = cp;
-               } else
-                       ndp->ni_pnbuf[linklen] = '\0';
-               ndp->ni_ptr = cp;
-               ndp->ni_pathlen += linklen;
-               vput(dp);
-               dp = ndp->ni_dvp;
-               goto start;
-       }
-#endif
-
-       /*
-        * Check to see if the vnode has been mounted on;
-        * if so find the root of the mounted file system.
-        * Ignore NFS mount points
-        */
-mntloop:
-       while (dp->v_type == VDIR && (mp = dp->v_mountedhere) &&
-               mp->m_fsid.val[1] != MOUNT_NFS) {
-               while(mp->m_flag & M_MLOCK) {
-                       mp->m_flag |= M_MWAIT;
-                       sleep((caddr_t)mp, PVFS);
-                       goto mntloop;
-               }
-               error = VFS_ROOT(mp, &tdp);
-               if (error || (mp->m_flag & M_EXPORTED) == 0)
-                       goto bad2;
-               vput(dp);
-               ndp->ni_vp = dp = tdp;
-               if (rootflg)
-                       ndp->ni_cred->cr_uid = mp->m_exroot;
-       }
 
 nextname:
 
 nextname:
+       ndp->ni_ptr = ndp->ni_next;
        /*
        /*
-        * Check for read-only file systems.
+        * Check for read-only file systems
         */
        if (flag == DELETE || flag == RENAME) {
                /*
         */
        if (flag == DELETE || flag == RENAME) {
                /*
@@ -839,22 +763,14 @@ nextname:
                 * file systems.
                 */
                if ((dp->v_mount->m_flag & (M_RDONLY|M_EXRDONLY)) ||
                 * file systems.
                 */
                if ((dp->v_mount->m_flag & (M_RDONLY|M_EXRDONLY)) ||
-                   (wantparent && (ndp->ni_dvp->v_mount->m_flag & M_RDONLY))) {
+                   (wantparent && (ndp->ni_dvp->v_mount->m_flag & (M_RDONLY|M_EXRDONLY)))) {
                        error = EROFS;
                        goto bad2;
                }
        }
 
                        error = EROFS;
                        goto bad2;
                }
        }
 
-       /*
-        * Kludge city... This is hokey, but since ufs_rename() calls
-        * namei() and namei() expects ni_cdir to be set, what can I
-        * do. Fortunately rename() holds onto the parent so I don't
-        * have to increment the v_count.
-        */
        if (!wantparent)
                vrele(ndp->ni_dvp);
        if (!wantparent)
                vrele(ndp->ni_dvp);
-       else
-               ndp->ni_cdir = ndp->ni_dvp;
 
        if ((ndp->ni_nameiop & LOCKLEAF) == 0)
                VOP_UNLOCK(dp);
 
        if ((ndp->ni_nameiop & LOCKLEAF) == 0)
                VOP_UNLOCK(dp);
index 4e09a8b..9ebb800 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs_vfsops.c        7.1 (Berkeley) %G%
+ *     @(#)nfs_vfsops.c        7.2 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -26,7 +26,7 @@
 #include "proc.h"
 #include "uio.h"
 #include "ucred.h"
 #include "proc.h"
 #include "uio.h"
 #include "ucred.h"
-#include "dir.h"
+#include "../ufs/dir.h"
 #include "namei.h"
 #include "vnode.h"
 #include "mount.h"
 #include "namei.h"
 #include "vnode.h"
 #include "mount.h"
@@ -131,7 +131,9 @@ mountnfs(argp, mp, saddr, pth, hst)
 {
        register struct nfsmount *nmp;
        struct nfsnode *np;
 {
        register struct nfsmount *nmp;
        struct nfsnode *np;
+#ifdef notdef
        struct statfs statf, *sbp;
        struct statfs statf, *sbp;
+#endif
        int error;
 
        nmp = (struct nfsmount *)malloc(sizeof (struct nfsmount), M_NFSMNT,
        int error;
 
        nmp = (struct nfsmount *)malloc(sizeof (struct nfsmount), M_NFSMNT,
@@ -170,6 +172,7 @@ mountnfs(argp, mp, saddr, pth, hst)
        bcopy((caddr_t)argp->fh, (caddr_t)&nmp->nm_fh, sizeof(nfsv2fh_t));
        bcopy(pth, nmp->nm_path, MNAMELEN);
        bcopy(hst, nmp->nm_host, MNAMELEN);
        bcopy((caddr_t)argp->fh, (caddr_t)&nmp->nm_fh, sizeof(nfsv2fh_t));
        bcopy(pth, nmp->nm_path, MNAMELEN);
        bcopy(hst, nmp->nm_host, MNAMELEN);
+#ifdef notdef
        sbp = &statf;
        /*
         * Kludge City...
        sbp = &statf;
        /*
         * Kludge City...
@@ -210,6 +213,13 @@ mountnfs(argp, mp, saddr, pth, hst)
                mp->m_bsize = sbp->f_bsize;
        else
                mp->m_bsize = CLBYTES;
                mp->m_bsize = sbp->f_bsize;
        else
                mp->m_bsize = CLBYTES;
+#else
+       /*
+        * Set to CLBYTES so that vinifod() doesn't get confused.
+        * Actually any exact multiple of CLBYTES will do
+        */
+       mp->m_bsize = mp->m_fsize = CLBYTES;
+#endif
        return (0);
 bad:
        m_freem(saddr);
        return (0);
 bad:
        m_freem(saddr);
index a85dfda..45a10b7 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfs_vnops.c 7.1 (Berkeley) %G%
+ *     @(#)nfs_vnops.c 7.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -33,7 +33,7 @@
 #include "mount.h"
 #include "buf.h"
 #include "vm.h"
 #include "mount.h"
 #include "buf.h"
 #include "vm.h"
-#include "dir.h"
+#include "../ufs/dir.h"
 #include "malloc.h"
 #include "mbuf.h"
 #include "uio.h"
 #include "malloc.h"
 #include "mbuf.h"
 #include "uio.h"
@@ -365,7 +365,7 @@ nfs_lookup(vp, ndp)
                 * an explaination of the locking protocol.
                 */
                if (vp == vdp) {
                 * an explaination of the locking protocol.
                 */
                if (vp == vdp) {
-                       vdp->v_count++;
+                       VREF(vdp);
                } else if (ndp->ni_isdotdot) {
                        nfs_unlock(vp);
                        nfs_ngrab(VTONFS(vdp));
                } else if (ndp->ni_isdotdot) {
                        nfs_unlock(vp);
                        nfs_ngrab(VTONFS(vdp));
@@ -377,7 +377,7 @@ nfs_lookup(vp, ndp)
                return (0);
        }
        nfsstats.lookupcache_misses++;
                return (0);
        }
        nfsstats.lookupcache_misses++;
-#endif notyet
+#endif
        nfsstats.rpccnt[NFSPROC_LOOKUP]++;
        len = ndp->ni_namelen;
        nfsm_reqhead(nfs_procids[NFSPROC_LOOKUP], ndp->ni_cred, NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len));
        nfsstats.rpccnt[NFSPROC_LOOKUP]++;
        len = ndp->ni_namelen;
        nfsm_reqhead(nfs_procids[NFSPROC_LOOKUP], ndp->ni_cred, NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len));
@@ -400,7 +400,7 @@ nfsmout:
         */
        if (flag == DELETE && *ndp->ni_next == 0) {
                if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
         */
        if (flag == DELETE && *ndp->ni_next == 0) {
                if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
-                       vp->v_count++;
+                       VREF(vp);
                        newvp = vp;
                        np = VTONFS(vp);
                } else {
                        newvp = vp;
                        np = VTONFS(vp);
                } else {
@@ -414,7 +414,7 @@ nfsmout:
                        if (newvp != vp)
                                nfs_nput(newvp);
                        else
                        if (newvp != vp)
                                nfs_nput(newvp);
                        else
-                               vp->v_count--;
+                               vrele(vp);
                        m_freem(mrep);
                        return (error);
                }
                        m_freem(mrep);
                        return (error);
                }
@@ -437,10 +437,7 @@ nfsmout:
                }
                newvp = NFSTOV(np);
                if (error = nfs_loadattrcache(newvp, &md, &dpos, (struct vattr *)0)) {
                }
                newvp = NFSTOV(np);
                if (error = nfs_loadattrcache(newvp, &md, &dpos, (struct vattr *)0)) {
-                       if (newvp != vp)
-                               nfs_nput(newvp);
-                       else
-                               vp->v_count--;
+                       nfs_nput(newvp);
                        m_freem(mrep);
                        return (error);
                }
                        m_freem(mrep);
                        return (error);
                }
@@ -451,7 +448,7 @@ nfsmout:
        }
 
        if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
        }
 
        if (!bcmp(VTONFS(vp)->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
-               vp->v_count++;
+               VREF(vp);
                newvp = vp;
                np = VTONFS(vp);
        } else if (ndp->ni_isdotdot) {
                newvp = vp;
                np = VTONFS(vp);
        } else if (ndp->ni_isdotdot) {
@@ -474,7 +471,7 @@ nfsmout:
                if (newvp != vp)
                        nfs_nput(newvp);
                else
                if (newvp != vp)
                        nfs_nput(newvp);
                else
-                       vp->v_count--;
+                       vrele(vp);
                m_freem(mrep);
                return (error);
        }
                m_freem(mrep);
                return (error);
        }
@@ -506,7 +503,7 @@ nfsmout:
 #ifdef notyet
        if (error == 0 && ndp->ni_makeentry)
                cache_enter(ndp);
 #ifdef notyet
        if (error == 0 && ndp->ni_makeentry)
                cache_enter(ndp);
-#endif notyet
+#endif
        return (error);
 }
 
        return (error);
 }
 
@@ -681,10 +678,10 @@ nfs_remove(ndp)
                nfsm_reqdone;
        }
        if (ndp->ni_dvp == ndp->ni_vp)
                nfsm_reqdone;
        }
        if (ndp->ni_dvp == ndp->ni_vp)
-               vrele(ndp->ni_dvp);
+               vrele(ndp->ni_vp);
        else
        else
-               nfs_nput(ndp->ni_dvp);
-       nfs_nput(ndp->ni_vp);
+               nfs_nput(ndp->ni_vp);
+       nfs_nput(ndp->ni_dvp);
        return (error);
 }
 
        return (error);
 }
 
@@ -766,6 +763,8 @@ nfs_link(vp, ndp)
 {
        nfsm_vars;
 
 {
        nfsm_vars;
 
+       if (ndp->ni_dvp != vp)
+               nfs_lock(vp);
        nfsstats.rpccnt[NFSPROC_LINK]++;
        nfsm_reqhead(nfs_procids[NFSPROC_LINK], ndp->ni_cred,
                NFSX_FH*2+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen));
        nfsstats.rpccnt[NFSPROC_LINK]++;
        nfsm_reqhead(nfs_procids[NFSPROC_LINK], ndp->ni_cred,
                NFSX_FH*2+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_dent.d_namlen));
@@ -774,6 +773,8 @@ nfs_link(vp, ndp)
        nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN);
        nfsm_request(vp);
        nfsm_reqdone;
        nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN);
        nfsm_request(vp);
        nfsm_reqdone;
+       if (ndp->ni_dvp != vp)
+               nfs_unlock(vp);
        nfs_nput(ndp->ni_dvp);
        return (error);
 }
        nfs_nput(ndp->ni_dvp);
        return (error);
 }
index 6eb8723..45de697 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)nfsm_subs.h 7.1 (Berkeley) %G%
+ *     @(#)nfsm_subs.h 7.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -63,7 +63,7 @@ struct vnode *nfs_fhtovp();
                else \
                        (m)->m_data = (m)->m_dat
 #define        NFSMADV(m, s)   (m)->m_data += (s)
                else \
                        (m)->m_data = (m)->m_dat
 #define        NFSMADV(m, s)   (m)->m_data += (s)
-#define        NFSMSIZ(m)      ((M_HASCL(m))?(MCLBYTES-max_hdr): \
+#define        NFSMSIZ(m)      ((M_HASCL(m))?MCLBYTES: \
                                (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
 #define        NFSMCOPY        m_copym
 #endif
                                (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
 #define        NFSMCOPY        m_copym
 #endif