Sherlock-Holo / fuse3

an async version fuse library for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't poll /dev/fuse for writing

asomers opened this issue · comments

/dev/fuse may block on reads, which is why fuse3 polls it with a tokio AsyncFd. But it will never, ever block on writes (at least on FreeBSD; I don't know about other operating systems). That's why FreeBSD didn't even support polling it for writeability until a few days ago. So fuse3 doesn't need to poll it; it can just charge ahead and write. So I think fuse3 shouldn't. It can change the FuseConnection struct to be like this:

#[derive(Debug)]
pub struct FuseConnection {
    rfd: AsyncFd<RawFd>,
    wfd: RawFd,
    read: Mutex<()>,
    write: Mutex<()>,
}

, using the wrapped file descriptor for reading and the unwrapped copy for writing. That would be more efficient than polling for writeability, and it would also work on older versions of FreeBSD.

That sounds great, I will go to check if blocks when write to /dev/fuse on Linux

sorry for the late reply
I read the kernel source codes https://elixir.bootlin.com/linux/v6.1.4/source/fs/fuse/dev.c#L2054 and found when no error, the mask always contains EPOLLOUT, so yes, in linux kernel the /dev/fuse is always writable

feel free to correct my option if I am wrong :)