Re: [PATCH] SCSI:STORVSC Use SCSI layer to allocate memory for per-command device request data

2015-03-10 Thread Olaf Hering
On Mon, Dec 29, Christoph Hellwig wrote:

 +++ b/drivers/scsi/storvsc_drv.c

  static struct scsi_host_template scsi_driver = {
   .module =   THIS_MODULE,
   .name = storvsc_host_t,
 + .cmd_size = sizeof(struct storvsc_cmd_request),
   .bios_param =   storvsc_get_chs,
   .queuecommand = storvsc_queuecommand,
   .eh_host_reset_handler =storvsc_host_reset_handler,
 + .proc_name =storvsc_host,

It would be nice to change .proc_name to KBUILD_MODNAME before v4.0 is
released. We carry a patch which adds this field. Of cource we can just
change the patch, but if code gets touched upstream anyway...


Olaf
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] SCSI:STORVSC Use SCSI layer to allocate memory for per-command device request data

2015-03-10 Thread Christoph Hellwig
On Tue, Mar 10, 2015 at 12:42:33PM +0100, Olaf Hering wrote:
 It would be nice to change .proc_name to KBUILD_MODNAME before v4.0 is
 released. We carry a patch which adds this field. Of cource we can just
 change the patch, but if code gets touched upstream anyway...

Please send a patch.  Would be nice if you had sent it long go insted of just
including it in a vendor tree..
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] SCSI:STORVSC Use SCSI layer to allocate memory for per-command device request data

2015-03-10 Thread Olaf Hering
On Tue, Mar 10, Christoph Hellwig wrote:

 On Tue, Mar 10, 2015 at 12:42:33PM +0100, Olaf Hering wrote:
  It would be nice to change .proc_name to KBUILD_MODNAME before v4.0 is
  released. We carry a patch which adds this field. Of cource we can just
  change the patch, but if code gets touched upstream anyway...
 
 Please send a patch.  Would be nice if you had sent it long go insted of just
 including it in a vendor tree..

I was told .procname was dead, but since the patch adds it anyway it
should have a content thats in use (by us).

Olaf
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] SCSI:STORVSC Use SCSI layer to allocate memory for per-command device request data

2014-12-29 Thread Christoph Hellwig
STORVSC uses its own momory pool to manage device request data. However, SCSI 
layer already has a mechanisim for allocating additional memory for each 
command issued to device driver. This patch removes the memory pool in STORVSC 
and makes it use SCSI layer to allocate memory for device request data.

Reviewed-by: Long Li lon...@microsoft.com
Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/scsi/storvsc_drv.c | 119 +++--
 1 file changed, 8 insertions(+), 111 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 4cff0dd..14ee98e 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -32,7 +32,6 @@
 #include linux/module.h
 #include linux/device.h
 #include linux/hyperv.h
-#include linux/mempool.h
 #include linux/blkdev.h
 #include scsi/scsi.h
 #include scsi/scsi_cmnd.h
@@ -309,14 +308,6 @@ enum storvsc_request_type {
  * This is the end of Protocol specific defines.
  */
 
-
-/*
- * We setup a mempool to allocate request structures for this driver
- * on a per-lun basis. The following define specifies the number of
- * elements in the pool.
- */
-
-#define STORVSC_MIN_BUF_NR 64
 static int storvsc_ringbuffer_size = (20 * PAGE_SIZE);
 
 module_param(storvsc_ringbuffer_size, int, S_IRUGO);
@@ -346,7 +337,6 @@ static void storvsc_on_channel_callback(void *context);
 #define STORVSC_IDE_MAX_CHANNELS   1
 
 struct storvsc_cmd_request {
-   struct list_head entry;
struct scsi_cmnd *cmd;
 
unsigned int bounce_sgl_count;
@@ -357,7 +347,6 @@ struct storvsc_cmd_request {
/* Synchronize the request/response if needed */
struct completion wait_event;
 
-   unsigned char *sense_buffer;
struct hv_multipage_buffer data_buffer;
struct vstor_packet vstor_packet;
 };
@@ -389,11 +378,6 @@ struct storvsc_device {
struct storvsc_cmd_request reset_request;
 };
 
-struct stor_mem_pools {
-   struct kmem_cache *request_pool;
-   mempool_t *request_mempool;
-};
-
 struct hv_host_device {
struct hv_device *dev;
unsigned int port;
@@ -1070,10 +1054,8 @@ static void storvsc_command_completion(struct 
storvsc_cmd_request *cmd_request)
 {
struct scsi_cmnd *scmnd = cmd_request-cmd;
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;
-   struct stor_mem_pools *memp = scmnd-device-hostdata;
struct Scsi_Host *host;
struct storvsc_device *stor_dev;
struct hv_device *dev = host_dev-dev;
@@ -1109,14 +1091,7 @@ static void storvsc_command_completion(struct 
storvsc_cmd_request *cmd_request)
cmd_request-data_buffer.len -
vm_srb-data_transfer_length);
 
-   scsi_done_fn = scmnd-scsi_done;
-
-   scmnd-host_scribble = NULL;
-   scmnd-scsi_done = NULL;
-
-   scsi_done_fn(scmnd);
-
-   mempool_free(cmd_request, memp-request_mempool);
+   scmnd-scsi_done(scmnd);
 }
 
 static void storvsc_on_io_completion(struct hv_device *device,
@@ -1160,7 +1135,7 @@ static void storvsc_on_io_completion(struct hv_device 
*device,
SRB_STATUS_AUTOSENSE_VALID) {
/* autosense data available */
 
-   memcpy(request-sense_buffer,
+   memcpy(request-cmd-sense_buffer,
   vstor_packet-vm_srb.sense_data,
   vstor_packet-vm_srb.sense_info_length);
 
@@ -1378,55 +1353,6 @@ static int storvsc_do_io(struct hv_device *device,
return ret;
 }
 
-static int storvsc_device_alloc(struct scsi_device *sdevice)
-{
-   struct stor_mem_pools *memp;
-   int number = STORVSC_MIN_BUF_NR;
-
-   memp = kzalloc(sizeof(struct stor_mem_pools), GFP_KERNEL);
-   if (!memp)
-   return -ENOMEM;
-
-   memp-request_pool =
-   kmem_cache_create(dev_name(sdevice-sdev_dev),
-   sizeof(struct storvsc_cmd_request), 0,
-   SLAB_HWCACHE_ALIGN, NULL);
-
-   if (!memp-request_pool)
-   goto err0;
-
-   memp-request_mempool = mempool_create(number, mempool_alloc_slab,
-   mempool_free_slab,
-   memp-request_pool);
-
-   if (!memp-request_mempool)
-   goto err1;
-
-   sdevice-hostdata = memp;
-
-   return 0;
-
-err1:
-   kmem_cache_destroy(memp-request_pool);
-
-err0:
-   kfree(memp);
-   return -ENOMEM;
-}
-
-static void storvsc_device_destroy(struct scsi_device *sdevice)
-{
-   struct stor_mem_pools *memp = sdevice-hostdata;
-
-   if (!memp)
-   return;
-
-   mempool_destroy(memp-request_mempool);
-   

RE: [PATCH] SCSI:STORVSC Use SCSI layer to allocate memory for per-command device request data

2014-12-29 Thread KY Srinivasan


 -Original Message-
 From: Christoph Hellwig [mailto:h...@lst.de]
 Sent: Monday, December 29, 2014 8:05 PM
 To: KY Srinivasan; Haiyang Zhang; jbottom...@parallels.com
 Cc: linux-s...@vger.kernel.org; de...@linuxdriverproject.org; linux-
 ker...@vger.kernel.org; Long Li; Christoph Hellwig
 Subject: [PATCH] SCSI:STORVSC Use SCSI layer to allocate memory for per-
 command device request data
 
 STORVSC uses its own momory pool to manage device request data.
 However, SCSI layer already has a mechanisim for allocating additional
 memory for each command issued to device driver. This patch removes the
 memory pool in STORVSC and makes it use SCSI layer to allocate memory for
 device request data.
 
 Reviewed-by: Long Li lon...@microsoft.com
 Signed-off-by: Christoph Hellwig h...@lst.de

Thanks Christoph.
Signed-off-by: K. Y. Srinivasan k...@microsoft.com

 ---
  drivers/scsi/storvsc_drv.c | 119 
 +++--
  1 file changed, 8 insertions(+), 111 deletions(-)
 
 diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index
 4cff0dd..14ee98e 100644
 --- a/drivers/scsi/storvsc_drv.c
 +++ b/drivers/scsi/storvsc_drv.c
 @@ -32,7 +32,6 @@
  #include linux/module.h
  #include linux/device.h
  #include linux/hyperv.h
 -#include linux/mempool.h
  #include linux/blkdev.h
  #include scsi/scsi.h
  #include scsi/scsi_cmnd.h
 @@ -309,14 +308,6 @@ enum storvsc_request_type {
   * This is the end of Protocol specific defines.
   */
 
 -
 -/*
 - * We setup a mempool to allocate request structures for this driver
 - * on a per-lun basis. The following define specifies the number of
 - * elements in the pool.
 - */
 -
 -#define STORVSC_MIN_BUF_NR   64
  static int storvsc_ringbuffer_size = (20 * PAGE_SIZE);
 
  module_param(storvsc_ringbuffer_size, int, S_IRUGO); @@ -346,7 +337,6
 @@ static void storvsc_on_channel_callback(void *context);
  #define STORVSC_IDE_MAX_CHANNELS 1
 
  struct storvsc_cmd_request {
 - struct list_head entry;
   struct scsi_cmnd *cmd;
 
   unsigned int bounce_sgl_count;
 @@ -357,7 +347,6 @@ struct storvsc_cmd_request {
   /* Synchronize the request/response if needed */
   struct completion wait_event;
 
 - unsigned char *sense_buffer;
   struct hv_multipage_buffer data_buffer;
   struct vstor_packet vstor_packet;
  };
 @@ -389,11 +378,6 @@ struct storvsc_device {
   struct storvsc_cmd_request reset_request;  };
 
 -struct stor_mem_pools {
 - struct kmem_cache *request_pool;
 - mempool_t *request_mempool;
 -};
 -
  struct hv_host_device {
   struct hv_device *dev;
   unsigned int port;
 @@ -1070,10 +1054,8 @@ static void storvsc_command_completion(struct
 storvsc_cmd_request *cmd_request)  {
   struct scsi_cmnd *scmnd = cmd_request-cmd;
   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;
 - struct stor_mem_pools *memp = scmnd-device-hostdata;
   struct Scsi_Host *host;
   struct storvsc_device *stor_dev;
   struct hv_device *dev = host_dev-dev; @@ -1109,14 +1091,7 @@
 static void storvsc_command_completion(struct storvsc_cmd_request
 *cmd_request)
   cmd_request-data_buffer.len -
   vm_srb-data_transfer_length);
 
 - scsi_done_fn = scmnd-scsi_done;
 -
 - scmnd-host_scribble = NULL;
 - scmnd-scsi_done = NULL;
 -
 - scsi_done_fn(scmnd);
 -
 - mempool_free(cmd_request, memp-request_mempool);
 + scmnd-scsi_done(scmnd);
  }
 
  static void storvsc_on_io_completion(struct hv_device *device, @@ -1160,7
 +1135,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
   SRB_STATUS_AUTOSENSE_VALID) {
   /* autosense data available */
 
 - memcpy(request-sense_buffer,
 + memcpy(request-cmd-sense_buffer,
  vstor_packet-vm_srb.sense_data,
  vstor_packet-vm_srb.sense_info_length);
 
 @@ -1378,55 +1353,6 @@ static int storvsc_do_io(struct hv_device *device,
   return ret;
  }
 
 -static int storvsc_device_alloc(struct scsi_device *sdevice) -{
 - struct stor_mem_pools *memp;
 - int number = STORVSC_MIN_BUF_NR;
 -
 - memp = kzalloc(sizeof(struct stor_mem_pools), GFP_KERNEL);
 - if (!memp)
 - return -ENOMEM;
 -
 - memp-request_pool =
 - kmem_cache_create(dev_name(sdevice-sdev_dev),
 - sizeof(struct storvsc_cmd_request), 0,
 - SLAB_HWCACHE_ALIGN, NULL);
 -
 - if (!memp-request_pool)
 - goto err0;
 -
 - memp-request_mempool = mempool_create(number,
 mempool_alloc_slab,
 - mempool_free_slab,
 - memp