svn commit: r360570 - head/sys/kern

Gleb Smirnoff glebius at FreeBSD.org
Sat May 2 22:44:24 UTC 2020


Author: glebius
Date: Sat May  2 22:44:23 2020
New Revision: 360570
URL: https://svnweb.freebsd.org/changeset/base/360570

Log:
  In mb_unmapped_compress() we don't need mbuf structure to keep data,
  but we need buffer of MLEN bytes.  This isn't just a simplification,
  but important fixup, because previous commit shrinked sizeof(struct
  mbuf) down below MSIZE, and instantiating an mbuf on stack no longer
  provides enough data.
  
  Reviewed by:	gallatin
  Differential Revision:	https://reviews.freebsd.org/D24598

Modified:
  head/sys/kern/kern_mbuf.c

Modified: head/sys/kern/kern_mbuf.c
==============================================================================
--- head/sys/kern/kern_mbuf.c	Sat May  2 22:39:26 2020	(r360569)
+++ head/sys/kern/kern_mbuf.c	Sat May  2 22:44:23 2020	(r360570)
@@ -853,7 +853,7 @@ int
 mb_unmapped_compress(struct mbuf *m)
 {
 	volatile u_int *refcnt;
-	struct mbuf m_temp;
+	char buf[MLEN];
 
 	/*
 	 * Assert that 'm' does not have a packet header.  If 'm' had
@@ -876,12 +876,8 @@ mb_unmapped_compress(struct mbuf *m)
 	if (*refcnt != 1)
 		return (EBUSY);
 
-	m_init(&m_temp, M_NOWAIT, MT_DATA, 0);
+	m_copydata(m, 0, m->m_len, buf);
 
-	/* copy data out of old mbuf */
-	m_copydata(m, 0, m->m_len, mtod(&m_temp, char *));
-	m_temp.m_len = m->m_len;
-
 	/* Free the backing pages. */
 	m->m_ext.ext_free(m);
 
@@ -889,8 +885,8 @@ mb_unmapped_compress(struct mbuf *m)
 	m->m_flags &= ~(M_EXT | M_RDONLY | M_NOMAP);
 	m->m_data = m->m_dat;
 
-	/* copy data back into m */
-	m_copydata(&m_temp, 0, m_temp.m_len, mtod(m, char *));
+	/* Copy data back into m. */
+	bcopy(buf, mtod(m, char *), m->m_len);
 
 	return (0);
 }


More information about the svn-src-all mailing list