svn commit: r263811 - in head/sys: cam/ctl conf modules/ctl

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Mar 27 11:10:15 UTC 2014


Author: trasz
Date: Thu Mar 27 11:10:13 2014
New Revision: 263811
URL: http://svnweb.freebsd.org/changeset/base/263811

Log:
  Remove ctl_mem_pool.{c,h}.
  
  Sponsored by:	The FreeBSD Foundation

Deleted:
  head/sys/cam/ctl/ctl_mem_pool.c
  head/sys/cam/ctl/ctl_mem_pool.h
Modified:
  head/sys/cam/ctl/README.ctl.txt
  head/sys/cam/ctl/ctl_frontend_cam_sim.c
  head/sys/cam/ctl/ctl_frontend_internal.c
  head/sys/conf/files
  head/sys/modules/ctl/Makefile

Modified: head/sys/cam/ctl/README.ctl.txt
==============================================================================
--- head/sys/cam/ctl/README.ctl.txt	Thu Mar 27 10:15:35 2014	(r263810)
+++ head/sys/cam/ctl/README.ctl.txt	Thu Mar 27 11:10:13 2014	(r263811)
@@ -394,14 +394,6 @@ ctl_ioctl.h:
 This defines all ioctls available through the CTL character device, and
 the data structures needed for those ioctls.
 
-ctl_mem_pool.c
-ctl_mem_pool.h:
---------------
-
-Generic memory pool implementation.  This is currently only used by the
-internal frontend.  The internal frontend can probably be rewritten to use
-UMA zones and this can be removed.
-
 ctl_private.h:
 -------------
 

Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_cam_sim.c	Thu Mar 27 10:15:35 2014	(r263810)
+++ head/sys/cam/ctl/ctl_frontend_cam_sim.c	Thu Mar 27 11:10:13 2014	(r263811)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
 #include <cam/ctl/ctl.h>
 #include <cam/ctl/ctl_frontend.h>
 #include <cam/ctl/ctl_frontend_internal.h>
-#include <cam/ctl/ctl_mem_pool.h>
 #include <cam/ctl/ctl_debug.h>
 
 #define	io_ptr		spriv_ptr1

Modified: head/sys/cam/ctl/ctl_frontend_internal.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_internal.c	Thu Mar 27 10:15:35 2014	(r263810)
+++ head/sys/cam/ctl/ctl_frontend_internal.c	Thu Mar 27 11:10:13 2014	(r263811)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/queue.h>
 #include <sys/sbuf.h>
 #include <sys/sysctl.h>
+#include <vm/uma.h>
 #include <cam/scsi/scsi_all.h>
 #include <cam/scsi/scsi_da.h>
 #include <cam/ctl/ctl_io.h>
@@ -73,7 +74,6 @@ __FBSDID("$FreeBSD$");
 #include <cam/ctl/ctl_util.h>
 #include <cam/ctl/ctl_ha.h>
 #include <cam/ctl/ctl_private.h>
-#include <cam/ctl/ctl_mem_pool.h>
 #include <cam/ctl/ctl_debug.h>
 #include <cam/ctl/ctl_scsi_all.h>
 #include <cam/ctl/ctl_error.h>
@@ -118,7 +118,6 @@ struct cfi_metatask {
 	cfi_tasktype		tasktype;
 	cfi_mt_status		status;
 	union cfi_taskinfo	taskinfo;
-	struct ctl_mem_element	*element;
 	void			*cfi_context;
 	STAILQ_ENTRY(cfi_metatask) links;
 };
@@ -153,7 +152,6 @@ struct cfi_lun {
 	int blocksize_powerof2;
 	uint32_t cur_tag_num;
 	cfi_lun_state state;
-	struct ctl_mem_element *element;
 	struct cfi_softc *softc;
 	STAILQ_HEAD(, cfi_lun_io) io_list;
 	STAILQ_ENTRY(cfi_lun) links;
@@ -181,12 +179,13 @@ struct cfi_softc {
 	cfi_flags flags;
 	STAILQ_HEAD(, cfi_lun) lun_list;
 	STAILQ_HEAD(, cfi_metatask) metatask_list;
-	struct ctl_mem_pool lun_pool;
-	struct ctl_mem_pool metatask_pool;
 };
 
 MALLOC_DEFINE(M_CTL_CFI, "ctlcfi", "CTL CFI");
 
+static uma_zone_t cfi_lun_zone;
+static uma_zone_t cfi_metatask_zone;
+
 static struct cfi_softc fetd_internal_softc;
 
 int cfi_init(void);
@@ -275,48 +274,15 @@ cfi_init(void)
 	if (ctl_frontend_register(fe, (softc->flags & CTL_FLAG_MASTER_SHELF)) != 0) 
 	{
 		printf("%s: internal frontend registration failed\n", __func__);
-		retval = 1;
-		goto bailout;
+		return (0);
 	}
 
-	if (ctl_init_mem_pool(&softc->lun_pool,
-			      sizeof(struct cfi_lun),
-			      CTL_MEM_POOL_PERM_GROW, /*grow_inc*/ 3,
-			      /* initial_pool_size */ CTL_MAX_LUNS) != 0) {
-		printf("%s: can't initialize LUN memory pool\n", __func__);
-		retval = 1;
-		goto bailout_error;
-	}
-
-	if (ctl_init_mem_pool(&softc->metatask_pool,
-			      sizeof(struct cfi_metatask),
-			      CTL_MEM_POOL_PERM_GROW, /*grow_inc*/ 3,
-			      /*initial_pool_size*/ 10) != 0) {
-		printf("%s: can't initialize metatask memory pool\n", __func__);
-		retval = 2;
-		goto bailout_error;
-	}
-bailout:
+	cfi_lun_zone = uma_zcreate("cfi_lun", sizeof(struct cfi_lun),
+	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
+	cfi_metatask_zone = uma_zcreate("cfi_metatask", sizeof(struct cfi_metatask),
+	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
 
 	return (0);
-
-bailout_error:
-
-	switch (retval) {
-	case 3:
-		ctl_shrink_mem_pool(&softc->metatask_pool);
-		/* FALLTHROUGH */
-	case 2:
-		ctl_shrink_mem_pool(&softc->lun_pool);
-		/* FALLTHROUGH */
-	case 1:
-		ctl_frontend_deregister(fe);
-		break;
-	default:
-		break;
-	}
-
-	return (ENOMEM);
 }
 
 void
@@ -332,11 +298,8 @@ cfi_shutdown(void)
 	if (ctl_frontend_deregister(&softc->fe) != 0)
 		printf("%s: ctl_frontend_deregister() failed\n", __func__);
 
-	if (ctl_shrink_mem_pool(&softc->lun_pool) != 0)
-		printf("%s: error shrinking LUN pool\n", __func__);
-
-	if (ctl_shrink_mem_pool(&softc->metatask_pool) != 0)
-		printf("%s: error shrinking LUN pool\n", __func__);
+	uma_zdestroy(cfi_lun_zone);
+	uma_zdestroy(cfi_metatask_zone);
 }
 
 static int
@@ -398,7 +361,6 @@ cfi_targ_disable(void *arg, struct ctl_i
 static int
 cfi_lun_enable(void *arg, struct ctl_id target_id, int lun_id)
 {
-	struct ctl_mem_element *element;
 	struct cfi_softc *softc;
 	struct cfi_lun *lun;
 	int found;
@@ -423,16 +385,12 @@ cfi_lun_enable(void *arg, struct ctl_id 
 	if (found != 0)
 		return (0);
 
-	element = ctl_alloc_mem_element(&softc->lun_pool, /*can_wait*/ 0);
-
-	if (element == NULL) {
+	lun = uma_zalloc(cfi_lun_zone, M_NOWAIT | M_ZERO);
+	if (lun == NULL) {
 		printf("%s: unable to allocate LUN structure\n", __func__);
 		return (1);
 	}
 
-	lun = (struct cfi_lun *)element->bytes;
-
-	lun->element = element;
 	lun->target_id = target_id;
 	lun->lun_id = lun_id;
 	lun->cur_tag_num = 0;
@@ -485,7 +443,7 @@ cfi_lun_disable(void *arg, struct ctl_id
 		return (1);
 	}
 
-	ctl_free_mem_element(lun->element);
+	uma_zfree(cfi_lun_zone, lun);
 
 	return (0);
 }
@@ -1682,106 +1640,20 @@ cfi_action(struct cfi_metatask *metatask
 	}
 }
 
-#ifdef oldapi
-void
-cfi_shutdown_shelf(cfi_cb_t callback, void *callback_arg)
-{
-	struct ctl_mem_element *element;
-	struct cfi_softc *softc;
-	struct cfi_metatask *metatask;
-
-	softc = &fetd_internal_softc;
-
-	element = ctl_alloc_mem_element(&softc->metatask_pool, /*can_wait*/ 0);
-	if (element == NULL) {
-		callback(callback_arg,
-			 /*status*/ CFI_MT_ERROR,
-			 /*sluns_found*/ 0,
-			 /*sluns_complete*/ 0,
-			 /*sluns_failed*/ 0);
-		return;
-	}
-
-	metatask = (struct cfi_metatask *)element->bytes;
-
-	memset(metatask, 0, sizeof(*metatask));
-	metatask->tasktype = CFI_TASK_SHUTDOWN;
-	metatask->status = CFI_MT_NONE;
-	metatask->taskinfo.startstop.callback = callback;
-	metatask->taskinfo.startstop.callback_arg = callback_arg;
-	metatask->element = element;
-
-	cfi_action(softc, metatask);
-
-	/*
-	 * - send a report luns to lun 0, get LUN list.
-	 * - send an inquiry to each lun
-	 * - send a stop/offline to each direct access LUN
-	 *    - if we get a reservation conflict, reset the LUN and then
-	 *      retry sending the stop/offline
-	 * - return status back to the caller
-	 */
-}
-
-void
-cfi_start_shelf(cfi_cb_t callback, void *callback_arg)
-{
-	struct ctl_mem_element *element;
-	struct cfi_softc *softc;
-	struct cfi_metatask *metatask;
-
-	softc = &fetd_internal_softc;
-
-	element = ctl_alloc_mem_element(&softc->metatask_pool, /*can_wait*/ 0);
-	if (element == NULL) {
-		callback(callback_arg,
-			 /*status*/ CFI_MT_ERROR,
-			 /*sluns_found*/ 0,
-			 /*sluns_complete*/ 0,
-			 /*sluns_failed*/ 0);
-		return;
-	}
-
-	metatask = (struct cfi_metatask *)element->bytes;
-
-	memset(metatask, 0, sizeof(*metatask));
-	metatask->tasktype = CFI_TASK_STARTUP;
-	metatask->status = CFI_MT_NONE;
-	metatask->taskinfo.startstop.callback = callback;
-	metatask->taskinfo.startstop.callback_arg = callback_arg;
-	metatask->element = element;
-
-	cfi_action(softc, metatask);
-
-	/*
-	 * - send a report luns to lun 0, get LUN list.
-	 * - send an inquiry to each lun
-	 * - send a stop/offline to each direct access LUN
-	 *    - if we get a reservation conflict, reset the LUN and then
-	 *      retry sending the stop/offline
-	 * - return status back to the caller
-	 */
-}
-
-#endif
-
 struct cfi_metatask *
 cfi_alloc_metatask(int can_wait)
 {
-	struct ctl_mem_element *element;
 	struct cfi_metatask *metatask;
 	struct cfi_softc *softc;
 
 	softc = &fetd_internal_softc;
 
-	element = ctl_alloc_mem_element(&softc->metatask_pool, can_wait);
-	if (element == NULL)
+	metatask = uma_zalloc(cfi_metatask_zone,
+	    (can_wait ? M_WAITOK : M_NOWAIT) | M_ZERO);
+	if (metatask == NULL)
 		return (NULL);
 
-	metatask = (struct cfi_metatask *)element->bytes;
-	memset(metatask, 0, sizeof(*metatask));
 	metatask->status = CFI_MT_NONE;
-	metatask->element = element;
 
 	return (metatask);
 }
@@ -1789,7 +1661,8 @@ cfi_alloc_metatask(int can_wait)
 void
 cfi_free_metatask(struct cfi_metatask *metatask)
 {
-	ctl_free_mem_element(metatask->element);
+
+	uma_zfree(cfi_metatask_zone, metatask);
 }
 
 /*

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Thu Mar 27 10:15:35 2014	(r263810)
+++ head/sys/conf/files	Thu Mar 27 11:10:13 2014	(r263811)
@@ -85,7 +85,6 @@ cam/ctl/ctl_frontend.c		optional ctl
 cam/ctl/ctl_frontend_cam_sim.c	optional ctl
 cam/ctl/ctl_frontend_internal.c	optional ctl
 cam/ctl/ctl_frontend_iscsi.c	optional ctl
-cam/ctl/ctl_mem_pool.c		optional ctl
 cam/ctl/ctl_scsi_all.c		optional ctl
 cam/ctl/ctl_error.c		optional ctl
 cam/ctl/ctl_util.c		optional ctl

Modified: head/sys/modules/ctl/Makefile
==============================================================================
--- head/sys/modules/ctl/Makefile	Thu Mar 27 10:15:35 2014	(r263810)
+++ head/sys/modules/ctl/Makefile	Thu Mar 27 11:10:13 2014	(r263811)
@@ -13,7 +13,6 @@ SRCS+=	ctl_frontend.c
 SRCS+=	ctl_frontend_cam_sim.c
 SRCS+=	ctl_frontend_internal.c
 SRCS+=	ctl_frontend_iscsi.c
-SRCS+=	ctl_mem_pool.c
 SRCS+=	ctl_scsi_all.c
 SRCS+=	ctl_error.c
 SRCS+=	ctl_util.c


More information about the svn-src-head mailing list