Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947366AbdDYM7o (ORCPT ); Tue, 25 Apr 2017 08:59:44 -0400 Received: from smtp.eu.citrix.com ([185.25.65.24]:54703 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1430646AbdDYM7e (ORCPT ); Tue, 25 Apr 2017 08:59:34 -0400 X-IronPort-AV: E=Sophos;i="5.37,249,1488844800"; d="scan'208";a="44901434" Date: Tue, 25 Apr 2017 13:59:24 +0100 From: Roger Pau =?iso-8859-1?Q?Monn=E9?= To: Juergen Gross CC: , , , Subject: Re: [PATCH] xen/blkback: fix disconnect while I/Os in flight Message-ID: <20170425125924.jxl35mujvaej33ki@dhcp-3-128.uk.xensource.com> References: <20170421085100.26210-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170421085100.26210-1-jgross@suse.com> User-Agent: NeoMutt/20170306 (1.8.0) X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1373 Lines: 30 On Fri, Apr 21, 2017 at 10:51:00AM +0200, Juergen Gross wrote: > Today disconnecting xen-blkback is broken in case there are still > I/Os in flight: xen_blkif_disconnect() will bail out early without > releasing all resources in the hope it will be called again when > the last request has terminated. This, however, won't happen as > xen_blkif_free() won't be called on termination of the last running > request: xen_blkif_put() won't decrement the blkif refcnt to 0 as > xen_blkif_disconnect() didn't finish before thus some xen_blkif_put() > calls in xen_blkif_disconnect() didn't happen. > > To solve this deadlock xen_blkif_disconnect() and > xen_blkif_alloc_rings() shouldn't use xen_blkif_put() and > xen_blkif_get() but use some other way to do their accounting of > resources. > > This at once fixes another error in xen_blkif_disconnect(): when it > returned early with -EBUSY for another ring than 0 it would call > xen_blkif_put() again for already handled rings on a subsequent call. > This will lead to inconsistencies in the refcnt handling. > > Cc: stable@vger.kernel.org > Signed-off-by: Juergen Gross > Tested-by: Steven Haigh Acked-by: Roger Pau Monn? TBH, it seems like all this accounting in blkback could be improved quite a lot. Right now this is just a complete caos. Thanks, Roger.