From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber de Oliveira Costa Subject: [PATCH] Safely finish closing protocol when guest fails in blkfront Date: Mon, 4 Dec 2006 19:40:17 -0200 Message-ID: <20061204214017.GA12102@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="VbJkn9YxBvnuCH5J" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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" --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="xen-frontend-fails-attach.patch" # 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 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: --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --VbJkn9YxBvnuCH5J--