linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Drivers: scsi: storvsc
@ 2013-02-21 20:04 K. Y. Srinivasan
  2013-02-21 20:04 ` [PATCH RESEND 1/4] Drivers: scsi: storvsc: Initialize the sglist K. Y. Srinivasan
  0 siblings, 1 reply; 5+ messages in thread
From: K. Y. Srinivasan @ 2013-02-21 20:04 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, ohering, jbottomley, hch, linux-scsi
  Cc: K. Y. Srinivasan

This patch set (two of the patches are being resent) fixes and enhances
the functionality of the Hyper-V storage driver

K. Y. Srinivasan (3):
  Drivers: scsi: storvsc: Initialize the sglist
  Drivers: scsi: storvsc: Restructure error handling code on command
    completion
  Drivers: scsi: storvsc: Handle dynamic resizing of the device

Olaf Hering (1):
  scsi: storvsc: avoid usage of WRITE_SAME

 drivers/scsi/storvsc_drv.c |  137 ++++++++++++++++++++++++++++++-------------
 1 files changed, 95 insertions(+), 42 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH RESEND 1/4] Drivers: scsi: storvsc: Initialize the sglist
  2013-02-21 20:04 [PATCH 0/4] Drivers: scsi: storvsc K. Y. Srinivasan
@ 2013-02-21 20:04 ` K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH RESEND 2/4] scsi: storvsc: avoid usage of WRITE_SAME K. Y. Srinivasan
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: K. Y. Srinivasan @ 2013-02-21 20:04 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, ohering, jbottomley, hch, linux-scsi
  Cc: K. Y. Srinivasan, stable

Initialize sglist before using it.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
---
 drivers/scsi/storvsc_drv.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 270b3cf..5ada1d0 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -467,6 +467,7 @@ static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
 	if (!bounce_sgl)
 		return NULL;
 
+	sg_init_table(bounce_sgl, num_pages);
 	for (i = 0; i < num_pages; i++) {
 		page_buf = alloc_page(GFP_ATOMIC);
 		if (!page_buf)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH RESEND 2/4] scsi: storvsc: avoid usage of WRITE_SAME
  2013-02-21 20:04 ` [PATCH RESEND 1/4] Drivers: scsi: storvsc: Initialize the sglist K. Y. Srinivasan
@ 2013-02-21 20:04   ` K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH 3/4] Drivers: scsi: storvsc: Restructure error handling code on command completion K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH 4/4] Drivers: scsi: storvsc: Handle dynamic resizing of the device K. Y. Srinivasan
  2 siblings, 0 replies; 5+ messages in thread
From: K. Y. Srinivasan @ 2013-02-21 20:04 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, ohering, jbottomley, hch, linux-scsi
  Cc: Olaf Hering, KY Srinivasan

From: Olaf Hering <olaf@aepfle.de>

Set scsi_device->no_write_same because the host does not support it.
Also blacklist WRITE_SAME to avoid (and log) accident usage.

If the guest uses the ext4 filesystem, storvsc hangs while it prints
these messages in an endless loop:
...
[  161.459523] hv_storvsc vmbus_0_1: cmd 0x41 scsi status 0x2 srb status 0x6
[  161.462157] sd 2:0:0:0: [sda]
[  161.463135] Sense Key : No Sense [current]
[  161.464983] sd 2:0:0:0: [sda]
[  161.465899] Add. Sense: No additional sense information
[  161.468211] hv_storvsc vmbus_0_1: cmd 0x41 scsi status 0x2 srb status 0x6
[  161.475766] sd 2:0:0:0: [sda]
[  161.476728] Sense Key : No Sense [current]
[  161.478284] sd 2:0:0:0: [sda]
[  161.479441] Add. Sense: No additional sense information
...

This happens with a guest running on Windows Server 2012, but happens to
work while running on Windows Server 2008. WRITE_SAME isnt really
supported by both versions, so disable the command usage globally.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: KY Srinivasan <kys@microsoft.com>
Cc: <linux-scsi@vger.kernel.org>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/scsi/storvsc_drv.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 5ada1d0..2060509 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1156,6 +1156,8 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 
 	blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
 
+	sdevice->no_write_same = 1;
+
 	return 0;
 }
 
@@ -1238,6 +1240,8 @@ static bool storvsc_scsi_cmd_ok(struct scsi_cmnd *scmnd)
 	u8 scsi_op = scmnd->cmnd[0];
 
 	switch (scsi_op) {
+	/* the host does not handle WRITE_SAME, log accident usage */
+	case WRITE_SAME:
 	/*
 	 * smartd sends this command and the host does not handle
 	 * this. So, don't send it.
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] Drivers: scsi: storvsc: Restructure error handling code on command completion
  2013-02-21 20:04 ` [PATCH RESEND 1/4] Drivers: scsi: storvsc: Initialize the sglist K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH RESEND 2/4] scsi: storvsc: avoid usage of WRITE_SAME K. Y. Srinivasan
@ 2013-02-21 20:04   ` K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH 4/4] Drivers: scsi: storvsc: Handle dynamic resizing of the device K. Y. Srinivasan
  2 siblings, 0 replies; 5+ messages in thread
From: K. Y. Srinivasan @ 2013-02-21 20:04 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, ohering, jbottomley, hch, linux-scsi
  Cc: K. Y. Srinivasan

In preparation for handling additional sense codes, restructure and cleanup
the error handling code in the command completion code path.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/scsi/storvsc_drv.c |  101 +++++++++++++++++++++++++------------------
 1 files changed, 59 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 2060509..16d5aac 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -761,6 +761,55 @@ cleanup:
 	return ret;
 }
 
+static void storvsc_handle_error(struct vmscsi_request *vm_srb,
+				struct scsi_cmnd *scmnd,
+				struct Scsi_Host *host,
+				u8 asc, u8 ascq)
+{
+	struct storvsc_scan_work *wrk;
+	void (*process_err_fn)(struct work_struct *work);
+	bool do_work = false;
+
+	switch (vm_srb->srb_status) {
+	case SRB_STATUS_ERROR:
+		/*
+		 * If there is an error; offline the device since all
+		 * error recovery strategies would have already been
+		 * deployed on the host side. However, if the command
+		 * were a pass-through command deal with it appropriately.
+		 */
+		switch (scmnd->cmnd[0]) {
+		case ATA_16:
+		case ATA_12:
+			set_host_byte(scmnd, DID_PASSTHROUGH);
+			break;
+		default:
+			set_host_byte(scmnd, DID_TARGET_FAILURE);
+		}
+		break;
+	case SRB_STATUS_INVALID_LUN:
+		do_work = true;
+		process_err_fn = storvsc_remove_lun;
+		break;
+	}
+	if (!do_work)
+		return;
+
+	/*
+	 * We need to schedule work to process this error; schedule it.
+	 */
+	wrk = kmalloc(sizeof(struct storvsc_scan_work), GFP_ATOMIC);
+	if (!wrk) {
+		set_host_byte(scmnd, DID_TARGET_FAILURE);
+		return;
+	}
+
+	wrk->host = host;
+	wrk->lun = vm_srb->lun;
+	INIT_WORK(&wrk->work, process_err_fn);
+	schedule_work(&wrk->work);
+}
+
 
 static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
 {
@@ -769,8 +818,13 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
 	void (*scsi_done_fn)(struct scsi_cmnd *);
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
-	struct storvsc_scan_work *wrk;
 	struct stor_mem_pools *memp = scmnd->device->hostdata;
+	struct Scsi_Host *host;
+	struct storvsc_device *stor_dev;
+	struct hv_device *dev = host_dev->dev;
+
+	stor_dev = get_in_stor_device(dev);
+	host = stor_dev->host;
 
 	vm_srb = &cmd_request->vstor_packet.vm_srb;
 	if (cmd_request->bounce_sgl_count) {
@@ -783,55 +837,18 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
 					cmd_request->bounce_sgl_count);
 	}
 
-	/*
-	 * If there is an error; offline the device since all
-	 * error recovery strategies would have already been
-	 * deployed on the host side. However, if the command
-	 * were a pass-through command deal with it appropriately.
-	 */
 	scmnd->result = vm_srb->scsi_status;
 
-	if (vm_srb->srb_status == SRB_STATUS_ERROR) {
-		switch (scmnd->cmnd[0]) {
-		case ATA_16:
-		case ATA_12:
-			set_host_byte(scmnd, DID_PASSTHROUGH);
-			break;
-		default:
-			set_host_byte(scmnd, DID_TARGET_FAILURE);
-		}
-	}
-
-
-	/*
-	 * If the LUN is invalid; remove the device.
-	 */
-	if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) {
-		struct storvsc_device *stor_dev;
-		struct hv_device *dev = host_dev->dev;
-		struct Scsi_Host *host;
-
-		stor_dev = get_in_stor_device(dev);
-		host = stor_dev->host;
-
-		wrk = kmalloc(sizeof(struct storvsc_scan_work),
-				GFP_ATOMIC);
-		if (!wrk) {
-			scmnd->result = DID_TARGET_FAILURE << 16;
-		} else {
-			wrk->host = host;
-			wrk->lun = vm_srb->lun;
-			INIT_WORK(&wrk->work, storvsc_remove_lun);
-			schedule_work(&wrk->work);
-		}
-	}
-
 	if (scmnd->result) {
 		if (scsi_normalize_sense(scmnd->sense_buffer,
 				SCSI_SENSE_BUFFERSIZE, &sense_hdr))
 			scsi_print_sense_hdr("storvsc", &sense_hdr);
 	}
 
+	if (vm_srb->srb_status != SRB_STATUS_SUCCESS)
+		storvsc_handle_error(vm_srb, scmnd, host, sense_hdr.asc,
+					 sense_hdr.ascq);
+
 	scsi_set_resid(scmnd,
 		cmd_request->data_buffer.len -
 		vm_srb->data_transfer_length);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] Drivers: scsi: storvsc: Handle dynamic resizing of the device
  2013-02-21 20:04 ` [PATCH RESEND 1/4] Drivers: scsi: storvsc: Initialize the sglist K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH RESEND 2/4] scsi: storvsc: avoid usage of WRITE_SAME K. Y. Srinivasan
  2013-02-21 20:04   ` [PATCH 3/4] Drivers: scsi: storvsc: Restructure error handling code on command completion K. Y. Srinivasan
@ 2013-02-21 20:04   ` K. Y. Srinivasan
  2 siblings, 0 replies; 5+ messages in thread
From: K. Y. Srinivasan @ 2013-02-21 20:04 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, ohering, jbottomley, hch, linux-scsi
  Cc: K. Y. Srinivasan

Handle LUN size changes by re-scanning the device.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/scsi/storvsc_drv.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 16d5aac..16a3a0c 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -201,6 +201,7 @@ enum storvsc_request_type {
 #define SRB_STATUS_AUTOSENSE_VALID	0x80
 #define SRB_STATUS_INVALID_LUN	0x20
 #define SRB_STATUS_SUCCESS	0x01
+#define SRB_STATUS_ABORTED	0x02
 #define SRB_STATUS_ERROR	0x04
 
 /*
@@ -295,6 +296,25 @@ struct storvsc_scan_work {
 	uint lun;
 };
 
+static void storvsc_device_scan(struct work_struct *work)
+{
+	struct storvsc_scan_work *wrk;
+	uint lun;
+	struct scsi_device *sdev;
+
+	wrk = container_of(work, struct storvsc_scan_work, work);
+	lun = wrk->lun;
+
+	sdev = scsi_device_lookup(wrk->host, 0, 0, lun);
+	if (!sdev)
+		goto done;
+	scsi_rescan_device(&sdev->sdev_gendev);
+	scsi_device_put(sdev);
+
+done:
+	kfree(wrk);
+}
+
 static void storvsc_bus_scan(struct work_struct *work)
 {
 	struct storvsc_scan_work *wrk;
@@ -791,7 +811,18 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,
 		do_work = true;
 		process_err_fn = storvsc_remove_lun;
 		break;
+	case (SRB_STATUS_ABORTED | SRB_STATUS_AUTOSENSE_VALID):
+		if ((asc == 0x2a) && (ascq == 0x9)) {
+			do_work = true;
+			process_err_fn = storvsc_device_scan;
+			/*
+			 * Retry the I/O that trigerred this.
+			 */
+			set_host_byte(scmnd, DID_REQUEUE);
+		}
+		break;
 	}
+
 	if (!do_work)
 		return;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-21 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-21 20:04 [PATCH 0/4] Drivers: scsi: storvsc K. Y. Srinivasan
2013-02-21 20:04 ` [PATCH RESEND 1/4] Drivers: scsi: storvsc: Initialize the sglist K. Y. Srinivasan
2013-02-21 20:04   ` [PATCH RESEND 2/4] scsi: storvsc: avoid usage of WRITE_SAME K. Y. Srinivasan
2013-02-21 20:04   ` [PATCH 3/4] Drivers: scsi: storvsc: Restructure error handling code on command completion K. Y. Srinivasan
2013-02-21 20:04   ` [PATCH 4/4] Drivers: scsi: storvsc: Handle dynamic resizing of the device K. Y. Srinivasan

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).