fix: correct misleading zero-copy/direct-io docs and internal naming (#733 Phase 1) (#3976)

This commit is contained in:
Zhengchao An
2026-06-28 09:12:49 +08:00
committed by GitHub
parent 3c6dc2a633
commit 7238a937a9
6 changed files with 48 additions and 47 deletions
+9 -9
View File
@@ -36,7 +36,7 @@ struct BitrotReaderSource {
path: String,
offset: usize,
length: usize,
use_zero_copy: bool,
use_mmap_read: bool,
}
impl BitrotReaderSource {
@@ -47,7 +47,7 @@ impl BitrotReaderSource {
rd.set_position(offset);
Ok(Some(Box::new(rd)))
} else if let Some(disk) = self.disk {
open_disk_reader(&disk, &self.bucket, &self.path, self.offset, self.length, self.use_zero_copy)
open_disk_reader(&disk, &self.bucket, &self.path, self.offset, self.length, self.use_mmap_read)
.await
.map(Some)
} else {
@@ -136,9 +136,9 @@ async fn open_disk_reader(
path: &str,
offset: usize,
length: usize,
use_zero_copy: bool,
use_mmap_read: bool,
) -> disk::error::Result<FileReader> {
if use_zero_copy && disk.is_local() {
if use_mmap_read && disk.is_local() {
let start = Instant::now();
match disk.read_file_zero_copy(bucket, path, offset, length).await {
Ok(bytes) => {
@@ -192,7 +192,7 @@ fn bitrot_encoded_range(offset: usize, length: usize, shard_size: usize, checksu
/// * `shard_size` - Shard size for erasure coding
/// * `checksum_algo` - Hash algorithm for bitrot verification
/// * `skip_verify` - If true, skip checksum verification
/// * `use_zero_copy` - If true, use zero-copy read (mmap on Unix)
/// * `use_mmap_read` - If true, use zero-copy read (mmap on Unix)
#[allow(clippy::too_many_arguments)]
pub async fn create_bitrot_reader(
inline_data: Option<&[u8]>,
@@ -204,7 +204,7 @@ pub async fn create_bitrot_reader(
shard_size: usize,
checksum_algo: HashAlgorithm,
skip_verify: bool,
use_zero_copy: bool,
use_mmap_read: bool,
) -> disk::error::Result<Option<BitrotReader<Box<dyn AsyncRead + Send + Sync + Unpin>>>> {
let (offset, length) = bitrot_encoded_range(offset, length, shard_size, checksum_algo.clone());
let source = BitrotReaderSource {
@@ -214,7 +214,7 @@ pub async fn create_bitrot_reader(
path: path.to_string(),
offset,
length,
use_zero_copy,
use_mmap_read,
};
source
@@ -234,7 +234,7 @@ pub fn create_deferred_bitrot_reader(
shard_size: usize,
checksum_algo: HashAlgorithm,
skip_verify: bool,
use_zero_copy: bool,
use_mmap_read: bool,
) -> BitrotReader<Box<dyn AsyncRead + Send + Sync + Unpin>> {
let (offset, length) = bitrot_encoded_range(offset, length, shard_size, checksum_algo.clone());
let source = BitrotReaderSource {
@@ -244,7 +244,7 @@ pub fn create_deferred_bitrot_reader(
path: path.to_string(),
offset,
length,
use_zero_copy,
use_mmap_read,
};
BitrotReader::new(Box::new(DeferredObjectReader::new(source)), shard_size, checksum_algo, skip_verify)
+2 -2
View File
@@ -362,7 +362,7 @@ impl SetDisks {
let till_offset = erasure.shard_file_offset(0, part.size, part.size);
// Read zero-copy configuration from environment variable
// Default: enabled (true) for performance
let use_zero_copy =
let use_mmap_read =
rustfs_utils::get_env_bool(ENV_OBJECT_ZERO_COPY_ENABLE, DEFAULT_OBJECT_ZERO_COPY_ENABLE);
let mut readers = Vec::with_capacity(latest_disks.len());
@@ -402,7 +402,7 @@ impl SetDisks {
erasure.shard_size(),
checksum_algo.clone(),
false,
use_zero_copy,
use_mmap_read,
)
.await
{
+7 -7
View File
@@ -819,7 +819,7 @@ async fn create_bitrot_readers_until_quorum(
shard_size: usize,
checksum_algo: HashAlgorithm,
skip_verify_bitrot: bool,
use_zero_copy: bool,
use_mmap_read: bool,
data_shards: usize,
parity_shards: usize,
mode: BitrotReaderSetupMode,
@@ -850,7 +850,7 @@ async fn create_bitrot_readers_until_quorum(
shard_size,
checksum_algo,
skip_verify_bitrot,
use_zero_copy,
use_mmap_read,
)
.await;
(idx, result)
@@ -902,7 +902,7 @@ async fn create_bitrot_readers_until_quorum(
shard_size,
checksum_algo.clone(),
skip_verify_bitrot,
use_zero_copy,
use_mmap_read,
));
setup.errors[idx] = None;
}
@@ -1972,7 +1972,7 @@ impl SetDisks {
// Read zero-copy configuration from environment variable
// Default: enabled (true) for performance
let use_zero_copy = rustfs_utils::get_env_bool(ENV_OBJECT_ZERO_COPY_ENABLE, DEFAULT_OBJECT_ZERO_COPY_ENABLE);
let use_mmap_read = rustfs_utils::get_env_bool(ENV_OBJECT_ZERO_COPY_ENABLE, DEFAULT_OBJECT_ZERO_COPY_ENABLE);
let reader_setup_stage_start = Instant::now();
let read_costs = disks
@@ -1990,7 +1990,7 @@ impl SetDisks {
erasure.shard_size(),
checksum_algo,
skip_verify_bitrot,
use_zero_copy,
use_mmap_read,
erasure.data_shards,
erasure.parity_shards,
BitrotReaderSetupMode::ReadQuorum,
@@ -2277,7 +2277,7 @@ impl SetDisks {
} else {
checksum_info.algorithm
};
let use_zero_copy = rustfs_utils::get_env_bool(ENV_OBJECT_ZERO_COPY_ENABLE, DEFAULT_OBJECT_ZERO_COPY_ENABLE);
let use_mmap_read = rustfs_utils::get_env_bool(ENV_OBJECT_ZERO_COPY_ENABLE, DEFAULT_OBJECT_ZERO_COPY_ENABLE);
let till_offset = erasure.shard_file_offset(0, part_length, part_size);
let reader_setup_stage_start = Instant::now();
@@ -2296,7 +2296,7 @@ impl SetDisks {
erasure.shard_size(),
checksum_algo,
skip_verify_bitrot,
use_zero_copy,
use_mmap_read,
erasure.data_shards,
erasure.parity_shards,
BitrotReaderSetupMode::VerifyReconstruction,