Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp716238rwd; Thu, 25 May 2023 02:57:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FUGetcU6h9Gq/jtr8qqdvadvfYA7xPmzxg5I2oWE78wn4wnqpS7HiB49U1uFb3tKu/pcN X-Received: by 2002:a17:902:d512:b0:1a9:80a0:47ef with SMTP id b18-20020a170902d51200b001a980a047efmr1313901plg.20.1685008656529; Thu, 25 May 2023 02:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685008656; cv=none; d=google.com; s=arc-20160816; b=tDYFOSzc8wLpI1DokEGRyqWdeVBgnSY3haASF8CULnO5VJlcujycLzWoppjhPSkWAy ELjQFPpy8Gwm7FHO865BPIgnH3jKgVSRh+bVSxQRVbOspjGKwrGIBDObzgk8dvviSGkG Wc6+1UywIVhWD6POcePrQ0hmbmuUxO01qy/wZ9EQHOytEFlLdulkRHP97gI07PIr/Kcn BQluU5I9pMpsJzpzpp19V7fNRxeecdrU00yyHAbip+azHQOnKuvKDO63fFlbU6EBcKXJ lTrUkJSS8RUxPGZsvNYkUfJUD0RqhqDHhn3KoH2Cm/eZZCjfaC0mSjd1+H7nbgaS9QL/ s37Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KFZI0jrvSnP8i73jOgPau2f4uBHJqNU4q0kHLQiJIwk=; b=ojf6hr2UZBvlAA3fQiFWXB7Ssp+m1P895Ut4CARCchwaTVyqDtMWjkGfHhdZDhJ0Ai +u/HaSfAuKRIMk8cgY/rftmwFzY4TsbWbmKhU+qierd8cshCk85Gsp3Agb96VrR7M+mM /M+lWoeboxG9mPozYj6Y9EPrbOHrQqfbIt2tz69+7YoJxLkEoa0ET9e4dfqn5SfS+4o2 ajG5Lofe/Cu5CPdpgACnUVtih3xbKFDJ5BX6JQXSuMc1yUIeWAl17dcyzRUxckt/DD7M QdpfvtC4dpXjDJdjZFFELXwnUbtNbSZOa27kHHo4Ha4xvgB9Ju/huG56gJ+oU35PhKUM TGXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=G7sduiF1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a170902bd9700b001ab13c7505asi191638pls.125.2023.05.25.02.57.23; Thu, 25 May 2023 02:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=G7sduiF1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240302AbjEYJuO (ORCPT + 99 others); Thu, 25 May 2023 05:50:14 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.