Re: [PATCH v2] scsi: be2iscsi: Use kasprintf

2017-10-11 Thread Kyle Fortin
On Oct 11, 2017, at 11:36 AM, Himanshu Jha <himanshujha199...@gmail.com> wrote:
> 
> Use kasprintf instead of combination of kmalloc and sprintf.
> Also, remove BEISCSI_MSI_NAME macro used to specify size of string as
> kasprintf handles size computations.
> 
> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> ---
> v2:
>   -remove the unnecessary macro BEISCSI_MSI_NAME. 
> 
> drivers/scsi/be2iscsi/be_main.c | 12 +---
> drivers/scsi/be2iscsi/be_main.h |  2 --
> 2 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index b4542e7..6a9ee0e 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> 
>   if (pcidev->msix_enabled) {
>   for (i = 0; i < phba->num_cpus; i++) {
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> - GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL,
> +   "beiscsi_%02x_%02x",
> +   phba->shost->host_no, i);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> 
> - sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> - phba->shost->host_no, i);
>   ret = request_irq(pci_irq_vector(pcidev, i),
> be_isr_msix, 0, phba->msi_name[i],
> _context->be_eq[i]);
> @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
>   goto free_msix_irqs;
>   }
>   }
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
> +   phba->shost->host_no);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> - sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> - phba->shost->host_no);
>   ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
> phba->msi_name[i], _context->be_eq[i]);
>   if (ret) {
> diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
> index 81ce3ff..8166de5 100644
> --- a/drivers/scsi/be2iscsi/be_main.h
> +++ b/drivers/scsi/be2iscsi/be_main.h
> @@ -155,8 +155,6 @@
> #define PAGES_REQUIRED(x) \
>   ((x < PAGE_SIZE) ? 1 :  ((x + PAGE_SIZE - 1) / PAGE_SIZE))
> 
> -#define BEISCSI_MSI_NAME 20 /* size of msi_name string */
> -
> #define MEM_DESCR_OFFSET 8
> #define BEISCSI_DEFQ_HDR 1
> #define BEISCSI_DEFQ_DATA 0
> -- 
> 2.7.4
> 

Looks good.

Reviewed-by: Kyle Fortin <kyle.for...@oracle.com>



Re: [PATCH v2] scsi: logging: update description of logging_level bits

2017-10-11 Thread Kyle Fortin
Looks good.

Reviewed-by: Kyle Fortin <kyle.for...@oracle.com>


Re: [PATCH] scsi: be2iscsi: Use kasprintf

2017-10-10 Thread Kyle Fortin
Hi Himanshu,

On Oct 6, 2017, at 2:57 PM, Himanshu Jha <himanshujha199...@gmail.com> wrote:
> 
> Use kasprintf instead of combination of kmalloc and sprintf.
> 
> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> ---
> drivers/scsi/be2iscsi/be_main.c | 12 +---
> 1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index b4542e7..6a9ee0e 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -803,15 +803,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
> 
>   if (pcidev->msix_enabled) {
>   for (i = 0; i < phba->num_cpus; i++) {
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
> - GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL,
> +   "beiscsi_%02x_%02x",
> +   phba->shost->host_no, i);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> 
> - sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
> - phba->shost->host_no, i);
>   ret = request_irq(pci_irq_vector(pcidev, i),
> be_isr_msix, 0, phba->msi_name[i],
> _context->be_eq[i]);
> @@ -824,13 +823,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
>   goto free_msix_irqs;
>   }
>   }
> - phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
> + phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
> +   phba->shost->host_no);
>   if (!phba->msi_name[i]) {
>   ret = -ENOMEM;
>   goto free_msix_irqs;
>   }
> - sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
> - phba->shost->host_no);
>   ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
>     phba->msi_name[i], _context->be_eq[i]);
>   if (ret) {
> -- 
> 2.7.4

Since you are getting rid of the only use for BEISCSI_MSI_NAME within 
drivers/scsi/be2iscsi/be_main.h, that should be removed too.

--
Kyle Fortin - Oracle Linux Engineering






Re: [PATCH] scsi: logging_level: update bits description

2017-10-10 Thread Kyle Fortin
Hi Randy,

On Oct 10, 2017, at 3:05 PM, Randy Dunlap <rdun...@infradead.org> wrote:
> 
> From: Randy Dunlap <rdun...@infradead.org>
> 
> Update the description of 'scsi_logging_level' from 8 4-bit nibbles
> to the (pre-git) reality of 10 3-bit 'nibbles'.
> 
> Signed-off-by: Randy Dunlap <rdun...@infradead.org>
> ---
> drivers/scsi/scsi_logging.h |8 
> 1 file changed, 4 insertions(+), 4 deletions(-)
> 
> --- lnx-414-rc3.orig/drivers/scsi/scsi_logging.h
> +++ lnx-414-rc3/drivers/scsi/scsi_logging.h
> @@ -3,10 +3,10 @@
> 
> 
> /*
> - * This defines the scsi logging feature.  It is a means by which the user
> - * can select how much information they get about various goings on, and it
> - * can be really useful for fault tracing.  The logging word is divided into
> - * 8 nibbles, each of which describes a loglevel.  The division of things is
> + * This defines the scsi logging feature.  It is a means by which the user 
> can
> + * select how much information they get about various goings on, and it can 
> be
> + * really useful for fault tracing.  The logging word is divided into 10 
> 3-bit
> + * 'nibbles', each of which describes a loglevel.  The division of things is

I think ‘bitfields' is more appropriate than ‘nibbles’ (a 4-bit construct in 
compute).

>  * somewhat arbitrary, and the division of the word could be changed if it
>  * were really needed for any reason.  The numbers below are the only place
>  * where these are specified.  For a first go-around, 3 bits is more than

Reviewed-by: Kyle Fortin <kyle.for...@oracle.com>






Re: [PATCH] vmw_pvscsi: Don't call free_irq twice on remove adapter

2017-10-05 Thread Kyle Fortin
Correction.

On Oct 5, 2017, at 1:55 PM, Kyle Fortin <kyle.for...@oracle.com> wrote:
> 
> Hi Jim,
> 
> On Oct 4, 2017, at 3:03 PM, Jim Gill <jg...@vmware.com> wrote:
>> 
>> Remove redundant call to pvscsi_shutdown_intr from
>> pvscsi_remove_resources.  Add calls to pvscsi_shutdown_intr
>> in the failure cases for pvscsi_probe.
>> 
>> Signed-off-by: Jim Gill <jg...@vmware.com>
>> ---
>> drivers/scsi/vmw_pvscsi.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
>> index c374e3b..c7e74ac 100644
>> --- a/drivers/scsi/vmw_pvscsi.c
>> +++ b/drivers/scsi/vmw_pvscsi.c
>> @@ -1197,8 +1197,6 @@ static void pvscsi_shutdown_intr(struct pvscsi_adapter 
>> *adapter)
>> 
>> static void pvscsi_release_resources(struct pvscsi_adapter *adapter)
>> {
>> -pvscsi_shutdown_intr(adapter);
>> -
>>  if (adapter->workqueue)
>>  destroy_workqueue(adapter->workqueue);
>> 
>> @@ -1530,6 +1528,7 @@ static int pvscsi_probe(struct pci_dev *pdev, const 
>> struct pci_device_id *id)
>> out_reset_adapter:
> 
> From what I understand the irq(s) are not allocated until the 
> pci_alloc_irq_vectors call.  After, all breakout jumps are to 
> out_reset_adapter.
> 
> Could it be simplified to just adding pvscsi_shutdown_intr before 
> ll_adapter_reset() here?  Then you don’t need the other two 
> pvscsi_shutdown_intr() calls below.

Add pvscsi_shutdown_intr after adapter reset instead.

>>  ll_adapter_reset(adapter);
>> out_release_resources:
>> +pvscsi_shutdown_intr(adapter);
>>  pvscsi_release_resources(adapter);
>>  scsi_host_put(host);
>> out_disable_device:
>> @@ -1538,6 +1537,7 @@ static int pvscsi_probe(struct pci_dev *pdev, const 
>> struct pci_device_id *id)
>>  return error;
>> 
>> out_release_resources_and_disable:
>> +pvscsi_shutdown_intr(adapter);
>>  pvscsi_release_resources(adapter);
>>  goto out_disable_device;
>> }
>> -- 
>> 2.7.4
> 
> --
> Kyle Fortin - Oracle Linux Engineering




Re: [PATCH] vmw_pvscsi: Don't call free_irq twice on remove adapter

2017-10-05 Thread Kyle Fortin
Hi Jim,

On Oct 4, 2017, at 3:03 PM, Jim Gill <jg...@vmware.com> wrote:
> 
> Remove redundant call to pvscsi_shutdown_intr from
> pvscsi_remove_resources.  Add calls to pvscsi_shutdown_intr
> in the failure cases for pvscsi_probe.
> 
> Signed-off-by: Jim Gill <jg...@vmware.com>
> ---
> drivers/scsi/vmw_pvscsi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
> index c374e3b..c7e74ac 100644
> --- a/drivers/scsi/vmw_pvscsi.c
> +++ b/drivers/scsi/vmw_pvscsi.c
> @@ -1197,8 +1197,6 @@ static void pvscsi_shutdown_intr(struct pvscsi_adapter 
> *adapter)
> 
> static void pvscsi_release_resources(struct pvscsi_adapter *adapter)
> {
> - pvscsi_shutdown_intr(adapter);
> -
>   if (adapter->workqueue)
>   destroy_workqueue(adapter->workqueue);
> 
> @@ -1530,6 +1528,7 @@ static int pvscsi_probe(struct pci_dev *pdev, const 
> struct pci_device_id *id)
> out_reset_adapter:

>From what I understand the irq(s) are not allocated until the 
>pci_alloc_irq_vectors call.  After, all breakout jumps are to 
>out_reset_adapter.

Could it be simplified to just adding pvscsi_shutdown_intr before 
ll_adapter_reset() here?  Then you don’t need the other two 
pvscsi_shutdown_intr() calls below.

>   ll_adapter_reset(adapter);
> out_release_resources:
> + pvscsi_shutdown_intr(adapter);
>   pvscsi_release_resources(adapter);
>   scsi_host_put(host);
> out_disable_device:
> @@ -1538,6 +1537,7 @@ static int pvscsi_probe(struct pci_dev *pdev, const 
> struct pci_device_id *id)
>   return error;
> 
> out_release_resources_and_disable:
> + pvscsi_shutdown_intr(adapter);
>   pvscsi_release_resources(adapter);
>   goto out_disable_device;
> }
> -- 
> 2.7.4

--
Kyle Fortin - Oracle Linux Engineering






Re: [PATCH] scsi: fixup kernel warning during rmmod()

2017-10-04 Thread Kyle Fortin
> On Oct 4, 2017, at 4:28 AM, Hannes Reinecke <h...@suse.de> wrote:
> 
> Signed-off-by: Hannes Reinecke <h...@suse.com>

Looks good to me.

Reviewed-by: Kyle Fortin <kyle.for...@oracle.com>

--
Kyle Fortin - Oracle Linux Engineering






[PATCH] scsi: libiscsi: use kvzalloc for iscsi_pool_init

2017-05-17 Thread Kyle Fortin
iscsiadm session login can fail with the following error:

iscsiadm: Could not login to [iface: default, target: iqn.1986-03.com...
iscsiadm: initiator reported error (9 - internal error)

When /etc/iscsi/iscsid.conf sets node.session.cmds_max = 4096, it results
in 64K-sized kmallocs per session.  A system under fragmented slab
pressure may not have any 64K objects available and fail iscsiadm session
login. Even though memory objects of a smaller size are available, the
large order allocation ends up failing.

The kernel prints a warning and does dump_stack, like below:

iscsid: page allocation failure: order:4, mode:0xc0d0
CPU: 0 PID: 2456 Comm: iscsid Not tainted 4.1.12-61.1.28.el6uek.x86_64 #2
Call Trace:
 [] dump_stack+0x63/0x83
 [] warn_alloc_failed+0xea/0x140
 [] __alloc_pages_slowpath+0x409/0x760
 [] __alloc_pages_nodemask+0x2b1/0x2d0
 [] ? dev_attr_host_ipaddress+0x20/0xc722
 [] alloc_pages_current+0xaf/0x170
 [] alloc_kmem_pages+0x31/0xd0
 [] ? iscsi_transport_group+0x20/0xc7e2
 [] kmalloc_order+0x18/0x50
 [] kmalloc_order_trace+0x34/0xe0
 [] ? transport_remove_classdev+0x70/0x70
 [] __kmalloc+0x27d/0x2a0
 [] ? complete_all+0x4d/0x60
 [] iscsi_pool_init+0x69/0x160 [libiscsi]
 [] ? device_initialize+0xb0/0xd0
 [] iscsi_session_setup+0x180/0x2f4 [libiscsi]
 [] ? iscsi_max_lun+0x20/0xfa9e [iscsi_tcp]
 [] iscsi_sw_tcp_session_create+0xcf/0x150 [iscsi_tcp]
 [] ? iscsi_max_lun+0x20/0xfa9e [iscsi_tcp]
 [] iscsi_if_create_session+0x33/0xd0
 [] ? iscsi_max_lun+0x20/0xfa9e [iscsi_tcp]
 [] iscsi_if_recv_msg+0x508/0x8c0 [scsi_transport_iscsi]
 [] ? __alloc_pages_nodemask+0x19b/0x2d0
 [] ? __kmalloc_node_track_caller+0x209/0x2c0
 [] iscsi_if_rx+0x7c/0x200 [scsi_transport_iscsi]
 [] netlink_unicast+0x126/0x1c0
 [] netlink_sendmsg+0x36c/0x400
 [] sock_sendmsg+0x4d/0x60
 [] ___sys_sendmsg+0x30a/0x330
 [] ? handle_pte_fault+0x20c/0x230
 [] ? __handle_mm_fault+0x1bc/0x330
 [] ? handle_mm_fault+0xb2/0x1a0
 [] __sys_sendmsg+0x49/0x90
 [] SyS_sendmsg+0x19/0x20
 [] system_call_fastpath+0x12/0x71

Use kvzalloc for iscsi_pool in iscsi_pool_init.

Signed-off-by: Kyle Fortin <kyle.for...@oracle.com>
Tested-by: Kyle Fortin <kyle.for...@oracle.com>
Reviewed-by: Joseph Slember <joe.slem...@oracle.com>
Reviewed-by: Lance Hartmann <lance.hartm...@oracle.com>
---
 drivers/scsi/libiscsi.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index dd6828f..42381ad 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2556,7 +2556,7 @@ int iscsi_eh_recover_target(struct scsi_cmnd *sc)
 * the array. */
if (items)
num_arrays++;
-   q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
+   q->pool = kvzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
if (q->pool == NULL)
return -ENOMEM;
 
@@ -2590,7 +2590,7 @@ void iscsi_pool_free(struct iscsi_pool *q)
 
for (i = 0; i < q->max; i++)
kfree(q->pool[i]);
-   kfree(q->pool);
+   kvfree(q->pool);
 }
 EXPORT_SYMBOL_GPL(iscsi_pool_free);
 
-- 
1.7.1



Re: [PATCH] libiscsi: use vzalloc for large allocations in iscsi_pool_init

2017-04-05 Thread Kyle Fortin
On Apr 3, 2017, at 3:46 PM, Chet L <chetanl...@gmail.com> wrote:
> 
> On Mon, Apr 3, 2017 at 6:30 AM, Kyle Fortin <kyle.for...@oracle.com> wrote:
> 
>> 
>>for (i = 0; i < q->max; i++)
>>kfree(q->pool[i]);
>> -   kfree(q->pool);
>> +   if (q->is_pool_vmalloc)
> 
> you could do something like:
> 
> if (is_vmalloc_addr(q->pool))
>vfree(...);
> else
>kfree(..);
> 
> And then remove the bool.
> 
> Chetan

Using linux-mmots.git which includes the new kvmalloc api, this patch is 
greatly simplified to a 2 character change (‘v’ x 2) of using kvmalloc / kvfree 
for the iscsi_pool allocation.  When kvmalloc is accepted into mainline and 
makes it into scsi.git, then I’ll post the v2 patch using that.

--
Kyle Fortin - Oracle Linux Engineering






Re: [PATCH] libiscsi: use vzalloc for large allocations in iscsi_pool_init

2017-04-03 Thread Kyle Fortin
On Apr 3, 2017, at 9:41 AM, Johannes Thumshirn <jthumsh...@suse.de> wrote:
> 
> On Mon, Apr 03, 2017 at 06:30:21AM -0700, Kyle Fortin wrote:
>> iscsiadm session login can fail with the following error:
>> 
>> iscsiadm: Could not login to [iface: default, target: iqn.1986-03.com...
>> iscsiadm: initiator reported error (9 - internal error)
>> 
>> When /etc/iscsi/iscsid.conf sets node.session.cmds_max = 4096, it results
>> in 64K-sized kmallocs per session.  A system under fragmented slab
>> pressure may not have any 64K objects available and fail iscsiadm session
>> login. Even though memory objects of a smaller size are available, the
>> large order allocation ends up failing.
>> 
>> The kernel will print a warning and dump_stack, like below:
> 
> There is a series of patches in Andrew's mmotm tree, which introduces
> a kvmalloc() function, that does exactly what you're looking for.
> 
> Maybe you want to base your patch on top of it.
> 
> -- 
> Johannes Thumshirn  Storage
> jthumsh...@suse.de+49 911 74053 689
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: Felix Imendörffer, Jane Smithard, Graham Norton
> HRB 21284 (AG Nürnberg)
> Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

Thanks Johannes.  I’ll take a look.
--
Kyle Fortin - Oracle Linux Engineering






[PATCH] libiscsi: use vzalloc for large allocations in iscsi_pool_init

2017-04-03 Thread Kyle Fortin
iscsiadm session login can fail with the following error:

iscsiadm: Could not login to [iface: default, target: iqn.1986-03.com...
iscsiadm: initiator reported error (9 - internal error)

When /etc/iscsi/iscsid.conf sets node.session.cmds_max = 4096, it results
in 64K-sized kmallocs per session.  A system under fragmented slab
pressure may not have any 64K objects available and fail iscsiadm session
login. Even though memory objects of a smaller size are available, the
large order allocation ends up failing.

The kernel will print a warning and dump_stack, like below:

iscsid: page allocation failure: order:4, mode:0xc0d0
CPU: 0 PID: 2456 Comm: iscsid Not tainted 4.1.12-61.1.28.el6uek.x86_64 #2
Call Trace:
 [] dump_stack+0x63/0x83
 [] warn_alloc_failed+0xea/0x140
 [] __alloc_pages_slowpath+0x409/0x760
 [] __alloc_pages_nodemask+0x2b1/0x2d0
 [] ? dev_attr_host_ipaddress+0x20/0xc722
 [] alloc_pages_current+0xaf/0x170
 [] alloc_kmem_pages+0x31/0xd0
 [] ? iscsi_transport_group+0x20/0xc7e2
 [] kmalloc_order+0x18/0x50
 [] kmalloc_order_trace+0x34/0xe0
 [] ? transport_remove_classdev+0x70/0x70
 [] __kmalloc+0x27d/0x2a0
 [] ? complete_all+0x4d/0x60
 [] iscsi_pool_init+0x69/0x160 [libiscsi]
 [] ? device_initialize+0xb0/0xd0
 [] iscsi_session_setup+0x180/0x2f4 [libiscsi]
 [] ? iscsi_max_lun+0x20/0xfa9e [iscsi_tcp]
 [] iscsi_sw_tcp_session_create+0xcf/0x150 [iscsi_tcp]
 [] ? iscsi_max_lun+0x20/0xfa9e [iscsi_tcp]
 [] iscsi_if_create_session+0x33/0xd0
 [] ? iscsi_max_lun+0x20/0xfa9e [iscsi_tcp]
 [] iscsi_if_recv_msg+0x508/0x8c0 [scsi_transport_iscsi]
 [] ? __alloc_pages_nodemask+0x19b/0x2d0
 [] ? __kmalloc_node_track_caller+0x209/0x2c0
 [] iscsi_if_rx+0x7c/0x200 [scsi_transport_iscsi]
 [] netlink_unicast+0x126/0x1c0
 [] netlink_sendmsg+0x36c/0x400
 [] sock_sendmsg+0x4d/0x60
 [] ___sys_sendmsg+0x30a/0x330
 [] ? handle_pte_fault+0x20c/0x230
 [] ? __handle_mm_fault+0x1bc/0x330
 [] ? handle_mm_fault+0xb2/0x1a0
 [] __sys_sendmsg+0x49/0x90
 [] SyS_sendmsg+0x19/0x20
 [] system_call_fastpath+0x12/0x71

Use vzalloc for iscsi_pool allocations larger than PAGE_SIZE.  This only
affects hosts using a non-standard larger /etc/iscsi/iscsid.conf
node.session.cmds_max value. Since iscsi_pool_init is also called to
allocate very small pools per cmd for r2t handling, it is best to retain
using kzalloc for those allocations.

Signed-off-by: Kyle Fortin <kyle.for...@oracle.com>
Tested-by: Kyle Fortin <kyle.for...@oracle.com>
Reviewed-by: Joseph Slember <joe.slem...@oracle.com>
Reviewed-by: Lance Hartmann <lance.hartm...@oracle.com>
---
 drivers/scsi/libiscsi.c | 15 +--
 include/scsi/libiscsi.h |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 3fca34a675af..5a622ba2f10d 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2546,6 +2547,7 @@ int iscsi_eh_recover_target(struct scsi_cmnd *sc)
 iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 {
int i, num_arrays = 1;
+   int alloc_size;
 
memset(q, 0, sizeof(*q));
 
@@ -2555,7 +2557,13 @@ int iscsi_eh_recover_target(struct scsi_cmnd *sc)
 * the array. */
if (items)
num_arrays++;
-   q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
+
+   alloc_size = num_arrays * max * sizeof(void *);
+   if (alloc_size > PAGE_SIZE) {
+   q->pool = vzalloc(alloc_size);
+   q->is_pool_vmalloc = true;
+   } else
+   q->pool = kzalloc(alloc_size, GFP_KERNEL);
if (q->pool == NULL)
return -ENOMEM;
 
@@ -2589,7 +2597,10 @@ void iscsi_pool_free(struct iscsi_pool *q)
 
for (i = 0; i < q->max; i++)
kfree(q->pool[i]);
-   kfree(q->pool);
+   if (q->is_pool_vmalloc)
+   vfree(q->pool);
+   else
+   kfree(q->pool);
 }
 EXPORT_SYMBOL_GPL(iscsi_pool_free);
 
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 583875ea136a..e3421e527559 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -258,6 +258,7 @@ struct iscsi_pool {
struct kfifoqueue;  /* FIFO Queue */
void**pool; /* Pool of elements */
int max;/* Max number of elements */
+   boolis_pool_vmalloc;
 };
 
 /* Session's states */
-- 
1.8.3.1