summaryrefslogtreecommitdiffstats
path: root/sys/cam/cam_periph.c
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>1998-10-22 22:16:56 +0000
committerken <ken@FreeBSD.org>1998-10-22 22:16:56 +0000
commit123c4e574210364558b003c3b4308600a6cbdf16 (patch)
tree37676d718bb5ecd358f7101d2d5f0f9d60810f82 /sys/cam/cam_periph.c
parentc4aa0cf6f77d3320883b9363e359ae996632fb1a (diff)
downloadFreeBSD-src-123c4e574210364558b003c3b4308600a6cbdf16.zip
FreeBSD-src-123c4e574210364558b003c3b4308600a6cbdf16.tar.gz
Fix a problem with the way we handled device invalidation when attaching
to a device failed. In theory, the same steps that happen when we get an AC_LOST_DEVICE async notification should have been taken when a driver fails to attach. In practice, that wasn't the case. This only affected the da, cd and ch drivers, but the fix affects all peripheral drivers. There were several possible problems: - In the da driver, we didn't remove the peripheral's softc from the da driver's linked list of softcs. Once the peripheral and softc got removed, we'd get a kernel panic the next time the timeout routine called dasendorderedtag(). - In the da, cd and possibly ch drivers, we didn't remove the peripheral's devstat structure from the devstat queue. Once the peripheral and softc were removed, this could cause a panic if anyone tried to access device statistics. (one component of the linked list wouldn't exist anymore) - In the cd driver, we didn't take the peripheral off the changer run queue if it was scheduled to run. In practice, it's highly unlikely, and maybe impossible that the peripheral would have been on the changer run queue at that stage of the probe process. The fix is: - Add a new peripheral callback function (the "oninvalidate" function) that is called the first time cam_periph_invalidate() is called for a peripheral. - Create new foooninvalidate() routines for each peripheral driver. This routine is always called at splsoftcam(), and contains all the stuff that used to be in the AC_LOST_DEVICE case of the async callback handler. - Move the devstat cleanup call to the destructor/cleanup routines, since some of the drivers do I/O in their close routines. - Make sure that when we're flushing the buffer queue, we traverse it at splbio(). - Add a check for the invalid flag in the pt driver's open routine. Reviewed by: gibbs
Diffstat (limited to 'sys/cam/cam_periph.c')
-rw-r--r--sys/cam/cam_periph.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index 6d6fe29..70ab1b1 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cam_periph.c,v 1.4 1998/10/13 21:41:32 ken Exp $
+ * $Id: cam_periph.c,v 1.5 1998/10/15 17:46:18 ken Exp $
*/
#include <sys/param.h>
@@ -62,10 +62,11 @@ static void camperiphdone(struct cam_periph *periph,
static void camperiphfree(struct cam_periph *periph);
cam_status
-cam_periph_alloc(periph_ctor_t *periph_ctor, periph_dtor_t *periph_dtor,
- periph_start_t *periph_start, char *name, cam_periph_type type,
- struct cam_path *path, ac_callback_t *ac_callback,
- ac_code code, void *arg)
+cam_periph_alloc(periph_ctor_t *periph_ctor,
+ periph_oninv_t *periph_oninvalidate,
+ periph_dtor_t *periph_dtor, periph_start_t *periph_start,
+ char *name, cam_periph_type type, struct cam_path *path,
+ ac_callback_t *ac_callback, ac_code code, void *arg)
{
struct periph_driver **p_drv;
struct cam_periph *periph;
@@ -122,6 +123,7 @@ cam_periph_alloc(periph_ctor_t *periph_ctor, periph_dtor_t *periph_dtor,
cam_init_pinfo(&periph->pinfo);
periph->periph_start = periph_start;
periph->periph_dtor = periph_dtor;
+ periph->periph_oninval = periph_oninvalidate;
periph->type = type;
periph->periph_name = name;
periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id);
@@ -372,10 +374,19 @@ cam_periph_invalidate(struct cam_periph *periph)
{
int s;
+ s = splsoftcam();
+ /*
+ * We only call this routine the first time a peripheral is
+ * invalidated. The oninvalidate() routine is always called at
+ * splsoftcam().
+ */
+ if (((periph->flags & CAM_PERIPH_INVALID) == 0)
+ && (periph->periph_oninval != NULL))
+ periph->periph_oninval(periph);
+
periph->flags |= CAM_PERIPH_INVALID;
periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
- s = splsoftcam();
if (periph->refcount == 0)
camperiphfree(periph);
else if (periph->refcount < 0)
OpenPOWER on IntegriCloud