Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1881928imm; Fri, 7 Sep 2018 07:34:44 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaa9sdsYg30rMJotbH0UNDT77j9pIozyl5+ef+QEJPgQrt8RdscXs4wghNCLgoHV0+oWEzA X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr8155011pll.24.1536330884173; Fri, 07 Sep 2018 07:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536330884; cv=none; d=google.com; s=arc-20160816; b=hwTn7Nm5GEFmxLebisYHVIqZHce1FuGvxjfgVsAnQ5i5XNvCc83P1dJ3YWM26+iNQp pwLkZ8NNLdUGef7VqTa7R7wy61HsmiNaa3J3HTbK4x9+pp7IV6mJyZN3SW25x/LX2HrO Ih8DXL1vgDrKhsp8eIYvuuSsdy0/jSsacMWz6pXC/Qa6Scm3E00EWcy06Xb6KFQQLaSq 3zvzkWErzjLSHalArmiNsFxHSm4ilsIkXiBmF9/BoMxIbXOzK90cIvIxSLBkaoyzEYRT UGy91VeNI7DBaznbbOmwVmqA7LnoHPSXA52Do7Tr4hpcP9yAzodWT+a7YS7Vr8g+FCJ4 9B7A== 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=bDVZBIrgnSZsqrSKtEKEnDLANZztLsY52/znIyB/W7w=; b=NXYIII8HmbrtdUX0Pr/Vh57be/+ebYGRy0p7D9S+dk45JEzdRtyXLLC3cJQvf70tBv m1xZ/GyZjPbXFX5AiGZWQCHqhra9ytw7Mo0S/OU9msicTfgPd4Biph7M6NKmAx45OKaP YrP+sUQbA81z6iKYVGC4WV5oAV1M8LewQ2YlwvGvuZ99zqNUMG0G6qxMN3ogJ5i1dkWy Kb7Us1nOjCHOFe8t6l+G/lChCJaC8TK/jZkmWithGpVl40G1SFqp5bhd19UBQaA3XG6x k0afkrNkXgqcCXCqlUOrnpzX0NTSeYjpGRHDprsI+cEyouUCBz0csFDX2zSfx4DUhteY 8gVA== 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 a98-v6si8738440pla.396.2018.09.07.07.34.28; Fri, 07 Sep 2018 07:34:44 -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 S1728731AbeIGPX5 (ORCPT + 99 others); Fri, 7 Sep 2018 11:23:57 -0400 Received: from smtp.ctxuk.citrix.com ([185.25.65.24]:31374 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbeIGPX4 (ORCPT ); Fri, 7 Sep 2018 11:23:56 -0400 X-IronPort-AV: E=Sophos;i="5.53,342,1531785600"; d="scan'208";a="78696431" Date: Fri, 7 Sep 2018 12:43:09 +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: <20180907104309.z4jsga5hcnphwxu7@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> <20180906162932.7qge5dmrgyqbmbbj@mac.bytemobile.com> <20180906221929.GZ26705@gavran.carpriv.carnet.hr> <20180907071530.te5dxdvg4zqgqscj@mac.bytemobile.com> <20180907072319.GA26705@gavran.carpriv.carnet.hr> <20180907075455.szxahgevvlmfjvwy@mac.bytemobile.com> <20180907102026.GH26705@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: <20180907102026.GH26705@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 Fri, Sep 07, 2018 at 12:20:26PM +0200, Valentin Vidic wrote: > On Fri, Sep 07, 2018 at 09:54:55AM +0200, Roger Pau Monn? wrote: > > Then I'm afraid you will have to look into the vbd_free/create fix. > > Yes, here is a first draft for that idea, let me know if you see some > problems there: Thanks! > --- xenbus.c.orig 2018-09-07 12:11:57.798071485 +0200 > +++ xenbus.c 2018-09-07 12:14:23.536077992 +0200 > @@ -758,6 +759,7 @@ > enum xenbus_state frontend_state) > { > struct backend_info *be = dev_get_drvdata(&dev->dev); > + struct block_device *bdev; > int err; > > pr_debug("%s %p %s\n", __func__, dev, xenbus_strstate(frontend_state)); > @@ -772,6 +774,22 @@ > > case XenbusStateInitialised: > case XenbusStateConnected: > + if (!be->blkif->vbd.bdev) { > + printk("blkdev_get"); > + bdev = blkdev_get_by_dev(be->blkif->vbd.pdevice, > + be->blkif->vbd.readonly ? > + FMODE_READ : FMODE_WRITE, NULL); > + > + if (IS_ERR(bdev)) { > + pr_warn("frontend_changed: device %08x could not be opened\n", > + be->blkif->vbd.pdevice); > + break; > + } > + > + printk("blkdev_get good"); > + be->blkif->vbd.bdev = bdev; > + } > + I would prefer if you could avoid open-coding this here, and instead use xen_vbd_create or similar. I would also prefer that the call to xen_vbd_create in backend_changed was removed and we had a single call to xen_vbd_create that's used for both initial device connection and reconnection. Also, I think this could cause issues if for some reason the frontend switches to state 'Connected' before hotplug scripts have run, in which case you would try to open an unexpected device because pdevice won't be correctly set. Roger.