Commit 361b1eb5 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Linus Torvalds

[PATCH] fuse: READ request initialization

Add a separate function for filling in the READ request.  This will make it
possible to send asynchronous READ requests as well as synchronous ones.
Signed-off-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9b9a0469
...@@ -762,12 +762,6 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file, ...@@ -762,12 +762,6 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file,
return 0; return 0;
} }
static size_t fuse_send_readdir(struct fuse_req *req, struct file *file,
struct inode *inode, loff_t pos, size_t count)
{
return fuse_send_read_common(req, file, inode, pos, count, 1);
}
static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
{ {
int err; int err;
...@@ -791,7 +785,9 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) ...@@ -791,7 +785,9 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir)
} }
req->num_pages = 1; req->num_pages = 1;
req->pages[0] = page; req->pages[0] = page;
nbytes = fuse_send_readdir(req, file, inode, file->f_pos, PAGE_SIZE); fuse_read_fill(req, file, inode, file->f_pos, PAGE_SIZE, FUSE_READDIR);
request_send(fc, req);
nbytes = req->out.args[0].size;
err = req->out.h.error; err = req->out.h.error;
fuse_put_request(fc, req); fuse_put_request(fc, req);
if (!err) if (!err)
......
...@@ -250,19 +250,16 @@ static int fuse_fsync(struct file *file, struct dentry *de, int datasync) ...@@ -250,19 +250,16 @@ static int fuse_fsync(struct file *file, struct dentry *de, int datasync)
return fuse_fsync_common(file, de, datasync, 0); return fuse_fsync_common(file, de, datasync, 0);
} }
size_t fuse_send_read_common(struct fuse_req *req, struct file *file, void fuse_read_fill(struct fuse_req *req, struct file *file,
struct inode *inode, loff_t pos, size_t count, struct inode *inode, loff_t pos, size_t count, int opcode)
int isdir)
{ {
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
struct fuse_read_in inarg; struct fuse_read_in *inarg = &req->misc.read_in;
memset(&inarg, 0, sizeof(struct fuse_read_in)); inarg->fh = ff->fh;
inarg.fh = ff->fh; inarg->offset = pos;
inarg.offset = pos; inarg->size = count;
inarg.size = count; req->in.h.opcode = opcode;
req->in.h.opcode = isdir ? FUSE_READDIR : FUSE_READ;
req->in.h.nodeid = get_node_id(inode); req->in.h.nodeid = get_node_id(inode);
req->inode = inode; req->inode = inode;
req->file = file; req->file = file;
...@@ -273,14 +270,15 @@ size_t fuse_send_read_common(struct fuse_req *req, struct file *file, ...@@ -273,14 +270,15 @@ size_t fuse_send_read_common(struct fuse_req *req, struct file *file,
req->out.argvar = 1; req->out.argvar = 1;
req->out.numargs = 1; req->out.numargs = 1;
req->out.args[0].size = count; req->out.args[0].size = count;
request_send(fc, req);
return req->out.args[0].size;
} }
static size_t fuse_send_read(struct fuse_req *req, struct file *file, static size_t fuse_send_read(struct fuse_req *req, struct file *file,
struct inode *inode, loff_t pos, size_t count) struct inode *inode, loff_t pos, size_t count)
{ {
return fuse_send_read_common(req, file, inode, pos, count, 0); struct fuse_conn *fc = get_fuse_conn(inode);
fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
request_send(fc, req);
return req->out.args[0].size;
} }
static int fuse_readpage(struct file *file, struct page *page) static int fuse_readpage(struct file *file, struct page *page)
......
...@@ -169,6 +169,7 @@ struct fuse_req { ...@@ -169,6 +169,7 @@ struct fuse_req {
struct fuse_release_in release_in; struct fuse_release_in release_in;
struct fuse_init_in init_in; struct fuse_init_in init_in;
struct fuse_init_out init_out; struct fuse_init_out init_out;
struct fuse_read_in read_in;
} misc; } misc;
/** page vector */ /** page vector */
...@@ -354,11 +355,10 @@ void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req, ...@@ -354,11 +355,10 @@ void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
unsigned long nodeid, u64 nlookup); unsigned long nodeid, u64 nlookup);
/** /**
* Send READ or READDIR request * Initialize READ or READDIR request
*/ */
size_t fuse_send_read_common(struct fuse_req *req, struct file *file, void fuse_read_fill(struct fuse_req *req, struct file *file,
struct inode *inode, loff_t pos, size_t count, struct inode *inode, loff_t pos, size_t count, int opcode);
int isdir);
/** /**
* Send OPEN or OPENDIR request * Send OPEN or OPENDIR request
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment