From 3c5e20b633b7e4f141f80b9e0bae9674095390d5 Mon Sep 17 00:00:00 2001 From: Nugine Date: Sun, 15 Jun 2025 21:01:38 +0800 Subject: [PATCH] refactor(ecstore): `DiskAPI::rename_part` `meta` use `Bytes` --- ecstore/src/disk/local.rs | 5 +++-- ecstore/src/disk/mod.rs | 5 +++-- ecstore/src/disk/remote.rs | 5 +++-- ecstore/src/set_disk.rs | 5 +++-- rustfs/src/grpc.rs | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 25870964e..0771f0d88 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -38,6 +38,7 @@ use rustfs_utils::path::{ }; use crate::erasure_coding::bitrot_verify; +use bytes::Bytes; use common::defer; use path_absolutize::Absolutize; use rustfs_filemeta::{ @@ -1250,7 +1251,7 @@ impl DiskAPI for LocalDisk { } #[tracing::instrument(level = "debug", skip(self))] - async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Vec) -> Result<()> { + async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Bytes) -> Result<()> { let src_volume_dir = self.get_bucket_path(src_volume)?; let dst_volume_dir = self.get_bucket_path(dst_volume)?; if !skip_access_checks(src_volume) { @@ -1303,7 +1304,7 @@ impl DiskAPI for LocalDisk { rename_all(&src_file_path, &dst_file_path, &dst_volume_dir).await?; - self.write_all(dst_volume, format!("{}.meta", dst_path).as_str(), meta) + self.write_all(dst_volume, format!("{}.meta", dst_path).as_str(), meta.to_vec()) .await?; if let Some(parent) = src_file_path.parent() { diff --git a/ecstore/src/disk/mod.rs b/ecstore/src/disk/mod.rs index a6369808c..8fc016017 100644 --- a/ecstore/src/disk/mod.rs +++ b/ecstore/src/disk/mod.rs @@ -22,6 +22,7 @@ use crate::heal::{ data_usage_cache::{DataUsageCache, DataUsageEntry}, heal_commands::{HealScanMode, HealingTracker}, }; +use bytes::Bytes; use endpoint::Endpoint; use error::DiskError; use error::{Error, Result}; @@ -319,7 +320,7 @@ impl DiskAPI for Disk { } #[tracing::instrument(skip(self))] - async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Vec) -> Result<()> { + async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Bytes) -> Result<()> { match self { Disk::Local(local_disk) => local_disk.rename_part(src_volume, src_path, dst_volume, dst_path, meta).await, Disk::Remote(remote_disk) => { @@ -493,7 +494,7 @@ pub trait DiskAPI: Debug + Send + Sync + 'static { async fn create_file(&self, origvolume: &str, volume: &str, path: &str, file_size: usize) -> Result; // ReadFileStream async fn rename_file(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str) -> Result<()>; - async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Vec) -> Result<()>; + async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Bytes) -> Result<()>; async fn delete(&self, volume: &str, path: &str, opt: DeleteOptions) -> Result<()>; // VerifyFile async fn verify_file(&self, volume: &str, path: &str, fi: &FileInfo) -> Result; diff --git a/ecstore/src/disk/remote.rs b/ecstore/src/disk/remote.rs index 511022cc6..7160dd545 100644 --- a/ecstore/src/disk/remote.rs +++ b/ecstore/src/disk/remote.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +use bytes::Bytes; use futures::lock::Mutex; use http::{HeaderMap, Method}; use protos::{ @@ -649,7 +650,7 @@ impl DiskAPI for RemoteDisk { } #[tracing::instrument(skip(self))] - async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Vec) -> Result<()> { + async fn rename_part(&self, src_volume: &str, src_path: &str, dst_volume: &str, dst_path: &str, meta: Bytes) -> Result<()> { info!("rename_part {}/{}", src_volume, src_path); let mut client = node_service_time_out_client(&self.addr) .await @@ -660,7 +661,7 @@ impl DiskAPI for RemoteDisk { src_path: src_path.to_string(), dst_volume: dst_volume.to_string(), dst_path: dst_path.to_string(), - meta, + meta: meta.to_vec(), }); let response = client.rename_part(request).await?.into_inner(); diff --git a/ecstore/src/set_disk.rs b/ecstore/src/set_disk.rs index 05fa3893b..271cc4c9a 100644 --- a/ecstore/src/set_disk.rs +++ b/ecstore/src/set_disk.rs @@ -45,6 +45,7 @@ use crate::{ heal::data_scanner::{HEAL_DELETE_DANGLING, globalHealConfig}, store_api::ListObjectVersionsInfo, }; +use bytes::Bytes; use bytesize::ByteSize; use chrono::Utc; use futures::future::join_all; @@ -489,7 +490,7 @@ impl SetDisks { src_object: &str, dst_bucket: &str, dst_object: &str, - meta: Vec, + meta: Bytes, write_quorum: usize, ) -> disk::error::Result>> { let src_bucket = Arc::new(src_bucket.to_string()); @@ -4600,7 +4601,7 @@ impl StorageAPI for SetDisks { &tmp_part_path, RUSTFS_META_MULTIPART_BUCKET, &part_path, - fi_buff, + fi_buff.into(), write_quorum, ) .await?; diff --git a/rustfs/src/grpc.rs b/rustfs/src/grpc.rs index 6c155edc0..80b957909 100644 --- a/rustfs/src/grpc.rs +++ b/rustfs/src/grpc.rs @@ -446,7 +446,7 @@ impl Node for NodeService { &request.src_path, &request.dst_volume, &request.dst_path, - request.meta, + request.meta.into(), ) .await {