Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out O_DIRECT at open_inode #192

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/passthrough/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ pub struct Config {
/// is bigger than the threshold.
/// The default value for this option is `false`.
pub use_host_ino: bool,

/// Whether the file system should honor the O_DIRECT flag. If this option is disabled,
/// that flag will be filtered out at `open_inode`.
///
/// The default is `true`.
pub allow_direct_io: bool,
}

impl Default for Config {
Expand All @@ -198,6 +204,7 @@ impl Default for Config {
dir_entry_timeout: None,
dir_attr_timeout: None,
use_host_ino: false,
allow_direct_io: true,
}
}
}
5 changes: 4 additions & 1 deletion src/passthrough/sync_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
if !is_safe_inode(data.mode) {
Err(ebadf())
} else {
let new_flags = self.get_writeback_open_flags(flags);
let mut new_flags = self.get_writeback_open_flags(flags);
if !self.cfg.allow_direct_io && flags & libc::O_DIRECT != 0 {
new_flags &= !libc::O_DIRECT;
}
data.open_file(new_flags | libc::O_CLOEXEC, &self.proc_self_fd)
}
}
Expand Down
Loading