Message ID | 20221111093702.80975-1-zhangjiachen.jaycee@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp643746wru; Fri, 11 Nov 2022 01:46:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4c55Mn5lSWgCA3H+hDL1o2j2g/F3iWgvnZZBRvX7CXhHBvYo8PTs3JZXbKL5APYzgLrFXh X-Received: by 2002:a05:6402:186:b0:461:caa4:4ad3 with SMTP id r6-20020a056402018600b00461caa44ad3mr697837edv.392.1668159968267; Fri, 11 Nov 2022 01:46:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668159968; cv=none; d=google.com; s=arc-20160816; b=vf8PC5Jy4ULIHKrEKKVGobbAp1IWYdxaKuCAvTnLu4HdgIk0UG9fwp48CKde/OYGq2 6PdbgtYGISEejUvXVtpuMfmI6VVtWTP0bgYshVR65Ot+Cujy6jGNrddJf39qfASHrioi 1FwZUdNiZtizTBZ8m4SmS13llC0y5SFAHh+AaVo5ND7wcLakS62fbHjk/7appIco5eh7 rkoQl3CS3iazvZfCQykYkfsnBtUQcWJdOzXmvab7hSZ7tJPJmpqI2eKiW5laQ2muYpDK cWT6SGXK/9GhWVt7lr0bw+BONj3tktxnQ4nc6MRlci93V3CvK+msaH5Fd89uAhg9T9/i n9NA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020aa7cf10000000b00461a98a20cbsi1580746edy.187.2022.11.11.01.45.45; Fri, 11 Nov 2022 01:46:08 -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 <rfc822;winker.wchi@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Fri, 11 Nov 2022 01:37:11 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id k15so4466141pfg.2 for <linux-kernel@vger.kernel.org>; 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 <zhangjiachen.jaycee@bytedance.com> To: Miklos Szeredi <miklos@szeredi.hu> Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749192506947668278?= X-GMAIL-MSGID: =?utf-8?q?1749192506947668278?= |
Series |
fuse: initialize attr_version of new fuse inodes by fc->attr_version
|
|
Commit Message
Jiachen Zhang
Nov. 11, 2022, 9:37 a.m. UTC
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 <zhangjiachen.jaycee@bytedance.com>
---
fs/fuse/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Fri, Nov 11, 2022 at 5:37 PM Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> wrote: > > 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") Ping..., and the Fixes tag should be: Fixes: fbee36b92abc ("fuse: fix uninitialized field in fuse_inode") Best regards, Jiachen > Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> > --- > 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 >
On Thu, 17 Nov 2022 at 09:52, Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> wrote: > > On Fri, Nov 11, 2022 at 5:37 PM Jiachen Zhang > <zhangjiachen.jaycee@bytedance.com> wrote: > > > > 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") > > Ping..., and the Fixes tag should be: > > Fixes: fbee36b92abc ("fuse: fix uninitialized field in fuse_inode") Do you have a reproducer? Thanks, Miklos
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);