svn commit: r359810 - in head/sys/fs: nfs nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Sat Apr 11 20:57:16 UTC 2020
Author: rmacklem
Date: Sat Apr 11 20:57:15 2020
New Revision: 359810
URL: https://svnweb.freebsd.org/changeset/base/359810
Log:
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.
Modified:
head/sys/fs/nfs/nfs_commonkrpc.c
head/sys/fs/nfs/nfsm_subs.h
head/sys/fs/nfsserver/nfs_nfsdcache.c
head/sys/fs/nfsserver/nfs_nfsdport.c
head/sys/fs/nfsserver/nfs_nfsdserv.c
head/sys/fs/nfsserver/nfs_nfsdstate.c
Modified: head/sys/fs/nfs/nfs_commonkrpc.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonkrpc.c Sat Apr 11 20:36:54 2020 (r359809)
+++ head/sys/fs/nfs/nfs_commonkrpc.c Sat Apr 11 20:57:15 2020 (r359810)
@@ -1188,8 +1188,8 @@ tryagain:
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)
Modified: head/sys/fs/nfs/nfsm_subs.h
==============================================================================
--- head/sys/fs/nfs/nfsm_subs.h Sat Apr 11 20:36:54 2020 (r359809)
+++ head/sys/fs/nfs/nfsm_subs.h Sat Apr 11 20:57:15 2020 (r359810)
@@ -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 s
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;
Modified: head/sys/fs/nfsserver/nfs_nfsdcache.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdcache.c Sat Apr 11 20:36:54 2020 (r359809)
+++ head/sys/fs/nfsserver/nfs_nfsdcache.c Sat Apr 11 20:57:15 2020 (r359810)
@@ -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);
Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c Sat Apr 11 20:36:54 2020 (r359809)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c Sat Apr 11 20:57:15 2020 (r359810)
@@ -903,18 +903,18 @@ nfsrv_createiovecw(int retlen, struct mbuf *m, char *c
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. */
Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdserv.c Sat Apr 11 20:36:54 2020 (r359809)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.c Sat Apr 11 20:57:15 2020 (r359810)
@@ -692,9 +692,9 @@ nfsrvd_readlink(struct nfsrv_descript *nd, __unused in
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 is
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 is
}
*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 in
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);
Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdstate.c Sat Apr 11 20:36:54 2020 (r359809)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c Sat Apr 11 20:57:15 2020 (r359810)
@@ -4468,9 +4468,9 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, n
* 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, n
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, n
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, n
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, n
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 @@ errout:
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--;
More information about the svn-src-all
mailing list