Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ impl FuseAdapter {
}
}

/// Per-open flags: DIRECT_IO bypasses the page cache; otherwise we ask
/// the kernel to retain it across opens (safe because init() negotiates
/// AUTO_INVAL_DATA, so the kernel invalidates on attr changes).
fn open_flags(&self) -> FopenFlags {
if self.direct_io {
FopenFlags::FOPEN_DIRECT_IO
} else {
FopenFlags::empty()
FopenFlags::FOPEN_KEEP_CACHE
}
}

Expand Down Expand Up @@ -141,6 +144,16 @@ impl Filesystem for FuseAdapter {
);
}

// Kernel auto-invalidates cached pages on mtime/size changes —
// required for FOPEN_KEEP_CACHE on writable mounts. Available
// since Linux 3.15 (2014); mandatory.
config.add_capabilities(InitFlags::FUSE_AUTO_INVAL_DATA).map_err(|_| {
io::Error::new(
io::ErrorKind::Unsupported,
"FUSE_AUTO_INVAL_DATA not supported (kernel < 3.15)",
)
})?;

// Receive O_TRUNC in open() flags instead of a separate setattr(size=0) call.
if !self.read_only {
let trunc_ok = config.add_capabilities(InitFlags::FUSE_ATOMIC_O_TRUNC).is_ok();
Expand Down