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

[Xen-devel] [PATCH 2/2 - resent]



This patch makes it so the blktap control device (device minor 0) does not have a descriptor allocated for it.

[This patch has been tested before the 3.0.3 branch, but only compiled tested after the branch]

-- Steve

Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>
diff -r 35a5d9ae9c1c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Fri Oct 20 13:11:17 
2006 -0400
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Fri Oct 20 13:16:02 
2006 -0400
@@ -354,6 +354,8 @@ static tap_blkif_t *get_next_free_dev(vo
 
        spin_lock_irq(&pending_free_lock);
 
+       /* tapfds[0] is always NULL */
+
        for (minor = 1; minor < blktap_next_minor; minor++) {
                info = tapfds[minor];
                /* we could have failed a previous attempt. */
@@ -419,7 +421,7 @@ int dom_to_devid(domid_t domid, int xenb
        tap_blkif_t *info;
        int i;
 
-       for (i = 0; i < blktap_next_minor; i++) {
+       for (i = 1; i < blktap_next_minor; i++) {
                info = tapfds[i];
                if ( info &&
                     (info->trans.domid == domid) &&
@@ -458,6 +460,10 @@ static int blktap_open(struct inode *ino
        tap_blkif_t *info;
        int i;
        
+       /* ctrl device, treat differently */
+       if (!idx)
+               return 0;
+
        info = tapfds[idx];
 
        if ((idx < 0) || (idx > MAX_TAP_DEV) || !info) {
@@ -507,12 +513,10 @@ static int blktap_release(struct inode *
 {
        tap_blkif_t *info = filp->private_data;
        
-       /* can this ever happen? - sdr */
-       if (!info) {
-               WPRINTK("Trying to free device that doesn't exist "
-                      "[/dev/xen/blktap%d]\n",iminor(inode) - BLKTAP_MINOR);
-               return -EBADF;
-       }
+       /* check for control device */
+       if (!info)
+               return 0;
+
        info->dev_inuse = 0;
        DPRINTK("Freeing device [/dev/xen/blktap%d]\n",info->minor);
 
@@ -704,7 +708,7 @@ static int blktap_ioctl(struct inode *in
 
                info = tapfds[dev];
 
-               if (!dev || (dev > MAX_TAP_DEV) || !info)
+               if ((dev > MAX_TAP_DEV) || !info)
                        return -EINVAL;
 
                return info->minor;
@@ -726,13 +730,8 @@ static unsigned int blktap_poll(struct f
 {
        tap_blkif_t *info = filp->private_data;
        
-       if (!info) {
-               WPRINTK(" poll, retrieving idx failed\n");
-               return 0;
-       }
-
        /* do not work on the control device */
-       if (!info->minor)
+       if (!info)
                return 0;
 
        poll_wait(filp, &info->wait, wait);
@@ -749,8 +748,7 @@ void blktap_kick_user(int idx)
 
        info = tapfds[idx];
 
-       /* Don't kick control device minor==0 */
-       if ((idx <= 0) || (idx > MAX_TAP_DEV) || !info)
+       if ((idx < 0) || (idx > MAX_TAP_DEV) || !info)
                return;
 
        wake_up_interruptible(&info->wait);
@@ -1427,7 +1425,6 @@ static int __init blkif_init(void)
 static int __init blkif_init(void)
 {
        int i,ret,blktap_dir;
-       tap_blkif_t *info;
 
        if (!is_running_on_xen())
                return -ENODEV;
@@ -1458,10 +1455,7 @@ static int __init blkif_init(void)
        
        blktap_major = ret;
 
-       info = kzalloc(sizeof(tap_blkif_t),GFP_KERNEL);
-       if (!info)
-               return -ENOMEM;
-
+       /* tapfds[0] is always NULL */
        blktap_next_minor++;
 
        ret = devfs_mk_cdev(MKDEV(blktap_major, i),
@@ -1471,8 +1465,6 @@ static int __init blkif_init(void)
                return -ENOMEM;
 
        DPRINTK("Created misc_dev [/dev/xen/blktap%d]\n",i);
-
-       tapfds[0] = info;
 
        /* Make sure the xen class exists */
        if (!setup_xen_class()) {
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.