[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130204191641.4817bba2@stein>
Date: Mon, 4 Feb 2013 19:16:41 +0100
From: Stefan Richter <stefanr@...6.in-berlin.de>
To: Tejun Heo <tj@...nel.org>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
rusty@...tcorp.com.au, bfields@...ldses.org,
skinsbursky@...allels.com, ebiederm@...ssion.com,
jmorris@...ei.org, axboe@...nel.dk,
linux1394-devel@...ts.sourceforge.net
Subject: Re: [PATCH v2 13/62] firewire: convert to idr_alloc()
On Feb 04 Tejun Heo wrote:
> Convert to the much saner new idr interface.
>
> Only compile tested.
>
> v2: Stefan pointed out that add_client_resource() may be called from
> non-process context. Preload iff @gfp_mask contains __GFP_WAIT.
> Also updated to include minor upper limit check.
>
> Signed-off-by: Tejun Heo <tj@...nel.org>
> Cc: Stefan Richter <stefanr@...6.in-berlin.de>
> Cc: linux1394-devel@...ts.sourceforge.net
Acked-by: Stefan Richter <stefanr@...6.in-berlin.de>
> ---
> drivers/firewire/core-cdev.c | 19 ++++++++++---------
> drivers/firewire/core-device.c | 8 +-------
> 2 files changed, 11 insertions(+), 16 deletions(-)
>
> --- a/drivers/firewire/core-cdev.c
> +++ b/drivers/firewire/core-cdev.c
> @@ -487,27 +487,28 @@ static int ioctl_get_info(struct client
> static int add_client_resource(struct client *client,
> struct client_resource *resource, gfp_t gfp_mask)
> {
> + bool preload = gfp_mask & __GFP_WAIT;
> unsigned long flags;
> int ret;
>
> - retry:
> - if (idr_pre_get(&client->resource_idr, gfp_mask) == 0)
> - return -ENOMEM;
> -
> + if (preload)
> + idr_preload(gfp_mask);
> spin_lock_irqsave(&client->lock, flags);
> +
> if (client->in_shutdown)
> ret = -ECANCELED;
> else
> - ret = idr_get_new(&client->resource_idr, resource,
> - &resource->handle);
> + ret = idr_alloc(&client->resource_idr, resource, 0, 0,
> + GFP_NOWAIT);
> if (ret >= 0) {
> + resource->handle = ret;
> client_get(client);
> schedule_if_iso_resource(resource);
> }
> - spin_unlock_irqrestore(&client->lock, flags);
>
> - if (ret == -EAGAIN)
> - goto retry;
> + spin_unlock_irqrestore(&client->lock, flags);
> + if (preload)
> + idr_preload_end();
>
> return ret < 0 ? ret : 0;
> }
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -1017,13 +1017,7 @@ static void fw_device_init(struct work_s
>
> fw_device_get(device);
> down_write(&fw_device_rwsem);
> - ret = idr_pre_get(&fw_device_idr, GFP_KERNEL) ?
> - idr_get_new(&fw_device_idr, device, &minor) :
> - -ENOMEM;
> - if (minor >= 1 << MINORBITS) {
> - idr_remove(&fw_device_idr, minor);
> - minor = -ENOSPC;
> - }
> + ret = idr_alloc(&fw_device_idr, device, 0, 1 << MINORBITS, GFP_KERNEL);
> up_write(&fw_device_rwsem);
>
> if (ret < 0)
--
Stefan Richter
-=====-===-= --=- --=--
http://arcgraph.de/sr/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists