Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/scsi/scsi_target.c
Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | targioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) | ||||
{ | { | ||||
struct ccb_debug cdbg; | struct ccb_debug cdbg; | ||||
/* If no periph available, disallow debugging changes */ | /* If no periph available, disallow debugging changes */ | ||||
if ((softc->state & TARG_STATE_LUN_ENABLED) == 0) { | if ((softc->state & TARG_STATE_LUN_ENABLED) == 0) { | ||||
status = CAM_DEV_NOT_THERE; | status = CAM_DEV_NOT_THERE; | ||||
break; | break; | ||||
} | } | ||||
bzero(&cdbg, sizeof cdbg); | xpt_setup_stack_ccb(&cdbg.ccb_h, sizeof(cdbg), softc->path, | ||||
imp: also an ordering bug | |||||
CAM_PRIORITY_NORMAL); | |||||
if (*((int *)addr) != 0) | if (*((int *)addr) != 0) | ||||
cdbg.flags = CAM_DEBUG_PERIPH; | cdbg.flags = CAM_DEBUG_PERIPH; | ||||
else | else | ||||
cdbg.flags = CAM_DEBUG_NONE; | cdbg.flags = CAM_DEBUG_NONE; | ||||
xpt_setup_ccb(&cdbg.ccb_h, softc->path, CAM_PRIORITY_NORMAL); | |||||
cdbg.ccb_h.func_code = XPT_DEBUG; | cdbg.ccb_h.func_code = XPT_DEBUG; | ||||
cdbg.ccb_h.cbfcnp = targdone; | cdbg.ccb_h.cbfcnp = targdone; | ||||
xpt_action((union ccb *)&cdbg); | xpt_action((union ccb *)&cdbg); | ||||
status = cdbg.ccb_h.status & CAM_STATUS_MASK; | status = cdbg.ccb_h.status & CAM_STATUS_MASK; | ||||
break; | break; | ||||
} | } | ||||
default: | default: | ||||
status = CAM_PROVIDE_FAIL; | status = CAM_PROVIDE_FAIL; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
/* Send the HBA the enable/disable message */ | /* Send the HBA the enable/disable message */ | ||||
static cam_status | static cam_status | ||||
targendislun(struct cam_path *path, int enable, int grp6_len, int grp7_len) | targendislun(struct cam_path *path, int enable, int grp6_len, int grp7_len) | ||||
{ | { | ||||
struct ccb_en_lun en_ccb; | struct ccb_en_lun en_ccb; | ||||
cam_status status; | cam_status status; | ||||
/* Tell the lun to begin answering selects */ | /* Tell the lun to begin answering selects */ | ||||
xpt_setup_ccb(&en_ccb.ccb_h, path, CAM_PRIORITY_NORMAL); | xpt_setup_stack_ccb( | ||||
&en_ccb.ccb_h, sizeof(en_ccb), path, CAM_PRIORITY_NORMAL); | |||||
en_ccb.ccb_h.func_code = XPT_EN_LUN; | en_ccb.ccb_h.func_code = XPT_EN_LUN; | ||||
/* Don't need support for any vendor specific commands */ | /* Don't need support for any vendor specific commands */ | ||||
en_ccb.grp6_len = grp6_len; | en_ccb.grp6_len = grp6_len; | ||||
en_ccb.grp7_len = grp7_len; | en_ccb.grp7_len = grp7_len; | ||||
en_ccb.enable = enable ? 1 : 0; | en_ccb.enable = enable ? 1 : 0; | ||||
xpt_action((union ccb *)&en_ccb); | xpt_action((union ccb *)&en_ccb); | ||||
status = en_ccb.ccb_h.status & CAM_STATUS_MASK; | status = en_ccb.ccb_h.status & CAM_STATUS_MASK; | ||||
if (status != CAM_REQ_CMP) { | if (status != CAM_REQ_CMP) { | ||||
▲ Show 20 Lines • Show All 653 Lines • ▼ Show 20 Lines | while ((descr = TAILQ_FIRST(&softc->work_queue)) != NULL) { | ||||
TAILQ_REMOVE(&softc->work_queue, descr, tqe); | TAILQ_REMOVE(&softc->work_queue, descr, tqe); | ||||
TAILQ_INSERT_TAIL(&softc->abort_queue, descr, tqe); | TAILQ_INSERT_TAIL(&softc->abort_queue, descr, tqe); | ||||
} | } | ||||
/* | /* | ||||
* Then abort all pending CCBs. | * Then abort all pending CCBs. | ||||
* targdone() will return the aborted CCB via user_ccb_queue | * targdone() will return the aborted CCB via user_ccb_queue | ||||
*/ | */ | ||||
xpt_setup_ccb(&cab.ccb_h, softc->path, CAM_PRIORITY_NORMAL); | xpt_setup_stack_ccb( | ||||
&cab.ccb_h, sizeof(cab), softc->path, CAM_PRIORITY_NORMAL); | |||||
cab.ccb_h.func_code = XPT_ABORT; | cab.ccb_h.func_code = XPT_ABORT; | ||||
cab.ccb_h.status = CAM_REQ_CMP_ERR; | cab.ccb_h.status = CAM_REQ_CMP_ERR; | ||||
TAILQ_FOREACH(ccb_h, &softc->pending_ccb_queue, periph_links.tqe) { | TAILQ_FOREACH(ccb_h, &softc->pending_ccb_queue, periph_links.tqe) { | ||||
CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, | CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, | ||||
("Aborting pending CCB %p\n", ccb_h)); | ("Aborting pending CCB %p\n", ccb_h)); | ||||
cab.abort_ccb = (union ccb *)ccb_h; | cab.abort_ccb = (union ccb *)ccb_h; | ||||
xpt_action((union ccb *)&cab); | xpt_action((union ccb *)&cab); | ||||
if (cab.ccb_h.status != CAM_REQ_CMP) { | if (cab.ccb_h.status != CAM_REQ_CMP) { | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |
also an ordering bug