diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2010-11-08 17:11:46 +0100 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2010-11-08 17:11:46 +0100 |
commit | 4e0aea6a96146115e2fb3b8c4a4c75325ad894d7 (patch) | |
tree | ddccccd975def8b0881dbd4b219a931a03ffd227 /lib/fuse_loop_mt.c | |
parent | 7d878eb13a9b1e0e1a428c1ead2733b8453a3bb7 (diff) |
libfuse: support zero copy writes in lowlevel interface
Add new ->write_buf() method to low level interface. This
allows passig a generic buffer, either containing a memory buffer
or a file descriptor. This allows implementing zero copy writes.
Add fuse_session_receive_buf() and fuse_session_process_buf()
which may be used in event loop implementations to replace
fuse_chan_recv() and fuse_session_process() respectively.
Diffstat (limited to 'lib/fuse_loop_mt.c')
-rw-r--r-- | lib/fuse_loop_mt.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 05935d5..a76713b 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -70,10 +70,14 @@ static void *fuse_do_work(void *data) while (!fuse_session_exited(mt->se)) { int isforget = 0; struct fuse_chan *ch = mt->prevch; + struct fuse_buf fbuf = { + .mem = w->buf, + .size = w->bufsize, + }; int res; pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); - res = fuse_chan_recv(&ch, w->buf, w->bufsize); + res = fuse_session_receive_buf(mt->se, &fbuf, &ch); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); if (res == -EINTR) continue; @@ -95,7 +99,8 @@ static void *fuse_do_work(void *data) * This disgusting hack is needed so that zillions of threads * are not created on a burst of FORGET messages */ - if (((struct fuse_in_header *) w->buf)->opcode == FUSE_FORGET) + if (!(fbuf.flags & FUSE_BUF_IS_FD) && + ((struct fuse_in_header *) fbuf.mem)->opcode == FUSE_FORGET) isforget = 1; if (!isforget) @@ -104,7 +109,7 @@ static void *fuse_do_work(void *data) fuse_start_thread(mt); pthread_mutex_unlock(&mt->lock); - fuse_session_process(mt->se, w->buf, res, ch); + fuse_session_process_buf(mt->se, &fbuf, ch); pthread_mutex_lock(&mt->lock); if (!isforget) |