summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom.h
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2012-07-29 11:51:48 +0000
committermav <mav@FreeBSD.org>2012-07-29 11:51:48 +0000
commit24017b5387054ebed0abcea2a144f0db7f108d51 (patch)
tree07c23269365b3097a0872aa1a4fe569caf1995e1 /sys/geom/geom.h
parent6009a2eb434a1c413557b4d2bc90c32da1b6e1d4 (diff)
downloadFreeBSD-src-24017b5387054ebed0abcea2a144f0db7f108d51.zip
FreeBSD-src-24017b5387054ebed0abcea2a144f0db7f108d51.tar.gz
Implement media change notification for DA and CD removable media devices.
It includes three parts: 1) Modifications to CAM to detect media media changes and report them to disk(9) layer. For modern SATA (and potentially UAS) devices it utilizes Asynchronous Notification mechanism to receive events from hardware. Active polling with TEST UNIT READY commands with 3 seconds period is used for incapable hardware. After that both CD and DA drivers work the same way, detecting two conditions: "NOT READY: Medium not present" after medium was detected previously, and "UNIT ATTENTION: Not ready to ready change, medium may have changed". First one reported to disk(9) as media removal, second as media insert/change. To reliably receive second event new AC_UNIT_ATTENTION async added to make UAs broadcasted to all periphs by generic error handling code in cam_periph_error(). 2) Modifications to GEOM core to handle media remove and change events. Media removal handled by spoiling all consumers attached to the provider. Media change event also schedules provider retaste after spoiling to probe new media. New flag G_CF_ORPHAN was added to consumers to reflect that consumer is in process of destruction. It allows retaste to create new geom instance of the same class, while previous one is still dying. 3) Modifications to some GEOM classes: DEV -- to report media change events to devd; VFS -- to handle spoiling same as orphan to prevent accessing replaced media. PART class already handles spoiling alike to orphan. Reviewed by: silence on geom@ and scsi@ Tested by: avg Sponsored by: iXsystems, Inc. / PC-BSD MFC after: 2 months
Diffstat (limited to 'sys/geom/geom.h')
-rw-r--r--sys/geom/geom.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index 526fbdb..6a447ae 100644
--- a/sys/geom/geom.h
+++ b/sys/geom/geom.h
@@ -174,7 +174,9 @@ struct g_consumer {
struct g_provider *provider;
LIST_ENTRY(g_consumer) consumers; /* XXX: better name */
int acr, acw, ace;
- int spoiled;
+ int flags;
+#define G_CF_SPOILED 0x1
+#define G_CF_ORPHAN 0x4
struct devstat *stat;
u_int nstart, nend;
@@ -247,6 +249,8 @@ int g_post_event(g_event_t *func, void *arg, int flag, ...);
int g_waitfor_event(g_event_t *func, void *arg, int flag, ...);
void g_cancel_event(void *ref);
int g_attr_changed(struct g_provider *pp, const char *attr, int flag);
+int g_media_changed(struct g_provider *pp, int flag);
+int g_media_gone(struct g_provider *pp, int flag);
void g_orphan_provider(struct g_provider *pp, int error);
void g_waitidlelock(void);
OpenPOWER on IntegriCloud