aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2007-10-18 06:07:03 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-18 17:37:31 -0400
commitb25e82e5673c750116e8b01a4fc7d09be7809f8c (patch)
tree03d23ccbca6e87ba98efeba445ff714455dba0bb /fs/fuse
parent93a8c3cd9e9834dc5f5c373336f3a0065521152d (diff)
fuse: add helper for asynchronous writes
This patch adds a new helper function fuse_write_fill() which makes it possible to send WRITE requests asynchronously. A new flag for WRITE requests is also added which indicates that this a write from the page cache, and not a "normal" file write. This patch is in preparation for writable mmap support. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/file.c33
-rw-r--r--fs/fuse/fuse_i.h4
2 files changed, 24 insertions, 13 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c4c59c7d0038..2b589de044e8 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -443,30 +443,37 @@ out:
443 return err; 443 return err;
444} 444}
445 445
446static size_t fuse_send_write(struct fuse_req *req, struct file *file, 446static void fuse_write_fill(struct fuse_req *req, struct fuse_file *ff,
447 struct inode *inode, loff_t pos, size_t count) 447 struct inode *inode, loff_t pos, size_t count,
448 int writepage)
448{ 449{
449 struct fuse_conn *fc = get_fuse_conn(inode); 450 struct fuse_write_in *inarg = &req->misc.write.in;
450 struct fuse_file *ff = file->private_data; 451 struct fuse_write_out *outarg = &req->misc.write.out;
451 struct fuse_write_in inarg;
452 struct fuse_write_out outarg;
453 452
454 memset(&inarg, 0, sizeof(struct fuse_write_in)); 453 memset(inarg, 0, sizeof(struct fuse_write_in));
455 inarg.fh = ff->fh; 454 inarg->fh = ff->fh;
456 inarg.offset = pos; 455 inarg->offset = pos;
457 inarg.size = count; 456 inarg->size = count;
457 inarg->write_flags = writepage ? FUSE_WRITE_CACHE : 0;
458 req->in.h.opcode = FUSE_WRITE; 458 req->in.h.opcode = FUSE_WRITE;
459 req->in.h.nodeid = get_node_id(inode); 459 req->in.h.nodeid = get_node_id(inode);
460 req->in.argpages = 1; 460 req->in.argpages = 1;
461 req->in.numargs = 2; 461 req->in.numargs = 2;
462 req->in.args[0].size = sizeof(struct fuse_write_in); 462 req->in.args[0].size = sizeof(struct fuse_write_in);
463 req->in.args[0].value = &inarg; 463 req->in.args[0].value = inarg;
464 req->in.args[1].size = count; 464 req->in.args[1].size = count;
465 req->out.numargs = 1; 465 req->out.numargs = 1;
466 req->out.args[0].size = sizeof(struct fuse_write_out); 466 req->out.args[0].size = sizeof(struct fuse_write_out);
467 req->out.args[0].value = &outarg; 467 req->out.args[0].value = outarg;
468}
469
470static size_t fuse_send_write(struct fuse_req *req, struct file *file,
471 struct inode *inode, loff_t pos, size_t count)
472{
473 struct fuse_conn *fc = get_fuse_conn(inode);
474 fuse_write_fill(req, file->private_data, inode, pos, count, 0);
468 request_send(fc, req); 475 request_send(fc, req);
469 return outarg.size; 476 return req->misc.write.out.size;
470} 477}
471 478
472static int fuse_write_begin(struct file *file, struct address_space *mapping, 479static int fuse_write_begin(struct file *file, struct address_space *mapping,
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 5657cca0d0cb..8b64a630e758 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -219,6 +219,10 @@ struct fuse_req {
219 struct fuse_init_in init_in; 219 struct fuse_init_in init_in;
220 struct fuse_init_out init_out; 220 struct fuse_init_out init_out;
221 struct fuse_read_in read_in; 221 struct fuse_read_in read_in;
222 struct {
223 struct fuse_write_in in;
224 struct fuse_write_out out;
225 } write;
222 struct fuse_lk_in lk_in; 226 struct fuse_lk_in lk_in;
223 } misc; 227 } misc;
224 228