Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3885658imu; Mon, 10 Dec 2018 09:19:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/VIIAndxIxc3rzcm55G4sx43alMmmy5QU29KTdjqqoxrkAzscx8gPcjWPLqwcFV6OUvJaFB X-Received: by 2002:a17:902:583:: with SMTP id f3mr13236757plf.202.1544462350757; Mon, 10 Dec 2018 09:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544462350; cv=none; d=google.com; s=arc-20160816; b=J6BHCJ6Y+rAXKPlcPX45GnQkEriJO2dfo1EPNewlRWfH/2DsyuiXUwhJBXtssg5Ndn bmdGBgJu8WHGCLXfx6PrSNn9NnKWRgoobJA6Vg9zP2tllqT+tZtsJM5bdJevYUv5uGUX GviaItfjmPZoisCvqg/0YczoEwpMyXjtkoBZzSjjwPsAwKQQV+kNY6W3qf0q34jl6VMg 1hEGl/6ZR7q3PPAaHmT7Qf2OE/e+G80ySpt9qMA4Ep7vASBZWC8W33EwB1P7t4kWJaoa Vzdy7UG7CKn0gFflL4RIAIhoMC4nM3fS/52k3/UkwY+qmXQdGj4fjL2O+2xlUMxDUmx3 oIWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=FV1euUeC3qKVH8HUvLXhIekAx11Ya4omHaaJeD2lTug=; b=W0u6kRbgiYOzuonpJnxC29H+nQd0UxBYcCsiEswdg8B9unGgxRvWPECrtJUYU6aMmA OFFWv4siByFUK5M5masilDiQnBx+8LlDK5hP3iomZsnPcDRUdO3hvYAZHYcOaBX3Zsds B4yeCpBYmuM5iRgDjLczbjBeIu2mMof762wKo3ieFnYqcbwAhbG4Vx+cTm9m9wgHeJ2L ey7FBsGaVk6LKhGBVexnDluuswtRK0+wjA3ARc2FBsazGNucf7ttDiCuq9Ap59JlhGrp LF+EzIMb9969pos+wk8/HgijAozNIOgsQTZkXBLtGvxFPzxmN3JHcoPb0fecJmOg45r1 zG9Q== 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 g9si11158017plb.54.2018.12.10.09.18.55; Mon, 10 Dec 2018 09:19:10 -0800 (PST) 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 S1728756AbeLJROL (ORCPT + 99 others); Mon, 10 Dec 2018 12:14:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45268 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728654AbeLJRNv (ORCPT ); Mon, 10 Dec 2018 12:13:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F16F71B98; Mon, 10 Dec 2018 17:13:50 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02D695D962; Mon, 10 Dec 2018 17:13:34 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 7E166224269; Mon, 10 Dec 2018 12:13:30 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, sweil@redhat.com, swhiteho@redhat.com Subject: [PATCH 30/52] fuse: delete dentry if timeout is zero Date: Mon, 10 Dec 2018 12:12:56 -0500 Message-Id: <20181210171318.16998-31-vgoyal@redhat.com> In-Reply-To: <20181210171318.16998-1-vgoyal@redhat.com> References: <20181210171318.16998-1-vgoyal@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Dec 2018 17:13:51 +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 47395b0c3b35..b7e6e421f6bb 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; } @@ -270,8 +284,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.13.6