From d0d72096d1d612747bed982ac96c8f4010763981 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 16 Mar 2026 17:43:32 -0700 Subject: [PATCH] Match Go VolumeStatus dat file size, EC shard stats, and disk pct precision --- seaweed-volume/src/server/grpc_server.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/seaweed-volume/src/server/grpc_server.rs b/seaweed-volume/src/server/grpc_server.rs index f34b1e802..c211065a6 100644 --- a/seaweed-volume/src/server/grpc_server.rs +++ b/seaweed-volume/src/server/grpc_server.rs @@ -793,9 +793,12 @@ impl VolumeServer for VolumeGrpcService { .find_volume(vid) .ok_or_else(|| Status::not_found(format!("not found volume id {}", vid)))?; + // Go uses v.DataBackend.GetStat() which returns the actual .dat file size + let volume_size = vol.dat_file_size().unwrap_or(0); + Ok(Response::new(volume_server_pb::VolumeStatusResponse { is_read_only: vol.is_read_only(), - volume_size: vol.content_size(), + volume_size, file_count: vol.file_count() as u64, file_deleted_count: vol.deleted_count() as u64, })) @@ -2346,20 +2349,16 @@ impl VolumeServer for VolumeGrpcService { } } - // Calculate volume size from shards - let volume_size = ec_vol - .shards - .iter() - .filter_map(|s| s.as_ref()) - .map(|s| s.file_size()) - .sum::() as u64; + // Walk .ecx index to compute file counts and total size (matching Go's WalkIndex) + let (file_count, file_deleted_count, volume_size) = + ec_vol.walk_ecx_stats().map_err(|e| Status::internal(e.to_string()))?; Ok(Response::new( volume_server_pb::VolumeEcShardsInfoResponse { ec_shard_infos: shard_infos, volume_size, - file_count: 0, - file_deleted_count: 0, + file_count, + file_deleted_count, }, )) } @@ -2664,12 +2663,12 @@ impl VolumeServer for VolumeGrpcService { let (all, free) = get_disk_usage(&loc.directory); let used = all.saturating_sub(free); let percent_free = if all > 0 { - (free as f32 / all as f32) * 100.0 + ((free as f64 / all as f64) * 100.0) as f32 } else { 0.0 }; let percent_used = if all > 0 { - (used as f32 / all as f32) * 100.0 + ((used as f64 / all as f64) * 100.0) as f32 } else { 0.0 };