Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp734039imm; Thu, 6 Sep 2018 09:17:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZvNSvYua7iqUokf51NiKAtyue3C1/848h+r7tmUHm6xzwWOBdSP52kAqRywgDPlbqUMkTc X-Received: by 2002:a62:6104:: with SMTP id v4-v6mr3742797pfb.122.1536250636096; Thu, 06 Sep 2018 09:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536250636; cv=none; d=google.com; s=arc-20160816; b=OtPwE3AzFrAmv9lMIh85ccTMgqgf63a7GTC57JQMmdCfQze+DRYY81VlRDQPvik4Wg AO4UA6/7LoJ95kGtUR/q45KjZ43IoDh1AdjsJvUBsWCAJ42fbF6eNccZjmY8lGnLarKc 5NFaqkdhGQr6YJs3poKvYIAhdKg9ciCKHOr8bwFwMPIlQo+BGWIT/nbucF9epAFAVoZf ruT7/ijP8dJha9TQyAG4eozrUyNi/4okTAZhLtpAbEKBrNq2iNzvAdC+r4P8Yel+aYI9 1n55MVaUEVmiaP9CWJarWFn2FOBLKwrxU27vSrhAHKW1XQLDxtJ/uJ7qCaPCJGJYTJ36 udGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=VSoyDA5JlKUaoRqTufwvRpULB0BkOSKMxa4f0YY5xbw=; b=xlg/urrNiKcx1Ar8WoqzEMpypIW/zEF3gqmPCDDIAuZLl1AhZtzgA1dTVXGJDTOagb 7s9+LSsDv6T1AnTyJRA6VXAEpnbJ8rKjXymZvTfp8F6pKN0m0FSs6uDnRFi0n5UO60SC wTHv2d6IXdusZ9jOBVpmW8Amm+jI5BqBsnlJT9zvXJcAUZGvf/cnoXnZNeIo4PSMwrrS mI1O8ZkwaTTn88CLx2rc9XRkC07vLyudGE1YZxOG8dVV/j8LMYCjgatX1+O/V62KWuFo u7pxybjDJoQ4AG09m4UxjFIo0CVQPxe9pE9UiscUMWZFA4tjd22CLFLv7smFJ9p/bSTf M8Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj4-v6si5090791plb.119.2018.09.06.09.16.58; Thu, 06 Sep 2018 09:17:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbeIFUun (ORCPT + 99 others); Thu, 6 Sep 2018 16:50:43 -0400 Received: from smtp.eu.citrix.com ([185.25.65.24]:18048 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbeIFUun (ORCPT ); Thu, 6 Sep 2018 16:50:43 -0400 X-IronPort-AV: E=Sophos;i="5.53,338,1531785600"; d="scan'208";a="78657326" Date: Thu, 6 Sep 2018 18:14:21 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Valentin Vidic CC: Konrad Rzeszutek Wilk , Jens Axboe , , , , , Subject: Re: [PATCH] xen-blkback: Switch to closed state after releasing the backing device Message-ID: <20180906161421.ba35p6qx5rvktjos@mac.bytemobile.com> References: <20180829065214.23546-1-Valentin.Vidic@CARNet.hr> <20180905103649.edugijsjx4v2fbxd@mac.bytemobile.com> <20180905162756.GA26705@gavran.carpriv.carnet.hr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180905162756.GA26705@gavran.carpriv.carnet.hr> User-Agent: NeoMutt/20180716 X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 05, 2018 at 06:27:56PM +0200, Valentin Vidic wrote: > On Wed, Sep 05, 2018 at 12:36:49PM +0200, Roger Pau Monn? wrote: > > On Wed, Aug 29, 2018 at 08:52:14AM +0200, Valentin Vidic wrote: > > > Switching to closed state earlier can cause the block-drbd > > > script to fail with 'Device is held open by someone': > > > > > > root: /etc/xen/scripts/block-drbd: remove XENBUS_PATH=backend/vbd/6/51712 > > > kernel: [ 2222.278235] block drbd6: State change failed: Device is held open by someone > > > kernel: [ 2222.278304] block drbd6: state = { cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate r----- } > > > kernel: [ 2222.278340] block drbd6: wanted = { cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate r----- } > > > root: /etc/xen/scripts/block-drbd: Writing backend/vbd/6/51712/hotplug-error /etc/xen/scripts/block-drbd failed; error detected. backend/vbd/6/51712/hotplug-status error to xenstore. > > > root: /etc/xen/scripts/block-drbd: /etc/xen/scripts/block-drbd failed; error detected. > > > > > > Signed-off-by: Valentin Vidic > > > Cc: stable@vger.kernel.org > > > --- > > > 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 a4bc74e72c39..43bddc996709 100644 > > > --- a/drivers/block/xen-blkback/xenbus.c > > > +++ b/drivers/block/xen-blkback/xenbus.c > > > @@ -323,6 +323,7 @@ static void xen_blkif_free(struct xen_blkif *blkif) > > > { > > > WARN_ON(xen_blkif_disconnect(blkif)); > > > xen_vbd_free(&blkif->vbd); > > > + xenbus_switch_state(blkif->be->dev, XenbusStateClosed); > > > kfree(blkif->be->mode); > > > kfree(blkif->be); > > > > > > @@ -814,7 +815,6 @@ static void frontend_changed(struct xenbus_device *dev, > > > > > > case XenbusStateClosed: > > > xen_blkif_disconnect(be->blkif); > > > - xenbus_switch_state(dev, XenbusStateClosed); > > > if (xenbus_dev_is_online(dev)) > > > break; > > > > AFAICT, this will cause the backend to never switch to 'Closed' state > > until the toolstack sets online to 0, which is not good IMO. > > > > If for example a frontend decides to close a device, the backend will > > stay in state 'Closing' until the toolstack actually removes the disk > > by setting online to 0. > > > > This will prevent resetting blk connections, as blkback will refuse to > > switch to state XenbusStateInitWait unless it's at XenbusStateClosed > > (see the XenbusStateInitialising case in frontend_changed), which will > > never be reached with your patch. > > Ok, is it possible to test this somehow? Yes, you can try booting a PV guest with pvgrub, that will cause pvgrub to open a blk connection, then close it and afterwards the OS kernel will start a new connection. Thanks, Roger.