pub struct SmartCopier {Show 19 fields
pub ring: IoUring,
pub buffer_pool: BufferPool,
pub atomic_buffer_pool: Option<BufferPool>,
pub async_fd: Arc<AsyncFd<RawFd>>,
pub vdo_opt: bool,
pub direct_io_ok: bool,
pub source_caps: Arc<Capabilities>,
pub target_caps: Arc<Capabilities>,
pub vdo_stall_threshold: u32,
pub barrier_callback: Option<Box<dyn Fn(u64) + Send + Sync>>,
pub source_uncached: bool,
pub target_uncached: bool,
pub governor: Option<Arc<Governor>>,
pub fsync_tracker: FsyncLatencyTracker,
pub skip_fsync: bool,
pub segment_stall_timeout_secs: u64,
pub segment_overall_timeout_secs: u64,
pub postcopy_ring: IoUring,
pub postcopy_async_fd: Arc<AsyncFd<RawFd>>,
}Expand description
Async copy engine backed by io_uring with auto-adaptive tier selection
Probes source/target capabilities and selects the fastest copy path: reflink (FICLONE), copy_file_range, sendfile, or pipelined io_uring.
Fields§
§ring: IoUringio_uring instance for async I/O submission
buffer_pool: BufferPoolRegistered buffer pool for io_uring fixed-buffer reads/writes
atomic_buffer_pool: Option<BufferPool>Separate aligned buffer pool for hardware atomic writes (RWF_ATOMIC)
async_fd: Arc<AsyncFd<RawFd>>Async wrapper around the io_uring eventfd for tokio integration
vdo_opt: boolEnable VDO zero-block optimization (punch holes for all-zero blocks)
direct_io_ok: boolWhether O_DIRECT is safe on the target filesystem
source_caps: Arc<Capabilities>Detected capabilities of the source filesystem
target_caps: Arc<Capabilities>Detected capabilities of the target filesystem
vdo_stall_threshold: u32Number of consecutive zero blocks before triggering VDO stall warning
barrier_callback: Option<Box<dyn Fn(u64) + Send + Sync>>Optional callback invoked after each file copy with the target inode
source_uncached: boolUse RWF_UNCACHED for source reads
target_uncached: boolUse RWF_UNCACHED for target writes
governor: Option<Arc<Governor>>PSI-based system stress governor
fsync_tracker: FsyncLatencyTrackerAdaptive fsync timeout tracker
skip_fsync: boolSkip fsync after writes (for batch operations that fsync at the end)
segment_stall_timeout_secs: u64Seconds without progress before declaring a segment stall
segment_overall_timeout_secs: u64Maximum seconds for an entire segment copy before timeout
postcopy_ring: IoUringSeparate io_uring ring for postcopy operations (rename, fsync, unlink, link, symlink, truncate, statx).
Uses IORING_SETUP_ATTACH_WQ to share the kernel async worker pool with ring.
postcopy_async_fd: Arc<AsyncFd<RawFd>>Async eventfd wrapper for the postcopy ring.
Implementations§
Source§impl SmartCopier
impl SmartCopier
Sourcepub async fn optimized_statx_nlink(&mut self, path: PathBuf) -> Result<u64>
pub async fn optimized_statx_nlink(&mut self, path: PathBuf) -> Result<u64>
Stat a path via io_uring Statx requesting only STATX_NLINK, returning the
hard-link count. Falls back to spawn_blocking(std::fs::metadata) when the
kernel returns EOPNOTSUPP or EINVAL (e.g. older kernels, NFS).
Source§impl SmartCopier
impl SmartCopier
Sourcepub async fn copy(
src: &Path,
dst: &Path,
ring: &mut IoUring,
buffer_pool: &mut BufferPool,
atomic_pool: Option<&mut BufferPool>,
async_fd: Arc<AsyncFd<RawFd>>,
vdo_opt: bool,
offset: u64,
length: u64,
direct_io_ok: bool,
src_file_size: u64,
source_caps: &Arc<Capabilities>,
target_caps: &Arc<Capabilities>,
vdo_stall_threshold: u32,
source_uncached: bool,
target_uncached: bool,
barrier_callback: &Option<Box<dyn Fn(u64) + Send + Sync>>,
governor: Option<Arc<Governor>>,
target_label: String,
fsync_tracker: &mut FsyncLatencyTracker,
skip_fsync: bool,
segment_stall_timeout_secs: u64,
segment_overall_timeout_secs: u64,
is_sparse: bool,
postcopy_ring: &mut IoUring,
postcopy_async_fd: &Arc<AsyncFd<RawFd>>,
) -> Result<CopyStats>
pub async fn copy( src: &Path, dst: &Path, ring: &mut IoUring, buffer_pool: &mut BufferPool, atomic_pool: Option<&mut BufferPool>, async_fd: Arc<AsyncFd<RawFd>>, vdo_opt: bool, offset: u64, length: u64, direct_io_ok: bool, src_file_size: u64, source_caps: &Arc<Capabilities>, target_caps: &Arc<Capabilities>, vdo_stall_threshold: u32, source_uncached: bool, target_uncached: bool, barrier_callback: &Option<Box<dyn Fn(u64) + Send + Sync>>, governor: Option<Arc<Governor>>, target_label: String, fsync_tracker: &mut FsyncLatencyTracker, skip_fsync: bool, segment_stall_timeout_secs: u64, segment_overall_timeout_secs: u64, is_sparse: bool, postcopy_ring: &mut IoUring, postcopy_async_fd: &Arc<AsyncFd<RawFd>>, ) -> Result<CopyStats>
Copy a file (or range) from src to dst using the full io_uring pipeline
Sourcepub async fn copy_with_limit(
src: &Path,
dst: &Path,
ring: &mut IoUring,
buffer_pool: &mut BufferPool,
atomic_pool: Option<&mut BufferPool>,
async_fd: Arc<AsyncFd<RawFd>>,
vdo_opt: bool,
offset: u64,
length: u64,
direct_io_ok: bool,
src_file_size: u64,
source_caps: &Arc<Capabilities>,
target_caps: &Arc<Capabilities>,
vdo_stall_threshold: u32,
source_uncached: bool,
target_uncached: bool,
barrier_callback: &Option<Box<dyn Fn(u64) + Send + Sync>>,
governor: Option<Arc<Governor>>,
target_label: String,
fsync_tracker: &mut FsyncLatencyTracker,
buffer_limit: Option<usize>,
skip_fsync: bool,
segment_stall_timeout_secs: u64,
segment_overall_timeout_secs: u64,
is_sparse: bool,
postcopy_ring: &mut IoUring,
postcopy_async_fd: &Arc<AsyncFd<RawFd>>,
) -> Result<CopyStats>
pub async fn copy_with_limit( src: &Path, dst: &Path, ring: &mut IoUring, buffer_pool: &mut BufferPool, atomic_pool: Option<&mut BufferPool>, async_fd: Arc<AsyncFd<RawFd>>, vdo_opt: bool, offset: u64, length: u64, direct_io_ok: bool, src_file_size: u64, source_caps: &Arc<Capabilities>, target_caps: &Arc<Capabilities>, vdo_stall_threshold: u32, source_uncached: bool, target_uncached: bool, barrier_callback: &Option<Box<dyn Fn(u64) + Send + Sync>>, governor: Option<Arc<Governor>>, target_label: String, fsync_tracker: &mut FsyncLatencyTracker, buffer_limit: Option<usize>, skip_fsync: bool, segment_stall_timeout_secs: u64, segment_overall_timeout_secs: u64, is_sparse: bool, postcopy_ring: &mut IoUring, postcopy_async_fd: &Arc<AsyncFd<RawFd>>, ) -> Result<CopyStats>
Copy with an optional buffer count limit for backpressure control
Source§impl SmartCopier
impl SmartCopier
Sourcepub async fn copy_delta(
&mut self,
src: &Path,
dst: &Path,
dirty_ranges: &[DirtyRange],
file_size: u64,
label: &str,
) -> Result<CopyStats>
pub async fn copy_delta( &mut self, src: &Path, dst: &Path, dirty_ranges: &[DirtyRange], file_size: u64, label: &str, ) -> Result<CopyStats>
Copy only the specified dirty ranges from src to dst.
Each DirtyRange triggers an optimized_copy_range() call.
Trait Implementations§
Source§impl OptimizedFs for SmartCopier
impl OptimizedFs for SmartCopier
Source§fn optimized_copy(
&mut self,
src: PathBuf,
dst: PathBuf,
src_file_size: u64,
target_label: String,
buffer_limit: Option<usize>,
skip_fsync: bool,
is_sparse: bool,
) -> impl Future<Output = Result<CopyStats>> + Send
fn optimized_copy( &mut self, src: PathBuf, dst: PathBuf, src_file_size: u64, target_label: String, buffer_limit: Option<usize>, skip_fsync: bool, is_sparse: bool, ) -> impl Future<Output = Result<CopyStats>> + Send
Source§fn optimized_rename(
&mut self,
src: PathBuf,
dst: PathBuf,
flags: u32,
) -> impl Future<Output = Result<CopyStats>> + Send
fn optimized_rename( &mut self, src: PathBuf, dst: PathBuf, flags: u32, ) -> impl Future<Output = Result<CopyStats>> + Send
Source§fn optimized_copy_range(
&mut self,
src: PathBuf,
dst: PathBuf,
offset: u64,
length: u64,
src_file_size: u64,
target_label: String,
buffer_limit: Option<usize>,
skip_fsync: bool,
) -> impl Future<Output = Result<CopyStats>> + Send
fn optimized_copy_range( &mut self, src: PathBuf, dst: PathBuf, offset: u64, length: u64, src_file_size: u64, target_label: String, buffer_limit: Option<usize>, skip_fsync: bool, ) -> impl Future<Output = Result<CopyStats>> + Send
Source§fn optimized_truncate(
&mut self,
dst: PathBuf,
size: u64,
) -> impl Future<Output = Result<CopyStats>> + Send
fn optimized_truncate( &mut self, dst: PathBuf, size: u64, ) -> impl Future<Output = Result<CopyStats>> + Send
Source§fn optimized_fallocate(
&mut self,
dst: PathBuf,
mode: i32,
offset: u64,
length: u64,
) -> impl Future<Output = Result<CopyStats>> + Send
fn optimized_fallocate( &mut self, dst: PathBuf, mode: i32, offset: u64, length: u64, ) -> impl Future<Output = Result<CopyStats>> + Send
Source§fn optimized_unlink(
&mut self,
path: PathBuf,
is_dir: bool,
) -> impl Future<Output = Result<CopyStats>> + Send
fn optimized_unlink( &mut self, path: PathBuf, is_dir: bool, ) -> impl Future<Output = Result<CopyStats>> + Send
Auto Trait Implementations§
impl Freeze for SmartCopier
impl !RefUnwindSafe for SmartCopier
impl Send for SmartCopier
impl Sync for SmartCopier
impl Unpin for SmartCopier
impl UnsafeUnpin for SmartCopier
impl !UnwindSafe for SmartCopier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more