CEPH-Devel archive mirror
 help / color / mirror / Atom feed
* [PATCH] rbd: Remove usage of the deprecated ida_simple_xx() API
@ 2024-01-15 20:37 Christophe JAILLET
  2024-01-16 13:30 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-01-15 20:37 UTC (permalink / raw
  To: Ilya Dryomov, Dongsheng Yang, Jens Axboe
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, ceph-devel,
	linux-block

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, buInputt 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/block/rbd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a999b698b131..63897d0d6629 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5326,7 +5326,7 @@ static void rbd_dev_release(struct device *dev)
 
 	if (need_put) {
 		destroy_workqueue(rbd_dev->task_wq);
-		ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
+		ida_free(&rbd_dev_id_ida, rbd_dev->dev_id);
 	}
 
 	rbd_dev_free(rbd_dev);
@@ -5402,9 +5402,9 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
 		return NULL;
 
 	/* get an id and fill in device name */
-	rbd_dev->dev_id = ida_simple_get(&rbd_dev_id_ida, 0,
-					 minor_to_rbd_dev_id(1 << MINORBITS),
-					 GFP_KERNEL);
+	rbd_dev->dev_id = ida_alloc_max(&rbd_dev_id_ida,
+					minor_to_rbd_dev_id(1 << MINORBITS) - 1,
+					GFP_KERNEL);
 	if (rbd_dev->dev_id < 0)
 		goto fail_rbd_dev;
 
@@ -5425,7 +5425,7 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
 	return rbd_dev;
 
 fail_dev_id:
-	ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
+	ida_free(&rbd_dev_id_ida, rbd_dev->dev_id);
 fail_rbd_dev:
 	rbd_dev_free(rbd_dev);
 	return NULL;
-- 
2.43.0


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

* Re: [PATCH] rbd: Remove usage of the deprecated ida_simple_xx() API
  2024-01-15 20:37 [PATCH] rbd: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
@ 2024-01-16 13:30 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2024-01-16 13:30 UTC (permalink / raw
  To: Christophe JAILLET
  Cc: Dongsheng Yang, Jens Axboe, linux-kernel, kernel-janitors,
	ceph-devel, linux-block

On Mon, Jan 15, 2024 at 9:37 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> 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, buInputt 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/block/rbd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index a999b698b131..63897d0d6629 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -5326,7 +5326,7 @@ static void rbd_dev_release(struct device *dev)
>
>         if (need_put) {
>                 destroy_workqueue(rbd_dev->task_wq);
> -               ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
> +               ida_free(&rbd_dev_id_ida, rbd_dev->dev_id);
>         }
>
>         rbd_dev_free(rbd_dev);
> @@ -5402,9 +5402,9 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
>                 return NULL;
>
>         /* get an id and fill in device name */
> -       rbd_dev->dev_id = ida_simple_get(&rbd_dev_id_ida, 0,
> -                                        minor_to_rbd_dev_id(1 << MINORBITS),
> -                                        GFP_KERNEL);
> +       rbd_dev->dev_id = ida_alloc_max(&rbd_dev_id_ida,
> +                                       minor_to_rbd_dev_id(1 << MINORBITS) - 1,
> +                                       GFP_KERNEL);
>         if (rbd_dev->dev_id < 0)
>                 goto fail_rbd_dev;
>
> @@ -5425,7 +5425,7 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
>         return rbd_dev;
>
>  fail_dev_id:
> -       ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
> +       ida_free(&rbd_dev_id_ida, rbd_dev->dev_id);
>  fail_rbd_dev:
>         rbd_dev_free(rbd_dev);
>         return NULL;
> --
> 2.43.0
>

Applied.

Thanks,

                Ilya

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

end of thread, other threads:[~2024-01-16 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 20:37 [PATCH] rbd: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
2024-01-16 13:30 ` Ilya Dryomov

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 read-only IMAP folder(s) and NNTP newsgroup(s).