Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3334656pxb; Tue, 20 Apr 2021 06:10:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyKIiRpBXqWJfk7heln+XTi36nD3Lp0n9oCL9CMT0Se1SpyORSd9mFlgc0EFMeSbMMkkGN X-Received: by 2002:a17:90a:2ac8:: with SMTP id i8mr4700893pjg.112.1618924249465; Tue, 20 Apr 2021 06:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618924249; cv=none; d=google.com; s=arc-20160816; b=R9Tg5TDwd+ujYKtXafqtMbWPMQUI13o566dhIi0K59pO3yHUaO33R5RDs9mNZTPdLZ zIQ1pcLvpTRmNhn3fJ9I7OL5dbV4urGe3v+HvOa2nAPtumdU47z8ZM3N34ePQiUpCAUj QJnJZluQh4YZvMLmAap3DSKAr8BL3tg66NR8JVS+tcmE02edsdI+sh3eI3X2igSF0W18 F+GPUOBU8+96Jpx2zNL9FTzpTY2iBbXKsRxNzxc9fqdkq7TZlbsiS/huEmDR1qy84NgB 5QvHrWpCyMeRqucolXsUsRXsZhI+cNKFHSho02AhRlPOWie1Y5YPyK7zQOXzijicZe2h 5AHg== 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=5H40PE5FcAXJU/1G1fCYEUxn7MUJo40J/cmcx9Vjp6w=; b=G7UfoyarVLSokg3rQGvE/RcT5tx1UlEE3CNlc9c9KaR2R7DxGfMWdDEMJxzQfNChsA BuZJwM8rDIiLZpCsxpq5Atu4nYAaVnSJWf0XbqAA7tedE58unfVzE04k3wx1waV7l4BD mVqgExrZ4zTndhamsuKrC7Ragw42Lz0Gr88UFZUP6OHkUkV74pNUhoSRRbTmUxwYBK7y LK1Di1S4CwvvFGrcZoJszEcOzkPYGRnxvRJwWCNohCQytdn3WHu22L7D2ZkaBU9qMV0x E8fedqyUbf82ctvcKr5RueZBVG9C5wNoUl38oIHXYy6ORhf3tkqYfmhIg2ZbDS8TzVgh TEBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h7rhL0Az; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si10411068plg.323.2021.04.20.06.10.32; Tue, 20 Apr 2021 06:10:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h7rhL0Az; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbhDTNLC (ORCPT + 99 others); Tue, 20 Apr 2021 09:11:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbhDTNLA (ORCPT ); Tue, 20 Apr 2021 09:11:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F91AC06174A; Tue, 20 Apr 2021 06:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=5H40PE5FcAXJU/1G1fCYEUxn7MUJo40J/cmcx9Vjp6w=; b=h7rhL0AzG0XZAn3uA00HxKS2gn yU+d2LbmMY9S6yr8REVTlnMRYlvIDeu3I0FZ6Fbr0dbFqcgEw1kfzlxhqPs3r0q1/Wy0GiKJkvPrQ KkmrZhN6lLJkEXb19wsDdOQb/5FyE8ytcamAsPKaA/vf0512Okjj8ICplUF0ZyxX+d4UwRjcQf1oN Soy2Irdjht2QLrSzEWaPJxl2QAPohrp+2A9qxxSKS+xgnpbaq1MD3lsiC15sO8UH/pQtlYAFkP2Nv HEqKpzZxzaZ/07LTuqWe6LKVIyfeFc+Mcs+ezAWfEMAY3k/+r2Jgmzg8TXJoDwRbwy5vn2aGbty0t larHU3og==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7N-00FBfz-7j; Tue, 20 Apr 2021 13:08:59 +0000 Date: Tue, 20 Apr 2021 14:08:41 +0100 From: Christoph Hellwig To: Zhang Yi Cc: Christoph Hellwig , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com Subject: Re: [RFC PATCH v2 7/7] ext4: fix race between blkdev_releasepage() and ext4_put_super() Message-ID: <20210420130841.GA3618564@infradead.org> References: <20210414134737.2366971-1-yi.zhang@huawei.com> <20210414134737.2366971-8-yi.zhang@huawei.com> <20210415145235.GD2069063@infradead.org> 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 casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Apr 16, 2021 at 04:00:48PM +0800, Zhang Yi wrote: > Now, we use already use "if (bdev->bd_super)" to prevent call into > ->bdev_try_to_free_page unless the super is alive, and the problem is > bd_super becomes NULL concurrently after this check. So, IIUC, I think it's > the same to switch to check the superblock is active or not. The acvive > flag also could becomes inactive (raced by umount) after we call into > bdev_try_to_free_page(). Indeed. > In order to close this race, One solution is introduce a lock to synchronize > the active state between kill_block_super() and blkdev_releasepage(), but > the releasing page process have to try to acquire this lock in > blkdev_releasepage() for each page, and the umount process still need to wait > until the page release if some one invoke into ->bdev_try_to_free_page(). > I think this solution may affect performace and is not a good way. > Think about it in depth, use percpu refcount seems have the smallest > performance effect on blkdev_releasepage(). > > If you don't like the refcount, maybe we could add synchronize_rcu_expedited() > in ext4_put_super(), it also could prevent this race. Any suggestions? I really don't like to put a lot of overhead into the core VFS and block device code. ext4/jbd does not own the block device inode and really has no business controlling releasepage for it. I suspect the right answer might be to simply revert the commit that added this hook.