aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/cam_periph.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2012-07-29 11:51:48 +0000
committerAlexander Motin <mav@FreeBSD.org>2012-07-29 11:51:48 +0000
commit3631c6382fa261edc7d8c7769e72f2ff7201468c (patch)
tree07c23269365b3097a0872aa1a4fe569caf1995e1 /sys/cam/cam_periph.c
parent0f4a46b376b627416bb39a3d2952b94b0209e5fb (diff)
downloadsrc-3631c6382fa261edc7d8c7769e72f2ff7201468c.tar.gz
src-3631c6382fa261edc7d8c7769e72f2ff7201468c.zip
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
Notes
Notes: svn path=/head/; revision=238886
Diffstat (limited to 'sys/cam/cam_periph.c')
-rw-r--r--sys/cam/cam_periph.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index d947732c30f2..4ebf84c5d986 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -1593,6 +1593,7 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
const char *action_string;
cam_status status;
int frozen, error, openings, print, lost_device;
+ int error_code, sense_key, asc, ascq;
u_int32_t relsim_flags, timeout;
print = 1;
@@ -1759,6 +1760,12 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
xpt_async(AC_LOST_DEVICE, newpath, NULL);
xpt_free_path(newpath);
}
+
+ /* Broadcast UNIT ATTENTIONs to all periphs. */
+ } else if (scsi_extract_sense_ccb(ccb,
+ &error_code, &sense_key, &asc, &ascq) &&
+ sense_key == SSD_KEY_UNIT_ATTENTION) {
+ xpt_async(AC_UNIT_ATTENTION, orig_ccb->ccb_h.path, orig_ccb);
}
/* Attempt a retry */