Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1898637rwb; Fri, 11 Nov 2022 01:58:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7WHjfwGVBh/H1xi+hqbEtFD/W8Lm7YonvSwtUZyVdacXzFZMPzfcxeOkbuGFTCWp/gAcrJ X-Received: by 2002:a63:5248:0:b0:46b:1590:2625 with SMTP id s8-20020a635248000000b0046b15902625mr942819pgl.569.1668160693949; Fri, 11 Nov 2022 01:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668160693; cv=none; d=google.com; s=arc-20160816; b=l7ROHwPf0O5euocbr9S35tGr+xTKtSaCmiYGjPs4l5+O91eJEgBbiScS3UblsQdhR7 SELfyIbNXLXXFV7xL7AMrSLL0E+gJJ47W0LsC+WbeqX2h/n8aDlp4qWlZk1Mqt83Qld9 P/2VPMNoVOUojZMB6EoT3abgF6rX4wVhi3NECsF4Y+5ZhVnJ8lcGR3S7p4hJ6pvg221o e3HBDXWCdbfCflIfFzcb7q+FBf+AqXIAAHSOtADyEnTxa8Ry9fHWrE8fafAhpQzY5qWd K9SogxuKBO+mlFCNp2yx1ZSQub8LUMdYFltrb4qowqTciyDhEvoBE/qbdw05+MP/Rm2A PsCQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=AmA/wiGTgxxSgV/ULL1vm+H9tlQ/4RzcG0V6hjmLS9I=; b=TxiY+hfRwuOiD2WSvXVGKg9VU8M4cr9820blL825rKOZhIQp9PtSC/5cPnBicrkiVt nNCxzBUiHlbukwt0xcKvsjQt42MOYB3sSPDZzOL6W+LgImEOu7LzRssyBLNZDQD/J80v ezpZBR2eXzVtayMAtkfQRfQD2H/q0kAHEgbYdetoW9Ez4xSZg+pZpLIy6gAcp0INHF0G QWbxrQAJn2qcgj9X9O7C2mIvpvRv3PIyKvVwuKs1NBvPCeZdLBnHq1BwjFm4DEAo79sV aJbihI/8F8KcCISNaY2JlySA5Wdvu0/kWhvUqsgOJzRgTyeh1JEg0R6SFN0fjpMAq2um /TDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=XVKz1JCS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 65-20020a621544000000b0056b8f6cd527si1738855pfv.61.2022.11.11.01.58.01; Fri, 11 Nov 2022 01:58:13 -0800 (PST) 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.20210112.gappssmtp.com header.s=20210112 header.b=XVKz1JCS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbiKKJhO (ORCPT + 92 others); Fri, 11 Nov 2022 04:37:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232955AbiKKJhM (ORCPT ); Fri, 11 Nov 2022 04:37:12 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C62036EB41 for ; Fri, 11 Nov 2022 01:37:11 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id k15so4466141pfg.2 for ; Fri, 11 Nov 2022 01:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AmA/wiGTgxxSgV/ULL1vm+H9tlQ/4RzcG0V6hjmLS9I=; b=XVKz1JCSIPdyUUo4gQ9rUzrRy5HmEp3kpsdg8K3eHfOkirx8584NyU5vkmNzO4M5VQ LW/XMA4X6QzDnJNA0aHHUM+z0S9D68b35PtTAF2iJ6iC+FAS/QdVq7i/Yvri6cVknKVU eu3bkntCNFzkROvqz92xT2UYE4op15fKXzX0Q0RedU9TkzIgRtURCeSAQmAhvVFuWvzF 4GLOwvr0iBJVgYi9cQU0Boxnnwnd89oJbyI+uokfQV/iyUaznyEqZ9E/2D+haC5umf7Z OPoHBkFXp3Gx5H6A4YZuvUytErrRs1vaUgOSOY4Vc4VLfw62W7z5XfQOYB+aTT+FJo19 byIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AmA/wiGTgxxSgV/ULL1vm+H9tlQ/4RzcG0V6hjmLS9I=; b=Uw9FmCtUKwym0gjESWMW3foGelbsUeziHTFQJmEGgukO7E4jbaimrtsAiPVk08H5fi GGbSuURyvczL5cWm3WzbTB5LDkK8jpSqo8EanxLUd2nbWJSvLEy8JJo0ALs96pdkydIM saPi+GjprP40RdaT0Lc9vgr1o0/bVt/4+RplferBu2ybp1SRjgJduMAnOPYNHB03/QJx R7BvNXelmxRA11asp2AxNhVwUc3G/9CW1sCQmjssEM0KTMBySQ9EimgU80kaoeBfJCdC Hi2Net3+EfQGHtyjnrK1x9Tc96fulcjSKkhiuazHODTrdSuTHcLkQ5GfJv8bB/DGd/fC z44Q== X-Gm-Message-State: ANoB5pnTuQimBGiTMQ1ClrSzhkLQ5QalEZxWe09r+poRZTRse8wYt5yk RGXJnSa7XrAZ5tp4Awwr8L79Xw== X-Received: by 2002:aa7:91d8:0:b0:56b:e5de:8b4f with SMTP id z24-20020aa791d8000000b0056be5de8b4fmr1784629pfa.67.1668159431346; Fri, 11 Nov 2022 01:37:11 -0800 (PST) Received: from localhost.localdomain ([61.120.150.75]) by smtp.gmail.com with ESMTPSA id x10-20020a1709029a4a00b001886863c6absm1235641plv.97.2022.11.11.01.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 01:37:10 -0800 (PST) From: Jiachen Zhang To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jiachen Zhang Subject: [PATCH] fuse: initialize attr_version of new fuse inodes by fc->attr_version Date: Fri, 11 Nov 2022 17:37:02 +0800 Message-Id: <20221111093702.80975-1-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 The FUSE_READDIRPLUS request reply handler fuse_direntplus_link() might call fuse_iget() to initialize a new fuse_inode and change its attributes. But as the new fi->attr_version is always initialized with 0, even if the attr_version of the FUSE_READDIRPLUS request has become staled, staled attr may still be set to the new fuse_inode. This may cause file size inconsistency even when a filesystem backend is mounted with a single FUSE mountpoint. This commit fixes the issue by initializing new fuse_inode attr_versions by the global fc->attr_version. This may introduce more FUSE_GETATTR but can avoid weird attributes rollback being seen by users. Fixes: 19332138887c ("fuse: initialize attr_version of new fuse inodes by fc->attr_version") Signed-off-by: Jiachen Zhang --- fs/fuse/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 6b3beda16c1b..145ded6b55af 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -71,6 +71,7 @@ struct fuse_forget_link *fuse_alloc_forget(void) static struct inode *fuse_alloc_inode(struct super_block *sb) { struct fuse_inode *fi; + struct fuse_conn *fc = get_fuse_conn_super(sb); fi = alloc_inode_sb(sb, fuse_inode_cachep, GFP_KERNEL); if (!fi) @@ -80,7 +81,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb) fi->inval_mask = 0; fi->nodeid = 0; fi->nlookup = 0; - fi->attr_version = 0; + fi->attr_version = fuse_get_attr_version(fc); fi->orig_ino = 0; fi->state = 0; mutex_init(&fi->mutex); -- 2.20.1