Add support for ext_pgs mbufs to nfsm_strtom().
Also, add a new function nfsm_add_ext_pgs() which will either add a page or add a new ext_pgs mbuf with a page to the mbuf list. Used by nfsm_strtom(). This is another in the series of commits that add support to the NFS client and server for building RPC messages in ext_pgs mbufs with anonymous pages. This is useful so that the entire mbuf list does not need to be copied before calling sosend() when NFS over TLS is enabled. Since ND_EXTPG is never set yet, there is no semantic change at this time.
This commit is contained in:
parent
4543c1c329
commit
34fc29e0c9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362949
@ -832,22 +832,38 @@ nfsm_strtom(struct nfsrv_descript *nd, const char *cp, int siz)
|
|||||||
bytesize = NFSX_UNSIGNED + siz + rem;
|
bytesize = NFSX_UNSIGNED + siz + rem;
|
||||||
m2 = nd->nd_mb;
|
m2 = nd->nd_mb;
|
||||||
cp2 = nd->nd_bpos;
|
cp2 = nd->nd_bpos;
|
||||||
left = M_TRAILINGSPACE(m2);
|
if ((nd->nd_flag & ND_EXTPG) != 0)
|
||||||
|
left = nd->nd_bextpgsiz;
|
||||||
|
else
|
||||||
|
left = M_TRAILINGSPACE(m2);
|
||||||
|
|
||||||
|
KASSERT(((m2->m_flags & (M_EXT | M_EXTPG)) ==
|
||||||
|
(M_EXT | M_EXTPG) && (nd->nd_flag & ND_EXTPG) != 0) ||
|
||||||
|
((m2->m_flags & (M_EXT | M_EXTPG)) !=
|
||||||
|
(M_EXT | M_EXTPG) && (nd->nd_flag & ND_EXTPG) == 0),
|
||||||
|
("nfsm_strtom: ext_pgs and non-ext_pgs mbufs mixed"));
|
||||||
/*
|
/*
|
||||||
* Loop around copying the string to mbuf(s).
|
* Loop around copying the string to mbuf(s).
|
||||||
*/
|
*/
|
||||||
while (siz > 0) {
|
while (siz > 0) {
|
||||||
if (left == 0) {
|
if (left == 0) {
|
||||||
if (siz > ncl_mbuf_mlen)
|
if ((nd->nd_flag & ND_EXTPG) != 0) {
|
||||||
NFSMCLGET(m1, M_WAITOK);
|
m2 = nfsm_add_ext_pgs(m2,
|
||||||
else
|
nd->nd_maxextsiz, &nd->nd_bextpg);
|
||||||
NFSMGET(m1);
|
cp2 = (char *)(void *)PHYS_TO_DMAP(
|
||||||
m1->m_len = 0;
|
m2->m_epg_pa[nd->nd_bextpg]);
|
||||||
m2->m_next = m1;
|
nd->nd_bextpgsiz = left = PAGE_SIZE;
|
||||||
m2 = m1;
|
} else {
|
||||||
cp2 = mtod(m2, caddr_t);
|
if (siz > ncl_mbuf_mlen)
|
||||||
left = M_TRAILINGSPACE(m2);
|
NFSMCLGET(m1, M_WAITOK);
|
||||||
|
else
|
||||||
|
NFSMGET(m1);
|
||||||
|
m1->m_len = 0;
|
||||||
|
cp2 = mtod(m1, char *);
|
||||||
|
left = M_TRAILINGSPACE(m1);
|
||||||
|
m2->m_next = m1;
|
||||||
|
m2 = m1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (left >= siz)
|
if (left >= siz)
|
||||||
xfer = siz;
|
xfer = siz;
|
||||||
@ -855,18 +871,31 @@ nfsm_strtom(struct nfsrv_descript *nd, const char *cp, int siz)
|
|||||||
xfer = left;
|
xfer = left;
|
||||||
NFSBCOPY(cp, cp2, xfer);
|
NFSBCOPY(cp, cp2, xfer);
|
||||||
cp += xfer;
|
cp += xfer;
|
||||||
|
cp2 += xfer;
|
||||||
m2->m_len += xfer;
|
m2->m_len += xfer;
|
||||||
siz -= xfer;
|
siz -= xfer;
|
||||||
left -= xfer;
|
left -= xfer;
|
||||||
|
if ((nd->nd_flag & ND_EXTPG) != 0) {
|
||||||
|
nd->nd_bextpgsiz -= xfer;
|
||||||
|
m2->m_epg_last_len += xfer;
|
||||||
|
}
|
||||||
if (siz == 0 && rem) {
|
if (siz == 0 && rem) {
|
||||||
if (left < rem)
|
if (left < rem)
|
||||||
panic("nfsm_strtom");
|
panic("nfsm_strtom");
|
||||||
NFSBZERO(cp2 + xfer, rem);
|
NFSBZERO(cp2, rem);
|
||||||
m2->m_len += rem;
|
m2->m_len += rem;
|
||||||
|
cp2 += rem;
|
||||||
|
if ((nd->nd_flag & ND_EXTPG) != 0) {
|
||||||
|
nd->nd_bextpgsiz -= rem;
|
||||||
|
m2->m_epg_last_len += rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nd->nd_mb = m2;
|
nd->nd_mb = m2;
|
||||||
nd->nd_bpos = mtod(m2, caddr_t) + m2->m_len;
|
if ((nd->nd_flag & ND_EXTPG) != 0)
|
||||||
|
nd->nd_bpos = cp2;
|
||||||
|
else
|
||||||
|
nd->nd_bpos = mtod(m2, char *) + m2->m_len;
|
||||||
return (bytesize);
|
return (bytesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4845,3 +4874,34 @@ nfsm_set(struct nfsrv_descript *nd, u_int offs)
|
|||||||
} else
|
} else
|
||||||
nd->nd_bpos = mtod(m, char *) + offs;
|
nd->nd_bpos = mtod(m, char *) + offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Grow a ext_pgs mbuf list. Either allocate another page or add
|
||||||
|
* an mbuf to the list.
|
||||||
|
*/
|
||||||
|
struct mbuf *
|
||||||
|
nfsm_add_ext_pgs(struct mbuf *m, int maxextsiz, int *bextpg)
|
||||||
|
{
|
||||||
|
struct mbuf *mp;
|
||||||
|
vm_page_t pg;
|
||||||
|
|
||||||
|
if ((m->m_epg_npgs + 1) * PAGE_SIZE > maxextsiz) {
|
||||||
|
mp = mb_alloc_ext_plus_pages(PAGE_SIZE, M_WAITOK);
|
||||||
|
*bextpg = 0;
|
||||||
|
m->m_next = mp;
|
||||||
|
} else {
|
||||||
|
do {
|
||||||
|
pg = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL |
|
||||||
|
VM_ALLOC_NOOBJ | VM_ALLOC_NODUMP |
|
||||||
|
VM_ALLOC_WIRED);
|
||||||
|
if (pg == NULL)
|
||||||
|
vm_wait(NULL);
|
||||||
|
} while (pg == NULL);
|
||||||
|
m->m_epg_pa[m->m_epg_npgs] = VM_PAGE_TO_PHYS(pg);
|
||||||
|
*bextpg = m->m_epg_npgs;
|
||||||
|
m->m_epg_npgs++;
|
||||||
|
m->m_epg_last_len = 0;
|
||||||
|
mp = m;
|
||||||
|
}
|
||||||
|
return (mp);
|
||||||
|
}
|
||||||
|
@ -361,6 +361,7 @@ void nfsv4_freeslot(struct nfsclsession *, int);
|
|||||||
struct ucred *nfsrv_getgrpscred(struct ucred *);
|
struct ucred *nfsrv_getgrpscred(struct ucred *);
|
||||||
struct nfsdevice *nfsv4_findmirror(struct nfsmount *);
|
struct nfsdevice *nfsv4_findmirror(struct nfsmount *);
|
||||||
void nfsm_set(struct nfsrv_descript *, u_int);
|
void nfsm_set(struct nfsrv_descript *, u_int);
|
||||||
|
struct mbuf *nfsm_add_ext_pgs(struct mbuf *, int, int *);
|
||||||
|
|
||||||
/* nfs_clcomsubs.c */
|
/* nfs_clcomsubs.c */
|
||||||
void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int);
|
void nfsm_uiombuf(struct nfsrv_descript *, struct uio *, int);
|
||||||
|
Loading…
Reference in New Issue
Block a user