From nobody Tue Feb 10 07:21:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64DCBC001B0 for ; Tue, 11 Jul 2023 04:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjGKEhi (ORCPT ); Tue, 11 Jul 2023 00:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbjGKEhA (ORCPT ); Tue, 11 Jul 2023 00:37:00 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44221BF for ; Mon, 10 Jul 2023 21:36:35 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-55b1238a024so4014135a12.0 for ; Mon, 10 Jul 2023 21:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1689050195; x=1691642195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3XAHhhESlWk2lPaujVBvLDXmvRjl2svsri3z2wXZkLk=; b=M8vGYeHoV98HxtEMd30yZy8J3vsp1gg2UT4CLif35qX5VjoffNTseSfCyCPQjIFXd3 jMXsnIN0y93aH99CbAOqK1hQE2WTk+EnG39KFI93kZTddE/ujIniiOVaxFJ9l2l4vTyy jxxAVfv4neMTtiBhVY1x1UCTGNus5SOkXaix/+VzLqJK/JlnU4Kcb8D4gfAGDEfpfMVG INTIy7c3kT1rRA6/vEmVG6JIAT+juFpfwpk2RuCHm+yuEJpr/Ig5n/5eBGCmRW1nx2i7 F2KVD16LtUYKJ7l7HCE+eVrlVLVXKFzfR62F3qHP5TSypqeEUutFNuq7rPM8cbnX+yk3 c8kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689050195; x=1691642195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3XAHhhESlWk2lPaujVBvLDXmvRjl2svsri3z2wXZkLk=; b=IEGKAWhVlNlWdspghGIZvPWt8H65FCY1xZMicXzy1syD5BWW34tAPdPSf+VF6o5hLk nw7jkq1yuBbo7GF3NFU2cVW2sd07jqH2xiEKojdv93msd65uQMc4dktK6/4q5PRuB/QP wukyxSqyA4e5fu+cjlHPidf81yursmeDTz75Trcw/55HNavsxJU6qOK+EqAKnlCVtKdM AOFeMHhZdZB5wv5sHjCzNTdTJqy3emOdDLm3EUHw+G3/5VcwOPedznbxzkEh2f837Hmu ZsjWJLuqjOuMkKOpPZNZdAMYV2iZdwEGUd3RR5y+yDxSn2FK2Tgal7VGP3xxkXLAAnwe ho4Q== X-Gm-Message-State: ABy/qLZz4TRRLSHegsBUWe2ucJdxBV40agyZVrOYX6ss9I37dR6nHaed 1gxvlXOhFzsMwfBV23uWtQf5lg== X-Google-Smtp-Source: APBJJlHVXHi5H4pyAltoj/82qhz5I3Bsfho9pJLgbS3udUMYxFnBreB2K43EEK98etc5oZFkabl6Ow== X-Received: by 2002:a17:902:b117:b0:1b3:e90b:93e1 with SMTP id q23-20020a170902b11700b001b3e90b93e1mr13910557plr.36.1689050194747; Mon, 10 Jul 2023 21:36:34 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id ij9-20020a170902ab4900b001b9de67285dsm755259plb.156.2023.07.10.21.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 21:36:34 -0700 (PDT) From: Jiachen Zhang To: Miklos Szeredi , Jonathan Corbet , linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: me@jcix.top, Jiachen Zhang Subject: [PATCH 2/5] fuse: invalidate dentry on EEXIST creates or ENOENT deletes Date: Tue, 11 Jul 2023 12:34:02 +0800 Message-Id: <20230711043405.66256-3-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230711043405.66256-1-zhangjiachen.jaycee@bytedance.com> References: <20230711043405.66256-1-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The EEXIST errors returned from server are strong sign that a local negative dentry should be invalidated. Similarly, The ENOENT errors from server can also be a sign of revalidate failure. This commit invalidates dentries on EEXIST creates and ENOENT deletes by calling fuse_invalidate_entry(), which improves the consistency with no performance degradation. Signed-off-by: Jiachen Zhang --- fs/fuse/dir.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 5a4a7155cf1c..cfe38ee91ffd 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -755,7 +755,8 @@ static int fuse_atomic_open(struct inode *dir, struct d= entry *entry, if (err =3D=3D -ENOSYS) { fc->no_create =3D 1; goto mknod; - } + } else if (err =3D=3D -EEXIST) + fuse_invalidate_entry(entry); out_dput: dput(res); return err; @@ -835,6 +836,8 @@ static int create_new_entry(struct fuse_mount *fm, stru= ct fuse_args *args, return 0; =20 out_put_forget_req: + if (err =3D=3D -EEXIST) + fuse_invalidate_entry(entry); kfree(forget); return err; } @@ -986,7 +989,7 @@ static int fuse_unlink(struct inode *dir, struct dentry= *entry) if (!err) { fuse_dir_changed(dir); fuse_entry_unlinked(entry); - } else if (err =3D=3D -EINTR) + } else if (err =3D=3D -EINTR || err =3D=3D -ENOENT) fuse_invalidate_entry(entry); return err; } @@ -1009,7 +1012,7 @@ static int fuse_rmdir(struct inode *dir, struct dentr= y *entry) if (!err) { fuse_dir_changed(dir); fuse_entry_unlinked(entry); - } else if (err =3D=3D -EINTR) + } else if (err =3D=3D -EINTR || err =3D=3D -ENOENT) fuse_invalidate_entry(entry); return err; } @@ -1050,7 +1053,7 @@ static int fuse_rename_common(struct inode *olddir, s= truct dentry *oldent, /* newent will end up negative */ if (!(flags & RENAME_EXCHANGE) && d_really_is_positive(newent)) fuse_entry_unlinked(newent); - } else if (err =3D=3D -EINTR) { + } else if (err =3D=3D -EINTR || err =3D=3D -ENOENT) { /* If request was interrupted, DEITY only knows if the rename actually took place. If the invalidation fails (e.g. some process has CWD under the renamed --=20 2.20.1