On Wed, Nov 29, 2023 at 5:21 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > On Wed, 29 Nov 2023 at 16:06, Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > > > On Wed, Nov 29, 2023 at 4:14 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > > > > > On Wed, 29 Nov 2023 at 08:25, Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > > > > > > My proposed solution is to change the semantics with the init flag > > > > FUSE_PASSTHROUGH to disallow mmap on FOPEN_DIRECT_IO > > > > files. > > > > > > Why? FOPEN_DIRECT_IO and FUSE_PASSTHROUGH should mix much more > > > readily than FOPEN_DIRECT_IO with page cache. > > > > > > > Am I misunderstanding how mmap works with FOPEN_DIRECT_IO file? > > My understanding is that mmap of FOPEN_DIRECT_IO reads/writes > > from page cache of fuse inode. > > > > To clarify, the plan is to never allow mixing open of passthrough and > > cached files on the same inode. > > Yep. > > But passthrough mmap + direct I/O should work, no? > direct I/O read()/write() is never a problem. The question is whether mmap() on a file opened with FOPEN_DIRECT_IO when the inode is in passthrough mode, also uses fuse_passthrough_mmap()? or denied, similar to how mmap with ff->open_flags & FOPEN_DIRECT_IO && vma->vm_flags & VM_MAYSHARE) && !fc->direct_io_relax is denied? > > It is allowed to open FOPEN_DIRECT_IO file for inode either in cached > > or passthrough mode, but it is NOT allowed to mmap a FOPEN_DIRECT_IO > > file for inode in passthrough mode. > > > > However, if inode only has file open in FOPEN_DIRECT_IO mode, then inode > > mode is neutral. If we allow mmap in this state then a later open in passthourgh > > mode and mmap in passthrough mode will collide with the direct mode mmap. > > We can keep track of when there are any page cache mmaps. Does that > not solve this? > A bit more challenging, because we will need to track unmounts, or at least track "was_cached_mmaped" state per file, but doable. > > > > Therefore, my proposal is than when filesystem is FUSE_PASSTHROUGH capable, > > only passthrough file and cached file may be mmaped, but never allow to > > mmap a FOPEN_DIRECT_IO file. > > > > Does that make sense? > > I'm not sure I understand how this is supposed to work. Disallowing > mmap will break applications. How is this different from existing -ENODEV in fuse_file_mmap() for !fc->direct_io_relax? What am I missing? Is it because VM_MAYSHARE is far less common for applications? Thanks, Amir.