On Mon, Mar 2, 2020 at 9:29 PM Nikolaus Rath <Nikolaus@xxxxxxxx> wrote: > > On Mar 02 2020, Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > On Sun, Mar 1, 2020 at 2:20 PM Nikolaus Rath <Nikolaus@xxxxxxxx> wrote: > >> > >> Hi, > >> > >> What happens if a file (on a FUSE mountpoint) is opened without > >> O_DIRECT, has some data in the page cache, and is then opened a second > >> with O_DIRECT? > >> > >> Will reads with O_DIRECT come from the page cache (if there's a hit), or > >> be passed through to the fuse daemon? > > > > O_DIRECT read will try first directly, and fall back to the cache on > > short or zero return count. > > > >> > >> What happens to writes (with and without O_DIRECT, and assuming that > >> writeback caching is active)? It seems to me that in order to keep > >> consistent, either caching has to be disabled for both file descriptors > >> or enabled for both... > > > > This is not a fuse specific problem. The kernel will try to keep > > things consistent by flushing dirty data before an O_DIRECT read. > > However this mode of operation is not recommended. See open(2) > > manpage: > [...] > > Is there currently any other way to execute a read request while making > sure that data does not end-up in the page cache (unless it happens to > be there already)? Hmm, that sounds something like posix_fadvise(..., POSIX_FADV_DONTNEED). Thanks, Miklos