All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc()
@ 2019-03-04  9:44 Andy Shevchenko
  2019-03-05 20:38 ` Bart Van Assche
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2019-03-04  9:44 UTC (permalink / raw)
  To: target-devel

Switch to bitmap_zalloc() to show clearly what we are allocating.
Besides that it returns pointer of bitmap type instead of opaque void *.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/target/target_core_user.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 5831e0eecea1..c726c029affe 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1663,7 +1663,7 @@ static void tcmu_dev_kref_release(struct kref *kref)
 	WARN_ON(!all_expired);
 
 	tcmu_blocks_release(&udev->data_blocks, 0, udev->dbi_max + 1);
-	kfree(udev->data_bitmap);
+	bitmap_free(udev->data_bitmap);
 	mutex_unlock(&udev->cmdr_lock);
 
 	call_rcu(&dev->rcu_head, tcmu_dev_call_rcu);
@@ -1870,9 +1870,7 @@ static int tcmu_configure_device(struct se_device *dev)
 	info = &udev->uio_info;
 
 	mutex_lock(&udev->cmdr_lock);
-	udev->data_bitmap = kcalloc(BITS_TO_LONGS(udev->max_blocks),
-				    sizeof(unsigned long),
-				    GFP_KERNEL);
+	udev->data_bitmap = bitmap_zalloc(udev->max_blocks, GFP_KERNEL);
 	mutex_unlock(&udev->cmdr_lock);
 	if (!udev->data_bitmap) {
 		ret = -ENOMEM;
@@ -1959,7 +1957,7 @@ static int tcmu_configure_device(struct se_device *dev)
 	vfree(udev->mb_addr);
 	udev->mb_addr = NULL;
 err_vzalloc:
-	kfree(udev->data_bitmap);
+	bitmap_free(udev->data_bitmap);
 	udev->data_bitmap = NULL;
 err_bitmap_alloc:
 	kfree(info->name);
-- 
2.20.1

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

* Re: [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc()
  2019-03-04  9:44 [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc() Andy Shevchenko
@ 2019-03-05 20:38 ` Bart Van Assche
  2019-03-06 17:52 ` Martin K. Petersen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2019-03-05 20:38 UTC (permalink / raw)
  To: target-devel

On Mon, 2019-03-04 at 11:44 +-0200, Andy Shevchenko wrote:
+AD4 Switch to bitmap+AF8-zalloc() to show clearly what we are allocating.
+AD4 Besides that it returns pointer of bitmap type instead of opaque void +ACo.

Reviewed-by: Bart Van Assche +ADw-bvanassche+AEA-acm.org+AD4

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

* Re: [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc()
  2019-03-04  9:44 [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc() Andy Shevchenko
  2019-03-05 20:38 ` Bart Van Assche
@ 2019-03-06 17:52 ` Martin K. Petersen
  2019-03-06 20:43 ` Mike Christie
  2019-03-07  0:13 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2019-03-06 17:52 UTC (permalink / raw)
  To: target-devel


Mike,

Please review!

> Switch to bitmap_zalloc() to show clearly what we are allocating.
> Besides that it returns pointer of bitmap type instead of opaque void *.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/target/target_core_user.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 5831e0eecea1..c726c029affe 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1663,7 +1663,7 @@ static void tcmu_dev_kref_release(struct kref *kref)
>  	WARN_ON(!all_expired);
>  
>  	tcmu_blocks_release(&udev->data_blocks, 0, udev->dbi_max + 1);
> -	kfree(udev->data_bitmap);
> +	bitmap_free(udev->data_bitmap);
>  	mutex_unlock(&udev->cmdr_lock);
>  
>  	call_rcu(&dev->rcu_head, tcmu_dev_call_rcu);
> @@ -1870,9 +1870,7 @@ static int tcmu_configure_device(struct se_device *dev)
>  	info = &udev->uio_info;
>  
>  	mutex_lock(&udev->cmdr_lock);
> -	udev->data_bitmap = kcalloc(BITS_TO_LONGS(udev->max_blocks),
> -				    sizeof(unsigned long),
> -				    GFP_KERNEL);
> +	udev->data_bitmap = bitmap_zalloc(udev->max_blocks, GFP_KERNEL);
>  	mutex_unlock(&udev->cmdr_lock);
>  	if (!udev->data_bitmap) {
>  		ret = -ENOMEM;
> @@ -1959,7 +1957,7 @@ static int tcmu_configure_device(struct se_device *dev)
>  	vfree(udev->mb_addr);
>  	udev->mb_addr = NULL;
>  err_vzalloc:
> -	kfree(udev->data_bitmap);
> +	bitmap_free(udev->data_bitmap);
>  	udev->data_bitmap = NULL;
>  err_bitmap_alloc:
>  	kfree(info->name);

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc()
  2019-03-04  9:44 [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc() Andy Shevchenko
  2019-03-05 20:38 ` Bart Van Assche
  2019-03-06 17:52 ` Martin K. Petersen
@ 2019-03-06 20:43 ` Mike Christie
  2019-03-07  0:13 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Mike Christie @ 2019-03-06 20:43 UTC (permalink / raw)
  To: target-devel

On 03/04/2019 03:44 AM, Andy Shevchenko wrote:
> Switch to bitmap_zalloc() to show clearly what we are allocating.
> Besides that it returns pointer of bitmap type instead of opaque void *.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/target/target_core_user.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 5831e0eecea1..c726c029affe 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1663,7 +1663,7 @@ static void tcmu_dev_kref_release(struct kref *kref)
>  	WARN_ON(!all_expired);
>  
>  	tcmu_blocks_release(&udev->data_blocks, 0, udev->dbi_max + 1);
> -	kfree(udev->data_bitmap);
> +	bitmap_free(udev->data_bitmap);
>  	mutex_unlock(&udev->cmdr_lock);
>  
>  	call_rcu(&dev->rcu_head, tcmu_dev_call_rcu);
> @@ -1870,9 +1870,7 @@ static int tcmu_configure_device(struct se_device *dev)
>  	info = &udev->uio_info;
>  
>  	mutex_lock(&udev->cmdr_lock);
> -	udev->data_bitmap = kcalloc(BITS_TO_LONGS(udev->max_blocks),
> -				    sizeof(unsigned long),
> -				    GFP_KERNEL);
> +	udev->data_bitmap = bitmap_zalloc(udev->max_blocks, GFP_KERNEL);
>  	mutex_unlock(&udev->cmdr_lock);
>  	if (!udev->data_bitmap) {
>  		ret = -ENOMEM;
> @@ -1959,7 +1957,7 @@ static int tcmu_configure_device(struct se_device *dev)
>  	vfree(udev->mb_addr);
>  	udev->mb_addr = NULL;
>  err_vzalloc:
> -	kfree(udev->data_bitmap);
> +	bitmap_free(udev->data_bitmap);
>  	udev->data_bitmap = NULL;
>  err_bitmap_alloc:
>  	kfree(info->name);
> 

Looks nice to me. Thanks.

Acked-by: Mike Christie <mchristi@redhat.com>

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

* Re: [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc()
  2019-03-04  9:44 [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2019-03-06 20:43 ` Mike Christie
@ 2019-03-07  0:13 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2019-03-07  0:13 UTC (permalink / raw)
  To: target-devel


Andy,

> Switch to bitmap_zalloc() to show clearly what we are allocating.
> Besides that it returns pointer of bitmap type instead of opaque void
> *.

Applied to 5.1/scsi-queue. Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2019-03-07  0:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-04  9:44 [PATCH v1] scsi: tcmu: Switch to bitmap_zalloc() Andy Shevchenko
2019-03-05 20:38 ` Bart Van Assche
2019-03-06 17:52 ` Martin K. Petersen
2019-03-06 20:43 ` Mike Christie
2019-03-07  0:13 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.