From patchwork Tue Jul 11 04:34:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiachen Zhang X-Patchwork-Id: 118253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp250321vqm; Mon, 10 Jul 2023 22:09:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlHF5nwfYD4YplPgMG4FN/pD//TQKF4eBDbVxcIUFz6kW6HwhLPhjxAg/BJVtcTlWkagolzo X-Received: by 2002:a17:906:1089:b0:993:f4cd:34b5 with SMTP id u9-20020a170906108900b00993f4cd34b5mr8764091eju.29.1689052185939; Mon, 10 Jul 2023 22:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689052185; cv=none; d=google.com; s=arc-20160816; b=orK+w8k/wGc2H/tTSeCkv7zq1jt8s0iDTWDeF/N/35WRBNZ/1n3Fa01W+vGpzu/wBm Lxtwf2C/621MoyU0gN3y3Txr3iIOvgz7RthCsznngDWcgNVVD0KB9U2u4BQTEba5+R2B aeVC132hMOR6R5b7ij6OfndqIc1XU6Yx53HGF2Hps60goQqNFm5KjFi9VbFqX9fSlBXD u6XckeayWhnA6/iS0wi79tRJLnYjbzcD7gvcEor/sQpuUIofGXDXzhdDq+1PmSSkn8Cr CpQCTHv4C8elxYRMU4HHJV7alu4+OEaqbd2B82KHeM+S5SSuLp9VkMHoxOX+dntXQvlC 9+Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3XAHhhESlWk2lPaujVBvLDXmvRjl2svsri3z2wXZkLk=; fh=AbZLXPTwDd6D4T6qkHRVC4qv5VyfsE5N5bMl5jebUv8=; b=BN752kYP488BtHVVDIT7iCdfUMNu+Cof47O6UTSK+PUj36iSyDk54mguMFxe1T78bR Jl/9IAvjGK1g8o1ncz1PS3fXolMSG6aAOOSI6cicNYqzKJPLFKU+gnRDiVb5fU+5inFy 6+LABHMGfYoBJMEUlkms2VNHLyxWGeXOWxNVoeEUje5oJ/K3Dy68c8uDsIh/Z9PypjQq oKRccv1eHrkI6aGr/9I01PrjFnXI69wECqG7/BBoSatbtH/2nYJCpLFiO5DTeAmRHpWY hcB40Ne164OlDJIp6VqkdkuBPd6tq/jPUH2Y5kEamQuibkgUwuU7Wdv9HzMixQ/vPpIa ZIfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=M8vGYeHo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cd18-20020a170906b35200b00992ac86148bsi1245932ejb.265.2023.07.10.22.09.22; Mon, 10 Jul 2023 22:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=M8vGYeHo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbjGKEhh (ORCPT + 99 others); Tue, 11 Jul 2023 00:37:37 -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-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771099584626535367 X-GMAIL-MSGID: 1771099584626535367 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 dentry *entry, if (err == -ENOSYS) { fc->no_create = 1; goto mknod; - } + } else if (err == -EEXIST) + fuse_invalidate_entry(entry); out_dput: dput(res); return err; @@ -835,6 +836,8 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, return 0; out_put_forget_req: + if (err == -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 == -EINTR) + } else if (err == -EINTR || err == -ENOENT) fuse_invalidate_entry(entry); return err; } @@ -1009,7 +1012,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) if (!err) { fuse_dir_changed(dir); fuse_entry_unlinked(entry); - } else if (err == -EINTR) + } else if (err == -EINTR || err == -ENOENT) fuse_invalidate_entry(entry); return err; } @@ -1050,7 +1053,7 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent, /* newent will end up negative */ if (!(flags & RENAME_EXCHANGE) && d_really_is_positive(newent)) fuse_entry_unlinked(newent); - } else if (err == -EINTR) { + } else if (err == -EINTR || err == -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