diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 4606f3771567..13c9b524ad17 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -255,25 +255,30 @@ m_freem(struct mbuf *mb) * Returns: * Nothing. */ -void +int m_extadd(struct mbuf *mb, caddr_t buf, u_int size, - void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type) + void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type, + int wait) { KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__)); if (type != EXT_EXTREF) - mb->m_ext.ref_cnt = (u_int *)uma_zalloc(zone_ext_refcnt, M_NOWAIT); - if (mb->m_ext.ref_cnt != NULL) { - *(mb->m_ext.ref_cnt) = 1; - mb->m_flags |= (M_EXT | flags); - mb->m_ext.ext_buf = buf; - mb->m_data = mb->m_ext.ext_buf; - mb->m_ext.ext_size = size; - mb->m_ext.ext_free = freef; - mb->m_ext.ext_arg1 = arg1; - mb->m_ext.ext_arg2 = arg2; - mb->m_ext.ext_type = type; - } + mb->m_ext.ref_cnt = uma_zalloc(zone_ext_refcnt, wait); + + if (mb->m_ext.ref_cnt == NULL) + return (ENOMEM); + + *(mb->m_ext.ref_cnt) = 1; + mb->m_flags |= (M_EXT | flags); + mb->m_ext.ext_buf = buf; + mb->m_data = mb->m_ext.ext_buf; + mb->m_ext.ext_size = size; + mb->m_ext.ext_free = freef; + mb->m_ext.ext_arg1 = arg1; + mb->m_ext.ext_arg2 = arg2; + mb->m_ext.ext_type = type; + + return (0); } /* diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index a2623067bd4f..4827cab53d6f 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -2222,8 +2222,14 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap, sf_buf_mext((void *)sf_buf_kva(sf), sf); break; } - MEXTADD(m0, sf_buf_kva(sf), PAGE_SIZE, sf_buf_mext, - sfs, sf, M_RDONLY, EXT_SFBUF); + if (m_extadd(m0, (caddr_t )sf_buf_kva(sf), PAGE_SIZE, + sf_buf_mext, sfs, sf, M_RDONLY, EXT_SFBUF, + (mnw ? M_NOWAIT : M_WAITOK)) != 0) { + error = (mnw ? EAGAIN : ENOBUFS); + sf_buf_mext((void *)sf_buf_kva(sf), sf); + m_freem(m0); + break; + } m0->m_data = (char *)sf_buf_kva(sf) + pgoff; m0->m_len = xfsize; diff --git a/sys/nfs/krpc_subr.c b/sys/nfs/krpc_subr.c index 6caafcf8f910..a1bb7b6cec8c 100644 --- a/sys/nfs/krpc_subr.c +++ b/sys/nfs/krpc_subr.c @@ -459,9 +459,7 @@ xdr_string_encode(char *str, int len) if (mlen > MCLBYTES) /* If too big, we just can't do it. */ return (NULL); - m = m_get(M_WAITOK, MT_DATA); - if (mlen > MLEN) - MCLGET(m, M_WAITOK); + m = m_get2(M_WAITOK, MT_DATA, 0, mlen); xs = mtod(m, struct xdr_string *); m->m_len = mlen; xs->len = txdr_unsigned(len); diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index 372322315549..7cc41af0b44e 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -171,23 +171,6 @@ nfs_xid_gen(void) return xid; } -/* - * Create the header for an rpc request packet - * The hsiz is the size of the rest of the nfs request header. - * (just used to decide if a cluster is a good idea) - */ -struct mbuf * -nfsm_reqhead(struct vnode *vp, u_long procid, int hsiz) -{ - struct mbuf *mb; - - MGET(mb, M_WAITOK, MT_DATA); - if (hsiz >= MINCLSIZE) - MCLGET(mb, M_WAITOK); - mb->m_len = 0; - return (mb); -} - /* * copies a uio scatter/gather list to an mbuf chain. * NOTE: can ony handle iovcnt == 1 @@ -218,10 +201,10 @@ nfsm_uiotombuf(struct uio *uiop, struct mbuf **mq, int siz, caddr_t *bpos) while (left > 0) { mlen = M_TRAILINGSPACE(mp); if (mlen == 0) { - MGET(mp, M_WAITOK, MT_DATA); if (clflg) - MCLGET(mp, M_WAITOK); - mp->m_len = 0; + mp = m_getcl(M_WAITOK, MT_DATA, 0); + else + mp = m_get(M_WAITOK, MT_DATA); mp2->m_next = mp; mp2 = mp; mlen = M_TRAILINGSPACE(mp); @@ -251,8 +234,7 @@ nfsm_uiotombuf(struct uio *uiop, struct mbuf **mq, int siz, caddr_t *bpos) } if (rem > 0) { if (rem > M_TRAILINGSPACE(mp)) { - MGET(mp, M_WAITOK, MT_DATA); - mp->m_len = 0; + mp = m_get(M_WAITOK, MT_DATA); mp2->m_next = mp; } cp = mtod(mp, caddr_t)+mp->m_len; @@ -296,10 +278,13 @@ nfsm_strtmbuf(struct mbuf **mb, char **bpos, const char *cp, long siz) } /* Loop around adding mbufs */ while (siz > 0) { - MGET(m1, M_WAITOK, MT_DATA); - if (siz > MLEN) - MCLGET(m1, M_WAITOK); - m1->m_len = NFSMSIZ(m1); + if (siz > MLEN) { + m1 = m_getcl(M_WAITOK, MT_DATA, 0); + m1->m_len = MCLBYTES; + } else { + m1 = m_get(M_WAITOK, MT_DATA); + m1->m_len = MLEN; + } m2->m_next = m1; m2 = m1; tl = mtod(m1, u_int32_t *); diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 9cec3077fbcb..90b0f7a9fe07 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -298,7 +298,7 @@ nfs_statfs(struct mount *mp, struct statfs *sbp) } else mtx_unlock(&nmp->nm_mtx); nfsstats.rpccnt[NFSPROC_FSSTAT]++; - mreq = nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -356,7 +356,7 @@ nfs_fsinfo(struct nfsmount *nmp, struct vnode *vp, struct ucred *cred, u_int64_t maxfsize; nfsstats.rpccnt[NFSPROC_FSINFO]++; - mreq = nfsm_reqhead(vp, NFSPROC_FSINFO, NFSX_FH(1)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(1)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, 1); diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index f5017eb28c12..5adc2a557305 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -294,7 +294,7 @@ nfs3_access_otw(struct vnode *vp, int wmode, struct thread *td, struct nfsnode *np = VTONFS(vp); nfsstats.rpccnt[NFSPROC_ACCESS]++; - mreq = nfsm_reqhead(vp, NFSPROC_ACCESS, NFSX_FH(v3) + NFSX_UNSIGNED); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3) + NFSX_UNSIGNED); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -714,7 +714,7 @@ nfs_getattr(struct vop_getattr_args *ap) goto nfsmout; } nfsstats.rpccnt[NFSPROC_GETATTR]++; - mreq = nfsm_reqhead(vp, NFSPROC_GETATTR, NFSX_FH(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -873,7 +873,7 @@ nfs_setattrrpc(struct vnode *vp, struct vattr *vap, struct ucred *cred) int v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_SETATTR]++; - mreq = nfsm_reqhead(vp, NFSPROC_SETATTR, NFSX_FH(v3) + NFSX_SATTR(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3) + NFSX_SATTR(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -1037,8 +1037,8 @@ nfs_lookup(struct vop_lookup_args *ap) nfsstats.lookupcache_misses++; nfsstats.rpccnt[NFSPROC_LOOKUP]++; len = cnp->cn_namelen; - mreq = nfsm_reqhead(dvp, NFSPROC_LOOKUP, - NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -1251,7 +1251,7 @@ nfs_readlinkrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) int v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_READLINK]++; - mreq = nfsm_reqhead(vp, NFSPROC_READLINK, NFSX_FH(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -1306,7 +1306,8 @@ nfs_readrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) while (tsiz > 0) { nfsstats.rpccnt[NFSPROC_READ]++; len = (tsiz > rsize) ? rsize : tsiz; - mreq = nfsm_reqhead(vp, NFSPROC_READ, NFSX_FH(v3) + NFSX_UNSIGNED * 3); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_UNSIGNED * 3); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -1378,8 +1379,8 @@ nfs_writerpc(struct vnode *vp, struct uio *uiop, struct ucred *cred, while (tsiz > 0) { nfsstats.rpccnt[NFSPROC_WRITE]++; len = (tsiz > wsize) ? wsize : tsiz; - mreq = nfsm_reqhead(vp, NFSPROC_WRITE, - NFSX_FH(v3) + 5 * NFSX_UNSIGNED + nfsm_rndup(len)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + 5 * NFSX_UNSIGNED + nfsm_rndup(len)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -1501,8 +1502,8 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) return (error); nfsstats.rpccnt[NFSPROC_MKNOD]++; - mreq = nfsm_reqhead(dvp, NFSPROC_MKNOD, NFSX_FH(v3) + 4 * NFSX_UNSIGNED + - + nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3) + 4 * NFSX_UNSIGNED + + nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -1605,8 +1606,8 @@ nfs_create(struct vop_create_args *ap) fmode |= O_EXCL; again: nfsstats.rpccnt[NFSPROC_CREATE]++; - mreq = nfsm_reqhead(dvp, NFSPROC_CREATE, NFSX_FH(v3) + 2 * NFSX_UNSIGNED + - nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3) + 2 * NFSX_UNSIGNED + + nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -1787,8 +1788,8 @@ nfs_removerpc(struct vnode *dvp, const char *name, int namelen, int v3 = NFS_ISV3(dvp); nfsstats.rpccnt[NFSPROC_REMOVE]++; - mreq = nfsm_reqhead(dvp, NFSPROC_REMOVE, - NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -1923,9 +1924,8 @@ nfs_renamerpc(struct vnode *fdvp, const char *fnameptr, int fnamelen, int v3 = NFS_ISV3(fdvp); nfsstats.rpccnt[NFSPROC_RENAME]++; - mreq = nfsm_reqhead(fdvp, NFSPROC_RENAME, - (NFSX_FH(v3) + NFSX_UNSIGNED)*2 + nfsm_rndup(fnamelen) + - nfsm_rndup(tnamelen)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, (NFSX_FH(v3) + NFSX_UNSIGNED)*2 + + nfsm_rndup(fnamelen) + nfsm_rndup(tnamelen)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(fdvp, v3); @@ -1983,8 +1983,8 @@ nfs_link(struct vop_link_args *ap) v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_LINK]++; - mreq = nfsm_reqhead(vp, NFSPROC_LINK, - NFSX_FH(v3)*2 + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3)*2 + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -2029,7 +2029,7 @@ nfs_symlink(struct vop_symlink_args *ap) nfsstats.rpccnt[NFSPROC_SYMLINK]++; slen = strlen(ap->a_target); - mreq = nfsm_reqhead(dvp, NFSPROC_SYMLINK, NFSX_FH(v3) + 2*NFSX_UNSIGNED + + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(v3) + 2*NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen) + nfsm_rndup(slen) + NFSX_SATTR(v3)); mb = mreq; bpos = mtod(mb, caddr_t); @@ -2123,8 +2123,8 @@ nfs_mkdir(struct vop_mkdir_args *ap) return (error); len = cnp->cn_namelen; nfsstats.rpccnt[NFSPROC_MKDIR]++; - mreq = nfsm_reqhead(dvp, NFSPROC_MKDIR, - NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len) + NFSX_SATTR(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len) + NFSX_SATTR(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -2188,8 +2188,8 @@ nfs_rmdir(struct vop_rmdir_args *ap) if (dvp == vp) return (EINVAL); nfsstats.rpccnt[NFSPROC_RMDIR]++; - mreq = nfsm_reqhead(dvp, NFSPROC_RMDIR, - NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -2307,8 +2307,8 @@ nfs_readdirrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) */ while (more_dirs && bigenough) { nfsstats.rpccnt[NFSPROC_READDIR]++; - mreq = nfsm_reqhead(vp, NFSPROC_READDIR, NFSX_FH(v3) + - NFSX_READDIR(v3)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_READDIR(v3)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, v3); @@ -2513,8 +2513,8 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred) */ while (more_dirs && bigenough) { nfsstats.rpccnt[NFSPROC_READDIRPLUS]++; - mreq = nfsm_reqhead(vp, NFSPROC_READDIRPLUS, - NFSX_FH(1) + 6 * NFSX_UNSIGNED); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(1) + 6 * NFSX_UNSIGNED); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, 1); @@ -2818,8 +2818,8 @@ nfs_lookitup(struct vnode *dvp, const char *name, int len, struct ucred *cred, int v3 = NFS_ISV3(dvp); nfsstats.rpccnt[NFSPROC_LOOKUP]++; - mreq = nfsm_reqhead(dvp, NFSPROC_LOOKUP, - NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, + NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(dvp, v3); @@ -2897,7 +2897,7 @@ nfs_commit(struct vnode *vp, u_quad_t offset, int cnt, struct ucred *cred, } mtx_unlock(&nmp->nm_mtx); nfsstats.rpccnt[NFSPROC_COMMIT]++; - mreq = nfsm_reqhead(vp, NFSPROC_COMMIT, NFSX_FH(1)); + mreq = m_get2(M_WAITOK, MT_DATA, 0, NFSX_FH(1)); mb = mreq; bpos = mtod(mb, caddr_t); nfsm_fhtom(vp, 1); diff --git a/sys/nfsclient/nfsm_subs.h b/sys/nfsclient/nfsm_subs.h index c12baddcc975..25467cc7bfc2 100644 --- a/sys/nfsclient/nfsm_subs.h +++ b/sys/nfsclient/nfsm_subs.h @@ -53,34 +53,6 @@ struct vnode; * First define what the actual subs. return */ u_int32_t nfs_xid_gen(void); -struct mbuf *nfsm_reqhead(struct vnode *vp, u_long procid, int hsiz); - -#define M_HASCL(m) ((m)->m_flags & M_EXT) -#define NFSMINOFF(m) \ - do { \ - if (M_HASCL(m)) \ - (m)->m_data = (m)->m_ext.ext_buf; \ - else if ((m)->m_flags & M_PKTHDR) \ - (m)->m_data = (m)->m_pktdat; \ - else \ - (m)->m_data = (m)->m_dat; \ - } while (0) -#define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \ - (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN)) - -/* - * Now for the macros that do the simple stuff and call the functions - * for the hard stuff. - * These macros use several vars. declared in nfsm_reqhead and these - * vars. must not be used elsewhere unless you are careful not to corrupt - * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries - * that may be used so long as the value is not expected to retained - * after a macro. - * I know, this is kind of dorkey, but it makes the actual op functions - * fairly clean and deals with the mess caused by the xdr discriminating - * unions. - */ - /* *********************************** */ /* Request generation phase macros */ diff --git a/sys/rpc/clnt_dg.c b/sys/rpc/clnt_dg.c index 86a8d01ee63e..a658de9eba53 100644 --- a/sys/rpc/clnt_dg.c +++ b/sys/rpc/clnt_dg.c @@ -431,7 +431,7 @@ clnt_dg_call( send_again: mtx_unlock(&cs->cs_lock); - MGETHDR(mreq, M_WAITOK, MT_DATA); + mreq = m_gethdr(M_WAITOK, MT_DATA); KASSERT(cu->cu_mcalllen <= MHLEN, ("RPC header too big")); bcopy(cu->cu_mcallc, mreq->m_data, cu->cu_mcalllen); mreq->m_len = cu->cu_mcalllen; diff --git a/sys/rpc/clnt_vc.c b/sys/rpc/clnt_vc.c index e42d26d4c843..bc48e198bddd 100644 --- a/sys/rpc/clnt_vc.c +++ b/sys/rpc/clnt_vc.c @@ -349,7 +349,7 @@ clnt_vc_call( /* * Leave space to pre-pend the record mark. */ - MGETHDR(mreq, M_WAITOK, MT_DATA); + mreq = m_gethdr(M_WAITOK, MT_DATA); mreq->m_data += sizeof(uint32_t); KASSERT(ct->ct_mpos + sizeof(uint32_t) <= MHLEN, ("RPC header too big")); diff --git a/sys/rpc/rpc_generic.c b/sys/rpc/rpc_generic.c index 65f57cf2e35c..dd5c6c354a20 100644 --- a/sys/rpc/rpc_generic.c +++ b/sys/rpc/rpc_generic.c @@ -750,9 +750,7 @@ clnt_call_private( struct mbuf *mrep; enum clnt_stat stat; - MGET(mreq, M_WAITOK, MT_DATA); - MCLGET(mreq, M_WAITOK); - mreq->m_len = 0; + mreq = m_getcl(M_WAITOK, MT_DATA, 0); xdrmbuf_create(&xdrs, mreq, XDR_ENCODE); if (!xargs(&xdrs, argsp)) { diff --git a/sys/rpc/rpcm_subs.h b/sys/rpc/rpcm_subs.h index f0d60a3d6ebc..e4fddb58334c 100644 --- a/sys/rpc/rpcm_subs.h +++ b/sys/rpc/rpcm_subs.h @@ -80,7 +80,7 @@ #define rpcm_build(a,c,s) \ { if ((s) > M_TRAILINGSPACE(mb)) { \ - MGET(mb2, M_WAITOK, MT_DATA); \ + mb2 = m_get(M_WAITOK, MT_DATA); \ if ((s) > MLEN) \ panic("build > MLEN"); \ mb->m_next = mb2; \ diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index f038e783c04e..bbc6f6d54505 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -563,9 +563,7 @@ svc_sendreply(struct svc_req *rqstp, xdrproc_t xdr_results, void * xdr_location) rply.acpted_rply.ar_results.where = NULL; rply.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void; - MGET(m, M_WAITOK, MT_DATA); - MCLGET(m, M_WAITOK); - m->m_len = 0; + m = m_getcl(M_WAITOK, MT_DATA, 0); xdrmbuf_create(&xdrs, m, XDR_ENCODE); ok = xdr_results(&xdrs, xdr_location); XDR_DESTROY(&xdrs); diff --git a/sys/rpc/svc_dg.c b/sys/rpc/svc_dg.c index ba6a56e1c700..3df79bb96e0f 100644 --- a/sys/rpc/svc_dg.c +++ b/sys/rpc/svc_dg.c @@ -238,8 +238,7 @@ svc_dg_reply(SVCXPRT *xprt, struct rpc_msg *msg, bool_t stat = TRUE; int error; - MGETHDR(mrep, M_WAITOK, MT_DATA); - mrep->m_len = 0; + mrep = m_gethdr(M_WAITOK, MT_DATA); xdrmbuf_create(&xdrs, mrep, XDR_ENCODE); diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c index 667d84c841cc..80824ef95610 100644 --- a/sys/rpc/svc_vc.c +++ b/sys/rpc/svc_vc.c @@ -796,8 +796,7 @@ svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg, /* * Leave space for record mark. */ - MGETHDR(mrep, M_WAITOK, MT_DATA); - mrep->m_len = 0; + mrep = m_gethdr(M_WAITOK, MT_DATA); mrep->m_data += sizeof(uint32_t); xdrmbuf_create(&xdrs, mrep, XDR_ENCODE); @@ -850,8 +849,7 @@ svc_vc_backchannel_reply(SVCXPRT *xprt, struct rpc_msg *msg, /* * Leave space for record mark. */ - MGETHDR(mrep, M_WAITOK, MT_DATA); - mrep->m_len = 0; + mrep = m_gethdr(M_WAITOK, MT_DATA); mrep->m_data += sizeof(uint32_t); xdrmbuf_create(&xdrs, mrep, XDR_ENCODE); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index af7f92b1267f..9960f533f5f5 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -655,7 +655,8 @@ m_last(struct mbuf *m) #define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type))) #define MCLGET(m, how) m_clget((m), (how)) #define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \ - m_extadd((m), (caddr_t)(buf), (size), (free),(arg1),(arg2),(flags), (type)) + (void )m_extadd((m), (caddr_t)(buf), (size), (free), (arg1), (arg2),\ + (flags), (type), M_NOWAIT) #define m_getm(m, len, how, type) \ m_getm2((m), (len), (how), (type), M_PKTHDR) @@ -780,8 +781,8 @@ int m_apply(struct mbuf *, int, int, int (*)(void *, void *, u_int), void *); int m_append(struct mbuf *, int, c_caddr_t); void m_cat(struct mbuf *, struct mbuf *); -void m_extadd(struct mbuf *, caddr_t, u_int, - void (*)(void *, void *), void *, void *, int, int); +int m_extadd(struct mbuf *, caddr_t, u_int, + void (*)(void *, void *), void *, void *, int, int, int); struct mbuf *m_collapse(struct mbuf *, int, int); void m_copyback(struct mbuf *, int, int, c_caddr_t); void m_copydata(const struct mbuf *, int, int, caddr_t); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 16fe378af6c3..79af894c768b 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2655,10 +2655,7 @@ vm_page_is_valid(vm_page_t m, int base, int size) VM_OBJECT_ASSERT_WLOCKED(m->object); bits = vm_page_bits(base, size); - if (m->valid && ((m->valid & bits) == bits)) - return 1; - else - return 0; + return (m->valid != 0 && (m->valid & bits) == bits); } /*