SCCS-vsn: sys/kern/uipc_mbuf.c 6.4
-/* uipc_mbuf.c 6.3 84/08/29 */
+/* uipc_mbuf.c 6.4 85/05/27 */
#include "../machine/pte.h"
#include "../machine/pte.h"
- if (m_clalloc(4096/CLBYTES, MPG_MBUFS) == 0)
+ s = splimp();
+ if (m_clalloc(4096/CLBYTES, MPG_MBUFS, M_DONTWAIT) == 0)
- if (m_clalloc(8*4096/CLBYTES, MPG_CLUSTERS) == 0)
+ if (m_clalloc(8*4096/CLBYTES, MPG_CLUSTERS, M_DONTWAIT) == 0)
return;
bad:
panic("mbinit");
}
return;
bad:
panic("mbinit");
}
+/*
+ * Must be called at splimp.
+ */
+m_clalloc(ncl, how, canwait)
register int ncl;
int how;
{
int npg, mbx;
register struct mbuf *m;
register int i;
register int ncl;
int how;
{
int npg, mbx;
register struct mbuf *m;
register int i;
- s = splimp(); /* careful: rmalloc isn't reentrant */
mbx = rmalloc(mbmap, (long)npg);
mbx = rmalloc(mbmap, (long)npg);
- splx(s);
- if (mbx == 0)
+ if (mbx == 0) {
+ if (canwait == M_WAIT)
+ panic("out of mbuf map");
m = cltom(mbx / CLSIZE);
if (memall(&Mbmap[mbx], npg, proc, CSYS) == 0) {
m = cltom(mbx / CLSIZE);
if (memall(&Mbmap[mbx], npg, proc, CSYS) == 0) {
rmfree(mbmap, (long)npg, (long)mbx);
rmfree(mbmap, (long)npg, (long)mbx);
return (0);
}
vmaccess(&Mbmap[mbx], (caddr_t)m, npg);
switch (how) {
case MPG_CLUSTERS:
return (0);
}
vmaccess(&Mbmap[mbx], (caddr_t)m, npg);
switch (how) {
case MPG_CLUSTERS:
for (i = 0; i < ncl; i++) {
m->m_off = 0;
m->m_next = mclfree;
for (i = 0; i < ncl; i++) {
m->m_off = 0;
m->m_next = mclfree;
mbstat.m_clfree++;
}
mbstat.m_clusters += ncl;
mbstat.m_clfree++;
}
mbstat.m_clusters += ncl;
+/*
+ * Must be called at splimp.
+ */
+m_expand(canwait)
+ int canwait;
- if (m_clalloc(1, MPG_MBUFS) == 0)
+ if (m_clalloc(1, MPG_MBUFS, canwait) == 0)
goto steal;
return (1);
steal:
goto steal;
return (1);
steal:
{
register struct mbuf *m;
{
register struct mbuf *m;
- m = m_get(canwait, type);
+ MGET(m, canwait, type);
if (m == 0)
return (0);
bzero(mtod(m, caddr_t), MLEN);
if (m == 0)
return (0);
bzero(mtod(m, caddr_t), MLEN);
+/*
+ * Get more mbufs; called from MGET macro if mfree list is empty.
+ * Must be called at splimp.
+ */
/*ARGSUSED*/
struct mbuf *
m_more(canwait, type)
/*ARGSUSED*/
struct mbuf *
m_more(canwait, type)
{
register struct mbuf *m;
{
register struct mbuf *m;
- if (!m_expand()) {
- mbstat.m_drops++;
- return (NULL);
+ while (m_expand(canwait) == 0) {
+ if (canwait == M_WAIT) {
+ m_want++;
+ sleep((caddr_t)mfree, PZERO - 1);
+ } else {
+ mbstat.m_drops++;
+ return (NULL);
+ }
}
#define m_more(x,y) (panic("m_more"), (struct mbuf *)0)
MGET(m, canwait, type);
}
#define m_more(x,y) (panic("m_more"), (struct mbuf *)0)
MGET(m, canwait, type);
/*
* Mbuffer utility routines.
*/
/*
* Mbuffer utility routines.
*/
+
+/*
+ * Make a copy of an mbuf chain starting "off" bytes from the beginning,
+ * continuing for "len" bytes. If len is M_COPYALL, copy to end of mbuf.
+ * Should get M_WAIT/M_DONTWAIT from caller.
+ */
struct mbuf *
m_copy(m, off, len)
register struct mbuf *m;
struct mbuf *
m_copy(m, off, len)
register struct mbuf *m;
panic("m_copy");
break;
}
panic("m_copy");
break;
}
- MGET(n, M_WAIT, m->m_type);
+ MGET(n, M_DONTWAIT, m->m_type);
*np = n;
if (n == 0)
goto nospace;
*np = n;
if (n == 0)
goto nospace;