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 commit is contained in:
Rick Macklem 2020-04-11 20:57:15 +00:00
parent 9803dbb3ea
commit 9f6624d317
6 changed files with 28 additions and 28 deletions

View File

@ -1188,8 +1188,8 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp,
newnfs_restore_sigmask(td, &oldset);
return (0);
nfsmout:
mbuf_freem(nd->nd_mrep);
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mrep);
m_freem(nd->nd_mreq);
if (usegssname == 0)
AUTH_DESTROY(auth);
if (rep != NULL)

View File

@ -68,8 +68,8 @@ nfsm_build(struct nfsrv_descript *nd, int siz)
NFSMCLGET(mb2, M_NOWAIT);
if (siz > MLEN)
panic("build > MLEN");
mbuf_setlen(mb2, 0);
nd->nd_bpos = NFSMTOD(mb2, caddr_t);
mb2->m_len = 0;
nd->nd_bpos = mtod(mb2, caddr_t);
nd->nd_mb->m_next = mb2;
nd->nd_mb = mb2;
}
@ -87,7 +87,7 @@ nfsm_dissect(struct nfsrv_descript *nd, int siz)
int tt1;
void *retp;
tt1 = NFSMTOD(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos;
tt1 = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos;
if (tt1 >= siz) {
retp = (void *)nd->nd_dpos;
nd->nd_dpos += siz;
@ -103,7 +103,7 @@ nfsm_dissect_nonblock(struct nfsrv_descript *nd, int siz)
int tt1;
void *retp;
tt1 = NFSMTOD(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos;
tt1 = mtod(nd->nd_md, caddr_t) + nd->nd_md->m_len - nd->nd_dpos;
if (tt1 >= siz) {
retp = (void *)nd->nd_dpos;
nd->nd_dpos += siz;

View File

@ -486,7 +486,7 @@ nfsrvd_updatecache(struct nfsrv_descript *nd)
mtx_unlock(mutex);
nd->nd_repstat = 0;
if (nd->nd_mreq)
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mreq);
if (!(rp->rc_flag & RC_REPMBUF))
panic("reply from cache");
nd->nd_mreq = m_copym(rp->rc_reply, 0,
@ -798,7 +798,7 @@ nfsrc_freecache(struct nfsrvcache *rp)
}
nfsrc_wanted(rp);
if (rp->rc_flag & RC_REPMBUF) {
mbuf_freem(rp->rc_reply);
m_freem(rp->rc_reply);
if (!(rp->rc_flag & RC_UDP))
atomic_add_int(&nfsrc_tcpsavedreplies, -1);
}
@ -1020,8 +1020,8 @@ nfsrc_getlenandcksum(mbuf_t m1, u_int16_t *cksum)
m = m1;
while (m) {
len += mbuf_len(m);
m = mbuf_next(m);
len += m->m_len;
m = m->m_next;
}
cklen = (len > NFSRVCACHE_CHECKLEN) ? NFSRVCACHE_CHECKLEN : len;
*cksum = in_cksum(m1, cklen);

View File

@ -903,18 +903,18 @@ nfsrv_createiovecw(int retlen, struct mbuf *m, char *cp, struct iovec **ivpp,
cnt = 0;
len = retlen;
mp = m;
i = mtod(mp, caddr_t) + mbuf_len(mp) - cp;
i = mtod(mp, caddr_t) + mp->m_len - cp;
while (len > 0) {
if (i > 0) {
len -= i;
cnt++;
}
mp = mbuf_next(mp);
mp = mp->m_next;
if (!mp) {
if (len > 0)
return (EBADRPC);
} else
i = mbuf_len(mp);
i = mp->m_len;
}
/* Now, create the iovec. */

View File

@ -692,9 +692,9 @@ nfsrvd_readlink(struct nfsrv_descript *nd, __unused int isdgram,
goto out;
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(len);
mbuf_setnext(nd->nd_mb, mp);
nd->nd_mb->m_next = mp;
nd->nd_mb = mpend;
nd->nd_bpos = NFSMTOD(mpend, caddr_t) + mbuf_len(mpend);
nd->nd_bpos = mtod(mpend, caddr_t) + mpend->m_len;
out:
NFSEXITCODE2(0, nd);
@ -849,7 +849,7 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram,
if (nd->nd_repstat) {
vput(vp);
if (m3)
mbuf_freem(m3);
m_freem(m3);
if (nd->nd_flag & ND_NFSV3)
nfsrv_postopattr(nd, getret, &nva);
goto out;
@ -873,9 +873,9 @@ nfsrvd_read(struct nfsrv_descript *nd, __unused int isdgram,
}
*tl = txdr_unsigned(cnt);
if (m3) {
mbuf_setnext(nd->nd_mb, m3);
nd->nd_mb->m_next = m3;
nd->nd_mb = m2;
nd->nd_bpos = NFSMTOD(m2, caddr_t) + mbuf_len(m2);
nd->nd_bpos = mtod(m2, caddr_t) + m2->m_len;
}
out:
@ -5564,9 +5564,9 @@ nfsrvd_getxattr(struct nfsrv_descript *nd, __unused int isdgram,
if (nd->nd_repstat == 0) {
NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
*tl = txdr_unsigned(len);
mbuf_setnext(nd->nd_mb, mp);
nd->nd_mb->m_next = mp;
nd->nd_mb = mpend;
nd->nd_bpos = NFSMTOD(mpend, caddr_t) + mbuf_len(mpend);
nd->nd_bpos = mtod(mpend, caddr_t) + mpend->m_len;
}
free(name, M_TEMP);

View File

@ -4468,9 +4468,9 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp,
* Get the first mbuf for the request.
*/
MGET(m, M_WAITOK, MT_DATA);
mbuf_setlen(m, 0);
m->m_len = 0;
nd->nd_mreq = nd->nd_mb = m;
nd->nd_bpos = NFSMTOD(m, caddr_t);
nd->nd_bpos = mtod(m, caddr_t);
/*
* and build the callback request.
@ -4480,7 +4480,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp,
error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBGETATTR,
"CB Getattr", &sep);
if (error != 0) {
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mreq);
goto errout;
}
(void)nfsm_fhtom(nd, (u_int8_t *)fhp, NFSX_MYFH, 0);
@ -4490,7 +4490,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp,
error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBRECALL,
"CB Recall", &sep);
if (error != 0) {
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mreq);
goto errout;
}
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_STATEID);
@ -4510,7 +4510,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp,
NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep);
NFSD_DEBUG(4, "aft cbcallargs=%d\n", error);
if (error != 0) {
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mreq);
goto errout;
}
NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
@ -4536,13 +4536,13 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp,
if ((clp->lc_flags & LCL_NFSV41) != 0) {
error = nfsv4_getcbsession(clp, &sep);
if (error != 0) {
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mreq);
goto errout;
}
}
} else {
error = NFSERR_SERVERFAULT;
mbuf_freem(nd->nd_mreq);
m_freem(nd->nd_mreq);
goto errout;
}
@ -4626,7 +4626,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp,
error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0,
NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL,
p, NULL);
mbuf_freem(nd->nd_mrep);
m_freem(nd->nd_mrep);
}
NFSLOCKSTATE();
clp->lc_cbref--;