summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-03-24 07:01:31 +0000
committermav <mav@FreeBSD.org>2017-03-24 07:01:31 +0000
commit3e15ed3c85c730f279490aaec6d2c81953e9fece (patch)
tree9154fc69e725c5e1d063a58dbe72617f40687091 /sys/cam
parent0d9d883e15e2055be3a26d1ec02ee71a85048117 (diff)
downloadFreeBSD-src-3e15ed3c85c730f279490aaec6d2c81953e9fece.zip
FreeBSD-src-3e15ed3c85c730f279490aaec6d2c81953e9fece.tar.gz
MFC r315030: Abort all ATIOs and INOTs queued to SIM on LUN disable.
Some SIMs may not abort them implicitly, that either fail the LUN disable request or just make us wait for those CCBs forever. With this change I can successfully disable LUNs on mpt(4). For isp(4), which aborts them implicitly, this change should be irrelevant.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/scsi_ctl.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c
index e0b1482..1d3eb4a 100644
--- a/sys/cam/ctl/scsi_ctl.c
+++ b/sys/cam/ctl/scsi_ctl.c
@@ -106,6 +106,8 @@ struct ctlfe_lun_softc {
int inots_alloced; /* Number of INOTs not freed */
struct task refdrain_task;
STAILQ_HEAD(, ccb_hdr) work_queue;
+ LIST_HEAD(, ccb_hdr) atio_list; /* List of ATIOs queued to SIM. */
+ LIST_HEAD(, ccb_hdr) inot_list; /* List of INOTs queued to SIM. */
STAILQ_ENTRY(ctlfe_lun_softc) links;
};
@@ -442,7 +444,7 @@ ctlferegister(struct cam_periph *periph, void *arg)
{
struct ctlfe_softc *bus_softc;
struct ctlfe_lun_softc *softc;
- union ccb en_lun_ccb;
+ union ccb ccb;
cam_status status;
int i;
@@ -450,19 +452,21 @@ ctlferegister(struct cam_periph *periph, void *arg)
bus_softc = softc->parent_softc;
STAILQ_INIT(&softc->work_queue);
+ LIST_INIT(&softc->atio_list);
+ LIST_INIT(&softc->inot_list);
softc->periph = periph;
periph->softc = softc;
- xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE);
- en_lun_ccb.ccb_h.func_code = XPT_EN_LUN;
- en_lun_ccb.cel.grp6_len = 0;
- en_lun_ccb.cel.grp7_len = 0;
- en_lun_ccb.cel.enable = 1;
- xpt_action(&en_lun_ccb);
- status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK);
+ xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE);
+ ccb.ccb_h.func_code = XPT_EN_LUN;
+ ccb.cel.grp6_len = 0;
+ ccb.cel.grp7_len = 0;
+ ccb.cel.enable = 1;
+ xpt_action(&ccb);
+ status = (ccb.ccb_h.status & CAM_STATUS_MASK);
if (status != CAM_REQ_CMP) {
xpt_print(periph->path, "%s: Enable LUN failed, status 0x%x\n",
- __func__, en_lun_ccb.ccb_h.status);
+ __func__, ccb.ccb_h.status);
return (status);
}
@@ -496,6 +500,7 @@ ctlferegister(struct cam_periph *periph, void *arg)
PRIV_INFO(new_io) = cmd_info;
softc->atios_alloced++;
new_ccb->ccb_h.io_ptr = new_io;
+ LIST_INSERT_HEAD(&softc->atio_list, &new_ccb->ccb_h, periph_links.le);
xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1);
new_ccb->ccb_h.func_code = XPT_ACCEPT_TARGET_IO;
@@ -542,6 +547,7 @@ ctlferegister(struct cam_periph *periph, void *arg)
}
softc->inots_alloced++;
new_ccb->ccb_h.io_ptr = new_io;
+ LIST_INSERT_HEAD(&softc->inot_list, &new_ccb->ccb_h, periph_links.le);
xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1);
new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY;
@@ -578,23 +584,34 @@ ctlferegister(struct cam_periph *periph, void *arg)
static void
ctlfeoninvalidate(struct cam_periph *periph)
{
- union ccb en_lun_ccb;
- cam_status status;
+ struct ctlfe_lun_softc *softc = (struct ctlfe_lun_softc *)periph->softc;
struct ctlfe_softc *bus_softc;
- struct ctlfe_lun_softc *softc;
+ union ccb ccb;
+ struct ccb_hdr *hdr;
+ cam_status status;
- softc = (struct ctlfe_lun_softc *)periph->softc;
+ /* Abort all ATIOs and INOTs queued to SIM. */
+ xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE);
+ ccb.ccb_h.func_code = XPT_ABORT;
+ LIST_FOREACH(hdr, &softc->atio_list, periph_links.le) {
+ ccb.cab.abort_ccb = (union ccb *)hdr;
+ xpt_action(&ccb);
+ }
+ LIST_FOREACH(hdr, &softc->inot_list, periph_links.le) {
+ ccb.cab.abort_ccb = (union ccb *)hdr;
+ xpt_action(&ccb);
+ }
- xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE);
- en_lun_ccb.ccb_h.func_code = XPT_EN_LUN;
- en_lun_ccb.cel.grp6_len = 0;
- en_lun_ccb.cel.grp7_len = 0;
- en_lun_ccb.cel.enable = 0;
- xpt_action(&en_lun_ccb);
- status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK);
+ /* Disable the LUN in SIM. */
+ ccb.ccb_h.func_code = XPT_EN_LUN;
+ ccb.cel.grp6_len = 0;
+ ccb.cel.grp7_len = 0;
+ ccb.cel.enable = 0;
+ xpt_action(&ccb);
+ status = (ccb.ccb_h.status & CAM_STATUS_MASK);
if (status != CAM_REQ_CMP) {
xpt_print(periph->path, "%s: Disable LUN failed, status 0x%x\n",
- __func__, en_lun_ccb.ccb_h.status);
+ __func__, ccb.ccb_h.status);
/*
* XXX KDM what do we do now?
*/
@@ -952,6 +969,11 @@ ctlfe_requeue_ccb(struct cam_periph *periph, union ccb *ccb, int unlock)
mtx_unlock(mtx);
return;
}
+ softc = (struct ctlfe_lun_softc *)periph->softc;
+ if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO)
+ LIST_INSERT_HEAD(&softc->atio_list, &ccb->ccb_h, periph_links.le);
+ else
+ LIST_INSERT_HEAD(&softc->inot_list, &ccb->ccb_h, periph_links.le);
if (unlock)
cam_periph_unlock(periph);
@@ -960,7 +982,6 @@ ctlfe_requeue_ccb(struct cam_periph *periph, union ccb *ccb, int unlock)
* target/lun. Reset the target and LUN fields back to the wildcard
* values before we send them back down to the SIM.
*/
- softc = (struct ctlfe_lun_softc *)periph->softc;
if (softc->flags & CTLFE_LUN_WILDCARD) {
ccb->ccb_h.target_id = CAM_TARGET_WILDCARD;
ccb->ccb_h.target_lun = CAM_LUN_WILDCARD;
@@ -1075,6 +1096,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
switch (done_ccb->ccb_h.func_code) {
case XPT_ACCEPT_TARGET_IO: {
+ LIST_REMOVE(&done_ccb->ccb_h, periph_links.le);
atio = &done_ccb->atio;
status = atio->ccb_h.status & CAM_STATUS_MASK;
if (status != CAM_CDB_RECVD) {
@@ -1364,6 +1386,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
struct ccb_immediate_notify *inot;
int send_ctl_io;
+ LIST_REMOVE(&done_ccb->ccb_h, periph_links.le);
inot = &done_ccb->cin1;
io = done_ccb->ccb_h.io_ptr;
ctl_zero_io(io);
OpenPOWER on IntegriCloud