Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1376268pxa; Sun, 23 Aug 2020 00:02:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJhd9GBOJtjp7XOllI4Zhl/6uYryn5LXIVmyl4R5LF0VzgK3gIoSiR28uxNaNmQFA5cwdr X-Received: by 2002:a05:6402:17d8:: with SMTP id s24mr182919edy.61.1598166155434; Sun, 23 Aug 2020 00:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598166155; cv=none; d=google.com; s=arc-20160816; b=JZjNfVn/sAtmDkszsNRGZ7uTbwKHNtuga7Dx5CpE8PAOkBbRORRYvQbG3szdhAr+Ip JXpuYhPLc4hj85eTYkFphDHOfa1k1MWrOYIFj6DZW8aRafbOVvCjnMonuRB9FWLLDgm8 dpdxVHr5LZlZBItfI5wp6eOCM7FSYkEZhqKTMr+Se38VW4DsEgF+AYPvXmhz4+PLybrl vOcAc+E7yflOx9XsnKkWTHJXpy9RnCgBY+rAmvkVNn83gj5z+6QI77ynTM6N98HXZDtd cUkaPsevYtnfP6wRXkLOJH4I9Tl8IjJlnTSOe3cTywRlR9463qGZ4wmmYfRyPc2ssOQz g35Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=qbIPnD27e0itRAMA/0BaZ6nUgsN7RuGniuA1f/auliM=; b=mfNozjcchp4umVRkpCxGK0o7QbeLXnS9UN6njWKgY6Ymo+CvGKITfUf6W6GLmOTI7C X1jBqmrERCePavksKUl91ceN0xfOoe1AmBce+Ze4eXtQCHNQBQtWXNFcxsiWjIoTHuak 2dxm2hmQl+e/iyX6L+/gEMGaPV8fSywmjvsd0E/qCuxvhf1461Twm7rUwmZ0+eM7iMF2 tGCY4a3b9Nfu0j9nZAv1vxPZkAzlImDJfRgC64finnNi8BEK2kIx6eNM0ORsYT/rXU9Y Gwwr5onmJNfE3E3VzEEeruKx34E1lb8Ap8x7Fls7tb7Zhg7OZH5TGOHz6gSZ2ZjTz70l IjuQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si4428581ejc.304.2020.08.23.00.02.11; Sun, 23 Aug 2020 00:02:35 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbgHWGyR (ORCPT + 99 others); Sun, 23 Aug 2020 02:54:17 -0400 Received: from mga18.intel.com ([134.134.136.126]:64468 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbgHWGyP (ORCPT ); Sun, 23 Aug 2020 02:54:15 -0400 IronPort-SDR: nH2ICmNsAsOXVWXH85bDjkwzluQayNTl8YJRbU3cHTQREeUZGt3TLicbqFF3ChoFFj/uQBYBzY KxCS4xmqNYxA== X-IronPort-AV: E=McAfee;i="6000,8403,9721"; a="143416653" X-IronPort-AV: E=Sophos;i="5.76,343,1592895600"; d="scan'208";a="143416653" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2020 23:54:15 -0700 IronPort-SDR: yAKzVZKnxtG1XrG//rBh0HhVBuobazBb3eMJ1t0SVyhJPMMJsHGpHS66FsXpDlnjI3yFWpYkZj 0xMaBbsVeQkQ== X-IronPort-AV: E=Sophos;i="5.76,343,1592895600"; d="scan'208";a="442804294" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2020 23:54:14 -0700 Date: Sat, 22 Aug 2020 23:54:14 -0700 From: Ira Weiny To: Hao Li 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: <20200823065413.GA535011@iweiny-DESK2.sc.intel.com> References: <20200821015953.22956-1-lihao2018.fnst@cn.fujitsu.com> <20200821174040.GG3142014@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200821174040.GG3142014@iweiny-DESK2.sc.intel.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > > 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 > > > > > >