summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-11-28 08:53:44 +0000
committermav <mav@FreeBSD.org>2014-11-28 08:53:44 +0000
commit6625927f313c498a0365eb84260b48349e8eaaf7 (patch)
treed040fccd65e31a8a8ded75008059496b9706aa03 /sys/cam
parent6f5634bed9883003fa2bf50b5ec5282a7c1abc80 (diff)
downloadFreeBSD-src-6625927f313c498a0365eb84260b48349e8eaaf7.zip
FreeBSD-src-6625927f313c498a0365eb84260b48349e8eaaf7.tar.gz
MFC r274789: Reduce race between LUN destruction and request arrival.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 095d4eb..a219e81 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -11717,15 +11717,18 @@ ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio)
targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun;
if ((targ_lun < CTL_MAX_LUNS)
- && (ctl_softc->ctl_luns[targ_lun] != NULL)) {
- lun = ctl_softc->ctl_luns[targ_lun];
+ && ((lun = ctl_softc->ctl_luns[targ_lun]) != NULL)) {
/*
* If the LUN is invalid, pretend that it doesn't exist.
* It will go away as soon as all pending I/O has been
* completed.
*/
+ mtx_lock(&lun->lun_lock);
if (lun->flags & CTL_LUN_DISABLED) {
+ mtx_unlock(&lun->lun_lock);
lun = NULL;
+ ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr = NULL;
+ ctsio->io_hdr.ctl_private[CTL_PRIV_BACKEND_LUN].ptr = NULL;
} else {
ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr = lun;
ctsio->io_hdr.ctl_private[CTL_PRIV_BACKEND_LUN].ptr =
@@ -11738,7 +11741,6 @@ ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio)
* Every I/O goes into the OOA queue for a
* particular LUN, and stays there until completion.
*/
- mtx_lock(&lun->lun_lock);
TAILQ_INSERT_TAIL(&lun->ooa_queue, &ctsio->io_hdr,
ooa_links);
}
OpenPOWER on IntegriCloud