PERFORCE change 162663 for review

Alexander Motin mav at FreeBSD.org
Sun May 24 18:43:09 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=162663

Change 162663 by mav at mav_mavbook on 2009/05/24 18:42:33

	Implement device change tracking in ATA XPT.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#5 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#5 (text+ko) ====

@@ -111,8 +111,6 @@
 } while(0)
 
 typedef enum {
-	PROBE_INQUIRY_CKSUM	= 0x01,
-	PROBE_SERIAL_CKSUM	= 0x02,
 	PROBE_NO_ANNOUNCE	= 0x04
 } probe_flags;
 
@@ -121,7 +119,6 @@
 	probe_action	action;
 	union ccb	saved_ccb;
 	probe_flags	flags;
-	MD5_CTX		context;
 	u_int8_t	digest[16];
 	struct cam_periph *periph;
 } probe_softc;
@@ -325,6 +322,23 @@
 
 		ident_buf = &periph->path->device->ident_data;
 
+		if ((periph->path->device->flags & CAM_DEV_UNCONFIGURED) == 0) {
+			/* Prepare check that it is the same device. */
+			MD5_CTX context;
+
+			MD5Init(&context);
+			MD5Update(&context,
+			    (unsigned char *)ident_buf->model,
+			    sizeof(ident_buf->model));
+			MD5Update(&context,
+			    (unsigned char *)ident_buf->revision,
+			    sizeof(ident_buf->revision));
+			MD5Update(&context,
+			    (unsigned char *)ident_buf->serial,
+			    sizeof(ident_buf->serial));
+			MD5Final(softc->digest, &context);
+		}
+
 		ata_ident(ataio,
 			     /*retries*/4,
 			     probedone,
@@ -506,6 +520,30 @@
 			btrim(ident_buf->serial, sizeof(ident_buf->serial));
 			bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial));
 
+			if ((periph->path->device->flags & CAM_DEV_UNCONFIGURED) == 0) {
+				/* Check that it is the same device. */
+				MD5_CTX context;
+				u_int8_t digest[16];
+
+				MD5Init(&context);
+				MD5Update(&context,
+				    (unsigned char *)ident_buf->model,
+				    sizeof(ident_buf->model));
+				MD5Update(&context,
+				    (unsigned char *)ident_buf->revision,
+				    sizeof(ident_buf->revision));
+				MD5Update(&context,
+				    (unsigned char *)ident_buf->serial,
+				    sizeof(ident_buf->serial));
+				MD5Final(digest, &context);
+				if (bcmp(digest, softc->digest, sizeof(digest))) {
+					/* Device changed. */
+					xpt_async(AC_LOST_DEVICE, path, NULL);
+				}
+				xpt_release_ccb(done_ccb);
+				break;
+			}
+
 			/* Clean up from previous instance of this device */
 			if (path->device->serial_num != NULL) {
 				free(path->device->serial_num, M_CAMXPT);


More information about the p4-projects mailing list