All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glauber de Oliveira Costa <gcosta@redhat.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Safely finish closing protocol when guest fails in blkfront
Date: Mon, 4 Dec 2006 19:40:17 -0200	[thread overview]
Message-ID: <20061204214017.GA12102@redhat.com> (raw)

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

If a guest finds any error and aborts the connection of a block device,
it's online state set at device create phase will stop it from being
properly cleaned up.

Follows a fix for it.

-- 
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"

[-- Attachment #2: xen-frontend-fails-attach.patch --]
[-- Type: text/plain, Size: 1890 bytes --]

# HG changeset patch
# User gcosta@redhat.com
# Date 1165272179 18000
# Node ID 6702c80880a1ed7e7467a59135f3764fb145cd0b
# Parent  fd28a1b139dea91b8bfcf06dd233dbdda8f51ff1
[LINUX] Get rid of device if block-attach fails

The current backend code checks to see if a device is online
before unregistering it. However,  when block attach fails
due to a guest failure, guest is the one to start closing protocols,
and state is never set to offline again.

Proposal is to check if there are error entries in xenstore,
and unregister if it is the case.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>

diff -r fd28a1b139de -r 6702c80880a1 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Dec 04 09:29:26 2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Mon Dec 04 17:42:59 2006 -0500
@@ -306,6 +306,32 @@ static void backend_changed(struct xenbu
 }
 
 
+static int dev_had_error(struct xenbus_device *dev)
+{
+	int err;
+	unsigned int virtual_device, frontend_id;
+	char *path = NULL;
+
+	err = xenbus_scanf(XBT_NIL, dev->otherend,
+					"virtual-device", "%u", &virtual_device);
+	if (err < 0)
+		return 0;
+
+	err = xenbus_scanf(XBT_NIL, dev->nodename,
+					"frontend-id", "%u", &frontend_id);
+	if (err < 0)
+		return 0;
+
+	path = kasprintf(GFP_KERNEL, "%u/error/device/vbd/%u",
+			frontend_id,virtual_device);
+	if (!path)
+		return 0;
+
+	err = xenbus_exists(XBT_NIL,"/local/domain",path);	
+	kfree(path);
+	return err;
+}
+ 
 /**
  * Callback received when the frontend's state changes.
  */
@@ -347,7 +373,7 @@ static void frontend_changed(struct xenb
 
 	case XenbusStateClosed:
 		xenbus_switch_state(dev, XenbusStateClosed);
-		if (xenbus_dev_is_online(dev))
+		if (xenbus_dev_is_online(dev) && !dev_had_error(dev))
 			break;
 		/* fall through if not online */
 	case XenbusStateUnknown:

[-- 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-12-04 21:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-04 21:40 Glauber de Oliveira Costa [this message]
2006-12-05  7:39 ` [PATCH] Safely finish closing protocol when guest fails in blkfront Keir Fraser
2006-12-05 10:22   ` Glauber de Oliveira Costa
2006-12-05 20:25     ` Glauber de Oliveira Costa

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=20061204214017.GA12102@redhat.com \
    --to=gcosta@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.