mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-03 17:48:17 +00:00
core: Enable direct I/O optimistically
...but keep going if the filesystem does not support it. Fixes Limbo on older Linux kernels that have io_uring but don't support direct I/O on all filesystems, such as tmpfs or encryptfs.
This commit is contained in:
parent
812a8b9ea2
commit
207ec5ce92
3 changed files with 27 additions and 4 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -205,6 +205,12 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_block"
|
||||
version = "0.1.1"
|
||||
|
@ -972,6 +978,7 @@ dependencies = [
|
|||
"libc",
|
||||
"log",
|
||||
"mimalloc",
|
||||
"nix 0.29.0",
|
||||
"ordered-multimap",
|
||||
"polling",
|
||||
"pprof",
|
||||
|
@ -1076,6 +1083,18 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-format"
|
||||
version = "0.4.4"
|
||||
|
@ -1274,7 +1293,7 @@ dependencies = [
|
|||
"inferno",
|
||||
"libc",
|
||||
"log",
|
||||
"nix",
|
||||
"nix 0.26.4",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"smallvec",
|
||||
|
@ -1525,7 +1544,7 @@ dependencies = [
|
|||
"libc",
|
||||
"log",
|
||||
"memchr",
|
||||
"nix",
|
||||
"nix 0.26.4",
|
||||
"radix_trie",
|
||||
"scopeguard",
|
||||
"unicode-segmentation",
|
||||
|
|
|
@ -33,6 +33,7 @@ cfg_block = "0.1.1"
|
|||
fallible-iterator = "0.3.0"
|
||||
libc = "0.2.155"
|
||||
log = "0.4.20"
|
||||
nix = { version = "0.29.0", features = ["fs"] }
|
||||
ordered-multimap = "0.7.1"
|
||||
sieve-cache = "0.1.4"
|
||||
sqlite3-parser = "0.11.0"
|
||||
|
|
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||
use libc::iovec;
|
||||
use log::trace;
|
||||
use std::cell::{Ref, RefCell};
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
use nix::fcntl::{self, FcntlArg, OFlag};
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -52,8 +52,11 @@ impl IO for LinuxIO {
|
|||
let file = std::fs::File::options()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.custom_flags(libc::O_DIRECT)
|
||||
.open(path)?;
|
||||
// Let's attempt to enable direct I/O. Not all filesystems support it
|
||||
// so ignore any errors.
|
||||
let fd = file.as_raw_fd();
|
||||
let _= nix::fcntl::fcntl(fd, FcntlArg::F_SETFL(OFlag::O_DIRECT));
|
||||
Ok(Rc::new(LinuxFile {
|
||||
io: self.inner.clone(),
|
||||
file,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue