diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -651,7 +651,7 @@ while (len > 0) { if (m == NULL) { m = mb_alloc_ext_pgs(flags & ~ICL_NOCOPY, - cxgbei_free_mext_pg); + cxgbei_free_mext_pg, 0); if (__predict_false(m == NULL)) return (ENOMEM); atomic_add_int(&icp->ref_cnt, 1); diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -2126,7 +2126,7 @@ if (npages < 0) break; - m = mb_alloc_ext_pgs(M_WAITOK, aiotx_free_pgs); + m = mb_alloc_ext_pgs(M_WAITOK, aiotx_free_pgs, M_RDONLY); m->m_epg_1st_off = pgoff; m->m_epg_npgs = npages; if (npages == 1) { diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c --- a/sys/dev/iscsi/icl_soft.c +++ b/sys/dev/iscsi/icl_soft.c @@ -1139,7 +1139,7 @@ while (len > 0) { if (m == NULL) { m = mb_alloc_ext_pgs(flags & ~ICL_NOCOPY, - icl_soft_free_mext_pg); + icl_soft_free_mext_pg, 0); if (__predict_false(m == NULL)) return (ENOMEM); atomic_add_int(&isp->ref_cnt, 1); diff --git a/sys/dev/nvmf/nvmf_tcp.c b/sys/dev/nvmf/nvmf_tcp.c --- a/sys/dev/nvmf/nvmf_tcp.c +++ b/sys/dev/nvmf/nvmf_tcp.c @@ -884,7 +884,7 @@ struct nvmf_tcp_command_buffer *cb = arg; struct mbuf *m; - m = mb_alloc_ext_pgs(how, nvmf_tcp_free_mext_pg); + m = mb_alloc_ext_pgs(how, nvmf_tcp_free_mext_pg, M_RDONLY); m->m_ext.ext_arg1 = cb; tcp_hold_command_buffer(cb); return (m); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -9402,7 +9402,7 @@ if (pgno == m->m_epg_npgs) panic("nfsm_split: eroneous ext_pgs mbuf"); - m2 = mb_alloc_ext_pgs(M_WAITOK, mb_free_mext_pgs); + m2 = mb_alloc_ext_pgs(M_WAITOK, mb_free_mext_pgs, 0); m2->m_epg_flags |= EPG_FLAG_ANON; /* diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -1014,7 +1014,8 @@ ref_inc++; m_extadd(m_new, (char *)sf_buf_kva(sf), PAGE_SIZE, - mb_unmapped_free_mext, sf, mref, M_RDONLY, EXT_SFBUF); + mb_unmapped_free_mext, sf, mref, m->m_flags & M_RDONLY, + EXT_SFBUF); m_new->m_data += segoff; m_new->m_len = seglen; @@ -1119,7 +1120,7 @@ * freed. */ struct mbuf * -mb_alloc_ext_pgs(int how, m_ext_free_t ext_free) +mb_alloc_ext_pgs(int how, m_ext_free_t ext_free, int flags) { struct mbuf *m; @@ -1137,7 +1138,7 @@ m->m_epg_tls = NULL; m->m_epg_so = NULL; m->m_data = NULL; - m->m_flags |= (M_EXT | M_RDONLY | M_EXTPG); + m->m_flags |= M_EXT | M_EXTPG | flags; m->m_ext.ext_flags = EXT_FLAG_EMBREF; m->m_ext.ext_count = 1; m->m_ext.ext_size = 0; @@ -1709,7 +1710,7 @@ vm_page_t pg; int i, npgs; - m = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + m = mb_alloc_ext_pgs(how, mb_free_mext_pgs, 0); if (m == NULL) return (NULL); m->m_epg_flags |= EPG_FLAG_ANON; diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -1003,7 +1003,7 @@ ext_pgs_idx++; if (ext_pgs_idx == max_pgs) { m0 = mb_alloc_ext_pgs(M_WAITOK, - sendfile_free_mext_pg); + sendfile_free_mext_pg, M_RDONLY); if (flags & SF_NOCACHE) { m0->m_ext.ext_flags |= diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1887,7 +1887,7 @@ * ciphersuites. */ if (__predict_false(total == 0)) { - mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs, 0); if (mb == NULL) return (NULL); mb->m_epg_flags = EPG_FLAG_ANON; @@ -1899,7 +1899,7 @@ */ m = NULL; while (total > 0) { - mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs, 0); if (mb == NULL) goto failed; if (m == NULL) diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -808,7 +808,7 @@ 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_pgs(int, m_ext_free_t, int); struct mbuf *mb_alloc_ext_plus_pages(int, int); struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int, struct mbuf **);