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: <4D9BD88C.3030807@fusionio.com>
Date:	Wed, 6 Apr 2011 05:05:48 +0200
From:	Jens Axboe <jaxboe@...ionio.com>
To:	Rusty Russell <rusty@...tcorp.com.au>
CC:	Takuma Umeya <tumeya@...hat.com>,
	"virtualization@...ts.linux-foundation.org" 
	<virtualization@...ts.linux-foundation.org>,
	Christoph Hellwig <hch@....de>,
	john cooper <john.cooper@...hat.com>,
	Tejun Heo <tj@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] virtio_blk: decrement index when blockdevice is removed

On 2011-04-06 03:32, Rusty Russell wrote:
> On Tue, 05 Apr 2011 07:08:12 +0200, Jens Axboe <jaxboe@...ionio.com> wrote:
>> On 2011-04-05 06:49, Takuma Umeya wrote:
>>> When virtio block device is removed, index does not get decremented. When 
>>> another virtio disk is attached it uses the next device letter to the 
>>> one that is suppose to be available. 
>>>
>>> Signed-off-by: Takuma Umeya <tumeya@...hat.com>
>>>
>>> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
>>> index 6ecf89c..730e7af 100644
>>> --- a/drivers/block/virtio_blk.c
>>> +++ b/drivers/block/virtio_blk.c
>>> @@ -489,6 +489,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
>>>         mempool_destroy(vblk->pool);
>>>         vdev->config->del_vqs(vdev);
>>>         kfree(vblk);
>>> +       index--;
>>>  }
>>>  
>>>  static const struct virtio_device_id id_table[] = {
>>
>> What happens when you delete a device that isn't the last one?
> 
> Obviously we should do something cleverer for assigning drives.
> 
> It might be a cute if genhd gave us a function to get the next free
> index for a given major number, and format it for us, like so:
> 
>       /* Return the next available minor for a given @major, at least
>        * @spacing after the previous and, and append appropriate letters
>        * to @name if it's not NULL.  -ve errno on fail (-ENOSPC?). */
>       int disk_next_minor(int major, unsigned spacing, char *name);
> 
> A trivial optimization would be to remember the last major and max minor
> (resetting that if any disks are removed).
> 
> This could clean up other code, too.

Something like idr would be a good fit for this. But yes, adding some
helpers for this might not hurt...

-- 
Jens Axboe
--
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