From owner-svn-src-stable@freebsd.org Thu Jan 5 11:25:14 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 21B8BC9F959; Thu, 5 Jan 2017 11:25:14 +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 EFB011F32; Thu, 5 Jan 2017 11:25:13 +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 v05BPD4T048843; Thu, 5 Jan 2017 11:25:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v05BPDZr048842; Thu, 5 Jan 2017 11:25:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201701051125.v05BPDZr048842@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:25:13 +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: r311404 - 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:25:14 -0000 Author: mav Date: Thu Jan 5 11:25:12 2017 New Revision: 311404 URL: https://svnweb.freebsd.org/changeset/base/311404 Log: MFC r310259: Following SPC-5, make REQUEST SENSE report "Logical unit not supported" in returned parameter data for not accessible LUNs. Modified: stable/10/sys/cam/ctl/ctl.c 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:23:55 2017 (r311403) +++ stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:25:12 2017 (r311404) @@ -9196,7 +9196,7 @@ ctl_request_sense(struct ctl_scsiio *cts { struct scsi_request_sense *cdb; struct scsi_sense_data *sense_ptr; - struct ctl_softc *ctl_softc; + struct ctl_softc *softc; struct ctl_lun *lun; uint32_t initidx; int have_error; @@ -9206,7 +9206,7 @@ ctl_request_sense(struct ctl_scsiio *cts cdb = (struct scsi_request_sense *)ctsio->cdb; - ctl_softc = control_softc; + softc = control_softc; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; CTL_DEBUG_PRINT(("ctl_request_sense\n")); @@ -9239,8 +9239,18 @@ ctl_request_sense(struct ctl_scsiio *cts /* * If we don't have a LUN, we don't have any pending sense. */ - if (lun == NULL) - goto no_sense; + if (lun == NULL || + ((lun->flags & CTL_LUN_PRIMARY_SC) == 0 && + softc->ha_link < CTL_HA_LINK_UNKNOWN)) { + /* "Logical unit not supported" */ + ctl_set_sense_data(sense_ptr, NULL, sense_format, + /*current_error*/ 1, + /*sense_key*/ SSD_KEY_ILLEGAL_REQUEST, + /*asc*/ 0x25, + /*ascq*/ 0x00, + SSD_ELEM_NONE); + goto send; + } have_error = 0; initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); @@ -9288,61 +9298,39 @@ ctl_request_sense(struct ctl_scsiio *cts have_error = 1; } else #endif - { + if (have_error == 0) { 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(&ctl_softc->ctl_lock); - ctl_clr_ua_allluns(ctl_softc, initidx, ua_type); - mtx_unlock(&ctl_softc->ctl_lock); + mtx_lock(&softc->ctl_lock); + ctl_clr_ua_allluns(softc, initidx, ua_type); + mtx_unlock(&softc->ctl_lock); mtx_lock(&lun->lun_lock); } - } - mtx_unlock(&lun->lun_lock); - - /* - * We already have a pending error, return it. - */ - if (have_error != 0) { + if (have_error == 0) { /* - * We report the SCSI status as OK, since the status of the - * request sense command itself is OK. - * We report 0 for the sense length, because we aren't doing - * autosense in this case. We're reporting sense as - * parameter data. + * Report informational exception if have one and allowed. */ - ctl_set_success(ctsio); - ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; - ctsio->be_move_done = ctl_config_move_done; - ctl_datamove((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); + if (lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie != SIEP_MRIE_NO) { + asc = lun->ie_asc; + ascq = lun->ie_ascq; + } + ctl_set_sense_data(sense_ptr, lun, sense_format, + /*current_error*/ 1, + /*sense_key*/ SSD_KEY_NO_SENSE, + /*asc*/ asc, + /*ascq*/ ascq, + SSD_ELEM_NONE); } + mtx_unlock(&lun->lun_lock); +send: /* - * No sense information to report, so we report that everything is - * okay, unless we have allowed Informational Exception. - */ - if (lun->mode_pages.ie_page[CTL_PAGE_CURRENT].mrie != SIEP_MRIE_NO) { - asc = lun->ie_asc; - ascq = lun->ie_ascq; - } - -no_sense: - ctl_set_sense_data(sense_ptr, - lun, - sense_format, - /*current_error*/ 1, - /*sense_key*/ SSD_KEY_NO_SENSE, - /*asc*/ asc, - /*ascq*/ ascq, - SSD_ELEM_NONE); - - /* - * We report 0 for the sense length, because we aren't doing - * autosense in this case. We're reporting sense as parameter data. + * We report the SCSI status as OK, since the status of the command + * itself is OK. We're reporting sense as parameter data. */ ctl_set_success(ctsio); ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;