From owner-svn-src-stable-11@freebsd.org Fri Mar 24 07:01:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF371D1BA14; Fri, 24 Mar 2017 07:01:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A450D1CDC; Fri, 24 Mar 2017 07:01:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O71Vmk054232; Fri, 24 Mar 2017 07:01:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O71Vgl054231; Fri, 24 Mar 2017 07:01:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240701.v2O71Vgl054231@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:01:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315888 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 07:01:33 -0000 Author: mav Date: Fri Mar 24 07:01:31 2017 New Revision: 315888 URL: https://svnweb.freebsd.org/changeset/base/315888 Log: 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. Modified: stable/11/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:00:16 2017 (r315887) +++ stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:01:31 2017 (r315888) @@ -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, { 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, 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, 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, } 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, 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; - - softc = (struct ctlfe_lun_softc *)periph->softc; + union ccb ccb; + struct ccb_hdr *hdr; + cam_status status; - 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); + /* 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); + } + + /* 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 *per 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 *per * 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, uni 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, uni 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);