Remove the freelist, which simply duplicates some of the zone allocator's
functionality. Submitted by: Daniel Braniss <danny@cs.huji.ac.il> MFC after: 3 weeks
This commit is contained in:
parent
2d15ca416e
commit
2cd149f045
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212149
@ -295,12 +295,6 @@ iscsi_read(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
sprintf(buf, "%d/%d /---- free -----/\n", sc->npdu_alloc, sc->npdu_max);
|
||||
i = 0;
|
||||
uiomove(buf, strlen(buf), uio);
|
||||
TAILQ_FOREACH(pq, &sc->freepdu, pq_link) {
|
||||
if(uio->uio_resid == 0)
|
||||
return 0;
|
||||
sprintf(buf, "%03d] %06x\n", i++, ntohl(pq->pdu.ipdu.bhs.itt));
|
||||
uiomove(buf, strlen(buf), uio);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int i = 0;
|
||||
@ -704,15 +698,10 @@ iscsi_shutdown(void *v)
|
||||
static void
|
||||
free_pdus(struct isc_softc *sc)
|
||||
{
|
||||
pduq_t *pq;
|
||||
|
||||
debug_called(8);
|
||||
|
||||
if(sc->pdu_zone != NULL) {
|
||||
TAILQ_FOREACH(pq, &sc->freepdu, pq_link) {
|
||||
TAILQ_REMOVE(&sc->freepdu, pq, pq_link);
|
||||
uma_zfree(sc->pdu_zone, pq);
|
||||
}
|
||||
uma_zdestroy(sc->pdu_zone);
|
||||
sc->pdu_zone = NULL;
|
||||
}
|
||||
@ -730,7 +719,6 @@ iscsi_start(void)
|
||||
isc->dev = make_dev(&iscsi_cdevsw, max_sessions, UID_ROOT, GID_WHEEL, 0600, "iscsi");
|
||||
isc->dev->si_drv1 = isc;
|
||||
mtx_init(&isc->isc_mtx, "iscsi", NULL, MTX_DEF);
|
||||
mtx_init(&isc->pdu_mtx, "iscsi pdu pool", NULL, MTX_DEF);
|
||||
|
||||
TAILQ_INIT(&isc->isc_sess);
|
||||
/*
|
||||
@ -744,7 +732,6 @@ iscsi_start(void)
|
||||
// XXX: should fail...
|
||||
}
|
||||
uma_zone_set_max(isc->pdu_zone, max_pdus);
|
||||
TAILQ_INIT(&isc->freepdu);
|
||||
isc->unit = new_unrhdr(0, max_sessions-1, NULL);
|
||||
sx_init(&isc->unit_sx, "iscsi sx");
|
||||
|
||||
@ -818,7 +805,6 @@ iscsi_stop(void)
|
||||
ic_destroy(sp);
|
||||
}
|
||||
mtx_destroy(&isc->isc_mtx);
|
||||
mtx_destroy(&isc->pdu_mtx);
|
||||
sx_destroy(&isc->unit_sx);
|
||||
|
||||
free_pdus(isc);
|
||||
|
@ -203,10 +203,7 @@ struct isc_softc {
|
||||
struct unrhdr *unit;
|
||||
struct sx unit_sx;
|
||||
|
||||
struct mtx pdu_mtx;
|
||||
uma_zone_t pdu_zone; // pool of free pdu's
|
||||
TAILQ_HEAD(,pduq) freepdu;
|
||||
|
||||
#ifdef ISCSI_INITIATOR_DEBUG
|
||||
int npdu_alloc, npdu_max; // for instrumentation
|
||||
#endif
|
||||
@ -303,25 +300,15 @@ pdu_alloc(struct isc_softc *isc, int wait)
|
||||
{
|
||||
pduq_t *pq;
|
||||
|
||||
mtx_lock(&isc->pdu_mtx);
|
||||
if((pq = TAILQ_FIRST(&isc->freepdu)) == NULL) {
|
||||
mtx_unlock(&isc->pdu_mtx);
|
||||
pq = (pduq_t *)uma_zalloc(isc->pdu_zone, wait /* M_WAITOK or M_NOWAIT*/);
|
||||
}
|
||||
else {
|
||||
TAILQ_REMOVE(&isc->freepdu, pq, pq_link);
|
||||
mtx_unlock(&isc->pdu_mtx);
|
||||
}
|
||||
pq = (pduq_t *)uma_zalloc(isc->pdu_zone, wait /* M_WAITOK or M_NOWAIT*/);
|
||||
if(pq == NULL) {
|
||||
debug(7, "out of mem");
|
||||
return NULL;
|
||||
}
|
||||
#ifdef ISCSI_INITIATOR_DEBUG
|
||||
mtx_lock(&isc->pdu_mtx);
|
||||
isc->npdu_alloc++;
|
||||
if(isc->npdu_alloc > isc->npdu_max)
|
||||
isc->npdu_max = isc->npdu_alloc;
|
||||
mtx_unlock(&isc->pdu_mtx);
|
||||
#endif
|
||||
memset(pq, 0, sizeof(pduq_t));
|
||||
|
||||
@ -337,12 +324,10 @@ pdu_free(struct isc_softc *isc, pduq_t *pq)
|
||||
if(pq->buf != NULL)
|
||||
free(pq->buf, M_ISCSIBUF);
|
||||
#endif
|
||||
mtx_lock(&isc->pdu_mtx);
|
||||
TAILQ_INSERT_TAIL(&isc->freepdu, pq, pq_link);
|
||||
#ifdef ISCSI_INITIATOR_DEBUG
|
||||
isc->npdu_alloc--;
|
||||
#endif
|
||||
mtx_unlock(&isc->pdu_mtx);
|
||||
uma_zfree(isc->pdu_zone, pq);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
|
Loading…
Reference in New Issue
Block a user