Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1860001ybe; Tue, 3 Sep 2019 04:43:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXIsJUAGrevqHYPg8nC8mS5UY+1yUmAYN07CeBMdg9Fil7COKfQfucEmT5jSGst+WdhBkA X-Received: by 2002:a63:6f41:: with SMTP id k62mr30070136pgc.32.1567511016433; Tue, 03 Sep 2019 04:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567511016; cv=none; d=google.com; s=arc-20160816; b=p3WDFhHWxOZFbZcO4Z/4fnHfuLmoLvQ/NQaHXTa80nalizjxW6M0jPguly8Uau8br3 D9gnh1crUpuWxgmT3hHk4U4743EufmkjDNVDZxPLrqRsfhNY/ODwGO9gmcnEE3QSbaiG tjmaEAVr0oH5qLOUjOjjn705YfA7E8UMrpa2ty7KMgusvgCSj6ml5KTZzoFR+mDft22h OSNgYsSA6qxAFwSmhHhkGp4Z5Fy6p2Pdfe23jXPUqss/h7khyu5qmFOjmy8cjq7A58F7 oudF/QM/5ROeEqx2LkmYp74WL+sBwc49DDOFOhn2NW+RTjlRY4T3dAaEe3SX9j6UayY1 SvXQ== 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=5kfQ4yDR8IW4hcJwhws0bc8ZuR6GN0FcetPuWp0WccA=; b=S0FO/7i7aPRP1Z0Itsq4e1DAtG3S+kESqmDRuYRK0PdN7Ygx4NXR8FMid9zuHNuSZA NZ3KBCfGZNICDmX7+D4O0/ZNC+dieHbarYNn/Z46TMZ8a/sMiGKPQTnJxawF7x6t3S/N 5q79ZR2lXL5X7q2pHq0T1qHdhZvtWziAXRa44HoWlykEhymTZ1AGym9zsG7soTFNY8lK bnVSzAk3UQmqFs1Tc9I2lSDGrWtPeWV5fafY5kblmslgUj21/28ng8+YfMqHx9GARP6o PFYj44Knc9zwF+3qih5H4D7dOyY1Qrr6nup9WCp1MrMAn2r2X+8Ga2Ki3EHNpmzyjjyS 7jhw== 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 k15si14794017pgj.216.2019.09.03.04.43.21; Tue, 03 Sep 2019 04:43:36 -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 S1729134AbfICLmX (ORCPT + 99 others); Tue, 3 Sep 2019 07:42:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54994 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729089AbfICLmQ (ORCPT ); Tue, 3 Sep 2019 07:42:16 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D4CC5AFD9 for ; Tue, 3 Sep 2019 11:42:15 +0000 (UTC) Received: by mail-wr1-f72.google.com with SMTP id t16so10331178wro.3 for ; Tue, 03 Sep 2019 04:42:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5kfQ4yDR8IW4hcJwhws0bc8ZuR6GN0FcetPuWp0WccA=; b=jMhEmg0Dgkei+YIpzePnLVY64dEq+xgdHzHIl7CBpFx+awXSThbgZyccde/1+eL5cl 42g1XPKnsdGvfWlFnSir+Y3lEldvzv2JfKtRxXXxDIFGegd8EGVzYEJJ/2ibkCBKU/ZR 4qGX/nYfHJyjl6lSkEUpFHOsDIr3RLJ484rRx3NHIdy1a4CAkiH50Lut9GXwqBQ9y2/f LMdRFidnXnLEhEgre1sbYbbR5kxi8cwDZVRuLRlDQIJMsdZubjg47rqmW19+DoJ0x4JI fFW862FVT5dgjiMcLIxOvaMpuC8AC3vplrvQjQRf/xcM2UkBvw+h2+Jmq1osUZ2ejjlT WTiA== X-Gm-Message-State: APjAAAU8RkuJgnAgBGNVwWAfCF21P81suWiyCpD5oauu681wujBuet8N PcWlqPPVlw89x2BRjoWpu0kvY2ordQyit194hVgMdsSb71XFFbDFBZGgOE2roPyHQzb0gTglman JKyopchrgJzhePGlIr/e5r4vQ X-Received: by 2002:a05:6000:108e:: with SMTP id y14mr13758528wrw.344.1567510934411; Tue, 03 Sep 2019 04:42:14 -0700 (PDT) X-Received: by 2002:a05:6000:108e:: with SMTP id y14mr13758506wrw.344.1567510934231; Tue, 03 Sep 2019 04:42:14 -0700 (PDT) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id x6sm2087551wmf.38.2019.09.03.04.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 04:42:13 -0700 (PDT) From: Miklos Szeredi To: virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Michael S. Tsirkin" , Stefan Hajnoczi , Vivek Goyal , "Dr. David Alan Gilbert" Subject: [PATCH v4 12/16] fuse: delete dentry if timeout is zero Date: Tue, 3 Sep 2019 13:41:59 +0200 Message-Id: <20190903114203.8278-7-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903113640.7984-1-mszeredi@redhat.com> References: <20190903113640.7984-1-mszeredi@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't hold onto dentry in lru list if need to re-lookup it anyway at next access. Only do this if explicitly enabled, otherwise it could result in performance regression. 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 | 28 +++++++++++++++++++++++++--- fs/fuse/fuse_i.h | 3 +++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index dd0f64f7bc06..d44f11ac22ec 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -29,12 +29,28 @@ 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; + struct fuse_conn *fc = get_fuse_conn_super(dentry->d_sb); + bool delete = !time && fc->delete_stale; + /* + * 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 ((!delete && (dentry->d_flags & DCACHE_OP_DELETE)) || + (delete && !(dentry->d_flags & DCACHE_OP_DELETE))) { + spin_lock(&dentry->d_lock); + if (!delete) + 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 +271,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, }; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 21a2e86bbdf2..700df42520ec 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -780,6 +780,9 @@ struct fuse_conn { /** Does the filesystem support copy_file_range? */ unsigned no_copy_file_range:1; + /* Delete dentries that have gone stale */ + unsigned int delete_stale:1; + /** The number of requests waiting for completion */ atomic_t num_waiting; -- 2.21.0