Don't allocate a descriptor for the control device in blktap
PATCH 2/2 Don't allocate a descriptor for the control device in blktap
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 <[email protected]>
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c +15 -23
@@ -354,6 +354,8 @@ static tap_blkif_t *get_next_free_dev(vospin_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 xenbtap_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 *inotap_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
[email protected]
http://lists.xensource.com/xen-devel