summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBret Lambert <blambert@cvs.openbsd.org>2009-01-20 18:03:34 +0000
committerBret Lambert <blambert@cvs.openbsd.org>2009-01-20 18:03:34 +0000
commit199b082eead7dda7c0f57481e944a270935477e6 (patch)
treea61b815572628c8611a844732dc103484f610b14
parent0ea2cfe352f9f811345e1465032118052d284515 (diff)
Start reworking NFS client mbuf handling by creating an interface which
requires well-formed mbuf chains to work. Existing function name is now a wrapper to this interface. Much, much more work to follow which will build on this. Truly change we can believe in. ok thib@, who would have preferred this in two commits, but I'm impatient :) testing on multiple arches (i386, arm, amd64, and sparc64 at least) by many, thanks to all who did so
-rw-r--r--sys/nfs/nfs_socket.c55
-rw-r--r--sys/nfs/nfs_subs.c13
-rw-r--r--sys/nfs/nfs_var.h6
3 files changed, 44 insertions, 30 deletions
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 945c0cdcec2..4056cade7ed 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_socket.c,v 1.72 2009/01/16 17:11:28 thib Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.73 2009/01/20 18:03:33 blambert Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
@@ -816,35 +816,50 @@ nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
struct mbuf **mdp;
caddr_t *dposp;
{
- struct mbuf *m, *mrep;
+ struct mbuf *m;
struct nfsreq *rep;
- u_int32_t *tl;
- int i;
- struct nfsmount *nmp;
- struct mbuf *md;
- time_t waituntil;
- caddr_t dpos, cp2;
- int t1, s, error = 0, mrest_len;
- int trylater_delay;
-
- trylater_delay = NFS_MINTIMEO;
+ int mrest_len;
- nmp = VFSTONFS(vp->v_mount);
rep = pool_get(&nfsreqpl, PR_WAITOK);
- rep->r_nmp = nmp;
+ rep->r_nmp = VFSTONFS(vp->v_mount);
rep->r_vp = vp;
rep->r_procp = procp;
rep->r_procnum = procnum;
- i = 0;
+
+ mrest_len = 0;
m = mrest;
while (m) {
- i += m->m_len;
+ mrest_len += m->m_len;
m = m->m_next;
}
- mrest_len = i;
+
+ /* 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_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;
+ time_t waituntil;
+ 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, mrest, mrest_len);
+ nfsm_rpchead(rep, cred, RPCAUTH_UNIX);
m = rep->r_mreq;
/*
@@ -862,7 +877,7 @@ tryagain:
else
rep->r_retry = NFS_MAXREXMIT + 1; /* past clip limit */
rep->r_rtt = rep->r_rexmit = 0;
- if (proct[procnum] > 0)
+ if (proct[rep->r_procnum] > 0)
rep->r_flags = R_TIMING;
else
rep->r_flags = 0;
@@ -993,7 +1008,7 @@ tryagain:
* lookup cache, just in case.
*/
if (error == ESTALE)
- cache_purge(vp);
+ cache_purge(rep->r_vp);
if (nmp->nm_flag & NFSMNT_NFSV3 || error == ESTALE) {
*mrp = mrep;
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index abe420b74c5..da2c2b9158b 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_subs.c,v 1.90 2009/01/13 19:44:20 grange Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.91 2009/01/20 18:03:33 blambert Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
@@ -561,8 +561,7 @@ nfs_get_xid(void)
* other authorization methods, such as Kerberos.
*/
void
-nfsm_rpchead(struct nfsreq *req, struct ucred *cr, int auth_type,
- struct mbuf *mrest, int mrest_len)
+nfsm_rpchead(struct nfsreq *req, struct ucred *cr, int auth_type)
{
struct mbuf *mb;
u_int32_t *tl;
@@ -572,10 +571,10 @@ nfsm_rpchead(struct nfsreq *req, struct ucred *cr, int auth_type,
/*
* RPCAUTH_UNIX fits in an hdr mbuf, in the future other
- * authorization methods need to figure out there own sizes
+ * authorization methods need to figure out their own sizes
* and allocate and chain mbuf's accorindgly.
*/
- MGETHDR(mb, M_WAIT, MT_DATA);
+ mb = req->r_mreq;
/*
* We need to start out by finding how big the authorization cred
@@ -640,10 +639,8 @@ nfsm_rpchead(struct nfsreq *req, struct ucred *cr, int auth_type,
break;
}
- mb->m_next = mrest;
- mb->m_pkthdr.len = authsiz + 10 * NFSX_UNSIGNED + mrest_len;
+ mb->m_pkthdr.len += authsiz + 10 * NFSX_UNSIGNED;
mb->m_pkthdr.rcvif = NULL;
- req->r_mreq = mb;
}
/*
diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h
index e2b886a0e5e..6ebd5314ceb 100644
--- a/sys/nfs/nfs_var.h
+++ b/sys/nfs/nfs_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_var.h,v 1.47 2009/01/18 21:04:41 blambert Exp $ */
+/* $OpenBSD: nfs_var.h,v 1.48 2009/01/20 18:03:33 blambert Exp $ */
/* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */
/*
@@ -187,6 +187,8 @@ 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_rephead(int, struct nfsrv_descript *, struct nfssvc_sock *, int,
struct mbuf **, struct mbuf **);
void nfs_timer(void *);
@@ -213,7 +215,7 @@ void nfsrv_cleancache(void);
/* nfs_subs.c */
struct mbuf *nfsm_reqhead(int);
u_int32_t nfs_get_xid(void);
-void nfsm_rpchead(struct nfsreq *, struct ucred *, int, struct mbuf *, int);
+void nfsm_rpchead(struct nfsreq *, struct ucred *, int);
void *nfsm_build(struct mbuf **, u_int);
int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
void nfsm_uiotombuf(struct mbuf **, struct uio *, size_t);