Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp14138ybl; Wed, 21 Aug 2019 14:00:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRjudWJAT/ZEySsrI/qwZ7t9vJXdxlB7z5jGEYaVFUe+8G+pIpZaHeCJQdvKxNCcdh2UNN X-Received: by 2002:aa7:81d9:: with SMTP id c25mr38430271pfn.255.1566421247126; Wed, 21 Aug 2019 14:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566421247; cv=none; d=google.com; s=arc-20160816; b=w9blKvU8eV/E9DakhAN4UZlEetUsJRPRqqThFGabzNpb7OzCjqlUoMCHqJ7r8AXDpZ t0wEXVbaSuSbjNNyGrRiacjpS3Eln1kUNnAtlPQ8bjsGRBklxH97Pf8Woy5VSVwDfAvL N6SVWjWj/QX4SYZvYrcI2Rp+ICxynh1O2bZZCpcX4e+iWdZuCA7rVFJ99JgZ2tNQaU3Q DYYG5XpBfc5mvgt78ENlBWqJ8Q7WlFgDyP+7PDgXlwmzYrDRLTe8bbW2SZJgDDpRHu5r SnjO6HAboaXLqKglM7DS2jTNUrsy4gRYbDSs7GcET3EjjdUDMcb9kPJWal58JW+OX0Op Yqow== 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=IhK7+wdXtqsX6PTpPQfUqpKJXiLZiTCBByJKr9GCzgT754udllKg76aajcT1K2oj5T eUZSqocFY03aneBuhO/hyH4kwP2f4No7ZN9OTnKFmcrGc0CRzcU8CN02BZ6J7i8+klC6 QWPw8khWkJePiZ34OX968iS9lVGFUdAwLh+XKcdvIlYrq3B9STi6OGba8KbNKBbWs/ua m2bAPDRDGLo+dnp9BK/18qZuuz1BJdOVwalcbGn+NQz8ZfMThNzl2U9y4LB1dNyRmg9Y 8sqYv18BVp1JJ0Vz2DgYpv2atAnES9dCnI++2cNkRNbLqRlc7SfImM2N4Ea6n5vgRakE DvsA== 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 m184si6508595pfb.127.2019.08.21.14.00.32; Wed, 21 Aug 2019 14:00:47 -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 S1730343AbfHURjT (ORCPT + 99 others); Wed, 21 Aug 2019 13:39:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24418 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728044AbfHURiU (ORCPT ); Wed, 21 Aug 2019 13:38:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E112307D930; Wed, 21 Aug 2019 17:38:20 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 126AA60E1C; Wed, 21 Aug 2019 17:38:15 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 9CC60223CFD; Wed, 21 Aug 2019 13:38:14 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, miklos@szeredi.hu Cc: virtio-fs@redhat.com, vgoyal@redhat.com, stefanha@redhat.com, dgilbert@redhat.com, Miklos Szeredi Subject: [PATCH 01/13] fuse: delete dentry if timeout is zero Date: Wed, 21 Aug 2019 13:37:30 -0400 Message-Id: <20190821173742.24574-2-vgoyal@redhat.com> In-Reply-To: <20190821173742.24574-1-vgoyal@redhat.com> References: <20190821173742.24574-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 21 Aug 2019 17:38:20 +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