svn commit: r360884 - in projects/nfs-over-tls/sys/fs: nfs nfsclient nfsserver

Rick Macklem rmacklem at FreeBSD.org
Sun May 10 21:37:41 UTC 2020


Author: rmacklem
Date: Sun May 10 21:37:39 2020
New Revision: 360884
URL: https://svnweb.freebsd.org/changeset/base/360884

Log:
  Simplify nfsm_set() so that it does not do the dissect case.
  
  This will simplify integration with head.

Modified:
  projects/nfs-over-tls/sys/fs/nfs/nfs_commonkrpc.c
  projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c
  projects/nfs-over-tls/sys/fs/nfs/nfs_var.h
  projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c
  projects/nfs-over-tls/sys/fs/nfsserver/nfs_fha_new.c
  projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdkrpc.c
  projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c

Modified: projects/nfs-over-tls/sys/fs/nfs/nfs_commonkrpc.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfs/nfs_commonkrpc.c	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfs/nfs_commonkrpc.c	Sun May 10 21:37:39 2020	(r360884)
@@ -895,7 +895,7 @@ tryagain:
 	 */
 	newnfs_realign(&nd->nd_mrep, M_WAITOK);
 	nd->nd_md = nd->nd_mrep;
-	nfsm_set(nd, ext.rc_mbufoffs, false);
+	nd->nd_dpos = mtod(nd->nd_md, char *);
 	nd->nd_repstat = 0;
 	if (nd->nd_procnum != NFSPROC_NULL &&
 	    nd->nd_procnum != NFSV4PROC_CBNULL) {

Modified: projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c	Sun May 10 21:37:39 2020	(r360884)
@@ -380,7 +380,7 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum,
 		mb = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK,
 		    mb_free_mext_pgs);
 		nd->nd_mreq = nd->nd_mb = mb;
-		nfsm_set(nd, 0, true);
+		nfsm_set(nd, 0);
 	} else {
 		if (nfs_bigrequest[procnum])
 			NFSMCLGET(mb, M_WAITOK);
@@ -4873,81 +4873,49 @@ nfsv4_findmirror(struct nfsmount *nmp)
  * The build argument is true for build and false for dissect.
  */
 int
-nfsm_set(struct nfsrv_descript *nd, u_int offs, bool build)
+nfsm_set(struct nfsrv_descript *nd, u_int offs)
 {
 	struct mbuf *m;
 	struct mbuf_ext_pgs *pgs;
 	int rlen;
 
-	if (build)
-		m = nd->nd_mb;
-	else
-		m = nd->nd_md;
+	m = nd->nd_mb;
 	if ((m->m_flags & M_NOMAP) != 0) {
-		if (build) {
-			pgs = &m->m_ext_pgs;
-			nd->nd_bextpg = 0;
-			while (offs > 0) {
-				if (nd->nd_bextpg == 0)
-					rlen = mbuf_ext_pg_len(pgs, 0,
-					    pgs->first_pg_off);
-				else
-					rlen = mbuf_ext_pg_len(pgs,
-					    nd->nd_bextpg, 0);
-				if (offs <= rlen)
-					break;
-				offs -= rlen;
-				nd->nd_bextpg++;
-				if (nd->nd_bextpg == pgs->npgs) {
-					printf("nfsm_set: build offs "
-					    "out of range\n");
-					nd->nd_bextpg--;
-					break;
-				}
-			}
-			nd->nd_bpos = (char *)(void *)
-			    PHYS_TO_DMAP(m->m_epg_pa[nd->nd_bextpg]);
+		pgs = &m->m_ext_pgs;
+		nd->nd_bextpg = 0;
+		while (offs > 0) {
 			if (nd->nd_bextpg == 0)
-				nd->nd_bpos += pgs->first_pg_off;
-			if (offs > 0) {
-				nd->nd_bpos += offs;
-				rlen = nd->nd_bextpgsiz = rlen - offs;
-			} else if (nd->nd_bextpg == 0)
-				rlen = nd->nd_bextpgsiz = PAGE_SIZE -
-				    pgs->first_pg_off;
+				rlen = mbuf_ext_pg_len(pgs, 0,
+				    pgs->first_pg_off);
 			else
-				rlen = nd->nd_bextpgsiz = PAGE_SIZE;
-		} else {
-			pgs = &m->m_ext_pgs;
-			nd->nd_dextpg = 0;
-			do {
-				nd->nd_dpos = (char *)(void *)
-				    PHYS_TO_DMAP(m->m_epg_pa[nd->nd_dextpg]);
-				if (nd->nd_dextpg == 0) {
-					nd->nd_dpos += pgs->first_pg_off;
-					rlen = nd->nd_dextpgsiz =
-					    mbuf_ext_pg_len(pgs, 0,
-					    pgs->first_pg_off);
-				} else
-					rlen = nd->nd_dextpgsiz =
-					    mbuf_ext_pg_len(pgs,
-					    nd->nd_dextpg, 0);
-				if (offs > rlen) {
-					nd->nd_dextpg++;
-					offs -= rlen;
-				} else if (offs > 0) {
-					nd->nd_dpos += offs;
-					nd->nd_dextpgsiz -= offs;
-					offs = 0;
-				}
-			} while (offs > 0);
+				rlen = mbuf_ext_pg_len(pgs,
+				    nd->nd_bextpg, 0);
+			if (offs <= rlen)
+				break;
+			offs -= rlen;
+			nd->nd_bextpg++;
+			if (nd->nd_bextpg == pgs->npgs) {
+				printf("nfsm_set: build offs "
+				    "out of range\n");
+				nd->nd_bextpg--;
+				break;
+			}
 		}
-	} else if (build) {
+		nd->nd_bpos = (char *)(void *)
+		    PHYS_TO_DMAP(m->m_epg_pa[nd->nd_bextpg]);
+		if (nd->nd_bextpg == 0)
+			nd->nd_bpos += pgs->first_pg_off;
+		if (offs > 0) {
+			nd->nd_bpos += offs;
+			rlen = nd->nd_bextpgsiz = rlen - offs;
+		} else if (nd->nd_bextpg == 0)
+			rlen = nd->nd_bextpgsiz = PAGE_SIZE -
+			    pgs->first_pg_off;
+		else
+			rlen = nd->nd_bextpgsiz = PAGE_SIZE;
+	} else {
 		nd->nd_bpos = mtod(m, char *) + offs;
 		rlen = m->m_len - offs;
-	} else {
-		nd->nd_dpos = mtod(m, char *);
-		rlen = m->m_len;
 	}
 	return (rlen);
 }

Modified: projects/nfs-over-tls/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfs/nfs_var.h	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfs/nfs_var.h	Sun May 10 21:37:39 2020	(r360884)
@@ -361,7 +361,7 @@ int nfsv4_sequencelookup(struct nfsmount *, struct nfs
 void nfsv4_freeslot(struct nfsclsession *, int);
 struct ucred *nfsrv_getgrpscred(struct ucred *);
 struct nfsdevice *nfsv4_findmirror(struct nfsmount *);
-int nfsm_set(struct nfsrv_descript *, u_int, bool);
+int nfsm_set(struct nfsrv_descript *, u_int);
 
 /* nfs_clcomsubs.c */
 void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int);

Modified: projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfsclient/nfs_clkrpc.c	Sun May 10 21:37:39 2020	(r360884)
@@ -95,7 +95,7 @@ printf("cbprogram proc=%d\n", rqst->rq_proc);
 	newnfs_realign(&nd.nd_mrep, M_WAITOK);
 	nd.nd_md = nd.nd_mrep;
 printf("cbreq nd_md=%p offs=%d\n", nd.nd_md, rqst->rq_xprt->xp_mbufoffs);
-	nfsm_set(&nd, rqst->rq_xprt->xp_mbufoffs, false);
+	nd.nd_dpos = mtod(nd.nd_md, char *);
 	nd.nd_nam = svc_getrpccaller(rqst);
 	nd.nd_nam2 = rqst->rq_addr;
 	nd.nd_mreq = NULL;

Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_fha_new.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsserver/nfs_fha_new.c	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfsserver/nfs_fha_new.c	Sun May 10 21:37:39 2020	(r360884)
@@ -338,7 +338,7 @@ fha_extract_info(struct svc_req *req, struct fha_info 
 	if (error)
 		goto out;
 	nd->nd_md = req->rq_args;
-	nfsm_set(nd, req->rq_xprt->xp_mbufoffs, false);
+	nd->nd_dpos = mtod(nd->nd_md, char *);
 
 	/* Grab the filehandle. */
 	error = fhanew_get_fh(&i->fh, v3, nd);

Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdkrpc.c	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdkrpc.c	Sun May 10 21:37:39 2020	(r360884)
@@ -164,7 +164,7 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
 	rqst->rq_args = NULL;
 	newnfs_realign(&nd.nd_mrep, M_WAITOK);
 	nd.nd_md = nd.nd_mrep;
-	nfsm_set(&nd, rqst->rq_xprt->xp_mbufoffs, false);
+	nd.nd_dpos = mtod(nd.nd_md, char *);
 	nd.nd_nam = svc_getrpccaller(rqst);
 	nd.nd_nam2 = rqst->rq_addr;
 	nd.nd_mreq = NULL;

Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c	Sun May 10 20:44:43 2020	(r360883)
+++ projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c	Sun May 10 21:37:39 2020	(r360884)
@@ -5285,7 +5285,7 @@ nfsrv_writedsdorpc(struct nfsmount *nmp, fhandle_t *fh
 	while (m->m_next != NULL)
 		m = m->m_next;
 	nd->nd_mb = m;
-	nfsm_set(nd, m->m_len, true);
+	nfsm_set(nd, m->m_len);
 	NFSD_DEBUG(4, "nfsrv_writedsdorpc: lastmb len=%d\n", m->m_len);
 
 	/* Do a Getattr for the attributes that change upon writing. */


More information about the svn-src-projects mailing list