aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/nvme/nvme_da.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-05-15 22:22:10 +0000
committerWarner Losh <imp@FreeBSD.org>2018-05-15 22:22:10 +0000
commitd9a7a61b2bdde172bc1db1e3c0b12f27aa8b466e (patch)
tree854593f246b5027d52b61e515bd4e8b8dfcf208f /sys/cam/nvme/nvme_da.c
parent40f242e4400ed9b62ab2c107bc85d11089fee426 (diff)
downloadsrc-d9a7a61b2bdde172bc1db1e3c0b12f27aa8b466e.tar.gz
src-d9a7a61b2bdde172bc1db1e3c0b12f27aa8b466e.zip
Hold the reference count until the CCB is released
When a disk disappears and the periph is invalidated, any I/Os that are pending with the controller can cause a crash when they complete. Move to holding the softc reference count taken in dastart() until the I/O is complete rather than only until xpt_action() returns. (This approach was suggested by Ken Merry.) This extends the method used in da to ada, nda, and mda. Sponsored by: Netflix Submitted by: Chuck Silvers
Notes
Notes: svn path=/head/; revision=333651
Diffstat (limited to 'sys/cam/nvme/nvme_da.c')
-rw-r--r--sys/cam/nvme/nvme_da.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 65155386f68a..76e60be3ed93 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -990,7 +990,6 @@ out:
cam_periph_unlock(periph);
xpt_action(start_ccb);
cam_periph_lock(periph);
- softc->refcount--;
/* May have more work to do, so ensure we stay scheduled */
ndaschedule(periph);
@@ -1101,6 +1100,11 @@ ndadone(struct cam_periph *periph, union ccb *done_ccb)
biodone(bp2);
}
}
+ /*
+ * Release the periph refcount taken in mdastart() for each CCB.
+ */
+ KASSERT(softc->refcount >= 1, ("ndadone softc %p refcount %d", softc, softc->refcount));
+ softc->refcount--;
return;
}
case NDA_CCB_DUMP: