diff options
-rw-r--r-- | sys/nfs/nfs_serv.c | 879 | ||||
-rw-r--r-- | sys/nfs/nfs_socket.c | 106 | ||||
-rw-r--r-- | sys/nfs/nfs_subs.c | 21 | ||||
-rw-r--r-- | sys/nfs/nfs_var.h | 9 | ||||
-rw-r--r-- | sys/nfs/nfs_vfsops.c | 48 | ||||
-rw-r--r-- | sys/nfs/nfs_vnops.c | 587 | ||||
-rw-r--r-- | sys/nfs/nfsm_subs.h | 110 |
7 files changed, 985 insertions, 775 deletions
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 54fdd986716..251c6a2c561 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_serv.c,v 1.77 2009/07/20 16:49:40 thib Exp $ */ +/* $OpenBSD: nfs_serv.c,v 1.78 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ /* @@ -104,9 +104,8 @@ nfsrv3_access(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; + struct nfsm_info info; struct ucred *cred = &nfsd->nd_cr; struct vnode *vp; nfsfh_t nfh; @@ -115,18 +114,23 @@ nfsrv3_access(nfsd, slp, procp, mrq) int32_t t1; int error = 0, rdonly, getret; char *cp2; - struct mbuf *mb, *mreq; struct vattr va; u_long testmode, nfsmode; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, 1, NULL, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, 1, NULL, &info.nmi_mb); + error = 0; + goto nfsmout; } nfsmode = fxdr_unsigned(u_int32_t, *tl); if ((nfsmode & NFSV3ACCESS_READ) && @@ -150,10 +154,11 @@ nfsrv3_access(nfsd, slp, procp, mrq) getret = VOP_GETATTR(vp, &va, cred, procp); vput(vp); nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &va, &mb); - tl = nfsm_build(&mb, NFSX_UNSIGNED); + nfsm_srvpostop_attr(nfsd, getret, &va, &info.nmi_mb); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); *tl = txdr_unsigned(nfsmode); nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -167,9 +172,8 @@ nfsrv_getattr(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; + struct nfsm_info info; struct ucred *cred = &nfsd->nd_cr; struct nfs_fattr *fp; struct vattr va; @@ -180,23 +184,32 @@ nfsrv_getattr(nfsd, slp, procp, mrq) int32_t t1; int error = 0, rdonly; char *cp2; - struct mbuf *mb, *mreq; + + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(0); - return (0); + error = 0; + goto nfsmout; } error = VOP_GETATTR(vp, &va, cred, procp); vput(vp); nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); - if (error) - return (0); - fp = nfsm_build(&mb, NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); + if (error) { + error = 0; + goto nfsmout; + } + fp = nfsm_build(&info.nmi_mb, NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); nfsm_srvfattr(nfsd, &va, fp); nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -210,9 +223,8 @@ nfsrv_setattr(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; + struct nfsm_info info; struct ucred *cred = &nfsd->nd_cr; struct vattr va, preat; struct nfsv2_sattr *sp; @@ -223,17 +235,22 @@ nfsrv_setattr(nfsd, slp, procp, mrq) u_int32_t *tl; int32_t t1; int error = 0, rdonly, preat_ret = 1, postat_ret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3), gcheck = 0; + int gcheck = 0; char *cp2; - struct mbuf *mb, *mreq; struct timespec guard; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); VATTR_NULL(&va); - if (v3) { + if (info.nmi_v3) { va.va_vaflags |= VA_UTIMES_NULL; - error = nfsm_srvsattr(&md, &va, mrep, &dpos); + error = nfsm_srvsattr(&info.nmi_md, &va, info.nmi_mrep, &info.nmi_dpos); if (error) goto nfsmout; nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); @@ -279,10 +296,11 @@ nfsrv_setattr(nfsd, slp, procp, mrq) error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); - nfsm_srvwcc(nfsd, preat_ret, &preat, postat_ret, &va, &mb); - return (0); + nfsm_srvwcc(nfsd, preat_ret, &preat, postat_ret, &va, &info.nmi_mb); + error = 0; + goto nfsmout; } - if (v3) { + if (info.nmi_v3) { error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); if (!error && gcheck && (preat.va_ctime.tv_sec != guard.tv_sec || @@ -290,10 +308,11 @@ nfsrv_setattr(nfsd, slp, procp, mrq) error = NFSERR_NOT_SYNC; if (error) { vput(vp); - nfsm_reply(NFSX_WCCDATA(v3)); + nfsm_reply(NFSX_WCCDATA(info.nmi_v3)); nfsm_srvwcc(nfsd, preat_ret, &preat, postat_ret, &va, - &mb); - return (0); + &info.nmi_mb); + error = 0; + goto nfsmout; } } @@ -320,15 +339,18 @@ nfsrv_setattr(nfsd, slp, procp, mrq) error = postat_ret; out: vput(vp); - nfsm_reply(NFSX_WCCORFATTR(v3)); - if (v3) { - nfsm_srvwcc(nfsd, preat_ret, &preat, postat_ret, &va, &mb); - return (0); + nfsm_reply(NFSX_WCCORFATTR(info.nmi_v3)); + if (info.nmi_v3) { + nfsm_srvwcc(nfsd, preat_ret, &preat, postat_ret, &va, + &info.nmi_mb); + error = 0; + goto nfsmout; } else { - fp = nfsm_build(&mb, NFSX_V2FATTR); + fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -342,13 +364,12 @@ nfsrv_lookup(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct nfs_fattr *fp; struct nameidata nd; struct vnode *vp, *dirp; + struct nfsm_info info; nfsfh_t nfh; fhandle_t *fhp; u_int32_t *tl; @@ -356,26 +377,32 @@ nfsrv_lookup(nfsd, slp, procp, mrq) int error = 0, len, dirattr_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct vattr va, dirattr; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_mreq = NULL; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, procp); vrele(dirp); } if (error) { - nfsm_reply(NFSX_POSTOPATTR(v3)); - nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &mb); - return (0); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3)); + nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &info.nmi_mb); + error = 0; + goto nfsmout; } vrele(nd.ni_startdir); pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); @@ -386,20 +413,23 @@ nfsrv_lookup(nfsd, slp, procp, mrq) if (!error) error = VOP_GETATTR(vp, &va, cred, procp); vput(vp); - nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); + nfsm_reply(NFSX_SRVFH(info.nmi_v3) + NFSX_POSTOPORFATTR(info.nmi_v3) + + NFSX_POSTOPATTR(info.nmi_v3)); if (error) { - nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &info.nmi_mb); + error = 0; + goto nfsmout; } - nfsm_srvfhtom(&mb, fhp, v3); + nfsm_srvfhtom(&info.nmi_mb, fhp, info.nmi_v3); if (v3) { - nfsm_srvpostop_attr(nfsd, 0, &va, &mb); - nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &mb); + nfsm_srvpostop_attr(nfsd, 0, &va, &info.nmi_mb); + nfsm_srvpostop_attr(nfsd, dirattr_ret, &dirattr, &info.nmi_mb); } else { - fp = nfsm_build(&mb, NFSX_V2FATTR); + fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -413,25 +443,29 @@ nfsrv_readlink(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct iovec iv[(NFS_MAXPATHLEN+MLEN-1)/MLEN]; struct iovec *ivp = iv; struct mbuf *mp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int error = 0, rdonly, i, tlen, len, getret; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq; + struct mbuf *mp2 = NULL, *mp3 = NULL; struct vnode *vp; struct vattr attr; nfsfh_t nfh; fhandle_t *fhp; struct uio io, *uiop = &io; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); len = 0; @@ -467,11 +501,12 @@ nfsrv_readlink(nfsd, slp, procp, mrq) if (error) { m_freem(mp3); nfsm_reply(2 * NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, 1, NULL, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, 1, NULL, &info.nmi_mb); + error = 0; + goto nfsmout; } if (vp->v_type != VLNK) { - if (v3) + if (info.nmi_v3) error = EINVAL; else error = ENXIO; @@ -483,21 +518,25 @@ out: vput(vp); if (error) m_freem(mp3); - nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED); - if (v3) { - nfsm_srvpostop_attr(nfsd, getret, &attr, &mb); - if (error) - return (0); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3) + NFSX_UNSIGNED); + if (info.nmi_v3) { + nfsm_srvpostop_attr(nfsd, getret, &attr, &info.nmi_mb); + if (error) { + error = 0; + goto nfsmout; + } } if (uiop->uio_resid > 0) { len -= uiop->uio_resid; tlen = nfsm_rndup(len); nfsm_adj(mp3, NFS_MAXPATHLEN-tlen, tlen-len); } - tl = nfsm_build(&mb, NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); *tl = txdr_unsigned(len); - mb->m_next = mp3; + info.nmi_mb->m_next = mp3; + nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -511,21 +550,18 @@ nfsrv_read(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct iovec *iv; struct iovec *iv2; struct mbuf *m; struct nfs_fattr *fp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - int i; + int i, reqlen; int error = 0, rdonly, cnt, len, left, siz, tlen, getret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3), reqlen; char *cp2; - struct mbuf *mb, *mreq; struct mbuf *m2; struct vnode *vp; nfsfh_t nfh; @@ -534,9 +570,15 @@ nfsrv_read(nfsd, slp, procp, mrq) struct vattr va; off_t off; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); off = fxdr_hyper(tl); } else { @@ -556,7 +598,7 @@ nfsrv_read(nfsd, slp, procp, mrq) goto bad; if (vp->v_type != VREG) { - if (v3) + if (info.nmi_v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; @@ -577,14 +619,14 @@ nfsrv_read(nfsd, slp, procp, mrq) cnt = va.va_size - off; else cnt = reqlen; - nfsm_reply(NFSX_POSTOPORFATTR(v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt)); - if (v3) { - tl = nfsm_build(&mb, NFSX_V3FATTR + 4 * NFSX_UNSIGNED); + nfsm_reply(NFSX_POSTOPORFATTR(info.nmi_v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt)); + if (info.nmi_v3) { + tl = nfsm_build(&info.nmi_mb, NFSX_V3FATTR + 4 * NFSX_UNSIGNED); *tl++ = nfs_true; fp = (struct nfs_fattr *)tl; tl += (NFSX_V3FATTR / sizeof (u_int32_t)); } else { - tl = nfsm_build(&mb, NFSX_V2FATTR + NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, NFSX_V2FATTR + NFSX_UNSIGNED); fp = (struct nfs_fattr *)tl; tl += (NFSX_V2FATTR / sizeof (u_int32_t)); } @@ -594,7 +636,7 @@ nfsrv_read(nfsd, slp, procp, mrq) * Generate the mbuf list with the uio_iov ref. to it. */ i = 0; - m = m2 = mb; + m = m2 = info.nmi_mb; while (left > 0) { siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { @@ -612,7 +654,7 @@ nfsrv_read(nfsd, slp, procp, mrq) } iv = malloc(i * sizeof(struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv2 = iv; - m = mb; + m = info.nmi_mb; left = len; i = 0; while (left > 0) { @@ -640,7 +682,7 @@ nfsrv_read(nfsd, slp, procp, mrq) if (error || (getret = VOP_GETATTR(vp, &va, cred, procp)) != 0){ if (!error) error = getret; - m_freem(mreq); + m_freem(info.nmi_mreq); goto vbad; } } else @@ -651,8 +693,8 @@ nfsrv_read(nfsd, slp, procp, mrq) cnt = cnt < tlen ? cnt : tlen; tlen = nfsm_rndup (cnt); if (len != tlen || tlen != cnt) - nfsm_adj(mb, len - tlen, tlen - cnt); - if (v3) { + nfsm_adj(info.nmi_mb, len - tlen, tlen - cnt); + if (info.nmi_v3) { *tl++ = txdr_unsigned(cnt); if (len < reqlen) *tl++ = nfs_true; @@ -661,13 +703,15 @@ nfsrv_read(nfsd, slp, procp, mrq) } *tl = txdr_unsigned(cnt); nfsmout: + *mrq = info.nmi_mreq; return(error); vbad: vput(vp); bad: nfsm_reply(0); - nfsm_srvpostop_attr(nfsd, getret, &va, &mb); + nfsm_srvpostop_attr(nfsd, getret, &va, &info.nmi_mb); + *mrq = info.nmi_mreq; return (0); } @@ -681,11 +725,10 @@ nfsrv_write(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct iovec *ivp; + struct nfsm_info info; int i, cnt; struct mbuf *mp; struct nfs_fattr *fp; @@ -696,22 +739,26 @@ nfsrv_write(nfsd, slp, procp, mrq) int error = 0, rdonly, len, forat_ret = 1; int ioflags, aftat_ret = 1, retlen, zeroing, adjust; int stable = NFSV3WRITE_FILESYNC; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp; nfsfh_t nfh; fhandle_t *fhp; struct uio io, *uiop = &io; off_t off; - if (mrep == NULL) { + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + + if (info.nmi_mrep == NULL) { *mrq = NULL; return (0); } fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); off = fxdr_hyper(tl); tl += 3; @@ -731,11 +778,11 @@ nfsrv_write(nfsd, slp, procp, mrq) */ if (len > 0) { zeroing = 1; - mp = mrep; + mp = info.nmi_mrep; while (mp) { - if (mp == md) { + if (mp == info.nmi_md) { zeroing = 0; - adjust = dpos - mtod(mp, caddr_t); + adjust = info.nmi_dpos - mtod(mp, caddr_t); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) mp->m_data += adjust; @@ -761,10 +808,10 @@ nfsrv_write(nfsd, slp, procp, mrq) error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) goto bad; - if (v3) + if (info.nmi_v3) forat_ret = VOP_GETATTR(vp, &forat, cred, procp); if (vp->v_type != VREG) { - if (v3) + if (info.nmi_v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; @@ -778,7 +825,7 @@ nfsrv_write(nfsd, slp, procp, mrq) ivp = malloc(cnt * sizeof(struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv = ivp; uiop->uio_iovcnt = cnt; - mp = mrep; + mp = info.nmi_mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, caddr_t); @@ -807,13 +854,15 @@ nfsrv_write(nfsd, slp, procp, mrq) vput(vp); if (!error) error = aftat_ret; - nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + - 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3)); - if (v3) { - nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb); - if (error) - return (0); - tl = nfsm_build(&mb, 4 * NFSX_UNSIGNED); + nfsm_reply(NFSX_PREOPATTR(info.nmi_v3) + NFSX_POSTOPORFATTR(info.nmi_v3) + + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(info.nmi_v3)); + if (info.nmi_v3) { + nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &info.nmi_mb); + if (error) { + error = 0; + goto nfsmout; + } + tl = nfsm_build(&info.nmi_mb, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(retlen); if (stable == NFSV3WRITE_UNSTABLE) *tl++ = txdr_unsigned(stable); @@ -827,17 +876,19 @@ nfsrv_write(nfsd, slp, procp, mrq) *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { - fp = nfsm_build(&mb, NFSX_V2FATTR); + fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } nfsmout: + *mrq = info.nmi_mreq; return(error); vbad: vput(vp); bad: nfsm_reply(0); - nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb); + nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &info.nmi_mb); + *mrq = info.nmi_mreq; return (0); } @@ -859,6 +910,7 @@ nfsrv_writegather(ndp, slp, procp, mrq) struct mbuf *mp; struct nfsrv_descript *wp, *nfsd, *nnfsd, *owp, *swp; struct nfs_fattr *fp; + struct nfsm_info info; int i = 0; struct iovec *iov; struct nfsrvw_delayhash *wpp; @@ -866,11 +918,9 @@ nfsrv_writegather(ndp, slp, procp, mrq) struct vattr va, forat; u_int32_t *tl; int32_t t1; - caddr_t dpos; int error = 0, rdonly, len = 0, forat_ret = 1; - int ioflags, aftat_ret = 1, s, adjust, v3, zeroing; + int ioflags, aftat_ret = 1, s, adjust, zeroing; char *cp2; - struct mbuf *mb, *mreq, *mrep, *md; struct vnode *vp; struct uio io, *uiop = &io; struct timeval tv; @@ -879,11 +929,12 @@ nfsrv_writegather(ndp, slp, procp, mrq) if (*ndp) { nfsd = *ndp; *ndp = NULL; - mrep = nfsd->nd_mrep; - md = nfsd->nd_md; - dpos = nfsd->nd_dpos; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; cred = &nfsd->nd_cr; - v3 = (nfsd->nd_flag & ND_NFSV3); + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); LIST_INIT(&nfsd->nd_coalesce); nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; @@ -894,7 +945,7 @@ nfsrv_writegather(ndp, slp, procp, mrq) * Now, get the write header.. */ nfsm_srvmtofh(&nfsd->nd_fh); - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); nfsd->nd_off = fxdr_hyper(tl); tl += 3; @@ -914,11 +965,11 @@ nfsrv_writegather(ndp, slp, procp, mrq) */ zeroing = 1; i = 0; - mp = mrep; + mp = info.nmi_mrep; while (mp) { - if (mp == md) { + if (mp == info.nmi_md) { zeroing = 0; - adjust = dpos - mtod(mp, caddr_t); + adjust = info.nmi_dpos - mtod(mp, caddr_t); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) mp->m_data += adjust; @@ -935,13 +986,14 @@ nfsrv_writegather(ndp, slp, procp, mrq) mp = mp->m_next; } if (len > NFS_MAXDATA || len < 0 || i < len) { - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: error = EIO; - nfsm_writereply(2 * NFSX_UNSIGNED, v3); - if (v3) - nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, &mb); - nfsd->nd_mreq = mreq; + nfsm_writereply(2 * NFSX_UNSIGNED, info.nmi_v3); + if (info.nmi_v3) + nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, &va, + &info.nmi_mb); + nfsd->nd_mreq = info.nmi_mreq; nfsd->nd_mrep = NULL; timerclear(&nfsd->nd_time); } @@ -1010,18 +1062,18 @@ loop1: LIST_REMOVE(nfsd, nd_tq); LIST_REMOVE(nfsd, nd_hash); splx(s); - mrep = nfsd->nd_mrep; + info.nmi_mrep = nfsd->nd_mrep; nfsd->nd_mrep = NULL; cred = &nfsd->nd_cr; - v3 = (nfsd->nd_flag & ND_NFSV3); + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); forat_ret = aftat_ret = 1; error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, nfsd->nd_nam, &rdonly); if (!error) { - if (v3) + if (info.nmi_v3) forat_ret = VOP_GETATTR(vp, &forat, cred, procp); if (vp->v_type != VREG) { - if (v3) + if (info.nmi_v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; @@ -1044,7 +1096,7 @@ loop1: uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; if (uiop->uio_resid > 0) { - mp = mrep; + mp = info.nmi_mrep; i = 0; while (mp) { if (mp->m_len > 0) @@ -1054,7 +1106,7 @@ loop1: uiop->uio_iovcnt = i; iov = malloc(i * sizeof(struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = ivp = iov; - mp = mrep; + mp = info.nmi_mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, caddr_t); @@ -1069,7 +1121,7 @@ loop1: } free(iov, M_TEMP); } - m_freem(mrep); + m_freem(info.nmi_mrep); if (vp) { aftat_ret = VOP_GETATTR(vp, &va, cred, procp); vput(vp); @@ -1082,19 +1134,19 @@ loop1: swp = nfsd; do { if (error) { - nfsm_writereply(NFSX_WCCDATA(v3), v3); - if (v3) { + nfsm_writereply(NFSX_WCCDATA(info.nmi_v3), info.nmi_v3); + if (info.nmi_v3) { nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, - &va, &mb); + &va, &info.nmi_mb); } } else { - nfsm_writereply(NFSX_PREOPATTR(v3) + - NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + - NFSX_WRITEVERF(v3), v3); - if (v3) { + nfsm_writereply(NFSX_PREOPATTR(info.nmi_v3) + + NFSX_POSTOPORFATTR(info.nmi_v3) + 2 * NFSX_UNSIGNED + + NFSX_WRITEVERF(info.nmi_v3), info.nmi_v3); + if (info.nmi_v3) { nfsm_srvwcc(nfsd, forat_ret, &forat, aftat_ret, - &va, &mb); - tl = nfsm_build(&mb, 4 * NFSX_UNSIGNED); + &va, &info.nmi_mb); + tl = nfsm_build(&info.nmi_mb, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(nfsd->nd_len); *tl++ = txdr_unsigned(swp->nd_stable); /* @@ -1105,11 +1157,11 @@ loop1: *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { - fp = nfsm_build(&mb, NFSX_V2FATTR); + fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } } - nfsd->nd_mreq = mreq; + nfsd->nd_mreq = info.nmi_mreq; if (nfsd->nd_mrep) panic("nfsrv_write: nd_mrep not free"); @@ -1150,6 +1202,7 @@ loop1: } } splx(s); + *mrq = info.nmi_mreq; return (0); } @@ -1217,28 +1270,32 @@ nfsrv_create(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct nfs_fattr *fp; struct vattr va, dirfor, diraft; struct nfsv2_sattr *sp; + struct nfsm_info info; u_int32_t *tl; struct nameidata nd; caddr_t cp; int32_t t1; int error = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; dev_t rdev = 0; - int v3 = (nfsd->nd_flag & ND_NFSV3), how, exclusive_flag = 0; + int how, exclusive_flag = 0; char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp = NULL, *dirp = NULL; nfsfh_t nfh; fhandle_t *fhp; u_quad_t tempsize; u_char cverf[NFSX_V3CREATEVERF]; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + nd.ni_cnd.cn_nameiop = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -1246,9 +1303,10 @@ nfsrv_create(nfsd, slp, procp, mrq) nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, + &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { @@ -1257,15 +1315,16 @@ nfsrv_create(nfsd, slp, procp, mrq) } } if (error) { - nfsm_reply(NFSX_WCCDATA(v3)); + nfsm_reply(NFSX_WCCDATA(info.nmi_v3)); nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); if (dirp) vrele(dirp); - return (0); + error = 0; + goto nfsmout; } VATTR_NULL(&va); - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); how = fxdr_unsigned(int, *tl); switch (how) { @@ -1275,7 +1334,8 @@ nfsrv_create(nfsd, slp, procp, mrq) break; } case NFSV3CREATE_UNCHECKED: - error = nfsm_srvsattr(&md, &va, mrep, &dpos); + error = nfsm_srvsattr(&info.nmi_md, &va, info.nmi_mrep, + &info.nmi_dpos); if (error) goto nfsmout; break; @@ -1341,7 +1401,8 @@ nfsrv_create(nfsd, slp, procp, mrq) VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); nfsm_reply(0); - return (0); + error = 0; + goto nfsmout; } else va.va_rdev = (dev_t)rdev; error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, @@ -1350,7 +1411,8 @@ nfsrv_create(nfsd, slp, procp, mrq) vrele(nd.ni_startdir); pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); nfsm_reply(0); - return (0); + error = 0; + goto nfsmout; } nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART); @@ -1359,7 +1421,8 @@ nfsrv_create(nfsd, slp, procp, mrq) if ((error = lookup(&nd)) != 0) { pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); nfsm_reply(0); - return (0); + error = 0; + goto nfsmout; } pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); @@ -1369,7 +1432,8 @@ nfsrv_create(nfsd, slp, procp, mrq) VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); error = EINVAL; nfsm_reply(0); - return (0); + error = 0; + goto nfsmout; } } else { vrele(nd.ni_startdir); @@ -1410,28 +1474,31 @@ nfsrv_create(nfsd, slp, procp, mrq) error = VOP_GETATTR(vp, &va, cred, procp); vput(vp); } - if (v3) { + if (info.nmi_v3) { if (exclusive_flag && !error && bcmp(cverf, (caddr_t)&va.va_atime, NFSX_V3CREATEVERF)) error = EEXIST; diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } - nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); - if (v3) { + nfsm_reply(NFSX_SRVFH(info.nmi_v3) + NFSX_FATTR(info.nmi_v3) + + NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { if (!error) { nfsm_srvpostop_fh(fhp); - nfsm_srvpostop_attr(nfsd, 0, &va, &mb); + nfsm_srvpostop_attr(nfsd, 0, &va, &info.nmi_mb); } nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); } else { - nfsm_srvfhtom(&mb, fhp, v3); - fp = nfsm_build(&mb, NFSX_V2FATTR); + nfsm_srvfhtom(&info.nmi_mb, fhp, info.nmi_v3); + fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } + *mrq = info.nmi_mreq; return (0); nfsmout: + *mrq = info.nmi_mreq; if (dirp) vrele(dirp); if (nd.ni_cnd.cn_nameiop) { @@ -1458,11 +1525,10 @@ nfsrv_mknod(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; + struct nfsm_info info; u_int32_t *tl; struct nameidata nd; int32_t t1; @@ -1470,11 +1536,16 @@ nfsrv_mknod(nfsd, slp, procp, mrq) u_int32_t major, minor; enum vtype vtyp; char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp, *dirp = NULL; nfsfh_t nfh; fhandle_t *fhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + nd.ni_cnd.cn_nameiop = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -1482,16 +1553,17 @@ nfsrv_mknod(nfsd, slp, procp, mrq) nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, &info.nmi_dpos, &dirp, procp); if (dirp) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); if (dirp) vrele(dirp); - return (0); + error = 0; + goto nfsmout; } nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); vtyp = nfsv3tov_type(*tl); @@ -1504,7 +1576,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq) goto out; } VATTR_NULL(&va); - error = nfsm_srvsattr(&md, &va, mrep, &dpos); + error = nfsm_srvsattr(&info.nmi_md, &va, info.nmi_mrep, &info.nmi_dpos); if (error) goto nfsmout; if (vtyp == VCHR || vtyp == VBLK) { @@ -1575,11 +1647,13 @@ out: nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); if (!error) { nfsm_srvpostop_fh(fhp); - nfsm_srvpostop_attr(nfsd, 0, &va, &mb); + nfsm_srvpostop_attr(nfsd, 0, &va, &info.nmi_mb); } - nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, &mb); + nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, &info.nmi_mb); + *mrq = info.nmi_mreq; return (0); nfsmout: + *mrq = info.nmi_mreq; if (dirp) vrele(dirp); if (nd.ni_cnd.cn_nameiop) { @@ -1606,22 +1680,25 @@ nfsrv_remove(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct nameidata nd; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int error = 0, len, dirfor_ret = 1, diraft_ret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp, *dirp; struct vattr dirfor, diraft; nfsfh_t nfh; fhandle_t *fhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + vp = NULL; fhp = &nfh.fh_generic; @@ -1630,9 +1707,9 @@ nfsrv_remove(nfsd, slp, procp, mrq) nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else @@ -1664,17 +1741,19 @@ out: vput(vp); } } - if (dirp && v3) { + if (dirp && info.nmi_v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } - nfsm_reply(NFSX_WCCDATA(v3)); - if (v3) { + nfsm_reply(NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); - return (0); + &info.nmi_mb); + error = 0; + goto nfsmout; } nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -1688,17 +1767,14 @@ nfsrv_rename(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int error = 0, len, len2, fdirfor_ret = 1, fdiraft_ret = 1; int tdirfor_ret = 1, tdiraft_ret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct nameidata fromnd, tond; struct vnode *fvp = NULL, *tvp, *tdvp, *fdirp = NULL; struct vnode *tdirp = NULL; @@ -1707,12 +1783,19 @@ nfsrv_rename(nfsd, slp, procp, mrq) fhandle_t *ffhp, *tfhp; uid_t saved_uid; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + ffhp = &fnfh.fh_generic; tfhp = &tnfh.fh_generic; fromnd.ni_cnd.cn_nameiop = 0; tond.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(ffhp); nfsm_srvnamesiz(len); + /* * Remember our original uid so that we can reset cr_uid before * the second nfs_namei() call, in case it is remapped. @@ -1721,9 +1804,10 @@ nfsrv_rename(nfsd, slp, procp, mrq) fromnd.ni_cnd.cn_cred = cred; fromnd.ni_cnd.cn_nameiop = DELETE; fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART; - error = nfs_namei(&fromnd, ffhp, len, slp, nam, &md, &dpos, &fdirp, procp); + error = nfs_namei(&fromnd, ffhp, len, slp, nam, &info.nmi_md, + &info.nmi_dpos, &fdirp, procp); if (fdirp) { - if (v3) + if (info.nmi_v3) fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, procp); else { @@ -1732,14 +1816,15 @@ nfsrv_rename(nfsd, slp, procp, mrq) } } if (error) { - nfsm_reply(2 * NFSX_WCCDATA(v3)); + nfsm_reply(2 * NFSX_WCCDATA(info.nmi_v3)); nfsm_srvwcc(nfsd, fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft, - &mb); + &info.nmi_mb); nfsm_srvwcc(nfsd, tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft, - &mb); + &info.nmi_mb); if (fdirp) vrele(fdirp); - return (0); + error = 0; + goto nfsmout; } fvp = fromnd.ni_vp; nfsm_srvmtofh(tfhp); @@ -1748,9 +1833,10 @@ nfsrv_rename(nfsd, slp, procp, mrq) tond.ni_cnd.cn_cred = cred; tond.ni_cnd.cn_nameiop = RENAME; tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; - error = nfs_namei(&tond, tfhp, len2, slp, nam, &md, &dpos, &tdirp, procp); + error = nfs_namei(&tond, tfhp, len2, slp, nam, &info.nmi_md, + &info.nmi_dpos, &tdirp, procp); if (tdirp) { - if (v3) + if (info.nmi_v3) tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, procp); else { @@ -1768,27 +1854,27 @@ nfsrv_rename(nfsd, slp, procp, mrq) tvp = tond.ni_vp; if (tvp != NULL) { if (fvp->v_type == VDIR && tvp->v_type != VDIR) { - error = v3 ? EEXIST : EISDIR; + error = info.nmi_v3 ? EEXIST : EISDIR; goto out; } else if (fvp->v_type != VDIR && tvp->v_type == VDIR) { - error = v3 ? EEXIST : ENOTDIR; + error = info.nmi_v3 ? EEXIST : ENOTDIR; goto out; } if (tvp->v_type == VDIR && tvp->v_mountedhere) { - error = v3 ? EXDEV : ENOTEMPTY; + error = info.nmi_v3 ? EXDEV : ENOTEMPTY; goto out; } } if (fvp->v_type == VDIR && fvp->v_mountedhere) { - error = v3 ? EXDEV : ENOTEMPTY; + error = info.nmi_v3 ? EXDEV : ENOTEMPTY; goto out; } if (fvp->v_mount != tdvp->v_mount) { - error = v3 ? EXDEV : ENOTEMPTY; + error = info.nmi_v3 ? EXDEV : ENOTEMPTY; goto out; } if (fvp == tdvp) - error = v3 ? EINVAL : ENOTEMPTY; + error = info.nmi_v3 ? EINVAL : ENOTEMPTY; /* * If source is the same as the destination (that is the * same vnode with the same name in the same directory), @@ -1830,16 +1916,18 @@ out1: } vrele(fromnd.ni_startdir); pool_put(&namei_pool, fromnd.ni_cnd.cn_pnbuf); - nfsm_reply(2 * NFSX_WCCDATA(v3)); - if (v3) { + nfsm_reply(2 * NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { nfsm_srvwcc(nfsd, fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft, - &mb); + &info.nmi_mb); nfsm_srvwcc(nfsd, tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft, - &mb); + &info.nmi_mb); } + *mrq = info.nmi_mreq; return (0); nfsmout: + *mrq = info.nmi_mreq; if (fdirp) vrele(fdirp); if (tdirp) @@ -1868,43 +1956,51 @@ nfsrv_link(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; + struct nfsm_info info; struct ucred *cred = &nfsd->nd_cr; struct nameidata nd; u_int32_t *tl; int32_t t1; int error = 0, rdonly, len, dirfor_ret = 1, diraft_ret = 1; - int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3); + int getret = 1; char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp, *xp, *dirp = NULL; struct vattr dirfor, diraft, at; nfsfh_t nfh, dnfh; fhandle_t *fhp, *dfhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; dfhp = &dnfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_srvmtofh(dfhp); nfsm_srvnamesiz(len); + error = nfsrv_fhtovp(fhp, 0, &vp, cred, slp, nam, &rdonly); if (error) { - nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3) + + NFSX_WCCDATA(info.nmi_v3)); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); - return (0); + &info.nmi_mb); + error = 0; + goto nfsmout; } if (vp->v_type == VDIR && (error = suser_ucred(cred)) != 0) goto out1; nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; - error = nfs_namei(&nd, dfhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, dfhp, len, slp, nam, &info.nmi_md, + &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { @@ -1935,21 +2031,22 @@ out: vrele(nd.ni_vp); } out1: - if (v3) + if (info.nmi_v3) getret = VOP_GETATTR(vp, &at, cred, procp); if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } vrele(vp); - nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); - if (v3) { - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3) + NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); - return (0); + &info.nmi_mb); + error = 0; } nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -1963,12 +2060,11 @@ nfsrv_symlink(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nameidata nd; + struct nfsm_info info; u_int32_t *tl; int32_t t1; struct nfsv2_sattr *sp; @@ -1976,22 +2072,28 @@ nfsrv_symlink(nfsd, slp, procp, mrq) struct uio io; struct iovec iv; int error = 0, len, len2, dirfor_ret = 1, diraft_ret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3); - struct mbuf *mb, *mreq; struct vnode *dirp = NULL; nfsfh_t nfh; fhandle_t *fhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + nd.ni_cnd.cn_nameiop = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_srvnamesiz(len); + nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, + &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { @@ -2002,8 +2104,9 @@ nfsrv_symlink(nfsd, slp, procp, mrq) if (error) goto out; VATTR_NULL(&va); - if (v3) - error = nfsm_srvsattr(&md, &va, mrep, &dpos); + if (info.nmi_v3) + error = nfsm_srvsattr(&info.nmi_md, &va, info.nmi_mrep, + &info.nmi_dpos); if (error) goto nfsmout; nfsm_strsiz(len2, NFS_MAXPATHLEN); @@ -2018,7 +2121,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) io.uio_rw = UIO_READ; io.uio_procp = NULL; nfsm_mtouio(&io, len2); - if (!v3) { + if (!info.nmi_v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); va.va_mode = fxdr_unsigned(u_int16_t, sp->sa_mode); } @@ -2039,7 +2142,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq) if (error) vrele(nd.ni_startdir); else { - if (v3) { + if (info.nmi_v3) { nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART | FOLLOW); nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF); @@ -2066,17 +2169,20 @@ out: diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } - nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); - if (v3) { + nfsm_reply(NFSX_SRVFH(info.nmi_v3) + NFSX_POSTOPATTR(info.nmi_v3) + + NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { if (!error) { nfsm_srvpostop_fh(fhp); - nfsm_srvpostop_attr(nfsd, 0, &va, &mb); + nfsm_srvpostop_attr(nfsd, 0, &va, &info.nmi_mb); } nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); } + *mrq = info.nmi_mreq; return (0); nfsmout: + *mrq = info.nmi_mreq; if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); pool_put(&namei_pool, nd.ni_cnd.cn_pnbuf); @@ -2105,32 +2211,37 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nfs_fattr *fp; struct nameidata nd; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int error = 0, len, dirfor_ret = 1, diraft_ret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp, *dirp = NULL; nfsfh_t nfh; fhandle_t *fhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_srvnamesiz(len); + nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, + &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { @@ -2139,16 +2250,18 @@ nfsrv_mkdir(nfsd, slp, procp, mrq) } } if (error) { - nfsm_reply(NFSX_WCCDATA(v3)); + nfsm_reply(NFSX_WCCDATA(info.nmi_v3)); nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); if (dirp) vrele(dirp); - return (0); + error = 0; + goto nfsmout; } VATTR_NULL(&va); - if (v3) { - error = nfsm_srvsattr(&md, &va, mrep, &dpos); + if (info.nmi_v3) { + error = nfsm_srvsattr(&info.nmi_md, &va, info.nmi_mrep, + &info.nmi_dpos); if (error) goto nfsmout; } else { @@ -2182,21 +2295,24 @@ out: diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } - nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); - if (v3) { + nfsm_reply(NFSX_SRVFH(info.nmi_v3) + NFSX_POSTOPATTR(info.nmi_v3) + + NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { if (!error) { nfsm_srvpostop_fh(fhp); - nfsm_srvpostop_attr(nfsd, 0, &va, &mb); + nfsm_srvpostop_attr(nfsd, 0, &va, &info.nmi_mb); } nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); } else { - nfsm_srvfhtom(&mb, fhp, v3); - fp = nfsm_build(&mb, NFSX_V2FATTR); + nfsm_srvfhtom(&info.nmi_mb, fhp, info.nmi_v3); + fp = nfsm_build(&info.nmi_mb, NFSX_V2FATTR); nfsm_srvfattr(nfsd, &va, fp); } + *mrq = info.nmi_mreq; return (0); nfsmout: + *mrq = info.nmi_mreq; if (dirp) vrele(dirp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); @@ -2219,31 +2335,35 @@ nfsrv_rmdir(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int error = 0, len, dirfor_ret = 1, diraft_ret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp, *dirp = NULL; struct vattr dirfor, diraft; nfsfh_t nfh; fhandle_t *fhp; struct nameidata nd; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; - error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp); + error = nfs_namei(&nd, fhp, len, slp, nam, &info.nmi_md, + &info.nmi_dpos, &dirp, procp); if (dirp) { - if (v3) + if (info.nmi_v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { @@ -2252,12 +2372,13 @@ nfsrv_rmdir(nfsd, slp, procp, mrq) } } if (error) { - nfsm_reply(NFSX_WCCDATA(v3)); + nfsm_reply(NFSX_WCCDATA(info.nmi_v3)); nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); + &info.nmi_mb); if (dirp) vrele(dirp); - return (0); + error = 0; + goto nfsmout; } vp = nd.ni_vp; if (vp->v_type != VDIR) { @@ -2291,13 +2412,14 @@ out: diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } - nfsm_reply(NFSX_WCCDATA(v3)); - if (v3) { + nfsm_reply(NFSX_WCCDATA(info.nmi_v3)); + if (info.nmi_v3) { nfsm_srvwcc(nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft, - &mb); - return (0); + &info.nmi_mb); + error = 0; } nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -2344,14 +2466,12 @@ nfsrv_readdir(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct dirent *dp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - struct mbuf *mb, *mreq; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp; struct vattr at; @@ -2361,13 +2481,18 @@ nfsrv_readdir(nfsd, slp, procp, mrq) struct iovec iv; int len, nlen, pad, xfer, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, ncookies; - int v3 = (nfsd->nd_flag & ND_NFSV3); u_quad_t off, toff, verf; u_long *cookies = NULL, *cookiep; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; @@ -2381,8 +2506,9 @@ nfsrv_readdir(nfsd, slp, procp, mrq) error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } error = getret = VOP_GETATTR(vp, &at, cred, procp); @@ -2390,9 +2516,10 @@ nfsrv_readdir(nfsd, slp, procp, mrq) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); if (error) { vput(vp); - nfsm_reply(NFSX_POSTOPATTR(v3)); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3)); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } off = toff; @@ -2429,7 +2556,7 @@ again: off = (off_t)io.uio_offset; if (!cookies && !error) error = NFSERR_PERM; - if (v3) { + if (info.nmi_v3) { getret = VOP_GETATTR(vp, &at, cred, procp); if (!error) error = getret; @@ -2441,9 +2568,10 @@ again: free((caddr_t)rbuf, M_TEMP); if (cookies) free((caddr_t)cookies, M_TEMP); - nfsm_reply(NFSX_POSTOPATTR(v3)); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3)); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } if (io.uio_resid) { siz -= io.uio_resid; @@ -2454,20 +2582,21 @@ again: */ if (siz == 0) { vrele(vp); - nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3) + NFSX_COOKIEVERF(info.nmi_v3) + 2 * NFSX_UNSIGNED); - if (v3) { - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - tl = nfsm_build(&mb, 4 * NFSX_UNSIGNED); + if (info.nmi_v3) { + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + tl = nfsm_build(&info.nmi_mb, 4 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); tl += 2; } else - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); *tl++ = nfs_false; *tl = nfs_true; free(rbuf, M_TEMP); free(cookies, M_TEMP); - return (0); + error = 0; + goto nfsmout; } } @@ -2493,10 +2622,10 @@ again: } len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */ - nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + siz); - if (v3) { - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3) + NFSX_COOKIEVERF(info.nmi_v3) + siz); + if (info.nmi_v3) { + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); } @@ -2506,7 +2635,7 @@ again: nlen = dp->d_namlen; pad = nfsm_padlen(nlen); len += (4 * NFSX_UNSIGNED + nlen + pad); - if (v3) + if (info.nmi_v3) len += 2 * NFSX_UNSIGNED; if (len > cnt) { eofflag = 0; @@ -2516,23 +2645,23 @@ again: * Build the directory record xdr from * the dirent entry. */ - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); *tl++ = nfs_true; - if (v3) { + if (info.nmi_v3) { *tl = 0; - tl = nfsm_build(&mb, NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); } *tl = txdr_unsigned(dp->d_fileno); /* And copy the name */ - nfsm_strtombuf(&mb, dp->d_name, nlen); + nfsm_strtombuf(&info.nmi_mb, dp->d_name, nlen); /* Finish off the record */ - if (v3) { - tl = nfsm_build(&mb, NFSX_UNSIGNED); + if (info.nmi_v3) { + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); *tl = 0; } - tl = nfsm_build(&mb, NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); *tl = txdr_unsigned(*cookiep); } cpos += dp->d_reclen; @@ -2541,7 +2670,7 @@ again: ncookies--; } vrele(vp); - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); *tl++ = nfs_false; if (eofflag) *tl = nfs_true; @@ -2550,6 +2679,7 @@ again: free(rbuf, M_TEMP); free(cookies, M_TEMP); nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -2560,14 +2690,12 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct dirent *dp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - struct mbuf *mb, *mreq; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp, *nvp; struct flrep fl; @@ -2582,6 +2710,12 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) u_quad_t off, toff, verf; u_long *cookies = NULL, *cookiep; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); @@ -2593,8 +2727,9 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } error = getret = VOP_GETATTR(vp, &at, cred, procp); @@ -2603,8 +2738,9 @@ nfsrv_readdirplus(nfsd, slp, procp, mrq) if (error) { vput(vp); nfsm_reply(NFSX_V3POSTOPATTR); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } siz = fxdr_unsigned(int, *tl++); @@ -2654,8 +2790,9 @@ again: free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); nfsm_reply(NFSX_V3POSTOPATTR); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } if (io.uio_resid) { siz -= io.uio_resid; @@ -2668,15 +2805,16 @@ again: vrele(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - tl = nfsm_build(&mb, 4 * NFSX_UNSIGNED); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + tl = nfsm_build(&info.nmi_mb, 4 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); tl += 2; *tl++ = nfs_false; *tl = nfs_true; free(cookies, M_TEMP); free(rbuf, M_TEMP); - return (0); + error = 0; + goto nfsmout; } } @@ -2715,8 +2853,8 @@ again: */ dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED; nfsm_reply(cnt); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); /* Loop through the records and build reply */ @@ -2769,13 +2907,13 @@ again: break; } - tl = nfsm_build(&mb, 3 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 3 * NFSX_UNSIGNED); *tl++ = nfs_true; *tl++ = 0; *tl = txdr_unsigned(dp->d_fileno); /* And copy the name */ - nfsm_strtombuf(&mb, dp->d_name, nlen); + nfsm_strtombuf(&info.nmi_mb, dp->d_name, nlen); /* * Build the directory record xdr from @@ -2790,7 +2928,7 @@ again: fl.fl_off.nfsuquad[1] = txdr_unsigned(*cookiep); /* Now copy the flrep structure out. */ - nfsm_buftombuf(&mb, &fl, sizeof(struct flrep)); + nfsm_buftombuf(&info.nmi_mb, &fl, sizeof(struct flrep)); } invalid: cpos += dp->d_reclen; @@ -2799,7 +2937,7 @@ invalid: ncookies--; } vrele(vp); - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); *tl++ = nfs_false; if (eofflag) *tl = nfs_true; @@ -2808,6 +2946,7 @@ invalid: free(cookies, M_TEMP); free(rbuf, M_TEMP); nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -2821,20 +2960,24 @@ nfsrv_commit(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr bfor, aft; struct vnode *vp; + struct nfsm_info info; nfsfh_t nfh; fhandle_t *fhp; u_int32_t *tl; int32_t t1; int error = 0, rdonly, for_ret = 1, aft_ret = 1, cnt; char *cp2; - struct mbuf *mb, *mreq; u_quad_t off; + + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -2850,22 +2993,25 @@ nfsrv_commit(nfsd, slp, procp, mrq) error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); - nfsm_srvwcc(nfsd, for_ret, &bfor, aft_ret, &aft, &mb); - return (0); + nfsm_srvwcc(nfsd, for_ret, &bfor, aft_ret, &aft, + &info.nmi_mb); + error = 0; + goto nfsmout; } for_ret = VOP_GETATTR(vp, &bfor, cred, procp); error = VOP_FSYNC(vp, cred, MNT_WAIT, procp); aft_ret = VOP_GETATTR(vp, &aft, cred, procp); vput(vp); nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF); - nfsm_srvwcc(nfsd, for_ret, &bfor, aft_ret, &aft, &mb); + nfsm_srvwcc(nfsd, for_ret, &bfor, aft_ret, &aft, &info.nmi_mb); if (!error) { - tl = nfsm_build(&mb, NFSX_V3WRITEVERF); + tl = nfsm_build(&info.nmi_mb, NFSX_V3WRITEVERF); *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else - return (0); + error = 0; nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -2879,18 +3025,15 @@ nfsrv_statfs(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct statfs *sf; struct nfs_statfs *sfp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int error = 0, rdonly, getret = 1; - int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp; struct vattr at; nfsfh_t nfh; @@ -2898,25 +3041,34 @@ nfsrv_statfs(nfsd, slp, procp, mrq) struct statfs statfs; u_quad_t tval; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } sf = &statfs; error = VFS_STATFS(vp->v_mount, sf, procp); getret = VOP_GETATTR(vp, &at, cred, procp); vput(vp); - nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3)); - if (v3) - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - if (error) - return (0); - sfp = nfsm_build(&mb, NFSX_STATFS(v3)); - if (v3) { + nfsm_reply(NFSX_POSTOPATTR(info.nmi_v3) + NFSX_STATFS(info.nmi_v3)); + if (info.nmi_v3) + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + if (error) { + error = 0; + goto nfsmout; + } + sfp = nfsm_build(&info.nmi_mb, NFSX_STATFS(info.nmi_v3)); + if (info.nmi_v3) { tval = (u_quad_t)sf->f_blocks; tval *= (u_quad_t)sf->f_bsize; txdr_hyper(tval, &sfp->sf_tbytes); @@ -2940,6 +3092,7 @@ nfsrv_statfs(nfsd, slp, procp, mrq) sfp->sf_bavail = txdr_unsigned(sf->f_bavail); } nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -2953,34 +3106,39 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; + struct nfsm_info info; u_int32_t *tl; struct nfsv3_fsinfo *sip; int32_t t1; int error = 0, rdonly, getret = 1, pref; char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp; struct vattr at; nfsfh_t nfh; fhandle_t *fhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } getret = VOP_GETATTR(vp, &at, cred, procp); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - sip = nfsm_build(&mb, NFSX_V3FSINFO); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + sip = nfsm_build(&info.nmi_mb, NFSX_V3FSINFO); /* * XXX @@ -3006,6 +3164,7 @@ nfsrv_fsinfo(nfsd, slp, procp, mrq) NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS | NFSV3FSINFO_CANSETTIME); nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -3019,29 +3178,34 @@ nfsrv_pathconf(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; - caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; + struct nfsm_info info; u_int32_t *tl; struct nfsv3_pathconf *pc; int32_t t1; int error = 0, rdonly, getret = 1; register_t linkmax, namemax, chownres, notrunc; char *cp2; - struct mbuf *mb, *mreq; struct vnode *vp; struct vattr at; nfsfh_t nfh; fhandle_t *fhp; + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); + fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - return (0); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + error = 0; + goto nfsmout; } error = VOP_PATHCONF(vp, _PC_LINK_MAX, &linkmax); if (!error) @@ -3053,10 +3217,12 @@ nfsrv_pathconf(nfsd, slp, procp, mrq) getret = VOP_GETATTR(vp, &at, cred, procp); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF); - nfsm_srvpostop_attr(nfsd, getret, &at, &mb); - if (error) - return (0); - pc = nfsm_build(&mb, NFSX_V3PATHCONF); + nfsm_srvpostop_attr(nfsd, getret, &at, &info.nmi_mb); + if (error) { + error = 0; + goto nfsmout; + } + pc = nfsm_build(&info.nmi_mb, NFSX_V3PATHCONF); pc->pc_linkmax = txdr_unsigned(linkmax); pc->pc_namemax = txdr_unsigned(namemax); @@ -3071,6 +3237,7 @@ nfsrv_pathconf(nfsd, slp, procp, mrq) pc->pc_caseinsensitive = nfs_false; pc->pc_casepreserving = nfs_true; nfsmout: + *mrq = info.nmi_mreq; return(error); } @@ -3085,11 +3252,17 @@ nfsrv_null(nfsd, slp, procp, mrq) struct proc *procp; struct mbuf **mrq; { - struct mbuf *mrep = nfsd->nd_mrep; + struct nfsm_info info; int error = NFSERR_RETVOID; - struct mbuf *mb, *mreq; + + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); nfsm_reply(0); + *mrq = info.nmi_mreq; return (0); } @@ -3103,16 +3276,22 @@ nfsrv_noop(nfsd, slp, procp, mrq) struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; -{ - struct mbuf *mrep = nfsd->nd_mrep; +{ + struct nfsm_info info; int error; - struct mbuf *mb, *mreq; + + info.nmi_mreq = NULL; + info.nmi_mrep = nfsd->nd_mrep; + info.nmi_md = nfsd->nd_md; + info.nmi_dpos = nfsd->nd_dpos; + info.nmi_v3 = (nfsd->nd_flag & ND_NFSV3); if (nfsd->nd_repstat) error = nfsd->nd_repstat; else error = EPROCUNAVAIL; nfsm_reply(0); + *mrq = info.nmi_mreq; return (0); } diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index aed2d7aa00e..85001370b0e 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.92 2009/07/30 14:04:28 thib Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.93 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -739,9 +739,10 @@ nfs_reply(myrep) { struct nfsreq *rep; struct nfsmount *nmp = myrep->r_nmp; - struct mbuf *mrep, *nam, *md; + struct nfsm_info info; + struct mbuf *nam; u_int32_t rxid, *tl, t1; - caddr_t dpos, cp2; + caddr_t cp2; int s, error; /* @@ -761,7 +762,7 @@ nfs_reply(myrep) /* * Get the next Rpc reply off the socket */ - error = nfs_receive(myrep, &nam, &mrep); + error = nfs_receive(myrep, &nam, &info.nmi_mrep); nfs_rcvunlock(&nmp->nm_flag); if (error) { @@ -781,13 +782,13 @@ nfs_reply(myrep) /* * Get the xid and check that it is an rpc reply */ - md = mrep; - dpos = mtod(md, caddr_t); + info.nmi_md = info.nmi_mrep; + info.nmi_dpos = mtod(info.nmi_md, caddr_t); nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED); rxid = *tl++; if (*tl != rpc_reply) { nfsstats.rpcinvalid++; - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: continue; } @@ -800,9 +801,9 @@ nfsmout: TAILQ_FOREACH(rep, &nfs_reqq, r_chain) { if (rep->r_mrep == NULL && rxid == rep->r_xid) { /* Found it.. */ - rep->r_mrep = mrep; - rep->r_md = md; - rep->r_dpos = dpos; + rep->r_mrep = info.nmi_mrep; + rep->r_md = info.nmi_md; + rep->r_dpos = info.nmi_dpos; /* * Update congestion window. @@ -833,7 +834,7 @@ nfsmout: */ if (rep == 0) { nfsstats.rpcunexpected++; - m_freem(mrep); + m_freem(info.nmi_mrep); } else if (rep == myrep) { if (rep->r_mrep == NULL) panic("nfsreply nil"); @@ -853,28 +854,27 @@ nfsmout: * nb: always frees up mreq mbuf list */ int -nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) - struct vnode *vp; - struct mbuf *mrest; - int procnum; - struct proc *procp; - struct ucred *cred; - struct mbuf **mrp; - struct mbuf **mdp; - caddr_t *dposp; +nfs_request(struct vnode *vp, int procnum, struct nfsm_info *infop) { struct mbuf *m; + u_int32_t *tl; + struct nfsmount *nmp; + struct timeval tv; + caddr_t cp2; + int t1, i, s, error = 0; + int trylater_delay; struct nfsreq *rep; int mrest_len; + struct nfsm_info info; rep = pool_get(&nfsreqpl, PR_WAITOK); rep->r_nmp = VFSTONFS(vp->v_mount); rep->r_vp = vp; - rep->r_procp = procp; + rep->r_procp = infop->nmi_procp; rep->r_procnum = procnum; mrest_len = 0; - m = mrest; + m = infop->nmi_mreq; while (m) { mrest_len += m->m_len; m = m->m_next; @@ -882,31 +882,15 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp) /* empty mbuf for AUTH_UNIX header */ rep->r_mreq = m_gethdr(M_WAIT, MT_DATA); - rep->r_mreq->m_next = mrest; + rep->r_mreq->m_next = infop->nmi_mreq; rep->r_mreq->m_pkthdr.len = mrest_len; - return (nfs_request1(rep, cred, mrp, mdp, dposp)); -} - -int -nfs_request1(struct nfsreq *rep, struct ucred *cred, struct mbuf **mrp, - struct mbuf **mdp, caddr_t *dposp) -{ - struct mbuf *m, *mrep; - u_int32_t *tl; - struct nfsmount *nmp; - struct mbuf *md; - struct timeval tv; - caddr_t dpos, cp2; - int t1, i, s, error = 0; - int trylater_delay; - trylater_delay = NFS_MINTIMEO; nmp = rep->r_nmp; /* Get the RPC header with authorization. */ - nfsm_rpchead(rep, cred, RPCAUTH_UNIX); + nfsm_rpchead(rep, infop->nmi_cred, RPCAUTH_UNIX); m = rep->r_mreq; /* @@ -991,11 +975,11 @@ tryagain: */ if (!error && (rep->r_flags & R_TPRINTFMSG)) nfs_msg(rep, "is alive again"); - mrep = rep->r_mrep; - md = rep->r_md; - dpos = rep->r_dpos; + info.nmi_mrep = rep->r_mrep; + info.nmi_md = rep->r_md; + info.nmi_dpos = rep->r_dpos; if (error) { - *mrp = NULL; + infop->nmi_mrep = NULL; goto nfsmout1; } @@ -1008,7 +992,7 @@ tryagain: error = EOPNOTSUPP; else error = EACCES; /* Should be EAUTH. */ - *mrp = NULL; + infop->nmi_mrep = NULL; goto nfsmout1; } @@ -1030,7 +1014,7 @@ tryagain: error = fxdr_unsigned(int, *tl); if ((nmp->nm_flag & NFSMNT_NFSV3) && error == NFSERR_TRYLATER) { - m_freem(mrep); + m_freem(info.nmi_mrep); error = 0; tv.tv_sec = time_second + trylater_delay; tv.tv_usec = 0; @@ -1055,9 +1039,9 @@ tryagain: error = EPROTONOSUPPORT; nfsmout: - *mrp = mrep; - *mdp = md; - *dposp = dpos; + infop->nmi_mrep = info.nmi_mrep; + infop->nmi_md = info.nmi_md; + infop->nmi_dpos = info.nmi_dpos; nfsmout1: m_freem(rep->r_mreq); pool_put(&nfsreqpl, rep); @@ -1499,19 +1483,19 @@ nfs_getreq(nd, nfsd, has_header) int len, i; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; u_int32_t nfsvers, auth_type; int error = 0; - struct mbuf *mrep, *md; + struct nfsm_info info; - mrep = nd->nd_mrep; - md = nd->nd_md; - dpos = nd->nd_dpos; + info.nmi_mrep = nd->nd_mrep; + info.nmi_md = nd->nd_md; + info.nmi_dpos = nd->nd_dpos; if (has_header) { nfsm_dissect(tl, u_int32_t *, 10 * NFSX_UNSIGNED); nd->nd_retxid = fxdr_unsigned(u_int32_t, *tl++); if (*tl++ != rpc_call) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (EBADRPC); } } else @@ -1552,7 +1536,7 @@ nfs_getreq(nd, nfsd, has_header) auth_type = *tl++; len = fxdr_unsigned(int, *tl++); if (len < 0 || len > RPCAUTH_MAXSIZ) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (EBADRPC); } @@ -1560,7 +1544,7 @@ nfs_getreq(nd, nfsd, has_header) if (auth_type == rpc_auth_unix) { len = fxdr_unsigned(int, *++tl); if (len < 0 || len > NFS_MAXNAMLEN) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (EBADRPC); } nfsm_adv(nfsm_rndup(len)); @@ -1571,7 +1555,7 @@ nfs_getreq(nd, nfsd, has_header) nd->nd_cr.cr_gid = fxdr_unsigned(gid_t, *tl++); len = fxdr_unsigned(int, *tl); if (len < 0 || len > RPCAUTH_UNIXGIDS) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (EBADRPC); } nfsm_dissect(tl, u_int32_t *, (len + 2) * NFSX_UNSIGNED); @@ -1585,7 +1569,7 @@ nfs_getreq(nd, nfsd, has_header) nfsrvw_sort(nd->nd_cr.cr_groups, nd->nd_cr.cr_ngroups); len = fxdr_unsigned(int, *++tl); if (len < 0 || len > RPCAUTH_MAXSIZ) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (EBADRPC); } if (len > 0) @@ -1596,8 +1580,8 @@ nfs_getreq(nd, nfsd, has_header) return (0); } - nd->nd_md = md; - nd->nd_dpos = dpos; + nd->nd_md = info.nmi_md; + nd->nd_dpos = info.nmi_dpos; return (0); nfsmout: return (error); diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 1705640ae68..f7384ad0334 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_subs.c,v 1.98 2009/07/20 16:49:40 thib Exp $ */ +/* $OpenBSD: nfs_subs.c,v 1.99 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */ /* @@ -671,13 +671,6 @@ nfsm_mbuftouio(mrep, uiop, siz, dpos) len = mp->m_len; } xfer = (left > len) ? len : left; -#ifdef notdef - /* Not Yet.. */ - if (uiop->uio_iov->iov_op != NULL) - (*(uiop->uio_iov->iov_op)) - (mbufcp, uiocp, xfer); - else -#endif if (uiop->uio_segflg == UIO_SYSSPACE) bcopy(mbufcp, uiocp, xfer); else @@ -1965,13 +1958,13 @@ int nfsm_srvsattr(struct mbuf **mp, struct vattr *va, struct mbuf *mrep, caddr_t *dposp) { - struct mbuf *md; + struct nfsm_info info; uint32_t *tl, t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0; - md = *mp; - dpos = *dposp; + info.nmi_md = *mp; + info.nmi_dpos = *dposp; nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); if (*tl == nfs_true) { @@ -2021,8 +2014,8 @@ nfsm_srvsattr(struct mbuf **mp, struct vattr *va, struct mbuf *mrep, break; }; - *dposp = dpos; - *mp = md; + *dposp = info.nmi_dpos; + *mp = info.nmi_md; nfsmout: return (error); } diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h index e311028ff0d..71d9e46ac2f 100644 --- a/sys/nfs/nfs_var.h +++ b/sys/nfs/nfs_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_var.h,v 1.51 2009/06/04 01:02:42 blambert Exp $ */ +/* $OpenBSD: nfs_var.h,v 1.52 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */ /* @@ -42,6 +42,7 @@ struct nfsnode; struct sillyrename; struct componentname; struct nfs_diskless; +struct nfsm_info; /* nfs_bio.c */ int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *); @@ -184,11 +185,7 @@ int nfs_send(struct socket *, struct mbuf *, struct mbuf *, struct nfsreq *); int nfs_receive(struct nfsreq *, struct mbuf **, struct mbuf **); int nfs_reply(struct nfsreq *); -int nfs_request(struct vnode *, struct mbuf *, int, struct proc *, - struct ucred *, struct mbuf **, struct mbuf **, - caddr_t *); -int nfs_request1(struct nfsreq *, struct ucred *, struct mbuf **, - struct mbuf **, caddr_t *); +int nfs_request(struct vnode *, int, struct nfsm_info *); int nfs_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *, int, struct mbuf **, struct mbuf **); void nfs_timer(void *); diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index cb376b5781b..145b179cf94 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vfsops.c,v 1.85 2009/07/20 16:49:40 thib Exp $ */ +/* $OpenBSD: nfs_vfsops.c,v 1.86 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */ /* @@ -105,40 +105,43 @@ nfs_statfs(mp, sbp, p) { struct vnode *vp; struct nfs_statfs *sfp = NULL; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; struct nfsmount *nmp = VFSTONFS(mp); - int error = 0, v3 = (nmp->nm_flag & NFSMNT_NFSV3), retattr; - struct mbuf *mreq, *mrep = NULL, *md, *mb; + int error = 0, retattr; struct ucred *cred; struct nfsnode *np; u_quad_t tquad; + info.nmi_v3 = (nmp->nm_flag & NFSMNT_NFSV3); + error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np); if (error) return (error); vp = NFSTOV(np); cred = crget(); cred->cr_ngroups = 0; - if (v3 && (nmp->nm_flag & NFSMNT_GOTFSINFO) == 0) + if (info.nmi_v3 && (nmp->nm_flag & NFSMNT_GOTFSINFO) == 0) (void)nfs_fsinfo(nmp, vp, cred, p); nfsstats.rpccnt[NFSPROC_FSSTAT]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3)); - nfsm_fhtom(&mb, vp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); - error = nfs_request(vp, mreq, NFSPROC_FSSTAT, p, cred, &mrep, - &md, &dpos); - if (v3) + info.nmi_procp = p; + info.nmi_cred = cred; + error = nfs_request(vp, NFSPROC_FSSTAT, &info); + if (info.nmi_v3) nfsm_postop_attr(vp, retattr); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } - nfsm_dissect(sfp, struct nfs_statfs *, NFSX_STATFS(v3)); + nfsm_dissect(sfp, struct nfs_statfs *, NFSX_STATFS(info.nmi_v3)); sbp->f_iosize = min(nmp->nm_rsize, nmp->nm_wsize); - if (v3) { + if (info.nmi_v3) { sbp->f_bsize = NFS_FABLKSIZE; tquad = fxdr_hyper(&sfp->sf_tbytes); sbp->f_blocks = tquad / (u_quad_t)NFS_FABLKSIZE; @@ -162,7 +165,7 @@ nfs_statfs(mp, sbp, p) sbp->f_ffree = 0; } copy_statfs_info(sbp, mp); - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: vrele(vp); crfree(cred); @@ -180,22 +183,23 @@ nfs_fsinfo(nmp, vp, cred, p) struct proc *p; { struct nfsv3_fsinfo *fsp; + struct nfsm_info info; int32_t t1; u_int32_t *tl, pref, max; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, retattr; - struct mbuf *mreq, *mrep, *md, *mb; nfsstats.rpccnt[NFSPROC_FSINFO]++; - mb = mreq = nfsm_reqhead(NFSX_FH(1)); - nfsm_fhtom(&mb, vp, 1); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(1)); + nfsm_fhtom(&info.nmi_mb, vp, 1); - error = nfs_request(vp, mreq, NFSPROC_FSINFO, p, cred, &mrep, - &md, &dpos); + info.nmi_procp = p; + info.nmi_cred = cred; + error = nfs_request(vp, NFSPROC_FSINFO, &info); nfsm_postop_attr(vp, retattr); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } @@ -231,7 +235,7 @@ nfs_fsinfo(nmp, vp, cred, p) } nmp->nm_flag |= NFSMNT_GOTFSINFO; - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: return (error); } diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 70101e5176e..2faf0f7cff4 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.119 2009/07/20 16:49:40 thib Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.120 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -213,14 +213,12 @@ nfs_null(vp, cred, procp) struct ucred *cred; struct proc *procp; { - caddr_t dpos; - int error = 0; - struct mbuf *mreq, *mrep, *md, *mb; + struct nfsm_info info; + int error = 0; - mb = mreq = nfsm_reqhead(0); - error = nfs_request(vp, mreq, NFSPROC_NULL, procp, cred, &mrep, - &md, &dpos); - m_freem(mrep); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(0); + error = nfs_request(vp, NFSPROC_NULL, &info); + m_freem(info.nmi_mrep); return (error); } @@ -238,12 +236,12 @@ nfs_access(v) struct vnode *vp = ap->a_vp; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, attrflag; - struct mbuf *mreq, *mrep, *md, *mb; u_int32_t mode, rmode; int v3 = NFS_ISV3(vp); int cachevalid; + struct nfsm_info info; struct nfsnode *np = VTONFS(vp); @@ -289,9 +287,9 @@ nfs_access(v) */ if (v3) { nfsstats.rpccnt[NFSPROC_ACCESS]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED); - nfsm_fhtom(&mb, vp, v3); - tl = nfsm_build(&mb, NFSX_UNSIGNED); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED); + nfsm_fhtom(&info.nmi_mb, vp, v3); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); if (ap->a_mode & VREAD) mode = NFSV3ACCESS_READ; else @@ -310,12 +308,13 @@ nfs_access(v) } *tl = txdr_unsigned(mode); - error = nfs_request(vp, mreq, NFSPROC_ACCESS, ap->a_p, - ap->a_cred, &mrep, &md, &dpos); + info.nmi_procp = ap->a_p; + info.nmi_cred = ap->a_cred; + error = nfs_request(vp, NFSPROC_ACCESS, &info); nfsm_postop_attr(vp, attrflag); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } @@ -329,7 +328,7 @@ nfs_access(v) if ((rmode & mode) != mode) error = EACCES; - m_freem(mrep); + m_freem(info.nmi_mrep); } else return (nfsspec_access(ap)); @@ -496,12 +495,12 @@ nfs_getattr(v) struct vop_getattr_args *ap = v; struct vnode *vp = ap->a_vp; struct nfsnode *np = VTONFS(vp); + struct nfsm_info info; int32_t t1; - caddr_t dpos; int error = 0; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(vp); - + + info.nmi_v3 = NFS_ISV3(vp); + /* * Update local times for special files. */ @@ -512,14 +511,16 @@ nfs_getattr(v) */ if (nfs_getattrcache(vp, ap->a_vap) == 0) return (0); + nfsstats.rpccnt[NFSPROC_GETATTR]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3)); - nfsm_fhtom(&mb, vp, v3); - error = nfs_request(vp, mreq, NFSPROC_GETATTR, ap->a_p, - ap->a_cred, &mrep, &md, &dpos); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); + info.nmi_procp = ap->a_p; + info.nmi_cred = ap->a_cred; + error = nfs_request(vp, NFSPROC_GETATTR, &info); if (!error) nfsm_loadattr(vp, ap->a_vap); - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: return (error); } @@ -619,23 +620,25 @@ nfs_setattrrpc(vp, vap, cred, procp) struct proc *procp; { struct nfsv2_sattr *sp; + struct nfsm_info info; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; u_int32_t *tl; int error = 0, wccflag = NFSV3_WCCRATTR; - struct mbuf *mreq, *mrep, *md, *mb; int v3 = NFS_ISV3(vp); + info.nmi_v3 = NFS_ISV3(vp); + nfsstats.rpccnt[NFSPROC_SETATTR]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_SATTR(v3)); - nfsm_fhtom(&mb, vp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_SATTR(v3)); + nfsm_fhtom(&info.nmi_mb, vp, v3); - if (v3) { - nfsm_v3attrbuild(&mb, vap, 1); - tl = nfsm_build(&mb, NFSX_UNSIGNED); + if (info.nmi_v3) { + nfsm_v3attrbuild(&info.nmi_mb, vap, 1); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); *tl = nfs_false; } else { - sp = nfsm_build(&mb, NFSX_V2SATTR); + sp = nfsm_build(&info.nmi_mb, NFSX_V2SATTR); if (vap->va_mode == (mode_t)VNOVAL) sp->sa_mode = nfs_xdrneg1; else @@ -653,15 +656,16 @@ nfs_setattrrpc(vp, vap, cred, procp) txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - error = nfs_request(vp, mreq, NFSPROC_SETATTR, procp, cred, &mrep, - &md, &dpos); + info.nmi_procp = procp; + info.nmi_cred = cred; + error = nfs_request(vp, NFSPROC_SETATTR, &info); - if (v3) + if (info.nmi_v3) nfsm_wcc_data(vp, wccflag); else if (error == 0) nfsm_loadattr(vp, NULL); - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: return (error); } @@ -680,18 +684,19 @@ nfs_lookup(v) struct vnode *dvp = ap->a_dvp; struct vnode **vpp = ap->a_vpp; struct proc *p = cnp->cn_proc; + struct nfsm_info info; int flags; struct vnode *newvp; u_int32_t *tl; int32_t t1; struct nfsmount *nmp; - caddr_t dpos, cp2; - struct mbuf *mreq, *mrep, *md, *mb; + caddr_t cp2; long len; nfsfh_t *fhp; struct nfsnode *np; int lockparent, wantparent, error = 0, attrflag, fhsize; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); cnp->cn_flags &= ~PDIRUNLOCK; flags = cnp->cn_flags; @@ -781,43 +786,45 @@ dorpc: nfsstats.lookupcache_misses++; nfsstats.rpccnt[NFSPROC_LOOKUP]++; len = cnp->cn_namelen; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED + nfsm_rndup(len)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); - error = nfs_request(dvp, mreq, NFSPROC_LOOKUP, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(dvp, NFSPROC_LOOKUP, &info); if (error) { - if (v3) + if (info.nmi_v3) nfsm_postop_attr(dvp, attrflag); - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } - nfsm_getfh(fhp, fhsize, v3); + nfsm_getfh(fhp, fhsize, info.nmi_v3); /* * Handle RENAME case... */ if (cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) { if (NFS_CMPFH(np, fhp, fhsize)) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (EISDIR); } error = nfs_nget(dvp->v_mount, fhp, fhsize, &np); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (error); } newvp = NFSTOV(np); - if (v3) { + if (info.nmi_v3) { nfsm_postop_attr(newvp, attrflag); nfsm_postop_attr(dvp, attrflag); } else nfsm_loadattr(newvp, NULL); *vpp = newvp; - m_freem(mrep); + m_freem(info.nmi_mrep); cnp->cn_flags |= SAVENAME; if (!lockparent) { VOP_UNLOCK(dvp, 0, p); @@ -835,7 +842,7 @@ dorpc: if (NFS_CMPFH(np, fhp, fhsize)) { vref(dvp); newvp = dvp; - if (v3) { + if (info.nmi_v3) { nfsm_postop_attr(newvp, attrflag); nfsm_postop_attr(dvp, attrflag); } else @@ -848,12 +855,12 @@ dorpc: if (error) { if (vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p) == 0) cnp->cn_flags &= ~PDIRUNLOCK; - m_freem(mrep); + m_freem(info.nmi_mrep); return (error); } newvp = NFSTOV(np); - if (v3) { + if (info.nmi_v3) { nfsm_postop_attr(newvp, attrflag); nfsm_postop_attr(dvp, attrflag); } else @@ -861,7 +868,7 @@ dorpc: if (lockparent && (flags & ISLASTCN)) { if ((error = vn_lock(dvp, LK_EXCLUSIVE, p))) { - m_freem(mrep); + m_freem(info.nmi_mrep); vput(newvp); return error; } @@ -871,11 +878,11 @@ dorpc: } else { error = nfs_nget(dvp->v_mount, fhp, fhsize, &np); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); return error; } newvp = NFSTOV(np); - if (v3) { + if (info.nmi_v3) { nfsm_postop_attr(newvp, attrflag); nfsm_postop_attr(dvp, attrflag); } else @@ -894,7 +901,7 @@ dorpc: } *vpp = newvp; - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: if (error) { @@ -968,28 +975,31 @@ nfs_readlinkrpc(vp, uiop, cred) struct uio *uiop; struct ucred *cred; { + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, len, attrflag; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(vp); + + info.nmi_v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_READLINK]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3)); - nfsm_fhtom(&mb, vp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); - error = nfs_request(vp, mreq, NFSPROC_READLINK, uiop->uio_procp, - cred, &mrep, &md, &dpos); + info.nmi_procp = uiop->uio_procp; + info.nmi_cred = cred; + error = nfs_request(vp, NFSPROC_READLINK, &info); - if (v3) + if (info.nmi_v3) nfsm_postop_attr(vp, attrflag); if (!error) { nfsm_strsiz(len, NFS_MAXPATHLEN); nfsm_mtouio(uiop, len); } - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: return (error); } @@ -1003,27 +1013,29 @@ nfs_readrpc(vp, uiop) struct vnode *vp; struct uio *uiop; { + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; - struct mbuf *mreq, *mrep, *md, *mb; + caddr_t cp2; struct nfsmount *nmp; int error = 0, len, retlen, tsiz, eof, attrflag; - int v3 = NFS_ISV3(vp); + + info.nmi_v3 = NFS_ISV3(vp); eof = 0; nmp = VFSTONFS(vp->v_mount); tsiz = uiop->uio_resid; - if (uiop->uio_offset + tsiz > 0xffffffff && !v3) + if (uiop->uio_offset + tsiz > 0xffffffff && !info.nmi_v3) return (EFBIG); while (tsiz > 0) { nfsstats.rpccnt[NFSPROC_READ]++; len = (tsiz > nmp->nm_rsize) ? nmp->nm_rsize : tsiz; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED * 3); - nfsm_fhtom(&mb, vp, v3); - tl = nfsm_build(&mb, NFSX_UNSIGNED * 3); - if (v3) { + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED * 3); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED * 3); + if (info.nmi_v3) { txdr_hyper(uiop->uio_offset, tl); *(tl + 2) = txdr_unsigned(len); } else { @@ -1032,16 +1044,17 @@ nfs_readrpc(vp, uiop) *tl = 0; } - error = nfs_request(vp, mreq, NFSPROC_READ, uiop->uio_procp, - VTONFS(vp)->n_rcred, &mrep, &md, &dpos); - if (v3) + info.nmi_procp = uiop->uio_procp; + info.nmi_cred = VTONFS(vp)->n_rcred; + error = nfs_request(vp, NFSPROC_READ, &info); + if (info.nmi_v3) nfsm_postop_attr(vp, attrflag); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); eof = fxdr_unsigned(int, *(tl + 1)); } else { @@ -1050,14 +1063,15 @@ nfs_readrpc(vp, uiop) nfsm_strsiz(retlen, nmp->nm_rsize); nfsm_mtouio(uiop, retlen); - m_freem(mrep); + m_freem(info.nmi_mrep); tsiz -= retlen; - if (v3) { + if (info.nmi_v3) { if (eof || retlen == 0) tsiz = 0; } else if (retlen < len) tsiz = 0; } + nfsmout: return (error); } @@ -1071,13 +1085,15 @@ nfs_writerpc(vp, uiop, iomode, must_commit) struct uio *uiop; int *iomode, *must_commit; { + struct nfsm_info info; u_int32_t *tl; int32_t t1, backup; - caddr_t dpos, cp2; - struct mbuf *mreq, *mrep, *md, *mb; + caddr_t cp2; struct nfsmount *nmp = VFSTONFS(vp->v_mount); int error = 0, len, tsiz, wccflag = NFSV3_WCCRATTR, rlen, commit; - int v3 = NFS_ISV3(vp), committed = NFSV3WRITE_FILESYNC; + int committed = NFSV3WRITE_FILESYNC; + + info.nmi_v3 = NFS_ISV3(vp); #ifdef DIAGNOSTIC if (uiop->uio_iovcnt != 1) @@ -1085,16 +1101,16 @@ nfs_writerpc(vp, uiop, iomode, must_commit) #endif *must_commit = 0; tsiz = uiop->uio_resid; - if (uiop->uio_offset + tsiz > 0xffffffff && !v3) + if (uiop->uio_offset + tsiz > 0xffffffff && !info.nmi_v3) return (EFBIG); while (tsiz > 0) { nfsstats.rpccnt[NFSPROC_WRITE]++; len = (tsiz > nmp->nm_wsize) ? nmp->nm_wsize : tsiz; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 5 * NFSX_UNSIGNED + - nfsm_rndup(len)); - nfsm_fhtom(&mb, vp, v3); - if (v3) { - tl = nfsm_build(&mb, 5 * NFSX_UNSIGNED); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + 5 * NFSX_UNSIGNED + nfsm_rndup(len)); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); + if (info.nmi_v3) { + tl = nfsm_build(&info.nmi_mb, 5 * NFSX_UNSIGNED); txdr_hyper(uiop->uio_offset, tl); tl += 2; *tl++ = txdr_unsigned(len); @@ -1103,7 +1119,7 @@ nfs_writerpc(vp, uiop, iomode, must_commit) } else { u_int32_t x; - tl = nfsm_build(&mb, 4 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 4 * NFSX_UNSIGNED); /* Set both "begin" and "current" to non-garbage. */ x = txdr_unsigned((u_int32_t)uiop->uio_offset); *tl++ = x; /* "begin offset" */ @@ -1113,21 +1129,22 @@ nfs_writerpc(vp, uiop, iomode, must_commit) *tl = x; /* size of this write */ } - nfsm_uiotombuf(&mb, uiop, len); + nfsm_uiotombuf(&info.nmi_mb, uiop, len); - error = nfs_request(vp, mreq, NFSPROC_WRITE, uiop->uio_procp, - VTONFS(vp)->n_wcred, &mrep, &md, &dpos); - if (v3) { + info.nmi_procp = uiop->uio_procp; + info.nmi_cred = VTONFS(vp)->n_wcred; + error = nfs_request(vp, NFSPROC_WRITE, &info); + if (info.nmi_v3) { wccflag = NFSV3_WCCCHK; nfsm_wcc_data(vp, wccflag); } if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } - if (v3) { + if (info.nmi_v3) { wccflag = NFSV3_WCCCHK; nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3WRITEVERF); @@ -1171,7 +1188,7 @@ nfs_writerpc(vp, uiop, iomode, must_commit) } if (wccflag) VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime; - m_freem(mrep); + m_freem(info.nmi_mrep); tsiz -= len; } nfsmout: @@ -1194,16 +1211,16 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) struct vattr *vap; { struct nfsv2_sattr *sp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; struct vnode *newvp = NULL; struct nfsnode *np = NULL; char *cp2; - caddr_t dpos; int error = 0, wccflag = NFSV3_WCCRATTR, gotvp = 0; - struct mbuf *mreq, *mrep, *md, *mb; u_int32_t rdev; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); if (vap->va_type == VCHR || vap->va_type == VBLK) rdev = txdr_unsigned(vap->va_rdev); @@ -1215,22 +1232,23 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) return (EOPNOTSUPP); } nfsstats.rpccnt[NFSPROC_MKNOD]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 4 * NFSX_UNSIGNED + - nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + 4 * NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + + NFSX_SATTR(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - if (v3) { - tl = nfsm_build(&mb, NFSX_UNSIGNED); + if (info.nmi_v3) { + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); *tl++ = vtonfsv3_type(vap->va_type); - nfsm_v3attrbuild(&mb, vap, 0); + nfsm_v3attrbuild(&info.nmi_mb, vap, 0); if (vap->va_type == VCHR || vap->va_type == VBLK) { - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(major(vap->va_rdev)); *tl = txdr_unsigned(minor(vap->va_rdev)); } } else { - sp = nfsm_build(&mb, NFSX_V2SATTR); + sp = nfsm_build(&info.nmi_mb, NFSX_V2SATTR); sp->sa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode); sp->sa_uid = nfs_xdrneg1; sp->sa_gid = nfs_xdrneg1; @@ -1239,10 +1257,11 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - error = nfs_request(dvp, mreq, NFSPROC_MKNOD, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(dvp, NFSPROC_MKNOD, &info); if (!error) { - nfsm_mtofh(dvp, newvp, v3, gotvp); + nfsm_mtofh(dvp, newvp, info.nmi_v3, gotvp); if (!gotvp) { if (newvp) { vrele(newvp); @@ -1254,9 +1273,10 @@ nfs_mknodrpc(dvp, vpp, cnp, vap) newvp = NFSTOV(np); } } - if (v3) + if (info.nmi_v3) nfsm_wcc_data(dvp, wccflag); - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: if (error) { if (newvp) @@ -1304,14 +1324,15 @@ nfs_create(v) struct vattr *vap = ap->a_vap; struct componentname *cnp = ap->a_cnp; struct nfsv2_sattr *sp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; struct nfsnode *np = NULL; struct vnode *newvp = NULL; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, wccflag = NFSV3_WCCRATTR, gotvp = 0, fmode = 0; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); /* * Oops, not for me.. @@ -1324,23 +1345,24 @@ nfs_create(v) again: nfsstats.rpccnt[NFSPROC_CREATE]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 2 * NFSX_UNSIGNED + - nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + 2 * NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + + NFSX_SATTR(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - if (v3) { - tl = nfsm_build(&mb, NFSX_UNSIGNED); + if (info.nmi_v3) { + tl = nfsm_build(&info.nmi_mb, NFSX_UNSIGNED); if (fmode & O_EXCL) { *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE); - tl = nfsm_build(&mb, NFSX_V3CREATEVERF); + tl = nfsm_build(&info.nmi_mb, NFSX_V3CREATEVERF); *tl++ = arc4random(); *tl = arc4random(); } else { *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED); - nfsm_v3attrbuild(&mb, vap, 0); + nfsm_v3attrbuild(&info.nmi_mb, vap, 0); } } else { - sp = nfsm_build(&mb, NFSX_V2SATTR); + sp = nfsm_build(&info.nmi_mb, NFSX_V2SATTR); sp->sa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode); sp->sa_uid = nfs_xdrneg1; sp->sa_gid = nfs_xdrneg1; @@ -1349,10 +1371,11 @@ again: txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - error = nfs_request(dvp, mreq, NFSPROC_CREATE, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(dvp, NFSPROC_CREATE, &info); if (!error) { - nfsm_mtofh(dvp, newvp, v3, gotvp); + nfsm_mtofh(dvp, newvp, info.nmi_v3, gotvp); if (!gotvp) { if (newvp) { vrele(newvp); @@ -1364,18 +1387,19 @@ again: newvp = NFSTOV(np); } } - if (v3) + if (info.nmi_v3) nfsm_wcc_data(dvp, wccflag); - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: if (error) { - if (v3 && (fmode & O_EXCL) && error == NFSERR_NOTSUPP) { + if (info.nmi_v3 && (fmode & O_EXCL) && error == NFSERR_NOTSUPP) { fmode &= ~O_EXCL; goto again; } if (newvp) vrele(newvp); - } else if (v3 && (fmode & O_EXCL)) + } else if (info.nmi_v3 && (fmode & O_EXCL)) error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_proc); if (!error) { if (cnp->cn_flags & MAKEENTRY) @@ -1486,23 +1510,27 @@ nfs_removerpc(dvp, name, namelen, cred, proc) struct ucred *cred; struct proc *proc; { + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, wccflag = NFSV3_WCCRATTR; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); nfsstats.rpccnt[NFSPROC_REMOVE]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + - nfsm_rndup(namelen)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED + nfsm_rndup(namelen)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(name, namelen, NFS_MAXNAMLEN); - error = nfs_request(dvp, mreq, NFSPROC_REMOVE, proc, cred, &mrep, - &md, &dpos); - if (v3) + + info.nmi_procp = proc; + info.nmi_cred = cred; + error = nfs_request(dvp, NFSPROC_REMOVE, &info); + if (info.nmi_v3) nfsm_wcc_data(dvp, wccflag); - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) @@ -1605,27 +1633,31 @@ nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc) struct ucred *cred; struct proc *proc; { + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, fwccflag = NFSV3_WCCRATTR, twccflag = NFSV3_WCCRATTR; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(fdvp); + + info.nmi_v3 = NFS_ISV3(fdvp); nfsstats.rpccnt[NFSPROC_RENAME]++; - mb = mreq = nfsm_reqhead((NFSX_FH(v3) + NFSX_UNSIGNED)*2 + - nfsm_rndup(fnamelen) + nfsm_rndup(tnamelen)); - nfsm_fhtom(&mb, fdvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead((NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED) * 2 + nfsm_rndup(fnamelen) + nfsm_rndup(tnamelen)); + nfsm_fhtom(&info.nmi_mb, fdvp, info.nmi_v3); nfsm_strtom(fnameptr, fnamelen, NFS_MAXNAMLEN); - nfsm_fhtom(&mb, tdvp, v3); + nfsm_fhtom(&info.nmi_mb, tdvp, info.nmi_v3); nfsm_strtom(tnameptr, tnamelen, NFS_MAXNAMLEN); - error = nfs_request(fdvp, mreq, NFSPROC_RENAME, proc, cred, &mrep, - &md, &dpos); - if (v3) { + + info.nmi_procp = proc; + info.nmi_cred = cred; + error = nfs_request(fdvp, NFSPROC_RENAME, &info); + if (info.nmi_v3) { nfsm_wcc_data(fdvp, fwccflag); nfsm_wcc_data(tdvp, twccflag); } - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: VTONFS(fdvp)->n_flag |= NMODIFIED; VTONFS(tdvp)->n_flag |= NMODIFIED; @@ -1647,12 +1679,13 @@ nfs_link(v) struct vnode *vp = ap->a_vp; struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, wccflag = NFSV3_WCCRATTR, attrflag = 0; - struct mbuf *mreq, *mrep, *md, *mb; - int v3; + + info.nmi_v3 = NFS_ISV3(vp); if (dvp->v_mount != vp->v_mount) { pool_put(&namei_pool, cnp->cn_pnbuf); @@ -1670,20 +1703,21 @@ nfs_link(v) */ VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_proc); - v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_LINK]++; - mb = mreq = nfsm_reqhead(2 * NFSX_FH(v3) + NFSX_UNSIGNED + - nfsm_rndup(cnp->cn_namelen)); - nfsm_fhtom(&mb, vp, v3); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(2 * NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - error = nfs_request(vp, mreq, NFSPROC_LINK, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); - if (v3) { + + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(vp, NFSPROC_LINK, &info); + if (info.nmi_v3) { nfsm_postop_attr(vp, attrflag); nfsm_wcc_data(dvp, wccflag); } - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; @@ -1710,25 +1744,27 @@ nfs_symlink(v) struct vattr *vap = ap->a_vap; struct componentname *cnp = ap->a_cnp; struct nfsv2_sattr *sp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int slen, error = 0, wccflag = NFSV3_WCCRATTR, gotvp; - struct mbuf *mreq, *mrep, *md, *mb; struct vnode *newvp = NULL; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); nfsstats.rpccnt[NFSPROC_SYMLINK]++; slen = strlen(ap->a_target); - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + 2 * NFSX_UNSIGNED + - nfsm_rndup(cnp->cn_namelen) + nfsm_rndup(slen) + NFSX_SATTR(v3)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + 2 * NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + nfsm_rndup(slen) + + NFSX_SATTR(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - if (v3) - nfsm_v3attrbuild(&mb, vap, 0); + if (info.nmi_v3) + nfsm_v3attrbuild(&info.nmi_mb, vap, 0); nfsm_strtom(ap->a_target, slen, NFS_MAXPATHLEN); - if (!v3) { - sp = nfsm_build(&mb, NFSX_V2SATTR); + if (!info.nmi_v3) { + sp = nfsm_build(&info.nmi_mb, NFSX_V2SATTR); sp->sa_mode = vtonfsv2_mode(VLNK, vap->va_mode); sp->sa_uid = nfs_xdrneg1; sp->sa_gid = nfs_xdrneg1; @@ -1736,14 +1772,17 @@ nfs_symlink(v) txdr_nfsv2time(&vap->va_atime, &sp->sa_atime); txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - error = nfs_request(dvp, mreq, NFSPROC_SYMLINK, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); - if (v3) { + + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(dvp, NFSPROC_SYMLINK, &info); + if (info.nmi_v3) { if (!error) - nfsm_mtofh(dvp, newvp, v3, gotvp); + nfsm_mtofh(dvp, newvp, info.nmi_v3, gotvp); nfsm_wcc_data(dvp, wccflag); } - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: if (newvp) vrele(newvp); @@ -1768,28 +1807,29 @@ nfs_mkdir(v) struct vattr *vap = ap->a_vap; struct componentname *cnp = ap->a_cnp; struct nfsv2_sattr *sp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; int len; struct nfsnode *np = NULL; struct vnode *newvp = NULL; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, wccflag = NFSV3_WCCRATTR; int gotvp = 0; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); len = cnp->cn_namelen; nfsstats.rpccnt[NFSPROC_MKDIR]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + - nfsm_rndup(len) + NFSX_SATTR(v3)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED + nfsm_rndup(len) + NFSX_SATTR(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN); - if (v3) { - nfsm_v3attrbuild(&mb, vap, 0); + if (info.nmi_v3) { + nfsm_v3attrbuild(&info.nmi_mb, vap, 0); } else { - sp = nfsm_build(&mb, NFSX_V2SATTR); + sp = nfsm_build(&info.nmi_mb, NFSX_V2SATTR); sp->sa_mode = vtonfsv2_mode(VDIR, vap->va_mode); sp->sa_uid = nfs_xdrneg1; sp->sa_gid = nfs_xdrneg1; @@ -1798,13 +1838,15 @@ nfs_mkdir(v) txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime); } - error = nfs_request(dvp, mreq, NFSPROC_MKDIR, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(dvp, NFSPROC_MKDIR, &info); if (!error) - nfsm_mtofh(dvp, newvp, v3, gotvp); - if (v3) + nfsm_mtofh(dvp, newvp, info.nmi_v3, gotvp); + if (info.nmi_v3) nfsm_wcc_data(dvp, wccflag); - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: VTONFS(dvp)->n_flag |= NMODIFIED; if (!wccflag) @@ -1844,12 +1886,13 @@ nfs_rmdir(v) struct vnode *vp = ap->a_vp; struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; + struct nfsm_info info; u_int32_t *tl; int32_t t1; - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, wccflag = NFSV3_WCCRATTR; - struct mbuf *mreq, *mrep, *md, *mb; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); if (dvp == vp) { vrele(dvp); @@ -1857,16 +1900,20 @@ nfs_rmdir(v) pool_put(&namei_pool, cnp->cn_pnbuf); return (EINVAL); } + nfsstats.rpccnt[NFSPROC_RMDIR]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + - nfsm_rndup(cnp->cn_namelen)); - nfsm_fhtom(&mb, dvp, v3); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN); - error = nfs_request(dvp, mreq, NFSPROC_RMDIR, cnp->cn_proc, - cnp->cn_cred, &mrep, &md, &dpos); - if (v3) + + info.nmi_procp = cnp->cn_proc; + info.nmi_cred = cnp->cn_cred; + error = nfs_request(dvp, NFSPROC_RMDIR, &info); + if (info.nmi_v3) nfsm_wcc_data(dvp, wccflag); - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: pool_put(&namei_pool, cnp->cn_pnbuf); VTONFS(dvp)->n_flag |= NMODIFIED; @@ -2068,18 +2115,19 @@ nfs_readdirrpc(struct vnode *vp, int len, left; struct nfs_dirent *ndp = NULL; struct dirent *dp = NULL; + struct nfsm_info info; u_int32_t *tl; caddr_t cp; int32_t t1; - caddr_t dpos, cp2; - struct mbuf *mreq, *mrep, *md, *mb; + caddr_t cp2; nfsuint64 cookie; struct nfsmount *nmp = VFSTONFS(vp->v_mount); struct nfsnode *dnp = VTONFS(vp); u_quad_t fileno; int error = 0, tlen, more_dirs = 1, blksiz = 0, bigenough = 1; int attrflag; - int v3 = NFS_ISV3(vp); + + info.nmi_v3 = NFS_ISV3(vp); #ifdef DIAGNOSTIC if (uiop->uio_iovcnt != 1 || @@ -2096,10 +2144,11 @@ nfs_readdirrpc(struct vnode *vp, */ while (more_dirs && bigenough) { nfsstats.rpccnt[NFSPROC_READDIR]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_READDIR(v3)); - nfsm_fhtom(&mb, vp, v3); - if (v3) { - tl = nfsm_build(&mb, 5 * NFSX_UNSIGNED); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + + NFSX_READDIR(info.nmi_v3)); + nfsm_fhtom(&info.nmi_mb, vp, info.nmi_v3); + if (info.nmi_v3) { + tl = nfsm_build(&info.nmi_mb, 5 * NFSX_UNSIGNED); *tl++ = cookie.nfsuquad[0]; *tl++ = cookie.nfsuquad[1]; if (cookie.nfsuquad[0] == 0 && @@ -2111,22 +2160,23 @@ nfs_readdirrpc(struct vnode *vp, *tl++ = dnp->n_cookieverf.nfsuquad[1]; } } else { - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED); *tl++ = cookie.nfsuquad[1]; } *tl = txdr_unsigned(nmp->nm_readdirsize); - error = nfs_request(vp, mreq, NFSPROC_READDIR, - uiop->uio_procp, cred, &mrep, &md, &dpos); - if (v3) + info.nmi_procp = uiop->uio_procp; + info.nmi_cred = cred; + error = nfs_request(vp, NFSPROC_READDIR, &info); + if (info.nmi_v3) nfsm_postop_attr(vp, attrflag); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); dnp->n_cookieverf.nfsuquad[0] = *tl++; @@ -2138,7 +2188,7 @@ nfs_readdirrpc(struct vnode *vp, /* loop thru the dir entries, doctoring them to 4bsd form */ while (more_dirs && bigenough) { - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); fileno = fxdr_hyper(tl); @@ -2151,7 +2201,7 @@ nfs_readdirrpc(struct vnode *vp, } if (len <= 0 || len > NFS_MAXNAMLEN) { error = EBADRPC; - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } tlen = nfsm_rndup(len + 1); @@ -2190,7 +2240,7 @@ nfs_readdirrpc(struct vnode *vp, uiop->uio_resid -= tlen; } else nfsm_adv(nfsm_rndup(len)); - if (v3) { + if (info.nmi_v3) { nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); } else { @@ -2198,14 +2248,14 @@ nfs_readdirrpc(struct vnode *vp, 2 * NFSX_UNSIGNED); } if (bigenough) { - if (v3) { + if (info.nmi_v3) { ndp->cookie[0] = cookie.nfsuquad[0] = *tl++; } else ndp->cookie[0] = 0; ndp->cookie[1] = cookie.nfsuquad[1] = *tl++; - } else if (v3) + } else if (info.nmi_v3) tl += 2; else tl++; @@ -2218,7 +2268,7 @@ nfs_readdirrpc(struct vnode *vp, nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); more_dirs = (fxdr_unsigned(int, *tl) == 0); } - m_freem(mrep); + m_freem(info.nmi_mrep); } /* * Fill last record, iff any, out to a multiple of NFS_READDIRBLKSIZ @@ -2259,12 +2309,13 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, int len, left; struct nfs_dirent *ndirp = NULL; struct dirent *dp = NULL; + struct nfsm_info info; u_int32_t *tl; caddr_t cp; int32_t t1; struct vnode *newvp; - caddr_t dpos, cp2, dpossav1, dpossav2; - struct mbuf *mreq, *mrep, *md, *mb, *mdsav1, *mdsav2; + caddr_t cp2, dpossav1, dpossav2; + struct mbuf *mdsav1, *mdsav2; struct nameidata nami, *ndp = &nami; struct componentname *cnp = &ndp->ni_cnd; nfsuint64 cookie; @@ -2292,9 +2343,9 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, */ while (more_dirs && bigenough) { nfsstats.rpccnt[NFSPROC_READDIRPLUS]++; - mb = mreq = nfsm_reqhead(NFSX_FH(1) + 6 * NFSX_UNSIGNED); - nfsm_fhtom(&mb, vp, 1); - tl = nfsm_build(&mb, 6 * NFSX_UNSIGNED); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(1) + 6 * NFSX_UNSIGNED); + nfsm_fhtom(&info.nmi_mb, vp, 1); + tl = nfsm_build(&info.nmi_mb, 6 * NFSX_UNSIGNED); *tl++ = cookie.nfsuquad[0]; *tl++ = cookie.nfsuquad[1]; if (cookie.nfsuquad[0] == 0 && @@ -2308,11 +2359,12 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, *tl++ = txdr_unsigned(nmp->nm_readdirsize); *tl = txdr_unsigned(nmp->nm_rsize); - error = nfs_request(vp, mreq, NFSPROC_READDIRPLUS, - uiop->uio_procp, cred, &mrep, &md, &dpos); + info.nmi_procp = uiop->uio_procp; + info.nmi_cred = cred; + error = nfs_request(vp, NFSPROC_READDIRPLUS, &info); nfsm_postop_attr(vp, attrflag); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } @@ -2328,7 +2380,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, len = fxdr_unsigned(int, *(tl + 2)); if (len <= 0 || len > NFS_MAXNAMLEN) { error = EBADRPC; - m_freem(mrep); + m_freem(info.nmi_mrep); goto nfsmout; } tlen = nfsm_rndup(len + 1); @@ -2384,8 +2436,8 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, */ attrflag = fxdr_unsigned(int, *tl); if (attrflag) { - dpossav1 = dpos; - mdsav1 = md; + dpossav1 = info.nmi_dpos; + mdsav1 = info.nmi_md; nfsm_adv(NFSX_V3FATTR); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); doit = fxdr_unsigned(int, *tl); @@ -2405,13 +2457,13 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, } } if (doit && bigenough) { - dpossav2 = dpos; - dpos = dpossav1; - mdsav2 = md; - md = mdsav1; + dpossav2 = info.nmi_dpos; + info.nmi_dpos = dpossav1; + mdsav2 = info.nmi_md; + info.nmi_md = mdsav1; nfsm_loadattr(newvp, NULL); - dpos = dpossav2; - md = mdsav2; + info.nmi_dpos = dpossav2; + info.nmi_md = mdsav2; dp->d_type = IFTODT(VTTOIF(np->n_vattr.va_type)); if (cnp->cn_namelen <= NCHNAMLEN) { @@ -2444,7 +2496,7 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); more_dirs = (fxdr_unsigned(int, *tl) == 0); } - m_freem(mrep); + m_freem(info.nmi_mrep); } /* * Fill last record, iff any, out to a multiple of NFS_READDIRBLKSIZ @@ -2555,31 +2607,33 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) struct proc *procp; struct nfsnode **npp; { + struct nfsm_info info; u_int32_t *tl; int32_t t1; struct vnode *newvp = NULL; struct nfsnode *np, *dnp = VTONFS(dvp); - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, fhlen, attrflag; - struct mbuf *mreq, *mrep, *md, *mb; nfsfh_t *nfhp; - int v3 = NFS_ISV3(dvp); + + info.nmi_v3 = NFS_ISV3(dvp); nfsstats.rpccnt[NFSPROC_LOOKUP]++; - mb = mreq = nfsm_reqhead(NFSX_FH(v3) + NFSX_UNSIGNED + + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(info.nmi_v3) + NFSX_UNSIGNED + nfsm_rndup(len)); - nfsm_fhtom(&mb, dvp, v3); + nfsm_fhtom(&info.nmi_mb, dvp, info.nmi_v3); nfsm_strtom(name, len, NFS_MAXNAMLEN); - error = nfs_request(dvp, mreq, NFSPROC_LOOKUP, procp, cred, &mrep, - &md, &dpos); - if (error && !v3) { - m_freem(mrep); + info.nmi_procp = procp; + info.nmi_cred = cred; + error = nfs_request(dvp, NFSPROC_LOOKUP, &info); + if (error && !info.nmi_v3) { + m_freem(info.nmi_mrep); goto nfsmout; } if (npp && !error) { - nfsm_getfh(nfhp, fhlen, v3); + nfsm_getfh(nfhp, fhlen, info.nmi_v3); if (*npp) { np = *npp; np->n_fhp = &np->n_fh; @@ -2593,22 +2647,22 @@ nfs_lookitup(dvp, name, len, cred, procp, npp) } else { error = nfs_nget(dvp->v_mount, nfhp, fhlen, &np); if (error) { - m_freem(mrep); + m_freem(info.nmi_mrep); return (error); } newvp = NFSTOV(np); } - if (v3) { + if (info.nmi_v3) { nfsm_postop_attr(newvp, attrflag); if (!attrflag && *npp == NULL) { - m_freem(mrep); + m_freem(info.nmi_mrep); vrele(newvp); return (ENOENT); } } else nfsm_loadattr(newvp, NULL); } - m_freem(mrep); + m_freem(info.nmi_mrep); nfsmout: if (npp && *npp == NULL) { if (error) { @@ -2630,27 +2684,27 @@ nfs_commit(vp, offset, cnt, procp) int cnt; struct proc *procp; { + struct nfsm_info info; u_int32_t *tl; int32_t t1; struct nfsmount *nmp = VFSTONFS(vp->v_mount); - caddr_t dpos, cp2; + caddr_t cp2; int error = 0, wccflag = NFSV3_WCCRATTR; - struct mbuf *mreq, *mrep, *md, *mb; if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0) return (0); nfsstats.rpccnt[NFSPROC_COMMIT]++; - mb = mreq = nfsm_reqhead(NFSX_FH(1)); - nfsm_fhtom(&mb, vp, 1); + info.nmi_mb = info.nmi_mreq = nfsm_reqhead(NFSX_FH(1)); + nfsm_fhtom(&info.nmi_mb, vp, 1); - tl = nfsm_build(&mb, 3 * NFSX_UNSIGNED); + tl = nfsm_build(&info.nmi_mb, 3 * NFSX_UNSIGNED); txdr_hyper(offset, tl); tl += 2; *tl = txdr_unsigned(cnt); - error = nfs_request(vp, mreq, NFSPROC_COMMIT, procp, - VTONFS(vp)->n_wcred, &mrep, &md, &dpos); - + info.nmi_procp = procp; + info.nmi_cred = VTONFS(vp)->n_wcred; + error = nfs_request(vp, NFSPROC_COMMIT, &info); nfsm_wcc_data(vp, wccflag); if (!error) { @@ -2662,7 +2716,8 @@ nfs_commit(vp, offset, cnt, procp) error = NFSERR_STALEWRITEVERF; } } - m_freem(mrep); + m_freem(info.nmi_mrep); + nfsmout: return (error); } diff --git a/sys/nfs/nfsm_subs.h b/sys/nfs/nfsm_subs.h index e278ad676cd..e26f101a9df 100644 --- a/sys/nfs/nfsm_subs.h +++ b/sys/nfs/nfsm_subs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsm_subs.h,v 1.40 2009/07/30 14:04:28 thib Exp $ */ +/* $OpenBSD: nfsm_subs.h,v 1.41 2009/08/04 17:12:39 thib Exp $ */ /* $NetBSD: nfsm_subs.h,v 1.10 1996/03/20 21:59:56 fvdl Exp $ */ /* @@ -40,42 +40,35 @@ #define _NFS_NFSM_SUBS_H_ -/* - * These macros do strange and peculiar things to mbuf chains for - * the assistance of the nfs code. To attempt to use them for any - * other purpose will be dangerous. (they make weird assumptions) - */ +#define NFSMSIZ(m) (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \ + (((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN)) -/* - * First define what the actual subs. return - */ +struct nfsm_info { + struct mbuf *nmi_mreq; + struct mbuf *nmi_mrep; -#define M_HASCL(m) ((m)->m_flags & M_EXT) -#define NFSMSIZ(m) ((M_HASCL(m)) ? (m)->m_ext.ext_size : \ - (((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN)) + struct proc *nmi_procp; /* XXX XXX XXX */ + struct ucred *nmi_cred; /* XXX XXX XXX */ -/* - * Now for the macros that do the simple stuff and call the functions - * for the hard stuff. - * These macros use several vars. declared in nfsm_reqhead and these - * vars. must not be used elsewhere unless you are careful not to corrupt - * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries - * that may be used so long as the value is not expected to retained - * after a macro. - * I know, this is kind of dorkey, but it makes the actual op functions - * fairly clean and deals with the mess caused by the xdr discriminating - * unions. - */ + /* Setting up / Tearing down. */ + struct mbuf *nmi_md; + struct mbuf *nmi_mb; + caddr_t nmi_dpos; + + int nmi_v3; +}; #define nfsm_dissect(a, c, s) { \ - t1 = mtod(md, caddr_t)+md->m_len-dpos; \ + t1 = mtod(info.nmi_md, caddr_t) + info.nmi_md->m_len - \ + info.nmi_dpos; \ if (t1 >= (s)) { \ - (a) = (c)(dpos); \ - dpos += (s); \ + (a) = (c)(info.nmi_dpos); \ + info.nmi_dpos += (s); \ } else if ((t1 = \ - nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0) { \ + nfsm_disct(&info.nmi_md, &info.nmi_dpos, (s), t1, \ + &cp2)) != 0) { \ error = t1; \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ goto nfsmout; \ } else { \ (a) = (c)cp2; \ @@ -83,7 +76,7 @@ } #define nfsm_srvpostop_fh(f) { \ - tl = nfsm_build(&mb, 2 * NFSX_UNSIGNED + NFSX_V3FH); \ + tl = nfsm_build(&info.nmi_mb, 2 * NFSX_UNSIGNED + NFSX_V3FH); \ *tl++ = nfs_true; \ *tl++ = txdr_unsigned(NFSX_V3FH); \ bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \ @@ -101,7 +94,7 @@ if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \ &ttnp)) != 0) { \ error = t1; \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ goto nfsmout; \ } \ (v) = NFSTOV(ttnp); \ @@ -122,7 +115,7 @@ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \ (s) > NFSX_V3FHMAX) { \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ error = EBADRPC; \ goto nfsmout; \ } \ @@ -133,23 +126,24 @@ #define nfsm_loadattr(v, a) { \ struct vnode *ttvp = (v); \ - if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \ + if ((t1 = nfs_loadattrcache(&ttvp, &info.nmi_md, \ + &info.nmi_dpos, (a))) != 0) { \ error = t1; \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ goto nfsmout; \ } \ (v) = ttvp; \ } -#define nfsm_postop_attr(v, f) { if (mrep != NULL) { \ +#define nfsm_postop_attr(v, f) { if (info.nmi_mrep != NULL) { \ struct vnode *ttvp = (v); \ nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \ if (((f) = fxdr_unsigned(int, *tl)) != 0) { \ - if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \ - NULL)) != 0) { \ + if ((t1 = nfs_loadattrcache(&ttvp, &info.nmi_md, \ + &info.nmi_dpos, NULL)) != 0) { \ error = t1; \ (f) = 0; \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ goto nfsmout; \ } \ (v) = ttvp; \ @@ -160,7 +154,7 @@ #define NFSV3_WCCRATTR 0 #define NFSV3_WCCCHK 1 -#define nfsm_wcc_data(v, f) do { if (mrep != NULL) { \ +#define nfsm_wcc_data(v, f) do { if (info.nmi_mrep != NULL) { \ struct timespec _mtime; \ int ttattrf, ttretf = 0; \ \ @@ -184,7 +178,7 @@ #define nfsm_strsiz(s,m) { \ nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \ if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ error = EBADRPC; \ goto nfsmout; \ } \ @@ -202,9 +196,10 @@ #define nfsm_mtouio(p,s) \ if ((s) > 0 && \ - (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \ + (t1 = nfsm_mbuftouio(&info.nmi_md,(p),(s), \ + &info.nmi_dpos)) != 0) { \ error = t1; \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ goto nfsmout; \ } @@ -212,25 +207,24 @@ #define nfsm_strtom(a,s,m) \ if ((s) > (m)) { \ - m_freem(mreq); \ + m_freem(info.nmi_mreq); \ error = ENAMETOOLONG; \ goto nfsmout; \ } \ - nfsm_strtombuf(&mb, (a), (s)) + nfsm_strtombuf(&info.nmi_mb, (a), (s)) #define nfsm_reply(s) { \ nfsd->nd_repstat = error; \ if (error && !(nfsd->nd_flag & ND_NFSV3)) \ (void) nfs_rephead(0, nfsd, slp, error, \ - mrq, &mb); \ + &info.nmi_mreq, &info.nmi_mb); \ else \ (void) nfs_rephead((s), nfsd, slp, error, \ - mrq, &mb); \ - if (mrep != NULL) { \ - m_freem(mrep); \ - mrep = NULL; \ + &info.nmi_mreq, &info.nmi_mb); \ + if (info.nmi_mrep != NULL) { \ + m_freem(info.nmi_mrep); \ + info.nmi_mrep = NULL; \ } \ - mreq = *mrq; \ if (error && (!(nfsd->nd_flag & ND_NFSV3) || error == EBADRPC)) \ return(0); \ } @@ -238,18 +232,22 @@ #define nfsm_writereply(s, v3) { \ nfsd->nd_repstat = error; \ if (error && !(v3)) \ - (void) nfs_rephead(0, nfsd, slp, error, &mreq, &mb); \ + (void) nfs_rephead(0, nfsd, slp, error, &info.nmi_mreq, \ + &info.nmi_mb); \ else \ - (void) nfs_rephead((s), nfsd, slp, error, &mreq, &mb); \ + (void) nfs_rephead((s), nfsd, slp, error, &info.nmi_mreq, \ + &info.nmi_mb); \ } #define nfsm_adv(s) { \ - t1 = mtod(md, caddr_t)+md->m_len-dpos; \ + t1 = mtod(info.nmi_md, caddr_t) + info.nmi_md->m_len - \ + info.nmi_dpos; \ if (t1 >= (s)) { \ - dpos += (s); \ - } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \ + info.nmi_dpos += (s); \ + } else if ((t1 = nfs_adv(&info.nmi_md, &info.nmi_dpos, \ + (s), t1)) != 0) { \ error = t1; \ - m_freem(mrep); \ + m_freem(info.nmi_mrep); \ goto nfsmout; \ } \ } |