svn commit: r212149 - head/sys/dev/iscsi/initiator
Dag-Erling Smorgrav
des at FreeBSD.org
Thu Sep 2 14:13:44 UTC 2010
Author: des
Date: Thu Sep 2 14:13:43 2010
New Revision: 212149
URL: http://svn.freebsd.org/changeset/base/212149
Log:
Remove the freelist, which simply duplicates some of the zone allocator's
functionality.
Submitted by: Daniel Braniss <danny at cs.huji.ac.il>
MFC after: 3 weeks
Modified:
head/sys/dev/iscsi/initiator/iscsi.c
head/sys/dev/iscsi/initiator/iscsivar.h
Modified: head/sys/dev/iscsi/initiator/iscsi.c
==============================================================================
--- head/sys/dev/iscsi/initiator/iscsi.c Thu Sep 2 14:05:32 2010 (r212148)
+++ head/sys/dev/iscsi/initiator/iscsi.c Thu Sep 2 14:13:43 2010 (r212149)
@@ -295,12 +295,6 @@ iscsi_read(struct cdev *dev, struct uio
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);
Modified: head/sys/dev/iscsi/initiator/iscsivar.h
==============================================================================
--- head/sys/dev/iscsi/initiator/iscsivar.h Thu Sep 2 14:05:32 2010 (r212148)
+++ head/sys/dev/iscsi/initiator/iscsivar.h Thu Sep 2 14:13:43 2010 (r212149)
@@ -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 wai
{
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 *
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
More information about the svn-src-all
mailing list