WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2/2] Don't allocate a descriptor for the control devi

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, andrew.warfield@xxxxxxxxxxxx, Keir.Fraser@xxxxxxxxxxxx, sct@xxxxxxxxxx
Subject: [Xen-devel] [PATCH 2/2] Don't allocate a descriptor for the control device in blktap
From: Steven Rostedt <srostedt@xxxxxxxxxx>
Date: Mon, 02 Oct 2006 17:55:05 -0400
Delivery-date: Mon, 02 Oct 2006 14:55:01 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060614)
This patch removes the allocated tap_blkif descriptor for the control devices. Now the tapfds[0] is always NULL. The rest of the functions take this into account. This removes confusion about blktap0 having other abilities.

-- Steve

Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>
diff -r cdcfecf2df93 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Mon Oct 02 17:37:11 
2006 -0400
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Mon Oct 02 17:43:15 
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
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/2] Don't allocate a descriptor for the control device in blktap, Steven Rostedt <=