Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Jun 2020 03:11:35 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r361883 - in projects/nfs-over-tls/sys: fs/nfs fs/nfsclient fs/nfsserver kern rpc sys
Message-ID:  <202006070311.0573BZL1012530@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Sun Jun  7 03:11:34 2020
New Revision: 361883
URL: https://svnweb.freebsd.org/changeset/base/361883

Log:
  Simplify the functions added to kern_mbuf.c by removing the ext_free
  argument, since they always use anonymous pages.
  Also, remove mb_splitatpos_ext(), since it is no longer used.

Modified:
  projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c
  projects/nfs-over-tls/sys/fs/nfs/nfsm_subs.h
  projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c
  projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c
  projects/nfs-over-tls/sys/kern/kern_mbuf.c
  projects/nfs-over-tls/sys/rpc/rpc_generic.c
  projects/nfs-over-tls/sys/sys/mbuf.h

Modified: projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/fs/nfs/nfs_commonsubs.c	Sun Jun  7 03:11:34 2020	(r361883)
@@ -375,8 +375,7 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum,
 	 * Get the first mbuf for the request.
 	 */
 	if ((nd->nd_flag & ND_EXTPG) != 0) {
-		mb = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK,
-		    mb_free_mext_pgs);
+		mb = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
 		nd->nd_mreq = nd->nd_mb = mb;
 		nfsm_set(nd, 0);
 	} else {
@@ -4465,8 +4464,7 @@ nfsrvd_rephead(struct nfsrv_descript *nd)
 	struct mbuf *mreq;
 
 	if ((nd->nd_flag & ND_EXTPG) != 0) {
-		mreq = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK,
-		    mb_free_mext_pgs);
+		mreq = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
 		nd->nd_mreq = nd->nd_mb = mreq;
 		nd->nd_bpos = (char *)(void *)
 		    PHYS_TO_DMAP(mreq->m_epg_pa[0]);
@@ -4918,8 +4916,7 @@ nfsm_add_ext_pgs(struct mbuf *m, int maxextsiz, int *b
 	vm_page_t pg;
 
 	if ((m->m_epg_npgs + 1) * PAGE_SIZE > maxextsiz) {
-		mp = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK,
-		    mb_free_mext_pgs);
+		mp = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
 		*bextpg = 0;
 		m->m_next = mp;
 	} else {

Modified: projects/nfs-over-tls/sys/fs/nfs/nfsm_subs.h
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfs/nfsm_subs.h	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/fs/nfs/nfsm_subs.h	Sun Jun  7 03:11:34 2020	(r361883)
@@ -75,8 +75,7 @@ nfsm_build(struct nfsrv_descript *nd, int siz)
 		nd->nd_mb = mb2;
 	} else if ((nd->nd_flag & ND_EXTPG) != 0) {
 		if (siz > nd->nd_bextpgsiz) {
-			mb2 = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK,
-			    mb_free_mext_pgs);
+			mb2 = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
 			nd->nd_bpos = (char *)(void *)
 			    PHYS_TO_DMAP(mb2->m_epg_pa[0]);
 			nd->nd_bextpg = 0;

Modified: projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/fs/nfsclient/nfs_clcomsubs.c	Sun Jun  7 03:11:34 2020	(r361883)
@@ -183,8 +183,7 @@ nfsm_uiombuflist(bool doextpgs, int maxextsiz, struct 
 		clflg = 0;
 	rem = NFSM_RNDUP(siz) - siz;
 	if (doextpgs) {
-		mp = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK,
-		    mb_free_mext_pgs);
+		mp = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
 		mcp = (char *)(void *)
 		    PHYS_TO_DMAP(mp->m_epg_pa[0]);
 		bextpgsiz = PAGE_SIZE;

Modified: projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/fs/nfsserver/nfs_nfsdport.c	Sun Jun  7 03:11:34 2020	(r361883)
@@ -860,8 +860,7 @@ nfsrv_createiovec_extpgs(int len, int maxextsiz, struc
 	i = 0;
 	while (left > 0) {
 		siz = min(left, maxextsiz);
-		m = mb_alloc_ext_plus_pages(siz, M_WAITOK,
-		    mb_free_mext_pgs);
+		m = mb_alloc_ext_plus_pages(siz, M_WAITOK);
 		left -= siz;
 		i += m->m_epg_npgs;
 		if (m3 != NULL)

Modified: projects/nfs-over-tls/sys/kern/kern_mbuf.c
==============================================================================
--- projects/nfs-over-tls/sys/kern/kern_mbuf.c	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/kern/kern_mbuf.c	Sun Jun  7 03:11:34 2020	(r361883)
@@ -1543,13 +1543,13 @@ m_snd_tag_destroy(struct m_snd_tag *mst)
  * Allocate an mbuf with anonymous external pages.
  */
 struct mbuf *
-mb_alloc_ext_plus_pages(int len, int how, m_ext_free_t ext_free)
+mb_alloc_ext_plus_pages(int len, int how)
 {
 	struct mbuf *m;
 	vm_page_t pg;
 	int i, npgs;
 
-	m = mb_alloc_ext_pgs(how, ext_free);
+	m = mb_alloc_ext_pgs(how, mb_free_mext_pgs);
 	if (m == NULL)
 		return (NULL);
 	m->m_epg_flags |= EPG_FLAG_ANON;
@@ -1574,13 +1574,14 @@ mb_alloc_ext_plus_pages(int len, int how, m_ext_free_t
 }
 
 /*
- * Copy the data in the mbuf chain to a chain of mbufs with external pages.
+ * Copy the data in the mbuf chain to a chain of mbufs with anonymous external
+ * unmapped pages.
  * len is the length of data in the input mbuf chain.
  * mlen is the maximum number of bytes put into each ext_page mbuf.
  */
 struct mbuf *
-mb_copym_ext_pgs(struct mbuf *mp, int len, int mlen, int how,
-    m_ext_free_t ext_free, struct mbuf **mlast)
+mb_mapped_to_unmapped(struct mbuf *mp, int len, int mlen, int how,
+    struct mbuf **mlast)
 {
 	struct mbuf *m, *mout = NULL;
 	char *pgpos = NULL, *mbpos;
@@ -1596,13 +1597,13 @@ mb_copym_ext_pgs(struct mbuf *mp, int len, int mlen, i
 				mbufsiz = min(mlen, len);
 				if (m == NULL) {
 					m = mout = mb_alloc_ext_plus_pages(
-					    mbufsiz, how, ext_free);
+					    mbufsiz, how);
 					if (m == NULL)
 						return (m);
 				} else {
 					m->m_epg_last_len = PAGE_SIZE;
 					m->m_next = mb_alloc_ext_plus_pages(
-					    mbufsiz, how, ext_free);
+					    mbufsiz, how);
 					m = m->m_next;
 					if (m == NULL) {
 						m_freem(mout);
@@ -1639,116 +1640,4 @@ mb_copym_ext_pgs(struct mbuf *mp, int len, int mlen, i
 	if (mlast != NULL)
 		*mlast = m;
 	return (mout);
-}
-
-/*
- * Split an ext_pgs mbuf list into two lists at len bytes.
- * Similar to m_split(), but for ext_pgs mbufs with
- * anonymous pages.
- */
-struct mbuf *
-mb_splitatpos_ext(struct mbuf *m0, int len, int how)
-{
-	struct mbuf *m, *mp;
-	vm_page_t pg;
-	int i, j, left, pgno, plen, trim;
-	char *cp, *cp0;
-
-	/* Nothing to do. */
-	if (len == 0)
-		return (NULL);
-
-	/* Find the correct mbuf to split at. */
-	for (mp = m0; mp != NULL && len > mp->m_len; mp = mp->m_next)
-		len -= mp->m_len;
-	if (mp == NULL)
-		return (NULL);
-
-	/* If len == mp->m_len, we can just split the mbuf list. */
-	if (len == mp->m_len) {
-		m = mp->m_next;
-		mp->m_next = NULL;
-		return (m);
-	}
-
-	/* Find the page to split at. */
-	KASSERT((mp->m_flags & (M_EXT | M_EXTPG)) ==
-	    (M_EXT | M_EXTPG),
-	    ("mb_splitatpos_ext: m0 not ext_pgs"));
-	KASSERT((mp->m_epg_flags & EPG_FLAG_ANON) != 0,
-	    ("mb_splitatpos_ext: not anonymous pages"));
-	pgno = 0;
-	left = len;
-	do {
-		if (pgno == 0)
-			plen = m_epg_pagelen(mp, 0, mp->m_epg_1st_off);
-		else
-			plen = m_epg_pagelen(mp, pgno, 0);
-		if (left <= plen)
-			break;
-		left -= plen;
-		pgno++;
-	} while (pgno < mp->m_epg_npgs);
-	if (pgno == mp->m_epg_npgs)
-		panic("mb_splitatpos_ext");
-	mp->m_len = len;
-
-	m = mb_alloc_ext_pgs(how, mb_free_mext_pgs);
-	if (m == NULL)
-		return (NULL);
-	m->m_epg_flags |= EPG_FLAG_ANON;
-
-	/*
-	 * If left < plen, allocate a new page for the new mbuf
-	 * and copy the data after left in the page to this new
-	 * page.
-	 */
-	if (left < plen) {
-		do {
-			pg = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL |
-			    VM_ALLOC_NOOBJ | VM_ALLOC_NODUMP |
-			    VM_ALLOC_WIRED);
-			if (pg == NULL) {
-				if (how == M_NOWAIT) {
-					m_free(m);
-					return (NULL);
-				}
-				vm_wait(NULL);
-			}
-		} while (pg == NULL);
-		m->m_epg_pa[0] = VM_PAGE_TO_PHYS(pg);
-		m->m_epg_npgs++;
-		trim = plen - left;
-		cp = (char *)(void *)PHYS_TO_DMAP(mp->m_epg_pa[pgno]);
-		cp0 = (char *)(void *)PHYS_TO_DMAP(m->m_epg_pa[0]);
-		if (pgno == 0)
-			cp += mp->m_epg_1st_off;
-		cp += left;
-		if (pgno == mp->m_epg_npgs - 1)
-			m->m_epg_last_len = trim;
-		else {
-			m->m_epg_last_len = mp->m_epg_last_len;
-			m->m_epg_1st_off = PAGE_SIZE - trim;
-			cp0 += PAGE_SIZE - trim;
-		}
-		memcpy(cp0, cp, trim);
-		m->m_len = trim;
-	} else
-		m->m_epg_last_len = mp->m_epg_last_len;
-
-	/* Move the pages beyond pgno to the new mbuf. */
-	for (i = pgno + 1, j = m->m_epg_npgs; i < mp->m_epg_npgs; i++, j++) {
-		m->m_epg_pa[j] = mp->m_epg_pa[i];
-		/* Never moves page 0. */
-		m->m_len += m_epg_pagelen(mp, i, 0);
-	}
-	m->m_epg_npgs = j;
-	mp->m_epg_npgs = pgno + 1;
-
-	/* Can now update mp->m_epg_last_len. */
-	mp->m_epg_last_len = left;
-
-	m->m_next = mp->m_next;
-	mp->m_next = NULL;
-	return (m);
 }

Modified: projects/nfs-over-tls/sys/rpc/rpc_generic.c
==============================================================================
--- projects/nfs-over-tls/sys/rpc/rpc_generic.c	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/rpc/rpc_generic.c	Sun Jun  7 03:11:34 2020	(r361883)
@@ -912,8 +912,8 @@ _rpc_copym_into_ext_pgs(struct mbuf *mp, int maxextsiz
 	 * mbuf list.
 	 */
 	m2->m_next = NULL;
-	mhead = mb_copym_ext_pgs(mp, tlen, maxextsiz, M_WAITOK,
-	    mb_free_mext_pgs, &m2);
+	mhead = mb_mapped_to_unmapped(mp, tlen, maxextsiz,
+	    M_WAITOK, &m2);
 
 	/*
 	 * Link the ext_pgs list onto the newly copied

Modified: projects/nfs-over-tls/sys/sys/mbuf.h
==============================================================================
--- projects/nfs-over-tls/sys/sys/mbuf.h	Sun Jun  7 02:40:21 2020	(r361882)
+++ projects/nfs-over-tls/sys/sys/mbuf.h	Sun Jun  7 03:11:34 2020	(r361883)
@@ -741,10 +741,9 @@ void		 mb_free_ext(struct mbuf *);
 void		 mb_free_extpg(struct mbuf *);
 void		 mb_free_mext_pgs(struct mbuf *);
 struct mbuf	*mb_alloc_ext_pgs(int, m_ext_free_t);
-struct mbuf	*mb_alloc_ext_plus_pages(int, int, m_ext_free_t);
-struct mbuf	*mb_copym_ext_pgs(struct mbuf *, int, int, int,
-		    m_ext_free_t, struct mbuf **);
-struct mbuf	*mb_splitatpos_ext(struct mbuf *, int, int);
+struct mbuf	*mb_alloc_ext_plus_pages(int, int);
+struct mbuf	*mb_mapped_to_unmapped(struct mbuf *, int, int, int,
+		    struct mbuf **);
 int		 mb_unmapped_compress(struct mbuf *m);
 struct mbuf 	*mb_unmapped_to_ext(struct mbuf *m);
 void		 mb_free_notready(struct mbuf *m, int count);



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