1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 18:43:50 +00:00

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.
This commit is contained in:
Nick Craig-Wood
2024-03-04 11:37:18 +00:00
parent f3f743c3f9
commit a67688dcc7
5 changed files with 15 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ const fhUnset = ^uint64(0)
type FS struct {
VFS *vfs.VFS
f fs.Fs
opt *mountlib.Options
ready chan (struct{})
mu sync.Mutex // to protect the below
handles []vfs.Handle
@@ -34,10 +35,11 @@ type FS struct {
}
// NewFS makes a new FS
func NewFS(VFS *vfs.VFS) *FS {
func NewFS(VFS *vfs.VFS, opt *mountlib.Options) *FS {
fsys := &FS{
VFS: VFS,
f: VFS.Fs(),
opt: opt,
ready: make(chan (struct{})),
}
return fsys
@@ -309,6 +311,9 @@ func (fsys *FS) OpenEx(path string, fi *fuse.FileInfo_t) (errc int) {
if entry := handle.Node().DirEntry(); entry != nil && entry.Size() < 0 {
fi.DirectIo = true
}
if fsys.opt.DirectIO {
fi.DirectIo = true
}
fi.Fh = fsys.openHandle(handle)
return 0