mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-02 22:26:21 +00:00
chore: merge main for the local regression run
This commit is contained in:
@@ -22,7 +22,7 @@ tracking_issue = "https://github.com/rustfs/backlog/issues/2668"
|
||||
reason = "chrono is marked unmaintained with no patched release; retained temporarily at compatibility boundaries and transitive datafusion/arrow/openidconnect dependencies during the jiff 1.0 migration reviewed in PR #9492."
|
||||
mitigation = "Informational unmaintained advisory with no CVE or memory-safety vulnerability; core server timestamp paths already migrated to jiff 1.0 in PR #9492 while remaining compatibility boundaries and upstream crates transition off chrono."
|
||||
approved_at = "2026-11-18T12:17:44Z"
|
||||
expires_at = "2026-11-30T23:59:59Z"
|
||||
expires_at = "2027-02-01T23:59:59Z"
|
||||
approval_reference = "https://github.com/rustfs/rustfs/pull/9492"
|
||||
|
||||
[[exceptions]]
|
||||
@@ -34,7 +34,7 @@ tracking_issue = "https://github.com/rustfs/backlog/issues/2668"
|
||||
reason = "chrono-tz is marked unmaintained with no patched release; pulled transitively by arrow-array 59.3.3 and datafusion-functions 55.3.0 during the jiff migration reviewed in PR #9492."
|
||||
mitigation = "Informational unmaintained advisory with no known security vulnerability; confined to transitive DataFusion/Arrow SQL timezone handling until upstream removes chrono-tz."
|
||||
approved_at = "2026-11-18T12:17:44Z"
|
||||
expires_at = "2026-11-30T23:59:59Z"
|
||||
expires_at = "2027-02-01T23:59:59Z"
|
||||
approval_reference = "https://github.com/rustfs/rustfs/pull/9492"
|
||||
|
||||
[[exceptions]]
|
||||
@@ -46,5 +46,5 @@ tracking_issue = "https://github.com/rustfs/backlog/issues/2668"
|
||||
reason = "humantime is marked unmaintained through chrono with no patched release; used by rustfs-madmin and transitively by object_store 0.13.2 / datafusion 55.3.0 as temporarily reviewed in PR #9492."
|
||||
mitigation = "Informational unmaintained advisory with no known security vulnerability; limited to duration formatting and tracked for removal alongside the remaining chrono/jiff migration."
|
||||
approved_at = "2026-11-18T12:17:44Z"
|
||||
expires_at = "2026-11-30T23:59:59Z"
|
||||
expires_at = "2027-02-01T23:59:59Z"
|
||||
approval_reference = "https://github.com/rustfs/rustfs/pull/9492"
|
||||
|
||||
@@ -211,6 +211,8 @@ jobs:
|
||||
|
||||
- name: Build selected fuzz targets
|
||||
env:
|
||||
# Keep memory-intensive instrumented rustc processes from crowding out the runner.
|
||||
CARGO_BUILD_JOBS: "2"
|
||||
FUZZ_TARGET: ${{ needs.select-targets.outputs.targets_csv }}
|
||||
run: BUILD_ONLY=1 ./scripts/fuzz/run.sh
|
||||
|
||||
|
||||
Generated
+13
-14
@@ -1264,9 +1264,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-s3"
|
||||
version = "1.162.0"
|
||||
version = "1.163.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ffd93a622eaef65d9dee213b1c8afb8b5d999aa2020fe1c9ba6a94ec5e973e4"
|
||||
checksum = "e9765cbe48081570df401ebc65cae8a9e32912fac5f4cf3c6bdb2547b8ecb62c"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"aws-credential-types",
|
||||
@@ -2112,9 +2112,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "brotli-decompressor"
|
||||
version = "6.4.0"
|
||||
version = "6.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "664148598c930650998ef56df301329ffe7b4cdb02d49b2a3fca3bcaf2185bcb"
|
||||
checksum = "50986a054f56ca3e15382f3c09abee2bf494c00311b238daae118a06bc1c15f1"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
@@ -5695,14 +5695,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "generator"
|
||||
version = "0.8.12"
|
||||
version = "0.8.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea6c6a73cd1aa4f4f00c02b109fa55d3a9d6ecc2fc4f53177b74ed6ee23b0c53"
|
||||
checksum = "66831419d9074e766421508dff218bf79d99616bc5e56e34599d3b433714a4a4"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"log",
|
||||
"rustversion",
|
||||
"windows-core 0.100.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
@@ -6844,9 +6842,9 @@ checksum = "2f0fb0570afe1fed943c5c3d4102d5358592d8625fda6a0007fdbe65a92fba96"
|
||||
|
||||
[[package]]
|
||||
name = "io-uring"
|
||||
version = "0.7.16"
|
||||
version = "0.7.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "878c26bc5e45fe089ce2ca25689260c152a87ce1d7de2ca86101efeea6973932"
|
||||
checksum = "42a8b27af47f173c8ccb750868620435d2afc8190ca314356f9dc29470274123"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
@@ -13381,8 +13379,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustfs-uring"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rustfs/uring.git?rev=eb8fc160e71d804427de1e905f5c226d580f71bf#eb8fc160e71d804427de1e905f5c226d580f71bf"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5d9b7f02481f7a178db09da8dc3ed63c85debb370ecfa8b5a015706b58025ba"
|
||||
dependencies = [
|
||||
"io-uring",
|
||||
"libc",
|
||||
@@ -14853,9 +14852,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.40.4"
|
||||
version = "0.40.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e80749408e2d8bec0ffa303012cf4e1b3b355f4a09087b4fdf7473680f6a2de"
|
||||
checksum = "0ebe31c61260d7bc4bfc204a2d096c428a4c9ef59ca48bfa693d17fec4f129ad"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"memchr",
|
||||
|
||||
+3
-3
@@ -261,7 +261,7 @@ rustls-native-certs = "0.8"
|
||||
rustls-pki-types = "1.16.0"
|
||||
x509-parser = "0.18.1"
|
||||
sha1 = "0.11.0"
|
||||
sha2 = "0.11.2"
|
||||
sha2 = "0.11.3"
|
||||
subtle = "2.6"
|
||||
zeroize = { version = "1.9.2" }
|
||||
proptest = "1"
|
||||
@@ -289,7 +289,7 @@ atomic_enum = "0.3.0"
|
||||
aws-config = { version = "1.13.4" }
|
||||
aws-credential-types = { version = "1.3.1" }
|
||||
aws-sdk-kms = { default-features = false, version = "1.134.0" }
|
||||
aws-sdk-s3 = { default-features = false, version = "1.162.0" }
|
||||
aws-sdk-s3 = { default-features = false, version = "1.163.0" }
|
||||
aws-sdk-sts = { default-features = false, version = "1.129.0" }
|
||||
aws-sdk-s3vectors = { default-features = false, version = "=1.52.0" }
|
||||
aws-smithy-async = { version = "1.3.1" }
|
||||
@@ -381,7 +381,7 @@ snap = "1.1.2"
|
||||
starshard = { version = "2.4.1" }
|
||||
strum = { version = "0.28.0" }
|
||||
sync_wrapper = "1.0.2"
|
||||
sysinfo = "0.40.4"
|
||||
sysinfo = "0.40.5"
|
||||
temp-env = "0.3.6"
|
||||
tempfile = "3.27.0"
|
||||
test-case = "3.4.1"
|
||||
|
||||
@@ -242,10 +242,10 @@ metrics = { workspace = true }
|
||||
# io-uring integration; only the tokio "io-uring" runtime feature is banned.
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
# Native completion owners keep physical I/O leases alive after cancellation.
|
||||
rustfs-uring = { git = "https://github.com/rustfs/uring.git", rev = "eb8fc160e71d804427de1e905f5c226d580f71bf" }
|
||||
rustfs-uring = "0.4.0"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dev-dependencies]
|
||||
rustfs-uring = { git = "https://github.com/rustfs/uring.git", rev = "eb8fc160e71d804427de1e905f5c226d580f71bf", features = ["fault-injection"] }
|
||||
rustfs-uring = { version = "0.4.0", features = ["fault-injection"] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi-util.workspace = true
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1130,6 +1130,7 @@ impl std::fmt::Debug for GetObjectSinkSegments {
|
||||
struct GetObjectSinkInner {
|
||||
writer: Option<GetObjectSinkWriter>,
|
||||
segments: Option<GetObjectSinkSegments>,
|
||||
max_bytes: Option<u64>,
|
||||
taken: bool,
|
||||
}
|
||||
|
||||
@@ -1148,6 +1149,7 @@ impl GetObjectSink {
|
||||
inner: Arc::new(std::sync::Mutex::new(GetObjectSinkInner {
|
||||
writer: Some(writer),
|
||||
segments: None,
|
||||
max_bytes: None,
|
||||
taken: false,
|
||||
})),
|
||||
}
|
||||
@@ -1159,11 +1161,24 @@ impl GetObjectSink {
|
||||
inner: Arc::new(std::sync::Mutex::new(GetObjectSinkInner {
|
||||
writer: Some(writer),
|
||||
segments: Some(segments),
|
||||
max_bytes: None,
|
||||
taken: false,
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
/// Bounds the resolved response byte count accepted before the sink is taken.
|
||||
#[must_use]
|
||||
pub fn with_max_bytes(self, max_bytes: u64) -> Self {
|
||||
self.lock().max_bytes = Some(max_bytes);
|
||||
self
|
||||
}
|
||||
|
||||
/// Maximum response byte count this sink can hold, when bounded.
|
||||
pub fn max_bytes(&self) -> Option<u64> {
|
||||
self.lock().max_bytes
|
||||
}
|
||||
|
||||
fn lock(&self) -> std::sync::MutexGuard<'_, GetObjectSinkInner> {
|
||||
self.inner.lock().unwrap_or_else(|poisoned| poisoned.into_inner())
|
||||
}
|
||||
|
||||
@@ -3640,6 +3640,13 @@ impl crate::storage_api_contracts::object::ObjectIO for SetDisks {
|
||||
let (producer_terminal_tx, producer_terminal_rx) = tokio::sync::oneshot::channel();
|
||||
let (mut reader, offset, length) =
|
||||
get_legacy_object_reader_with_context(&self.ctx, rd, producer_terminal_rx, range, &object_info, opts, &h).await?;
|
||||
if let Some(max_bytes) = caller_sink.as_ref().and_then(crate::object_api::GetObjectSink::max_bytes)
|
||||
&& u64::try_from(length).is_ok_and(|needed| needed > max_bytes)
|
||||
{
|
||||
return Err(StorageError::InvalidRangeSpec(format!(
|
||||
"rdma token buffer ({max_bytes} bytes) is smaller than the response ({length} bytes)"
|
||||
)));
|
||||
}
|
||||
// Carry the hook probe result so the app layer skips its now-redundant
|
||||
// lookup on the streaming miss path (ODC-16).
|
||||
reader.body_source = body_source;
|
||||
@@ -4004,6 +4011,108 @@ mod sink_segment_plan_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod get_object_sink_bounds_tests {
|
||||
use super::hermetic_set_disks_support::hermetic_set_disks_isolated;
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn undersized_get_object_sink_rejects_before_taking_sink_or_writing_bytes() {
|
||||
#[derive(Clone, Default)]
|
||||
struct RecordingSink(Arc<std::sync::Mutex<Vec<u8>>>);
|
||||
|
||||
impl tokio::io::AsyncWrite for RecordingSink {
|
||||
fn poll_write(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_cx: &mut std::task::Context<'_>,
|
||||
buf: &[u8],
|
||||
) -> std::task::Poll<std::io::Result<usize>> {
|
||||
self.0.lock().expect("sink buffer lock").extend_from_slice(buf);
|
||||
std::task::Poll::Ready(Ok(buf.len()))
|
||||
}
|
||||
|
||||
fn poll_flush(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<std::io::Result<()>> {
|
||||
std::task::Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
fn poll_shutdown(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<std::io::Result<()>> {
|
||||
std::task::Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
let (_dirs, disks, set_disks) = hermetic_set_disks_isolated(4).await;
|
||||
let bucket = "sink-max-bytes-check";
|
||||
let object = "large-plain.bin";
|
||||
for disk in &disks {
|
||||
disk.make_volume(bucket).await.expect("create fixture bucket");
|
||||
}
|
||||
let payload = b"rustfs-rdma-sink-bounds-".repeat(40_000);
|
||||
let mut upload = PutObjReader::from_vec(payload.clone());
|
||||
set_disks
|
||||
.put_object(
|
||||
bucket,
|
||||
object,
|
||||
&mut upload,
|
||||
&ObjectOptions {
|
||||
write_completion: crate::object_api::WriteCompletion::TailDrained,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("upload fixture object");
|
||||
|
||||
let recorded = RecordingSink::default();
|
||||
let undersized_sink = crate::object_api::GetObjectSink::new(GetObjectSinkWriter::new(Box::new(recorded.clone())))
|
||||
.with_max_bytes((payload.len() - 1) as u64);
|
||||
let opts = ObjectOptions {
|
||||
no_lock: true,
|
||||
get_object_sink: Some(undersized_sink.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
let error = match set_disks
|
||||
.get_object_reader(bucket, object, None, HeaderMap::new(), &opts)
|
||||
.await
|
||||
{
|
||||
Err(error) => error,
|
||||
Ok(_) => panic!("undersized sink must be rejected before opening reader"),
|
||||
};
|
||||
assert!(
|
||||
matches!(error, StorageError::InvalidRangeSpec(_)),
|
||||
"expected InvalidRangeSpec, got {error:?}"
|
||||
);
|
||||
assert!(!undersized_sink.is_taken(), "undersized sink must not be taken");
|
||||
assert!(recorded.0.lock().expect("sink buffer lock").is_empty(), "no bytes may be written");
|
||||
|
||||
let exact_recorded = RecordingSink::default();
|
||||
let fitting_sink = crate::object_api::GetObjectSink::new(GetObjectSinkWriter::new(Box::new(exact_recorded.clone())))
|
||||
.with_max_bytes(payload.len() as u64);
|
||||
let fit_opts = ObjectOptions {
|
||||
no_lock: true,
|
||||
get_object_sink: Some(fitting_sink.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut reader = set_disks
|
||||
.get_object_reader(bucket, object, None, HeaderMap::new(), &fit_opts)
|
||||
.await
|
||||
.expect("fitting sink must open reader");
|
||||
assert!(fitting_sink.is_taken(), "fitting sink must be taken by producer");
|
||||
let mut pipe_drain = Vec::new();
|
||||
reader
|
||||
.stream
|
||||
.read_to_end(&mut pipe_drain)
|
||||
.await
|
||||
.expect("wait for producer completion");
|
||||
assert!(pipe_drain.is_empty(), "pipe carries only completion when sink is used");
|
||||
assert_eq!(*exact_recorded.0.lock().expect("sink buffer lock"), payload);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod legacy_producer_stack_tests {
|
||||
use super::*;
|
||||
|
||||
@@ -1022,6 +1022,13 @@ impl PreparedGetObjectReader {
|
||||
self
|
||||
}
|
||||
|
||||
/// Attaches or clears the one-shot body sink before constructing the reader.
|
||||
#[must_use]
|
||||
pub fn with_sink(mut self, sink: Option<crate::object_api::GetObjectSink>) -> Self {
|
||||
self.opts.get_object_sink = sink;
|
||||
self
|
||||
}
|
||||
|
||||
/// Constructs the body reader while retaining the metadata snapshot's read
|
||||
/// lock, then transfers that lock to the returned stream as usual. The
|
||||
/// staged caller already performed the authoritative app-layer cache probe,
|
||||
|
||||
@@ -86,6 +86,10 @@ pub(crate) enum DataUsageCacheRevision {
|
||||
}
|
||||
|
||||
impl DataUsageCacheRevision {
|
||||
fn from_etag(etag: Option<String>) -> Option<Self> {
|
||||
etag.filter(|etag| !etag.is_empty()).map(Self::Etag)
|
||||
}
|
||||
|
||||
pub(crate) fn preconditions(&self) -> HTTPPreconditions {
|
||||
match self {
|
||||
Self::Missing => HTTPPreconditions {
|
||||
@@ -183,11 +187,7 @@ pub(crate) async fn read_config_revision<S: ScannerObjectIO>(store: Arc<S>, path
|
||||
read,
|
||||
);
|
||||
match read.await {
|
||||
Ok(reader) => reader
|
||||
.object_info
|
||||
.etag
|
||||
.filter(|etag| !etag.is_empty())
|
||||
.map(DataUsageCacheRevision::Etag)
|
||||
Ok(reader) => DataUsageCacheRevision::from_etag(reader.object_info.etag)
|
||||
.ok_or_else(|| StorageError::other(format!("scanner config object {path} has no ETag"))),
|
||||
Err(
|
||||
Error::ConfigNotFound
|
||||
|
||||
@@ -18,8 +18,26 @@ mod scan_load;
|
||||
use super::*;
|
||||
use bytes::Bytes;
|
||||
use std::sync::Arc;
|
||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
/// Compare the stored body exactly without allocating a second copy of the cache.
|
||||
pub(super) async fn cache_body_matches(reader: &mut (impl AsyncRead + Unpin), mut expected: &[u8]) -> std::io::Result<bool> {
|
||||
let mut buffer = vec![0; expected.len().clamp(1, 16 * 1024)];
|
||||
loop {
|
||||
// When the expected body ends, read at most one extra byte to verify EOF.
|
||||
let limit = buffer.len().min(expected.len().saturating_add(1));
|
||||
let read = reader.read(&mut buffer[..limit]).await?;
|
||||
if read == 0 {
|
||||
return Ok(expected.is_empty());
|
||||
}
|
||||
let Some(remaining) = expected.strip_prefix(&buffer[..read]) else {
|
||||
return Ok(false);
|
||||
};
|
||||
expected = remaining;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct CachePublicationAdmissionUnavailable;
|
||||
|
||||
@@ -96,6 +114,12 @@ impl DataUsageCacheLoadAttempt {
|
||||
}
|
||||
|
||||
impl DataUsageCacheRevisions {
|
||||
pub(crate) async fn refresh_unknown_backup<S: ScannerObjectIO>(&mut self, store: Arc<S>, name: &str) {
|
||||
if self.backup.is_none() {
|
||||
self.backup = DataUsageCache::backup_revision(store, name).await;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn matches_current_for_resume<S: ScannerObjectIO>(&self, store: Arc<S>, name: &str) -> StorageResult<bool> {
|
||||
let main = DataUsageCache::main_revision(store.clone(), name).await?;
|
||||
// A baseline decoded from backup always has its revision. An unknown
|
||||
@@ -179,6 +203,7 @@ impl DataUsageCache {
|
||||
read_config_revision(store, &main_path).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn read_revisions<S: ScannerObjectIO>(store: Arc<S>, name: &str) -> StorageResult<DataUsageCacheRevisions> {
|
||||
let main = Self::main_revision(store.clone(), name).await?;
|
||||
let backup = Self::backup_revision(store, name).await;
|
||||
@@ -556,15 +581,15 @@ impl DataUsageCache {
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) async fn retry_save_op<F, Fut>(
|
||||
pub(super) async fn retry_save_op<F, Fut, T>(
|
||||
path_type: &'static str,
|
||||
timeout_duration: Duration,
|
||||
max_retries: u32,
|
||||
mut save_op: F,
|
||||
) -> StorageResult<()>
|
||||
) -> StorageResult<T>
|
||||
where
|
||||
F: FnMut() -> Fut,
|
||||
Fut: Future<Output = StorageResult<()>>,
|
||||
Fut: Future<Output = StorageResult<T>>,
|
||||
{
|
||||
let mut last_err: Option<StorageError> = None;
|
||||
|
||||
@@ -574,9 +599,9 @@ impl DataUsageCache {
|
||||
let duration = attempt_start.elapsed();
|
||||
|
||||
match timeout_res {
|
||||
Ok(Ok(())) => {
|
||||
Ok(Ok(value)) => {
|
||||
Self::record_save_attempt(path_type, "success", duration);
|
||||
return Ok(());
|
||||
return Ok(value);
|
||||
}
|
||||
Err(e) => {
|
||||
Self::record_save_attempt(path_type, "timeout", duration);
|
||||
@@ -610,7 +635,7 @@ impl DataUsageCache {
|
||||
max_retries: u32,
|
||||
revision: Option<DataUsageCacheRevision>,
|
||||
expected_epoch: Option<u64>,
|
||||
) -> StorageResult<()> {
|
||||
) -> StorageResult<Option<DataUsageCacheRevision>> {
|
||||
Self::ensure_cache_save_metrics_registered();
|
||||
let path_type = Self::cache_path_type(path);
|
||||
let path = path.to_string();
|
||||
@@ -641,7 +666,7 @@ impl DataUsageCache {
|
||||
counter!(METRIC_CACHE_SAVE_PAYLOAD_BYTES_TOTAL, "cache" => path_type)
|
||||
.increment(u64::try_from(buf_clone.len()).unwrap_or(u64::MAX));
|
||||
if let Some(revision) = revision {
|
||||
crate::save_config_shared_with_preconditions_and_lease_fence_and_scope(
|
||||
let committed = crate::save_config_shared_with_preconditions_and_lease_fence_and_scope(
|
||||
store_clone,
|
||||
&path_clone,
|
||||
buf_clone,
|
||||
@@ -651,17 +676,19 @@ impl DataUsageCache {
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
Ok(DataUsageCacheRevision::from_etag(committed.etag))
|
||||
} else {
|
||||
save_config(store_clone, &path_clone, buf_clone.to_vec()).await?;
|
||||
Ok(None)
|
||||
}
|
||||
Ok::<(), StorageError>(())
|
||||
}
|
||||
})
|
||||
.await;
|
||||
histogram!("rustfs_scanner_cache_persist_attempt_seconds", "path_type" => path_type, "retry_result" => if save_result.is_ok() { "success" } else { "error" })
|
||||
.record(persist_started.elapsed().as_secs_f64());
|
||||
let Err(save_err) = save_result else {
|
||||
return Ok(());
|
||||
let save_err = match save_result {
|
||||
Ok(revision) => return Ok(revision),
|
||||
Err(error) => error,
|
||||
};
|
||||
|
||||
// An epoch-specific admission failure is authoritative: reconciling
|
||||
@@ -686,15 +713,17 @@ impl DataUsageCache {
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok::<bool, StorageError>(reader.read_all().await?.as_slice() == buf.as_ref())
|
||||
let matches = cache_body_matches(&mut reader, buf).await?;
|
||||
Ok::<_, StorageError>((matches, DataUsageCacheRevision::from_etag(reader.object_info.etag)))
|
||||
})
|
||||
.await;
|
||||
if matches!(reconcile, Ok(Ok(true))) {
|
||||
Self::record_save_attempt(path_type, "reconciled", Duration::ZERO);
|
||||
return Ok(());
|
||||
}
|
||||
if matches!(reconcile, Ok(Ok(false))) {
|
||||
break;
|
||||
match reconcile {
|
||||
Ok(Ok((true, revision))) => {
|
||||
Self::record_save_attempt(path_type, "reconciled", Duration::ZERO);
|
||||
return Ok(revision);
|
||||
}
|
||||
Ok(Ok((false, _))) => break,
|
||||
_ => {}
|
||||
}
|
||||
if attempt < max_retries {
|
||||
sleep(Duration::from_millis(50_u64 * (u64::from(attempt) + 1))).await;
|
||||
@@ -705,7 +734,7 @@ impl DataUsageCache {
|
||||
}
|
||||
|
||||
pub async fn save<S: ScannerObjectIO + ScannerConfigObjectDelete>(&self, store: Arc<S>, name: &str) -> StorageResult<()> {
|
||||
self.save_inner(store, name, None, None).await
|
||||
self.save_inner(store, name, None, None).await.map(drop)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -715,12 +744,14 @@ impl DataUsageCache {
|
||||
name: &str,
|
||||
revisions: &DataUsageCacheRevisions,
|
||||
) -> StorageResult<()> {
|
||||
self.save_inner(store, name, Some(revisions), None).await
|
||||
self.save_inner(store, name, Some(revisions), None).await.map(drop)
|
||||
}
|
||||
|
||||
/// All epoch-fenced cache writes use background disk admission. Incremental
|
||||
/// checkpoints pass their scan token; finalization uses a fresh token so a
|
||||
/// spent scan budget can still persist progress within the save timeout.
|
||||
/// A successful save without a confirmed primary ETag cannot supply a new
|
||||
/// baseline for another write from the same walk.
|
||||
pub(crate) async fn save_with_revisions_for_epoch<S: ScannerObjectIO + ScannerConfigObjectDelete>(
|
||||
&self,
|
||||
store: Arc<S>,
|
||||
@@ -728,7 +759,7 @@ impl DataUsageCache {
|
||||
revisions: &DataUsageCacheRevisions,
|
||||
expected_epoch: u64,
|
||||
cancellation: CancellationToken,
|
||||
) -> StorageResult<()> {
|
||||
) -> StorageResult<Option<DataUsageCacheRevisions>> {
|
||||
crate::storage_api::ecstore_with_background_disk_io(
|
||||
cancellation,
|
||||
self.save_inner(store, name, Some(revisions), Some(expected_epoch)),
|
||||
@@ -742,7 +773,7 @@ impl DataUsageCache {
|
||||
name: &str,
|
||||
revisions: Option<&DataUsageCacheRevisions>,
|
||||
expected_epoch: Option<u64>,
|
||||
) -> StorageResult<()> {
|
||||
) -> StorageResult<Option<DataUsageCacheRevisions>> {
|
||||
let serialize_started = Instant::now();
|
||||
let paged = matches!((revisions, expected_epoch), (Some(_), Some(_))) && pages::eligible(self, name);
|
||||
let encoded = if paged { Some(pages::encode(self)?) } else { None };
|
||||
@@ -792,7 +823,7 @@ impl DataUsageCache {
|
||||
.ok()
|
||||
.flatten();
|
||||
let primary_save_started = Instant::now();
|
||||
Self::save_path_with_retry(
|
||||
let main = Self::save_path_with_retry(
|
||||
store.clone(),
|
||||
&path,
|
||||
&primary_buf,
|
||||
@@ -809,8 +840,13 @@ impl DataUsageCache {
|
||||
let backup_path = path_join_buf(&[BUCKET_META_PREFIX, &backup_name]);
|
||||
let backup_timeout_duration = Self::backup_cache_save_timeout(timeout_duration, primary_save_started.elapsed());
|
||||
let backup_revision = revisions.and_then(|revisions| revisions.backup.clone());
|
||||
let mut committed = main.map(|main| DataUsageCacheRevisions {
|
||||
main,
|
||||
backup: None,
|
||||
damaged_pages: DamagedPages::default(),
|
||||
});
|
||||
if revisions.is_some() && backup_revision.is_none() {
|
||||
return Ok(());
|
||||
return Ok(committed);
|
||||
}
|
||||
let save_backup = async {
|
||||
let (backup_buf, retired) = match (&encoded, &backup_revision, expected_epoch) {
|
||||
@@ -828,7 +864,7 @@ impl DataUsageCache {
|
||||
}
|
||||
_ => (inline, [None, None]),
|
||||
};
|
||||
Self::save_path_with_retry(
|
||||
let backup = Self::save_path_with_retry(
|
||||
store.clone(),
|
||||
&backup_path,
|
||||
&backup_buf,
|
||||
@@ -839,29 +875,36 @@ impl DataUsageCache {
|
||||
)
|
||||
.await?;
|
||||
pages::reclaim_retired(store, &backup_name, retired, expected_epoch).await;
|
||||
Ok::<_, StorageError>(())
|
||||
Ok::<_, StorageError>(backup)
|
||||
};
|
||||
let backup_result = match timeout(backup_timeout_duration, save_backup).await {
|
||||
Ok(result) => result,
|
||||
Err(_) => Err(StorageError::other("scanner cache backup save timed out")),
|
||||
};
|
||||
if let Err(e) = backup_result {
|
||||
warn!(
|
||||
target: "rustfs::scanner::data_usage",
|
||||
event = EVENT_SCANNER_CACHE_SAVE_STATE,
|
||||
component = LOG_COMPONENT_SCANNER,
|
||||
subsystem = LOG_SUBSYSTEM_CACHE,
|
||||
cache_name = %name,
|
||||
backup_path = %backup_path,
|
||||
state = "backup_save_failed",
|
||||
error = %e,
|
||||
"Scanner cache backup save failed"
|
||||
);
|
||||
if is_cache_publication_admission_unavailable(&e) || is_cache_publication_epoch_changed(&e) {
|
||||
return Err(e);
|
||||
match backup_result {
|
||||
Ok(backup) => {
|
||||
if let Some(committed) = &mut committed {
|
||||
committed.backup = backup;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
target: "rustfs::scanner::data_usage",
|
||||
event = EVENT_SCANNER_CACHE_SAVE_STATE,
|
||||
component = LOG_COMPONENT_SCANNER,
|
||||
subsystem = LOG_SUBSYSTEM_CACHE,
|
||||
cache_name = %name,
|
||||
backup_path = %backup_path,
|
||||
state = "backup_save_failed",
|
||||
error = %e,
|
||||
"Scanner cache backup save failed"
|
||||
);
|
||||
if is_cache_publication_admission_unavailable(&e) || is_cache_publication_epoch_changed(&e) {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
Ok(committed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,8 @@ async fn backup_revision<S: ScannerObjectIO>(
|
||||
Err(StorageError::FileNotFound | StorageError::ObjectNotFound(..)) => return Ok(Some(DataUsageCacheRevision::Missing)),
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
if usize::try_from(reader.object_info.size).ok() == Some(expected.len()) {
|
||||
let mut bytes = Vec::with_capacity(expected.len());
|
||||
(&mut reader).take(PAGE_MAX as u64 + 1).read_to_end(&mut bytes).await?;
|
||||
if bytes == expected.as_ref() {
|
||||
return Ok(None);
|
||||
}
|
||||
if usize::try_from(reader.object_info.size).ok() == Some(expected.len()) && cache_body_matches(&mut reader, expected).await? {
|
||||
return Ok(None);
|
||||
}
|
||||
let etag = reader
|
||||
.object_info
|
||||
|
||||
@@ -226,6 +226,50 @@ impl AsyncRead for PrefixThenErrorReader {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cache_body_comparison_requires_exact_bytes_and_verified_eof() {
|
||||
use super::persistence::cache_body_matches;
|
||||
|
||||
let payload = vec![b'x'; 128 * 1024];
|
||||
for (actual, expected, matches) in [
|
||||
(payload.as_slice(), payload.as_slice(), true),
|
||||
(&payload[..payload.len() - 1], payload.as_slice(), false),
|
||||
(payload.as_slice(), &payload[..payload.len() - 1], false),
|
||||
(b"".as_slice(), b"".as_slice(), true),
|
||||
(b"x".as_slice(), b"".as_slice(), false),
|
||||
] {
|
||||
assert_eq!(
|
||||
cache_body_matches(&mut Cursor::new(actual), expected)
|
||||
.await
|
||||
.expect("compare cache body"),
|
||||
matches,
|
||||
"stored length {}, expected length {}",
|
||||
actual.len(),
|
||||
expected.len()
|
||||
);
|
||||
}
|
||||
|
||||
let mut reader = PrefixThenErrorReader {
|
||||
prefix: Cursor::new(vec![b'y']),
|
||||
failed: false,
|
||||
};
|
||||
assert!(
|
||||
!cache_body_matches(&mut reader, &payload)
|
||||
.await
|
||||
.expect("an already divergent prefix needs no further reads")
|
||||
);
|
||||
assert!(!reader.failed, "the comparison must stop before polling the unread suffix");
|
||||
|
||||
let mut reader = PrefixThenErrorReader {
|
||||
prefix: Cursor::new(payload.clone()),
|
||||
failed: false,
|
||||
};
|
||||
assert!(
|
||||
cache_body_matches(&mut reader, &payload).await.is_err(),
|
||||
"matching bytes cannot establish equality until EOF succeeds"
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct CacheReadStore {
|
||||
main: CacheReadBody,
|
||||
@@ -3104,7 +3148,7 @@ async fn test_retry_save_op_does_not_retry_namespace_lock_errors() {
|
||||
let attempts = attempts_clone.clone();
|
||||
async move {
|
||||
attempts.fetch_add(1, Ordering::SeqCst);
|
||||
Err(StorageError::NamespaceLockQuorumUnavailable {
|
||||
Err::<(), _>(StorageError::NamespaceLockQuorumUnavailable {
|
||||
mode: "write",
|
||||
bucket: RUSTFS_META_BUCKET.to_string(),
|
||||
object: "buckets/.usage-cache.bin".to_string(),
|
||||
|
||||
@@ -106,14 +106,17 @@ where
|
||||
context.ctx.clone(),
|
||||
)
|
||||
.await;
|
||||
if let Err(error) = checkpoint_save {
|
||||
record_checkpoint_save_failure(cache_name, checkpoint, &error);
|
||||
return if matches!(error, StorageError::PreconditionFailed) {
|
||||
ScannerCheckpointPersistResult::RetryBucket(error)
|
||||
} else {
|
||||
ScannerCheckpointPersistResult::Skipped
|
||||
};
|
||||
}
|
||||
let next_revisions = match checkpoint_save {
|
||||
Ok(revisions) => revisions,
|
||||
Err(error) => {
|
||||
record_checkpoint_save_failure(cache_name, checkpoint, &error);
|
||||
return if matches!(error, StorageError::PreconditionFailed) {
|
||||
ScannerCheckpointPersistResult::RetryBucket(error)
|
||||
} else {
|
||||
ScannerCheckpointPersistResult::Skipped
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if crate::remote_scanner::validate_remote_scanner_request_fence_with_store(context.cycle, context.leader_epoch, fence_store)
|
||||
.await
|
||||
@@ -125,39 +128,34 @@ where
|
||||
return ScannerCheckpointPersistResult::FenceChanged;
|
||||
}
|
||||
|
||||
match crate::storage_api::ecstore_with_background_disk_io(
|
||||
let Some(mut next_revisions) = next_revisions else {
|
||||
// The previous token was consumed. A fresh lookup could observe
|
||||
// another writer's checkpoint and give its revision to this walk.
|
||||
let error = StorageError::other("scanner checkpoint commit did not confirm a primary revision");
|
||||
record_checkpoint_save_failure(cache_name, checkpoint, &error);
|
||||
return ScannerCheckpointPersistResult::RetryBucket(error);
|
||||
};
|
||||
crate::storage_api::ecstore_with_background_disk_io(
|
||||
context.ctx.clone(),
|
||||
DataUsageCache::read_revisions(store, cache_name),
|
||||
next_revisions.refresh_unknown_backup(store, cache_name),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(next_revisions) => {
|
||||
*revisions = next_revisions;
|
||||
if let Some(source) = checkpoint.info.source {
|
||||
let saved = checkpoint.info.scan_checkpoint.as_ref().map(|cursor| {
|
||||
rustfs_scanner_metrics::metrics::ScannerCheckpointReport {
|
||||
version: cursor.version,
|
||||
resume_after: cursor.resume_after.clone(),
|
||||
reason: cursor.reason.as_str().to_string(),
|
||||
last_event: "saved".to_string(),
|
||||
}
|
||||
.await;
|
||||
*revisions = next_revisions;
|
||||
if let Some(source) = checkpoint.info.source {
|
||||
let saved =
|
||||
checkpoint
|
||||
.info
|
||||
.scan_checkpoint
|
||||
.as_ref()
|
||||
.map(|cursor| rustfs_scanner_metrics::metrics::ScannerCheckpointReport {
|
||||
version: cursor.version,
|
||||
resume_after: cursor.resume_after.clone(),
|
||||
reason: cursor.reason.as_str().to_string(),
|
||||
last_event: "saved".to_string(),
|
||||
});
|
||||
global_metrics().record_scanner_checkpoint_saved(
|
||||
source.pool_index,
|
||||
source.set_index,
|
||||
&checkpoint.info.name,
|
||||
saved,
|
||||
);
|
||||
}
|
||||
ScannerCheckpointPersistResult::Saved
|
||||
}
|
||||
Err(error) => {
|
||||
// A successful PUT consumed the old CAS revision. Reload the bucket
|
||||
// before another write instead of rebasing this scan over a newer writer.
|
||||
record_checkpoint_save_failure(cache_name, checkpoint, &error);
|
||||
ScannerCheckpointPersistResult::RetryBucket(error)
|
||||
}
|
||||
global_metrics().record_scanner_checkpoint_saved(source.pool_index, source.set_index, &checkpoint.info.name, saved);
|
||||
}
|
||||
ScannerCheckpointPersistResult::Saved
|
||||
}
|
||||
|
||||
fn record_checkpoint_save_failure(cache_name: &str, checkpoint: &DataUsageCache, error: &StorageError) {
|
||||
@@ -1559,7 +1557,7 @@ pub(super) async fn persist_scanner_service_ledger(
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(()) => true,
|
||||
Ok(_) => true,
|
||||
Err(error) => {
|
||||
log_skipped("service_order_save_failed", &error);
|
||||
false
|
||||
|
||||
@@ -2157,7 +2157,7 @@ impl ScannerIOCache for SetDisks {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(()) => true,
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
if scanner_bucket_generation_is_retired(
|
||||
&store_clone_clone,
|
||||
|
||||
@@ -889,8 +889,10 @@ async fn checkpoint_uses_global_cycle_fence_with_set_scoped_cache_revisions() {
|
||||
struct CheckpointFaultStore {
|
||||
set: Arc<SetDisks>,
|
||||
fail_put: AtomicBool,
|
||||
fail_revision_read: AtomicBool,
|
||||
lose_primary_response: AtomicBool,
|
||||
omit_primary_etag: AtomicBool,
|
||||
backup_unavailable: AtomicBool,
|
||||
reads: std::sync::atomic::AtomicUsize,
|
||||
backup_puts: std::sync::atomic::AtomicUsize,
|
||||
}
|
||||
|
||||
@@ -912,12 +914,7 @@ impl crate::storage_api::owner::ObjectIO for CheckpointFaultStore {
|
||||
headers: Self::HeaderMap,
|
||||
opts: &Self::ObjectOptions,
|
||||
) -> crate::EcstoreResult<Self::GetObjectReader> {
|
||||
if self.fail_revision_read.swap(false, Ordering::SeqCst) {
|
||||
return Err(StorageError::Io(std::io::Error::new(
|
||||
std::io::ErrorKind::Interrupted,
|
||||
"injected revision read failure",
|
||||
)));
|
||||
}
|
||||
self.reads.fetch_add(1, Ordering::SeqCst);
|
||||
if object.ends_with(".bkp") && self.backup_unavailable.load(Ordering::SeqCst) {
|
||||
return Err(StorageError::InsufficientReadQuorum(bucket.to_string(), object.to_string()));
|
||||
}
|
||||
@@ -943,7 +940,19 @@ impl crate::storage_api::owner::ObjectIO for CheckpointFaultStore {
|
||||
return Err(StorageError::PreconditionFailed);
|
||||
}
|
||||
}
|
||||
self.set.put_object(bucket, object, data, opts).await
|
||||
let mut committed = self.set.put_object(bucket, object, data, opts).await?;
|
||||
if !object.ends_with(".bkp") {
|
||||
if self.lose_primary_response.swap(false, Ordering::SeqCst) {
|
||||
return Err(StorageError::Io(std::io::Error::new(
|
||||
std::io::ErrorKind::Interrupted,
|
||||
"injected lost primary PUT response",
|
||||
)));
|
||||
}
|
||||
if self.omit_primary_etag.swap(false, Ordering::SeqCst) {
|
||||
committed.etag = None;
|
||||
}
|
||||
}
|
||||
Ok(committed)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,7 +974,7 @@ impl crate::ScannerConfigObjectDelete for CheckpointFaultStore {
|
||||
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn checkpoint_retries_next_snapshot_after_lock_failure_and_reloads_after_revision_failure() {
|
||||
async fn checkpoint_advances_only_with_confirmed_commit_revisions() {
|
||||
let (_temp_dir, fence_store) = setup_local_scanner_store(1, 4).await;
|
||||
let cycle = 8457;
|
||||
let leader_epoch = 19;
|
||||
@@ -990,8 +999,10 @@ async fn checkpoint_retries_next_snapshot_after_lock_failure_and_reloads_after_r
|
||||
let store = Arc::new(CheckpointFaultStore {
|
||||
set: set.clone(),
|
||||
fail_put: AtomicBool::new(true),
|
||||
fail_revision_read: AtomicBool::new(false),
|
||||
lose_primary_response: AtomicBool::new(false),
|
||||
omit_primary_etag: AtomicBool::new(false),
|
||||
backup_unavailable: AtomicBool::new(false),
|
||||
reads: std::sync::atomic::AtomicUsize::new(0),
|
||||
backup_puts: std::sync::atomic::AtomicUsize::new(0),
|
||||
});
|
||||
let ctx = CancellationToken::new();
|
||||
@@ -1026,10 +1037,12 @@ async fn checkpoint_retries_next_snapshot_after_lock_failure_and_reloads_after_r
|
||||
.as_mut()
|
||||
.expect("checkpoint cursor")
|
||||
.resume_after = "checkpoint-recovery/second".to_string();
|
||||
let reads = store.reads.load(Ordering::SeqCst);
|
||||
assert!(matches!(
|
||||
persist_scanner_checkpoint(store.clone(), fence_store.clone(), context(), cache_name, &checkpoint, &mut revisions).await,
|
||||
ScannerCheckpointPersistResult::Saved
|
||||
));
|
||||
assert_eq!(store.reads.load(Ordering::SeqCst), reads, "successful PUTs supply both revisions");
|
||||
assert_ne!(revisions, initial_revisions);
|
||||
let mut loaded = DataUsageCache::default();
|
||||
loaded.load(set.clone(), cache_name).await.expect("load recovered checkpoint");
|
||||
@@ -1083,6 +1096,30 @@ async fn checkpoint_retries_next_snapshot_after_lock_failure_and_reloads_after_r
|
||||
.expect("read backup after it becomes writable again");
|
||||
assert_ne!(backup_before, backup_after);
|
||||
|
||||
checkpoint
|
||||
.info
|
||||
.scan_checkpoint
|
||||
.as_mut()
|
||||
.expect("checkpoint cursor")
|
||||
.resume_after = "checkpoint-recovery/lost-response".to_string();
|
||||
let reads = store.reads.load(Ordering::SeqCst);
|
||||
store.lose_primary_response.store(true, Ordering::SeqCst);
|
||||
assert!(matches!(
|
||||
persist_scanner_checkpoint(store.clone(), fence_store.clone(), context(), cache_name, &checkpoint, &mut revisions).await,
|
||||
ScannerCheckpointPersistResult::Saved
|
||||
));
|
||||
assert_eq!(
|
||||
store.reads.load(Ordering::SeqCst),
|
||||
reads + 1,
|
||||
"reconciliation supplies the matching object's ETag"
|
||||
);
|
||||
assert_eq!(
|
||||
revisions,
|
||||
DataUsageCache::read_revisions(set.clone(), cache_name)
|
||||
.await
|
||||
.expect("committed revisions")
|
||||
);
|
||||
|
||||
let saved_revisions = revisions.clone();
|
||||
checkpoint
|
||||
.info
|
||||
@@ -1090,12 +1127,18 @@ async fn checkpoint_retries_next_snapshot_after_lock_failure_and_reloads_after_r
|
||||
.as_mut()
|
||||
.expect("checkpoint cursor")
|
||||
.resume_after = "checkpoint-recovery/third".to_string();
|
||||
store.fail_revision_read.store(true, Ordering::SeqCst);
|
||||
let reads = store.reads.load(Ordering::SeqCst);
|
||||
store.omit_primary_etag.store(true, Ordering::SeqCst);
|
||||
assert!(matches!(
|
||||
persist_scanner_checkpoint(store, fence_store, context(), cache_name, &checkpoint, &mut revisions).await,
|
||||
ScannerCheckpointPersistResult::RetryBucket(StorageError::Io(_))
|
||||
persist_scanner_checkpoint(store.clone(), fence_store, context(), cache_name, &checkpoint, &mut revisions).await,
|
||||
ScannerCheckpointPersistResult::RetryBucket(_)
|
||||
));
|
||||
assert_eq!(revisions, saved_revisions, "indeterminate revision refresh must not rebase the writer");
|
||||
assert_eq!(
|
||||
store.reads.load(Ordering::SeqCst),
|
||||
reads,
|
||||
"do not adopt a primary revision from a later read"
|
||||
);
|
||||
assert_eq!(revisions, saved_revisions, "a missing commit revision must not rebase the writer");
|
||||
loaded
|
||||
.load(set.clone(), cache_name)
|
||||
.await
|
||||
|
||||
@@ -22,11 +22,7 @@ sum(shard grant amounts) <= quota_limit
|
||||
shard.accounted_usage <= sum(shard grant amounts)
|
||||
```
|
||||
|
||||
`accounted_usage` includes committed bytes and pending positive reservation
|
||||
growth. An abort removes the pending growth; a commit removes only the pending
|
||||
record because its growth is already accounted. A reservation whose commit
|
||||
marker was persisted is removed only as a precharged reconcile candidate; the
|
||||
shard is then rebuilt from objects belonging to that shard.
|
||||
`accounted_usage` includes committed bytes and pending positive reservation growth. An abort removes pending growth. A commit removes the pending record because its growth is already accounted. Before releasing a commit-started orphan's precharged bytes, recovery revokes and drains the orphan's object publication and then reconciles the shard against its objects.
|
||||
|
||||
## Locking and fencing
|
||||
|
||||
@@ -37,13 +33,7 @@ caller object/upload -> metadata transaction -> operation lock -> allocator
|
||||
read lock -> shard write lock
|
||||
```
|
||||
|
||||
Credit refill releases the operation and shard locks before taking the
|
||||
allocator write lock. The allocator write is fenced before persistence. Shard
|
||||
reservation and settlement fence the shard before persistence. The allocator
|
||||
generation and bucket incarnation/revision are checked on every load, so a
|
||||
late writer from an older epoch fails closed. Allocator and shard paths include
|
||||
the bucket incarnation and quota revision, so a quota change starts a new epoch
|
||||
after an exact bucket bootstrap instead of reusing old grants.
|
||||
Credit refill keeps the operation lock, releases the shared allocator and shard locks, then acquires the exclusive allocator lock before reloading the requester shard. The refill may lock donor shards while it holds the exclusive allocator lock. Allocator and shard mutations are fenced before persistence. Allocator and shard paths include the bucket incarnation and quota revision, so a quota change starts a new epoch after an exact bucket bootstrap instead of reusing old grants.
|
||||
|
||||
## Crash and replay behavior
|
||||
|
||||
@@ -56,6 +46,8 @@ releasing credit for an object that may already be durable.
|
||||
Repeated commit/abort operations are keyed by the operation ID and expected
|
||||
reservation fields; mismatches fail closed.
|
||||
|
||||
When reclaiming a whole grant, the allocator first clears any bootstrap usage metadata for the affected durable donor shards. The donor records are then saved with less credit and enough remaining credit to cover their full accounted usage. The allocator publishes the returned and newly assigned credit together. Before that publication, restarting readers can re-adopt the donor's old grants. After publication, they adopt only the retained grants. The initial allocator record can describe a populated shard before that shard is materialized. An empty requester receives regular credit only after its shard record is durable. A denied refill leaves the requester unmaterialized if it did not already exist.
|
||||
|
||||
## Mixed-version rollout
|
||||
|
||||
`reservation_protocol: 2` is serialized with `reservation_quota`. A node that
|
||||
@@ -107,15 +99,9 @@ encoding that makes pre-reservation coordinators reject positive growth.
|
||||
|
||||
## Performance boundary
|
||||
|
||||
Normal v2 requests take a shared allocator read lock and one shard write lock;
|
||||
the bucket-wide allocator write lock is used only to issue a new credit chunk.
|
||||
The per-grant chunk is bounded by roughly one sixteenth of the quota (or the
|
||||
requested growth when larger), so one active shard cannot consume the entire
|
||||
remaining quota through a single speculative grant. It is a conservative upper
|
||||
bound, not a best-effort token bucket.
|
||||
Unused credit is intentionally retained until the quota epoch changes or a
|
||||
future reconciliation operation returns it, trading some capacity utilization
|
||||
for a simple crash-safe upper bound.
|
||||
Normal v2 admission acquires the shared allocator lock and reads the allocator once, then acquires the shard write lock. The same allocator snapshot remains protected until the reservation is saved. When orphan recovery frees enough local credit, the recovered and new reservations are saved together under the shared allocator lock. When a write exhausts its shard credit, the exclusive allocator lock protects the recheck, refill and reservation. If the remaining unissued credit is insufficient, the allocator can reuse whole grants from other shards, scanning at most the quota's 16 shard ledgers. Donor selection uses up to four concurrent read-only shard checks and performs no object listing. A prospective donor is fenced and reread only once a set of candidates can cover the shortfall. An insufficient candidate set leaves donor records untouched. A donor-backed refill issues the exact shortfall and returns excess credit to the common pool. An empty requester at the bootstrap generation also receives only its requested growth. Ordinary refills from unissued credit aim for roughly one sixteenth of the quota, or the shortfall when larger, within the available budget.
|
||||
|
||||
A shard can still hold idle credit inside a partly used grant. The allocator selects whole grants greedily, so it may also miss a combination of smaller grants. When the allocator cannot refill the write, the quota error reports total accounted usage across the shard ledgers, including pending growth. Deletes can leave accounted usage above the live object bytes.
|
||||
|
||||
## Quotas saved before the reservation protocols
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//! or the `?metadata=true` listing (`listing.rs`).
|
||||
//! Upstream: both S3 edges. Downstream: the store, `table_list_isolation`.
|
||||
|
||||
use super::list_objects::{listed_etag, listed_last_modified, listed_storage_class};
|
||||
use super::list_objects::{listed_etag_owned, listed_last_modified, listed_storage_class_owned};
|
||||
use super::*;
|
||||
use crate::app::storage_api::bucket_usecase::contract::list::ListOperations as _;
|
||||
use rustfs_gateway_types::OpaqueString;
|
||||
@@ -104,16 +104,44 @@ fn list_object_versions_output(
|
||||
params: ListObjectVersionsParams,
|
||||
encoding_type: Option<gateway_dto::EncodingType>,
|
||||
) -> S3Result<gateway_dto::ListObjectVersionsOutput> {
|
||||
let mut versions = Vec::new();
|
||||
let mut delete_markers = Vec::new();
|
||||
for object in info.objects.iter().filter(|object| !object.name.is_empty()) {
|
||||
let key = dto_values::stored_object_key(&object.name)?;
|
||||
let last_modified = listed_last_modified(object.mod_time);
|
||||
if object.delete_marker {
|
||||
let (version_count, delete_count) = info.objects.iter().fold((0usize, 0usize), |(v, d), object| {
|
||||
if object.name.is_empty() {
|
||||
(v, d)
|
||||
} else if object.delete_marker {
|
||||
(v, d + 1)
|
||||
} else {
|
||||
(v + 1, d)
|
||||
}
|
||||
});
|
||||
let mut versions = Vec::with_capacity(version_count);
|
||||
let mut delete_markers = Vec::with_capacity(delete_count);
|
||||
for object in info.objects {
|
||||
if object.name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let size = if object.delete_marker {
|
||||
0
|
||||
} else {
|
||||
object.get_actual_size_or_physical()
|
||||
};
|
||||
let ObjectInfo {
|
||||
name,
|
||||
mod_time,
|
||||
etag,
|
||||
storage_class,
|
||||
user_defined,
|
||||
delete_marker,
|
||||
version_id,
|
||||
is_latest,
|
||||
..
|
||||
} = object;
|
||||
let key = dto_values::stored_object_key_owned(name)?;
|
||||
let last_modified = listed_last_modified(mod_time);
|
||||
if delete_marker {
|
||||
delete_markers.push(gateway_dto::DeleteMarkerEntry {
|
||||
key,
|
||||
version_id: listed_version_id(object.version_id),
|
||||
is_latest: object.is_latest,
|
||||
version_id: listed_version_id(version_id),
|
||||
is_latest,
|
||||
last_modified,
|
||||
..Default::default()
|
||||
});
|
||||
@@ -121,11 +149,11 @@ fn list_object_versions_output(
|
||||
versions.push(gateway_dto::ObjectVersion {
|
||||
key,
|
||||
last_modified,
|
||||
size: object.get_actual_size_or_physical(),
|
||||
version_id: listed_version_id(object.version_id),
|
||||
is_latest: object.is_latest,
|
||||
e_tag: listed_etag(object),
|
||||
storage_class: listed_storage_class(object.storage_class.as_deref()),
|
||||
size,
|
||||
version_id: listed_version_id(version_id),
|
||||
is_latest,
|
||||
e_tag: listed_etag_owned(etag, &user_defined),
|
||||
storage_class: listed_storage_class_owned(storage_class),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -239,9 +239,16 @@ pub(crate) fn list_objects_v2_output(
|
||||
fetch_owner: bool,
|
||||
encoding_type: Option<gateway_dto::EncodingType>,
|
||||
) -> S3Result<gateway_dto::ListObjectsV2Output> {
|
||||
let (contents, common_prefixes) = page_entries(&info, fetch_owner)?;
|
||||
let ListObjectsV2Info {
|
||||
is_truncated,
|
||||
next_continuation_token,
|
||||
objects,
|
||||
prefixes,
|
||||
..
|
||||
} = info;
|
||||
let (contents, common_prefixes) = page_entries(objects, prefixes, fetch_owner)?;
|
||||
Ok(gateway_dto::ListObjectsV2Output {
|
||||
is_truncated: info.is_truncated,
|
||||
is_truncated,
|
||||
key_count: key_count(contents.len() + common_prefixes.len()),
|
||||
contents,
|
||||
common_prefixes,
|
||||
@@ -251,8 +258,7 @@ pub(crate) fn list_objects_v2_output(
|
||||
max_keys: params.max_keys,
|
||||
encoding_type,
|
||||
continuation_token: params.response_continuation_token.map(OpaqueString::from),
|
||||
next_continuation_token: info
|
||||
.next_continuation_token
|
||||
next_continuation_token: next_continuation_token
|
||||
.map(|cursor| OpaqueString::from(encode_list_objects_v2_continuation_token(&cursor))),
|
||||
start_after: params.response_start_after,
|
||||
..Default::default()
|
||||
@@ -275,9 +281,10 @@ fn list_objects_output(
|
||||
) -> S3Result<gateway_dto::ListObjectsOutput> {
|
||||
let cursor = info.next_continuation_token.as_deref().filter(|_| cursor_is_a_key);
|
||||
let next_marker = list_objects_next_marker(&info, cursor);
|
||||
let (contents, common_prefixes) = page_entries(&info, false)?;
|
||||
let is_truncated = info.is_truncated;
|
||||
let (contents, common_prefixes) = page_entries(info.objects, info.prefixes, false)?;
|
||||
Ok(gateway_dto::ListObjectsOutput {
|
||||
is_truncated: info.is_truncated,
|
||||
is_truncated,
|
||||
marker: marker.unwrap_or_default(),
|
||||
next_marker,
|
||||
contents,
|
||||
@@ -302,42 +309,50 @@ fn key_count(entries: usize) -> i32 {
|
||||
/// The entries of a page as an answer carries them. A keyless entry is the store's placeholder for
|
||||
/// a page boundary, never an object.
|
||||
fn page_entries(
|
||||
info: &ListObjectsV2Info,
|
||||
objects: Vec<ObjectInfo>,
|
||||
prefixes: Vec<String>,
|
||||
fetch_owner: bool,
|
||||
) -> S3Result<(Vec<gateway_dto::Object>, Vec<gateway_dto::CommonPrefix>)> {
|
||||
let contents = info
|
||||
.objects
|
||||
.iter()
|
||||
.filter(|object| !object.name.is_empty())
|
||||
.map(|object| {
|
||||
Ok(gateway_dto::Object {
|
||||
key: dto_values::stored_object_key(&object.name)?,
|
||||
last_modified: listed_last_modified(object.mod_time),
|
||||
// Compressed legacy objects may retain an unknown (-1) logical-size sentinel; never
|
||||
// expose that internal value.
|
||||
size: object.get_actual_size_or_physical(),
|
||||
e_tag: listed_etag(object),
|
||||
storage_class: listed_storage_class(object.storage_class.as_deref()),
|
||||
owner: fetch_owner.then(dto_values::owner),
|
||||
..Default::default()
|
||||
})
|
||||
})
|
||||
.collect::<S3Result<_>>()?;
|
||||
let common_prefixes = info
|
||||
.prefixes
|
||||
.iter()
|
||||
.map(|prefix| gateway_dto::CommonPrefix { prefix: prefix.clone() })
|
||||
let mut contents = Vec::with_capacity(objects.len());
|
||||
for object in objects {
|
||||
if object.name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
// Compressed legacy objects may retain an unknown (-1) logical-size sentinel; never
|
||||
// expose that internal value.
|
||||
let size = object.get_actual_size_or_physical();
|
||||
let ObjectInfo {
|
||||
name,
|
||||
mod_time,
|
||||
etag,
|
||||
storage_class,
|
||||
user_defined,
|
||||
..
|
||||
} = object;
|
||||
contents.push(gateway_dto::Object {
|
||||
key: dto_values::stored_object_key_owned(name)?,
|
||||
last_modified: listed_last_modified(mod_time),
|
||||
size,
|
||||
e_tag: listed_etag_owned(etag, &user_defined),
|
||||
storage_class: listed_storage_class_owned(storage_class),
|
||||
owner: fetch_owner.then(dto_values::owner),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
let common_prefixes = prefixes
|
||||
.into_iter()
|
||||
.map(|prefix| gateway_dto::CommonPrefix { prefix })
|
||||
.collect();
|
||||
Ok((contents, common_prefixes))
|
||||
}
|
||||
|
||||
/// The entity tag a listing shows: none for an object whose tag is an encryption fingerprint.
|
||||
pub(super) fn listed_etag(object: &ObjectInfo) -> Option<rustfs_gateway_types::ETag> {
|
||||
object
|
||||
.etag
|
||||
.as_deref()
|
||||
.filter(|_| rustfs_utils::http::etag_can_be_listed(&object.user_defined))
|
||||
.map(dto_values::stored_etag)
|
||||
pub(super) fn listed_etag_owned(
|
||||
etag: Option<String>,
|
||||
user_defined: &HashMap<String, String>,
|
||||
) -> Option<rustfs_gateway_types::ETag> {
|
||||
etag.filter(|_| rustfs_utils::http::etag_can_be_listed(user_defined))
|
||||
.map(dto_values::stored_etag_owned)
|
||||
}
|
||||
|
||||
/// A listing entry's `LastModified`. An entry the store holds without one (an on-demand migration
|
||||
@@ -348,10 +363,8 @@ pub(super) fn listed_last_modified(mod_time: Option<time::OffsetDateTime>) -> ru
|
||||
}
|
||||
|
||||
/// A listing entry's `StorageClass`, absent as [`listed_last_modified`] is.
|
||||
pub(super) fn listed_storage_class(storage_class: Option<&str>) -> gateway_dto::StorageClass {
|
||||
storage_class
|
||||
.map(|storage_class| gateway_dto::StorageClass::custom(storage_class.to_owned()))
|
||||
.unwrap_or_default()
|
||||
pub(super) fn listed_storage_class_owned(storage_class: Option<String>) -> gateway_dto::StorageClass {
|
||||
storage_class.map(gateway_dto::StorageClass::custom).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// ListObjects' `NextMarker`: on a truncated page, the key the walker stopped at (the cursor the
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
//! Object and version listing use-case operations, including the metadata listing extension.
|
||||
|
||||
use super::list_objects::listed_etag;
|
||||
use super::list_objects::listed_etag_owned;
|
||||
use super::*;
|
||||
use crate::app::metadata_listing::{MetadataListQuery, ObjectsQuery, VersionsQuery};
|
||||
use crate::app::storage_api::bucket_usecase::access::{versioned_read_action, versioned_tagging_action};
|
||||
@@ -326,15 +326,31 @@ fn encode_list_versions_value(value: &str, encoding_type: Option<&EncodingType>)
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_list_objects_v2_value(value: &str, encoding_type: Option<&EncodingType>) -> String {
|
||||
fn encode_list_versions_value_owned(value: String, encoding_type: Option<&EncodingType>) -> String {
|
||||
if encoding_type == Some(&EncodingType::URL) {
|
||||
value
|
||||
.split('/')
|
||||
.map(|part| encode(part).into_owned())
|
||||
.collect::<Vec<_>>()
|
||||
.join("/")
|
||||
match encode(&value) {
|
||||
Cow::Borrowed(_) => value,
|
||||
Cow::Owned(encoded) => encoded,
|
||||
}
|
||||
} else {
|
||||
value.to_string()
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_list_objects_v2_value_owned(value: String, encoding_type: Option<&EncodingType>) -> String {
|
||||
if encoding_type != Some(&EncodingType::URL) {
|
||||
return value;
|
||||
}
|
||||
// ListObjectsV2 preserves path separators and RFC 3986 unreserved characters.
|
||||
const ENCODE_SET: &percent_encoding::AsciiSet = &percent_encoding::NON_ALPHANUMERIC
|
||||
.remove(b'/')
|
||||
.remove(b'-')
|
||||
.remove(b'.')
|
||||
.remove(b'_')
|
||||
.remove(b'~');
|
||||
match Cow::from(percent_encoding::utf8_percent_encode(&value, ENCODE_SET)) {
|
||||
Cow::Borrowed(_) => value,
|
||||
Cow::Owned(encoded) => encoded,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +479,7 @@ fn build_list_object_versions_metadata_output(
|
||||
let common_prefixes = object_infos
|
||||
.prefixes
|
||||
.into_iter()
|
||||
.map(|prefix_value| encode_list_versions_value(&prefix_value, encoding_type))
|
||||
.map(|prefix_value| encode_list_versions_value_owned(prefix_value, encoding_type))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let entries = object_infos
|
||||
@@ -471,26 +487,44 @@ fn build_list_object_versions_metadata_output(
|
||||
.into_iter()
|
||||
.filter(|object| !object.name.is_empty())
|
||||
.map(|object| {
|
||||
let object_name = encode_list_versions_value(&object.name, encoding_type);
|
||||
let version_id = list_object_version_id(object.version_id);
|
||||
let permission = permissions
|
||||
.get(&(object.name.clone(), object.version_id))
|
||||
.copied()
|
||||
.unwrap_or_default();
|
||||
let size = if object.delete_marker {
|
||||
0
|
||||
} else {
|
||||
object.get_actual_size_or_physical()
|
||||
};
|
||||
let ObjectInfo {
|
||||
name,
|
||||
mod_time,
|
||||
etag,
|
||||
storage_class,
|
||||
user_defined,
|
||||
user_tags,
|
||||
data_blocks,
|
||||
parity_blocks,
|
||||
delete_marker,
|
||||
version_id,
|
||||
is_latest,
|
||||
..
|
||||
} = object;
|
||||
let version_id_str = list_object_version_id(version_id);
|
||||
let lookup_key = (name, version_id);
|
||||
let permission = permissions.get(&lookup_key).copied().unwrap_or_default();
|
||||
let (name, _) = lookup_key;
|
||||
let object_name = encode_list_versions_value_owned(name, encoding_type);
|
||||
let user_metadata = if permission.metadata_allowed {
|
||||
build_metadata_extension_user_metadata(&object.user_defined)
|
||||
build_metadata_extension_user_metadata(&user_defined)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let user_tags = if permission.tags_allowed && !object.user_tags.is_empty() {
|
||||
Some((*object.user_tags).clone())
|
||||
let user_tags = if permission.tags_allowed && !user_tags.is_empty() {
|
||||
Some((*user_tags).clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let internal = if permission.metadata_allowed && (object.data_blocks > 0 || object.parity_blocks > 0) {
|
||||
let internal = if permission.metadata_allowed && (data_blocks > 0 || parity_blocks > 0) {
|
||||
Some(ObjectInternalInfo {
|
||||
k: metadata_count_to_i32(object.data_blocks),
|
||||
m: metadata_count_to_i32(object.parity_blocks),
|
||||
k: metadata_count_to_i32(data_blocks),
|
||||
m: metadata_count_to_i32(parity_blocks),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@@ -502,32 +536,28 @@ fn build_list_object_versions_metadata_output(
|
||||
internal,
|
||||
};
|
||||
|
||||
if object.delete_marker {
|
||||
if delete_marker {
|
||||
ListObjectVersionMetadataEntry::DeleteMarker(
|
||||
MetadataObject {
|
||||
key: object_name,
|
||||
last_modified: object.mod_time,
|
||||
last_modified: mod_time,
|
||||
owner: Some(owner.clone()),
|
||||
version_id: Some(version_id),
|
||||
is_latest: Some(object.is_latest),
|
||||
version_id: Some(version_id_str),
|
||||
is_latest: Some(is_latest),
|
||||
..Default::default()
|
||||
},
|
||||
extension,
|
||||
)
|
||||
} else {
|
||||
ListObjectVersionMetadataEntry::Version(ObjectMetadataEntry {
|
||||
e_tag: listed_etag(&object),
|
||||
e_tag: listed_etag_owned(etag, &user_defined),
|
||||
object: MetadataObject {
|
||||
key: object_name,
|
||||
last_modified: object.mod_time,
|
||||
size: Some(object.get_actual_size_or_physical()),
|
||||
version_id: Some(version_id),
|
||||
is_latest: Some(object.is_latest),
|
||||
storage_class: Some(
|
||||
object
|
||||
.storage_class
|
||||
.unwrap_or_else(|| StorageClass::STANDARD.as_str().to_owned()),
|
||||
),
|
||||
last_modified: mod_time,
|
||||
size: Some(size),
|
||||
version_id: Some(version_id_str),
|
||||
is_latest: Some(is_latest),
|
||||
storage_class: Some(storage_class.unwrap_or_else(|| StorageClass::STANDARD.as_str().to_owned())),
|
||||
owner: Some(owner.clone()),
|
||||
},
|
||||
extension,
|
||||
@@ -539,7 +569,7 @@ fn build_list_object_versions_metadata_output(
|
||||
let next_key_marker = object_infos
|
||||
.next_marker
|
||||
.filter(|marker| !marker.is_empty())
|
||||
.map(|marker| encode_list_versions_value(&marker, encoding_type));
|
||||
.map(|marker| encode_list_versions_value_owned(marker, encoding_type));
|
||||
let next_version_id_marker = object_infos.next_version_idmarker.filter(|marker| !marker.is_empty());
|
||||
|
||||
ListObjectVersionsMetadataOutput {
|
||||
@@ -574,46 +604,51 @@ fn build_list_objects_v2_metadata_output(
|
||||
fetch_owner: bool,
|
||||
permissions: &HashMap<String, ObjectMetadataPermissions>,
|
||||
) -> ListObjectsV2MetadataOutput {
|
||||
let owner = rustfs_owner();
|
||||
|
||||
let contents = object_infos
|
||||
.objects
|
||||
.iter()
|
||||
.into_iter()
|
||||
.filter(|object| !object.name.is_empty())
|
||||
.map(|object| {
|
||||
let permission = permissions.get(&object.name).copied().unwrap_or_default();
|
||||
let size = object.get_actual_size_or_physical();
|
||||
let ObjectInfo {
|
||||
name,
|
||||
mod_time,
|
||||
etag,
|
||||
storage_class,
|
||||
user_defined,
|
||||
user_tags,
|
||||
data_blocks,
|
||||
parity_blocks,
|
||||
..
|
||||
} = object;
|
||||
let permission = permissions.get(&name).copied().unwrap_or_default();
|
||||
let user_metadata = if permission.metadata_allowed {
|
||||
build_metadata_extension_user_metadata(&object.user_defined)
|
||||
build_metadata_extension_user_metadata(&user_defined)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let user_tags = if permission.tags_allowed && !object.user_tags.is_empty() {
|
||||
Some((*object.user_tags).clone())
|
||||
let user_tags = if permission.tags_allowed && !user_tags.is_empty() {
|
||||
Some((*user_tags).clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let internal = if permission.metadata_allowed && (object.data_blocks > 0 || object.parity_blocks > 0) {
|
||||
let internal = if permission.metadata_allowed && (data_blocks > 0 || parity_blocks > 0) {
|
||||
Some(ObjectInternalInfo {
|
||||
k: metadata_count_to_i32(object.data_blocks),
|
||||
m: metadata_count_to_i32(object.parity_blocks),
|
||||
k: metadata_count_to_i32(data_blocks),
|
||||
m: metadata_count_to_i32(parity_blocks),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
ObjectMetadataEntry {
|
||||
e_tag: listed_etag(object),
|
||||
e_tag: listed_etag_owned(etag, &user_defined),
|
||||
object: MetadataObject {
|
||||
key: encode_list_objects_v2_value(&object.name, encoding_type),
|
||||
last_modified: object.mod_time,
|
||||
size: Some(object.get_actual_size_or_physical()),
|
||||
storage_class: Some(
|
||||
object
|
||||
.storage_class
|
||||
.clone()
|
||||
.unwrap_or_else(|| StorageClass::STANDARD.as_str().to_owned()),
|
||||
),
|
||||
owner: fetch_owner.then_some(owner.clone()),
|
||||
key: encode_list_objects_v2_value_owned(name, encoding_type),
|
||||
last_modified: mod_time,
|
||||
size: Some(size),
|
||||
storage_class: Some(storage_class.unwrap_or_else(|| StorageClass::STANDARD.as_str().to_owned())),
|
||||
owner: fetch_owner.then(rustfs_owner),
|
||||
..Default::default()
|
||||
},
|
||||
extension: ObjectMetadataExtension {
|
||||
@@ -628,7 +663,7 @@ fn build_list_objects_v2_metadata_output(
|
||||
let common_prefixes = object_infos
|
||||
.prefixes
|
||||
.into_iter()
|
||||
.map(|prefix| encode_list_objects_v2_value(&prefix, encoding_type))
|
||||
.map(|prefix| encode_list_objects_v2_value_owned(prefix, encoding_type))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let key_count = metadata_count_to_i32(contents.len() + common_prefixes.len());
|
||||
|
||||
@@ -69,9 +69,14 @@ pub(crate) fn stored_bucket_name(name: &str) -> S3Result<BucketName> {
|
||||
/// The store's write rule refuses every such key (pinned by `dto_values::tests`), so this is a
|
||||
/// store defect, never a key to leave out.
|
||||
pub(crate) fn stored_object_key(key: &str) -> S3Result<ObjectKey> {
|
||||
stored_object_key_owned(key.to_owned())
|
||||
}
|
||||
|
||||
/// Owned counterpart of [`stored_object_key`] that moves `key` without cloning.
|
||||
pub(crate) fn stored_object_key_owned(key: String) -> S3Result<ObjectKey> {
|
||||
// The floor alone: a request name policy also refuses control characters, which a stored key
|
||||
// can hold.
|
||||
ObjectKey::new(key.to_owned()).map_err(|rejection| {
|
||||
ObjectKey::new(key).map_err(|rejection| {
|
||||
S3Error::with_message(
|
||||
S3ErrorCode::InternalError,
|
||||
format!("a stored object key the gateway cannot represent: {rejection}"),
|
||||
@@ -130,6 +135,16 @@ pub(crate) fn stored_etag(stored: &str) -> ETag {
|
||||
ETag::from_stored(inside.to_owned())
|
||||
}
|
||||
|
||||
/// Owned counterpart of [`stored_etag`] that moves unquoted stored tags without cloning;
|
||||
/// `stored.len() >= 2` matches `stored_etag`'s `strip_prefix('"').and_then(|r| r.strip_suffix('"'))`
|
||||
/// so a single-character `"` remains unstripped.
|
||||
pub(crate) fn stored_etag_owned(stored: String) -> ETag {
|
||||
if stored.starts_with("W/\"") || (stored.starts_with('"') && stored.ends_with('"') && stored.len() >= 2) {
|
||||
return stored_etag(&stored);
|
||||
}
|
||||
ETag::from_stored(stored)
|
||||
}
|
||||
|
||||
/// A stored bucket configuration as the gateway DTO holds it: the bytes RustFS persists, read by
|
||||
/// `parse`, one of the gateway's DTO bridges. The answer carries every stored member and no other.
|
||||
///
|
||||
@@ -336,6 +351,7 @@ mod tests {
|
||||
let mut differing = Vec::new();
|
||||
for (stored, opaque, weak, main_header, gateway_header, xml) in rows {
|
||||
let etag = stored_etag(stored);
|
||||
assert_eq!(stored_etag_owned(stored.to_owned()), etag, "stored_etag_owned mismatch for {stored:?}");
|
||||
let header_fact = crate::app::object::ResponseEtag {
|
||||
opaque: etag.opaque_tag().to_owned(),
|
||||
weak: etag.is_weak(),
|
||||
@@ -351,6 +367,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
assert!(differing.is_empty(), "(stored tag, object header, gateway header, XML): {differing:?}");
|
||||
for edge in [r#"""#, r#"W/"abc"#] {
|
||||
assert_eq!(stored_etag_owned(edge.to_owned()), stored_etag(edge));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -71,8 +71,8 @@ use std::time::{Duration, Instant};
|
||||
use tokio::io::{AsyncReadExt, AsyncWrite};
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::{info, warn};
|
||||
use transport::{Error as CuObjectError, RdmaToken, RegisteredArena, Server as CuObjectServer, StagingChunk};
|
||||
pub(crate) use transport::{RDMA_BYTES_TRANSFERRED_HEADER, RDMA_REPLY_HEADER};
|
||||
use transport::{Error as CuObjectError, RegisteredArena, Server as CuObjectServer, StagingChunk};
|
||||
pub(crate) use transport::{RDMA_BYTES_TRANSFERRED_HEADER, RDMA_REPLY_HEADER, RdmaToken};
|
||||
|
||||
const LOG_COMPONENT_OBJECT: &str = "object";
|
||||
const LOG_SUBSYSTEM_CUOBJECT: &str = "cuobject";
|
||||
@@ -162,17 +162,28 @@ async fn resolve_addrs() -> io::Result<Vec<IpAddr>> {
|
||||
Ok(ips.into_iter().collect())
|
||||
}
|
||||
|
||||
/// Whether the RDMA transport of this build is switched on.
|
||||
/// Whether the S3-over-RDMA object surface of this build is switched on.
|
||||
#[cfg(not(feature = "nixl"))]
|
||||
fn transport_enabled() -> bool {
|
||||
fn s3_transport_enabled() -> bool {
|
||||
get_env_bool(rustfs_config::ENV_RUSTFS_CUOBJECT_ENABLE, rustfs_config::DEFAULT_RUSTFS_CUOBJECT_ENABLE)
|
||||
}
|
||||
|
||||
#[cfg(feature = "nixl")]
|
||||
fn transport_enabled() -> bool {
|
||||
fn s3_transport_enabled() -> bool {
|
||||
get_env_bool(rustfs_config::ENV_RUSTFS_NIXL_ENABLE, rustfs_config::DEFAULT_RUSTFS_NIXL_ENABLE)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "nixl"))]
|
||||
fn internode_nixl_enabled() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(feature = "nixl")]
|
||||
fn internode_nixl_enabled() -> bool {
|
||||
get_env_opt_str(rustfs_config::ENV_RUSTFS_INTERNODE_DATA_TRANSPORT)
|
||||
.is_some_and(|raw| raw.trim().eq_ignore_ascii_case(rustfs_config::INTERNODE_DATA_TRANSPORT_NIXL))
|
||||
}
|
||||
|
||||
/// The transport servers of this node plus (control port, chunk bytes, pool
|
||||
/// bytes) for the startup log; an empty list means the node has nowhere to
|
||||
/// serve RDMA from and keeps serving over HTTP only.
|
||||
@@ -279,13 +290,16 @@ async fn build_servers() -> io::Result<(Vec<Arc<CuObjectServer>>, u16, usize, us
|
||||
Ok((vec![server], 0, chunk_bytes, pool_bytes))
|
||||
}
|
||||
|
||||
/// Starts the RDMA transport servers of this node when the transport is
|
||||
/// enabled (`RUSTFS_CUOBJECT_ENABLE` or `RUSTFS_NIXL_ENABLE`).
|
||||
/// Starts the RDMA transport servers of this node when the S3 transport
|
||||
/// (`RUSTFS_CUOBJECT_ENABLE` or `RUSTFS_NIXL_ENABLE`) or internode NIXL
|
||||
/// (`RUSTFS_INTERNODE_DATA_TRANSPORT=nixl`) is enabled.
|
||||
///
|
||||
/// Invalid settings and server construction failures fail startup; a node
|
||||
/// without RDMA addresses logs and serves GETs over HTTP only.
|
||||
pub(crate) async fn init_cuobject_service() -> io::Result<()> {
|
||||
if !transport_enabled() {
|
||||
let s3_enabled = s3_transport_enabled();
|
||||
let internode_enabled = internode_nixl_enabled();
|
||||
if !s3_enabled && !internode_enabled {
|
||||
return Ok(());
|
||||
}
|
||||
let inflight_writes = get_env_usize(ENV_RUSTFS_CUOBJECT_INFLIGHT_WRITES, DEFAULT_RUSTFS_CUOBJECT_INFLIGHT_WRITES).max(1);
|
||||
@@ -307,7 +321,11 @@ pub(crate) async fn init_cuobject_service() -> io::Result<()> {
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
let shard_arena = install_cuobject_shard_arena(&servers).await?;
|
||||
let shard_arena = if s3_enabled {
|
||||
install_cuobject_shard_arena(&servers).await?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
#[cfg(feature = "nixl")]
|
||||
install_nixl_recv_pool(&servers)?;
|
||||
let (major, minor) = transport::library_version();
|
||||
@@ -316,6 +334,8 @@ pub(crate) async fn init_cuobject_service() -> io::Result<()> {
|
||||
component = LOG_COMPONENT_OBJECT,
|
||||
subsystem = LOG_SUBSYSTEM_CUOBJECT,
|
||||
state = "started",
|
||||
s3_enabled,
|
||||
internode_enabled,
|
||||
server_count = servers.len(),
|
||||
port,
|
||||
chunk_bytes,
|
||||
@@ -333,18 +353,20 @@ pub(crate) async fn init_cuobject_service() -> io::Result<()> {
|
||||
if let Some(server) = servers.first() {
|
||||
crate::storage::rpc::nixl_read::install_nixl_server(Arc::clone(server));
|
||||
}
|
||||
let _ = SERVICE.set(Arc::new(CuObjectService {
|
||||
servers,
|
||||
inflight_writes,
|
||||
put_read_ahead,
|
||||
get_fanout,
|
||||
get_fanout_min_bytes,
|
||||
get_fanout_budget,
|
||||
get_fanout_permits: Arc::new(tokio::sync::Semaphore::new(get_fanout_budget)),
|
||||
active_gets: Arc::new(AtomicUsize::new(0)),
|
||||
shard_arena,
|
||||
next: AtomicUsize::new(0),
|
||||
}));
|
||||
if s3_enabled {
|
||||
let _ = SERVICE.set(Arc::new(CuObjectService {
|
||||
servers,
|
||||
inflight_writes,
|
||||
put_read_ahead,
|
||||
get_fanout,
|
||||
get_fanout_min_bytes,
|
||||
get_fanout_budget,
|
||||
get_fanout_permits: Arc::new(tokio::sync::Semaphore::new(get_fanout_budget)),
|
||||
active_gets: Arc::new(AtomicUsize::new(0)),
|
||||
shard_arena,
|
||||
next: AtomicUsize::new(0),
|
||||
}));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -577,6 +599,9 @@ pub(crate) fn rdma_token_for_request(headers: &HeaderMap) -> Option<RdmaToken> {
|
||||
}
|
||||
|
||||
fn transfer_error(context: &str, error: CuObjectError) -> S3Error {
|
||||
if matches!(error, CuObjectError::TokenTooSmall { .. }) {
|
||||
return S3Error::with_message(S3ErrorCode::InvalidRange, error.to_string());
|
||||
}
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("rdma get {context}: {error}"))
|
||||
}
|
||||
|
||||
@@ -841,7 +866,7 @@ pub(crate) fn rdma_put_body(bucket: &str, key: &str, token: &RdmaToken) -> S3Res
|
||||
let read_ahead = service.put_read_ahead;
|
||||
let total = token.buffer_len;
|
||||
let length = usize::try_from(total).map_err(|_| S3Error::with_message(S3ErrorCode::EntityTooLarge, "rdma put too large"))?;
|
||||
let mut reads = PutReads {
|
||||
let reads = PutReads {
|
||||
server,
|
||||
object: format!("{bucket}/{key}"),
|
||||
token: token.clone(),
|
||||
@@ -849,7 +874,6 @@ pub(crate) fn rdma_put_body(bucket: &str, key: &str, token: &RdmaToken) -> S3Res
|
||||
read_ahead,
|
||||
pending: VecDeque::new(),
|
||||
};
|
||||
reads.prefetch();
|
||||
let stream = futures::stream::try_unfold(reads, move |mut reads| async move {
|
||||
let Some(chunk) = reads.next().await? else { return Ok(None) };
|
||||
Ok::<_, io::Error>(Some((Bytes::from_owner(chunk), reads)))
|
||||
@@ -1409,3 +1433,37 @@ pub(crate) async fn finish_get_through_sink(
|
||||
);
|
||||
Ok(moved)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn token_too_small_maps_to_invalid_range() {
|
||||
let error = transfer_error(
|
||||
"write",
|
||||
CuObjectError::TokenTooSmall {
|
||||
buffer: 1024,
|
||||
needed: 2048,
|
||||
},
|
||||
);
|
||||
assert_eq!(error.code(), &S3ErrorCode::InvalidRange);
|
||||
|
||||
let other = transfer_error("write", CuObjectError::PoolExhausted);
|
||||
assert_eq!(other.code(), &S3ErrorCode::InternalError);
|
||||
}
|
||||
|
||||
#[cfg(feature = "nixl")]
|
||||
#[test]
|
||||
fn internode_nixl_switch_recognizes_trimmed_nixl_backend() {
|
||||
temp_env::with_var(rustfs_config::ENV_RUSTFS_INTERNODE_DATA_TRANSPORT, Some(" nixl "), || {
|
||||
assert!(internode_nixl_enabled());
|
||||
});
|
||||
temp_env::with_var(rustfs_config::ENV_RUSTFS_INTERNODE_DATA_TRANSPORT, Some("tcp-http"), || {
|
||||
assert!(!internode_nixl_enabled());
|
||||
});
|
||||
temp_env::with_var_unset(rustfs_config::ENV_RUSTFS_INTERNODE_DATA_TRANSPORT, || {
|
||||
assert!(!internode_nixl_enabled());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+105
-16
@@ -392,6 +392,8 @@ struct GetObjectReadSetup {
|
||||
struct GetObjectPreparedRead {
|
||||
io_planning: GetObjectIoPlanning,
|
||||
read_setup: GetObjectReadSetup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink: Option<super::cuobject::StagingSinkHandle>,
|
||||
}
|
||||
|
||||
struct GetObjectStrategyContext {
|
||||
@@ -3024,6 +3026,52 @@ impl DefaultObjectUsecase {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
fn ensure_rdma_token_fits_object(
|
||||
rdma_token: Option<&super::cuobject::RdmaToken>,
|
||||
rs: &Option<HTTPRangeSpec>,
|
||||
opts: &ObjectOptions,
|
||||
info: &ObjectInfo,
|
||||
) -> S3Result<()> {
|
||||
if let Some(token) = rdma_token
|
||||
&& let Some(expected) = get_object_body_cache_plaintext_len(rs, opts, info)
|
||||
&& u64::try_from(expected).is_ok_and(|needed| needed > token.buffer_len)
|
||||
{
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::InvalidRange,
|
||||
format!(
|
||||
"rdma token buffer ({} bytes) is smaller than the response ({expected} bytes)",
|
||||
token.buffer_len
|
||||
),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
async fn prepare_rdma_sink_for_object(
|
||||
bucket: &str,
|
||||
key: &str,
|
||||
rdma_token: Option<&super::cuobject::RdmaToken>,
|
||||
rs: &Option<HTTPRangeSpec>,
|
||||
opts: &ObjectOptions,
|
||||
info: &ObjectInfo,
|
||||
) -> S3Result<(
|
||||
Option<crate::app::storage_api::object_usecase::StorageGetObjectSink>,
|
||||
Option<super::cuobject::StagingSinkHandle>,
|
||||
)> {
|
||||
let Some(token) = rdma_token else {
|
||||
return Ok((None, None));
|
||||
};
|
||||
Self::ensure_rdma_token_fits_object(Some(token), rs, opts, info)?;
|
||||
if info.is_compressed() || info.is_encrypted() {
|
||||
return Ok((None, None));
|
||||
}
|
||||
let handle = super::cuobject::StagingSinkHandle::new(bucket, key, token).await?;
|
||||
let sink = handle.sink().with_max_bytes(token.buffer_len);
|
||||
Ok((Some(sink), Some(handle)))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn prepare_get_object_read_execution(
|
||||
&self,
|
||||
@@ -3046,6 +3094,8 @@ impl DefaultObjectUsecase {
|
||||
let read_principal = SseKmsPrincipal::from_request(envelope);
|
||||
let cache_adapter = self.object_data_cache();
|
||||
let conditional = has_read_preconditions(envelope.headers());
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let rdma_token = super::cuobject::rdma_token_for_request(envelope.headers());
|
||||
if cache_adapter.is_disabled() {
|
||||
let io_planning = Self::acquire_get_object_io_planning(
|
||||
manager,
|
||||
@@ -3072,6 +3122,14 @@ impl DefaultObjectUsecase {
|
||||
// entering `into_reader()`, which unwraps the stored DEK inside
|
||||
// ecstore without a request principal (rustfs/backlog#2702).
|
||||
authorize_sse_kms_object_read(read_principal.as_ref(), &prepared.object_info().user_defined).await?;
|
||||
if conditional {
|
||||
Self::validate_get_object_before_body(envelope, input, bucket, key, part_number, prepared.object_info()).await?;
|
||||
}
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let (sink, rdma_sink) =
|
||||
Self::prepare_rdma_sink_for_object(bucket, key, rdma_token.as_ref(), &rs, opts, prepared.object_info()).await?;
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let prepared = prepared.with_sink(sink);
|
||||
let reader = track_object_read_setup(
|
||||
object_traffic_health.as_deref(),
|
||||
Self::with_get_object_conditions(
|
||||
@@ -3097,7 +3155,12 @@ impl DefaultObjectUsecase {
|
||||
read_principal.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
return Ok(GetObjectPreparedRead { io_planning, read_setup });
|
||||
return Ok(GetObjectPreparedRead {
|
||||
io_planning,
|
||||
read_setup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink,
|
||||
});
|
||||
}
|
||||
|
||||
// Preserve the legacy metadata-fanout bound without making followers
|
||||
@@ -3129,6 +3192,8 @@ impl DefaultObjectUsecase {
|
||||
Self::validate_get_object_before_body(envelope, input, bucket, key, part_number, initial_metadata.object_info())
|
||||
.await?;
|
||||
}
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
Self::ensure_rdma_token_fits_object(rdma_token.as_ref(), &rs, opts, initial_metadata.object_info())?;
|
||||
let mut prepared = Some(initial_metadata);
|
||||
'snapshot: {
|
||||
let info = prepared
|
||||
@@ -3193,6 +3258,8 @@ impl DefaultObjectUsecase {
|
||||
return Ok(GetObjectPreparedRead {
|
||||
io_planning: Self::get_object_io_planning_without_disk(manager),
|
||||
read_setup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink: None,
|
||||
});
|
||||
}
|
||||
if matches!(legacy_probe, GetObjectBodyCacheHookLookup::Miss) {
|
||||
@@ -3224,6 +3291,8 @@ impl DefaultObjectUsecase {
|
||||
return Ok(GetObjectPreparedRead {
|
||||
io_planning: Self::get_object_io_planning_without_disk(manager),
|
||||
read_setup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3428,6 +3497,8 @@ impl DefaultObjectUsecase {
|
||||
return Ok(GetObjectPreparedRead {
|
||||
io_planning: Self::get_object_io_planning_without_disk(manager),
|
||||
read_setup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink: None,
|
||||
});
|
||||
}
|
||||
ColdFillCoordinateOutcome::Bypass => {
|
||||
@@ -3438,10 +3509,20 @@ impl DefaultObjectUsecase {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let rdma_sink;
|
||||
let (mut io_planning, reader) = if let Some(prepared) = prepared.take() {
|
||||
let io_planning = metadata_admission
|
||||
.take()
|
||||
.ok_or_else(|| s3_error!(InternalError, "prepared metadata admission is unavailable"))?;
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let prepared = {
|
||||
let (sink, handle) =
|
||||
Self::prepare_rdma_sink_for_object(bucket, key, rdma_token.as_ref(), &rs, opts, prepared.object_info())
|
||||
.await?;
|
||||
rdma_sink = handle;
|
||||
prepared.with_sink(sink)
|
||||
};
|
||||
let reader = track_object_read_setup(
|
||||
object_traffic_health.as_deref(),
|
||||
Self::with_get_object_conditions(
|
||||
@@ -3477,6 +3558,17 @@ impl DefaultObjectUsecase {
|
||||
.await
|
||||
.map_err(map_get_object_reader_error)?;
|
||||
authorize_sse_kms_object_read(read_principal.as_ref(), &prepared.object_info().user_defined).await?;
|
||||
if conditional {
|
||||
Self::validate_get_object_before_body(envelope, input, bucket, key, part_number, prepared.object_info()).await?;
|
||||
}
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let prepared = {
|
||||
let (sink, handle) =
|
||||
Self::prepare_rdma_sink_for_object(bucket, key, rdma_token.as_ref(), &rs, opts, prepared.object_info())
|
||||
.await?;
|
||||
rdma_sink = handle;
|
||||
prepared.with_sink(sink)
|
||||
};
|
||||
let reader = track_object_read_setup(
|
||||
object_traffic_health.as_deref(),
|
||||
Self::with_get_object_conditions(
|
||||
@@ -3515,7 +3607,12 @@ impl DefaultObjectUsecase {
|
||||
read_stage_start.elapsed().as_secs_f64(),
|
||||
);
|
||||
}
|
||||
Ok(GetObjectPreparedRead { io_planning, read_setup })
|
||||
Ok(GetObjectPreparedRead {
|
||||
io_planning,
|
||||
read_setup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink,
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -4904,19 +5001,6 @@ impl DefaultObjectUsecase {
|
||||
opts,
|
||||
} = request_context;
|
||||
drop(object_metadata_progress);
|
||||
// cuObject S3-over-RDMA: hand the storage layer a sink that writes decoded
|
||||
// bytes straight into registered staging (no pipe, no consumer copy). The
|
||||
// owned handle moves to the body builder after the read is prepared.
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
let (opts, rdma_sink) = match super::cuobject::rdma_token_for_request(envelope.headers()) {
|
||||
Some(token) => {
|
||||
let handle = super::cuobject::StagingSinkHandle::new(&bucket, &key, &token).await?;
|
||||
let mut opts = opts;
|
||||
opts.get_object_sink = Some(handle.sink());
|
||||
(opts, Some(handle))
|
||||
}
|
||||
None => (opts, None),
|
||||
};
|
||||
|
||||
let manager = get_concurrency_manager();
|
||||
|
||||
@@ -5014,7 +5098,12 @@ impl DefaultObjectUsecase {
|
||||
return finish_object_read_error(&mut envelope, helper.version_id(version_id_for_event), err).await;
|
||||
}
|
||||
};
|
||||
let GetObjectPreparedRead { io_planning, read_setup } = prepared_read;
|
||||
let GetObjectPreparedRead {
|
||||
io_planning,
|
||||
read_setup,
|
||||
#[cfg(all(any(feature = "cuobject", feature = "nixl"), target_os = "linux"))]
|
||||
rdma_sink,
|
||||
} = prepared_read;
|
||||
let GetObjectIoPlanning {
|
||||
disk_permit,
|
||||
permit_wait_duration,
|
||||
|
||||
Reference in New Issue
Block a user