[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: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Miklos Szeredi and committed by Linus Torvalds 361b1eb5 9b9a0469

+18 -24
+3 -7
fs/fuse/dir.c
··· 762 return 0; 763 } 764 765 - static size_t fuse_send_readdir(struct fuse_req *req, struct file *file, 766 - struct inode *inode, loff_t pos, size_t count) 767 - { 768 - return fuse_send_read_common(req, file, inode, pos, count, 1); 769 - } 770 - 771 static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) 772 { 773 int err; ··· 785 } 786 req->num_pages = 1; 787 req->pages[0] = page; 788 - nbytes = fuse_send_readdir(req, file, inode, file->f_pos, PAGE_SIZE); 789 err = req->out.h.error; 790 fuse_put_request(fc, req); 791 if (!err)
··· 762 return 0; 763 } 764 765 static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) 766 { 767 int err; ··· 791 } 792 req->num_pages = 1; 793 req->pages[0] = page; 794 + fuse_read_fill(req, file, inode, file->f_pos, PAGE_SIZE, FUSE_READDIR); 795 + request_send(fc, req); 796 + nbytes = req->out.args[0].size; 797 err = req->out.h.error; 798 fuse_put_request(fc, req); 799 if (!err)
+11 -13
fs/fuse/file.c
··· 250 return fuse_fsync_common(file, de, datasync, 0); 251 } 252 253 - size_t fuse_send_read_common(struct fuse_req *req, struct file *file, 254 - struct inode *inode, loff_t pos, size_t count, 255 - int isdir) 256 { 257 - struct fuse_conn *fc = get_fuse_conn(inode); 258 struct fuse_file *ff = file->private_data; 259 - struct fuse_read_in inarg; 260 261 - memset(&inarg, 0, sizeof(struct fuse_read_in)); 262 - inarg.fh = ff->fh; 263 - inarg.offset = pos; 264 - inarg.size = count; 265 - req->in.h.opcode = isdir ? FUSE_READDIR : FUSE_READ; 266 req->in.h.nodeid = get_node_id(inode); 267 req->inode = inode; 268 req->file = file; ··· 270 req->out.argvar = 1; 271 req->out.numargs = 1; 272 req->out.args[0].size = count; 273 - request_send(fc, req); 274 - return req->out.args[0].size; 275 } 276 277 static size_t fuse_send_read(struct fuse_req *req, struct file *file, 278 struct inode *inode, loff_t pos, size_t count) 279 { 280 - return fuse_send_read_common(req, file, inode, pos, count, 0); 281 } 282 283 static int fuse_readpage(struct file *file, struct page *page)
··· 250 return fuse_fsync_common(file, de, datasync, 0); 251 } 252 253 + void fuse_read_fill(struct fuse_req *req, struct file *file, 254 + struct inode *inode, loff_t pos, size_t count, int opcode) 255 { 256 struct fuse_file *ff = file->private_data; 257 + struct fuse_read_in *inarg = &req->misc.read_in; 258 259 + inarg->fh = ff->fh; 260 + inarg->offset = pos; 261 + inarg->size = count; 262 + req->in.h.opcode = opcode; 263 req->in.h.nodeid = get_node_id(inode); 264 req->inode = inode; 265 req->file = file; ··· 273 req->out.argvar = 1; 274 req->out.numargs = 1; 275 req->out.args[0].size = count; 276 } 277 278 static size_t fuse_send_read(struct fuse_req *req, struct file *file, 279 struct inode *inode, loff_t pos, size_t count) 280 { 281 + struct fuse_conn *fc = get_fuse_conn(inode); 282 + fuse_read_fill(req, file, inode, pos, count, FUSE_READ); 283 + request_send(fc, req); 284 + return req->out.args[0].size; 285 } 286 287 static int fuse_readpage(struct file *file, struct page *page)
+4 -4
fs/fuse/fuse_i.h
··· 169 struct fuse_release_in release_in; 170 struct fuse_init_in init_in; 171 struct fuse_init_out init_out; 172 } misc; 173 174 /** page vector */ ··· 355 unsigned long nodeid, u64 nlookup); 356 357 /** 358 - * Send READ or READDIR request 359 */ 360 - size_t fuse_send_read_common(struct fuse_req *req, struct file *file, 361 - struct inode *inode, loff_t pos, size_t count, 362 - int isdir); 363 364 /** 365 * Send OPEN or OPENDIR request
··· 169 struct fuse_release_in release_in; 170 struct fuse_init_in init_in; 171 struct fuse_init_out init_out; 172 + struct fuse_read_in read_in; 173 } misc; 174 175 /** page vector */ ··· 354 unsigned long nodeid, u64 nlookup); 355 356 /** 357 + * Initialize READ or READDIR request 358 */ 359 + void fuse_read_fill(struct fuse_req *req, struct file *file, 360 + struct inode *inode, loff_t pos, size_t count, int opcode); 361 362 /** 363 * Send OPEN or OPENDIR request