Goswin von Brederlow | 11 Mar 06:18 2010

Re: Echoing poll()/select() calls to underlying filesystems

Stef Bon <stefbon@...> writes:

> 2010/3/7 Goswin von Brederlow <goswin-v-b@...>:
>> Alberto Miranda <alberto.miranda@...> writes:
>>> Hi,
>>>enough clues in the source yet so as to
>>> confirm my theory or not.
>> What you do is store the FD to poll/select and in the main loop you
>> poll/select the list of stored FDs + the fuse FD. That way activity on
>> either the file you wait for or fuse will wake you up.
>> I do this with libaio, which gives me an event FD. When a read/write
>> request comes in I start the libaio request and go back to sleep. Then
>> either libaio wakes me up and I reply to fuse that the requets has
>> completed or fuse wakes me up and I handle a second request in parallel
>> to the ones pending.
> I'm trying my best to understand what you're describing here. Main loop?
> Is this in the function main, before the call of fuse_main(args.argc,
> args.argv, &xmp_oper, NULL)?
> Can you give an preview/example code, it does much help.

You need to replace the

  int fuse_session_loop(struct fuse_session *se);

with your own loop. fuse_main(), as the comment in the header says, "is
for the lazy" and you can't use that then. You can cut&paste most of it
from the fuse source and modify it to select/poll as needed though. My
loop looks something like this:

while(true) {
  select(nfds, readfds, writefds, exceptfds, timeout);
  if (FD_ISSET(fuse_fd, readfds)) {
    if (fuse_session_exited(fs->se) != 0) {
	buffer = NULL;
    struct fuse_chan *tmpch = fs->ch;
    res = fuse_chan_recv(&tmpch, buf, size);
    if (res > 0) {
	fuse_session_process(fs->se, buf, res, tmpch);
    } else if (fuse_session_exited(fs->se) != 0) {
	buffer = NULL;
  } else {
    // handle aio


Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.