bcache: Remove usage of the deprecated ida_simple_xx() API
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 9 May 2024 01:11:16 +0000 (09:11 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 9 May 2024 01:15:01 +0000 (19:15 -0600)
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>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20240509011117.2697-2-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/super.c

index 330bcd9ea4a9ccd0366e9c5d28d0e7b1fb061fe6..38e41039edb8c9caaeb93f35f92617f553cd1cd0 100644 (file)
@@ -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);
        }
 
@@ -940,8 +940,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;
 
@@ -986,7 +986,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: