cloud-hypervisor / fuse-backend-rs

Rust crate for implementing FUSE backends
Apache License 2.0
129 stars 63 forks source link

fuse: Ensure fd has same flags as read/write #154

Closed Champ-Goblem closed 8 months ago

Champ-Goblem commented 9 months ago

We found when running minio with recent versions of nydus that it was no longer able to boot properly due to Invalid Argument when writing to a temporary file. Tracing the high-level flow showed that the file was originally opened with O_DIRECT, then later on if the buffer size was not correctly aligned, fcntl with F_SETFL would be used to remove the O_DIRECT flag. In virtiofs, there is no independent call for fcntl, so the underlying file descriptor opened by nydus still had the O_DIRECT flag set. Meaning that during a write to this file, it would error with -EINVAL as the buffer size was not aligned.

This patch aims to fix this by first recording the open flags for a file in the HandleData struct, then on read/write checking these flags match the flags provided by virtiofs in the read/write message. If the flags do not match, the current flags of the file are checked with F_GETFL and updated with F_SETFL if these also do not match.

eryugey commented 9 months ago

And would you please rebase to latest master branch? The Macos-CI got fixed there.