Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159547467
D26844.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D26844.diff
View Options
Index: sys/cam/cam_xpt.c
===================================================================
--- sys/cam/cam_xpt.c
+++ sys/cam/cam_xpt.c
@@ -54,6 +54,8 @@
#include <sys/sysctl.h>
#include <sys/kthread.h>
+#include <vm/uma.h>
+
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_iosched.h>
@@ -95,7 +97,6 @@
/* 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");
struct xpt_softc {
@@ -128,6 +129,7 @@
struct mtx xpt_topo_lock;
struct taskqueue *xpt_taskq;
+ uma_zone_t ccb_zone;
};
typedef enum {
@@ -899,6 +901,8 @@
mtx_init(&xsoftc.xpt_highpower_lock, "XPT highpower lock", NULL, MTX_DEF);
xsoftc.xpt_taskq = taskqueue_create("CAM XPT task", M_WAITOK,
taskqueue_thread_enqueue, /*context*/&xsoftc.xpt_taskq);
+ xsoftc.ccb_zone = uma_zcreate("ccb", sizeof(union ccb), NULL, NULL, NULL, NULL,
+ UMA_ALIGN_PTR, 0);
#ifdef CAM_BOOT_DELAY
/*
@@ -4651,7 +4655,7 @@
{
union ccb *new_ccb;
- new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK);
+ new_ccb = uma_zalloc(xsoftc.ccb_zone, M_WAITOK | M_ZERO);
return (new_ccb);
}
@@ -4660,14 +4664,15 @@
{
union ccb *new_ccb;
- new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT);
+ new_ccb = uma_zalloc(xsoftc.ccb_zone, M_NOWAIT | M_ZERO);
return (new_ccb);
}
void
xpt_free_ccb(union ccb *free_ccb)
{
- free(free_ccb, M_CAMCCB);
+
+ uma_zfree(xsoftc.ccb_zone, free_ccb);
}
/* Private XPT functions */
@@ -4682,7 +4687,7 @@
{
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++;
@@ -4696,7 +4701,7 @@
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);
Index: sys/cam/ctl/scsi_ctl.c
===================================================================
--- sys/cam/ctl/scsi_ctl.c
+++ sys/cam/ctl/scsi_ctl.c
@@ -499,15 +499,14 @@
union ctl_io *new_io;
struct ctlfe_cmd_info *cmd_info;
- new_ccb = (union ccb *)malloc(sizeof(*new_ccb), M_CTLFE,
- M_ZERO|M_NOWAIT);
+ new_ccb = xpt_alloc_ccb_nowait();
if (new_ccb == NULL) {
status = CAM_RESRC_UNAVAIL;
break;
}
new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref);
if (new_io == NULL) {
- free(new_ccb, M_CTLFE);
+ xpt_free_ccb(new_ccb);
status = CAM_RESRC_UNAVAIL;
break;
}
@@ -515,7 +514,7 @@
M_ZERO | M_NOWAIT);
if (cmd_info == NULL) {
ctl_free_io(new_io);
- free(new_ccb, M_CTLFE);
+ xpt_free_ccb(new_ccb);
status = CAM_RESRC_UNAVAIL;
break;
}
@@ -533,7 +532,7 @@
if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
free(cmd_info, M_CTLFE);
ctl_free_io(new_io);
- free(new_ccb, M_CTLFE);
+ xpt_free_ccb(new_ccb);
break;
}
}
@@ -555,15 +554,14 @@
union ccb *new_ccb;
union ctl_io *new_io;
- new_ccb = (union ccb *)malloc(sizeof(*new_ccb), M_CTLFE,
- M_ZERO|M_NOWAIT);
+ new_ccb = xpt_alloc_ccb_nowait();
if (new_ccb == NULL) {
status = CAM_RESRC_UNAVAIL;
break;
}
new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref);
if (new_io == NULL) {
- free(new_ccb, M_CTLFE);
+ xpt_free_ccb(new_ccb);
status = CAM_RESRC_UNAVAIL;
break;
}
@@ -952,7 +950,7 @@
}
ctl_free_io(io);
- free(ccb, M_CTLFE);
+ xpt_free_ccb(ccb);
KASSERT(softc->atios_alloced >= 0, ("%s: atios_alloced %d < 0",
__func__, softc->atios_alloced));
Index: sys/cam/scsi/scsi_targ_bh.c
===================================================================
--- sys/cam/scsi/scsi_targ_bh.c
+++ sys/cam/scsi/scsi_targ_bh.c
@@ -266,8 +266,7 @@
for (i = 0; i < MAX_ACCEPT; i++) {
struct ccb_accept_tio *atio;
- atio = (struct ccb_accept_tio*)malloc(sizeof(*atio), M_SCSIBH,
- M_NOWAIT);
+ atio = (struct ccb_accept_tio*)xpt_alloc_ccb_nowait();
if (atio == NULL) {
status = CAM_RESRC_UNAVAIL;
break;
@@ -276,7 +275,7 @@
atio->ccb_h.ccb_descr = targbhallocdescr();
if (atio->ccb_h.ccb_descr == NULL) {
- free(atio, M_SCSIBH);
+ xpt_free_ccb((union ccb *)atio);
status = CAM_RESRC_UNAVAIL;
break;
}
@@ -308,8 +307,7 @@
for (i = 0; i < MAX_ACCEPT; i++) {
struct ccb_immediate_notify *inot;
- inot = (struct ccb_immediate_notify*)malloc(sizeof(*inot),
- M_SCSIBH, M_NOWAIT);
+ inot = (struct ccb_immediate_notify*)xpt_alloc_ccb_nowait();
if (inot == NULL) {
status = CAM_RESRC_UNAVAIL;
@@ -695,7 +693,7 @@
break;
} else {
targbhfreedescr(desc);
- free(atio, M_SCSIBH);
+ xpt_free_ccb((union ccb *)atio);
}
break;
}
Index: sys/cam/scsi/scsi_target.c
===================================================================
--- sys/cam/scsi/scsi_target.c
+++ sys/cam/scsi/scsi_target.c
@@ -936,7 +936,7 @@
int ccb_len;
ccb_len = targccblen(type);
- ccb = malloc(ccb_len, M_TARG, M_NOWAIT);
+ ccb = xpt_alloc_ccb_nowait();
CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("getccb %p\n", ccb));
if (ccb == NULL) {
return (ccb);
@@ -964,7 +964,7 @@
case XPT_IMMED_NOTIFY:
case XPT_IMMEDIATE_NOTIFY:
CAM_DEBUG_PRINT(CAM_DEBUG_PERIPH, ("freeing ccb %p\n", ccb));
- free(ccb, M_TARG);
+ xpt_free_ccb(ccb);
break;
default:
/* Send back CCB if we got it from the periph */
@@ -975,7 +975,7 @@
} else {
CAM_DEBUG_PRINT(CAM_DEBUG_PERIPH,
("freeing ccb %p\n", ccb));
- free(ccb, M_TARG);
+ xpt_free_ccb(ccb);
}
break;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jun 16, 2:44 PM (7 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33990155
Default Alt Text
D26844.diff (5 KB)
Attached To
Mode
D26844: Use UMA for CCBs.
Attached
Detach File
Event Timeline
Log In to Comment