nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] libnvdimm, label: Switch to bitmap_zalloc()
@ 2018-08-30 10:32 Andy Shevchenko
  2018-08-30 12:16 ` Johannes Thumshirn
  2018-08-30 21:46 ` Dave Jiang
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-08-30 10:32 UTC (permalink / raw)
  To: Dan Williams, Ross Zwisler, linux-nvdimm, Vishal Verma, Dave Jiang
  Cc: Andy Shevchenko

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/nvdimm/label.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 1d28cd656536..53159262c85d 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -814,8 +814,7 @@ static int __blk_label_update(struct nd_region *nd_region,
 	victims = 0;
 	if (old_num_resources) {
 		/* convert old local-label-map to dimm-slot victim-map */
-		victim_map = kcalloc(BITS_TO_LONGS(nslot), sizeof(long),
-				GFP_KERNEL);
+		victim_map = bitmap_zalloc(nslot, GFP_KERNEL);
 		if (!victim_map)
 			return -ENOMEM;
 
@@ -838,7 +837,7 @@ static int __blk_label_update(struct nd_region *nd_region,
 	/* don't allow updates that consume the last label */
 	if (nfree - alloc < 0 || nfree - alloc + victims < 1) {
 		dev_info(&nsblk->common.dev, "insufficient label space\n");
-		kfree(victim_map);
+		bitmap_free(victim_map);
 		return -ENOSPC;
 	}
 	/* from here on we need to abort on error */
@@ -1010,7 +1009,7 @@ static int __blk_label_update(struct nd_region *nd_region,
 
  out:
 	kfree(old_res_list);
-	kfree(victim_map);
+	bitmap_free(victim_map);
 	return rc;
 
  abort:
-- 
2.18.0

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

* Re: [PATCH v1] libnvdimm, label: Switch to bitmap_zalloc()
  2018-08-30 10:32 [PATCH v1] libnvdimm, label: Switch to bitmap_zalloc() Andy Shevchenko
@ 2018-08-30 12:16 ` Johannes Thumshirn
  2018-08-30 21:46 ` Dave Jiang
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2018-08-30 12:16 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-nvdimm, Ross Zwisler

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@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
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

* Re: [PATCH v1] libnvdimm, label: Switch to bitmap_zalloc()
  2018-08-30 10:32 [PATCH v1] libnvdimm, label: Switch to bitmap_zalloc() Andy Shevchenko
  2018-08-30 12:16 ` Johannes Thumshirn
@ 2018-08-30 21:46 ` Dave Jiang
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2018-08-30 21:46 UTC (permalink / raw)
  To: Andy Shevchenko, Dan Williams, Ross Zwisler, linux-nvdimm, Vishal Verma



On 08/30/2018 03:32 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>

Applied

> ---
>  drivers/nvdimm/label.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
> index 1d28cd656536..53159262c85d 100644
> --- a/drivers/nvdimm/label.c
> +++ b/drivers/nvdimm/label.c
> @@ -814,8 +814,7 @@ static int __blk_label_update(struct nd_region *nd_region,
>  	victims = 0;
>  	if (old_num_resources) {
>  		/* convert old local-label-map to dimm-slot victim-map */
> -		victim_map = kcalloc(BITS_TO_LONGS(nslot), sizeof(long),
> -				GFP_KERNEL);
> +		victim_map = bitmap_zalloc(nslot, GFP_KERNEL);
>  		if (!victim_map)
>  			return -ENOMEM;
>  
> @@ -838,7 +837,7 @@ static int __blk_label_update(struct nd_region *nd_region,
>  	/* don't allow updates that consume the last label */
>  	if (nfree - alloc < 0 || nfree - alloc + victims < 1) {
>  		dev_info(&nsblk->common.dev, "insufficient label space\n");
> -		kfree(victim_map);
> +		bitmap_free(victim_map);
>  		return -ENOSPC;
>  	}
>  	/* from here on we need to abort on error */
> @@ -1010,7 +1009,7 @@ static int __blk_label_update(struct nd_region *nd_region,
>  
>   out:
>  	kfree(old_res_list);
> -	kfree(victim_map);
> +	bitmap_free(victim_map);
>  	return rc;
>  
>   abort:
> 
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

end of thread, other threads:[~2018-08-30 21:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-30 10:32 [PATCH v1] libnvdimm, label: Switch to bitmap_zalloc() Andy Shevchenko
2018-08-30 12:16 ` Johannes Thumshirn
2018-08-30 21:46 ` Dave Jiang

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