From owner-p4-projects@FreeBSD.ORG Sun May 24 18:43:08 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 36AB11065676; Sun, 24 May 2009 18:43:08 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8EEF1065672 for ; Sun, 24 May 2009 18:43:07 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D6EC98FC15 for ; Sun, 24 May 2009 18:43:07 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4OIh7dY084775 for ; Sun, 24 May 2009 18:43:07 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4OIh7U0084773 for perforce@freebsd.org; Sun, 24 May 2009 18:43:07 GMT (envelope-from mav@freebsd.org) Date: Sun, 24 May 2009 18:43:07 GMT Message-Id: <200905241843.n4OIh7U0084773@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Cc: Subject: PERFORCE change 162663 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2009 18:43:09 -0000 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);