fuse: convert readdir to simple api
authorMiklos Szeredi <mszeredi@redhat.com>
Tue, 10 Sep 2019 13:04:10 +0000 (15:04 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 10 Sep 2019 14:29:49 +0000 (16:29 +0200)
The old fuse_read_fill() helper can be deleted, now that the last user is
gone.

The fuse_io_args struct is moved to fuse_i.h so it can be shared between
readdir/read code.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/file.c
fs/fuse/fuse_i.h
fs/fuse/readdir.c

index ac2323443c0909cf47a523df0f4effde3bff5172..3cb98ff267cfdbcd970152b34ece1e223dc206c6 100644 (file)
@@ -532,42 +532,6 @@ out:
        return err;
 }
 
-void fuse_read_fill(struct fuse_req *req, struct file *file, loff_t pos,
-                   size_t count, int opcode)
-{
-       struct fuse_read_in *inarg = &req->misc.read.in;
-       struct fuse_file *ff = file->private_data;
-
-       inarg->fh = ff->fh;
-       inarg->offset = pos;
-       inarg->size = count;
-       inarg->flags = file->f_flags;
-       req->in.h.opcode = opcode;
-       req->in.h.nodeid = ff->nodeid;
-       req->in.numargs = 1;
-       req->in.args[0].size = sizeof(struct fuse_read_in);
-       req->in.args[0].value = inarg;
-       req->out.argvar = 1;
-       req->out.numargs = 1;
-       req->out.args[0].size = count;
-}
-
-struct fuse_io_args {
-       union {
-               struct {
-                       struct fuse_read_in in;
-                       u64 attr_ver;
-               } read;
-               struct {
-                       struct fuse_write_in in;
-                       struct fuse_write_out out;
-               } write;
-       };
-       struct fuse_args_pages ap;
-       struct fuse_io_priv *io;
-       struct fuse_file *ff;
-};
-
 void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
                         size_t count, int opcode)
 {
index 8f46c5549e572162e56a892332621accab6d5379..4d7cd20967c20c2175d68831eb71c5fa17371bbd 100644 (file)
@@ -830,11 +830,28 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
 
 struct fuse_forget_link *fuse_alloc_forget(void);
 
-/**
+/*
  * Initialize READ or READDIR request
  */
-void fuse_read_fill(struct fuse_req *req, struct file *file,
-                   loff_t pos, size_t count, int opcode);
+struct fuse_io_args {
+       union {
+               struct {
+                       struct fuse_read_in in;
+                       u64 attr_ver;
+               } read;
+               struct {
+                       struct fuse_write_in in;
+                       struct fuse_write_out out;
+               } write;
+       };
+       struct fuse_args_pages ap;
+       struct fuse_io_priv *io;
+       struct fuse_file *ff;
+};
+
+void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
+                        size_t count, int opcode);
+
 
 /**
  * Send OPEN or OPENDIR request
index 56a19faa855db82c9efa7644fe5b876b4dafa1f0..fae025db06f4d4a2a5badc4b5070a2bfc64ef1fc 100644 (file)
@@ -316,62 +316,55 @@ static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
 
 static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx)
 {
-       int plus, err;
-       size_t nbytes;
+       int plus;
+       ssize_t res;
        struct page *page;
        struct inode *inode = file_inode(file);
        struct fuse_conn *fc = get_fuse_conn(inode);
-       struct fuse_req *req;
+       struct fuse_io_args ia = {};
+       struct fuse_args_pages *ap = &ia.ap;
+       struct fuse_page_desc desc = { .length = PAGE_SIZE };
        u64 attr_version = 0;
        bool locked;
 
-       req = fuse_get_req(fc, 1);
-       if (IS_ERR(req))
-               return PTR_ERR(req);
-
        page = alloc_page(GFP_KERNEL);
-       if (!page) {
-               fuse_put_request(fc, req);
+       if (!page)
                return -ENOMEM;
-       }
 
        plus = fuse_use_readdirplus(inode, ctx);
-       req->out.argpages = 1;
-       req->num_pages = 1;
-       req->pages[0] = page;
-       req->page_descs[0].length = PAGE_SIZE;
+       ap->args.out_pages = 1;
+       ap->num_pages = 1;
+       ap->pages = &page;
+       ap->descs = &desc;
        if (plus) {
                attr_version = fuse_get_attr_version(fc);
-               fuse_read_fill(req, file, ctx->pos, PAGE_SIZE,
-                              FUSE_READDIRPLUS);
+               fuse_read_args_fill(&ia, file, ctx->pos, PAGE_SIZE,
+                                   FUSE_READDIRPLUS);
        } else {
-               fuse_read_fill(req, file, ctx->pos, PAGE_SIZE,
-                              FUSE_READDIR);
+               fuse_read_args_fill(&ia, file, ctx->pos, PAGE_SIZE,
+                                   FUSE_READDIR);
        }
        locked = fuse_lock_inode(inode);
-       fuse_request_send(fc, req);
+       res = fuse_simple_request(fc, &ap->args);
        fuse_unlock_inode(inode, locked);
-       nbytes = req->out.args[0].size;
-       err = req->out.h.error;
-       fuse_put_request(fc, req);
-       if (!err) {
-               if (!nbytes) {
+       if (res >= 0) {
+               if (!res) {
                        struct fuse_file *ff = file->private_data;
 
                        if (ff->open_flags & FOPEN_CACHE_DIR)
                                fuse_readdir_cache_end(file, ctx->pos);
                } else if (plus) {
-                       err = parse_dirplusfile(page_address(page), nbytes,
+                       res = parse_dirplusfile(page_address(page), res,
                                                file, ctx, attr_version);
                } else {
-                       err = parse_dirfile(page_address(page), nbytes, file,
+                       res = parse_dirfile(page_address(page), res, file,
                                            ctx);
                }
        }
 
        __free_page(page);
        fuse_invalidate_atime(inode);
-       return err;
+       return res;
 }
 
 enum fuse_parse_result {