diff options
author | ru <ru@FreeBSD.org> | 2008-03-25 09:39:02 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2008-03-25 09:39:02 +0000 |
commit | 3b1bf8c2e9222b7d27e8b9084e637a84005de7ba (patch) | |
tree | cf0376c9359f2d1ca6e4e8e4ad4a4f722dba61a7 /sys | |
parent | 0655a583e2ccba8b534e710284a730a0d6af1375 (diff) | |
download | FreeBSD-src-3b1bf8c2e9222b7d27e8b9084e637a84005de7ba.zip FreeBSD-src-3b1bf8c2e9222b7d27e8b9084e637a84005de7ba.tar.gz |
Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT.
Removed dead code that assumed that M_TRYWAIT can return NULL; it's not true
since the advent of MBUMA.
Reviewed by: arch
There are ongoing disputes as to whether we want to switch to directly using
UMA flags M_WAITOK/M_NOWAIT for mbuf(9) allocation.
Diffstat (limited to 'sys')
35 files changed, 121 insertions, 250 deletions
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c index 34ceff45..b937ca8 100644 --- a/sys/dev/en/midway.c +++ b/sys/dev/en/midway.c @@ -835,27 +835,15 @@ copy_mbuf(struct mbuf *m) { struct mbuf *new; - MGET(new, M_TRYWAIT, MT_DATA); - if (new == NULL) - return (NULL); + MGET(new, M_WAIT, MT_DATA); if (m->m_flags & M_PKTHDR) { M_MOVE_PKTHDR(new, m); - if (m->m_len > MHLEN) { - MCLGET(new, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(new); - return (NULL); - } - } + if (m->m_len > MHLEN) + MCLGET(new, M_WAIT); } else { - if (m->m_len > MLEN) { - MCLGET(new, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(new); - return (NULL); - } - } + if (m->m_len > MLEN) + MCLGET(new, M_WAIT); } bcopy(m->m_data, new->m_data, m->m_len); @@ -2932,9 +2920,7 @@ en_attach(struct en_softc *sc) &en_utopia_methods); utopia_init_media(&sc->utopia); - MGET(sc->padbuf, M_TRYWAIT, MT_DATA); - if (sc->padbuf == NULL) - goto fail; + MGET(sc->padbuf, M_WAIT, MT_DATA); bzero(sc->padbuf->m_data, MLEN); if (bus_dma_tag_create(NULL, 1, 0, diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c index 8ba31c1..1c3bf69 100644 --- a/sys/dev/fatm/if_fatm.c +++ b/sys/dev/fatm/if_fatm.c @@ -1776,21 +1776,11 @@ copy_mbuf(struct mbuf *m) if (m->m_flags & M_PKTHDR) { M_MOVE_PKTHDR(new, m); - if (m->m_len > MHLEN) { - MCLGET(new, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(new); - return (NULL); - } - } + if (m->m_len > MHLEN) + MCLGET(new, M_WAIT); } else { - if (m->m_len > MLEN) { - MCLGET(new, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(new); - return (NULL); - } - } + if (m->m_len > MLEN) + MCLGET(new, M_WAIT); } bcopy(m->m_data, new->m_data, m->m_len); diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index 438838d..dfc44ca 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -357,19 +357,11 @@ fwe_init(void *arg) STAILQ_INIT(&xferq->stdma); xferq->stproc = NULL; for (i = 0; i < xferq->bnchunk; i ++) { - m = -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - m_getcl(M_WAIT, MT_DATA, M_PKTHDR); -#else - m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); -#endif + m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR); xferq->bulkxfer[i].mbuf = m; - if (m != NULL) { - m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; - STAILQ_INSERT_TAIL(&xferq->stfree, - &xferq->bulkxfer[i], link); - } else - printf("%s: m_getcl failed\n", __FUNCTION__); + m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; + STAILQ_INSERT_TAIL(&xferq->stfree, + &xferq->bulkxfer[i], link); } STAILQ_INIT(&fwe->xferlist); for (i = 0; i < TX_MAX_QUEUE; i++) { diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c index a9d1f38..b99e378 100644 --- a/sys/dev/firewire/if_fwip.c +++ b/sys/dev/firewire/if_fwip.c @@ -332,19 +332,11 @@ fwip_init(void *arg) STAILQ_INIT(&xferq->stdma); xferq->stproc = NULL; for (i = 0; i < xferq->bnchunk; i ++) { - m = -#if defined(__DragonFly__) || __FreeBSD_version < 500000 - m_getcl(M_WAIT, MT_DATA, M_PKTHDR); -#else - m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); -#endif + m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR); xferq->bulkxfer[i].mbuf = m; - if (m != NULL) { - m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; - STAILQ_INSERT_TAIL(&xferq->stfree, - &xferq->bulkxfer[i], link); - } else - printf("fwip_as_input: m_getcl failed\n"); + m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; + STAILQ_INSERT_TAIL(&xferq->stfree, + &xferq->bulkxfer[i], link); } fwip->fwb.start = INET_FIFO; @@ -356,7 +348,7 @@ fwip_init(void *arg) xfer = fw_xfer_alloc(M_FWIP); if (xfer == NULL) break; - m = m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); + m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR); xfer->recv.payload = mtod(m, uint32_t *); xfer->recv.pay_len = MCLBYTES; xfer->hand = fwip_unicast_input; @@ -876,7 +868,7 @@ fwip_unicast_input_recycle(struct fwip_softc *fwip, struct fw_xfer *xfer) * We have finished with a unicast xfer. Allocate a new * cluster and stick it on the back of the input queue. */ - m = m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); + m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR); xfer->mbuf = m; xfer->recv.payload = mtod(m, uint32_t *); xfer->recv.pay_len = MCLBYTES; diff --git a/sys/dev/iscsi/initiator/isc_soc.c b/sys/dev/iscsi/initiator/isc_soc.c index 0826ff6..bbe891e 100644 --- a/sys/dev/iscsi/initiator/isc_soc.c +++ b/sys/dev/iscsi/initiator/isc_soc.c @@ -100,7 +100,7 @@ isc_sendPDU(isc_session_t *sp, pduq_t *pq) iv++; #else /* USE_MBUF */ /* mbuf for the iSCSI header */ - MGETHDR(mh, M_TRYWAIT, MT_DATA); + MGETHDR(mh, M_WAIT, MT_DATA); mh->m_len = mh->m_pkthdr.len = sizeof(union ipdu_u); mh->m_pkthdr.rcvif = NULL; MH_ALIGN(mh, sizeof(union ipdu_u)); @@ -160,7 +160,7 @@ isc_sendPDU(isc_session_t *sp, pduq_t *pq) while (len > 0) { int l; - MGET(md, M_TRYWAIT, MT_DATA); + MGET(md, M_WAIT, MT_DATA); md->m_ext.ref_cnt = &nil_refcnt; l = min(MCLBYTES, len); MEXTADD(md, pp->ds + off, l, nil_fn, @@ -187,7 +187,7 @@ isc_sendPDU(isc_session_t *sp, pduq_t *pq) iv->iov_len = sizeof(int); iv++; #else /* USE_MBUF */ - MGET(me, M_TRYWAIT, MT_DATA); + MGET(me, M_WAIT, MT_DATA); me->m_len = sizeof(int); MH_ALIGN(mh, sizeof(int)); bcopy(&pp->ds_dig, me->m_data, sizeof(int)); diff --git a/sys/kern/subr_mchain.c b/sys/kern/subr_mchain.c index dc70af2..239564e 100644 --- a/sys/kern/subr_mchain.c +++ b/sys/kern/subr_mchain.c @@ -56,9 +56,7 @@ mb_init(struct mbchain *mbp) { struct mbuf *m; - m = m_gethdr(M_TRYWAIT, MT_DATA); - if (m == NULL) - return ENOBUFS; + m = m_gethdr(M_WAIT, MT_DATA); m->m_len = 0; mb_initm(mbp, m); return 0; @@ -113,9 +111,7 @@ mb_reserve(struct mbchain *mbp, int size) panic("mb_reserve: size = %d\n", size); m = mbp->mb_cur; if (mbp->mb_mleft < size) { - mn = m_get(M_TRYWAIT, MT_DATA); - if (mn == NULL) - return NULL; + mn = m_get(M_WAIT, MT_DATA); mbp->mb_cur = m->m_next = mn; m = mn; m->m_len = 0; @@ -190,11 +186,9 @@ mb_put_mem(struct mbchain *mbp, c_caddr_t source, int size, int type) while (size > 0) { if (mleft == 0) { - if (m->m_next == NULL) { - m = m_getm(m, size, M_TRYWAIT, MT_DATA); - if (m == NULL) - return ENOBUFS; - } else + if (m->m_next == NULL) + m = m_getm(m, size, M_WAIT, MT_DATA); + else m = m->m_next; mleft = M_TRAILINGSPACE(m); continue; @@ -295,9 +289,7 @@ md_init(struct mdchain *mdp) { struct mbuf *m; - m = m_gethdr(M_TRYWAIT, MT_DATA); - if (m == NULL) - return ENOBUFS; + m = m_gethdr(M_WAIT, MT_DATA); m->m_len = 0; md_initm(mdp, m); return 0; @@ -503,9 +495,7 @@ md_get_mbuf(struct mdchain *mdp, int size, struct mbuf **ret) { struct mbuf *m = mdp->md_cur, *rm; - rm = m_copym(m, mdp->md_pos - mtod(m, u_char*), size, M_TRYWAIT); - if (rm == NULL) - return EBADRPC; + rm = m_copym(m, mdp->md_pos - mtod(m, u_char*), size, M_WAIT); md_get_mem(mdp, NULL, size, MB_MZERO); *ret = rm; return 0; diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 9015ec7..eff51eb 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -519,7 +519,7 @@ m_prepend(struct mbuf *m, int len, int how) /* * Make a copy of an mbuf chain starting "off0" bytes from the beginning, * continuing for "len" bytes. If len is M_COPYALL, copy to end of mbuf. - * The wait parameter is a choice of M_TRYWAIT/M_DONTWAIT from caller. + * The wait parameter is a choice of M_WAIT/M_DONTWAIT from caller. * Note that the copy is read-only, because clusters are not copied, * only their reference counts are incremented. */ diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index bbb4f89..4b25b58 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -860,16 +860,16 @@ sosend_copyin(struct uio *uio, struct mbuf **retmp, int atomic, long *space, } #else /* ZERO_COPY_SOCKETS */ if (top == NULL) { - m = m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); + m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR); m->m_pkthdr.len = 0; m->m_pkthdr.rcvif = NULL; } else - m = m_getcl(M_TRYWAIT, MT_DATA, 0); + m = m_getcl(M_WAIT, MT_DATA, 0); len = min(min(MCLBYTES, resid), *space); #endif /* ZERO_COPY_SOCKETS */ } else { if (top == NULL) { - m = m_gethdr(M_TRYWAIT, MT_DATA); + m = m_gethdr(M_WAIT, MT_DATA); m->m_pkthdr.len = 0; m->m_pkthdr.rcvif = NULL; @@ -881,7 +881,7 @@ sosend_copyin(struct uio *uio, struct mbuf **retmp, int atomic, long *space, if (atomic && m && len < MHLEN) MH_ALIGN(m, len); } else { - m = m_get(M_TRYWAIT, MT_DATA); + m = m_get(M_WAIT, MT_DATA); len = min(min(MLEN, resid), *space); } } @@ -1304,9 +1304,7 @@ soreceive_rcvoob(struct socket *so, struct uio *uio, int flags) KASSERT(flags & MSG_OOB, ("soreceive_rcvoob: (flags & MSG_OOB) == 0")); - m = m_get(M_TRYWAIT, MT_DATA); - if (m == NULL) - return (ENOBUFS); + m = m_get(M_WAIT, MT_DATA); error = (*pr->pr_usrreqs->pru_rcvoob)(so, m, flags & MSG_PEEK); if (error) goto bad; @@ -1718,11 +1716,11 @@ dontblock: if (flags & MSG_DONTWAIT) copy_flag = M_DONTWAIT; else - copy_flag = M_TRYWAIT; - if (copy_flag == M_TRYWAIT) + copy_flag = M_WAIT; + if (copy_flag == M_WAIT) SOCKBUF_UNLOCK(&so->so_rcv); *mp = m_copym(m, 0, len, copy_flag); - if (copy_flag == M_TRYWAIT) + if (copy_flag == M_WAIT) SOCKBUF_LOCK(&so->so_rcv); if (*mp == NULL) { /* @@ -2333,11 +2331,11 @@ soopt_getm(struct sockopt *sopt, struct mbuf **mp) struct mbuf *m, *m_prev; int sopt_size = sopt->sopt_valsize; - MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT, MT_DATA); if (m == NULL) return ENOBUFS; if (sopt_size > MLEN) { - MCLGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT); + MCLGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_free(m); return ENOBUFS; @@ -2351,13 +2349,13 @@ soopt_getm(struct sockopt *sopt, struct mbuf **mp) m_prev = m; while (sopt_size) { - MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT, MT_DATA); if (m == NULL) { m_freem(*mp); return ENOBUFS; } if (sopt_size > MLEN) { - MCLGET(m, sopt->sopt_td != NULL ? M_TRYWAIT : + MCLGET(m, sopt->sopt_td != NULL ? M_WAIT : M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(m); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 270c4d8..ab5cb5f 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -705,16 +705,11 @@ sendit(td, s, mp, flags) if (mp->msg_flags == MSG_COMPAT) { struct cmsghdr *cm; - M_PREPEND(control, sizeof(*cm), M_TRYWAIT); - if (control == 0) { - error = ENOBUFS; - goto bad; - } else { - cm = mtod(control, struct cmsghdr *); - cm->cmsg_len = control->m_len; - cm->cmsg_level = SOL_SOCKET; - cm->cmsg_type = SCM_RIGHTS; - } + M_PREPEND(control, sizeof(*cm), M_WAIT); + cm = mtod(control, struct cmsghdr *); + cm->cmsg_len = control->m_len; + cm->cmsg_level = SOL_SOCKET; + cm->cmsg_type = SCM_RIGHTS; } #endif } else { @@ -1627,16 +1622,9 @@ sockargs(mp, buf, buflen, type) if ((u_int)buflen > MCLBYTES) return (EINVAL); } - m = m_get(M_TRYWAIT, type); - if (m == NULL) - return (ENOBUFS); - if ((u_int)buflen > MLEN) { - MCLGET(m, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(m); - return (ENOBUFS); - } - } + m = m_get(M_WAIT, type); + if ((u_int)buflen > MLEN) + MCLGET(m, M_WAIT); m->m_len = buflen; error = copyin(buf, mtod(m, caddr_t), (u_int)buflen); if (error) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index eef3241..7de49049 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -386,13 +386,10 @@ bpf_movein(struct uio *uio, int linktype, struct ifnet *ifp, struct mbuf **mp, if ((unsigned)len > MCLBYTES) return (EIO); - if (len > MHLEN) { - m = m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR); - } else { - MGETHDR(m, M_TRYWAIT, MT_DATA); - } - if (m == NULL) - return (ENOBUFS); + if (len > MHLEN) + m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR); + else + MGETHDR(m, M_WAIT, MT_DATA); m->m_pkthdr.len = m->m_len = len; m->m_pkthdr.rcvif = NULL; *mp = m; diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c index 19c1687..cf12fab 100644 --- a/sys/net/if_ef.c +++ b/sys/net/if_ef.c @@ -415,11 +415,7 @@ ef_output(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, type = htons(m->m_pkthdr.len); break; case ETHER_FT_8022: - M_PREPEND(m, ETHER_HDR_LEN + 3, M_TRYWAIT); - if (m == NULL) { - *mp = NULL; - return ENOBUFS; - } + M_PREPEND(m, ETHER_HDR_LEN + 3, M_WAIT); /* * Ensure that ethernet header and next three bytes * will fit into single mbuf @@ -438,11 +434,7 @@ ef_output(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, *hlen += 3; break; case ETHER_FT_SNAP: - M_PREPEND(m, 8, M_TRYWAIT); - if (m == NULL) { - *mp = NULL; - return ENOBUFS; - } + M_PREPEND(m, 8, M_WAIT); type = htons(m->m_pkthdr.len); cp = mtod(m, u_char *); bcopy("\xAA\xAA\x03\x00\x00\x00\x81\x37", cp, 8); diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 7152eac..c4e7b62 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -204,9 +204,7 @@ fddi_output(ifp, m, dst, rt0) if (aa->aa_flags & AFA_PHASE2) { struct llc llc; - M_PREPEND(m, LLC_SNAPFRAMELEN, M_TRYWAIT); - if (m == 0) - senderr(ENOBUFS); + M_PREPEND(m, LLC_SNAPFRAMELEN, M_WAIT); llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP; llc.llc_control = LLC_UI; bcopy(at_org_code, llc.llc_snap.org_code, sizeof(at_org_code)); diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index 7abf585..dd50923 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -336,9 +336,7 @@ iso88025_output(ifp, m, dst, rt0) bcopy((caddr_t)&(satoipx_addr(dst).x_host), (caddr_t)edst, ISO88025_ADDR_LEN); - M_PREPEND(m, 3, M_TRYWAIT); - if (m == 0) - senderr(ENOBUFS); + M_PREPEND(m, 3, M_WAIT); m = m_pullup(m, 3); if (m == 0) senderr(ENOBUFS); diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index 3e33970..801d3a7 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -298,20 +298,8 @@ slcreate(void) return (NULL); } - m = m_gethdr(M_TRYWAIT, MT_DATA); - if (m != NULL) { - MCLGET(m, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(m); - m = NULL; - } - } - - if (m == NULL) { - printf("sl: can't allocate buffer\n"); - free(sc, M_SL); - return (NULL); - } + m = m_gethdr(M_WAIT, MT_DATA); + MCLGET(m, M_WAIT); sc->sc_ep = mtod(m, u_char *) + SLBUFSIZE; sc->sc_mbuf = m; diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c index 705db61..dd41180 100644 --- a/sys/net/raw_cb.c +++ b/sys/net/raw_cb.c @@ -141,7 +141,7 @@ raw_bind(so, nam) if (ifnet == 0) return (EADDRNOTAVAIL); rp = sotorawcb(so); - nam = m_copym(nam, 0, M_COPYALL, M_TRYWAIT); + nam = m_copym(nam, 0, M_COPYALL, M_WAIT); rp->rcb_laddr = mtod(nam, struct sockaddr *); return (0); } diff --git a/sys/netatalk/aarp.c b/sys/netatalk/aarp.c index c13d610..fc328d3 100644 --- a/sys/netatalk/aarp.c +++ b/sys/netatalk/aarp.c @@ -633,9 +633,7 @@ aarpprobe(void *arg) sizeof(eh->ether_dhost)); eh->ether_type = htons(sizeof(struct llc) + sizeof(struct ether_aarp)); - M_PREPEND(m, sizeof(struct llc), M_TRYWAIT); - if (m == NULL) - return; + M_PREPEND(m, sizeof(struct llc), M_WAIT); llc = mtod(m, struct llc *); llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; llc->llc_control = LLC_UI; diff --git a/sys/netatm/port.h b/sys/netatm/port.h index 1487ac5..c9daf61 100644 --- a/sys/netatm/port.h +++ b/sys/netatm/port.h @@ -126,7 +126,7 @@ #include <sys/mbuf.h> typedef struct mbuf KBuffer; -#define KB_F_WAIT M_TRYWAIT +#define KB_F_WAIT M_WAIT #define KB_F_NOWAIT M_DONTWAIT #define KB_T_HEADER MT_HEADER diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 2cdf1a6..78aff7f 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -823,7 +823,7 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt) error = EMSGSIZE; break; } - MGET(m, sopt->sopt_td ? M_TRYWAIT : M_DONTWAIT, MT_DATA); + MGET(m, sopt->sopt_td ? M_WAIT : M_DONTWAIT, MT_DATA); if (m == NULL) { error = ENOBUFS; break; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index c0b2bd7..e2faaa6 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -2729,7 +2729,7 @@ ip6_getmoptions(int optname, struct ip6_moptions *im6o, struct mbuf **mp) { u_int *hlim, *loop, *ifindex; - *mp = m_get(M_TRYWAIT, MT_HEADER); /* XXX */ + *mp = m_get(M_WAIT, MT_HEADER); /* XXX */ switch (optname) { diff --git a/sys/netncp/ncp_sock.c b/sys/netncp/ncp_sock.c index 426f40c..3c4d5b9 100644 --- a/sys/netncp/ncp_sock.c +++ b/sys/netncp/ncp_sock.c @@ -163,7 +163,7 @@ ncp_sock_send(struct socket *so, struct mbuf *top, struct ncp_rq *rqp) int error, flags=0; for (;;) { - m = m_copym(top, 0, M_COPYALL, M_TRYWAIT); + m = m_copym(top, 0, M_COPYALL, M_WAIT); /* NCPDDEBUG(m);*/ error = sosend(so, to, 0, m, 0, flags, td); if (error == 0 || error == EINTR || error == ENETDOWN) diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c index e265f43..860ff4b 100644 --- a/sys/netsmb/smb_iod.c +++ b/sys/netsmb/smb_iod.c @@ -261,8 +261,8 @@ smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp) } SMBSDEBUG("M:%04x, P:%04x, U:%04x, T:%04x\n", rqp->sr_mid, 0, 0, 0); m_dumpm(rqp->sr_rq.mb_top); - m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_TRYWAIT); - error = rqp->sr_lerror = m ? SMB_TRAN_SEND(vcp, m, td) : ENOBUFS; + m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_WAIT); + error = rqp->sr_lerror = SMB_TRAN_SEND(vcp, m, td); if (error == 0) { getnanotime(&rqp->sr_timesent); iod->iod_lastrqsent = rqp->sr_timesent; diff --git a/sys/netsmb/smb_rq.c b/sys/netsmb/smb_rq.c index fb7e5d5..5d2557c 100644 --- a/sys/netsmb/smb_rq.c +++ b/sys/netsmb/smb_rq.c @@ -433,9 +433,7 @@ smb_t2_placedata(struct mbuf *mtop, u_int16_t offset, u_int16_t count, struct mbuf *m, *m0; int len; - m0 = m_split(mtop, offset, M_TRYWAIT); - if (m0 == NULL) - return EBADRPC; + m0 = m_split(mtop, offset, M_WAIT); len = m_length(m0, &m); m->m_len -= len - count; if (mdp->md_top == NULL) { diff --git a/sys/netsmb/smb_trantcp.c b/sys/netsmb/smb_trantcp.c index 5e34943..88fd556 100644 --- a/sys/netsmb/smb_trantcp.c +++ b/sys/netsmb/smb_trantcp.c @@ -572,9 +572,7 @@ smb_nbst_send(struct smb_vc *vcp, struct mbuf *m0, struct thread *td) error = ENOTCONN; goto abort; } - M_PREPEND(m0, 4, M_TRYWAIT); - if (m0 == NULL) - return ENOBUFS; + M_PREPEND(m0, 4, M_WAIT); nb_sethdr(m0, NB_SSN_MESSAGE, m_fixhdr(m0) - 4); error = nb_sosend(nbp->nbp_tso, m0, 0, td); return error; diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index 54c3f41..4c0a2c9 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -263,7 +263,7 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos) void *ret; if (s > M_TRAILINGSPACE(*mb)) { - MGET(mb2, M_TRYWAIT, MT_DATA); + MGET(mb2, M_WAIT, MT_DATA); if (s > MLEN) panic("build > MLEN"); (*mb)->m_next = mb2; @@ -280,7 +280,7 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos) void * nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos) { - return nfsm_dissect_xx_sub(s, md, dpos, M_TRYWAIT); + return nfsm_dissect_xx_sub(s, md, dpos, M_WAIT); } void * diff --git a/sys/nfsclient/krpc_subr.c b/sys/nfsclient/krpc_subr.c index b5a1d15..d7f6059 100644 --- a/sys/nfsclient/krpc_subr.c +++ b/sys/nfsclient/krpc_subr.c @@ -151,9 +151,7 @@ krpc_portmap(struct sockaddr_in *sin, u_int prog, u_int vers, u_int16_t *portp, return 0; } - m = m_get(M_TRYWAIT, MT_DATA); - if (m == NULL) - return ENOBUFS; + m = m_get(M_WAIT, MT_DATA); sdata = mtod(m, struct sdata *); m->m_len = sizeof(*sdata); @@ -274,7 +272,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func, /* * Prepend RPC message header. */ - mhead = m_gethdr(M_TRYWAIT, MT_DATA); + mhead = m_gethdr(M_WAIT, MT_DATA); mhead->m_next = *data; call = mtod(mhead, struct krpc_call *); mhead->m_len = sizeof(*call); @@ -308,11 +306,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func, timo = 0; for (;;) { /* Send RPC request (or re-send). */ - m = m_copym(mhead, 0, M_COPYALL, M_TRYWAIT); - if (m == NULL) { - error = ENOBUFS; - goto out; - } + m = m_copym(mhead, 0, M_COPYALL, M_WAIT); error = sosend(so, (struct sockaddr *)sa, NULL, m, NULL, 0, td); if (error) { @@ -462,14 +456,9 @@ 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_TRYWAIT, MT_DATA); - if (mlen > MLEN) { - MCLGET(m, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - (void) m_free(m); /* There can be only one. */ - return (NULL); - } - } + m = m_get(M_WAIT, MT_DATA); + if (mlen > MLEN) + MCLGET(m, M_WAIT); xs = mtod(m, struct xdr_string *); m->m_len = mlen; xs->len = txdr_unsigned(len); diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c index 3975577..140edb4 100644 --- a/sys/nfsclient/nfs_socket.c +++ b/sys/nfsclient/nfs_socket.c @@ -1169,7 +1169,7 @@ nfs_request(struct vnode *vp, struct mbuf *mrest, int procnum, * For stream protocols, insert a Sun RPC Record Mark. */ if (nmp->nm_sotype == SOCK_STREAM) { - M_PREPEND(m, NFSX_UNSIGNED, M_TRYWAIT); + M_PREPEND(m, NFSX_UNSIGNED, M_WAIT); *mtod(m, u_int32_t *) = htonl(0x80000000 | (m->m_pkthdr.len - NFSX_UNSIGNED)); } @@ -1213,7 +1213,7 @@ tryagain: if (nmp->nm_sotype == SOCK_STREAM) nmp->nm_nfstcpstate.sock_send_inprog++; mtx_unlock(&nmp->nm_mtx); - m2 = m_copym(m, 0, M_COPYALL, M_TRYWAIT); + m2 = m_copym(m, 0, M_COPYALL, M_WAIT); error = nfs_send(nmp->nm_so, nmp->nm_nam, m2, rep); mtx_lock(&nmp->nm_mtx); mtx_lock(&rep->r_mtx); diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index 6b5c63f..9f57ab3 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -165,9 +165,9 @@ nfsm_reqhead(struct vnode *vp, u_long procid, int hsiz) { struct mbuf *mb; - MGET(mb, M_TRYWAIT, MT_DATA); + MGET(mb, M_WAIT, MT_DATA); if (hsiz >= MINCLSIZE) - MCLGET(mb, M_TRYWAIT); + MCLGET(mb, M_WAIT); mb->m_len = 0; return (mb); } @@ -191,9 +191,9 @@ nfsm_rpchead(struct ucred *cr, int nmflag, int procid, int auth_type, int grpsiz, authsiz; authsiz = nfsm_rndup(auth_len); - MGETHDR(mb, M_TRYWAIT, MT_DATA); + MGETHDR(mb, M_WAIT, MT_DATA); if ((authsiz + 10 * NFSX_UNSIGNED) >= MINCLSIZE) { - MCLGET(mb, M_TRYWAIT); + MCLGET(mb, M_WAIT); } else if ((authsiz + 10 * NFSX_UNSIGNED) < MHLEN) { MH_ALIGN(mb, authsiz + 10 * NFSX_UNSIGNED); } else { @@ -286,9 +286,9 @@ 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_TRYWAIT, MT_DATA); + MGET(mp, M_WAIT, MT_DATA); if (clflg) - MCLGET(mp, M_TRYWAIT); + MCLGET(mp, M_WAIT); mp->m_len = 0; mp2->m_next = mp; mp2 = mp; @@ -319,7 +319,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_TRYWAIT, MT_DATA); + MGET(mp, M_WAIT, MT_DATA); mp->m_len = 0; mp2->m_next = mp; } @@ -364,9 +364,9 @@ nfsm_strtmbuf(struct mbuf **mb, char **bpos, const char *cp, long siz) } /* Loop around adding mbufs */ while (siz > 0) { - MGET(m1, M_TRYWAIT, MT_DATA); + MGET(m1, M_WAIT, MT_DATA); if (siz > MLEN) - MCLGET(m1, M_TRYWAIT); + MCLGET(m1, M_WAIT); m1->m_len = NFSMSIZ(m1); m2->m_next = m1; m2 = m1; @@ -563,7 +563,7 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp, md = *mdp; t1 = (mtod(md, caddr_t) + md->m_len) - *dposp; - cp2 = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, M_TRYWAIT); + cp2 = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, M_WAIT); if (cp2 == NULL) return EBADRPC; fp = (struct nfs_fattr *)cp2; diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 67a0a7f..04f743a 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -686,8 +686,8 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, len = 0; i = 0; while (len < NFS_MAXPATHLEN) { - MGET(nmp, M_TRYWAIT, MT_DATA); - MCLGET(nmp, M_TRYWAIT); + MGET(nmp, M_WAIT, MT_DATA); + MCLGET(nmp, M_WAIT); nmp->m_len = NFSMSIZ(nmp); if (len == 0) mp3 = mp = nmp; @@ -935,8 +935,8 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, i++; } if (left > 0) { - MGET(m, M_TRYWAIT, MT_DATA); - MCLGET(m, M_TRYWAIT); + MGET(m, M_WAIT, MT_DATA); + MCLGET(m, M_WAIT); m->m_len = 0; m2->m_next = m; m2 = m; diff --git a/sys/nfsserver/nfs_srvcache.c b/sys/nfsserver/nfs_srvcache.c index ca6b8c2..a0f272b 100644 --- a/sys/nfsserver/nfs_srvcache.c +++ b/sys/nfsserver/nfs_srvcache.c @@ -227,7 +227,7 @@ loop: nfsrvstats.srvcache_nonidemdonehits++; NFSD_UNLOCK(); *repp = m_copym(rp->rc_reply, 0, M_COPYALL, - M_TRYWAIT); + M_WAIT); NFSD_LOCK(); ret = RC_REPLY; } else { @@ -348,7 +348,7 @@ loop: } else { NFSD_UNLOCK(); rp->rc_reply = m_copym(repmbuf, - 0, M_COPYALL, M_TRYWAIT); + 0, M_COPYALL, M_WAIT); NFSD_LOCK(); rp->rc_flag |= RC_REPMBUF; } diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c index 1a7f91b..6df5998 100644 --- a/sys/nfsserver/nfs_srvsock.c +++ b/sys/nfsserver/nfs_srvsock.c @@ -148,7 +148,7 @@ nfs_rephead(int siz, struct nfsrv_descript *nd, int err, nd->nd_repstat = err; if (err && (nd->nd_flag & ND_NFSV3) == 0) /* XXX recheck */ siz = 0; - MGETHDR(mreq, M_TRYWAIT, MT_DATA); + MGETHDR(mreq, M_WAIT, MT_DATA); mb = mreq; /* * If this is a big reply, use a cluster else @@ -157,7 +157,7 @@ nfs_rephead(int siz, struct nfsrv_descript *nd, int err, mreq->m_len = 6 * NFSX_UNSIGNED; siz += RPC_REPLYSIZ; if ((max_hdr + siz) >= MINCLSIZE) { - MCLGET(mreq, M_TRYWAIT); + MCLGET(mreq, M_WAIT); } else mreq->m_data += min(max_hdr, M_TRAILINGSPACE(mreq)); tl = mtod(mreq, u_int32_t *); @@ -244,9 +244,9 @@ nfs_realign(struct mbuf **pm, int hsiz) /* XXX COMMON */ ++nfs_realign_test; while ((m = *pm) != NULL) { if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) { - MGET(n, M_TRYWAIT, MT_DATA); + MGET(n, M_WAIT, MT_DATA); if (m->m_len >= MINCLSIZE) { - MCLGET(n, M_TRYWAIT); + MCLGET(n, M_WAIT); } n->m_len = 0; break; @@ -401,7 +401,7 @@ nfsmout: * Socket upcall routine for the nfsd sockets. * The caddr_t arg is a pointer to the "struct nfssvc_sock". * Essentially do as much as possible non-blocking, else punt and it will - * be called with M_TRYWAIT from an nfsd. + * be called with M_WAIT from an nfsd. */ void nfsrv_rcv(struct socket *so, void *arg, int waitflag) diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 6db52b6..9fa702c 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -1352,8 +1352,8 @@ nfsm_clget_xx(u_int32_t **tl, struct mbuf *mb, struct mbuf **mp, if (*bp >= *be) { if (*mp == mb) (*mp)->m_len += *bp - bpos; - MGET(nmp, M_TRYWAIT, MT_DATA); - MCLGET(nmp, M_TRYWAIT); + MGET(nmp, M_WAIT, MT_DATA); + MCLGET(nmp, M_WAIT); nmp->m_len = NFSMSIZ(nmp); (*mp)->m_next = nmp; *mp = nmp; diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index 3043fcd..52ba9d9 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -351,7 +351,7 @@ nfssvc_nfsd(struct thread *td) (void) nfs_slplock(slp, 1); NFSD_UNLOCK(); nfsrv_rcv(slp->ns_so, (caddr_t)slp, - M_TRYWAIT); + M_WAIT); NFSD_LOCK(); nfs_slpunlock(slp); } @@ -489,7 +489,7 @@ nfssvc_nfsd(struct thread *td) * Record Mark. */ if (sotype == SOCK_STREAM) { - M_PREPEND(m, NFSX_UNSIGNED, M_TRYWAIT); + M_PREPEND(m, NFSX_UNSIGNED, M_WAIT); *mtod(m, u_int32_t *) = htonl(0x80000000 | siz); } NFSD_LOCK(); diff --git a/sys/pci/if_mn.c b/sys/pci/if_mn.c index ebe421f..e8b3dc6 100644 --- a/sys/pci/if_mn.c +++ b/sys/pci/if_mn.c @@ -693,9 +693,7 @@ ngmn_connect(hook_p hook) /* Setup a transmit chain with one descriptor */ /* XXX: we actually send a 1 byte packet */ dp = mn_alloc_desc(); - MGETHDR(m, M_TRYWAIT, MT_DATA); - if (m == NULL) - return ENOBUFS; + MGETHDR(m, M_WAIT, MT_DATA); m->m_pkthdr.len = 0; dp->m = m; dp->flags = 0xc0000000 + (1 << 16); @@ -710,17 +708,8 @@ ngmn_connect(hook_p hook) dp = mn_alloc_desc(); m = NULL; - MGETHDR(m, M_TRYWAIT, MT_DATA); - if (m == NULL) { - mn_free_desc(dp); - return (ENOBUFS); - } - MCLGET(m, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - mn_free_desc(dp); - m_freem(m); - return (ENOBUFS); - } + MGETHDR(m, M_WAIT, MT_DATA); + MCLGET(m, M_WAIT); dp->m = m; dp->data = vtophys(m->m_data); dp->flags = 0x40000000; @@ -733,18 +722,8 @@ ngmn_connect(hook_p hook) dp2 = dp; dp = mn_alloc_desc(); m = NULL; - MGETHDR(m, M_TRYWAIT, MT_DATA); - if (m == NULL) { - mn_free_desc(dp); - m_freem(m); - return (ENOBUFS); - } - MCLGET(m, M_TRYWAIT); - if ((m->m_flags & M_EXT) == 0) { - mn_free_desc(dp); - m_freem(m); - return (ENOBUFS); - } + MGETHDR(m, M_WAIT, MT_DATA); + MCLGET(m, M_WAIT); dp->m = m; dp->data = vtophys(m->m_data); dp->flags = 0x00000000; diff --git a/sys/rpc/rpcclnt.c b/sys/rpc/rpcclnt.c index 94ffd52..ba41a3c 100644 --- a/sys/rpc/rpcclnt.c +++ b/sys/rpc/rpcclnt.c @@ -801,7 +801,7 @@ tryagain: goto tryagain; } while (rep->r_flags & R_MUSTRESEND) { - m = m_copym(rep->r_mreq, 0, M_COPYALL, M_TRYWAIT); + m = m_copym(rep->r_mreq, 0, M_COPYALL, M_WAIT); rpcstats.rpcretries++; error = rpcclnt_send(so, rep->r_rpcclnt->rc_name, m, rep); if (error) { @@ -1181,7 +1181,7 @@ rpcclnt_request(rpc, mrest, procnum, td, cred, reply) * For stream protocols, insert a Sun RPC Record Mark. */ if (rpc->rc_sotype == SOCK_STREAM) { - M_PREPEND(m, RPCX_UNSIGNED, M_TRYWAIT); + M_PREPEND(m, RPCX_UNSIGNED, M_WAIT); *mtod(m, u_int32_t *) = htonl(0x80000000 | (m->m_pkthdr.len - RPCX_UNSIGNED)); } @@ -1229,7 +1229,7 @@ rpcclnt_request(rpc, mrest, procnum, td, cred, reply) error = rpcclnt_sndlock(&rpc->rc_flag, task); if (!error) { error = rpcclnt_send(rpc->rc_so, rpc->rc_name, - m_copym(m, 0, M_COPYALL, M_TRYWAIT), + m_copym(m, 0, M_COPYALL, M_WAIT), task); if (rpc->rc_soflags & PR_CONNREQUIRED) rpcclnt_sndunlock(&rpc->rc_flag); @@ -1750,9 +1750,9 @@ rpcclnt_realign(struct mbuf **pm, int hsiz) while ((m = *pm) != NULL) { if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) { - MGET(n, M_TRYWAIT, MT_DATA); + MGET(n, M_WAIT, MT_DATA); if (m->m_len >= MINCLSIZE) { - MCLGET(n, M_TRYWAIT); + MCLGET(n, M_WAIT); } n->m_len = 0; break; @@ -1826,9 +1826,9 @@ rpcclnt_buildheader(rc, procid, mrest, mrest_len, xidp, mheadend, cred) struct mbuf *mreq, *mb2; int error; - MGETHDR(mb, M_TRYWAIT, MT_DATA); + MGETHDR(mb, M_WAIT, MT_DATA); if (6 * RPCX_UNSIGNED >= MINCLSIZE) { - MCLGET(mb, M_TRYWAIT); + MCLGET(mb, M_WAIT); } else if (6 * RPCX_UNSIGNED < MHLEN) { MH_ALIGN(mb, 6 * RPCX_UNSIGNED); } else { @@ -1908,7 +1908,7 @@ rpcm_disct(mdp, dposp, siz, left, cp2) } else if (siz > MHLEN) { panic("rpc S too big"); } else { - MGET(mp2, M_TRYWAIT, MT_DATA); + MGET(mp2, M_WAIT, MT_DATA); mp2->m_next = mp->m_next; mp->m_next = mp2; mp->m_len -= left; diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 8bb2eae..c0fa484 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -291,11 +291,11 @@ struct mbstat { * * The flag to use is as follows: * - M_DONTWAIT or M_NOWAIT from an interrupt handler to not block allocation. - * - M_WAIT or M_WAITOK or M_TRYWAIT from wherever it is safe to block. + * - M_WAIT or M_WAITOK from wherever it is safe to block. * * M_DONTWAIT/M_NOWAIT means that we will not block the thread explicitly and * if we cannot allocate immediately we may return NULL, whereas - * M_WAIT/M_WAITOK/M_TRYWAIT means that if we cannot allocate resources we + * M_WAIT/M_WAITOK means that if we cannot allocate resources we * will block until they are available, and thus never return NULL. * * XXX Eventually just phase this out to use M_WAITOK/M_NOWAIT. |