Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp831270pxa; Thu, 27 Aug 2020 17:36:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5LPJ3n1Ac09yO5hA2b8cG8lI9h8L69jK99pTDgYGKlF23wh2cliWjpwSxeohUjs/UnsWC X-Received: by 2002:a17:906:410d:: with SMTP id j13mr23236280ejk.139.1598575007114; Thu, 27 Aug 2020 17:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598575007; cv=none; d=google.com; s=arc-20160816; b=wsXSJWhMzBf1UiTJUQvu5d+skVY8RnVZsGjbavMHY/okul6a3T9AQB2rG1lbRLHGvb KaBT+FXWbrI3jUBmYeT+/Vqnr/nyc3ZXjzkN1ljz+Ix0iBkOed9Lkg6wboPg1znkduE6 5NaArRvQUp9ED/3A/VrPyEmY2h3ypcfSIlXfd/ele/shQCFgICdfiqzWxVwaSMyzS+Ka KYITmY0SajzFKALklPsG/NbPWHerH2ZIaufT763KsUpa39AHIpvlNSXBOm5ffGjM9GkW 43KxTga2kA2byNOWODzjgGRpwcZx3k3/jhiZcQKCKjIzdpOXoUXGdVwKco9/E8PaeV7f WuZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=xRDs1oEqTp7Y5dKBAS/AxIDlPbPTzqwvzzDiH4cOOHU=; b=IRm9+3Vh2OE3c6f0KPqNRyiqCNMT+XmTB97cmsEhxti6CWlpCkyR7hHjIp9GWpDULV AZ1oFGXUnetfaBTxz5F5LYDRVcP2y3R/DOgG0S0znO0Joo9SgK/I30MsgCecqDSKIVva 3u5sBesflv9/fom7Jshax/hRzvq2A861CWHpzvdKwY7A21fLL8ksgOB6p1HWCCyiIfEC ClFq8AqYKN79DqdG4ZuephDQZyqjFLtQwipVPbb3FmGWzmogCm9ekU+vrqrVEDNte/t1 v0m/dKIbEcbAyasAVSChtk9S8KACYEGVKXJ7YQR2WCa5vqDOW16+HAYjJi1txWtr8h1W Lh4w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 25si2775383ejl.76.2020.08.27.17.36.23; Thu, 27 Aug 2020 17:36:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728114AbgH1Afq (ORCPT + 99 others); Thu, 27 Aug 2020 20:35:46 -0400 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:36716 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbgH1Afq (ORCPT ); Thu, 27 Aug 2020 20:35:46 -0400 Received: from dread.disaster.area (pa49-181-146-199.pa.nsw.optusnet.com.au [49.181.146.199]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id C82003A7122; Fri, 28 Aug 2020 10:35:42 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1kBSMn-0007ec-DX; Fri, 28 Aug 2020 10:35:41 +1000 Date: Fri, 28 Aug 2020 10:35:41 +1000 From: Dave Chinner To: "Li, Hao" Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, y-goto@fujitsu.com Subject: Re: [PATCH] fs: Kill DCACHE_DONTCACHE dentry even if DCACHE_REFERENCED is set Message-ID: <20200828003541.GD12096@dread.disaster.area> References: <20200821015953.22956-1-lihao2018.fnst@cn.fujitsu.com> <20200827063748.GA12096@dread.disaster.area> <6b3b3439-2199-8f00-ceca-d65769e94fe0@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b3b3439-2199-8f00-ceca-d65769e94fe0@cn.fujitsu.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=IuRgj43g c=1 sm=1 tr=0 cx=a_idp_d a=GorAHYkI+xOargNMzM6qxQ==:117 a=GorAHYkI+xOargNMzM6qxQ==:17 a=kj9zAlcOel0A:10 a=y4yBn9ojGxQA:10 a=omOdbC7AAAAA:8 a=7-415B0cAAAA:8 a=4EakmT0XTRVUVr4ZEt4A:9 a=CjuIK1q_8ugA:10 a=baC4JDFNLZpnPwus_NF9:22 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 05:58:07PM +0800, Li, Hao wrote: > On 2020/8/27 14:37, Dave Chinner wrote: > > On Fri, Aug 21, 2020 at 09:59:53AM +0800, Hao Li wrote: > >> Currently, DCACHE_REFERENCED prevents the dentry with DCACHE_DONTCACHE > >> set from being killed, so the corresponding inode can't be evicted. If > >> the DAX policy of an inode is changed, we can't make policy changing > >> take effects unless dropping caches manually. > >> > >> This patch fixes this problem and flushes the inode to disk to prepare > >> for evicting it. > >> > >> Signed-off-by: Hao Li > >> --- > >> fs/dcache.c | 3 ++- > >> fs/inode.c | 2 +- > >> 2 files changed, 3 insertions(+), 2 deletions(-) > >> > >> diff --git a/fs/dcache.c b/fs/dcache.c > >> index ea0485861d93..486c7409dc82 100644 > >> --- a/fs/dcache.c > >> +++ b/fs/dcache.c > >> @@ -796,7 +796,8 @@ static inline bool fast_dput(struct dentry *dentry) > >> */ > >> smp_rmb(); > >> d_flags = READ_ONCE(dentry->d_flags); > >> - d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST | DCACHE_DISCONNECTED; > >> + d_flags &= DCACHE_REFERENCED | DCACHE_LRU_LIST | DCACHE_DISCONNECTED > >> + | DCACHE_DONTCACHE; > > Seems reasonable, but you need to update the comment above as to > > how this flag fits into this code.... > > Yes. I will change it. Thanks. > > > > >> /* Nothing to do? Dropping the reference was all we needed? */ > >> if (d_flags == (DCACHE_REFERENCED | DCACHE_LRU_LIST) && !d_unhashed(dentry)) > >> diff --git a/fs/inode.c b/fs/inode.c > >> index 72c4c347afb7..5218a8aebd7f 100644 > >> --- a/fs/inode.c > >> +++ b/fs/inode.c > >> @@ -1632,7 +1632,7 @@ static void iput_final(struct inode *inode) > >> } > >> > >> state = inode->i_state; > >> - if (!drop) { > >> + if (!drop || (drop && (inode->i_state & I_DONTCACHE))) { > >> WRITE_ONCE(inode->i_state, state | I_WILL_FREE); > >> spin_unlock(&inode->i_lock); > > What's this supposed to do? We'll only get here with drop set if the > > filesystem is mounting or unmounting. > > The variable drop will also be set to True if I_DONTCACHE is set on > inode->i_state. > Although mounting/unmounting will set the drop variable, it won't set > I_DONTCACHE if I understand correctly. As a result, > drop && (inode->i_state & I_DONTCACHE) will filter out mounting/unmounting. So what does this have to do with changing the way the dcache treats DCACHE_DONTCACHE? Also, if I_DONTCACHE is set, but the inode has also been unlinked or is unhashed, should we be writing it back? i.e. it might have been dropped for a different reason to I_DONTCACHE.... IOWs, if there is a problem with how I_DONTCACHE is being handled, then the problem must already exists regardless of the DCACHE_DONTCACHE behaviour, right? So shouldn't this be a separate bug fix with it's own explanation of the problem and the fix? Cheers, Dave. -- Dave Chinner david@fromorbit.com