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