Re: [PATCH 01/17] Add ida and idr helper routines.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Tue, Sep 15, 2015 at 09:46:01AM -0700, Lee Duncan wrote:
> +/**
> + * ida_get_index - allocate a ida index value
> + * @ida		idr handle
> + * @lock	spinlock handle protecting this index
> + * @p_id	pointer to allocated index value
> + *
> + * A helper function for safely allocating an index value (id),
> + * returning a negative errno value on failure, else 0.
> + */
> +static inline int ida_get_index(struct ida *ida, spinlock_t *lock, int *p_id)
> +{
> +	int error = -ENOMEM;
> +
> +	do {
> +		if (!ida_pre_get(ida, GFP_KERNEL))
> +			break;
> +		spin_lock(lock);
> +		error = ida_get_new(ida, p_id);
> +		spin_unlock(lock);
> +	} while (error == -EAGAIN);
> +
> +	return error;
> +}

Obviously ida allocation doesn't need to be synchronized against
anything else.  Why not just use ida_simple_get/remove()?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux