Hi, I'm new to contributing to FreeBSD and I try to solve issues and learn in the process.
fusefs currently doesn't allows per-filehandle direct io. This was an issue raised by ALAN SOMERS "If a FUSE daemon responds to a FUSE_OPEN request with the FOPEN_DIRECT_IO flag, then it wants the kernel to bypass the cache for that file. And fusefs(4) will honor that. However, the fuse protocol allows a file to be opened multiple times, possibly with different FOPEN_ flags. In that case, the kernel should consider that those FOPEN_ flags reply to one file descriptor only. So whether we bypass the cache should depend on what FUSE_OPEN returned for that particular file descriptor.
The problem is that our current code interprets FOPEN_DIRECT_IO by setting the FN_DIRECTIO flag within the vnode's private data. But there can be multiple file descriptors per vnode. So we can't possibly respect that flag as the protocol intends."
I have made the required changes:
1. fuse_file.c: removed all the code where vnode flag was getting set/unset to FN_DIRECTIO
2. fuse_vnops.c: replaced all the checks of VTOFUD(vp)->flag with checks of
fufh->fuse_open_flags & FOPEN_DIRECTIO. After which I guess fuse_vnop_write and fuse_vnop_read now correctly set IO_DIRECT based on the filehandle not the vnode.
And now i want to write 2 tests one for reads and one for writes. I know that we have to open two file handles whose PIDs are different and the fuse daemon should give FOPEN_DIRECT_IO for one but not for the other. But i dont know how to exactly do it in the gtest framework.
If someone could just guide me for writing the reads test part that would be very helpful.
Thank you.
fusefs currently doesn't allows per-filehandle direct io. This was an issue raised by ALAN SOMERS "If a FUSE daemon responds to a FUSE_OPEN request with the FOPEN_DIRECT_IO flag, then it wants the kernel to bypass the cache for that file. And fusefs(4) will honor that. However, the fuse protocol allows a file to be opened multiple times, possibly with different FOPEN_ flags. In that case, the kernel should consider that those FOPEN_ flags reply to one file descriptor only. So whether we bypass the cache should depend on what FUSE_OPEN returned for that particular file descriptor.
The problem is that our current code interprets FOPEN_DIRECT_IO by setting the FN_DIRECTIO flag within the vnode's private data. But there can be multiple file descriptors per vnode. So we can't possibly respect that flag as the protocol intends."
I have made the required changes:
1. fuse_file.c: removed all the code where vnode flag was getting set/unset to FN_DIRECTIO
2. fuse_vnops.c: replaced all the checks of VTOFUD(vp)->flag with checks of
fufh->fuse_open_flags & FOPEN_DIRECTIO. After which I guess fuse_vnop_write and fuse_vnop_read now correctly set IO_DIRECT based on the filehandle not the vnode.
And now i want to write 2 tests one for reads and one for writes. I know that we have to open two file handles whose PIDs are different and the fuse daemon should give FOPEN_DIRECT_IO for one but not for the other. But i dont know how to exactly do it in the gtest framework.
If someone could just guide me for writing the reads test part that would be very helpful.
Thank you.