diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2007-10-18 06:07:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-18 17:37:31 -0400 |
commit | b25e82e5673c750116e8b01a4fc7d09be7809f8c (patch) | |
tree | 03d23ccbca6e87ba98efeba445ff714455dba0bb /fs/fuse/file.c | |
parent | 93a8c3cd9e9834dc5f5c373336f3a0065521152d (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/file.c')
-rw-r--r-- | fs/fuse/file.c | 33 |
1 files changed, 20 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 | ||
446 | static size_t fuse_send_write(struct fuse_req *req, struct file *file, | 446 | static 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 | |||
470 | static 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 | ||
472 | static int fuse_write_begin(struct file *file, struct address_space *mapping, | 479 | static int fuse_write_begin(struct file *file, struct address_space *mapping, |