Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp752180imm; Thu, 6 Sep 2018 09:33:19 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbyg/s2D51C2CG18P+wIhm/tbEyTi1+vZK3uXQBP0vNNLDFzR6TaQAYA5VIupOoK05R/SFj X-Received: by 2002:a63:e949:: with SMTP id q9-v6mr3679568pgj.4.1536251597638; Thu, 06 Sep 2018 09:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536251597; cv=none; d=google.com; s=arc-20160816; b=xFgFhctCvsd+4tbTqSh4TBiPkU+CRfCwKzFdf/Smo616yZ2fffRrx7hScqC2vowGb3 44NRYMi8IFPtmW4Owys0oWPXEfxCcTIutxAVgQR23E3idEfm5kYeBE2wgKMyMujhAN5r t10Ynrt51j0QSUD0ZNKy40OvwbRCB/xo/zTOvxE+bh5h9VycTeaTUTjjJ/aaFBk5I1X2 zd5+j9T5EBCTlKEsRW/QR6eHUtvCqtxW8SKQDxT2EvwBJMAkT2u/85DELd13Lrkgn0fO pps5DJCUkfOhhzONtFeZtzjfL1NkgIXr9vI1CJthNcX6gu7IEaOyyO5QFWjtRdILpm1a klFw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=x2RUvsvn+dWH6CNs9r0nbFmkr80t7dxpdtw3QH6GQbM=; b=OsrEgAtrGL1KJ8g1DmwJBwG0Br/cI3v7SpkmG8QnXqmvhxIJuT3QFEgGaHZ+pdU2s2 vkpMa2ue3VwyE4qr47CUGMmy9oREKZikAxGCsqPf92a0oNrWAWoFgulIpz7qHuUWdBQ2 W1aSy6boGIEZsalTZuGyBR6zmbxBgx+AWl0X2zwVBq9RCG85WogC3IgrttUaP2F+9b/z 3SZxANPaoCU99Af3/iL7uH+uwEAFeYuFCT6/3x34ODWIkIBKk8GQmyhnvroAS0fyht4M Mu4jFZ+bdmbEO/nNhWCI3BhQjDwT3QMkXKkRc9vf9D/Mha2tMRsFLeH6+2hA6b4wm4qg ypKw== 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 p17-v6si4797411pgd.352.2018.09.06.09.32.58; Thu, 06 Sep 2018 09:33:17 -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 S1727975AbeIFVF5 (ORCPT + 99 others); Thu, 6 Sep 2018 17:05:57 -0400 Received: from smtp.ctxuk.citrix.com ([185.25.65.24]:18731 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbeIFVF4 (ORCPT ); Thu, 6 Sep 2018 17:05:56 -0400 X-IronPort-AV: E=Sophos;i="5.53,338,1531785600"; d="scan'208";a="78658170" Date: Thu, 6 Sep 2018 18:29:32 +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: <20180906162932.7qge5dmrgyqbmbbj@mac.bytemobile.com> References: <20180829065214.23546-1-Valentin.Vidic@CARNet.hr> <20180905103649.edugijsjx4v2fbxd@mac.bytemobile.com> <20180905113515.GU26705@gavran.carpriv.carnet.hr> <20180905162801.GB26705@gavran.carpriv.carnet.hr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180905162801.GB26705@gavran.carpriv.carnet.hr> User-Agent: NeoMutt/20180716 X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) 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:28:01PM +0200, Valentin Vidic wrote: > On Wed, Sep 05, 2018 at 01:35:15PM +0200, Valentin Vidic wrote: > > > 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. > > Would it be possible to call xen_vbd_free before the state change? > > case XenbusStateClosed: > xen_blkif_disconnect(be->blkif); > xen_vbd_free(&be->blkif->vbd); > xenbus_switch_state(dev, XenbusStateClosed); I think that will break reconnection, since xen_vbd_create is only called after hotplug script execution is performed (which happens only once at device attachment), but not when DomU changes frontend state. If you want to perform this xen_vbd_free you will also have to move the xen_vbd_create call AFAICT, to a place that's also called when reconnecting a device. Note that I could be wrong, so it might be worth a shot to try different approaches since the blkback code is quite tangled and I might miss something. Thanks, Roger.