diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 3ce61e7f6198..aed42c799efb 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -71,6 +71,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include /* geometry translation */ #include /* for xpt_print below */ @@ -96,9 +98,10 @@ _Static_assert(XPT_PRINT_LEN <= XPT_PRINT_MAXLEN, "XPT_PRINT_LEN is too large"); /* Datastructures internal to the xpt layer */ MALLOC_DEFINE(M_CAMXPT, "CAM XPT", "CAM XPT buffers"); MALLOC_DEFINE(M_CAMDEV, "CAM DEV", "CAM devices"); -MALLOC_DEFINE(M_CAMCCB, "CAM CCB", "CAM CCBs"); MALLOC_DEFINE(M_CAMPATH, "CAM path", "CAM paths"); +static uma_zone_t xpt_ccb_zone; + /* Object for defering XPT actions to a taskqueue */ struct xpt_task { struct task task; @@ -906,6 +909,9 @@ xpt_init(void *dummy) xsoftc.xpt_taskq = taskqueue_create("CAM XPT task", M_WAITOK, taskqueue_thread_enqueue, /*context*/&xsoftc.xpt_taskq); + xpt_ccb_zone = uma_zcreate("CAM CCB", sizeof(union ccb), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOBUCKET); + #ifdef CAM_BOOT_DELAY /* * Override this value at compile time to assist our users @@ -4698,30 +4704,25 @@ xpt_done_direct(union ccb *done_ccb) } union ccb * -xpt_alloc_ccb() +xpt_alloc_ccb(void) { - union ccb *new_ccb; - new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK); - return (new_ccb); + return (uma_zalloc(xpt_ccb_zone, M_ZERO | M_WAITOK)); } union ccb * -xpt_alloc_ccb_nowait() +xpt_alloc_ccb_nowait(void) { - union ccb *new_ccb; - new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT); - return (new_ccb); + return (uma_zalloc(xpt_ccb_zone, M_ZERO | M_NOWAIT)); } void xpt_free_ccb(union ccb *free_ccb) { - free(free_ccb, M_CAMCCB); -} - + uma_zfree(xpt_ccb_zone, free_ccb); +} /* Private XPT functions */ @@ -4735,7 +4736,7 @@ xpt_get_ccb_nowait(struct cam_periph *periph) { union ccb *new_ccb; - new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT); + new_ccb = xpt_alloc_ccb_nowait(); if (new_ccb == NULL) return (NULL); periph->periph_allocated++; @@ -4749,7 +4750,7 @@ xpt_get_ccb(struct cam_periph *periph) union ccb *new_ccb; cam_periph_unlock(periph); - new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK); + new_ccb = xpt_alloc_ccb(); cam_periph_lock(periph); periph->periph_allocated++; cam_ccbq_take_opening(&periph->path->device->ccbq);