Help understanding --direct-io for mount

I am trying to learn more about --direct-io. I searched the forum and only found it mentioned in the release note or when someone copy/pasted the docs.

Some of my non-mutually exclusive questions are

  • What exactly is this flag for?
  • What is the use case?
  • How is it different than turning off the cache?
  • Does it work on all remotes?
  • Is it basically a transparent layer? So can a program write in the middle of a file without a whole new copy?

I plan to test it empirically with FUSE and FUSE-T on macOS but I’d like to better understand the intent rather than just the empirical behavior.

Thanks!

hi @jwink3101

me too.


from github,
Support for direct io #8816

mount,cmount,mount2: add --direct-io flag to force uncached access · rclone/rclone@a67688d · GitHub
"mount,cmount,mount2: add --direct-io flag to force uncached access
This change adds the --direct-io flag to the mount. This means the
page cache is completely bypassed for reads and writes. No read-ahead
takes place. Shared mmap is disabled.

This is useful to accurately read files which may change length
frequently on the source."

Back in the day, you’d want to use direct-io on things like Oracle DBs or places you already had some kind of memory cache already setup so you aren’t double caching things and wasting memory on the OS file cache and the DB cache.

I’m not sure these days what would still apply.