From: Joanne Koong <joannelkoong@gmail.com>
To: miklos@szeredi.hu
Cc: amir73il@gmail.com, fuse-devel@lists.linux.dev, luis@igalia.com
Subject: [PATCH v1 15/17] fuse: add passthrough setattr
Date: Mon, 20 Apr 2026 15:16:35 -0700 [thread overview]
Message-ID: <20260420221637.2631478-16-joannelkoong@gmail.com> (raw)
In-Reply-To: <20260420221637.2631478-1-joannelkoong@gmail.com>
Add passthrough setattr for setting the attributes directly on a
backing inode via notify_change() instead of issuing a FUSE_SETATTR
request to the server.
After updating the backing inode, sync the fuse inode's vfs-visible
attributes with a passthrough getattr (which is guaranteed to be
supported, as getattr must be passed through in order to use inode
passthrough) so that it matches the attributes of the backing file.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/dir.c | 3 +++
fs/fuse/fuse_i.h | 3 ++-
fs/fuse/passthrough.c | 31 +++++++++++++++++++++++++++++++
include/uapi/linux/fuse.h | 1 +
4 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ff9a92d8a496..6dea0f8e384f 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -2546,6 +2546,9 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
if (!attr->ia_valid)
return 0;
+ if (fuse_inode_passthrough_op(inode, FUSE_SETATTR))
+ return fuse_passthrough_setattr(inode, attr);
+
ret = fuse_do_setattr(idmap, entry, attr, file);
if (!ret) {
/*
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index daf7b664e1b9..d722382676e2 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1571,7 +1571,7 @@ void fuse_file_release(struct inode *inode, struct fuse_file *ff,
/* Inode passthrough operations for backing file attached to inode */
#define FUSE_PASSTHROUGH_INODE_OPS \
- (FUSE_PASSTHROUGH_OP_GETATTR)
+ (FUSE_PASSTHROUGH_OP_GETATTR | FUSE_PASSTHROUGH_OP_SETATTR)
#define FUSE_BACKING_MAP_OP(map, op) \
((map)->ops_mask & FUSE_PASSTHROUGH_OP(op))
@@ -1683,6 +1683,7 @@ static inline bool fuse_inode_passthrough_op(struct inode *inode,
int fuse_passthrough_getattr(struct inode *inode, struct kstat *stat,
u32 request_mask, unsigned int flags);
+int fuse_passthrough_setattr(struct inode *inode, struct iattr *attr);
static inline bool fuse_use_entry2(struct fuse_conn *fc)
{
diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
index 8ecce2a97ee8..c70478f07d6a 100644
--- a/fs/fuse/passthrough.c
+++ b/fs/fuse/passthrough.c
@@ -9,6 +9,7 @@
#include <linux/file.h>
#include <linux/backing-file.h>
+#include <linux/posix_acl.h>
#include <linux/splice.h>
static void fuse_file_accessed(struct file *file)
@@ -251,3 +252,33 @@ int fuse_passthrough_getattr(struct inode *inode, struct kstat *stat,
return 0;
}
+
+int fuse_passthrough_setattr(struct inode *inode, struct iattr *attr)
+{
+ struct fuse_conn *fc = get_fuse_conn(inode);
+ struct fuse_inode *fi = get_fuse_inode(inode);
+ struct fuse_backing *fb = fuse_inode_passthrough(fi);
+ const struct cred *old_cred;
+ struct dentry *backing_entry = fb->file->f_path.dentry;
+ struct mnt_idmap *backing_idmap = mnt_idmap(fb->file->f_path.mnt);
+ int err;
+
+ old_cred = override_creds(fb->cred);
+ inode_lock(d_inode(backing_entry));
+ err = notify_change(backing_idmap, backing_entry, attr, NULL);
+ inode_unlock(d_inode(backing_entry));
+ revert_creds(old_cred);
+
+ if (err)
+ return err;
+
+ if (fc->posix_acl)
+ forget_all_cached_acls(inode);
+
+ /*
+ * Sync the fuse inode's cached attributes with the backing inode after
+ * updating the backing inode's attributes. The fuse inode's vfs-visible
+ * fields need to be in sync with the backing inode
+ */
+ return fuse_passthrough_getattr(inode, NULL, STATX_BASIC_STATS, 0);
+}
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 3963631558f9..040fee549bb9 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -1158,6 +1158,7 @@ struct fuse_backing_map {
#define FUSE_PASSTHROUGH_OP_WRITE FUSE_PASSTHROUGH_OP(FUSE_WRITE)
#define FUSE_PASSTHROUGH_OP_READDIR FUSE_PASSTHROUGH_OP(FUSE_READDIR)
#define FUSE_PASSTHROUGH_OP_GETATTR FUSE_PASSTHROUGH_OP(FUSE_GETATTR)
+#define FUSE_PASSTHROUGH_OP_SETATTR FUSE_PASSTHROUGH_OP(FUSE_SETATTR)
/* Device ioctls: */
#define FUSE_DEV_IOC_MAGIC 229
--
2.52.0
next prev parent reply other threads:[~2026-04-20 22:18 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 22:16 [PATCH v1 00/17] fuse: extend passthrough to inode operations Joanne Koong
2026-04-20 22:16 ` [PATCH v1 01/17] fuse: introduce FUSE_PASSTHROUGH_INO mode Joanne Koong
2026-04-21 21:11 ` Darrick J. Wong
2026-04-21 23:38 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 02/17] fuse: prepare for passthrough of inode operations Joanne Koong
2026-04-21 21:16 ` Darrick J. Wong
2026-04-22 1:12 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 03/17] fuse: prepare for readdir passthrough on directories Joanne Koong
2026-04-21 21:17 ` Darrick J. Wong
2026-04-21 23:12 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 04/17] fuse: implement passthrough for readdir Joanne Koong
2026-04-20 22:16 ` [PATCH v1 05/17] fuse: prepare for long lived reference on backing file Joanne Koong
2026-04-20 22:16 ` [PATCH v1 06/17] fuse: implement passthrough for getattr/statx Joanne Koong
2026-04-20 22:16 ` [PATCH v1 07/17] fuse: prepare to setup backing inode passthrough on lookup Joanne Koong
2026-04-20 22:16 ` [PATCH v1 08/17] fuse: add passthrough ops gating Joanne Koong
2026-04-21 10:48 ` Amir Goldstein
2026-04-22 2:57 ` Joanne Koong
2026-04-22 7:27 ` Amir Goldstein
2026-04-23 1:47 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 09/17] fuse: prepare to cache statx attributes from entry replies Joanne Koong
2026-04-21 12:26 ` Amir Goldstein
2026-04-20 22:16 ` [PATCH v1 10/17] fuse: add struct fuse_entry2_out and helpers for extended " Joanne Koong
2026-04-21 12:25 ` Amir Goldstein
2026-04-22 0:50 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 11/17] fuse: add passthrough lookup Joanne Koong
2026-04-21 13:23 ` Amir Goldstein
2026-04-22 3:17 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 12/17] fuse: add passthrough support for entry creation Joanne Koong
2026-04-21 14:08 ` Amir Goldstein
2026-04-22 3:01 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 13/17] fuse: add passthrough support for atomic file creation Joanne Koong
2026-04-21 19:51 ` Amir Goldstein
2026-04-22 0:40 ` Joanne Koong
2026-04-22 5:10 ` Amir Goldstein
2026-04-20 22:16 ` [PATCH v1 14/17] fuse: use passthrough getattr in setattr suid/sgid handling Joanne Koong
2026-04-21 14:25 ` Amir Goldstein
2026-04-22 3:48 ` Joanne Koong
2026-04-22 5:22 ` Amir Goldstein
2026-04-23 0:03 ` Joanne Koong
2026-04-20 22:16 ` Joanne Koong [this message]
2026-04-21 14:20 ` [PATCH v1 15/17] fuse: add passthrough setattr Amir Goldstein
2026-04-21 14:32 ` Amir Goldstein
2026-04-22 1:09 ` Joanne Koong
2026-04-20 22:16 ` [PATCH v1 16/17] fuse: add passthrough open Joanne Koong
2026-04-21 20:20 ` Amir Goldstein
2026-04-22 4:19 ` Joanne Koong
2026-04-22 4:23 ` Joanne Koong
2026-04-22 6:51 ` Amir Goldstein
2026-04-20 22:16 ` [PATCH v1 17/17] docs: fuse: document extended passthrough (FUSE_PASSTHROUGH_INO) Joanne Koong
2026-04-21 11:09 ` Amir Goldstein
2026-04-22 1:04 ` Joanne Koong
2026-04-21 9:37 ` [PATCH v1 00/17] fuse: extend passthrough to inode operations Amir Goldstein
2026-04-21 13:55 ` Amir Goldstein
2026-04-21 21:05 ` Joanne Koong
2026-04-22 6:02 ` Amir Goldstein
2026-04-23 1:02 ` Joanne Koong
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=20260420221637.2631478-16-joannelkoong@gmail.com \
--to=joannelkoong@gmail.com \
--cc=amir73il@gmail.com \
--cc=fuse-devel@lists.linux.dev \
--cc=luis@igalia.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.