Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Dec 2011 02:08:51 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r229064 - in projects/nfsv4.1-client/sys/fs: nfs nfsclient nfsserver
Message-ID:  <201112310208.pBV28p2h041664@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Sat Dec 31 02:08:51 2011
New Revision: 229064
URL: http://svn.freebsd.org/changeset/base/229064

Log:
  Add an optional argument to newnfs_request() that is a pointer to
  the new session structure. If this argument is NULL, it will use
  the default session structure in the nfsclclient structure. This
  prepares the code to be used for Data Server sessions as well as
  the default Metadata Server session.

Modified:
  projects/nfsv4.1-client/sys/fs/nfs/nfs_commonkrpc.c
  projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c
  projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h
  projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clport.c
  projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c
  projects/nfsv4.1-client/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: projects/nfsv4.1-client/sys/fs/nfs/nfs_commonkrpc.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_commonkrpc.c	Sat Dec 31 01:33:25 2011	(r229063)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_commonkrpc.c	Sat Dec 31 02:08:51 2011	(r229064)
@@ -491,7 +491,7 @@ int
 newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp,
     struct nfsclient *clp, struct nfssockreq *nrp, vnode_t vp,
     struct thread *td, struct ucred *cred, u_int32_t prog, u_int32_t vers,
-    u_char *retsum, int toplevel, u_int64_t *xidp)
+    u_char *retsum, int toplevel, u_int64_t *xidp, struct nfsclsession *sep)
 {
 	u_int32_t retseq, retval, *tl;
 	time_t waituntil;
@@ -785,6 +785,9 @@ tryagain:
 	nd->nd_dpos = NFSMTOD(nd->nd_md, caddr_t);
 	nd->nd_repstat = 0;
 	if (nd->nd_procnum != NFSPROC_NULL) {
+		/* If sep == NULL, set it to the default in nfsclclient. */
+		if (sep == NULL && nmp != NULL && nmp->nm_clp != NULL)
+			sep = &nmp->nm_clp->nfsc_sess;
 		/*
 		 * and now the actual NFS xdr.
 		 */
@@ -814,19 +817,19 @@ if (nmp != NULL && i == NFSV4OP_SEQUENCE
 			if (nmp != NULL && i == NFSV4OP_SEQUENCE && j == 0) {
 				NFSM_DISSECT(tl, uint32_t *, NFSX_V4SESSIONID +
 				    5 * NFSX_UNSIGNED);
-				NFSLOCKMNT(nmp);
+				mtx_lock(&sep->nfsess_mtx);
 				tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
 				retseq = fxdr_unsigned(uint32_t, *tl++);
 				slot = fxdr_unsigned(int, *tl++);
 				freeslot = slot;
-				if (retseq != nmp->nm_slotseq[slot])
+				if (retseq != sep->nfsess_slotseq[slot])
 					printf("retseq diff 0x%x\n", retseq);
 				retval = fxdr_unsigned(uint32_t, *++tl);
 #ifdef notyet
-				if ((retval + 1) < nmp->nm_foreslots)
-					nmp->nm_foreslots = (retval + 1);
-				else if ((retval + 1) > nmp->nm_foreslots)
-					nmp->nm_foreslots = (retval < 64) ?
+				if ((retval + 1) < sep->nfsess_foreslots)
+					sep->nfsess_foreslots = (retval + 1);
+				else if ((retval + 1) > sep->nfsess_foreslots)
+					sep->nfsess_foreslots = (retval < 64) ?
 					    (retval + 1) : 64;
 #else
 				/*
@@ -837,24 +840,24 @@ if (nmp != NULL && i == NFSV4OP_SEQUENCE
 				 * In other words, is it N or N-1?
 				 * For now, play it safe and assume the
 				 * worst cases of the above, such that
-				 * nm_foreslots might be one less than the
+				 * nfsess_foreslots might be one less than the
 				 * server specified. This is safe, whereas
-				 * setting nm_foreslots one greater than
+				 * setting nfsess_foreslots one greater than
 				 * the server intended could cause grief.
 				 */
-				if (retval < nmp->nm_foreslots)
+				if (retval < sep->nfsess_foreslots)
 {
 printf("foreslots shrinking %d\n", retval);
-					nmp->nm_foreslots = retval;
+					sep->nfsess_foreslots = retval;
 }
-				else if (retval > nmp->nm_foreslots)
+				else if (retval > sep->nfsess_foreslots)
 {
 printf("foreslots growing %d\n", retval);
-					nmp->nm_foreslots = (retval < 64) ?
+					sep->nfsess_foreslots = (retval < 64) ?
 					    retval : 64;
 }
 #endif	/* notyet */
-				NFSUNLOCKMNT(nmp);
+				mtx_unlock(&sep->nfsess_mtx);
 
 				/* Grab the op and status for the next one. */
 				if (opcnt > 1) {
@@ -890,11 +893,11 @@ printf("foreslots growing %d\n", retval)
 					(void) nfs_catnap(PZERO, 0, "nfstry");
 				trylater_delay *= 2;
 				if (slot != -1) {
-					NFSLOCKMNT(nmp);
-					nmp->nm_slotseq[slot]++;
+					mtx_lock(&sep->nfsess_mtx);
+					sep->nfsess_slotseq[slot]++;
 					*nd->nd_slotseq = txdr_unsigned(
-					    nmp->nm_slotseq[slot]);
-					NFSUNLOCKMNT(nmp);
+					    sep->nfsess_slotseq[slot]);
+					mtx_unlock(&sep->nfsess_mtx);
 				}
 				m_freem(nd->nd_mrep);
 				nd->nd_mrep = NULL;
@@ -915,7 +918,7 @@ printf("foreslots growing %d\n", retval)
 		if ((nd->nd_flag & ND_NFSV4) != 0) {
 			/* Free the slot, as required. */
 			if (freeslot != -1)
-				nfscl_freeslot(nmp, freeslot);
+				nfsv4_freeslot(sep, freeslot);
 			/*
 			 * If this op is Putfh, throw its results away.
 			 */

Modified: projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c	Sat Dec 31 01:33:25 2011	(r229063)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c	Sat Dec 31 02:08:51 2011	(r229064)
@@ -3003,7 +3003,7 @@ nfsrv_getuser(int procnum, uid_t uid, gi
 		(void) nfsm_strtom(nd, name, len);
 	}
 	error = newnfs_request(nd, NULL, NULL, &nfsrv_nfsuserdsock, NULL, NULL,
-		cred, RPCPROG_NFSUSERD, RPCNFSUSERD_VERS, NULL, 0, NULL);
+		cred, RPCPROG_NFSUSERD, RPCNFSUSERD_VERS, NULL, 0, NULL, NULL);
 	NFSFREECRED(cred);
 	if (!error) {
 		mbuf_freem(nd->nd_mrep);

Modified: projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h	Sat Dec 31 01:33:25 2011	(r229063)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h	Sat Dec 31 02:08:51 2011	(r229064)
@@ -599,7 +599,8 @@ void newnfs_restore_sigmask(struct threa
 int newnfs_msleep(struct thread *, void *, struct mtx *, int, char *, int);
 int newnfs_request(struct nfsrv_descript *, struct nfsmount *,
     struct nfsclient *, struct nfssockreq *, vnode_t, NFSPROC_T *,
-    struct ucred *, u_int32_t, u_int32_t, u_char *, int, u_int64_t *);
+    struct ucred *, u_int32_t, u_int32_t, u_char *, int, u_int64_t *,
+    struct nfsclsession *);
 int newnfs_connect(struct nfsmount *, struct nfssockreq *,
     struct ucred *, NFSPROC_T *, int);
 void newnfs_disconnect(struct nfssockreq *);

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clport.c	Sat Dec 31 01:33:25 2011	(r229063)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clport.c	Sat Dec 31 02:08:51 2011	(r229064)
@@ -857,7 +857,7 @@ nfscl_request(struct nfsrv_descript *nd,
 	else
 		vers = NFS_VER2;
 	ret = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, vp, p, cred,
-		NFS_PROG, vers, NULL, 1, NULL);
+		NFS_PROG, vers, NULL, 1, NULL, NULL);
 	return (ret);
 }
 

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c	Sat Dec 31 01:33:25 2011	(r229063)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c	Sat Dec 31 02:08:51 2011	(r229064)
@@ -377,7 +377,7 @@ nfsrpc_openrpc(struct nfsmount *nmp, vno
 	if (syscred)
 		nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, vp, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	NFSCL_INCRSEQID(op->nfso_own->nfsow_seqid, nd);
@@ -697,7 +697,7 @@ nfsrpc_closerpc(struct nfsrv_descript *n
 	if (syscred)
 		nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	NFSCL_INCRSEQID(op->nfso_own->nfsow_seqid, nd);
@@ -835,7 +835,7 @@ if (error) printf("aft crs=%d\n",error);
 	*tl = txdr_unsigned(clp->nfsc_cbident);
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-		NFS_PROG, NFS_VER4, NULL, 1, NULL);
+		NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	if (nd->nd_repstat == 0) {
@@ -859,7 +859,7 @@ if (error) printf("aft crs=%d\n",error);
 	    *tl = confirm.lval[1];
 	    nd->nd_flag |= ND_USEGSSNAME;
 	    error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p,
-		cred, NFS_PROG, NFS_VER4, NULL, 1, NULL);
+		cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	    if (error)
 		return (error);
 	    mbuf_freem(nd->nd_mrep);
@@ -872,7 +872,7 @@ if (error) printf("aft crs=%d\n",error);
 		(void) nfsrv_putattrbit(nd, &attrbits);
 		nd->nd_flag |= ND_USEGSSNAME;
 		error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p,
-		    cred, NFS_PROG, NFS_VER4, NULL, 1, NULL);
+		    cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 		if (error)
 		    return (error);
 		if (nd->nd_repstat == 0) {
@@ -945,7 +945,7 @@ nfsrpc_getattrnovp(struct nfsmount *nmp,
 	if (syscred)
 		nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, vers, NULL, 1, xidp);
+	    NFS_PROG, vers, NULL, 1, xidp, NULL);
 	if (error)
 		return (error);
 	if (nd->nd_repstat == 0) {
@@ -3734,7 +3734,7 @@ nfsrpc_locku(struct nfsrv_descript *nd, 
 	if (syscred)
 		nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	NFSCL_INCRSEQID(lp->nfsl_seqid, nd);
 	if (error)
 		return (error);
@@ -3805,7 +3805,7 @@ nfsrpc_lock(struct nfsrv_descript *nd, s
 	if (syscred)
 		nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, vp, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	if (newone)
@@ -4035,7 +4035,7 @@ nfsrpc_renew(struct nfsclclient *clp, st
 	}
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-		NFS_PROG, NFS_VER4, NULL, 1, NULL);
+		NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	error = nd->nd_repstat;
@@ -4072,7 +4072,7 @@ nfsrpc_rellockown(struct nfsmount *nmp, 
 	}
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	error = nd->nd_repstat;
@@ -4127,7 +4127,7 @@ nfsrpc_getdirpath(struct nfsmount *nmp, 
 	*tl = txdr_unsigned(NFSV4OP_GETFH);
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-		NFS_PROG, NFS_VER4, NULL, 1, NULL);
+		NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 printf("dirp ret=%d\n", nd->nd_repstat);
@@ -4171,7 +4171,7 @@ nfsrpc_delegreturn(struct nfscldeleg *dp
 	if (syscred)
 		nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error)
 		return (error);
 	error = nd->nd_repstat;
@@ -4287,7 +4287,7 @@ nfsrpc_exchangeid(struct nfsmount *nmp, 
 	txdr_nfsv4time(&verstime, tl);
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 printf("exch err=%d reps=%d\n",error,nd->nd_repstat);
 	if (error != 0)
 		return (error);
@@ -4362,7 +4362,7 @@ printf("clseq0=0x%x\n",clp->nfsc_sequenc
 	*tl = 0;				/* No additional gids */
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error != 0)
 		return (error);
 	if (nd->nd_repstat == 0) {
@@ -4416,7 +4416,7 @@ nfsrpc_destroysession(struct nfsmount *n
 	bcopy(clp->nfsc_sessionid, tl, NFSX_V4SESSIONID);
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error != 0)
 		return (error);
 	error = nd->nd_repstat;
@@ -4442,7 +4442,7 @@ nfsrpc_destroyclient(struct nfsmount *nm
 	*tl = clp->nfsc_clientid.lval[1];
 	nd->nd_flag |= ND_USEGSSNAME;
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
-	    NFS_PROG, NFS_VER4, NULL, 1, NULL);
+	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
 	if (error != 0)
 		return (error);
 	error = nd->nd_repstat;

Modified: projects/nfsv4.1-client/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsserver/nfs_nfsdstate.c	Sat Dec 31 01:33:25 2011	(r229063)
+++ projects/nfsv4.1-client/sys/fs/nfsserver/nfs_nfsdstate.c	Sat Dec 31 02:08:51 2011	(r229064)
@@ -3775,7 +3775,8 @@ nfsrv_docallback(struct nfsclient *clp, 
 	newnfs_sndunlock(&clp->lc_req.nr_lock);
 	if (!error) {
 		error = newnfs_request(nd, NULL, clp, &clp->lc_req, NULL,
-		    NULL, cred, clp->lc_program, NFSV4_CBVERS, NULL, 1, NULL);
+		    NULL, cred, clp->lc_program, NFSV4_CBVERS, NULL, 1, NULL,
+		    NULL);
 	}
 	NFSFREECRED(cred);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112310208.pBV28p2h041664>