svn commit: r188503 - head/sys/cam/scsi

John Baldwin jhb at FreeBSD.org
Wed Feb 11 14:29:10 PST 2009


Author: jhb
Date: Wed Feb 11 22:29:09 2009
New Revision: 188503
URL: http://svn.freebsd.org/changeset/base/188503

Log:
  Reorder dacleanup() and cdcleanup() slightly so that the sysctl context is
  freed while the periph lock is not held.  While here, wait until after
  freeing the softc before reacquiring the periph lock.
  
  Tested by:	sbruno

Modified:
  head/sys/cam/scsi/scsi_cd.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_cd.c
==============================================================================
--- head/sys/cam/scsi/scsi_cd.c	Wed Feb 11 22:22:26 2009	(r188502)
+++ head/sys/cam/scsi/scsi_cd.c	Wed Feb 11 22:29:09 2009	(r188503)
@@ -401,11 +401,6 @@ cdcleanup(struct cam_periph *periph)
 
 	xpt_print(periph->path, "removing device entry\n");
 
-	if ((softc->flags & CD_FLAG_SCTX_INIT) != 0
-	    && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
-		xpt_print(periph->path, "can't remove sysctl context\n");
-	}
-
 	/*
 	 * In the queued, non-active case, the device in question
 	 * has already been removed from the changer run queue.  Since this
@@ -474,9 +469,14 @@ cdcleanup(struct cam_periph *periph)
 		free(softc->changer, M_DEVBUF);
 	}
 	cam_periph_unlock(periph);
+	if ((softc->flags & CD_FLAG_SCTX_INIT) != 0
+	    && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
+		xpt_print(periph->path, "can't remove sysctl context\n");
+	}
+
 	disk_destroy(softc->disk);
-	cam_periph_lock(periph);
 	free(softc, M_DEVBUF);
+	cam_periph_lock(periph);
 }
 
 static void

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c	Wed Feb 11 22:22:26 2009	(r188502)
+++ head/sys/cam/scsi/scsi_da.c	Wed Feb 11 22:29:09 2009	(r188503)
@@ -995,6 +995,8 @@ dacleanup(struct cam_periph *periph)
 	softc = (struct da_softc *)periph->softc;
 
 	xpt_print(periph->path, "removing device entry\n");
+	cam_periph_unlock(periph);
+
 	/*
 	 * If we can't free the sysctl tree, oh well...
 	 */
@@ -1003,11 +1005,10 @@ dacleanup(struct cam_periph *periph)
 		xpt_print(periph->path, "can't remove sysctl context\n");
 	}
 
-	cam_periph_unlock(periph);
 	disk_destroy(softc->disk);
 	callout_drain(&softc->sendordered_c);
-	cam_periph_lock(periph);
 	free(softc, M_DEVBUF);
+	cam_periph_lock(periph);
 }
 
 static void


More information about the svn-src-head mailing list