Add support for ext_pgs mbufs to nfsm_uiombuf().
This patch uses a slightly different algorithm for the non-ext_pgs case, where a variable called "mcp" is maintained, pointing to the current location that mbuf data can be filled into. This avoids use of mtod(mp, char *) + mp->m_len to calculate the location, since this does not work for ext_pgs mbufs and I think it makes the algorithm more readable. This change should not result in semantic changes for the non-ext_pgs case. 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
565a5f040f
commit
3eaf03766e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363001
@ -62,7 +62,7 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz)
|
|||||||
struct mbuf *mp, *mp2;
|
struct mbuf *mp, *mp2;
|
||||||
int xfer, left, mlen;
|
int xfer, left, mlen;
|
||||||
int uiosiz, clflg, rem;
|
int uiosiz, clflg, rem;
|
||||||
char *cp, *tcp;
|
char *mcp, *tcp;
|
||||||
|
|
||||||
KASSERT(uiop->uio_iovcnt == 1, ("nfsm_uiotombuf: iovcnt != 1"));
|
KASSERT(uiop->uio_iovcnt == 1, ("nfsm_uiotombuf: iovcnt != 1"));
|
||||||
|
|
||||||
@ -72,41 +72,52 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz)
|
|||||||
clflg = 0;
|
clflg = 0;
|
||||||
rem = NFSM_RNDUP(siz) - siz;
|
rem = NFSM_RNDUP(siz) - siz;
|
||||||
mp = mp2 = nd->nd_mb;
|
mp = mp2 = nd->nd_mb;
|
||||||
|
mcp = nd->nd_bpos;
|
||||||
while (siz > 0) {
|
while (siz > 0) {
|
||||||
|
KASSERT((nd->nd_flag & ND_EXTPG) != 0 || mcp ==
|
||||||
|
mtod(mp, char *) + mp->m_len, ("nfsm_uiombuf: mcp wrong"));
|
||||||
left = uiop->uio_iov->iov_len;
|
left = uiop->uio_iov->iov_len;
|
||||||
uiocp = uiop->uio_iov->iov_base;
|
uiocp = uiop->uio_iov->iov_base;
|
||||||
if (left > siz)
|
if (left > siz)
|
||||||
left = siz;
|
left = siz;
|
||||||
uiosiz = left;
|
uiosiz = left;
|
||||||
while (left > 0) {
|
while (left > 0) {
|
||||||
mlen = M_TRAILINGSPACE(mp);
|
if ((nd->nd_flag & ND_EXTPG) != 0)
|
||||||
if (mlen == 0) {
|
mlen = nd->nd_bextpgsiz;
|
||||||
if (clflg)
|
else
|
||||||
NFSMCLGET(mp, M_WAITOK);
|
|
||||||
else
|
|
||||||
NFSMGET(mp);
|
|
||||||
mp->m_len = 0;
|
|
||||||
mp2->m_next = mp;
|
|
||||||
mp2 = mp;
|
|
||||||
mlen = M_TRAILINGSPACE(mp);
|
mlen = M_TRAILINGSPACE(mp);
|
||||||
|
if (mlen == 0) {
|
||||||
|
if ((nd->nd_flag & ND_EXTPG) != 0) {
|
||||||
|
mp = nfsm_add_ext_pgs(mp,
|
||||||
|
nd->nd_maxextsiz, &nd->nd_bextpg);
|
||||||
|
mcp = (char *)(void *)PHYS_TO_DMAP(
|
||||||
|
mp->m_epg_pa[nd->nd_bextpg]);
|
||||||
|
nd->nd_bextpgsiz = PAGE_SIZE;
|
||||||
|
} else {
|
||||||
|
if (clflg)
|
||||||
|
NFSMCLGET(mp, M_WAITOK);
|
||||||
|
else
|
||||||
|
NFSMGET(mp);
|
||||||
|
mp->m_len = 0;
|
||||||
|
mlen = M_TRAILINGSPACE(mp);
|
||||||
|
mcp = mtod(mp, char *);
|
||||||
|
mp2->m_next = mp;
|
||||||
|
mp2 = mp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xfer = (left > mlen) ? mlen : left;
|
xfer = (left > mlen) ? mlen : left;
|
||||||
#ifdef notdef
|
|
||||||
/* Not Yet.. */
|
|
||||||
if (uiop->uio_iov->iov_op != NULL)
|
|
||||||
(*(uiop->uio_iov->iov_op))
|
|
||||||
(uiocp, mtod(mp, caddr_t) + mp->m_len,
|
|
||||||
xfer);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (uiop->uio_segflg == UIO_SYSSPACE)
|
if (uiop->uio_segflg == UIO_SYSSPACE)
|
||||||
NFSBCOPY(uiocp, mtod(mp, caddr_t) + mp->m_len,
|
NFSBCOPY(uiocp, mcp, xfer);
|
||||||
xfer);
|
|
||||||
else
|
else
|
||||||
copyin(uiocp, mtod(mp, caddr_t) + mp->m_len, xfer);
|
copyin(uiocp, mcp, xfer);
|
||||||
mp->m_len += xfer;
|
mp->m_len += xfer;
|
||||||
left -= xfer;
|
left -= xfer;
|
||||||
uiocp += xfer;
|
uiocp += xfer;
|
||||||
|
mcp += xfer;
|
||||||
|
if ((nd->nd_flag & ND_EXTPG) != 0) {
|
||||||
|
nd->nd_bextpgsiz -= xfer;
|
||||||
|
mp->m_epg_last_len += xfer;
|
||||||
|
}
|
||||||
uiop->uio_offset += xfer;
|
uiop->uio_offset += xfer;
|
||||||
uiop->uio_resid -= xfer;
|
uiop->uio_resid -= xfer;
|
||||||
}
|
}
|
||||||
@ -117,18 +128,30 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz)
|
|||||||
siz -= uiosiz;
|
siz -= uiosiz;
|
||||||
}
|
}
|
||||||
if (rem > 0) {
|
if (rem > 0) {
|
||||||
if (rem > M_TRAILINGSPACE(mp)) {
|
if ((nd->nd_flag & ND_EXTPG) == 0 && rem >
|
||||||
|
M_TRAILINGSPACE(mp)) {
|
||||||
NFSMGET(mp);
|
NFSMGET(mp);
|
||||||
mp->m_len = 0;
|
mp->m_len = 0;
|
||||||
mp2->m_next = mp;
|
mp2->m_next = mp;
|
||||||
|
mcp = mtod(mp, char *);
|
||||||
|
} else if ((nd->nd_flag & ND_EXTPG) != 0 && rem >
|
||||||
|
nd->nd_bextpgsiz) {
|
||||||
|
mp = nfsm_add_ext_pgs(mp, nd->nd_maxextsiz,
|
||||||
|
&nd->nd_bextpg);
|
||||||
|
mcp = (char *)(void *)
|
||||||
|
PHYS_TO_DMAP(mp->m_epg_pa[nd->nd_bextpg]);
|
||||||
|
nd->nd_bextpgsiz = PAGE_SIZE;
|
||||||
}
|
}
|
||||||
cp = mtod(mp, caddr_t) + mp->m_len;
|
|
||||||
for (left = 0; left < rem; left++)
|
for (left = 0; left < rem; left++)
|
||||||
*cp++ = '\0';
|
*mcp++ = '\0';
|
||||||
mp->m_len += rem;
|
mp->m_len += rem;
|
||||||
nd->nd_bpos = cp;
|
nd->nd_bpos = mcp;
|
||||||
|
if ((nd->nd_flag & ND_EXTPG) != 0) {
|
||||||
|
nd->nd_bextpgsiz -= rem;
|
||||||
|
mp->m_epg_last_len += rem;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
nd->nd_bpos = mtod(mp, caddr_t) + mp->m_len;
|
nd->nd_bpos = mcp;
|
||||||
nd->nd_mb = mp;
|
nd->nd_mb = mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user