From owner-svn-src-head@FreeBSD.ORG Thu Jun 26 09:42:01 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6B3ACBE1; Thu, 26 Jun 2014 09:42:01 +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 589C123E9; Thu, 26 Jun 2014 09:42:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5Q9g1rl088374; Thu, 26 Jun 2014 09:42:01 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5Q9g0O3088364; Thu, 26 Jun 2014 09:42:00 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201406260942.s5Q9g0O3088364@svn.freebsd.org> From: Alexander Motin Date: Thu, 26 Jun 2014 09:42:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267906 - in head/sys/cam: ctl scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2014 09:42:01 -0000 Author: mav Date: Thu Jun 26 09:42:00 2014 New Revision: 267906 URL: http://svnweb.freebsd.org/changeset/base/267906 Log: Allow MODE SENSE commands through Write Exclusive persistent reservation, as required by SPC-4. Report that fact in persistent reservation capabilities. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_cmd_table.c head/sys/cam/scsi/scsi_all.h Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Thu Jun 26 08:56:36 2014 (r267905) +++ head/sys/cam/ctl/ctl.c Thu Jun 26 09:42:00 2014 (r267906) @@ -6672,6 +6672,24 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) else control_dev = 0; + if (lun->flags & CTL_LUN_PR_RESERVED) { + uint32_t residx; + + /* + * XXX KDM need a lock here. + */ + residx = ctl_get_resindex(&ctsio->io_hdr.nexus); + if ((lun->res_type == SPR_TYPE_EX_AC + && residx != lun->pr_res_idx) + || ((lun->res_type == SPR_TYPE_EX_AC_RO + || lun->res_type == SPR_TYPE_EX_AC_AR) + && !lun->per_res[residx].registered)) { + ctl_set_reservation_conflict(ctsio); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); + } + } + switch (ctsio->cdb[0]) { case MODE_SENSE_6: { struct scsi_mode_sense_6 *cdb; @@ -7465,7 +7483,7 @@ retry: res_cap = (struct scsi_per_res_cap *)ctsio->kern_data_ptr; scsi_ulto2b(sizeof(*res_cap), res_cap->length); - res_cap->flags2 |= SPRI_TMV; + res_cap->flags2 |= SPRI_TMV | SPRI_ALLOW_3; type_mask = SPRI_TM_WR_EX_AR | SPRI_TM_EX_AC_RO | SPRI_TM_WR_EX_RO | Modified: head/sys/cam/ctl/ctl_cmd_table.c ============================================================================== --- head/sys/cam/ctl/ctl_cmd_table.c Thu Jun 26 08:56:36 2014 (r267905) +++ head/sys/cam/ctl/ctl_cmd_table.c Thu Jun 26 09:42:00 2014 (r267906) @@ -192,7 +192,8 @@ struct ctl_cmd_entry ctl_cmd_table[] = CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_SECONDARY | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE}, /* 1B START STOP UNIT */ @@ -436,7 +437,8 @@ struct ctl_cmd_entry ctl_cmd_table[] = CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_SECONDARY | - CTL_FLAG_DATA_IN, + CTL_FLAG_DATA_IN | + CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_LUN_PAT_NONE}, /* 5B CLOSE TRACK/SESSION */ Modified: head/sys/cam/scsi/scsi_all.h ============================================================================== --- head/sys/cam/scsi/scsi_all.h Thu Jun 26 08:56:36 2014 (r267905) +++ head/sys/cam/scsi/scsi_all.h Thu Jun 26 09:42:00 2014 (r267906) @@ -308,6 +308,11 @@ struct scsi_per_res_cap #define SPRI_PTPL_C 0x01 uint8_t flags2; #define SPRI_TMV 0x80 +#define SPRI_ALLOW_MASK 0x70 +#define SPRI_ALLOW_0 0x00 +#define SPRI_ALLOW_1 0x10 +#define SPRI_ALLOW_2 0x20 +#define SPRI_ALLOW_3 0x30 #define SPRI_PTPL_A 0x01 uint8_t type_mask[2]; #define SPRI_TM_WR_EX_AR 0x8000 @@ -746,12 +751,16 @@ struct scsi_read_buffer { u_int8_t opcode; u_int8_t byte2; -#define RWB_MODE 0x07 +#define RWB_MODE 0x1F #define RWB_MODE_HDR_DATA 0x00 #define RWB_MODE_VENDOR 0x01 #define RWB_MODE_DATA 0x02 +#define RWB_MODE_DESCR 0x03 #define RWB_MODE_DOWNLOAD 0x04 #define RWB_MODE_DOWNLOAD_SAVE 0x05 +#define RWB_MODE_ECHO 0x0A +#define RWB_MODE_ECHO_DESCR 0x0B +#define RWB_MODE_ERROR_HISTORY 0x1C u_int8_t buffer_id; u_int8_t offset[3]; u_int8_t length[3];