From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39B3FC7EE2C for ; Thu, 25 May 2023 09:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240590AbjEYJuP (ORCPT ); Thu, 25 May 2023 05:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232749AbjEYJuM (ORCPT ); Thu, 25 May 2023 05:50:12 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B5A5197 for ; Thu, 25 May 2023 02:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KFZI0jrvSnP8i73jOgPau2f4uBHJqNU4q0kHLQiJIwk=; b=G7sduiF1N7/mNC2HnetFtqFaxt BUcKM04q3z55SQjhS5mX6ujntAykMlhBipyJ8yJd2ofjoUjHODiIDxpdoXIVbCOlMYtp63RmwP3IQ MRRhftNZ9kuvYiybyYSt1ZlgD2Pm2Ompcxn5dSsDxC/cnAW/WbHQZi8u0C8oyQ/5gxPsuOfKJwqk3 kYHW/cEIHGxenupsPYfbBhCombPEEUtrd/Lb3WjIIbpiHDnMPp3UAbdKAxD+HAZMibtP2I7VfLybh aArXBg+ocWd7JuKSveCDb48pXvHm65JMC2kGe2RvzJUOEW3FCVJCBLaeTSTip/Pgi085R5pf1bMdz QZcwBkJg==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q27bj-00GBmU-0Z; Thu, 25 May 2023 09:50:07 +0000 Date: Thu, 25 May 2023 02:50:07 -0700 From: "hch@infradead.org" To: Vincent Whitchurch Cc: "hch@infradead.org" , kernel , "vigneshr@ti.com" , "linux-kernel@vger.kernel.org" , "miquel.raynal@bootlin.com" , "richard@nod.at" , "linux-mtd@lists.infradead.org" Subject: Re: [PATCH 2/2] ubi: block: Fix deadlock on remove Message-ID: References: <20230523-ubiblock-remove-v1-0-240bed75849b@axis.com> <20230523-ubiblock-remove-v1-2-240bed75849b@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 24, 2023 at 01:36:39PM +0000, Vincent Whitchurch wrote: > On Tue, 2023-05-23 at 23:04 -0700, Christoph Hellwig wrote: > > If you imlement ->free_disk, the list_del and kfree can move into > > that, and we don't really care if a new opener raced with the delete. > > Moving the kfree() to ->free_disk() works, but the list_del() still > needs to be in ubiblock_remove() since otherwise ubiblock_remove() could > attempt to remove the same device twice. Or we'd still need your removed flag.. > I assumed the current code really wanted to prevent new openers racing > with delete, but if that is not needed, yes, we don't need to add a > ->removing flag if we move the kfree() to ->free_disk(). I'll re-spin > this based on your suggestions. Thanks. I think in the past we always had to protect against removals of live devices because handling of hot removes sucked so bad, both in drivers and in the block layer itself. With some newer infrastructure including the ->free_disk method this can now be handled sanely.