diff options
author | dfr <dfr@FreeBSD.org> | 2009-06-30 19:03:27 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2009-06-30 19:03:27 +0000 |
commit | 5d248bb05f33623d905b8b5a72d90e459d23be96 (patch) | |
tree | b34567acfe860cb1978c433954c8376efa8a9fbb /sys/nfsserver/nfs_serv.c | |
parent | 92b2f1511851bf5a137742d90131b79d0ff4c1ff (diff) | |
download | FreeBSD-src-5d248bb05f33623d905b8b5a72d90e459d23be96.zip FreeBSD-src-5d248bb05f33623d905b8b5a72d90e459d23be96.tar.gz |
Remove the old kernel RPC implementation and the NFS_LEGACYRPC option.
Approved by: re
Diffstat (limited to 'sys/nfsserver/nfs_serv.c')
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 424 |
1 files changed, 0 insertions, 424 deletions
diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index b6a61a8..00be15e 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -93,7 +93,6 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_object.h> #include <nfs/nfsproto.h> -#include <nfs/rpcv2.h> #include <nfsserver/nfs.h> #include <nfs/xdr_subs.h> #include <nfsserver/nfsm_subs.h> @@ -142,10 +141,6 @@ SYSCTL_STRUCT(_vfs_nfsrv, NFS_NFSRVSTATS, nfsrvstats, CTLFLAG_RW, static int nfsrv_access(struct vnode *, accmode_t, struct ucred *, int, int); -#ifdef NFS_LEGACYRPC -static void nfsrvw_coalesce(struct nfsrv_descript *, - struct nfsrv_descript *); -#endif /* * Clear nameidata fields that are tested in nsfmout cleanup code prior @@ -1229,425 +1224,6 @@ nfsmout: return(error); } -#ifdef NFS_LEGACYRPC - -/* - * XXX dfr - write gathering isn't supported by the new RPC code since - * its really only useful for NFSv2. If there is a real need, we could - * attempt to fit it into the filehandle affinity system, e.g. by - * looking to see if there are queued write requests that overlap this - * one. - */ - -/* - * For the purposes of write gathering, we must decide if the credential - * associated with two pending requests have equivilent privileges. Since - * NFS only uses a subset of the BSD ucred -- the effective uid and group - * IDs -- we have a compare routine that checks only the relevant fields. - */ -static int -nfsrv_samecred(struct ucred *cr1, struct ucred *cr2) -{ - int i; - - if (cr1->cr_uid != cr2->cr_uid) - return (0); - if (cr1->cr_ngroups != cr2->cr_ngroups) - return (0); - for (i = 0; i < cr1->cr_ngroups; i++) { - if (cr1->cr_groups[i] != cr2->cr_groups[i]) - return (0); - } - return (1); -} - -/* - * NFS write service with write gathering support. Called when - * nfsrvw_procrastinate > 0. - * See: Chet Juszczak, "Improving the Write Performance of an NFS Server", - * in Proc. of the Winter 1994 Usenix Conference, pg. 247-259, San Franscisco, - * Jan. 1994. - */ -int -nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, - struct mbuf **mrq) -{ - struct iovec *ivp; - struct mbuf *mp; - struct nfsrv_descript *wp, *nfsd, *owp, *swp; - struct nfs_fattr *fp; - int i; - struct iovec *iov; - struct nfsrvw_delayhash *wpp; - struct ucred *cred; - struct vattr va, forat; - u_int32_t *tl; - caddr_t bpos, dpos; - int error = 0, rdonly, len, forat_ret = 1; - int ioflags, aftat_ret = 1, s, adjust, v3, zeroing; - struct mbuf *mb, *mreq, *mrep, *md; - struct vnode *vp = NULL; - struct uio io, *uiop = &io; - u_quad_t cur_usec; - struct mount *mntp = NULL; - int mvfslocked; - int vfslocked; - - nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); -#ifndef nolint - i = 0; - len = 0; -#endif - vfslocked = 0; - *mrq = NULL; - if (*ndp) { - nfsd = *ndp; - *ndp = NULL; - mrep = nfsd->nd_mrep; - md = nfsd->nd_md; - dpos = nfsd->nd_dpos; - cred = nfsd->nd_cr; - v3 = (nfsd->nd_flag & ND_NFSV3); - LIST_INIT(&nfsd->nd_coalesce); - nfsd->nd_mreq = NULL; - nfsd->nd_stable = NFSV3WRITE_FILESYNC; - cur_usec = nfs_curusec(); - nfsd->nd_time = cur_usec + - (v3 ? nfsrvw_procrastinate_v3 : nfsrvw_procrastinate); - - /* - * Now, get the write header.. - */ - nfsm_srvmtofh(&nfsd->nd_fh); - if (v3) { - tl = nfsm_dissect_nonblock(u_int32_t *, 5 * NFSX_UNSIGNED); - nfsd->nd_off = fxdr_hyper(tl); - tl += 3; - nfsd->nd_stable = fxdr_unsigned(int, *tl++); - } else { - tl = nfsm_dissect_nonblock(u_int32_t *, 4 * NFSX_UNSIGNED); - nfsd->nd_off = (off_t)fxdr_unsigned(u_int32_t, *++tl); - tl += 2; - if (nfs_async) - nfsd->nd_stable = NFSV3WRITE_UNSTABLE; - } - len = fxdr_unsigned(int32_t, *tl); - nfsd->nd_len = len; - nfsd->nd_eoff = nfsd->nd_off + len; - - /* - * Trim the header out of the mbuf list and trim off any trailing - * junk so that the mbuf list has only the write data. - */ - zeroing = 1; - i = 0; - mp = mrep; - while (mp) { - if (mp == md) { - zeroing = 0; - adjust = dpos - mtod(mp, caddr_t); - mp->m_len -= adjust; - if (mp->m_len > 0 && adjust > 0) - mp->m_data += adjust; - } - if (zeroing) - mp->m_len = 0; - else { - i += mp->m_len; - if (i > len) { - mp->m_len -= (i - len); - zeroing = 1; - } - } - mp = mp->m_next; - } - if (len > NFS_MAXDATA || len < 0 || i < len) { -nfsmout: - m_freem(mrep); - error = EIO; - nfsm_writereply(2 * NFSX_UNSIGNED); - if (v3) - nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); - nfsd->nd_mreq = mreq; - nfsd->nd_mrep = NULL; - nfsd->nd_time = 0; - } - - /* - * Add this entry to the hash and time queues. - */ - s = splsoftclock(); - owp = NULL; - wp = LIST_FIRST(&slp->ns_tq); - while (wp && wp->nd_time < nfsd->nd_time) { - owp = wp; - wp = LIST_NEXT(wp, nd_tq); - } - NFS_DPF(WG, ("Q%03x", nfsd->nd_retxid & 0xfff)); - if (owp) { - LIST_INSERT_AFTER(owp, nfsd, nd_tq); - } else { - LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); - } - if (nfsd->nd_mrep) { - wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_fid.fid_data); - owp = NULL; - wp = LIST_FIRST(wpp); - while (wp && - bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh, NFSX_V3FH)){ - owp = wp; - wp = LIST_NEXT(wp, nd_hash); - } - while (wp && wp->nd_off < nfsd->nd_off && - !bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh, NFSX_V3FH)) { - owp = wp; - wp = LIST_NEXT(wp, nd_hash); - } - if (owp) { - LIST_INSERT_AFTER(owp, nfsd, nd_hash); - - /* - * Search the hash list for overlapping entries and - * coalesce. - */ - for(; nfsd && NFSW_CONTIG(owp, nfsd); nfsd = wp) { - wp = LIST_NEXT(nfsd, nd_hash); - if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) - nfsrvw_coalesce(owp, nfsd); - } - } else { - LIST_INSERT_HEAD(wpp, nfsd, nd_hash); - } - } - splx(s); - } - - /* - * Now, do VOP_WRITE()s for any one(s) that need to be done now - * and generate the associated reply mbuf list(s). - */ -loop1: - cur_usec = nfs_curusec(); - s = splsoftclock(); - for (nfsd = LIST_FIRST(&slp->ns_tq); nfsd; nfsd = owp) { - owp = LIST_NEXT(nfsd, nd_tq); - if (nfsd->nd_time > cur_usec) - break; - if (nfsd->nd_mreq) - continue; - NFS_DPF(WG, ("P%03x", nfsd->nd_retxid & 0xfff)); - LIST_REMOVE(nfsd, nd_tq); - LIST_REMOVE(nfsd, nd_hash); - splx(s); - mrep = nfsd->nd_mrep; - nfsd->nd_mrep = NULL; - cred = nfsd->nd_cr; - v3 = (nfsd->nd_flag & ND_NFSV3); - forat_ret = aftat_ret = 1; - error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, &vfslocked, nfsd, - slp, nfsd->nd_nam, &rdonly, TRUE); - if (!error) { - if (v3) - forat_ret = VOP_GETATTR(vp, &forat, cred); - if (vp->v_type != VREG) { - if (v3) - error = EINVAL; - else - error = (vp->v_type == VDIR) ? EISDIR : EACCES; - } - } else { - vp = NULL; - } - if (!error) - error = nfsrv_access(vp, VWRITE, cred, rdonly, 1); - if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE) - ioflags = IO_NODELOCKED; - else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC) - ioflags = (IO_SYNC | IO_NODELOCKED); - else - ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); - uiop->uio_rw = UIO_WRITE; - uiop->uio_segflg = UIO_SYSSPACE; - uiop->uio_td = NULL; - uiop->uio_offset = nfsd->nd_off; - uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; - if (uiop->uio_resid > 0) { - mp = mrep; - i = 0; - while (mp) { - if (mp->m_len > 0) - i++; - mp = mp->m_next; - } - uiop->uio_iovcnt = i; - iov = malloc(i * sizeof (struct iovec), - M_TEMP, M_WAITOK); - uiop->uio_iov = ivp = iov; - mp = mrep; - while (mp) { - if (mp->m_len > 0) { - ivp->iov_base = mtod(mp, caddr_t); - ivp->iov_len = mp->m_len; - ivp++; - } - mp = mp->m_next; - } - mvfslocked = 0; - if (!error) { - if (vn_start_write(vp, &mntp, V_NOWAIT) != 0) { - VOP_UNLOCK(vp, 0); - error = vn_start_write(NULL, &mntp, V_WAIT); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - } - mvfslocked = VFS_LOCK_GIANT(mntp); - } - if (!error) { - error = VOP_WRITE(vp, uiop, ioflags, cred); - /* Unlocked write. */ - nfsrvstats.srvvop_writes++; - vn_finished_write(mntp); - } - VFS_UNLOCK_GIANT(mvfslocked); - free((caddr_t)iov, M_TEMP); - } - m_freem(mrep); - if (vp) { - aftat_ret = VOP_GETATTR(vp, &va, cred); - vput(vp); - vp = NULL; - } - VFS_UNLOCK_GIANT(vfslocked); - /* - * Loop around generating replies for all write rpcs that have - * now been completed. - */ - swp = nfsd; - do { - NFS_DPF(WG, ("R%03x", nfsd->nd_retxid & 0xfff)); - if (error) { - nfsm_writereply(NFSX_WCCDATA(v3)); - if (v3) { - nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); - } - } else { - nfsm_writereply(NFSX_PREOPATTR(v3) + - NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + - NFSX_WRITEVERF(v3)); - if (v3) { - nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); - tl = nfsm_build(u_int32_t *, 4 * NFSX_UNSIGNED); - *tl++ = txdr_unsigned(nfsd->nd_len); - *tl++ = txdr_unsigned(swp->nd_stable); - /* - * Actually, there is no need to txdr these fields, - * but it may make the values more human readable, - * for debugging purposes. - */ - if (nfsver.tv_sec == 0) - nfsver = boottime; - *tl++ = txdr_unsigned(nfsver.tv_sec); - *tl = txdr_unsigned(nfsver.tv_usec); - } else { - fp = nfsm_build(struct nfs_fattr *, NFSX_V2FATTR); - nfsm_srvfillattr(&va, fp); - } - } - nfsd->nd_mreq = mreq; - if (nfsd->nd_mrep) - panic("nfsrv_write: nd_mrep not free"); - - /* - * Done. Put it at the head of the timer queue so that - * the final phase can return the reply. - */ - s = splsoftclock(); - if (nfsd != swp) { - nfsd->nd_time = 0; - LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); - } - nfsd = LIST_FIRST(&swp->nd_coalesce); - if (nfsd) { - LIST_REMOVE(nfsd, nd_tq); - } - splx(s); - } while (nfsd); - s = splsoftclock(); - swp->nd_time = 0; - LIST_INSERT_HEAD(&slp->ns_tq, swp, nd_tq); - splx(s); - goto loop1; - } - splx(s); - - /* - * Search for a reply to return. - */ - s = splsoftclock(); - LIST_FOREACH(nfsd, &slp->ns_tq, nd_tq) - if (nfsd->nd_mreq) { - NFS_DPF(WG, ("X%03x", nfsd->nd_retxid & 0xfff)); - LIST_REMOVE(nfsd, nd_tq); - *mrq = nfsd->nd_mreq; - *ndp = nfsd; - break; - } - splx(s); - return (0); -} - -/* - * Coalesce the write request nfsd into owp. To do this we must: - * - remove nfsd from the queues - * - merge nfsd->nd_mrep into owp->nd_mrep - * - update the nd_eoff and nd_stable for owp - * - put nfsd on owp's nd_coalesce list - * NB: Must be called at splsoftclock(). - */ -static void -nfsrvw_coalesce(struct nfsrv_descript *owp, struct nfsrv_descript *nfsd) -{ - int overlap; - struct mbuf *mp; - struct nfsrv_descript *p; - - NFS_DPF(WG, ("C%03x-%03x", - nfsd->nd_retxid & 0xfff, owp->nd_retxid & 0xfff)); - LIST_REMOVE(nfsd, nd_hash); - LIST_REMOVE(nfsd, nd_tq); - if (owp->nd_eoff < nfsd->nd_eoff) { - overlap = owp->nd_eoff - nfsd->nd_off; - if (overlap < 0) - panic("nfsrv_coalesce: bad off"); - if (overlap > 0) - m_adj(nfsd->nd_mrep, overlap); - mp = owp->nd_mrep; - while (mp->m_next) - mp = mp->m_next; - mp->m_next = nfsd->nd_mrep; - owp->nd_eoff = nfsd->nd_eoff; - } else - m_freem(nfsd->nd_mrep); - nfsd->nd_mrep = NULL; - if (nfsd->nd_stable == NFSV3WRITE_FILESYNC) - owp->nd_stable = NFSV3WRITE_FILESYNC; - else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC && - owp->nd_stable == NFSV3WRITE_UNSTABLE) - owp->nd_stable = NFSV3WRITE_DATASYNC; - LIST_INSERT_HEAD(&owp->nd_coalesce, nfsd, nd_tq); - - /* - * If nfsd had anything else coalesced into it, transfer them - * to owp, otherwise their replies will never get sent. - */ - for (p = LIST_FIRST(&nfsd->nd_coalesce); p; - p = LIST_FIRST(&nfsd->nd_coalesce)) { - LIST_REMOVE(p, nd_tq); - LIST_INSERT_HEAD(&owp->nd_coalesce, p, nd_tq); - } -} - -#endif - /* * nfs create service * now does a truncate to 0 length via. setattr if it already exists |