Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Feb 2020 00:13:24 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357897 - head/sys/cam
Message-ID:  <202002140013.01E0DOnw032723@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Fri Feb 14 00:13:23 2020
New Revision: 357897
URL: https://svnweb.freebsd.org/changeset/base/357897

Log:
  Add a KASSERT that there's no outstanding CCBs when we call camperiphfree. We
  know that if there are any outstanding CCBs, then when they dereference the path
  that's freed at the bottom of camperiphfree there will be some flavor of
  panic. This moves that eventual panic to a traceback of when we free the last
  reference on the device, which is earlier but may not be early enough.

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==============================================================================
--- head/sys/cam/cam_periph.c	Fri Feb 14 00:12:59 2020	(r357896)
+++ head/sys/cam/cam_periph.c	Fri Feb 14 00:13:23 2020	(r357897)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_periph.h>
 #include <cam/cam_debug.h>
 #include <cam/cam_sim.h>
+#include <cam/cam_xpt_internal.h>	/* For KASSERTs only */
 
 #include <cam/scsi/scsi_all.h>
 #include <cam/scsi/scsi_message.h>
@@ -681,6 +682,10 @@ camperiphfree(struct cam_periph *periph)
 	cam_periph_assert(periph, MA_OWNED);
 	KASSERT(periph->periph_allocating == 0, ("%s%d: freed while allocating",
 	    periph->periph_name, periph->unit_number));
+	KASSERT(periph->path->device->ccbq.dev_active == 0,
+	    ("%s%d: freed with %d active CCBs\n",
+		periph->periph_name, periph->unit_number,
+		periph->path->device->ccbq.dev_active));
 	for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
 		if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002140013.01E0DOnw032723>