Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't poll /dev/fuse for writing #4

Closed
asomers opened this issue Jun 19, 2021 · 2 comments
Closed

Don't poll /dev/fuse for writing #4

asomers opened this issue Jun 19, 2021 · 2 comments

Comments

@asomers
Copy link
Contributor

asomers commented Jun 19, 2021

/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.

@Sherlock-Holo
Copy link
Owner

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

asomers added a commit to bfffs/bfffs that referenced this issue May 15, 2022
The fuse3 crate does not work on 13.0 (though it does work on 12.3) due
to Sherlock-Holo/fuse3#4 .  And any way,
FreeBSD 13.1 is just out!
@Sherlock-Holo
Copy link
Owner

Sherlock-Holo commented Jan 12, 2023

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 :)

Sherlock-Holo added a commit that referenced this issue Jan 15, 2023
#4 (comment)
we check the kernel codes that the /dev/fuse is always writable, there's
no need to use AsyncFd(tokio)/Async(async-std) to check if the /dev/fuse
fd is writable or not
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants