Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbdIEHgh (ORCPT ); Tue, 5 Sep 2017 03:36:37 -0400 Received: from mail4.gandi.net ([217.70.183.210]:48229 "EHLO gandi.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751149AbdIEHgg (ORCPT ); Tue, 5 Sep 2017 03:36:36 -0400 X-Greylist: delayed 464 seconds by postgrey-1.27 at vger.kernel.org; Tue, 05 Sep 2017 03:36:35 EDT X-Spam-Flag: NO X-Spam-Score: -101.556 Date: Tue, 5 Sep 2017 09:28:49 +0200 From: Vincent Legout To: Roger Pau =?utf-8?B?TW9ubsOp?= Cc: Jan Beulich , xen-devel@lists.xenproject.org, Boris Ostrovsky , Juergen Gross , linux-kernel@vger.kernel.org Subject: Re: [Xen-devel] [PATCH] xen-blkfront: emit KOBJ_OFFLINE uevent when detaching device Message-ID: <20170905072849.mymaugf3im2luqai@bres.gandi.net> References: <20170704114823.pvk6323gfebioikl@bres.gandi.net> <20170704165927.c6dgitftm4v3xk7w@dhcp-3-128.uk.xensource.com> <20170705080804.j6lptyhmjguhdj47@bres.gandi.net> <595CBCB40200007800168A16@prv-mh.provo.novell.com> <20170705123715.exc4qyllpxatxpnj@bres.gandi.net> <595CFD650200007800168BF1@prv-mh.provo.novell.com> <20170705133000.ugnbckhul4xevzk5@bres.gandi.net> <20170707081053.s6pocjgz3ibkkyjg@dhcp-3-128.uk.xensource.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="roi5cq3k2ppnurql" Content-Disposition: inline In-Reply-To: <20170707081053.s6pocjgz3ibkkyjg@dhcp-3-128.uk.xensource.com> User-Agent: NeoMutt/20170609 (1.8.3) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4720 Lines: 121 --roi5cq3k2ppnurql Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, Sorry for such a long delay. I'm still interested in having this patch merged. I've tried to make the patch more generic and move it to xenbus as discussed during the Xen summit, but I'm not sure how or if it's possible. Would doing something in xenbus_otherend_changed() make sense? But do we have enough information there? I'd be happy to get any advice, I've re-attached the original patch. On Fri, Jul 07, 2017 at 09:10:53AM +0100, Roger Pau Monn=C3=A9 wrote : > On Wed, Jul 05, 2017 at 03:30:00PM +0200, Vincent Legout wrote: > > On Wed, Jul 05, 2017 at 06:53:25AM -0600, Jan Beulich wrote : > > > >>> On 05.07.17 at 14:37, wrote: > > > > On Wed, Jul 05, 2017 at 02:17:24AM -0600, Jan Beulich wrote : > > > >> >>> On 05.07.17 at 10:08, wrote: > > > >> > Without the patch, blkif_release and xlvbd_release_gendisk are= never > > > >> > called, and no call to blk_unregister_queue is made. > > > >>=20 > > > >> But isn't that what needs to be fixed then? The device should be > > > >> removed once its last user goes away (which would be at the time > > > >> the umount is eventually done aiui). > > > >=20 > > > > You mean that block-detach should fail if the device is still mou= nted? > > > > or find a way to wait until all the users are gone? > > > >=20 > > > > I don't say that's not what should be done, but that's not what I= get. > > > > The device is removed after a block-detach, even if still mounted= . So > > > > the system is left in an unstable state without the patch. > > >=20 > > > Unstable? I'd expect subsequent I/O to fail for that device, yes, b= ut > > > that's still a stable system. Are you observing anything else? > >=20 > > Yes, that's what I meant by unstable, nothing else. Sorry for the > > confusion. >=20 > IMHO, this should behave in the same exact way as hot-unplugging a USB > drive that's mounted, can you confirm that's correct? I agree. And if I'm not wrong, it currently doesn't behave the same as USB device unplugging. The patch tries to fix that. Thanks, Vincent --roi5cq3k2ppnurql Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-xen-blkfront-emit-KOBJ_OFFLINE-uevent-when-detaching.patch" >From 902ae3e380fcf75a2b453ae20a68952ee9752853 Mon Sep 17 00:00:00 2001 From: Vincent Legout Date: Tue, 27 Jun 2017 11:09:32 +0200 Subject: [PATCH] xen-blkfront: emit KOBJ_OFFLINE uevent when detaching device Devices are not unmounted inside a domU after a xl block-detach. After xl block-detach, blkfront_closing() is called with state == XenbusStateConnected, it detects that the device is still in use and only switches state to XenbusStateClosing. blkfront_closing() is called a second time but returns immediately because state == XenbusStateClosing. Thus the device keeps being mounted inside the domU. To fix this, emit a KOBJ_OFFLINE uevent even if the device has users. With this patch, inside domU, udev has: KERNEL[16994.526789] offline /devices/vbd-51728/block/xvdb (block) KERNEL[16994.796197] remove /devices/virtual/bdi/202:16 (bdi) KERNEL[16994.797167] remove /devices/vbd-51728/block/xvdb (block) UDEV [16994.798035] remove /devices/virtual/bdi/202:16 (bdi) UDEV [16994.809429] offline /devices/vbd-51728/block/xvdb (block) UDEV [16994.842365] remove /devices/vbd-51728/block/xvdb (block) KERNEL[16995.461991] remove /devices/vbd-51728 (xen) UDEV [16995.462549] remove /devices/vbd-51728 (xen) While without, it had: KERNEL[30.862764] remove /devices/vbd-51728 (xen) UDEV [30.867838] remove /devices/vbd-51728 (xen) Signed-off-by: Pascal Bouchareine Signed-off-by: Fatih Acar Signed-off-by: Vincent Legout --- drivers/block/xen-blkfront.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 39459631667c..da0b0444ee1f 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2185,8 +2185,10 @@ static void blkfront_closing(struct blkfront_info *info) mutex_lock(&bdev->bd_mutex); if (bdev->bd_openers) { - xenbus_dev_error(xbdev, -EBUSY, - "Device in use; refusing to close"); + dev_warn(disk_to_dev(info->gd), + "detaching %s with pending users\n", + xbdev->nodename); + kobject_uevent(&disk_to_dev(info->gd)->kobj, KOBJ_OFFLINE); xenbus_switch_state(xbdev, XenbusStateClosing); } else { xlvbd_release_gendisk(info); -- 2.13.2 --roi5cq3k2ppnurql--