mirror of
https://github.com/torvalds/linux.git
synced 2025-04-09 14:45:27 +00:00
fuse: make args->in_args[0] to be always the header
This change sets up FUSE operations to always have headers in args.in_args[0], even for opcodes without an actual header. This step prepares for a clean separation of payload from headers, initially it is used by fuse-over-io-uring. For opcodes without a header, we use a zero-sized struct as a placeholder. This approach: - Keeps things consistent across all FUSE operations - Will help with payload alignment later - Avoids future issues when header sizes change Op codes that already have an op code specific header do not need modification. Op codes that have neither payload nor op code headers are not modified either (FUSE_READLINK and FUSE_DESTROY). FUSE_BATCH_FORGET already has the header in the right place, but is not using fuse_copy_args - as -over-uring is currently not handling forgets it does not matter for now, but header separation will later need special attention for that op code. Correct the struct fuse_args->in_args array max size. Signed-off-by: Bernd Schubert <bschubert@ddn.com> Reviewed-by: Joanne Koong <joannelkoong@gmail.com> Reviewed-by: Luis Henriques <luis@igalia.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
a7040a06e4
commit
7ccd86ba3a
@ -240,11 +240,12 @@ static int fuse_send_removemapping(struct inode *inode,
|
||||
|
||||
args.opcode = FUSE_REMOVEMAPPING;
|
||||
args.nodeid = fi->nodeid;
|
||||
args.in_numargs = 2;
|
||||
args.in_args[0].size = sizeof(*inargp);
|
||||
args.in_args[0].value = inargp;
|
||||
args.in_args[1].size = inargp->count * sizeof(*remove_one);
|
||||
args.in_args[1].value = remove_one;
|
||||
args.in_numargs = 3;
|
||||
fuse_set_zero_arg0(&args);
|
||||
args.in_args[1].size = sizeof(*inargp);
|
||||
args.in_args[1].value = inargp;
|
||||
args.in_args[2].size = inargp->count * sizeof(*remove_one);
|
||||
args.in_args[2].value = remove_one;
|
||||
return fuse_simple_request(fm, &args);
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1746,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
|
||||
args = &ap->args;
|
||||
args->nodeid = outarg->nodeid;
|
||||
args->opcode = FUSE_NOTIFY_REPLY;
|
||||
args->in_numargs = 2;
|
||||
args->in_numargs = 3;
|
||||
args->in_pages = true;
|
||||
args->end = fuse_retrieve_end;
|
||||
|
||||
@ -1774,9 +1774,10 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
|
||||
}
|
||||
ra->inarg.offset = outarg->offset;
|
||||
ra->inarg.size = total_len;
|
||||
args->in_args[0].size = sizeof(ra->inarg);
|
||||
args->in_args[0].value = &ra->inarg;
|
||||
args->in_args[1].size = total_len;
|
||||
fuse_set_zero_arg0(args);
|
||||
args->in_args[1].size = sizeof(ra->inarg);
|
||||
args->in_args[1].value = &ra->inarg;
|
||||
args->in_args[2].size = total_len;
|
||||
|
||||
err = fuse_simple_notify_reply(fm, args, outarg->notify_unique);
|
||||
if (err)
|
||||
|
@ -175,9 +175,10 @@ static void fuse_lookup_init(struct fuse_conn *fc, struct fuse_args *args,
|
||||
memset(outarg, 0, sizeof(struct fuse_entry_out));
|
||||
args->opcode = FUSE_LOOKUP;
|
||||
args->nodeid = nodeid;
|
||||
args->in_numargs = 1;
|
||||
args->in_args[0].size = name->len + 1;
|
||||
args->in_args[0].value = name->name;
|
||||
args->in_numargs = 2;
|
||||
fuse_set_zero_arg0(args);
|
||||
args->in_args[1].size = name->len + 1;
|
||||
args->in_args[1].value = name->name;
|
||||
args->out_numargs = 1;
|
||||
args->out_args[0].size = sizeof(struct fuse_entry_out);
|
||||
args->out_args[0].value = outarg;
|
||||
@ -928,11 +929,12 @@ static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
FUSE_ARGS(args);
|
||||
|
||||
args.opcode = FUSE_SYMLINK;
|
||||
args.in_numargs = 2;
|
||||
args.in_args[0].size = entry->d_name.len + 1;
|
||||
args.in_args[0].value = entry->d_name.name;
|
||||
args.in_args[1].size = len;
|
||||
args.in_args[1].value = link;
|
||||
args.in_numargs = 3;
|
||||
fuse_set_zero_arg0(&args);
|
||||
args.in_args[1].size = entry->d_name.len + 1;
|
||||
args.in_args[1].value = entry->d_name.name;
|
||||
args.in_args[2].size = len;
|
||||
args.in_args[2].value = link;
|
||||
return create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK);
|
||||
}
|
||||
|
||||
@ -992,9 +994,10 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry)
|
||||
|
||||
args.opcode = FUSE_UNLINK;
|
||||
args.nodeid = get_node_id(dir);
|
||||
args.in_numargs = 1;
|
||||
args.in_args[0].size = entry->d_name.len + 1;
|
||||
args.in_args[0].value = entry->d_name.name;
|
||||
args.in_numargs = 2;
|
||||
fuse_set_zero_arg0(&args);
|
||||
args.in_args[1].size = entry->d_name.len + 1;
|
||||
args.in_args[1].value = entry->d_name.name;
|
||||
err = fuse_simple_request(fm, &args);
|
||||
if (!err) {
|
||||
fuse_dir_changed(dir);
|
||||
@ -1015,9 +1018,10 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
|
||||
|
||||
args.opcode = FUSE_RMDIR;
|
||||
args.nodeid = get_node_id(dir);
|
||||
args.in_numargs = 1;
|
||||
args.in_args[0].size = entry->d_name.len + 1;
|
||||
args.in_args[0].value = entry->d_name.name;
|
||||
args.in_numargs = 2;
|
||||
fuse_set_zero_arg0(&args);
|
||||
args.in_args[1].size = entry->d_name.len + 1;
|
||||
args.in_args[1].value = entry->d_name.name;
|
||||
err = fuse_simple_request(fm, &args);
|
||||
if (!err) {
|
||||
fuse_dir_changed(dir);
|
||||
|
@ -310,7 +310,7 @@ struct fuse_args {
|
||||
bool is_ext:1;
|
||||
bool is_pinned:1;
|
||||
bool invalidate_vmap:1;
|
||||
struct fuse_in_arg in_args[3];
|
||||
struct fuse_in_arg in_args[4];
|
||||
struct fuse_arg out_args[2];
|
||||
void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error);
|
||||
/* Used for kvec iter backed by vmalloc address */
|
||||
@ -947,6 +947,19 @@ struct fuse_mount {
|
||||
struct rcu_head rcu;
|
||||
};
|
||||
|
||||
/*
|
||||
* Empty header for FUSE opcodes without specific header needs.
|
||||
* Used as a placeholder in args->in_args[0] for consistency
|
||||
* across all FUSE operations, simplifying request handling.
|
||||
*/
|
||||
struct fuse_zero_header {};
|
||||
|
||||
static inline void fuse_set_zero_arg0(struct fuse_args *args)
|
||||
{
|
||||
args->in_args[0].size = sizeof(struct fuse_zero_header);
|
||||
args->in_args[0].value = NULL;
|
||||
}
|
||||
|
||||
static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb)
|
||||
{
|
||||
return sb->s_fs_info;
|
||||
|
@ -164,9 +164,10 @@ int fuse_removexattr(struct inode *inode, const char *name)
|
||||
|
||||
args.opcode = FUSE_REMOVEXATTR;
|
||||
args.nodeid = get_node_id(inode);
|
||||
args.in_numargs = 1;
|
||||
args.in_args[0].size = strlen(name) + 1;
|
||||
args.in_args[0].value = name;
|
||||
args.in_numargs = 2;
|
||||
fuse_set_zero_arg0(&args);
|
||||
args.in_args[1].size = strlen(name) + 1;
|
||||
args.in_args[1].value = name;
|
||||
err = fuse_simple_request(fm, &args);
|
||||
if (err == -ENOSYS) {
|
||||
fm->fc->no_removexattr = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user