From: Goswin v. B. <gos...@we...> - 2011-12-08 10:54:00
|
Miklos Szeredi <mi...@sz...> writes: > Goswin von Brederlow <gos...@we...> writes: > >> I don't know how feasable this is, but: Could request be split up into a >> command fd and data fd? The main thread would open the command fd and >> each thread would request it own data fd over the command fd. Then when >> a thread reads a request from the command fd (and it is a big one) the >> kernel would dump the data to the data fd for the requesting thread. >> >> With this fuse wouldn't even have to splice the data into an extra pipe >> but could just pass the data fd to the callback as is. > > The kernel should not need to care about threads and such. It should > not contain knowledge about the implementation of libfuse. > > So slightly modifying your idea: the kernel can attach a data fd > (basically the read end of a pipe) to the request and dump the data into > that pipe. > > The question is: how to attach the data fd to the request? File > descriptor passing over unix domain sockets (SCM_RIGHTS) comes to mind. > But changing the device interface into a socket interface is not quite > trivial. > > Passing the file descriptor in the fuse_write_in header would be > possible, but that's really messy. > > An ioctl() to request that the data be dumped onto the given pipe is > perhaps the cleanest way to do this. E.g. > > struct fuse_data_request { > u64 unique; > int fd; > }; > > static void do_write() > { > struct fuse_data_request fdr; > int pip[2]; > ... > pipe(pip); > fdr.unique = req->unique; > fdr.fd = pip[1]; > ioctl(fuse_dev, FUSE_IOCTL_GETDATA, &fdr); > /* data available in pip[0] */ > ... > } > > Thanks, > Miklos One more thing I forgot. Does the FD have to be a pipe? Think of an overlay filesystem. Why not pass the FD of the underlying file: struct fuse_data_request { u64 unique; u64 offset; int fd; }; static void do_write(...) { struct fuse_data_request fdr; fdr.unique = req->unique; fdt.offset = off; fdr.fd = fi->fh; ioctl(fuse_dev, FUSE_IOCTL_GETDATA, &fdr); } Plus some error handling. MfG Goswin |