summaryrefslogtreecommitdiffstats
path: root/sys/nfsserver
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2010-02-09 23:45:14 +0000
committermarius <marius@FreeBSD.org>2010-02-09 23:45:14 +0000
commitefffc45c735166ffa1717576e4807cba15304cad (patch)
tree7818cc46c36d665fc28d90982bdd75b487296427 /sys/nfsserver
parent8c1dfdc492d1c6bd09a599013e66bb05a06a1d5c (diff)
downloadFreeBSD-src-efffc45c735166ffa1717576e4807cba15304cad.zip
FreeBSD-src-efffc45c735166ffa1717576e4807cba15304cad.tar.gz
- Move nfs_realign() from the NFS client to the shared NFS code and
remove the NFS server version in order to reduce code duplication. The shared version now uses a second parameter how, which is passed on to m_get(9) and m_getcl(9) as the server used M_WAIT while the client requires M_DONTWAIT, and replaces the the previously unused parameter hsiz. - Change nfs_realign() to use nfsm_aligned() so as with other NFS code the alignment check isn't actually performed on platforms without strict alignment requirements for performance reasons because as the comment suggests unaligned data only occasionally occurs with TCP. - Change fha_extract_info() to use nfs_realign() with M_DONTWAIT rather than M_WAIT because it's called with the RPC sp_lock held. Reviewed by: jhb, rmacklem MFC after: 1 week
Diffstat (limited to 'sys/nfsserver')
-rw-r--r--sys/nfsserver/nfs.h1
-rw-r--r--sys/nfsserver/nfs_fha.c4
-rw-r--r--sys/nfsserver/nfs_srvkrpc.c59
3 files changed, 4 insertions, 60 deletions
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h
index 00dbe5b..bb1893e 100644
--- a/sys/nfsserver/nfs.h
+++ b/sys/nfsserver/nfs.h
@@ -239,7 +239,6 @@ extern int nfs_debug;
#endif
-void nfs_realign(struct mbuf **);
struct mbuf *nfs_rephead(int, struct nfsrv_descript *, int, struct mbuf **,
caddr_t *);
void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
diff --git a/sys/nfsserver/nfs_fha.c b/sys/nfsserver/nfs_fha.c
index 25e930f..76537d7 100644
--- a/sys/nfsserver/nfs_fha.c
+++ b/sys/nfsserver/nfs_fha.c
@@ -202,7 +202,9 @@ fha_extract_info(struct svc_req *req, struct fha_info *i)
procnum == NFSPROC_NULL)
goto out;
- nfs_realign(&req->rq_args);
+ error = nfs_realign(&req->rq_args, M_DONTWAIT);
+ if (error)
+ goto out;
md = req->rq_args;
dpos = mtod(md, caddr_t);
diff --git a/sys/nfsserver/nfs_srvkrpc.c b/sys/nfsserver/nfs_srvkrpc.c
index bdfe424..512373b 100644
--- a/sys/nfsserver/nfs_srvkrpc.c
+++ b/sys/nfsserver/nfs_srvkrpc.c
@@ -96,8 +96,6 @@ SYSCTL_DECL(_vfs_nfsrv);
SVCPOOL *nfsrv_pool;
int nfsd_waiting = 0;
int nfsrv_numnfsd = 0;
-static int nfs_realign_test;
-static int nfs_realign_count;
struct callout nfsrv_callout;
static eventhandler_tag nfsrv_nmbclusters_tag;
@@ -111,10 +109,6 @@ SYSCTL_INT(_vfs_nfsrv, OID_AUTO, gatherdelay, CTLFLAG_RW,
SYSCTL_INT(_vfs_nfsrv, OID_AUTO, gatherdelay_v3, CTLFLAG_RW,
&nfsrvw_procrastinate_v3, 0,
"Delay in seconds for NFSv3 write gathering");
-SYSCTL_INT(_vfs_nfsrv, OID_AUTO, realign_test, CTLFLAG_RW,
- &nfs_realign_test, 0, "");
-SYSCTL_INT(_vfs_nfsrv, OID_AUTO, realign_count, CTLFLAG_RW,
- &nfs_realign_count, 0, "");
static int nfssvc_addsock(struct file *, struct thread *);
static int nfssvc_nfsd(struct thread *, struct nfsd_nfsd_args *);
@@ -250,57 +244,6 @@ nfs_rephead(int siz, struct nfsrv_descript *nd, int err,
return (mreq);
}
-/*
- * nfs_realign:
- *
- * Check for badly aligned mbuf data and realign by copying the unaligned
- * portion of the data into a new mbuf chain and freeing the portions
- * of the old chain that were replaced.
- *
- * We cannot simply realign the data within the existing mbuf chain
- * because the underlying buffers may contain other rpc commands and
- * we cannot afford to overwrite them.
- *
- * We would prefer to avoid this situation entirely. The situation does
- * not occur with NFS/UDP and is supposed to only occassionally occur
- * with TCP. Use vfs.nfs.realign_count and realign_test to check this.
- */
-void
-nfs_realign(struct mbuf **pm) /* XXX COMMON */
-{
- struct mbuf *m;
- struct mbuf *n = NULL;
- int off = 0;
-
- ++nfs_realign_test;
- while ((m = *pm) != NULL) {
- if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
- MGET(n, M_WAIT, MT_DATA);
- if (m->m_len >= MINCLSIZE) {
- MCLGET(n, M_WAIT);
- }
- n->m_len = 0;
- break;
- }
- pm = &m->m_next;
- }
-
- /*
- * If n is non-NULL, loop on m copying data, then replace the
- * portion of the chain that had to be realigned.
- */
- if (n != NULL) {
- ++nfs_realign_count;
- while (m) {
- m_copyback(n, off, m->m_len, mtod(m, caddr_t));
- off += m->m_len;
- m = m->m_next;
- }
- m_freem(*pm);
- *pm = n;
- }
-}
-
static void
nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
{
@@ -334,7 +277,7 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
mreq = mrep = NULL;
mreq = rqst->rq_args;
rqst->rq_args = NULL;
- nfs_realign(&mreq);
+ (void)nfs_realign(&mreq, M_WAIT);
/*
* Note: we want rq_addr, not svc_getrpccaller for nd_nam2 -
OpenPOWER on IntegriCloud