From owner-svn-src-stable@freebsd.org Thu Jan 5 11:45:37 2017 Return-Path: Delivered-To: svn-src-stable@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 E89DFCA0BC6; Thu, 5 Jan 2017 11:45:37 +0000 (UTC) (envelope-from mav@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 C31E91BB1; Thu, 5 Jan 2017 11:45:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v05BjaJQ058720; Thu, 5 Jan 2017 11:45:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v05BjaER058717; Thu, 5 Jan 2017 11:45:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201701051145.v05BjaER058717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 5 Jan 2017 11:45:36 +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: r311428 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2017 11:45:38 -0000 Author: mav Date: Thu Jan 5 11:45:36 2017 New Revision: 311428 URL: https://svnweb.freebsd.org/changeset/base/311428 Log: MFC r310366: Add support for SITUA bit in Logical Block Provisioning mode page. VMware tries to enable this bit to avoid multiple threshold notifications in case of multiple initiators connected to the same LUN. Unfortunately their code sends MODE SELECT(6) request with parameter length hardcoded for the page without any thresholds. Since we have four threshold and our page is bigger, this attempt fails, that is correct in my understanding. So all we can do about this now is to report proper error code and hope VMware fix their code one day. Modified: stable/10/sys/cam/ctl/ctl.c stable/10/sys/cam/ctl/ctl_error.c stable/10/sys/cam/ctl/ctl_private.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:44:56 2017 (r311427) +++ stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:45:36 2017 (r311428) @@ -332,7 +332,7 @@ const static struct ctl_logical_block_pr /*page_code*/SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, /*subpage_code*/0x02, /*page_length*/{CTL_LBPM_LEN >> 8, CTL_LBPM_LEN}, - /*flags*/0, + /*flags*/SLBPP_SITUA, /*reserved*/{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /*descr*/{}}, {{/*flags*/0, @@ -6066,11 +6066,7 @@ do_next_page: * the mode page header, or if they didn't specify enough data in * the CDB to avoid truncating this page, kick out the request. */ - if ((page_len != (page_index->page_len - page_len_offset - - page_len_size)) - || (*len_left < page_index->page_len)) { - - + if (page_len != page_index->page_len - page_len_offset - page_len_size) { ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 0, @@ -6081,6 +6077,12 @@ do_next_page: ctl_done((union ctl_io *)ctsio); return (CTL_RETVAL_COMPLETE); } + if (*len_left < page_index->page_len) { + free(ctsio->kern_data_ptr, M_CTL); + ctl_set_param_len_error(ctsio); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } /* * Run through the mode page, checking to make sure that the bits @@ -9317,13 +9319,6 @@ ctl_request_sense(struct ctl_scsiio *cts ua_type = ctl_build_ua(lun, initidx, sense_ptr, sense_format); if (ua_type != CTL_UA_NONE) have_error = 1; - if (ua_type == CTL_UA_LUN_CHANGE) { - mtx_unlock(&lun->lun_lock); - mtx_lock(&softc->ctl_lock); - ctl_clr_ua_allluns(softc, initidx, ua_type); - mtx_unlock(&softc->ctl_lock); - mtx_lock(&lun->lun_lock); - } } if (have_error == 0) { /* Modified: stable/10/sys/cam/ctl/ctl_error.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_error.c Thu Jan 5 11:44:56 2017 (r311427) +++ stable/10/sys/cam/ctl/ctl_error.c Thu Jan 5 11:45:36 2017 (r311428) @@ -515,6 +515,7 @@ ctl_build_ua(struct ctl_lun *lun, uint32 uint32_t p, i; mtx_assert(&lun->lun_lock, MA_OWNED); + mtx_assert(&lun->ctl_softc->ctl_lock, MA_NOTOWNED); p = initidx / CTL_MAX_INIT_PER_PORT; if ((ua = lun->pending_ua[p]) == NULL) { mtx_unlock(&lun->lun_lock); @@ -547,6 +548,17 @@ ctl_build_ua(struct ctl_lun *lun, uint32 /* We're reporting this UA, so clear it */ ua[i] &= ~ua_to_clear; + if (ua_to_build == CTL_UA_LUN_CHANGE) { + mtx_unlock(&lun->lun_lock); + mtx_lock(&lun->ctl_softc->ctl_lock); + ctl_clr_ua_allluns(lun->ctl_softc, initidx, ua_to_build); + mtx_unlock(&lun->ctl_softc->ctl_lock); + mtx_lock(&lun->lun_lock); + } else if (ua_to_build == CTL_UA_THIN_PROV_THRES && + (lun->MODE_LBP.main.flags & SLBPP_SITUA) != 0) { + ctl_clr_ua_all(lun, -1, ua_to_build); + } + return (ua_to_build); } Modified: stable/10/sys/cam/ctl/ctl_private.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_private.h Thu Jan 5 11:44:56 2017 (r311427) +++ stable/10/sys/cam/ctl/ctl_private.h Thu Jan 5 11:45:36 2017 (r311428) @@ -290,7 +290,7 @@ static const struct ctl_page_index page_ CTL_PAGE_FLAG_ALL, NULL, ctl_ie_page_handler}, {SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02, sizeof(struct ctl_logical_block_provisioning_page), NULL, - CTL_PAGE_FLAG_DIRECT, NULL, NULL}, + CTL_PAGE_FLAG_DIRECT, NULL, ctl_default_page_handler}, {SMS_CDDVD_CAPS_PAGE, 0, sizeof(struct scsi_cddvd_capabilities_page), NULL, CTL_PAGE_FLAG_CDROM, NULL, NULL},