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 [thread overview]
Message-ID: <20221111093702.80975-1-zhangjiachen.jaycee@bytedance.com> (raw)
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(-)
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
next reply other threads:[~2022-11-11 9:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 9:37 Jiachen Zhang [this message]
2022-11-17 8:52 ` [PATCH] fuse: initialize attr_version of new fuse inodes by fc->attr_version Jiachen Zhang
2023-02-01 15:54 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111093702.80975-1-zhangjiachen.jaycee@bytedance.com \
--to=zhangjiachen.jaycee@bytedance.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).