Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: Hao Li <lihao2018.fnst@cn.fujitsu.com>
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
Date: Sat, 22 Aug 2020 23:54:14 -0700	[thread overview]
Message-ID: <20200823065413.GA535011@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20200821174040.GG3142014@iweiny-DESK2.sc.intel.com>

On Fri, Aug 21, 2020 at 10:40:41AM -0700, 'Ira Weiny' 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.
> 
> This looks intriguing and I really hope this helps but I don't think this will
> guarantee that the state changes immediately will it?
> 
> Do you have a test case which fails before and passes after?  Perhaps one of
> the new xfstests submitted by Xiao?

Ok I just went back and read your comment before.[1]  Sorry for being a bit
slow on the correlation between this patch and that email.  (BTW, I think it
would have been good to put those examples in the commit message and or
reference that example.)  I'm assuming that with this patch example 2 from [1]
works without a drop_cache _if_ no other task has the file open?

Anyway, with that explanation I think you are correct that this improves the
situation _if_ the only references on the file is controlled by the user and
they have indeed closed all of them.

The code for DCACHE_DONTCACHE as I attempted to write it was that it should
have prevented further caching of the inode such that the inode would evict
sooner.  But it seems you have found a bug/optimization?

In the end, however, if another user (such as a backup running by the admin)
has a reference the DAX change may still be delayed.  So I'm thinking the
documentation should remain largely as is?  But perhaps I am wrong.  Does this
completely remove the need for a drop_caches or only in the example you gave?
Since I'm not a FS expert I'm still not sure.

Regardless, thanks for the fixup!  :-D
Ira

[1] https://lore.kernel.org/linux-xfs/ba98b77e-a806-048a-a0dc-ca585677daf3@cn.fujitsu.com/

> 
> Ira
> 
> > 
> > Signed-off-by: Hao Li <lihao2018.fnst@cn.fujitsu.com>
> > ---
> >  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;
> >  
> >  	/* 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);
> >  
> > -- 
> > 2.28.0
> > 
> > 
> > 

  reply	other threads:[~2020-08-23  6:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21  1:59 Hao Li
2020-08-21 17:40 ` Ira Weiny
2020-08-23  6:54   ` Ira Weiny [this message]
2020-08-24  6:17     ` Li, Hao
2020-08-26 10:06       ` Li, Hao
2020-08-27  6:37 ` Dave Chinner
2020-08-27  9:58   ` Li, Hao
2020-08-28  0:35     ` Dave Chinner
2020-08-28  9:04       ` Li, Hao
2020-08-31  0:34         ` Dave Chinner
2020-08-31  9:45           ` Li, Hao
2020-11-10  2:59 Hao Li
2020-12-08  2:10 Hao Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200823065413.GA535011@iweiny-DESK2.sc.intel.com \
    --to=ira.weiny@intel.com \
    --cc=lihao2018.fnst@cn.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y-goto@fujitsu.com \
    --subject='Re: [PATCH] fs: Kill DCACHE_DONTCACHE dentry even if DCACHE_REFERENCED is set' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).