fuse: restructure requests extensions handling
Subsystems (2)
v2 cover fuse: restructure requests extensions handling
Hi!
I'm sending v2 of this patch after finding an issue with function fuse_free_ext(). The issue was that this function was freeing the ->value for all the ext args, which isn't what I wanted -- now it only frees it for FUSE_EXT_GROUPS extentions. While there, I've also added back the immediate return if there are no extensions.
And for reference, here's the origin text from v1:
This patch was going to be included in the lookup_handle patchset. But since it is self-contained and it can eventually be picked independently, I've decided to send it as a separate RFC.
It basically re-implements the idea of extensions, making it easier to add new ones: a extension can be simply added to the 'ext_args' array in fuse_args.
Luis Henriques (1):
fuse: restructure requests extensions handling
fs/fuse/dev.c | 35 ++++++++++++++- fs/fuse/dir.c | 108 ++++++++++++++++++++++------------------------- fs/fuse/fuse_i.h | 11 ++++- 3 files changed, 93 insertions(+), 61 deletions(-)
RFC PATCH v2 1/1 fuse: restructure requests extensions handling
This commit simplifies the implementation of extensions by using an extensions vector just like the other (in/out) args.
This simplification includes reverting the handling of security contexts back into a regular inarg, as it was done before commit 15d937d7ca8c ("fuse: add request extension").
--- fs/fuse/dev.c | 35 ++++++++++++++- fs/fuse/dir.c | 108 ++++++++++++++++++++++------------------------- fs/fuse/fuse_i.h | 11 ++++- 3 files changed, 93 insertions(+), 61 deletions(-)
fs/fuse/dev.c +33 -2
@@ -654,8 +654,15 @@ static void fuse_args_to_req(struct fuse_req *req, struct fuse_args *args) req->in.h.opcode = args->opcode; req->in.h.nodeid = args->nodeid; req->args = args; -if (args->is_ext) - req->in.h.total_extlen = args->in_args[args->ext_idx].size /8 ; +if (args->has_ext) { +int i; + + req->in.h.total_extlen = +sizeof (struct fuse_ext_header ) * args->numext; +for (i =0 ; i < args->numext; i++) + req->in.h.total_extlen += args->ext_args[i].size; + req->in.h.total_extlen /=8 ; + }if (args->end)__set_bit (FR_ASYNC , &req->flags); }
@@ -1226,6 +1233,28 @@ int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs,return err; } +static int fuse_copy_extensions (struct fuse_copy_state *cs, +struct fuse_args *args) +{ +struct fuse_ext_header xh; +struct fuse_ext_arg *arg; +int err =0 ; +int i; + +for (i =0 ; !err && i < args->numext; i++) { + arg = &args->ext_args[i]; + xh.size = arg->size; + xh.type = arg->type; +/* Copy extension header... */ + err =fuse_copy_one (cs, &xh,sizeof (xh)); +if (!err) +/* ... and payload */ + err =fuse_copy_one (cs, arg->value, arg->size); + } + +return err; +} +static int forget_pending (struct fuse_iqueue *fiq) {return fiq->forget_list_head.next !=NULL ;
@@ -1497,6 +1526,8 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,if (!err) err =fuse_copy_args (cs, args->in_numargs, args->in_pages, (struct fuse_arg *) args->in_args,0 ); +if (!err) + err =fuse_copy_extensions (cs, args);fuse_copy_finish (cs);spin_lock (&fpq->lock);clear_bit (FR_LOCKED , &req->flags);
fs/fuse/dir.c +51 -57
169 lines not on this page · raw message
fs/fuse/fuse_i.h +9 -2
@@ -326,12 +326,18 @@ struct fuse_folio_desc {unsigned int offset; }; +struct fuse_ext_arg { +unsigned int type; +unsigned int size; +void *value; +}; +struct fuse_args {uint64_t nodeid;uint32_t opcode;uint8_t in_numargs;uint8_t out_numargs; -uint8_t ext_idx; +uint8_t numext;bool force:1 ;bool noreply:1 ;bool nocreds:1 ;
@@ -342,10 +348,11 @@ struct fuse_args { bool page_zeroing:1; bool page_replace:1; bool may_block:1; - bool is_ext:1; + bool has_ext:1; bool is_pinned:1; bool invalidate_vmap:1;struct fuse_in_arg in_args[4 ]; +struct fuse_ext_arg ext_args[2 ];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 */