[PATCH] bcache: Remove usage of the deprecated ida_simple_xx() API

Christophe JAILLET posted 1 patch 1 year, 11 months ago
drivers/md/bcache/super.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
[PATCH] bcache: Remove usage of the deprecated ida_simple_xx() API
Posted by Christophe JAILLET 1 year, 11 months ago
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_max() is inclusive. So a -1 has been added when needed.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/md/bcache/super.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index dc3f50f69714..a2eecd1db126 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -881,8 +881,8 @@ static void bcache_device_free(struct bcache_device *d)
 		bcache_device_detach(d);
 
 	if (disk) {
-		ida_simple_remove(&bcache_device_idx,
-				  first_minor_to_idx(disk->first_minor));
+		ida_free(&bcache_device_idx,
+			 first_minor_to_idx(disk->first_minor));
 		put_disk(disk);
 	}
 
@@ -926,8 +926,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
 	if (!d->full_dirty_stripes)
 		goto out_free_stripe_sectors_dirty;
 
-	idx = ida_simple_get(&bcache_device_idx, 0,
-				BCACHE_DEVICE_IDX_MAX, GFP_KERNEL);
+	idx = ida_alloc_max(&bcache_device_idx, BCACHE_DEVICE_IDX_MAX - 1,
+			    GFP_KERNEL);
 	if (idx < 0)
 		goto out_free_full_dirty_stripes;
 
@@ -980,7 +980,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
 out_bioset_exit:
 	bioset_exit(&d->bio_split);
 out_ida_remove:
-	ida_simple_remove(&bcache_device_idx, idx);
+	ida_free(&bcache_device_idx, idx);
 out_free_full_dirty_stripes:
 	kvfree(d->full_dirty_stripes);
 out_free_stripe_sectors_dirty:
-- 
2.43.0
Re: [PATCH] bcache: Remove usage of the deprecated ida_simple_xx() API
Posted by Coly Li 1 year, 11 months ago
On Sun, Jan 14, 2024 at 01:30:16PM +0100, Christophe JAILLET wrote:
> ida_alloc() and ida_free() should be preferred to the deprecated
> ida_simple_get() and ida_simple_remove().
> 
> Note that the upper limit of ida_simple_get() is exclusive, but the one of
> ida_alloc_max() is inclusive. So a -1 has been added when needed.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

It looks good to me. Add this patch into my testing directory.

Thanks.

Coly Li


> ---
>  drivers/md/bcache/super.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index dc3f50f69714..a2eecd1db126 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -881,8 +881,8 @@ static void bcache_device_free(struct bcache_device *d)
>  		bcache_device_detach(d);
>  
>  	if (disk) {
> -		ida_simple_remove(&bcache_device_idx,
> -				  first_minor_to_idx(disk->first_minor));
> +		ida_free(&bcache_device_idx,
> +			 first_minor_to_idx(disk->first_minor));
>  		put_disk(disk);
>  	}
>  
> @@ -926,8 +926,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
>  	if (!d->full_dirty_stripes)
>  		goto out_free_stripe_sectors_dirty;
>  
> -	idx = ida_simple_get(&bcache_device_idx, 0,
> -				BCACHE_DEVICE_IDX_MAX, GFP_KERNEL);
> +	idx = ida_alloc_max(&bcache_device_idx, BCACHE_DEVICE_IDX_MAX - 1,
> +			    GFP_KERNEL);
>  	if (idx < 0)
>  		goto out_free_full_dirty_stripes;
>  
> @@ -980,7 +980,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
>  out_bioset_exit:
>  	bioset_exit(&d->bio_split);
>  out_ida_remove:
> -	ida_simple_remove(&bcache_device_idx, idx);
> +	ida_free(&bcache_device_idx, idx);
>  out_free_full_dirty_stripes:
>  	kvfree(d->full_dirty_stripes);
>  out_free_stripe_sectors_dirty:
> -- 
> 2.43.0
> 

-- 
Coly Li
Re: [PATCH] bcache: Remove usage of the deprecated ida_simple_xx() API
Posted by Christophe JAILLET 1 year, 8 months ago
Le 14/01/2024 à 16:16, Coly Li a écrit :
> On Sun, Jan 14, 2024 at 01:30:16PM +0100, Christophe JAILLET wrote:
>> ida_alloc() and ida_free() should be preferred to the deprecated
>> ida_simple_get() and ida_simple_remove().
>>
>> Note that the upper limit of ida_simple_get() is exclusive, but the one of
>> ida_alloc_max() is inclusive. So a -1 has been added when needed.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> It looks good to me. Add this patch into my testing directory.
> 
> Thanks.
> 
> Coly Li

Hi,

polite reminder ;-)

CJ

> 
> 
>> ---
>>   drivers/md/bcache/super.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>> index dc3f50f69714..a2eecd1db126 100644
>> --- a/drivers/md/bcache/super.c
>> +++ b/drivers/md/bcache/super.c
>> @@ -881,8 +881,8 @@ static void bcache_device_free(struct bcache_device *d)
>>   		bcache_device_detach(d);
>>   
>>   	if (disk) {
>> -		ida_simple_remove(&bcache_device_idx,
>> -				  first_minor_to_idx(disk->first_minor));
>> +		ida_free(&bcache_device_idx,
>> +			 first_minor_to_idx(disk->first_minor));
>>   		put_disk(disk);
>>   	}
>>   
>> @@ -926,8 +926,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
>>   	if (!d->full_dirty_stripes)
>>   		goto out_free_stripe_sectors_dirty;
>>   
>> -	idx = ida_simple_get(&bcache_device_idx, 0,
>> -				BCACHE_DEVICE_IDX_MAX, GFP_KERNEL);
>> +	idx = ida_alloc_max(&bcache_device_idx, BCACHE_DEVICE_IDX_MAX - 1,
>> +			    GFP_KERNEL);
>>   	if (idx < 0)
>>   		goto out_free_full_dirty_stripes;
>>   
>> @@ -980,7 +980,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
>>   out_bioset_exit:
>>   	bioset_exit(&d->bio_split);
>>   out_ida_remove:
>> -	ida_simple_remove(&bcache_device_idx, idx);
>> +	ida_free(&bcache_device_idx, idx);
>>   out_free_full_dirty_stripes:
>>   	kvfree(d->full_dirty_stripes);
>>   out_free_stripe_sectors_dirty:
>> -- 
>> 2.43.0
>>
> 

Re: [PATCH] bcache: Remove usage of the deprecated ida_simple_xx() API
Posted by Coly Li 1 year, 8 months ago

> 2024年4月14日 16:24,Christophe JAILLET <christophe.jaillet@wanadoo.fr> 写道:
> 
> Le 14/01/2024 à 16:16, Coly Li a écrit :
>> On Sun, Jan 14, 2024 at 01:30:16PM +0100, Christophe JAILLET wrote:
>>> ida_alloc() and ida_free() should be preferred to the deprecated
>>> ida_simple_get() and ida_simple_remove().
>>> 
>>> Note that the upper limit of ida_simple_get() is exclusive, but the one of
>>> ida_alloc_max() is inclusive. So a -1 has been added when needed.
>>> 
>>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> It looks good to me. Add this patch into my testing directory.
>> Thanks.
>> Coly Li
> 
> Hi,
> 
> polite reminder ;-)

Yes, this one is included in my recent performance testing :-)

Thank you.

Coly Li