From owner-svn-src-stable-11@freebsd.org Mon Aug 8 07:09:42 2016 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 047E9BB1F44; Mon, 8 Aug 2016 07:09:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 AACE81E1F; Mon, 8 Aug 2016 07:09:41 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7879eeE039971; Mon, 8 Aug 2016 07:09:40 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7879ef3039970; Mon, 8 Aug 2016 07:09:40 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201608080709.u7879ef3039970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 8 Aug 2016 07:09:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r303828 - stable/11/sys/dev/hyperv/storvsc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2016 07:09:42 -0000 Author: sephe Date: Mon Aug 8 07:09:40 2016 New Revision: 303828 URL: https://svnweb.freebsd.org/changeset/base/303828 Log: MFC 303737 hyperv/storvsc: Claim SPC-3 conformance, thus enable UNMAP support The Hyper-V on pre-win10 systems will only report SPC-2 conformance, but it actually conforms to SPC-3. The INQUIRY response is adjusted to propagate the SPC-3 version information to CAM. Submitted by: Hongjiang Zhang Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7405 Approved by: re (delphij) Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Aug 8 06:33:59 2016 (r303827) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Aug 8 07:09:40 2016 (r303828) @@ -2062,8 +2062,8 @@ storvsc_io_done(struct hv_storvsc_reques * For more information about INQUIRY, please refer to: * ftp://ftp.avc-pioneer.com/Mtfuji_7/Proposal/Jun09/INQUIRY.pdf */ - const struct scsi_inquiry_data *inq_data = - (const struct scsi_inquiry_data *)csio->data_ptr; + struct scsi_inquiry_data *inq_data = + (struct scsi_inquiry_data *)csio->data_ptr; uint8_t* resp_buf = (uint8_t*)csio->data_ptr; /* Get the buffer length reported by host */ int resp_xfer_len = vm_srb->transfer_len; @@ -2092,6 +2092,25 @@ storvsc_io_done(struct hv_storvsc_reques mtx_unlock(&sc->hs_lock); } } else { + char vendor[16]; + cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor), + sizeof(vendor)); + /** + * XXX: upgrade SPC2 to SPC3 if host is WIN8 or WIN2012 R2 + * in order to support UNMAP feature + */ + if (!strncmp(vendor,"Msft",4) && + SID_ANSI_REV(inq_data) == SCSI_REV_SPC2 && + (vmstor_proto_version == VMSTOR_PROTOCOL_VERSION_WIN8_1 || + vmstor_proto_version== VMSTOR_PROTOCOL_VERSION_WIN8)) { + inq_data->version = SCSI_REV_SPC3; + if (bootverbose) { + mtx_lock(&sc->hs_lock); + xpt_print(ccb->ccb_h.path, + "storvsc upgrades SPC2 to SPC3\n"); + mtx_unlock(&sc->hs_lock); + } + } ccb->ccb_h.status |= CAM_REQ_CMP; if (bootverbose) { mtx_lock(&sc->hs_lock);