Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp18649pxy; Thu, 29 Apr 2021 22:42:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgqCEJsJXifk/cFuVdPFtpda+m+em7xcIIGIGcJEUrDWyOK90Gu2qPOPZAPs3eUML+7Bx7 X-Received: by 2002:a17:90b:234d:: with SMTP id ms13mr12925231pjb.152.1619761336908; Thu, 29 Apr 2021 22:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619761336; cv=none; d=google.com; s=arc-20160816; b=OWwjjcpNYi6HzrOXn5Z0F8dJxxRqTTHpOHGYZ8HZbnW7mtGUEN8oA/3dqFYpvmVkIC IOoRQPtMlYlJADHRa5zuxGCGPtYsZXAwN87JuLft8KlEQNTKsGQFE0ophTrdsXqmgics ESL9amqP3PptPgKtAHnIgish3H/06EeGHBTC5R4lUMaDssDluymqWsKi7QhflGXfokiF enkuKx+Dv6J+5axeAD9rP2loRNjKmzqyY2mGhXYN9zxXROFU3coRjYJO04zwjm4VkI82 LATE19FhytHNoGS7P8ruMqN2rwqk8kgg2fGz9cvK+yZ+rHxbGkdF6hUR3sg4nM0/9CeY GS3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=Zx8pZdhiNX5aPOyXUOIzWq8zYQHmuVtq5hGUZrL+hxk=; b=GF3r+r8+fSh2Adbp/mp1OZY18D41IYhCNSFcK0Ty9SlTwQXVxzPLMC2XdxnidxCw6y SBkw6rmw+IDHTzLGUFtrbWydlRydtjpG9/rwk8V/kIitoQ4lD0Muj5TzKApLe7+4TdCk zxpwP0/JXhn81VNYwhGE08gSYJehfVndznm16KbptvdcD7SdztVTNxiBhRlphYhwEBmp ikAuWa4ZNtdj8hm2CzAfmByUgf+A6QMoZyQexY47yoVdQQ7iImwVsM/0/DYAaBp/CY9p kv+pwwduq43c1g/Sypr7+KA1wT9wqkTeczCSq7dWrGa9VCM/PeSlxmnoj+MyfKLHEjCG 47nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=leXLFTKd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si1165425pfr.289.2021.04.29.22.42.04; Thu, 29 Apr 2021 22:42:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20161025 header.b=leXLFTKd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbhD3FmO (ORCPT + 99 others); Fri, 30 Apr 2021 01:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbhD3FmL (ORCPT ); Fri, 30 Apr 2021 01:42:11 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215D8C06174A for ; Thu, 29 Apr 2021 22:41:22 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id x27so33873952qvd.2 for ; Thu, 29 Apr 2021 22:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=Zx8pZdhiNX5aPOyXUOIzWq8zYQHmuVtq5hGUZrL+hxk=; b=leXLFTKdISvneTcPmvgUXPy0vucswWlGanD1F9s2b2AM5ZlSIVmek08Oc6xCvLso+i SdFwKFSs0p3/a0i1XzlDr/VTxcPgVkORFyoRglFCTeGrRFseFEJ+CxlNWsvKUSJXuj29 e2usBGYSeWD10SugISYejx9upWSBnBuzwpRZSo5jq7Kyif963vjzwqVdy+G2OMJsuAIY AMax8Z5vPcJOaLCzLCIgM2y5pYstLLiJMIKgGWoto6LU7i998eaIsejstUfW6WVQ2dsA gJyujCd7bfz6Q8RZH3JjXzcVN0TCeMNA46pWSoZitsTFYxkzrDpr00mzSd75n/k3JNmg 1JWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Zx8pZdhiNX5aPOyXUOIzWq8zYQHmuVtq5hGUZrL+hxk=; b=SVJdQ5PrkEET3Lc9EzIcYAJiaXU/uqHndX6wKmoksAEM9AuIX3FjqhdnxgtYprmNt2 AnBj5nWW8Thkgi7PZqGimO2pVxTYvlBOoMQc1qMzBl1bvRec4acVyswSX/P/kiFskqI4 Dd6K9Yg1t81kC7n5ExV2v8HmORyajc3vZdsXUGPdSYvnZrLqXfrrZGCIFVOrBr39saIH 0gK+rDGHOD1eBuWpq3OtkXSg0hdxh4EUzjzejxdWjCshUB7py8YuB1fCelVTW65s7DbG 5MnqG7COWwMlkLcZLz0Bamvu48OSC1RzPbNKu0uR/yI66OoCe3In7tNGG4mkmiLEWxgB Vk3g== X-Gm-Message-State: AOAM531/GHp6p+Zhmv2LU7BKxQ+NqCWH3RqPsk7PM43jzRJe4uDU0u1G tvoiQgBlB1lxIYJfBz7Lwm/hRg== X-Received: by 2002:a0c:e242:: with SMTP id x2mr3422063qvl.45.1619761281109; Thu, 29 Apr 2021 22:41:21 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a24sm672835qkn.104.2021.04.29.22.41.19 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 29 Apr 2021 22:41:20 -0700 (PDT) Date: Thu, 29 Apr 2021 22:41:05 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Hugh Dickins , Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: BUG_ON(!mapping_empty(&inode->i_data)) In-Reply-To: <20210429211634.de4e0fb98d27b3ab9d05757c@linux-foundation.org> Message-ID: References: <20210331024913.GS351017@casper.infradead.org> <20210401170615.GH351017@casper.infradead.org> <20210402031305.GK351017@casper.infradead.org> <20210402132708.GM351017@casper.infradead.org> <20210402170414.GQ351017@casper.infradead.org> <20210429211634.de4e0fb98d27b3ab9d05757c@linux-foundation.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Apr 2021, Andrew Morton wrote: > > I'm not sure this ever was resolved? It was not resolved: Matthew had prospective fixes for one way in which it could happen, but they did not help the case which still hits my testing (well, I replace the BUG_ON by a WARN_ON, so not hit badly). > > Is it the case that the series "Remove nrexceptional tracking v2" at > least exposed this bug? Yes: makes a BUG out of a long-standing issue not noticed before. > > IOW, what the heck should I do with > > mm-introduce-and-use-mapping_empty.patch > mm-stop-accounting-shadow-entries.patch > dax-account-dax-entries-as-nrpages.patch > mm-remove-nrexceptional-from-inode.patch If Matthew doesn't have a proper fix yet (and it's a bit late for more than an obvious fix), I think those should go in, with this addition: [PATCH] mm: remove nrexceptional from inode: remove BUG_ON clear_inode()'s BUG_ON(!mapping_empty(&inode->i_data)) is unsafe: we know of two ways in which nodes can and do (on rare occasions) get left behind. Until those are fixed, do not BUG_ON() nor even WARN_ON(). Yes, this will then leak those nodes (or the next user of the struct inode may use them); but this has been happening for years, and the new BUG_ON(!mapping_empty) was only guilty of revealing that. A proper fix will follow, but no hurry. Signed-off-by: Hugh Dickins --- fs/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- mmotm/fs/inode.c 2021-04-22 18:30:46.285908982 -0700 +++ linux/fs/inode.c 2021-04-29 22:13:54.096530691 -0700 @@ -529,7 +529,14 @@ void clear_inode(struct inode *inode) */ xa_lock_irq(&inode->i_data.i_pages); BUG_ON(inode->i_data.nrpages); - BUG_ON(!mapping_empty(&inode->i_data)); + /* + * Almost always, mapping_empty(&inode->i_data) here; but there are + * two known and long-standing ways in which nodes may get left behind + * (when deep radix-tree node allocation failed partway; or when THP + * collapse_file() failed). Until those two known cases are cleaned up, + * or a cleanup function is called here, do not BUG_ON(!mapping_empty), + * nor even WARN_ON(!mapping_empty). + */ xa_unlock_irq(&inode->i_data.i_pages); BUG_ON(!list_empty(&inode->i_data.private_list)); BUG_ON(!(inode->i_state & I_FREEING));