io: promote WritebackFile to pub
Bounded-cache buffered File replacement used across mux/extract/sweep/patch -- general I/O infrastructure, not recovery policy. freemkv-engine's relocated sweep/patch need to construct it directly once those methods leave this crate. No behavior change.
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ pub(crate) mod platform_macos;
|
|||||||
|
|
||||||
pub mod pipeline;
|
pub mod pipeline;
|
||||||
|
|
||||||
pub(crate) use writeback_file::WritebackFile;
|
pub use writeback_file::WritebackFile;
|
||||||
|
|
||||||
pub use pipeline::{
|
pub use pipeline::{
|
||||||
DEFAULT_PIPELINE_DEPTH, Flow, Pipeline, READ_PIPELINE_DEPTH, Sink, WRITE_PIPELINE_DEPTH,
|
DEFAULT_PIPELINE_DEPTH, Flow, Pipeline, READ_PIPELINE_DEPTH, Sink, WRITE_PIPELINE_DEPTH,
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ fn writeback_chunk_bytes() -> u64 {
|
|||||||
.unwrap_or(WRITEBACK_CHUNK_BYTES_DEFAULT)
|
.unwrap_or(WRITEBACK_CHUNK_BYTES_DEFAULT)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct WritebackFile {
|
pub struct WritebackFile {
|
||||||
file: File,
|
file: File,
|
||||||
pipeline: WritebackPipeline,
|
pipeline: WritebackPipeline,
|
||||||
pos: u64,
|
pos: u64,
|
||||||
@@ -115,7 +115,7 @@ impl WritebackFile {
|
|||||||
/// once so the pipeline starts tracking from wherever the file
|
/// once so the pipeline starts tracking from wherever the file
|
||||||
/// already is (typically 0 for fresh files; non-zero for resumed
|
/// already is (typically 0 for fresh files; non-zero for resumed
|
||||||
/// or appended files).
|
/// or appended files).
|
||||||
pub(crate) fn new(mut file: File) -> io::Result<Self> {
|
pub fn new(mut file: File) -> io::Result<Self> {
|
||||||
let pos = file.stream_position()?;
|
let pos = file.stream_position()?;
|
||||||
let pipeline = WritebackPipeline::new(&file, pos, writeback_chunk_bytes());
|
let pipeline = WritebackPipeline::new(&file, pos, writeback_chunk_bytes());
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -136,7 +136,7 @@ impl WritebackFile {
|
|||||||
/// [`Self::create_with_size_hint`] so the kernel can pre-reserve
|
/// [`Self::create_with_size_hint`] so the kernel can pre-reserve
|
||||||
/// extents.
|
/// extents.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) fn create(path: &Path) -> io::Result<Self> {
|
pub fn create(path: &Path) -> io::Result<Self> {
|
||||||
let file = File::create(path)?;
|
let file = File::create(path)?;
|
||||||
Self::new(file)
|
Self::new(file)
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ impl WritebackFile {
|
|||||||
/// On platforms without an extent-preallocation primitive this is
|
/// On platforms without an extent-preallocation primitive this is
|
||||||
/// equivalent to `create` — the size hint is dropped after a debug
|
/// equivalent to `create` — the size hint is dropped after a debug
|
||||||
/// log.
|
/// log.
|
||||||
pub(crate) fn create_with_size_hint(path: &Path, size_bytes: u64) -> io::Result<Self> {
|
pub fn create_with_size_hint(path: &Path, size_bytes: u64) -> io::Result<Self> {
|
||||||
let file = File::create(path)?;
|
let file = File::create(path)?;
|
||||||
platform::preallocate(&file, size_bytes);
|
platform::preallocate(&file, size_bytes);
|
||||||
Self::new(file)
|
Self::new(file)
|
||||||
@@ -163,7 +163,7 @@ impl WritebackFile {
|
|||||||
/// wrap it. Mirrors `File::open` semantics for the writable case
|
/// wrap it. Mirrors `File::open` semantics for the writable case
|
||||||
/// — used by patch / resume paths that mutate an existing ISO in
|
/// — used by patch / resume paths that mutate an existing ISO in
|
||||||
/// place.
|
/// place.
|
||||||
pub(crate) fn open(path: &Path) -> io::Result<Self> {
|
pub fn open(path: &Path) -> io::Result<Self> {
|
||||||
let file = OpenOptions::new().write(true).open(path)?;
|
let file = OpenOptions::new().write(true).open(path)?;
|
||||||
Self::new(file)
|
Self::new(file)
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ impl WritebackFile {
|
|||||||
/// completed. Callers needing crash-consistency (e.g. mux-finish
|
/// completed. Callers needing crash-consistency (e.g. mux-finish
|
||||||
/// then external commit/DB update) must not treat `Ok(())` as a
|
/// then external commit/DB update) must not treat `Ok(())` as a
|
||||||
/// durability barrier.
|
/// durability barrier.
|
||||||
pub(crate) fn sync_all(&mut self) -> io::Result<()> {
|
pub fn sync_all(&mut self) -> io::Result<()> {
|
||||||
if self.seek_count > 0 {
|
if self.seek_count > 0 {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
target: "mux",
|
target: "mux",
|
||||||
|
|||||||
@@ -180,6 +180,14 @@ pub use io::pipeline::{
|
|||||||
WRITE_THROUGH_DEPTH,
|
WRITE_THROUGH_DEPTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ─── Bounded-cache buffered file writer ─────────────────────────────────────
|
||||||
|
//
|
||||||
|
// Drop-in `std::fs::File` replacement used everywhere the lib writes large
|
||||||
|
// sequential output (mux, extract, sweep, patch) — drains dirty pages
|
||||||
|
// continuously instead of bursting. General I/O infra, not recovery policy;
|
||||||
|
// promoted to `pub` so freemkv-engine's relocated sweep/patch can use it too.
|
||||||
|
pub use io::WritebackFile;
|
||||||
|
|
||||||
// ─── Drive events (low-level callbacks) ─────────────────────────────────────
|
// ─── Drive events (low-level callbacks) ─────────────────────────────────────
|
||||||
pub use event::{BatchSizeReason, Event, EventKind};
|
pub use event::{BatchSizeReason, Event, EventKind};
|
||||||
pub use identity::DriveId;
|
pub use identity::DriveId;
|
||||||
|
|||||||
Reference in New Issue
Block a user