Re: [PATCH 1/1] [virt] virtio-blk: Use ida to allocate disk index

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

 



Hello,

On Wed, Jun 15, 2011 at 02:21:51PM +0930, Rusty Russell wrote:
> > +	if (index_to_minor(index) >= 1 << MINORBITS) {
> > +		err =  -ENOSPC;
> > +		goto out_free_index;
> > +	}
> 
> Is this *really* how this is supposed to be used?
> 
> Tejun, this is your code.  What do you think of something like this?
> (untested)

It's inherited from idr which was designed to have separate
prepare/allocation stages so that allocation can happen inside an
outer spinlock.  It doesn't have too much to do with optimization.
It's mostly to be able to use sleepable context for memory allocation
while allowing atomic id[ra] allocation.

>  /**
> + * ida_simple_get - get a new id.
> + * @ida: the (initialized) ida.
> + * @min_id: the minimum id (inclusive)
> + * @max_id: the maximum id (inclusive)
> + *
> + * Allocates an id in the range min_id <= id <= max_id, or returns -ENOSPC.
> + * On allocation failure, returns -ENOMEM.  This function can sleep.
> + *
> + * Use ida_simple_remove() to get rid of an id.
> + */
> +int ida_simple_get(struct ida *ida, int min_id, int max_id)

Hmmm... new interface different from existing id[ra] style, but yeah
something like the above would have made more sense from the
beginning.  The only thing is that isn't (begin <= range < end) more
conventional form to express ranges?

Thanks.

-- 
tejun
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/virtualization


[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux