Date: Sun, 24 May 2009 18:43:07 GMT From: Alexander Motin <mav@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 162663 for review Message-ID: <200905241843.n4OIh7U0084773@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=162663 Change 162663 by mav@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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905241843.n4OIh7U0084773>