misc fixes plus diskless support from Rick Macklem
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 5 Mar 1991 14:53:37 +0000 (06:53 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 5 Mar 1991 14:53:37 +0000 (06:53 -0800)
SCCS-vsn: sys/nfs/nfs_vfsops.c 7.25
SCCS-vsn: sys/nfs/nfs_subs.c 7.37
SCCS-vsn: sys/nfs/nfs_syscalls.c 7.23
SCCS-vsn: sys/nfs/nfs_serv.c 7.35
SCCS-vsn: sys/nfs/nfs_vnops.c 7.54
SCCS-vsn: sys/kern/vfs_bio.c 7.33
SCCS-vsn: sys/kern/vfs_cluster.c 7.33
SCCS-vsn: sys/kern/vfs_subr.c 7.51

usr/src/sys/kern/vfs_bio.c
usr/src/sys/kern/vfs_cluster.c
usr/src/sys/kern/vfs_subr.c
usr/src/sys/nfs/nfs_serv.c
usr/src/sys/nfs/nfs_subs.c
usr/src/sys/nfs/nfs_syscalls.c
usr/src/sys/nfs/nfs_vfsops.c
usr/src/sys/nfs/nfs_vnops.c

index 7474206..4b8e9dd 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_bio.c   7.32 (Berkeley) %G%
+ *     @(#)vfs_bio.c   7.33 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -509,6 +509,7 @@ loop:
                crfree(cred);
        }
        bp->b_flags = B_BUSY;
                crfree(cred);
        }
        bp->b_flags = B_BUSY;
+       bp->b_dirtyoff = bp->b_dirtyend = 0;
        return (bp);
 }
 
        return (bp);
 }
 
index 6cb2142..7671e0e 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_cluster.c       7.32 (Berkeley) %G%
+ *     @(#)vfs_cluster.c       7.33 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -509,6 +509,7 @@ loop:
                crfree(cred);
        }
        bp->b_flags = B_BUSY;
                crfree(cred);
        }
        bp->b_flags = B_BUSY;
+       bp->b_dirtyoff = bp->b_dirtyend = 0;
        return (bp);
 }
 
        return (bp);
 }
 
index ae73b2b..bf373ec 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_subr.c  7.50 (Berkeley) %G%
+ *     @(#)vfs_subr.c  7.51 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -311,6 +311,8 @@ bdevvp(dev, vpp)
        struct vnode *nvp;
        int error;
 
        struct vnode *nvp;
        int error;
 
+       if (dev == NODEV)
+               return (0);
        error = getnewvnode(VT_NON, (struct mount *)0, &spec_vnodeops, &nvp);
        if (error) {
                *vpp = 0;
        error = getnewvnode(VT_NON, (struct mount *)0, &spec_vnodeops, &nvp);
        if (error) {
                *vpp = 0;
index bff10e1..76d4655 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_serv.c  7.34 (Berkeley) %G%
+ *     @(#)nfs_serv.c  7.35 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -562,7 +562,7 @@ nfsrv_create(mrep, md, dpos, cred, xid, mrq, repstat)
                        vap->va_type = VREG;
                vap->va_mode = nfstov_mode(*p);
                rdev = fxdr_unsigned(long, *(p+3));
                        vap->va_type = VREG;
                vap->va_mode = nfstov_mode(*p);
                rdev = fxdr_unsigned(long, *(p+3));
-               if (vap->va_type == VREG) {
+               if (vap->va_type == VREG || vap->va_type == VSOCK) {
                        if (error = VOP_CREATE(ndp, vap))
                                nfsm_reply(0);
                } else if (vap->va_type == VCHR || vap->va_type == VBLK ||
                        if (error = VOP_CREATE(ndp, vap))
                                nfsm_reply(0);
                } else if (vap->va_type == VCHR || vap->va_type == VBLK ||
index d987bc1..ec13b8b 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_subs.c  7.36 (Berkeley) %G%
+ *     @(#)nfs_subs.c  7.37 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -27,6 +27,8 @@
 #include "mbuf.h"
 #include "errno.h"
 #include "map.h"
 #include "mbuf.h"
 #include "errno.h"
 #include "map.h"
+#include "../ufs/quota.h"
+#include "../ufs/inode.h"
 #include "rpcv2.h"
 #include "nfsv2.h"
 #include "nfsnode.h"
 #include "rpcv2.h"
 #include "nfsv2.h"
 #include "nfsnode.h"
@@ -586,6 +588,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
        int error = 0;
        struct mbuf *md;
        enum vtype type;
        int error = 0;
        struct mbuf *md;
        enum vtype type;
+       u_short mode;
        long rdev;
        struct timeval mtime;
        struct vnode *nvp;
        long rdev;
        struct timeval mtime;
        struct vnode *nvp;
@@ -597,6 +600,9 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
                return (error);
        fp = (struct nfsv2_fattr *)cp2;
        type = nfstov_type(fp->fa_type);
                return (error);
        fp = (struct nfsv2_fattr *)cp2;
        type = nfstov_type(fp->fa_type);
+       mode = fxdr_unsigned(u_short, fp->fa_mode);
+       if (type == VNON)
+               type = IFTOVT(mode);
        rdev = fxdr_unsigned(long, fp->fa_rdev);
        fxdr_time(&fp->fa_mtime, &mtime);
        /*
        rdev = fxdr_unsigned(long, fp->fa_rdev);
        fxdr_time(&fp->fa_mtime, &mtime);
        /*
@@ -646,7 +652,7 @@ nfs_loadattrcache(vpp, mdp, dposp, vaper)
        }
        vap = &np->n_vattr;
        vap->va_type = type;
        }
        vap = &np->n_vattr;
        vap->va_type = type;
-       vap->va_mode = nfstov_mode(fp->fa_mode);
+       vap->va_mode = (mode & 07777);
        vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
        vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
        vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
        vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
        vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
        vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
index 5f29ab9..0ef0db5 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_syscalls.c      7.22 (Berkeley) %G%
+ *     @(#)nfs_syscalls.c      7.23 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -37,7 +37,7 @@
 extern u_long nfs_prog, nfs_vers;
 extern int (*nfsrv_procs[NFS_NPROCS])();
 extern struct buf nfs_bqueue;
 extern u_long nfs_prog, nfs_vers;
 extern int (*nfsrv_procs[NFS_NPROCS])();
 extern struct buf nfs_bqueue;
-extern int nfs_asyncdaemons;
+extern int nfs_numasync;
 extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
 extern int nfs_tcpnodelay;
 struct mbuf *nfs_compress();
 extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
 extern int nfs_tcpnodelay;
 struct mbuf *nfs_compress();
@@ -45,6 +45,7 @@ struct mbuf *nfs_compress();
 #define        TRUE    1
 #define        FALSE   0
 
 #define        TRUE    1
 #define        FALSE   0
 
+static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
 static int compressreply[NFS_NPROCS] = {
        FALSE,
        TRUE,
 static int compressreply[NFS_NPROCS] = {
        FALSE,
        TRUE,
@@ -286,8 +287,8 @@ async_daemon(p, uap, retval)
        int *retval;
 {
        register struct buf *bp, *dp;
        int *retval;
 {
        register struct buf *bp, *dp;
+       register int i, myiod;
        int error;
        int error;
-       int myiod;
 
        /*
         * Must be super user
 
        /*
         * Must be super user
@@ -297,28 +298,42 @@ async_daemon(p, uap, retval)
        /*
         * Assign my position or return error if too many already running
         */
        /*
         * Assign my position or return error if too many already running
         */
-       if (nfs_asyncdaemons > NFS_MAXASYNCDAEMON)
+       myiod = -1;
+       for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
+               if (nfs_asyncdaemon[i] == 0) {
+                       nfs_asyncdaemon[i]++;
+                       myiod = i;
+                       break;
+               }
+       if (myiod == -1)
                return (EBUSY);
                return (EBUSY);
-       myiod = nfs_asyncdaemons++;
+       nfs_numasync++;
        dp = &nfs_bqueue;
        /*
         * Just loop around doin our stuff until SIGKILL
         */
        for (;;) {
        dp = &nfs_bqueue;
        /*
         * Just loop around doin our stuff until SIGKILL
         */
        for (;;) {
-               while (dp->b_actf == NULL) {
-                       nfs_iodwant[myiod] = p;
-                       if (error = tsleep((caddr_t)&nfs_iodwant[myiod],
-                               PWAIT | PCATCH, "nfsidl", 0))
-                               return (error);
+               while (dp->b_actf == NULL && error == 0) {
+                       nfs_iodwant[myiod] = u.u_procp;
+                       error = tsleep((caddr_t)&nfs_iodwant[myiod],
+                               PWAIT | PCATCH, "nfsidl", 0);
+                       nfs_iodwant[myiod] = (struct proc *)0;
+               }
+               while (dp->b_actf != NULL) {
+                       /* Take one off the end of the list */
+                       bp = dp->b_actl;
+                       if (bp->b_actl == dp) {
+                               dp->b_actf = dp->b_actl = (struct buf *)0;
+                       } else {
+                               dp->b_actl = bp->b_actl;
+                               bp->b_actl->b_actf = dp;
+                       }
+                       (void) nfs_doio(bp);
                }
                }
-               /* Take one off the end of the list */
-               bp = dp->b_actl;
-               if (bp->b_actl == dp) {
-                       dp->b_actf = dp->b_actl = (struct buf *)0;
-               } else {
-                       dp->b_actl = bp->b_actl;
-                       bp->b_actl->b_actf = dp;
+               if (error) {
+                       nfs_asyncdaemon[myiod] = 0;
+                       nfs_numasync--;
+                       return (error);
                }
                }
-               (void) nfs_doio(bp);
        }
 }
        }
 }
index d7b7beb..9649856 100644 (file)
@@ -7,10 +7,12 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_vfsops.c        7.24 (Berkeley) %G%
+ *     @(#)nfs_vfsops.c        7.25 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
+#include "conf.h"
+#include "ioctl.h"
 #include "signal.h"
 #include "user.h"
 #include "proc.h"
 #include "signal.h"
 #include "user.h"
 #include "proc.h"
 #include "mbuf.h"
 #include "socket.h"
 #include "systm.h"
 #include "mbuf.h"
 #include "socket.h"
 #include "systm.h"
+#include "../net/if.h"
+#include "../net/route.h"
+#include "../netinet/in.h"
 #include "nfsv2.h"
 #include "nfsnode.h"
 #include "nfsmount.h"
 #include "nfs.h"
 #include "xdr_subs.h"
 #include "nfsm_subs.h"
 #include "nfsv2.h"
 #include "nfsnode.h"
 #include "nfsmount.h"
 #include "nfs.h"
 #include "xdr_subs.h"
 #include "nfsm_subs.h"
+#include "nfsdiskless.h"
 
 /*
  * nfs vfs operations.
 
 /*
  * nfs vfs operations.
@@ -58,6 +64,7 @@ struct vfsops nfs_vfsops = {
 static u_char nfs_mntid;
 extern u_long nfs_procids[NFS_NPROCS];
 extern u_long nfs_prog, nfs_vers;
 static u_char nfs_mntid;
 extern u_long nfs_procids[NFS_NPROCS];
 extern u_long nfs_prog, nfs_vers;
+struct nfs_diskless nfs_diskless;
 void nfs_disconnect();
 
 #define TRUE   1
 void nfs_disconnect();
 
 #define TRUE   1
@@ -113,12 +120,131 @@ nfs_statfs(mp, sbp)
 }
 
 /*
 }
 
 /*
- * Called by vfs_mountroot when nfs is going to be mounted as root
- * Not Yet (By a LONG shot)
+ * Mount a remote root fs via. nfs. This depends on the info in the
+ * nfs_diskless structure that has been filled in properly by some primary
+ * bootstrap.
+ * It goes something like this:
+ * - do enough of "ifconfig" by calling ifioctl() so that the system
+ *   can talk to the server
+ * - If nfs_diskless.mygateway is filled in, use that address as
+ *   a default gateway.
+ *   (This is done the 4.3 way with rtioctl() and should be changed)
+ * - hand craft the swap nfs vnode hanging off a fake mount point
+ * - build the rootfs mount point and call mountnfs() to do the rest.
  */
 nfs_mountroot()
 {
  */
 nfs_mountroot()
 {
-       return (ENODEV);
+       register struct mount *mp;
+       register struct mbuf *m;
+       struct socket *so;
+       struct vnode *vp;
+       int error;
+
+       /*
+        * Do enough of ifconfig(8) so that critical net interface can
+        * talk to the server.
+        */
+       if (socreate(nfs_diskless.myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0))
+               panic("nfs ifconf");
+       if (ifioctl(so, SIOCAIFADDR, &nfs_diskless.myif))
+               panic("nfs ifconf2");
+       soclose(so);
+
+       /*
+        * If the gateway field is filled in, set it as the default route.
+        */
+#ifdef COMPAT_43
+       if (nfs_diskless.mygateway.sa_family == AF_INET) {
+               struct ortentry rt;
+               struct sockaddr_in *sin;
+
+               sin = (struct sockaddr_in *) &rt.rt_dst;
+               sin->sin_len = sizeof (struct sockaddr_in);
+               sin->sin_family = AF_INET;
+               sin->sin_addr.s_addr = 0;       /* default */
+               bcopy((caddr_t)&nfs_diskless.mygateway, (caddr_t)&rt.rt_gateway,
+                       sizeof (struct sockaddr_in));
+               rt.rt_flags = (RTF_UP | RTF_GATEWAY);
+               if (rtioctl(SIOCADDRT, (caddr_t)&rt))
+                       panic("nfs root route");
+       }
+#endif /* COMPAT_43 */
+
+       /*
+        * If swapping to an nfs node (indicated by swdevt[0].sw_dev == NODEV):
+        * Create a fake mount point just for the swap vnode so that the
+        * swap file can be on a different server from the rootfs.
+        */
+       if (swdevt[0].sw_dev == NODEV) {
+               mp = (struct mount *)malloc((u_long)sizeof(struct mount),
+                       M_MOUNT, M_NOWAIT);
+               if (mp == NULL)
+                       panic("nfs root mount");
+               mp->mnt_op = &nfs_vfsops;
+               mp->mnt_flag = 0;
+               mp->mnt_exroot = 0;
+               mp->mnt_mounth = NULLVP;
+       
+               /*
+                * Set up the diskless nfs_args for the swap mount point
+                * and then call mountnfs() to mount it.
+                * Since the swap file is not the root dir of a file system,
+                * hack it to a regular file.
+                */
+               nfs_diskless.swap_args.fh = (nfsv2fh_t *)nfs_diskless.swap_fh;
+               MGET(m, MT_SONAME, M_DONTWAIT);
+               if (m == NULL)
+                       panic("nfs root mbuf");
+               bcopy((caddr_t)&nfs_diskless.swap_saddr, mtod(m, caddr_t),
+                       nfs_diskless.swap_saddr.sa_len);
+               m->m_len = nfs_diskless.swap_saddr.sa_len;
+               if (mountnfs(&nfs_diskless.swap_args, mp, m, "/swap",
+                       nfs_diskless.swap_hostnam, &vp))
+                       panic("nfs swap");
+               vp->v_type = VREG;
+               vp->v_flag = 0;
+               swapdev_vp = vp;
+               VREF(vp);
+               swdevt[0].sw_vp = vp;
+               VREF(vp);
+               argdev_vp = vp;
+       }
+
+       /*
+        * Create the rootfs mount point.
+        */
+       mp = (struct mount *)malloc((u_long)sizeof(struct mount),
+               M_MOUNT, M_NOWAIT);
+       if (mp == NULL)
+               panic("nfs root mount2");
+       mp->mnt_op = &nfs_vfsops;
+       mp->mnt_flag = MNT_RDONLY;
+       mp->mnt_exroot = 0;
+       mp->mnt_mounth = NULLVP;
+
+       /*
+        * Set up the root fs args and call mountnfs() to do the rest.
+        */
+       nfs_diskless.root_args.fh = (nfsv2fh_t *)nfs_diskless.root_fh;
+       MGET(m, MT_SONAME, M_DONTWAIT);
+       if (m == NULL)
+               panic("nfs root mbuf2");
+       bcopy((caddr_t)&nfs_diskless.root_saddr, mtod(m, caddr_t),
+               nfs_diskless.root_saddr.sa_len);
+       m->m_len = nfs_diskless.root_saddr.sa_len;
+       if (mountnfs(&nfs_diskless.root_args, mp, m, "/",
+               nfs_diskless.root_hostnam, &vp))
+               panic("nfs root");
+       if (vfs_lock(mp))
+               panic("nfs root2");
+       rootfs = mp;
+       mp->mnt_next = mp;
+       mp->mnt_prev = mp;
+       mp->mnt_vnodecovered = NULLVP;
+       vfs_unlock(mp);
+       rootvp = vp;
+       inittodr((time_t)0);    /* There is no time in the nfs fsstat so ?? */
+       return (0);
 }
 
 /*
 }
 
 /*
@@ -140,6 +266,7 @@ nfs_mount(mp, path, data, ndp)
        int error;
        struct nfs_args args;
        struct mbuf *nam;
        int error;
        struct nfs_args args;
        struct mbuf *nam;
+       struct vnode *vp;
        char pth[MNAMELEN], hst[MNAMELEN];
        int len;
        nfsv2fh_t nfh;
        char pth[MNAMELEN], hst[MNAMELEN];
        int len;
        nfsv2fh_t nfh;
@@ -161,18 +288,19 @@ nfs_mount(mp, path, data, ndp)
                sizeof (struct sockaddr), MT_SONAME))
                return (error);
        args.fh = &nfh;
                sizeof (struct sockaddr), MT_SONAME))
                return (error);
        args.fh = &nfh;
-       error = mountnfs(&args, mp, nam, pth, hst);
+       error = mountnfs(&args, mp, nam, pth, hst, &vp);
        return (error);
 }
 
 /*
  * Common code for mount and mountroot
  */
        return (error);
 }
 
 /*
  * Common code for mount and mountroot
  */
-mountnfs(argp, mp, nam, pth, hst)
+mountnfs(argp, mp, nam, pth, hst, vpp)
        register struct nfs_args *argp;
        register struct mount *mp;
        struct mbuf *nam;
        char *pth, *hst;
        register struct nfs_args *argp;
        register struct mount *mp;
        struct mbuf *nam;
        char *pth, *hst;
+       struct vnode **vpp;
 {
        register struct nfsmount *nmp;
        struct nfsnode *np;
 {
        register struct nfsmount *nmp;
        struct nfsnode *np;
@@ -202,7 +330,7 @@ mountnfs(argp, mp, nam, pth, hst)
                ++nfs_mntid;
        tfsid.val[0] = makedev(nblkdev, nfs_mntid);
        tfsid.val[1] = MOUNT_NFS;
                ++nfs_mntid;
        tfsid.val[0] = makedev(nblkdev, nfs_mntid);
        tfsid.val[1] = MOUNT_NFS;
-       while (getvfs(&tfsid)) {
+       while (rootfs && getvfs(&tfsid)) {
                tfsid.val[0]++;
                nfs_mntid++;
        }
                tfsid.val[0]++;
                nfs_mntid++;
        }
@@ -287,6 +415,7 @@ mountnfs(argp, mp, nam, pth, hst)
         * Unlock it, but keep the reference count.
         */
        nfs_unlock(NFSTOV(np));
         * Unlock it, but keep the reference count.
         */
        nfs_unlock(NFSTOV(np));
+       *vpp = NFSTOV(np);
 
        return (0);
 bad:
 
        return (0);
 bad:
index 96e4b33..5ffcbd1 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_vnops.c 7.53 (Berkeley) %G%
+ *     @(#)nfs_vnops.c 7.54 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -216,8 +216,8 @@ extern u_long nfs_prog, nfs_vers;
 extern char nfsiobuf[MAXPHYS+NBPG];
 struct map nfsmap[NFS_MSIZ];
 struct buf nfs_bqueue;         /* Queue head for nfsiod's */
 extern char nfsiobuf[MAXPHYS+NBPG];
 struct map nfsmap[NFS_MSIZ];
 struct buf nfs_bqueue;         /* Queue head for nfsiod's */
-int nfs_asyncdaemons = 0;
 struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
 struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
+int nfs_numasync = 0;
 static int nfsmap_want = 0;
 
 /*
 static int nfsmap_want = 0;
 
 /*
@@ -406,7 +406,10 @@ nfs_setattr(vp, vap, cred)
                np = VTONFS(vp);
                if (np->n_flag & NMODIFIED) {
                        np->n_flag &= ~NMODIFIED;
                np = VTONFS(vp);
                if (np->n_flag & NMODIFIED) {
                        np->n_flag &= ~NMODIFIED;
-                       vinvalbuf(vp, TRUE);
+                       if (vap->va_size == 0)
+                               vinvalbuf(vp, FALSE);
+                       else
+                               vinvalbuf(vp, TRUE);
                        np->n_attrstamp = 0;
                }
        }
                        np->n_attrstamp = 0;
                }
        }
@@ -651,14 +654,12 @@ nfs_readlinkrpc(vp, uiop, cred, procp)
        long len;
 
        nfsstats.rpccnt[NFSPROC_READLINK]++;
        long len;
 
        nfsstats.rpccnt[NFSPROC_READLINK]++;
-       nfs_unlock(vp);
        nfsm_reqhead(nfs_procids[NFSPROC_READLINK], cred, NFSX_FH);
        nfsm_fhtom(vp);
        nfsm_request(vp, NFSPROC_READLINK, procp, 0);
        nfsm_strsiz(len, NFS_MAXPATHLEN);
        nfsm_mtouio(uiop, len);
        nfsm_reqdone;
        nfsm_reqhead(nfs_procids[NFSPROC_READLINK], cred, NFSX_FH);
        nfsm_fhtom(vp);
        nfsm_request(vp, NFSPROC_READLINK, procp, 0);
        nfsm_strsiz(len, NFS_MAXPATHLEN);
        nfsm_mtouio(uiop, len);
        nfsm_reqdone;
-       nfs_lock(vp);
        return (error);
 }
 
        return (error);
 }
 
@@ -821,7 +822,7 @@ nfs_create(ndp, vap)
        nfsm_fhtom(ndp->ni_dvp);
        nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        nfsm_fhtom(ndp->ni_dvp);
        nfsm_strtom(ndp->ni_dent.d_name, ndp->ni_dent.d_namlen, NFS_MAXNAMLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
-       sp->sa_mode = vtonfs_mode(VREG, vap->va_mode);
+       sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
        sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
        sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
        sp->sa_size = txdr_unsigned(0);
        sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
        sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
        sp->sa_size = txdr_unsigned(0);
@@ -1488,7 +1489,6 @@ nfs_strategy(bp)
 {
        register struct buf *dp;
        register int i;
 {
        register struct buf *dp;
        register int i;
-       struct proc *rp;
        int error = 0;
        int fnd = 0;
 
        int error = 0;
        int fnd = 0;
 
@@ -1498,27 +1498,21 @@ nfs_strategy(bp)
         * Set b_proc == NULL for asynchronous ops, since these may still
         * be hanging about after the process terminates.
         */
         * Set b_proc == NULL for asynchronous ops, since these may still
         * be hanging about after the process terminates.
         */
-       if (bp->b_flags & B_ASYNC)
-               bp->b_proc = (struct proc *)0;
-       else
-               bp->b_proc = u.u_procp;
-
+       if ((bp->b_flags & B_PHYS) == 0) {
+               if (bp->b_flags & B_ASYNC)
+                       bp->b_proc = (struct proc *)0;
+               else
+                       bp->b_proc = u.u_procp;
+       }
        /*
         * If the op is asynchronous and an i/o daemon is waiting
         * queue the request, wake it up and wait for completion
         * otherwise just do it ourselves.
         */
        /*
         * If the op is asynchronous and an i/o daemon is waiting
         * queue the request, wake it up and wait for completion
         * otherwise just do it ourselves.
         */
-       if (bp->b_proc == (struct proc *)NULL)
-           for (i = 0; i < nfs_asyncdaemons; i++) {
-               if (rp = nfs_iodwant[i]) {
-                       /*
-                        * Ensure that the async_daemon is still waiting here
-                        */
-                       if (rp->p_stat != SSLEEP ||
-                           rp->p_wchan != ((caddr_t)&nfs_iodwant[i])) {
-                               nfs_iodwant[i] = (struct proc *)0;
-                               continue;
-                       }
+       if ((bp->b_flags & B_ASYNC) == 0 || nfs_numasync == 0)
+               return (nfs_doio(bp));
+       for (i = 0; i < NFS_MAXASYNCDAEMON; i++) {
+               if (nfs_iodwant[i]) {
                        dp = &nfs_bqueue;
                        if (dp->b_actf == NULL) {
                                dp->b_actl = bp;
                        dp = &nfs_bqueue;
                        if (dp->b_actf == NULL) {
                                dp->b_actl = bp;
@@ -1530,7 +1524,6 @@ nfs_strategy(bp)
                        dp->b_actf = bp;
                        bp->b_actl = dp;
                        fnd++;
                        dp->b_actf = bp;
                        bp->b_actl = dp;
                        fnd++;
-                       nfs_iodwant[i] = (struct proc *)0;
                        wakeup((caddr_t)&nfs_iodwant[i]);
                        break;
                }
                        wakeup((caddr_t)&nfs_iodwant[i]);
                        break;
                }
@@ -1584,7 +1577,7 @@ nfs_doio(bp)
         */
        if (bp->b_flags & B_PHYS) {
                rp = (bp->b_flags & B_DIRTY) ? pageproc : bp->b_proc;
         */
        if (bp->b_flags & B_PHYS) {
                rp = (bp->b_flags & B_DIRTY) ? pageproc : bp->b_proc;
-               bp->b_rcred = cr = crcopy(rp->p_ucred);
+               cr = crcopy(rp->p_ucred);
 #if defined(hp300) || defined(i386)
                /* mapping was already done by vmapbuf */
                io.iov_base = bp->b_un.b_addr;
 #if defined(hp300) || defined(i386)
                /* mapping was already done by vmapbuf */
                io.iov_base = bp->b_un.b_addr;
@@ -1637,14 +1630,12 @@ nfs_doio(bp)
                if (bp->b_flags & B_READ) {
                        uiop->uio_rw = UIO_READ;
                        nfsstats.read_physios++;
                if (bp->b_flags & B_READ) {
                        uiop->uio_rw = UIO_READ;
                        nfsstats.read_physios++;
-                       bp->b_error = error = nfs_readrpc(vp, uiop,
-                               bp->b_rcred, bp->b_proc);
+                       bp->b_error = error = nfs_readrpc(vp, uiop, cr, rp);
                        (void) vnode_pager_uncache(vp);
                } else {
                        uiop->uio_rw = UIO_WRITE;
                        nfsstats.write_physios++;
                        (void) vnode_pager_uncache(vp);
                } else {
                        uiop->uio_rw = UIO_WRITE;
                        nfsstats.write_physios++;
-                       bp->b_error = error = nfs_writerpc(vp, uiop,
-                               bp->b_wcred, bp->b_proc);
+                       bp->b_error = error = nfs_writerpc(vp, uiop, cr, rp);
                }
 
                /*
                }
 
                /*