[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d8f87c17-75d1-2e6b-65e1-23adc75bb515@wanadoo.fr>
Date: Thu, 2 Dec 2021 19:12:01 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Juergen Gross <jgross@...e.com>, boris.ostrovsky@...cle.com,
sstabellini@...nel.org, roger.pau@...rix.com, axboe@...nel.dk
Cc: xen-devel@...ts.xenproject.org, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] xen-blkfront: Use the bitmap API when applicable
Le 02/12/2021 à 07:12, Juergen Gross a écrit :
> On 01.12.21 22:10, Christophe JAILLET wrote:
>> Use 'bitmap_zalloc()' to simplify code, improve the semantic and avoid
>> some
>> open-coded arithmetic in allocator arguments.
>>
>> Also change the corresponding 'kfree()' into 'bitmap_free()' to keep
>> consistency.
>>
>> Use 'bitmap_copy()' to avoid an explicit 'memcpy()'
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
>> ---
>> drivers/block/xen-blkfront.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index 700c765a759a..fe4d69cf9469 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -442,16 +442,14 @@ static int xlbd_reserve_minors(unsigned int
>> minor, unsigned int nr)
>> if (end > nr_minors) {
>> unsigned long *bitmap, *old;
>> - bitmap = kcalloc(BITS_TO_LONGS(end), sizeof(*bitmap),
>> - GFP_KERNEL);
>> + bitmap = bitmap_zalloc(end, GFP_KERNEL);
>> if (bitmap == NULL)
>> return -ENOMEM;
>> spin_lock(&minor_lock);
>> if (end > nr_minors) {
>> old = minors;
>> - memcpy(bitmap, minors,
>> - BITS_TO_LONGS(nr_minors) * sizeof(*bitmap));
>> + bitmap_copy(bitmap, minors, nr_minors);
>> minors = bitmap;
>> nr_minors = BITS_TO_LONGS(end) * BITS_PER_LONG;
>> } else
>
> Shouldn't you use bitmap_free(old) some lines down?
Obvious.
I'll send a V2, Thx for the review.
CJ
>
>> @@ -2610,7 +2608,7 @@ static void __exit xlblk_exit(void)
>> xenbus_unregister_driver(&blkfront_driver);
>> unregister_blkdev(XENVBD_MAJOR, DEV_NAME);
>> - kfree(minors);
>> + bitmap_free(minors);
>> }
>> module_exit(xlblk_exit);
>
>
> Juergen
>
Powered by blists - more mailing lists