Re: [PATCH 4/4] virtio_blk: use disk_name_format() to support mass ofdisks naming

From: Asias He
Date: Fri Mar 30 2012 - 07:23:26 EST


Hi, Ren

On Fri, Mar 30, 2012 at 5:53 PM, Ren Mingxin <renmx@xxxxxxxxxxxxxx> wrote:
> ÂThe current virtblk's naming algorithm only supports 263 Âdisks.
> If there are mass of virtblks(exceeding 263), there will be disks
> with the same name.

This fix is pretty nice. However, current virtblk's naming still
supports up to 18278 disks, no?
( index 0 -> vda, index 18277 -> vdzzz ).

> By renaming "sd_format_disk_name()" to "disk_name_format()"
> and moving it into block core, virtio_blk can use this function to
> support mass of disks.
>
> Signed-off-by: Ren Mingxin <renmx@xxxxxxxxxxxxxx>
> ---
> Âvirtio_blk.c | Â 13 +------------
> Â1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index c4a60ba..54612c2 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -442,18 +442,7 @@ static int __devinit virtblk_probe(struct virtio_device
> *vdev)
>
> Â Â Â Âq->queuedata = vblk;
>
> - Â Â Â if (index < 26) {
> - Â Â Â Â Â Â Â sprintf(vblk->disk->disk_name, "vd%c", 'a' + index % 26);
> - Â Â Â } else if (index < (26 + 1) * 26) {
> - Â Â Â Â Â Â Â sprintf(vblk->disk->disk_name, "vd%c%c",
> - Â Â Â Â Â Â Â Â Â Â Â 'a' + index / 26 - 1, 'a' + index % 26);
> - Â Â Â } else {
> - Â Â Â Â Â Â Â const unsigned int m1 = (index / 26 - 1) / 26 - 1;
> - Â Â Â Â Â Â Â const unsigned int m2 = (index / 26 - 1) % 26;
> - Â Â Â Â Â Â Â const unsigned int m3 = Âindex % 26;
> - Â Â Â Â Â Â Â sprintf(vblk->disk->disk_name, "vd%c%c%c",
> - Â Â Â Â Â Â Â Â Â Â Â 'a' + m1, 'a' + m2, 'a' + m3);
> - Â Â Â }
> + Â Â Â disk_name_format("vd", index, vblk->disk->disk_name, DISK_NAME_LEN);
>
> Â Â Â Âvblk->disk->major = major;
> Â Â Â Âvblk->disk->first_minor = index_to_minor(index);
>
> --
> 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



--
Asias He
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/