[PATCH v2 2/2] scsi: scsi_debug: Use vcalloc to simplify code

Qianfeng Rong posted 2 patches 2 months ago
[PATCH v2 2/2] scsi: scsi_debug: Use vcalloc to simplify code
Posted by Qianfeng Rong 2 months ago
Use vcalloc() instead of vmalloc() followed by bitmap_zero() to simplify
the functions sdebug_add_store().

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/scsi/scsi_debug.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 353cb60e1abe..14e2d6e94dd2 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -8805,8 +8805,8 @@ static int sdebug_add_store(void)
 	/* Logical Block Provisioning */
 	if (scsi_debug_lbp()) {
 		map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
-		sip->map_storep = vmalloc(array_size(sizeof(long),
-						     BITS_TO_LONGS(map_size)));
+		sip->map_storep = vcalloc(BITS_TO_LONGS(map_size),
+					  sizeof(long));
 
 		pr_info("%lu provisioning blocks\n", map_size);
 
@@ -8815,8 +8815,6 @@ static int sdebug_add_store(void)
 			goto err;
 		}
 
-		bitmap_zero(sip->map_storep, map_size);
-
 		/* Map first 1KB for partition table */
 		if (sdebug_num_parts)
 			map_region(sip, 0, 2);
-- 
2.34.1
Re: [PATCH v2 2/2] scsi: scsi_debug: Use vcalloc to simplify code
Posted by Markus Elfring 2 months ago
…
> the functions sdebug_add_store().

      function?

Regards,
Markus
Re: [PATCH v2 2/2] scsi: scsi_debug: Use vcalloc to simplify code
Posted by Qianfeng Rong 2 months ago
在 2025/8/5 20:38, Markus Elfring 写道:
> [You don't often get email from markus.elfring@web.de. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> …
>> the functions sdebug_add_store().
>        function?
Thank you for your correction, I will modify it in the next version.
>
> Regards,
> Markus