# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID f5d179bcad704351bb0c1d4f36c20146080c79cc
# Parent 80b296ec93dcdeb948f3b9046f6e70230a483298
[BLKTAP] Do not allocate a descriptor for blktap control device
(minor 0).
Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>
---
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c | 38 +++++++++--------------
1 files changed, 15 insertions(+), 23 deletions(-)
diff -r 80b296ec93dc -r f5d179bcad70
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Mon Oct 23 14:18:16
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Mon Oct 23 14:19:14
2006 +0100
@@ -356,6 +356,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. */
@@ -421,7 +423,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) &&
@@ -460,6 +462,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) {
@@ -509,12 +515,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);
@@ -706,7 +710,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;
@@ -728,13 +732,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);
@@ -751,8 +750,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);
@@ -1386,7 +1384,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;
@@ -1417,10 +1414,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),
@@ -1430,8 +1424,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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|