Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp936515yba; Wed, 15 May 2019 12:34:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7m9JSRbfeqW/PmJKjKq8tlqKTh+myLuBybx8edkncVtyXul3iwOOQxA04gHQBh+AqNSlV X-Received: by 2002:a63:778b:: with SMTP id s133mr45715774pgc.198.1557948879536; Wed, 15 May 2019 12:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557948879; cv=none; d=google.com; s=arc-20160816; b=XfEzs9gaSkLtlOI6KgkXBoFXxtuMmM2NK6H1juerpgN3EEcXX4uxCh3fM+j+zjWlfJ Dzk+qqZw33jlQsCKUMF8l6X3+9ijBaac8zi2f6/7Tk/drLQ3Z/MZboZUe2sC7lwxKj8c dc37sOAVZ/hCQeHMyxujXPmEe697gNpKqSO7OGnrCjO1oy8oXC87+aKQqFiAA59EU3qg 5cKGT44vCVrvfqCzLF/KJiuyffG6cvhWJ5sGRdED2DGSxOLM62eh5Hx/rY7E4YV6TdEG etbK//RqZSzS8ddrI3Nd8TjPdw+4DDXG/yYhMff6e+qWfXJnZlt3aCWG3e3h4B4aXSYT r1sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=j03cwytKRPAoggyA3IWCFzWl3pg2s//DdQ38Cxd5gwk=; b=CEtNKsWF7lsIo2To5lc9K/DEH1guMVBMM4tVPRE02hegKkEs0e0mBW/qw5cIfEOpgv uz/SgPLaXUlJvuVGM2RcuarILBg4OK08Rf09MN1RzVy3DOYu6F1p4F23ENagSRo7911k Gu3EqeCSZZFCJk04VcKgd1N4pBwIHbW63ZZF7uPACB2Ef5c6QsOYFnEOA1pDnq9woLb1 5tcZpDHwSpInTiRHvYSuqkobwYCnNWXHueOMVR655AEb05Bew8M72e2kOTTCPW6y5GMy YzIMxljIB+Xn78QwJaY2QfoyDNO/S3m6FnsazbKQBSFiYQeU44a5S6gT9h09jt1pSZOE NWBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si1355567plm.343.2019.05.15.12.34.24; Wed, 15 May 2019 12:34:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728351AbfEOTbi (ORCPT + 99 others); Wed, 15 May 2019 15:31:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34970 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfEOT1c (ORCPT ); Wed, 15 May 2019 15:27:32 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8022EC0703C6; Wed, 15 May 2019 19:27:32 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6AF419C71; Wed, 15 May 2019 19:27:29 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 5C4D322063D; Wed, 15 May 2019 15:27:29 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-nvdimm@lists.01.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, swhiteho@redhat.com Subject: [PATCH v2 01/30] fuse: delete dentry if timeout is zero Date: Wed, 15 May 2019 15:26:46 -0400 Message-Id: <20190515192715.18000-2-vgoyal@redhat.com> In-Reply-To: <20190515192715.18000-1-vgoyal@redhat.com> References: <20190515192715.18000-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 15 May 2019 19:27:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi Don't hold onto dentry in lru list if need to re-lookup it anyway at next access. More advanced version of this patch would periodically flush out dentries from the lru which have gone stale. Signed-off-by: Miklos Szeredi --- fs/fuse/dir.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index dd0f64f7bc06..fd8636e67ae9 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -29,12 +29,26 @@ union fuse_dentry { struct rcu_head rcu; }; -static inline void fuse_dentry_settime(struct dentry *entry, u64 time) +static void fuse_dentry_settime(struct dentry *dentry, u64 time) { - ((union fuse_dentry *) entry->d_fsdata)->time = time; + /* + * Mess with DCACHE_OP_DELETE because dput() will be faster without it. + * Don't care about races, either way it's just an optimization + */ + if ((time && (dentry->d_flags & DCACHE_OP_DELETE)) || + (!time && !(dentry->d_flags & DCACHE_OP_DELETE))) { + spin_lock(&dentry->d_lock); + if (time) + dentry->d_flags &= ~DCACHE_OP_DELETE; + else + dentry->d_flags |= DCACHE_OP_DELETE; + spin_unlock(&dentry->d_lock); + } + + ((union fuse_dentry *) dentry->d_fsdata)->time = time; } -static inline u64 fuse_dentry_time(struct dentry *entry) +static inline u64 fuse_dentry_time(const struct dentry *entry) { return ((union fuse_dentry *) entry->d_fsdata)->time; } @@ -255,8 +269,14 @@ static void fuse_dentry_release(struct dentry *dentry) kfree_rcu(fd, rcu); } +static int fuse_dentry_delete(const struct dentry *dentry) +{ + return time_before64(fuse_dentry_time(dentry), get_jiffies_64()); +} + const struct dentry_operations fuse_dentry_operations = { .d_revalidate = fuse_dentry_revalidate, + .d_delete = fuse_dentry_delete, .d_init = fuse_dentry_init, .d_release = fuse_dentry_release, }; -- 2.20.1