Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d50ed907dc3db5bf2dd0a05b4e199a65793a3788
Commit:     d50ed907dc3db5bf2dd0a05b4e199a65793a3788
Parent:     4f3bf19c6e8164b441faaee476e734b4f612a78d
Author:     Christian Borntraeger <[EMAIL PROTECTED]>
AuthorDate: Fri Feb 1 09:05:00 2008 +0100
Committer:  Rusty Russell <[EMAIL PROTECTED]>
CommitDate: Mon Feb 4 23:50:11 2008 +1100

    virtio_blk: implement naming for vda-vdz,vdaa-vdzz,vdaaa-vdzzz
    
    Am Freitag, 1. Februar 2008 schrieb Christian Borntraeger:
    > Right. I will fix that with an additional patch.
    
    This patch goes on top of the minor number patch. Please let me know if
    you want a merged patch:
    
    Currently virtio_blk creates the disk name combinging "vd"  with 'a'++.
    This will give strange names after vdz. I have implemented names up to
    vdzzz - inspired by the sd.c code. That should be sufficient for now.
    
    There is one driver in the kernel (driver/s390/block/dasd_genhd.c) that
    implements names from dasda-dasdzzzz allowing even more disks. Maybe
    a janitor can come up with a common implementation usable for all kind
    of block device drivers.
    
    I have tested this patch with 100 disks - seems to work.
    
    Signed-off-by: Christian Borntraeger <[EMAIL PROTECTED]>
    Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
---
 drivers/block/virtio_blk.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 559c322..3b1a68d 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -9,8 +9,7 @@
 #define VIRTIO_MAX_SG  (3+MAX_PHYS_SEGMENTS)
 #define PART_BITS 4
 
-static unsigned char virtblk_index = 'a';
-static int major, minor;
+static int major, index;
 
 struct virtio_blk
 {
@@ -171,6 +170,11 @@ static struct block_device_operations virtblk_fops = {
        .getgeo = virtblk_getgeo,
 };
 
+static int index_to_minor(int index)
+{
+       return index << PART_BITS;
+}
+
 static int virtblk_probe(struct virtio_device *vdev)
 {
        struct virtio_blk *vblk;
@@ -178,7 +182,7 @@ static int virtblk_probe(struct virtio_device *vdev)
        u64 cap;
        u32 v;
 
-       if (minor >= 1 << MINORBITS)
+       if (index_to_minor(index) >= 1 << MINORBITS)
                return -ENOSPC;
 
        vdev->priv = vblk = kmalloc(sizeof(*vblk), GFP_KERNEL);
@@ -217,13 +221,24 @@ static int virtblk_probe(struct virtio_device *vdev)
                goto out_put_disk;
        }
 
-       sprintf(vblk->disk->disk_name, "vd%c", virtblk_index++);
+       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);
+       }
+
        vblk->disk->major = major;
-       vblk->disk->first_minor = minor;
+       vblk->disk->first_minor = index_to_minor(index);
        vblk->disk->private_data = vblk;
        vblk->disk->fops = &virtblk_fops;
-
-       minor += 1 << PART_BITS;
+       index++;
 
        /* If barriers are supported, tell block layer that queue is ordered */
        if (vdev->config->feature(vdev, VIRTIO_BLK_F_BARRIER))
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to