virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features
  2011-11-08 17:01 [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features K. Y. Srinivasan
@ 2011-11-08 16:39 ` James Bottomley
  2011-11-08 16:46   ` KY Srinivasan
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
  1 sibling, 1 reply; 14+ messages in thread
From: James Bottomley @ 2011-11-08 16:39 UTC (permalink / raw)
  To: K. Y. Srinivasan
  Cc: gregkh, linux-kernel, devel, virtualization, ohering, hch

On Tue, 2011-11-08 at 09:01 -0800, K. Y. Srinivasan wrote:
> Cleanup storvsc based on review comments from James and
> implement a couple of new features:
> 
> 	1) The bulk of this patch-set addresses the review comments by James.
> 	   James, the last time I had posted the patch to move the storage
> 	   driver out of staging, you wanted to wait until Greg's tree had
> 	   percolated up. Now, Greg's staging/hv has been merged up. Do you 
> 	   now want me to re-post the patch to move the storage driver 
> 	   out of staging? Let me know.
> 
> 	2) I have also implemented the feature to support hot add/remove
> 	   of devices configured under the scsi controller on the host.

If you want scsi review on this, it should go to the scsi list:

linux-scsi@vger.kernel.org

James

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

* RE: [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features
  2011-11-08 16:39 ` James Bottomley
@ 2011-11-08 16:46   ` KY Srinivasan
  0 siblings, 0 replies; 14+ messages in thread
From: KY Srinivasan @ 2011-11-08 16:46 UTC (permalink / raw)
  To: James Bottomley
  Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org,
	ohering@suse.com, hch@infradead.org



> -----Original Message-----
> From: James Bottomley [mailto:James.Bottomley@HansenPartnership.com]
> Sent: Tuesday, November 08, 2011 11:40 AM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; ohering@suse.com;
> hch@infradead.org
> Subject: Re: [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features
> 
> On Tue, 2011-11-08 at 09:01 -0800, K. Y. Srinivasan wrote:
> > Cleanup storvsc based on review comments from James and
> > implement a couple of new features:
> >
> > 	1) The bulk of this patch-set addresses the review comments by James.
> > 	   James, the last time I had posted the patch to move the storage
> > 	   driver out of staging, you wanted to wait until Greg's tree had
> > 	   percolated up. Now, Greg's staging/hv has been merged up. Do you
> > 	   now want me to re-post the patch to move the storage driver
> > 	   out of staging? Let me know.
> >
> > 	2) I have also implemented the feature to support hot add/remove
> > 	   of devices configured under the scsi controller on the host.
> 
> If you want scsi review on this, it should go to the scsi list:
> 
> linux-scsi@vger.kernel.org

These patches are against Greg's current staging tree. 
I was planning to send the patch that would move this driver out of staging
(that would include the cleanup patches I just sent out) to the scsi list. I am going
to send it out shortly.

Regards,

K. Y




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

* [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features
@ 2011-11-08 17:01 K. Y. Srinivasan
  2011-11-08 16:39 ` James Bottomley
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
  0 siblings, 2 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan

Cleanup storvsc based on review comments from James and
implement a couple of new features:

	1) The bulk of this patch-set addresses the review comments by James.
	   James, the last time I had posted the patch to move the storage
	   driver out of staging, you wanted to wait until Greg's tree had
	   percolated up. Now, Greg's staging/hv has been merged up. Do you 
	   now want me to re-post the patch to move the storage driver 
	   out of staging? Let me know.

	2) I have also implemented the feature to support hot add/remove
	   of devices configured under the scsi controller on the host.

Regards,

K. Y

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

* [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request
  2011-11-08 17:01 [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features K. Y. Srinivasan
  2011-11-08 16:39 ` James Bottomley
@ 2011-11-08 17:01 ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 02/11] Staging: hv: storvsc: Cleanup error handling in the probe function K. Y. Srinivasan
                     ` (9 more replies)
  1 sibling, 10 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan, Haiyang Zhang

We intend to use the storage driver to manage the root device.
To avoid deadlocks, use mempools to allocate struct storvsc_cmd_request.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index ae8c33e..6a255e9 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/hyperv.h>
+#include <linux/mempool.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -42,6 +43,7 @@
 #include <scsi/scsi_dbg.h>
 
 
+#define STORVSC_MIN_BUF_NR				64
 #define STORVSC_RING_BUFFER_SIZE			(20*PAGE_SIZE)
 static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
 
@@ -287,6 +289,7 @@ struct storvsc_device {
 struct hv_host_device {
 	struct hv_device *dev;
 	struct kmem_cache *request_pool;
+	mempool_t *request_mempool;
 	unsigned int port;
 	unsigned char path;
 	unsigned char target;
@@ -974,8 +977,10 @@ static int storvsc_remove(struct hv_device *dev)
 
 	storvsc_dev_remove(dev);
 	if (host_dev->request_pool) {
+		mempool_destroy(host_dev->request_mempool);
 		kmem_cache_destroy(host_dev->request_pool);
 		host_dev->request_pool = NULL;
+		host_dev->request_mempool = NULL;
 	}
 	return 0;
 }
@@ -1120,7 +1125,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
 
 	scsi_done_fn(scmnd);
 
-	kmem_cache_free(host_dev->request_pool, cmd_request);
+	mempool_free(cmd_request, host_dev->request_mempool);
 }
 
 static bool storvsc_check_scsi_cmd(struct scsi_cmnd *scmnd)
@@ -1176,12 +1181,13 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 	request_size = sizeof(struct storvsc_cmd_request);
 
-	cmd_request = kmem_cache_zalloc(host_dev->request_pool,
+	cmd_request = mempool_alloc(host_dev->request_mempool,
 				       GFP_ATOMIC);
 	if (!cmd_request) {
 		scmnd->scsi_done = NULL;
 		return SCSI_MLQUEUE_DEVICE_BUSY;
 	}
+	memset(cmd_request, 0, sizeof(struct storvsc_cmd_request));
 
 	/* Setup the cmd request */
 	cmd_request->bounce_sgl_count = 0;
@@ -1235,8 +1241,8 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 			if (!cmd_request->bounce_sgl) {
 				scmnd->scsi_done = NULL;
 				scmnd->host_scribble = NULL;
-				kmem_cache_free(host_dev->request_pool,
-						cmd_request);
+				mempool_free(cmd_request,
+						host_dev->request_mempool);
 
 				return SCSI_MLQUEUE_HOST_BUSY;
 			}
@@ -1278,7 +1284,7 @@ retry_request:
 			destroy_bounce_buffer(cmd_request->bounce_sgl,
 					cmd_request->bounce_sgl_count);
 
-		kmem_cache_free(host_dev->request_pool, cmd_request);
+		mempool_free(cmd_request, host_dev->request_mempool);
 
 		scmnd->scsi_done = NULL;
 		scmnd->host_scribble = NULL;
@@ -1348,6 +1354,7 @@ static int storvsc_probe(struct hv_device *device,
 			const struct hv_vmbus_device_id *dev_id)
 {
 	int ret;
+	int number = STORVSC_MIN_BUF_NR;
 	struct Scsi_Host *host;
 	struct hv_host_device *host_dev;
 	bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
@@ -1376,8 +1383,19 @@ static int storvsc_probe(struct hv_device *device,
 		return -ENOMEM;
 	}
 
+	host_dev->request_mempool = mempool_create(number, mempool_alloc_slab,
+						mempool_free_slab,
+						host_dev->request_pool);
+
+	if (!host_dev->request_mempool) {
+		kmem_cache_destroy(host_dev->request_pool);
+		scsi_host_put(host);
+		return -ENOMEM;
+	}
+
 	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
 	if (!stor_device) {
+		mempool_destroy(host_dev->request_mempool);
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
 		return -ENOMEM;
@@ -1392,6 +1410,7 @@ static int storvsc_probe(struct hv_device *device,
 	stor_device->port_number = host->host_no;
 	ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
 	if (ret) {
+		mempool_destroy(host_dev->request_mempool);
 		kmem_cache_destroy(host_dev->request_pool);
 		scsi_host_put(host);
 		kfree(stor_device);
@@ -1431,6 +1450,7 @@ static int storvsc_probe(struct hv_device *device,
 
 err_out:
 	storvsc_dev_remove(device);
+	mempool_destroy(host_dev->request_mempool);
 	kmem_cache_destroy(host_dev->request_pool);
 	scsi_host_put(host);
 	return -ENODEV;
-- 
1.7.4.1

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

* [PATCH 02/11] Staging: hv: storvsc: Cleanup error handling in the probe function
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 03/11] Staging: hv: storvsc: Fixup the error when processing SET_WINDOW command K. Y. Srinivasan
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan, Haiyang Zhang

Cleanup error handling in the probe function.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 6a255e9..a72cc22 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1388,17 +1388,14 @@ static int storvsc_probe(struct hv_device *device,
 						host_dev->request_pool);
 
 	if (!host_dev->request_mempool) {
-		kmem_cache_destroy(host_dev->request_pool);
-		scsi_host_put(host);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_out0;
 	}
 
 	stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
 	if (!stor_device) {
-		mempool_destroy(host_dev->request_mempool);
-		kmem_cache_destroy(host_dev->request_pool);
-		scsi_host_put(host);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_out1;
 	}
 
 	stor_device->destroy = false;
@@ -1409,13 +1406,8 @@ static int storvsc_probe(struct hv_device *device,
 
 	stor_device->port_number = host->host_no;
 	ret = storvsc_connect_to_vsp(device, storvsc_ringbuffer_size);
-	if (ret) {
-		mempool_destroy(host_dev->request_mempool);
-		kmem_cache_destroy(host_dev->request_pool);
-		scsi_host_put(host);
-		kfree(stor_device);
-		return ret;
-	}
+	if (ret)
+		goto err_out2;
 
 	if (dev_is_ide)
 		storvsc_get_ide_info(device, &target, &path);
@@ -1435,7 +1427,7 @@ static int storvsc_probe(struct hv_device *device,
 	/* Register the HBA and start the scsi bus scan */
 	ret = scsi_add_host(host, &device->device);
 	if (ret != 0)
-		goto err_out;
+		goto err_out3;
 
 	if (!dev_is_ide) {
 		scsi_scan_host(host);
@@ -1444,16 +1436,30 @@ static int storvsc_probe(struct hv_device *device,
 	ret = scsi_add_device(host, 0, target, 0);
 	if (ret) {
 		scsi_remove_host(host);
-		goto err_out;
+		goto err_out3;
 	}
 	return 0;
 
-err_out:
+err_out3:
+	/*
+	 * Once we have connected with the host, we would need to
+	 * to invoke storvsc_dev_remove() to rollback this state and
+	 * this call also frees up the stor_device; hence the jump around
+	 * err_out2 label.
+	 */
 	storvsc_dev_remove(device);
+	goto err_out1;
+
+err_out2:
+	kfree(stor_device);
+
+err_out1:
 	mempool_destroy(host_dev->request_mempool);
+
+err_out0:
 	kmem_cache_destroy(host_dev->request_pool);
 	scsi_host_put(host);
-	return -ENODEV;
+	return ret;
 }
 
 /* The one and only one */
-- 
1.7.4.1

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

* [PATCH 03/11] Staging: hv: storvsc: Fixup the error when processing SET_WINDOW command
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 02/11] Staging: hv: storvsc: Cleanup error handling in the probe function K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 04/11] Staging: hv: storvsc: Fix error handling storvsc_host_reset() K. Y. Srinivasan
                     ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: Haiyang Zhang

Fixup the error when processing SET_WINDOW command.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index a72cc22..e16c7a3 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1136,7 +1136,7 @@ static bool storvsc_check_scsi_cmd(struct scsi_cmnd *scmnd)
 	switch (scsi_op) {
 	/* smartd sends this command, which will offline the device */
 	case SET_WINDOW:
-		scmnd->result = DID_ERROR << 16;
+		scmnd->result = ILLEGAL_REQUEST << 16;
 		allowed = false;
 		break;
 	default:
-- 
1.7.4.1

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

* [PATCH 04/11] Staging: hv: storvsc: Fix error handling storvsc_host_reset()
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 02/11] Staging: hv: storvsc: Cleanup error handling in the probe function K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 03/11] Staging: hv: storvsc: Fixup the error when processing SET_WINDOW command K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 05/11] Staging: hv: storvsc: Use the accessor function shost_priv() K. Y. Srinivasan
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: Haiyang Zhang

Fix error handling storvsc_host_reset(). I would like to thank
Long Li <longli@microsoft.com> for reporting this.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reported-by: Long Li <longli@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index e16c7a3..a145245 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1019,7 +1019,7 @@ static int storvsc_host_reset(struct hv_device *device)
 
 	stor_device = get_out_stor_device(device);
 	if (!stor_device)
-		return -ENODEV;
+		return FAILED;
 
 	request = &stor_device->reset_request;
 	vstor_packet = &request->vstor_packet;
@@ -1036,13 +1036,11 @@ static int storvsc_host_reset(struct hv_device *device)
 			       VM_PKT_DATA_INBAND,
 			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 	if (ret != 0)
-		goto cleanup;
+		return FAILED;
 
 	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
-	if (t == 0) {
-		ret = -ETIMEDOUT;
-		goto cleanup;
-	}
+	if (t == 0)
+		return TIMEOUT_ERROR;
 
 
 	/*
@@ -1050,8 +1048,7 @@ static int storvsc_host_reset(struct hv_device *device)
 	 * should have been flushed out and return to us
 	 */
 
-cleanup:
-	return ret;
+	return SUCCESS;
 }
 
 
@@ -1060,16 +1057,11 @@ cleanup:
  */
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 {
-	int ret;
 	struct hv_host_device *host_dev =
 		(struct hv_host_device *)scmnd->device->host->hostdata;
 	struct hv_device *dev = host_dev->dev;
 
-	ret = storvsc_host_reset(dev);
-	if (ret != 0)
-		return ret;
-
-	return ret;
+	return storvsc_host_reset(dev);
 }
 
 
-- 
1.7.4.1

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

* [PATCH 05/11] Staging: hv: storvsc: Use the accessor function shost_priv()
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (2 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 04/11] Staging: hv: storvsc: Fix error handling storvsc_host_reset() K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 06/11] Staging: hv: storvsc: Use the unlocked version queuecommand K. Y. Srinivasan
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: Haiyang Zhang

Use the accessor function shost_priv().

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index a145245..b21e85f 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -968,8 +968,7 @@ static int storvsc_remove(struct hv_device *dev)
 {
 	struct storvsc_device *stor_device = hv_get_drvdata(dev);
 	struct Scsi_Host *host = stor_device->host;
-	struct hv_host_device *host_dev =
-			(struct hv_host_device *)host->hostdata;
+	struct hv_host_device *host_dev = shost_priv(host);
 
 	scsi_remove_host(host);
 
@@ -1057,8 +1056,7 @@ static int storvsc_host_reset(struct hv_device *device)
  */
 static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 {
-	struct hv_host_device *host_dev =
-		(struct hv_host_device *)scmnd->device->host->hostdata;
+	struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
 	struct hv_device *dev = host_dev->dev;
 
 	return storvsc_host_reset(dev);
@@ -1073,8 +1071,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
 	struct storvsc_cmd_request *cmd_request =
 		(struct storvsc_cmd_request *)request->context;
 	struct scsi_cmnd *scmnd = cmd_request->cmd;
-	struct hv_host_device *host_dev =
-		(struct hv_host_device *)scmnd->device->host->hostdata;
+	struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
 	void (*scsi_done_fn)(struct scsi_cmnd *);
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
@@ -1144,8 +1141,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				void (*done)(struct scsi_cmnd *))
 {
 	int ret;
-	struct hv_host_device *host_dev =
-		(struct hv_host_device *)scmnd->device->host->hostdata;
+	struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
 	struct hv_device *dev = host_dev->dev;
 	struct hv_storvsc_request *request;
 	struct storvsc_cmd_request *cmd_request;
@@ -1359,7 +1355,7 @@ static int storvsc_probe(struct hv_device *device,
 	if (!host)
 		return -ENOMEM;
 
-	host_dev = (struct hv_host_device *)host->hostdata;
+	host_dev = shost_priv(host);
 	memset(host_dev, 0, sizeof(struct hv_host_device));
 
 	host_dev->port = host->host_no;
-- 
1.7.4.1

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

* [PATCH 06/11] Staging: hv: storvsc: Use the unlocked version queuecommand
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (3 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 05/11] Staging: hv: storvsc: Use the accessor function shost_priv() K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 07/11] Staging: hv: storvsc: use the macro KBUILD_MODNAME K. Y. Srinivasan
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the unlocked version queuecommand.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index b21e85f..827bc68 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1137,11 +1137,10 @@ static bool storvsc_check_scsi_cmd(struct scsi_cmnd *scmnd)
 /*
  * storvsc_queuecommand - Initiate command processing
  */
-static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
-				void (*done)(struct scsi_cmnd *))
+static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
 {
 	int ret;
-	struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
+	struct hv_host_device *host_dev = shost_priv(host);
 	struct hv_device *dev = host_dev->dev;
 	struct hv_storvsc_request *request;
 	struct storvsc_cmd_request *cmd_request;
@@ -1152,7 +1151,7 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 	struct vmscsi_request *vm_srb;
 
 	if (storvsc_check_scsi_cmd(scmnd) == false) {
-		done(scmnd);
+		scmnd->scsi_done(scmnd);
 		return 0;
 	}
 
@@ -1165,16 +1164,13 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 		goto retry_request;
 	}
 
-	scmnd->scsi_done = done;
-
 	request_size = sizeof(struct storvsc_cmd_request);
 
 	cmd_request = mempool_alloc(host_dev->request_mempool,
 				       GFP_ATOMIC);
-	if (!cmd_request) {
-		scmnd->scsi_done = NULL;
+	if (!cmd_request)
 		return SCSI_MLQUEUE_DEVICE_BUSY;
-	}
+
 	memset(cmd_request, 0, sizeof(struct storvsc_cmd_request));
 
 	/* Setup the cmd request */
@@ -1227,7 +1223,6 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 				create_bounce_buffer(sgl, scsi_sg_count(scmnd),
 						     scsi_bufflen(scmnd));
 			if (!cmd_request->bounce_sgl) {
-				scmnd->scsi_done = NULL;
 				scmnd->host_scribble = NULL;
 				mempool_free(cmd_request,
 						host_dev->request_mempool);
@@ -1274,7 +1269,6 @@ retry_request:
 
 		mempool_free(cmd_request, host_dev->request_mempool);
 
-		scmnd->scsi_done = NULL;
 		scmnd->host_scribble = NULL;
 
 		ret = SCSI_MLQUEUE_DEVICE_BUSY;
@@ -1283,9 +1277,6 @@ retry_request:
 	return ret;
 }
 
-static DEF_SCSI_QCMD(storvsc_queuecommand)
-
-
 /* Scsi driver */
 static struct scsi_host_template scsi_driver = {
 	.module	=		THIS_MODULE,
-- 
1.7.4.1

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

* [PATCH 07/11] Staging: hv: storvsc: use the macro KBUILD_MODNAME
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (4 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 06/11] Staging: hv: storvsc: Use the unlocked version queuecommand K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 08/11] Staging: hv: storvsc: Get rid of an unnecessary forward declaration K. Y. Srinivasan
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan, Haiyang Zhang

Use the macro KBUILD_MODNAME.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 827bc68..916f5d0 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -1444,7 +1444,7 @@ err_out0:
 /* The one and only one */
 
 static struct hv_driver storvsc_drv = {
-	.name = "storvsc",
+	.name = KBUILD_MODNAME,
 	.id_table = id_table,
 	.probe = storvsc_probe,
 	.remove = storvsc_remove,
-- 
1.7.4.1

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

* [PATCH 08/11] Staging: hv: storvsc: Get rid of an unnecessary forward declaration
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (5 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 07/11] Staging: hv: storvsc: use the macro KBUILD_MODNAME K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 09/11] Staging: hv: storvsc: Upgrade the vmstor protocol version K. Y. Srinivasan
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan, Haiyang Zhang

Get rid of an unnecessary forward declaration.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 916f5d0..4cdb417 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -236,8 +236,6 @@ struct vstor_packet {
 #define STORVSC_MAX_CHANNELS				1
 #define STORVSC_MAX_CMD_LEN				16
 
-struct hv_storvsc_request;
-
 /* Matches Windows-end */
 enum storvsc_request_type {
 	WRITE_TYPE,
-- 
1.7.4.1

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

* [PATCH 09/11] Staging: hv: storvsc: Upgrade the vmstor protocol version
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (6 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 08/11] Staging: hv: storvsc: Get rid of an unnecessary forward declaration K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 10/11] Staging: hv: storvsc: Support hot add of scsi disks K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 11/11] Staging: hv: storvsc: Support hot-removing of scsi devices K. Y. Srinivasan
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: Haiyang Zhang

In preparation for supporting hot add/remove of scsi devices,
upgrade the vmstor protocol version.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/staging/hv/storvsc_drv.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 4cdb417..9153641 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -80,7 +80,7 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
 /* V1 Beta                    0.1 */
 /* V1 RC < 2008/1/31          1.0 */
 /* V1 RC > 2008/1/31          2.0 */
-#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
+#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(4, 2)
 
 
 
@@ -106,7 +106,8 @@ enum vstor_packet_operation {
 	VSTOR_OPERATION_END_INITIALIZATION	= 8,
 	VSTOR_OPERATION_QUERY_PROTOCOL_VERSION	= 9,
 	VSTOR_OPERATION_QUERY_PROPERTIES	= 10,
-	VSTOR_OPERATION_MAXIMUM			= 10
+	VSTOR_OPERATION_ENUMERATE_BUS		= 11,
+	VSTOR_OPERATION_MAXIMUM			= 11
 };
 
 /*
-- 
1.7.4.1

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

* [PATCH 10/11] Staging: hv: storvsc: Support hot add of scsi disks
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (7 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 09/11] Staging: hv: storvsc: Upgrade the vmstor protocol version K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  2011-11-08 17:01   ` [PATCH 11/11] Staging: hv: storvsc: Support hot-removing of scsi devices K. Y. Srinivasan
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: K. Y. Srinivasan, Haiyang Zhang

Support hot add of scsi disks.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 9153641..7c82d14 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -304,6 +304,30 @@ struct storvsc_cmd_request {
 	struct hv_storvsc_request request;
 };
 
+struct storvsc_scan_work {
+	struct work_struct work;
+	struct Scsi_Host *host;
+	uint lun;
+};
+
+static void storvsc_bus_scan(struct work_struct *work)
+{
+	struct storvsc_scan_work *wrk;
+	int id, order_id;
+
+	wrk = container_of(work, struct storvsc_scan_work, work);
+	for (id = 0; id < wrk->host->max_id; ++id) {
+		if (wrk->host->reverse_ordering)
+			order_id = wrk->host->max_id - id - 1;
+		else
+			order_id = id;
+
+		scsi_scan_target(&wrk->host->shost_gendev, 0,
+				order_id, SCAN_WILD_CARD, 1);
+	}
+	kfree(wrk);
+}
+
 static inline struct storvsc_device *get_out_stor_device(
 					struct hv_device *device)
 {
@@ -551,11 +575,25 @@ static void storvsc_on_receive(struct hv_device *device,
 			     struct vstor_packet *vstor_packet,
 			     struct hv_storvsc_request *request)
 {
+	struct storvsc_scan_work *work;
+	struct storvsc_device *stor_device;
+
 	switch (vstor_packet->operation) {
 	case VSTOR_OPERATION_COMPLETE_IO:
 		storvsc_on_io_completion(device, vstor_packet, request);
 		break;
+
 	case VSTOR_OPERATION_REMOVE_DEVICE:
+	case VSTOR_OPERATION_ENUMERATE_BUS:
+		stor_device = get_in_stor_device(device);
+		work = kmalloc(sizeof(struct storvsc_scan_work), GFP_ATOMIC);
+		if (!work)
+			return;
+
+		INIT_WORK(&work->work, storvsc_bus_scan);
+		work->host = stor_device->host;
+		schedule_work(&work->work);
+		break;
 
 	default:
 		break;
-- 
1.7.4.1

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

* [PATCH 11/11] Staging: hv: storvsc: Support hot-removing of scsi devices
  2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
                     ` (8 preceding siblings ...)
  2011-11-08 17:01   ` [PATCH 10/11] Staging: hv: storvsc: Support hot add of scsi disks K. Y. Srinivasan
@ 2011-11-08 17:01   ` K. Y. Srinivasan
  9 siblings, 0 replies; 14+ messages in thread
From: K. Y. Srinivasan @ 2011-11-08 17:01 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, virtualization, ohering,
	James.Bottomley, hch
  Cc: Haiyang Zhang

Support hot-removing of scsi devices.

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

diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 7c82d14..0245143 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -328,6 +328,27 @@ static void storvsc_bus_scan(struct work_struct *work)
 	kfree(wrk);
 }
 
+static void storvsc_remove_lun(struct work_struct *work)
+{
+	struct storvsc_scan_work *wrk;
+	struct scsi_device *sdev;
+
+	wrk = container_of(work, struct storvsc_scan_work, work);
+	if (!scsi_host_get(wrk->host))
+		goto done;
+
+	sdev = scsi_device_lookup(wrk->host, 0, 0, wrk->lun);
+
+	if (sdev) {
+		scsi_remove_device(sdev);
+		scsi_device_put(sdev);
+	}
+	scsi_host_put(wrk->host);
+
+done:
+	kfree(wrk);
+}
+
 static inline struct storvsc_device *get_out_stor_device(
 					struct hv_device *device)
 {
@@ -1112,6 +1133,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
 	void (*scsi_done_fn)(struct scsi_cmnd *);
 	struct scsi_sense_hdr sense_hdr;
 	struct vmscsi_request *vm_srb;
+	struct storvsc_scan_work *wrk;
 
 	vm_srb = &request->vstor_packet.vm_srb;
 	if (cmd_request->bounce_sgl_count) {
@@ -1134,6 +1156,29 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
 	else
 		scmnd->result = vm_srb->scsi_status;
 
+	/*
+	 * If the LUN is invalid; remove the device.
+	 */
+	if (vm_srb->srb_status == 0x20) {
+		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))
-- 
1.7.4.1

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

end of thread, other threads:[~2011-11-08 17:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 17:01 [PATCH 0000/0011] Staging: hv: storvsc cleanup/new features K. Y. Srinivasan
2011-11-08 16:39 ` James Bottomley
2011-11-08 16:46   ` KY Srinivasan
2011-11-08 17:01 ` [PATCH 01/11] Staging: hv: storvsc: Use mempools to allocate struct storvsc_cmd_request K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 02/11] Staging: hv: storvsc: Cleanup error handling in the probe function K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 03/11] Staging: hv: storvsc: Fixup the error when processing SET_WINDOW command K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 04/11] Staging: hv: storvsc: Fix error handling storvsc_host_reset() K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 05/11] Staging: hv: storvsc: Use the accessor function shost_priv() K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 06/11] Staging: hv: storvsc: Use the unlocked version queuecommand K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 07/11] Staging: hv: storvsc: use the macro KBUILD_MODNAME K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 08/11] Staging: hv: storvsc: Get rid of an unnecessary forward declaration K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 09/11] Staging: hv: storvsc: Upgrade the vmstor protocol version K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 10/11] Staging: hv: storvsc: Support hot add of scsi disks K. Y. Srinivasan
2011-11-08 17:01   ` [PATCH 11/11] Staging: hv: storvsc: Support hot-removing of scsi devices 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).