Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107356450
D30352.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D30352.diff
View Options
Index: sys/cam/cam_ccb.h
===================================================================
--- sys/cam/cam_ccb.h
+++ sys/cam/cam_ccb.h
@@ -62,6 +62,9 @@
/* CCB memory allocation flags */
typedef enum {
CAM_CCB_FROM_UMA = 0x00000001,/* CCB from a periph UMA zone */
+ CAM_CCB_FROM_STACK = 0x00000002,/* CCB lives on the stack */
+ CAM_CCB_FROM_MALLOC = 0x00000004,/* CCB Obtained from malloc */
+ CAM_CCB_FROM_MASK = 0x00000007,/* Mask of all CCB from types */
} ccb_alloc_flags;
/* CAM CCB flags */
Index: sys/cam/cam_xpt.h
===================================================================
--- sys/cam/cam_xpt.h
+++ sys/cam/cam_xpt.h
@@ -85,6 +85,10 @@
void xpt_setup_ccb(struct ccb_hdr *ccb_h,
struct cam_path *path,
u_int32_t priority);
+void xpt_setup_stack_ccb(struct ccb_hdr *ccb_h,
+ size_t len,
+ struct cam_path *path,
+ u_int32_t priority);
void xpt_merge_ccb(union ccb *dst_ccb,
union ccb *src_ccb);
cam_status xpt_create_path(struct cam_path **new_path_ptr,
Index: sys/cam/cam_xpt.c
===================================================================
--- sys/cam/cam_xpt.c
+++ sys/cam/cam_xpt.c
@@ -3556,6 +3556,8 @@
{
CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_setup_ccb\n"));
+ KASSERT((ccb_h->alloc_flags & CAM_CCB_FROM_MASK) != 0,
+ ("CCB alloc mask not set."));
ccb_h->pinfo.priority = priority;
ccb_h->path = path;
ccb_h->path_id = path->bus->path_id;
@@ -3580,6 +3582,15 @@
xpt_setup_ccb_flags(ccb_h, path, priority, /*flags*/ 0);
}
+void
+xpt_setup_stack_ccb(struct ccb_hdr *ccb_h, size_t len, struct cam_path *path,
+ u_int32_t priority)
+{
+ memset(ccb_h, 0, len);
+ ccb_h->alloc_flags |= CAM_CCB_FROM_STACK;
+ xpt_setup_ccb_flags(ccb_h, path, priority, 0);
+}
+
/* Path manipulation functions */
cam_status
xpt_create_path(struct cam_path **new_path_ptr, struct cam_periph *perph,
@@ -4678,6 +4689,7 @@
union ccb *new_ccb;
new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK);
+ new_ccb->ccb_h.alloc_flags |= CAM_CCB_FROM_MALLOC;
return (new_ccb);
}
@@ -4687,6 +4699,8 @@
union ccb *new_ccb;
new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT);
+ if (new_ccb != NULL)
+ new_ccb->ccb_h.alloc_flags |= CAM_CCB_FROM_MALLOC;
return (new_ccb);
}
@@ -4695,6 +4709,11 @@
{
struct cam_periph *periph;
+ KASSERT((free_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_MASK) !=
+ CAM_CCB_FROM_STACK,
+ ("CCB allocated from stack can't be freed"));
+
+
if (free_ccb->ccb_h.alloc_flags & CAM_CCB_FROM_UMA) {
/*
* Looks like a CCB allocated from a periph UMA zone.
Index: sys/cam/scsi/scsi_da.c
===================================================================
--- sys/cam/scsi/scsi_da.c
+++ sys/cam/scsi/scsi_da.c
@@ -1931,9 +1931,9 @@
if ((softc->flags & DA_FLAG_PACK_INVALID) != 0)
return (ENXIO);
- memset(&csio, 0, sizeof(csio));
if (length > 0) {
- xpt_setup_ccb(&csio.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_stack_ccb(&csio.ccb_h, sizeof(csio), periph->path,
+ CAM_PRIORITY_NORMAL);
csio.ccb_h.ccb_state = DA_CCB_DUMP;
scsi_read_write(&csio,
/*retries*/0,
@@ -1959,7 +1959,8 @@
* Sync the disk cache contents to the physical media.
*/
if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) {
- xpt_setup_ccb(&csio.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_stack_ccb(&csio.ccb_h, sizeof(csio), periph->path,
+ CAM_PRIORITY_NORMAL);
csio.ccb_h.ccb_state = DA_CCB_DUMP;
scsi_synchronize_cache(&csio,
/*retries*/0,
@@ -2373,8 +2374,8 @@
/*
* Add some addressing info.
*/
- memset(&cts, 0, sizeof (cts));
- xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NONE);
+ xpt_setup_stack_ccb(&cts.ccb_h, sizeof(cts), periph->path,
+ CAM_PRIORITY_NONE);
cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
cts.type = CTS_TYPE_CURRENT_SETTINGS;
cam_periph_lock(periph);
@@ -4897,9 +4898,8 @@
/*timeout*/0,
/*getcount_only*/0);
- memset(&cgd, 0, sizeof(cgd));
- xpt_setup_ccb(&cgd.ccb_h, done_ccb->ccb_h.path,
- CAM_PRIORITY_NORMAL);
+ xpt_setup_stack_ccb(&cgd.ccb_h, sizeof(cgd),
+ done_ccb->ccb_h.path, CAM_PRIORITY_NORMAL);
cgd.ccb_h.func_code = XPT_GDEV_TYPE;
xpt_action((union ccb *)&cgd);
@@ -6144,8 +6144,8 @@
* up with something that will make this a bootable
* device.
*/
- memset(&ccg, 0, sizeof(ccg));
- xpt_setup_ccb(&ccg.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_stack_ccb(&ccg.ccb_h, sizeof(ccg), periph->path,
+ CAM_PRIORITY_NORMAL);
ccg.ccb_h.func_code = XPT_CALC_GEOMETRY;
ccg.block_size = dp->secsize;
ccg.volume_size = dp->sectors;
@@ -6182,8 +6182,8 @@
min(sizeof(softc->rcaplong), rcap_len)) != 0)) {
struct ccb_dev_advinfo cdai;
- memset(&cdai, 0, sizeof(cdai));
- xpt_setup_ccb(&cdai.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ xpt_setup_stack_ccb(&cdai.ccb_h, sizeof(cdai), periph->path,
+ CAM_PRIORITY_NORMAL);
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
cdai.buftype = CDAI_TYPE_RCAPLONG;
cdai.flags = CDAI_FLAG_STORE;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 13, 11:44 PM (20 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15788795
Default Alt Text
D30352.diff (4 KB)
Attached To
Mode
D30352: cam: introduce xpt_setup_stack_ccb
Attached
Detach File
Event Timeline
Log In to Comment