All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <srostedt@redhat.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	andrew.warfield@cl.cam.ac.uk, Keir.Fraser@cl.cam.ac.uk,
	sct@redhat.com
Subject: [PATCH 2/2] Don't allocate a descriptor for the control device in blktap
Date: Mon, 02 Oct 2006 17:55:05 -0400	[thread overview]
Message-ID: <45218AB9.6000906@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

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@redhat.com>

[-- Attachment #2: xen-linux-blktap-ctrl-no-info.patch --]
[-- Type: text/x-patch, Size: 2947 bytes --]

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()) {

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2006-10-02 21:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45218AB9.6000906@redhat.com \
    --to=srostedt@redhat.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=andrew.warfield@cl.cam.ac.uk \
    --cc=sct@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.