WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xen-blkback: Don't disconnect backend until state sw

To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Jens Axboe <jaxboe@xxxxxxxxxxxx>, Daniel Stodden <daniel.stodden@xxxxxxxxxx>, Annie Li <annie.li@xxxxxxxxxx>, Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] xen-blkback: Don't disconnect backend until state switched to XenbusStateClosed.
From: Joe Jin <joe.jin@xxxxxxxxxx>
Date: Mon, 15 Aug 2011 12:51:31 +0800
Cc: Kurt C Hackel <KURT.HACKEL@xxxxxxxxxx>, Greg Marsden <greg.marsden@xxxxxxxxxx>, Joe Jin <joe.jin@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>
Delivery-date: Sun, 14 Aug 2011 21:52:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0
When do block-attach/block-detach test with below steps, umount hang
in guest. Also shutdown ends up being stuck when umounting filesystems.

1. start guest.
2. attach new block device by xm block-attach in Dom0.
3. mount new disk in guest.
4. execute xm block-detach to detach the block device in dom0 until timeout
5. Any request to the disk will hung.

Root cause:
  This issue caused by when setting backend device's state to
  'XenbusStateClosing', which will send frontend XenbusStateClosing 
  notification. When frontend receives the notification it tries to release
  the disk by blkfront_closing(), but at that moment, the disk is still in use
  by guest, so frontend refuses to close. 
  In blkfront_closing(), it sets the disk state to XenbusStateClosing and send
  a state switch to Closing notification to backend, when backend received the
  event, it disconnect the vbd from real device, set the vbd device state to
  XenbusStateClosing. For backend disconnected from real device/file, any IO
  requests to the disk in guest will end up, leaving disk DEAD disk and set to
  "XenbusStateClosing". For the disk have been disconnected, umount will hang
  on blkif_release()->xlvbd_release_gendisk() for unable send any IO to the
  disk, this prevent system clean shutdown.

Solution:
  Don't disconnect backend until frontend state switch to XenbusStateClosed.

Signed-off-by: Joe Jin <joe.jin@xxxxxxxxxx>
Cc: Daniel Stodden <daniel.stodden@xxxxxxxxxx>
Cc: Jens Axboe <jaxboe@xxxxxxxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Annie Li <annie.li@xxxxxxxxxx>
Cc: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
---
 drivers/block/xen-blkback/xenbus.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/xen-blkback/xenbus.c 
b/drivers/block/xen-blkback/xenbus.c
index 3f129b4..1a87f5b 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -601,11 +601,11 @@ static void frontend_changed(struct xenbus_device *dev,
                break;
 
        case XenbusStateClosing:
-               xen_blkif_disconnect(be->blkif);
                xenbus_switch_state(dev, XenbusStateClosing);
                break;
 
        case XenbusStateClosed:
+               xen_blkif_disconnect(be->blkif);
                xenbus_switch_state(dev, XenbusStateClosed);
                if (xenbus_dev_is_online(dev))
                        break;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] xen-blkback: Don't disconnect backend until state switched to XenbusStateClosed., Joe Jin <=