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

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

Log:
  Modify the nfscl_setsequence() and nfscl_freeslot() functions so
  that they use the new nfsclsession structure. Also, rename and
  move them to the common module, since they are called by code
  in the common module and may be useful for a NFSv4.1 server someday.

Modified:
  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_clstate.c

Modified: projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c	Sat Dec 31 00:09:33 2011	(r229049)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_commonsubs.c	Sat Dec 31 00:12:51 2011	(r229050)
@@ -3541,3 +3541,80 @@ nfsv4_seqsess_cacherep(uint32_t slotid, 
 	slots[slotid].nfssl_inprog = 0;
 }
 
+/*
+ * Generate the xdr for an NFSv4.1 Sequence Operation.
+ */
+APPLESTATIC void
+nfsv4_setsequence(struct nfsrv_descript *nd, struct nfsclsession *sep,
+    int dont_replycache)
+{
+	uint32_t *tl, slotseq = 0;
+	int i, maxslot, slotpos;
+	uint64_t bitval;
+	uint8_t sessionid[NFSX_V4SESSIONID];
+
+	/* Find an unused slot. */
+	slotpos = -1;
+	maxslot = -1;
+	mtx_lock(&sep->nfsess_mtx);
+	do {
+		bitval = 1;
+		for (i = 0; i < sep->nfsess_foreslots; i++) {
+			if ((bitval & sep->nfsess_slots) == 0) {
+				slotpos = i;
+				sep->nfsess_slots |= bitval;
+				sep->nfsess_slotseq[i]++;
+				slotseq = sep->nfsess_slotseq[i];
+				break;
+			}
+			bitval <<= 1;
+		}
+		if (slotpos == -1)
+			(void)mtx_sleep(&sep->nfsess_slots, &sep->nfsess_mtx,
+			    PZERO, "nfsclseq", 0);
+	} while (slotpos == -1);
+	/* Now, find the highest slot in use. (nfsc_slots is 64bits) */
+	bitval = 1;
+	for (i = 0; i < 64; i++) {
+		if ((bitval & sep->nfsess_slots) != 0)
+			maxslot = i;
+		bitval <<= 1;
+	}
+	bcopy(sep->nfsess_sessionid, sessionid, NFSX_V4SESSIONID);
+	mtx_unlock(&sep->nfsess_mtx);
+	KASSERT(maxslot >= 0, ("nfscl_setsequence neg maxslot"));
+
+	/* Build the Sequence arguments. */
+	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 4 * NFSX_UNSIGNED);
+	bcopy(sessionid, tl, NFSX_V4SESSIONID);
+	tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
+	nd->nd_slotseq = tl;
+	*tl++ = txdr_unsigned(slotseq);
+	*tl++ = txdr_unsigned(slotpos);
+	*tl++ = txdr_unsigned(maxslot);
+	if (dont_replycache == 0)
+		*tl = newnfs_true;
+	else
+		*tl = newnfs_false;
+	nd->nd_flag |= ND_HASSEQUENCE;
+}
+
+/*
+ * Free a session slot.
+ */
+APPLESTATIC void
+nfsv4_freeslot(struct nfsclsession *sep, int slot)
+{
+	uint64_t bitval;
+
+	bitval = 1;
+	if (slot > 0)
+		bitval <<= slot;
+	mtx_lock(&sep->nfsess_mtx);
+	if ((bitval & sep->nfsess_slots) == 0)
+		printf("freeing free slot!!\n");
+	sep->nfsess_slots &= ~bitval;
+	wakeup(&sep->nfsess_slots);
+	mtx_unlock(&sep->nfsess_mtx);
+}
+

Modified: projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h	Sat Dec 31 00:09:33 2011	(r229049)
+++ projects/nfsv4.1-client/sys/fs/nfs/nfs_var.h	Sat Dec 31 00:12:51 2011	(r229050)
@@ -260,6 +260,8 @@ void newnfs_sndunlock(int *);
 int nfsv4_seqsession(uint32_t, uint32_t, uint32_t, struct nfsslot *,
     struct mbuf **, uint16_t);
 void nfsv4_seqsess_cacherep(uint32_t, struct nfsslot *, struct mbuf *);
+void nfsv4_setsequence(struct nfsrv_descript *, struct nfsclsession *, int);
+void nfsv4_freeslot(struct nfsclsession *, int);
 
 /* nfs_clcomsubs.c */
 void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int);
@@ -498,8 +500,6 @@ void nfscl_deleggetmodtime(vnode_t, stru
 int nfscl_tryclose(struct nfsclopen *, struct ucred *,
     struct nfsmount *, NFSPROC_T *);
 void nfscl_cleanup(NFSPROC_T *);
-void nfscl_setsequence(struct nfsrv_descript *, struct nfsmount *, int);
-void nfscl_freeslot(struct nfsmount *, int);
 
 /* nfs_clport.c */
 int nfscl_nget(mount_t, vnode_t, struct nfsfh *,

Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c	Sat Dec 31 00:09:33 2011	(r229049)
+++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clstate.c	Sat Dec 31 00:12:51 2011	(r229050)
@@ -4368,85 +4368,3 @@ nfscl_errmap(struct nfsrv_descript *nd)
 	return (txdr_unsigned(*defaulterrp));
 }
 
-/*
- * Generate the xdr for an NFSv4.1 Sequence Operation.
- */
-APPLESTATIC void
-nfscl_setsequence(struct nfsrv_descript *nd, struct nfsmount *nmp,
-    int dont_replycache)
-{
-	uint32_t *tl, slotseq = 0;
-	int i, maxslot, slotpos;
-	uint64_t bitval;
-	uint8_t sessionid[NFSX_V4SESSIONID];
-
-	/* Find an unused slot. */
-	slotpos = -1;
-	maxslot = -1;
-	NFSLOCKMNT(nmp);
-	do {
-		bitval = 1;
-		for (i = 0; i < nmp->nm_foreslots; i++) {
-			if ((bitval & nmp->nm_slots) == 0) {
-				slotpos = i;
-				nmp->nm_slots |= bitval;
-				nmp->nm_slotseq[i]++;
-				slotseq = nmp->nm_slotseq[i];
-				break;
-			}
-			bitval <<= 1;
-		}
-		if (slotpos == -1)
-			(void)mtx_sleep(&nmp->nm_slots, &nmp->nm_mtx, PZERO,
-			    "nfsclseq", 0);
-	} while (slotpos == -1);
-	/* Now, find the highest slot in use. (nm_slots is 64bits) */
-	bitval = 1;
-	for (i = 0; i < 64; i++) {
-		if ((bitval & nmp->nm_slots) != 0)
-			maxslot = i;
-		bitval <<= 1;
-	}
-	if (nmp->nm_clp != NULL)
-		bcopy(nmp->nm_clp->nfsc_sessionid, sessionid, NFSX_V4SESSIONID);
-	else {
-		printf("nfscl_setsequence: NULL sessionid\n");
-		bzero(sessionid, NFSX_V4SESSIONID);
-	}
-	NFSUNLOCKMNT(nmp);
-	KASSERT(maxslot >= 0, ("nfscl_setsequence neg maxslot"));
-
-	/* Build the Sequence arguments. */
-	NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID + 4 * NFSX_UNSIGNED);
-	bcopy(sessionid, tl, NFSX_V4SESSIONID);
-	tl += NFSX_V4SESSIONID / NFSX_UNSIGNED;
-	nd->nd_slotseq = tl;
-	*tl++ = txdr_unsigned(slotseq);
-	*tl++ = txdr_unsigned(slotpos);
-	*tl++ = txdr_unsigned(maxslot);
-	if (dont_replycache == 0)
-		*tl = newnfs_true;
-	else
-		*tl = newnfs_false;
-	nd->nd_flag |= ND_HASSEQUENCE;
-}
-
-/*
- * Free a session slot.
- */
-void
-nfscl_freeslot(struct nfsmount *nmp, int slot)
-{
-	uint64_t bitval;
-
-	bitval = 1;
-	if (slot > 0)
-		bitval <<= slot;
-	NFSLOCKMNT(nmp);
-	if ((bitval & nmp->nm_slots) == 0)
-		printf("freeing free slot!!\n");
-	nmp->nm_slots &= ~bitval;
-	wakeup(&nmp->nm_slots);
-	NFSUNLOCKMNT(nmp);
-}
-



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