Replace mbuf macros with the code they would generate in the NFS code.

When the code was ported to Mac OS/X, mbuf handling functions were
converted to using the Mac OS/X accessor functions. For FreeBSD, they
are a simple set of macros in sys/fs/nfs/nfskpiport.h.
Since porting to Mac OS/X is no longer a consideration, replacement of
these macros with the code generated by them makes the code more
readable.
When support for external page mbufs is added as needed by the KERN_TLS,
the patch becomes simpler if done without the macros.

This patch should not result in any semantic change.
This conversion will be committed one file at a time.
This commit is contained in:
rmacklem 2020-04-10 22:42:14 +00:00
parent 26844b844e
commit 23f6c382b1

View File

@ -87,8 +87,8 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz)
NFSMCLGET(mp, M_WAITOK);
else
NFSMGET(mp);
mbuf_setlen(mp, 0);
mbuf_setnext(mp2, mp);
mp->m_len = 0;
mp2->m_next = mp;
mp2 = mp;
mlen = M_TRAILINGSPACE(mp);
}
@ -97,17 +97,17 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz)
/* Not Yet.. */
if (uiop->uio_iov->iov_op != NULL)
(*(uiop->uio_iov->iov_op))
(uiocp, NFSMTOD(mp, caddr_t) + mbuf_len(mp),
(uiocp, mtod(mp, caddr_t) + mp->m_len,
xfer);
else
#endif
if (uiop->uio_segflg == UIO_SYSSPACE)
NFSBCOPY(uiocp, NFSMTOD(mp, caddr_t) + mbuf_len(mp),
NFSBCOPY(uiocp, mtod(mp, caddr_t) + mp->m_len,
xfer);
else
copyin(CAST_USER_ADDR_T(uiocp), NFSMTOD(mp, caddr_t)
+ mbuf_len(mp), xfer);
mbuf_setlen(mp, mbuf_len(mp) + xfer);
copyin(CAST_USER_ADDR_T(uiocp), mtod(mp, caddr_t)
+ mp->m_len, xfer);
mp->m_len += xfer;
left -= xfer;
uiocp += xfer;
uiop->uio_offset += xfer;
@ -122,16 +122,16 @@ nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz)
if (rem > 0) {
if (rem > M_TRAILINGSPACE(mp)) {
NFSMGET(mp);
mbuf_setlen(mp, 0);
mbuf_setnext(mp2, mp);
mp->m_len = 0;
mp2->m_next = mp;
}
cp = NFSMTOD(mp, caddr_t) + mbuf_len(mp);
cp = mtod(mp, caddr_t) + mp->m_len;
for (left = 0; left < rem; left++)
*cp++ = '\0';
mbuf_setlen(mp, mbuf_len(mp) + rem);
mp->m_len += rem;
nd->nd_bpos = cp;
} else
nd->nd_bpos = NFSMTOD(mp, caddr_t) + mbuf_len(mp);
nd->nd_bpos = mtod(mp, caddr_t) + mp->m_len;
nd->nd_mb = mp;
}
@ -159,7 +159,7 @@ nfsm_uiombuflist(struct uio *uiop, int siz, struct mbuf **mbp, char **cpp)
NFSMCLGET(mp, M_WAITOK);
else
NFSMGET(mp);
mbuf_setlen(mp, 0);
mp->m_len = 0;
firstmp = mp2 = mp;
while (siz > 0) {
left = uiop->uio_iov->iov_len;
@ -174,19 +174,19 @@ nfsm_uiombuflist(struct uio *uiop, int siz, struct mbuf **mbp, char **cpp)
NFSMCLGET(mp, M_WAITOK);
else
NFSMGET(mp);
mbuf_setlen(mp, 0);
mbuf_setnext(mp2, mp);
mp->m_len = 0;
mp2->m_next = mp;
mp2 = mp;
mlen = M_TRAILINGSPACE(mp);
}
xfer = (left > mlen) ? mlen : left;
if (uiop->uio_segflg == UIO_SYSSPACE)
NFSBCOPY(uiocp, NFSMTOD(mp, caddr_t) +
mbuf_len(mp), xfer);
NFSBCOPY(uiocp, mtod(mp, caddr_t) +
mp->m_len, xfer);
else
copyin(uiocp, NFSMTOD(mp, caddr_t) +
mbuf_len(mp), xfer);
mbuf_setlen(mp, mbuf_len(mp) + xfer);
copyin(uiocp, mtod(mp, caddr_t) +
mp->m_len, xfer);
mp->m_len += xfer;
left -= xfer;
uiocp += xfer;
uiop->uio_offset += xfer;
@ -199,7 +199,7 @@ nfsm_uiombuflist(struct uio *uiop, int siz, struct mbuf **mbp, char **cpp)
siz -= uiosiz;
}
if (cpp != NULL)
*cpp = NFSMTOD(mp, caddr_t) + mbuf_len(mp);
*cpp = mtod(mp, caddr_t) + mp->m_len;
if (mbp != NULL)
*mbp = mp;
return (firstmp);