[Midnightbsd-cvs] src [9281] trunk/sys/cam/ata/ata_da.c: add a callback to the ada(4) driver so that it knows when GEOM has released references to it.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Mar 2 17:57:14 EST 2017
Revision: 9281
http://svnweb.midnightbsd.org/src/?rev=9281
Author: laffer1
Date: 2017-03-02 17:57:14 -0500 (Thu, 02 Mar 2017)
Log Message:
-----------
add a callback to the ada(4) driver so that it knows when GEOM has released references to it. (freebsd svn 249661)
Modified Paths:
--------------
trunk/sys/cam/ata/ata_da.c
Modified: trunk/sys/cam/ata/ata_da.c
===================================================================
--- trunk/sys/cam/ata/ata_da.c 2017-02-20 03:23:36 UTC (rev 9280)
+++ trunk/sys/cam/ata/ata_da.c 2017-03-02 22:57:14 UTC (rev 9281)
@@ -938,7 +938,21 @@
}
}
+/*
+ * Callback from GEOM, called when it has finished cleaning up its
+ * resources.
+ */
static void
+adadiskgonecb(struct disk *dp)
+{
+ struct cam_periph *periph;
+
+ periph = (struct cam_periph *)dp->d_drv1;
+
+ cam_periph_release(periph);
+}
+
+static void
adaoninvalidate(struct cam_periph *periph)
{
struct ada_softc *softc;
@@ -1277,6 +1291,7 @@
softc->disk->d_strategy = adastrategy;
softc->disk->d_getattr = adagetattr;
softc->disk->d_dump = adadump;
+ softc->disk->d_gone = adadiskgonecb;
softc->disk->d_name = "ada";
softc->disk->d_drv1 = periph;
maxio = cpi.maxio; /* Honor max I/O size of SIM */
@@ -1340,6 +1355,17 @@
}
} else
legacy_id = -1;
+ /*
+ * Acquire a reference to the periph before we register with GEOM.
+ * We'll release this reference once GEOM calls us back (via
+ * adadiskgonecb()) telling us that our provider has been freed.
+ */
+ if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
+ xpt_print(periph->path, "%s: lost periph during "
+ "registration!\n", __func__);
+ cam_periph_lock(periph);
+ return (CAM_REQ_CMP_ERR);
+ }
disk_create(softc->disk, DISK_VERSION);
cam_periph_lock(periph);
cam_periph_unhold(periph);
More information about the Midnightbsd-cvs
mailing list