From: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
To: Miklos Szeredi <miklos@szeredi.hu>,
Jonathan Corbet <corbet@lwn.net>,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: me@jcix.top, Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
Subject: [PATCH 3/5] fuse: add FOPEN_INVAL_ATTR
Date: Tue, 11 Jul 2023 12:34:03 +0800 [thread overview]
Message-ID: <20230711043405.66256-4-zhangjiachen.jaycee@bytedance.com> (raw)
In-Reply-To: <20230711043405.66256-1-zhangjiachen.jaycee@bytedance.com>
Add FOPEN_INVAL_ATTR so that the fuse daemon can ask kernel to invalidate
the attr cache on file open.
The fi->attr_version should be increased when handling FOPEN_INVAL_ATTR.
Because if a FUSE request returning attributes (getattr, setattr, lookup,
and readdirplus) starts before a FUSE_OPEN replying FOPEN_INVAL_ATTR, but
finishes after the FUSE_OPEN, staled attributes will be set to the inode
and falsely clears the inval_mask.
Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
---
fs/fuse/file.c | 10 ++++++++++
include/uapi/linux/fuse.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index de37a3a06a71..412824a11b7b 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -215,6 +215,16 @@ void fuse_finish_open(struct inode *inode, struct file *file)
file_update_time(file);
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
}
+
+ if (ff->open_flags & FOPEN_INVAL_ATTR) {
+ struct fuse_inode *fi = get_fuse_inode(inode);
+
+ spin_lock(&fi->lock);
+ fi->attr_version = atomic64_inc_return(&fc->attr_version);
+ fuse_invalidate_attr(inode);
+ spin_unlock(&fi->lock);
+ }
+
if ((file->f_mode & FMODE_WRITE) && fc->writeback_cache)
fuse_link_write_file(file);
}
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index b3fcab13fcd3..1a24c11637a4 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -315,6 +315,7 @@ struct fuse_file_lock {
* FOPEN_STREAM: the file is stream-like (no file position at all)
* FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE)
* FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode
+ * FOPEN_INVAL_ATTR: invalidate the attr cache on open
*/
#define FOPEN_DIRECT_IO (1 << 0)
#define FOPEN_KEEP_CACHE (1 << 1)
@@ -323,6 +324,7 @@ struct fuse_file_lock {
#define FOPEN_STREAM (1 << 4)
#define FOPEN_NOFLUSH (1 << 5)
#define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6)
+#define FOPEN_INVAL_ATTR (1 << 7)
/**
* INIT request/reply flags
--
2.20.1
next prev parent reply other threads:[~2023-07-11 4:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 4:34 [PATCH 0/5] FUSE consistency improvements Jiachen Zhang
2023-07-11 4:34 ` [PATCH 1/5] fuse: check attributes staleness on fuse_iget() Jiachen Zhang
2023-08-23 8:57 ` Miklos Szeredi
2023-07-11 4:34 ` [PATCH 2/5] fuse: invalidate dentry on EEXIST creates or ENOENT deletes Jiachen Zhang
2023-08-16 12:27 ` Miklos Szeredi
2023-07-11 4:34 ` Jiachen Zhang [this message]
2023-08-23 9:01 ` [PATCH 3/5] fuse: add FOPEN_INVAL_ATTR Miklos Szeredi
2023-08-23 11:12 ` Jiachen Zhang
2023-07-11 4:34 ` [PATCH 4/5] fuse: writeback_cache consistency enhancement (writeback_cache_v2) Jiachen Zhang
2023-08-23 9:07 ` Miklos Szeredi
2023-08-23 10:35 ` Bernd Schubert
2023-08-23 10:59 ` Jiachen Zhang
2023-08-23 22:55 ` Bernd Schubert
2023-07-11 4:34 ` [PATCH 5/5] docs: fuse: improve FUSE consistency explanation Jiachen Zhang
2023-07-11 4:42 ` Randy Dunlap
2023-07-11 7:15 ` Jiachen Zhang
2023-07-14 5:50 ` [PATCH 0/5] FUSE consistency improvements Jingbo Xu
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=20230711043405.66256-4-zhangjiachen.jaycee@bytedance.com \
--to=zhangjiachen.jaycee@bytedance.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@jcix.top \
--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).