lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mqdsi5t7ezy.fsf@c203.arch.suse.de>
Date:	Fri, 02 Oct 2015 12:15:45 +0200
From:	Johannes Thumshirn <jthumshirn@...e.de>
To:	Lee Duncan <lduncan@...e.com>
Cc:	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
	James Bottomley <James.Bottomley@...senPartnership.com>,
	Tejun Heo <tj@...nel.org>, Hannes Reinecke <hare@...e.com>,
	Christoph Hellwig <hch@...radead.org>,
	Matthew Wilcox <willy@...ux.intel.com>,
	linux-nvme@...ts.infradead.org
Subject: Re: [PATCH 3/5] block: nvme-core: simplify ida usage

Lee Duncan <lduncan@...e.com> writes:

> Simplify ida index allocation and removal by
> using the ida_simple_* helper functions.
>
> Signed-off-by: Lee Duncan <lduncan@...e.com>
> ---
>  drivers/block/nvme-core.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
> index d1d6141920d3..d354a3391e4a 100644
> --- a/drivers/block/nvme-core.c
> +++ b/drivers/block/nvme-core.c
> @@ -2713,18 +2713,10 @@ static DEFINE_IDA(nvme_instance_ida);
>  
>  static int nvme_set_instance(struct nvme_dev *dev)
>  {
> -	int instance, error;
> +	int instance;
>  
> -	do {
> -		if (!ida_pre_get(&nvme_instance_ida, GFP_KERNEL))
> -			return -ENODEV;
> -
> -		spin_lock(&dev_list_lock);
> -		error = ida_get_new(&nvme_instance_ida, &instance);
> -		spin_unlock(&dev_list_lock);
> -	} while (error == -EAGAIN);
> -
> -	if (error)
> +	instance = ida_simple_get(&nvme_instance_ida, 0, 0, GFP_KERNEL);
> +	if (instance < 0)
>  		return -ENODEV;
>  
>  	dev->instance = instance;
> @@ -2734,7 +2726,7 @@ static int nvme_set_instance(struct nvme_dev *dev)
>  static void nvme_release_instance(struct nvme_dev *dev)
>  {
>  	spin_lock(&dev_list_lock);
> -	ida_remove(&nvme_instance_ida, dev->instance);
> +	ida_simple_remove(&nvme_instance_ida, dev->instance);
>  	spin_unlock(&dev_list_lock);
>  }

Reviewed-by: Johannes Thumshirn <jthumshirn@...e.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@...e.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ