Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jan 2015 13:12:48 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r276617 - stable/10/sys/cam/ctl
Message-ID:  <201501031312.t03DCmFe042240@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Jan  3 13:12:47 2015
New Revision: 276617
URL: https://svnweb.freebsd.org/changeset/base/276617

Log:
  MFC r276141: Hide block device VPD pages for non-block devices.

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	Sat Jan  3 13:11:39 2015	(r276616)
+++ stable/10/sys/cam/ctl/ctl.c	Sat Jan  3 13:12:47 2015	(r276617)
@@ -9601,6 +9601,7 @@ ctl_inquiry_evpd_supported(struct ctl_sc
 	struct scsi_vpd_supported_pages *pages;
 	int sup_page_size;
 	struct ctl_lun *lun;
+	int p;
 
 	lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
 
@@ -9634,27 +9635,30 @@ ctl_inquiry_evpd_supported(struct ctl_sc
 	else
 		pages->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT;
 
-	pages->length = SCSI_EVPD_NUM_SUPPORTED_PAGES;
+	p = 0;
 	/* Supported VPD pages */
-	pages->page_list[0] = SVPD_SUPPORTED_PAGES;
+	pages->page_list[p++] = SVPD_SUPPORTED_PAGES;
 	/* Serial Number */
-	pages->page_list[1] = SVPD_UNIT_SERIAL_NUMBER;
+	pages->page_list[p++] = SVPD_UNIT_SERIAL_NUMBER;
 	/* Device Identification */
-	pages->page_list[2] = SVPD_DEVICE_ID;
+	pages->page_list[p++] = SVPD_DEVICE_ID;
 	/* Extended INQUIRY Data */
-	pages->page_list[3] = SVPD_EXTENDED_INQUIRY_DATA;
+	pages->page_list[p++] = SVPD_EXTENDED_INQUIRY_DATA;
 	/* Mode Page Policy */
-	pages->page_list[4] = SVPD_MODE_PAGE_POLICY;
+	pages->page_list[p++] = SVPD_MODE_PAGE_POLICY;
 	/* SCSI Ports */
-	pages->page_list[5] = SVPD_SCSI_PORTS;
+	pages->page_list[p++] = SVPD_SCSI_PORTS;
 	/* Third-party Copy */
-	pages->page_list[6] = SVPD_SCSI_TPC;
-	/* Block limits */
-	pages->page_list[7] = SVPD_BLOCK_LIMITS;
-	/* Block Device Characteristics */
-	pages->page_list[8] = SVPD_BDC;
-	/* Logical Block Provisioning */
-	pages->page_list[9] = SVPD_LBP;
+	pages->page_list[p++] = SVPD_SCSI_TPC;
+	if (lun != NULL && lun->be_lun->lun_type == T_DIRECT) {
+		/* Block limits */
+		pages->page_list[p++] = SVPD_BLOCK_LIMITS;
+		/* Block Device Characteristics */
+		pages->page_list[p++] = SVPD_BDC;
+		/* Logical Block Provisioning */
+		pages->page_list[p++] = SVPD_LBP;
+	}
+	pages->length = p;
 
 	ctl_set_success(ctsio);
 	ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;
@@ -10236,13 +10240,12 @@ ctl_inquiry_evpd_lbp(struct ctl_scsiio *
 static int
 ctl_inquiry_evpd(struct ctl_scsiio *ctsio)
 {
+	struct ctl_lun *lun;
 	struct scsi_inquiry *cdb;
 	int alloc_len, retval;
 
+	lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
 	cdb = (struct scsi_inquiry *)ctsio->cdb;
-
-	retval = CTL_RETVAL_COMPLETE;
-
 	alloc_len = scsi_2btoul(cdb->length);
 
 	switch (cdb->page_code) {
@@ -10268,15 +10271,22 @@ ctl_inquiry_evpd(struct ctl_scsiio *ctsi
 		retval = ctl_inquiry_evpd_tpc(ctsio, alloc_len);
 		break;
 	case SVPD_BLOCK_LIMITS:
+		if (lun == NULL || lun->be_lun->lun_type != T_DIRECT)
+			goto err;
 		retval = ctl_inquiry_evpd_block_limits(ctsio, alloc_len);
 		break;
 	case SVPD_BDC:
+		if (lun == NULL || lun->be_lun->lun_type != T_DIRECT)
+			goto err;
 		retval = ctl_inquiry_evpd_bdc(ctsio, alloc_len);
 		break;
 	case SVPD_LBP:
+		if (lun == NULL || lun->be_lun->lun_type != T_DIRECT)
+			goto err;
 		retval = ctl_inquiry_evpd_lbp(ctsio, alloc_len);
 		break;
 	default:
+err:
 		ctl_set_invalid_field(ctsio,
 				      /*sks_valid*/ 1,
 				      /*command*/ 1,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501031312.t03DCmFe042240>