From owner-svn-src-all@FreeBSD.ORG Thu May 8 07:12:07 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1B23EEC0; Thu, 8 May 2014 07:12:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 07DF783C; Thu, 8 May 2014 07:12:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s487C6MN054361; Thu, 8 May 2014 07:12:06 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s487C6dv054360; Thu, 8 May 2014 07:12:06 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201405080712.s487C6dv054360@svn.freebsd.org> From: Alexander Motin Date: Thu, 8 May 2014 07:12:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265643 - stable/10/sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 May 2014 07:12:07 -0000 Author: mav Date: Thu May 8 07:12:06 2014 New Revision: 265643 URL: http://svnweb.freebsd.org/changeset/base/265643 Log: MFC r265150: Do not reread SCSI disk VPD pages on every device open. Instead of rereading VPD pages on every device open, do it only on initial device probe, and in cases when device reported via UNIT ATTENTIONs that something has changed. Capacity is still rereaded on every open because it is more critical for operation and more probable to change in run time. On my tests with Intel 530 SSDs on mps(4) HBA this change reduces time GEOM needs to retaste the device (that includes few open/close cycles) from ~150ms to ~30ms. Modified: stable/10/sys/cam/scsi/scsi_da.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_da.c Thu May 8 07:10:38 2014 (r265642) +++ stable/10/sys/cam/scsi/scsi_da.c Thu May 8 07:12:06 2014 (r265643) @@ -90,7 +90,8 @@ typedef enum { DA_FLAG_SCTX_INIT = 0x200, DA_FLAG_CAN_RC16 = 0x400, DA_FLAG_PROBED = 0x800, - DA_FLAG_DIRTY = 0x1000 + DA_FLAG_DIRTY = 0x1000, + DA_FLAG_ANNOUNCED = 0x2000 } da_flags; typedef enum { @@ -1658,10 +1659,18 @@ daasync(void *callback_arg, u_int32_t co &error_code, &sense_key, &asc, &ascq)) { if (asc == 0x2A && ascq == 0x09) { xpt_print(ccb->ccb_h.path, - "capacity data has changed\n"); + "Capacity data has changed\n"); + softc->flags &= ~DA_FLAG_PROBED; dareprobe(periph); - } else if (asc == 0x28 && ascq == 0x00) + } else if (asc == 0x28 && ascq == 0x00) { + softc->flags &= ~DA_FLAG_PROBED; disk_media_changed(softc->disk, M_NOWAIT); + } else if (asc == 0x3F && ascq == 0x03) { + xpt_print(ccb->ccb_h.path, + "INQUIRY data has changed\n"); + softc->flags &= ~DA_FLAG_PROBED; + dareprobe(periph); + } } cam_periph_async(periph, code, path, arg); break; @@ -1891,7 +1900,7 @@ daprobedone(struct cam_periph *periph, u dadeletemethodchoose(softc, DA_DELETE_NONE); - if (bootverbose && (softc->flags & DA_FLAG_PROBED) == 0) { + if (bootverbose && (softc->flags & DA_FLAG_ANNOUNCED) == 0) { char buf[80]; int i, sep; @@ -1932,10 +1941,11 @@ daprobedone(struct cam_periph *periph, u */ xpt_release_ccb(ccb); softc->state = DA_STATE_NORMAL; + softc->flags |= DA_FLAG_PROBED; daschedule(periph); wakeup(&softc->disk->d_mediasize); - if ((softc->flags & DA_FLAG_PROBED) == 0) { - softc->flags |= DA_FLAG_PROBED; + if ((softc->flags & DA_FLAG_ANNOUNCED) == 0) { + softc->flags |= DA_FLAG_ANNOUNCED; cam_periph_unhold(periph); } else cam_periph_release_locked(periph); @@ -3193,7 +3203,8 @@ dadone(struct cam_periph *periph, union } } free(csio->data_ptr, M_SCSIDA); - if (announce_buf[0] != '\0' && ((softc->flags & DA_FLAG_PROBED) == 0)) { + if (announce_buf[0] != '\0' && + ((softc->flags & DA_FLAG_ANNOUNCED) == 0)) { /* * Create our sysctl variables, now that we know * we have successfully attached. @@ -3211,6 +3222,12 @@ dadone(struct cam_periph *periph, union } } + /* We already probed the device. */ + if (softc->flags & DA_FLAG_PROBED) { + daprobedone(periph, done_ccb); + return; + } + /* Ensure re-probe doesn't see old delete. */ softc->delete_available = 0; if (lbp && (softc->quirks & DA_Q_NO_UNMAP) == 0) { @@ -3528,13 +3545,21 @@ daerror(union ccb *ccb, u_int32_t cam_fl */ else if (sense_key == SSD_KEY_UNIT_ATTENTION && asc == 0x2A && ascq == 0x09) { - xpt_print(periph->path, "capacity data has changed\n"); + xpt_print(periph->path, "Capacity data has changed\n"); + softc->flags &= ~DA_FLAG_PROBED; dareprobe(periph); sense_flags |= SF_NO_PRINT; } else if (sense_key == SSD_KEY_UNIT_ATTENTION && - asc == 0x28 && ascq == 0x00) + asc == 0x28 && ascq == 0x00) { + softc->flags &= ~DA_FLAG_PROBED; disk_media_changed(softc->disk, M_NOWAIT); - else if (sense_key == SSD_KEY_NOT_READY && + } else if (sense_key == SSD_KEY_UNIT_ATTENTION && + asc == 0x3F && ascq == 0x03) { + xpt_print(periph->path, "INQUIRY data has changed\n"); + softc->flags &= ~DA_FLAG_PROBED; + dareprobe(periph); + sense_flags |= SF_NO_PRINT; + } else if (sense_key == SSD_KEY_NOT_READY && asc == 0x3a && (softc->flags & DA_FLAG_PACK_INVALID) == 0) { softc->flags |= DA_FLAG_PACK_INVALID; disk_media_gone(softc->disk, M_NOWAIT);