mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-17 10:22:56 +00:00
require target_os=linux for direct io path
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
This commit is contained in:
@@ -974,16 +974,28 @@ pub mod virtual_file {
|
||||
serde_with::DeserializeFromStr,
|
||||
serde_with::SerializeDisplay,
|
||||
Debug,
|
||||
Default,
|
||||
)]
|
||||
#[strum(serialize_all = "kebab-case")]
|
||||
pub enum IoModeKind {
|
||||
/// Uses buffered IO.
|
||||
#[default]
|
||||
Buffered,
|
||||
/// Uses direct IO, error out if the operation fails.
|
||||
#[cfg(target_os = "linux")]
|
||||
Direct,
|
||||
}
|
||||
|
||||
impl IoModeKind {
|
||||
// TODO(yuchen): change to [`Self::Direct`] once finish rollout.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const fn preferred() -> Self {
|
||||
Self::Buffered
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub const fn preferred() -> Self {
|
||||
Self::Buffered
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@@ -137,7 +137,7 @@ pub(crate) async fn main(cmd: &AnalyzeLayerMapCmd) -> Result<()> {
|
||||
pageserver::virtual_file::init(
|
||||
10,
|
||||
virtual_file::api::IoEngineKind::StdFs,
|
||||
IoModeKind::default(),
|
||||
IoModeKind::preferred(),
|
||||
);
|
||||
pageserver::page_cache::init(100);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ async fn read_delta_file(path: impl AsRef<Path>, ctx: &RequestContext) -> Result
|
||||
virtual_file::init(
|
||||
10,
|
||||
virtual_file::api::IoEngineKind::StdFs,
|
||||
IoModeKind::default(),
|
||||
IoModeKind::preferred(),
|
||||
);
|
||||
page_cache::init(100);
|
||||
let path = Utf8Path::from_path(path.as_ref()).expect("non-Unicode path");
|
||||
@@ -64,7 +64,7 @@ async fn read_image_file(path: impl AsRef<Path>, ctx: &RequestContext) -> Result
|
||||
virtual_file::init(
|
||||
10,
|
||||
virtual_file::api::IoEngineKind::StdFs,
|
||||
IoModeKind::default(),
|
||||
IoModeKind::preferred(),
|
||||
);
|
||||
page_cache::init(100);
|
||||
let path = Utf8Path::from_path(path.as_ref()).expect("non-Unicode path");
|
||||
@@ -170,7 +170,7 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> {
|
||||
pageserver::virtual_file::init(
|
||||
10,
|
||||
virtual_file::api::IoEngineKind::StdFs,
|
||||
IoModeKind::default(),
|
||||
IoModeKind::preferred(),
|
||||
);
|
||||
pageserver::page_cache::init(100);
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ async fn print_layerfile(path: &Utf8Path) -> anyhow::Result<()> {
|
||||
virtual_file::init(
|
||||
10,
|
||||
virtual_file::api::IoEngineKind::StdFs,
|
||||
IoModeKind::default(),
|
||||
IoModeKind::preferred(),
|
||||
);
|
||||
page_cache::init(100);
|
||||
let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error);
|
||||
|
||||
@@ -416,7 +416,7 @@ impl PageServerConf {
|
||||
.map(crate::l0_flush::L0FlushConfig::from)
|
||||
.unwrap_or_default(),
|
||||
virtual_file_io_mode: virtual_file_io_mode
|
||||
.unwrap_or(virtual_file::IoModeKind::default()),
|
||||
.unwrap_or(virtual_file::IoModeKind::preferred()),
|
||||
no_sync: no_sync.unwrap_or(false),
|
||||
};
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ impl VirtualFile {
|
||||
_mode: IoMode::Buffered,
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
IoMode::Direct => {
|
||||
let inner = VirtualFileInner::open_with_options(
|
||||
path,
|
||||
@@ -1375,6 +1376,7 @@ pub(crate) type IoPageSlice<'a> =
|
||||
pub(crate) enum IoMode {
|
||||
NotSet,
|
||||
Buffered,
|
||||
#[cfg(target_os = "linux")]
|
||||
Direct,
|
||||
}
|
||||
|
||||
@@ -1385,6 +1387,7 @@ impl TryFrom<u8> for IoMode {
|
||||
Ok(match value {
|
||||
v if v == (IoMode::NotSet as u8) => IoMode::NotSet,
|
||||
v if v == (IoMode::Buffered as u8) => IoMode::Buffered,
|
||||
#[cfg(target_os = "linux")]
|
||||
v if v == (IoMode::Direct as u8) => IoMode::Direct,
|
||||
x => return Err(x),
|
||||
})
|
||||
@@ -1395,6 +1398,7 @@ impl From<IoModeKind> for IoMode {
|
||||
fn from(value: IoModeKind) -> Self {
|
||||
match value {
|
||||
IoModeKind::Buffered => IoMode::Buffered,
|
||||
#[cfg(target_os = "linux")]
|
||||
IoModeKind::Direct => IoMode::Direct,
|
||||
}
|
||||
}
|
||||
@@ -1420,7 +1424,7 @@ fn get_io_mode() -> IoMode {
|
||||
panic!("invalid VirtualFile io mode for env var {env_var_name}: {e:#}: {v:?}")
|
||||
}
|
||||
},
|
||||
Err(std::env::VarError::NotPresent) => IoModeKind::Direct,
|
||||
Err(std::env::VarError::NotPresent) => IoModeKind::preferred(),
|
||||
Err(std::env::VarError::NotUnicode(_)) => {
|
||||
panic!("env var {env_var_name} is not unicode");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user