linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sitsofe Wheeler <sitsofe@gmail.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, ohering@suse.com,
	apw@canonical.com, jasowang@redhat.com, jbottomley@parallels.com,
	hch@infradead.org, linux-scsi@vger.kernel.org
Subject: [PATCH 1/3] [SCSI] Add quirk for forcing logical block provisioning tests
Date: Thu, 24 Jul 2014 08:52:07 +0100	[thread overview]
Message-ID: <20140724075207.GB15127@sucs.org> (raw)
In-Reply-To: <20140724074739.GA15127@sucs.org>

Despite supporting modern SCSI features (such an UNMAP) some storage
devices continue to claim conformance to an older version of the SPC
spec for compatibility with legacy operating systems.

Linux by default will not attempt to read VPD pages on devices that
claim SPC-2 or older.

Introduce a blacklist flag that allows the forcing of the paths leading
to logical block provisioning tests.

See https://lkml.org/lkml/2014/7/13/59 for the previous version.

Reported-by: K. Y. Srinivasan <kys@microsoft.com>
Original-patch-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
---
 drivers/scsi/scsi_scan.c    |  4 +++-
 drivers/scsi/sd.c           |  8 ++++++++
 drivers/scsi/storvsc_drv.c  | 10 ++++++++++
 include/scsi/scsi_device.h  |  1 +
 include/scsi/scsi_devinfo.h |  2 ++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index e02b3aa..02ca1c2 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -950,7 +950,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
 	sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
 
-	if (*bflags & BLIST_SKIP_VPD_PAGES)
+	if (*bflags & BLIST_TRY_LBP)
+		sdev->try_lbp = 1;
+	else if (*bflags & BLIST_SKIP_VPD_PAGES)
 		sdev->skip_vpd_pages = 1;
 
 	transport_configure_device(&sdev->sdev_gendev);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6825eda..8249e51 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2109,6 +2109,8 @@ static int sd_try_rc16_first(struct scsi_device *sdp)
 		return 1;
 	if (scsi_device_protection(sdp))
 		return 1;
+	if (sdp->try_lbp)
+		return 1;
 	return 0;
 }
 
@@ -2682,6 +2684,12 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
 static int sd_try_extended_inquiry(struct scsi_device *sdp)
 {
 	/*
+	 * Attempt VPD inquiry if the device blacklist explicitly calls
+	 * for it.
+	 */
+	if (sdp->try_lbp)
+		return 1;
+	/*
 	 * Although VPD inquiries can go to SCSI-2 type devices,
 	 * some USB ones crash on receiving them, and the pages
 	 * we currently ask for are for SPC-3 and beyond
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 9969fa1..5ad2810 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -326,6 +326,8 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
  */
 static int storvsc_timeout = 180;
 
+static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
+
 #define STORVSC_MAX_IO_REQUESTS				200
 
 static void storvsc_on_channel_callback(void *context);
@@ -1441,6 +1443,14 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 
 	sdevice->no_write_same = 1;
 
+	/*
+	 * Add blist flags to permit the reading of the VPD pages even when
+	 * the target may claim SPC-2 compliance. MSFT targets currently
+	 * claim SPC-2 compliance while they implement post SPC-2 features.
+	 * With this patch we can correctly handle WRITE_SAME_16 issues.
+	 */
+	sdevice->sdev_bflags |= msft_blist_flags;
+
 	return 0;
 }
 
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 27ab310..0a5c6fa 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -155,6 +155,7 @@ struct scsi_device {
 	unsigned skip_ms_page_8:1;	/* do not use MODE SENSE page 0x08 */
 	unsigned skip_ms_page_3f:1;	/* do not use MODE SENSE page 0x3f */
 	unsigned skip_vpd_pages:1;	/* do not read VPD pages */
+	unsigned try_lbp:1;		/* Try LBP tests */
 	unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
 	unsigned no_start_on_add:1;	/* do not issue start on add */
 	unsigned allow_restart:1; /* issue START_UNIT in error handler */
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 447d2d7..9d15d78 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -32,4 +32,6 @@
 #define BLIST_ATTACH_PQ3	0x1000000 /* Scan: Attach to PQ3 devices */
 #define BLIST_NO_DIF		0x2000000 /* Disable T10 PI (DIF) */
 #define BLIST_SKIP_VPD_PAGES	0x4000000 /* Ignore SBC-3 VPD pages */
+#define BLIST_TRY_LBP		0x10000000 /* Check Logical Block Provisioning
+					      even on < SPC-3 devices */
 #endif
-- 
1.9.3

  reply	other threads:[~2014-07-24  7:52 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 23:06 [PATCH 1/1] Drivers: scsi: storvsc: Add blist flags K. Y. Srinivasan
2014-07-23 10:04 ` Sitsofe Wheeler
2014-07-23 11:51   ` Christoph Hellwig
2014-07-23 12:54     ` Sitsofe Wheeler
2014-07-23 14:10       ` Christoph Hellwig
2014-07-23 15:31         ` Sitsofe Wheeler
2014-07-23 15:40         ` KY Srinivasan
2014-07-23 15:39   ` KY Srinivasan
2014-07-23 14:10 ` Sitsofe Wheeler
2014-07-23 14:15   ` Christoph Hellwig
2014-07-23 20:13     ` Sitsofe Wheeler
2014-07-24  7:47       ` [PATCH 0/3] Enable discard on Hyper-V Sitsofe Wheeler
2014-07-24  7:52         ` Sitsofe Wheeler [this message]
2014-07-24  7:56         ` [PATCH 2/3] [SCSI] storvsc: Add Hyper-V logical block provisioning tests Sitsofe Wheeler
2014-07-24 14:09           ` James Bottomley
2014-07-24 18:03             ` Sitsofe Wheeler
2014-07-24  7:58         ` [PATCH 3/3] [SCSI] Make LBP quirk skip lbpme checks tests Sitsofe Wheeler
2014-07-24 12:22           ` [PATCH v2 " Sitsofe Wheeler
2014-07-24 13:54             ` Martin K. Petersen
2014-07-24 15:34               ` Christoph Hellwig
2014-07-24 15:35                 ` Christoph Hellwig
2014-07-24 16:24                   ` Sitsofe Wheeler
2014-07-24 15:36               ` Sitsofe Wheeler
2014-07-24 15:54                 ` Martin K. Petersen
2014-07-25 16:47                   ` KY Srinivasan
2014-07-25 16:57                     ` Martin K. Petersen
2014-07-26 13:44                       ` KY Srinivasan
2014-07-26 16:54                         ` Martin K. Petersen
2014-07-26 17:17                           ` KY Srinivasan
2014-07-26 19:25                             ` Martin K. Petersen
2014-07-27  2:09                               ` KY Srinivasan
2014-07-28 18:50                               ` KY Srinivasan
2014-07-28 19:02                                 ` Martin K. Petersen
2014-07-28 19:05                                   ` KY Srinivasan
2014-07-28 20:02                                     ` James Bottomley
2014-07-28 20:05                                       ` KY Srinivasan
2014-07-29 17:41                                       ` KY Srinivasan
2014-07-29 19:30                                         ` Martin K. Petersen
2014-07-25 17:10                     ` James Bottomley
2014-07-26 13:42                       ` KY Srinivasan
2014-07-24 12:37         ` [PATCH 0/3] Enable discard on Hyper-V Sitsofe Wheeler
2014-07-24  5:40 ` [PATCH 1/1] Drivers: scsi: storvsc: Add blist flags Hannes Reinecke
2014-08-01 19:48   ` Sitsofe Wheeler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140724075207.GB15127@sucs.org \
    --to=sitsofe@gmail.com \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=jasowang@redhat.com \
    --cc=jbottomley@parallels.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=ohering@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).