From 0f1ca16457a15815cde6c7faac58b9d8a9560048 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 10 Aug 2025 18:42:22 -0700 Subject: [PATCH] more accurate estimation --- weed/admin/maintenance/maintenance_scanner.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/weed/admin/maintenance/maintenance_scanner.go b/weed/admin/maintenance/maintenance_scanner.go index 7c1161fe8..6216750f7 100644 --- a/weed/admin/maintenance/maintenance_scanner.go +++ b/weed/admin/maintenance/maintenance_scanner.go @@ -7,6 +7,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + "github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding" "github.com/seaweedfs/seaweedfs/weed/worker/types" ) @@ -300,14 +301,18 @@ func (ms *MaintenanceScanner) createECVolumeMetric(volumeID uint32) *VolumeHealt Age: 24 * time.Hour, // Default age } - // Calculate total size from all shards of this volume + // Calculate total size from all shards of this volume if len(ecShardInfo.ShardSizes) > 0 { var totalShardSize uint64 for _, shardSize := range ecShardInfo.ShardSizes { totalShardSize += uint64(shardSize) // Convert int64 to uint64 } - // Estimate original volume size (shards are compressed/encoded) - metric.Size = totalShardSize * 2 // Rough estimate + // Estimate original volume size from the data shards + // Assumes shard sizes are roughly equal + avgShardSize := totalShardSize / uint64(len(ecShardInfo.ShardSizes)) + metric.Size = avgShardSize * uint64(erasure_coding.DataShardsCount) + } else { + metric.Size = 0 // No shards, no size } glog.V(3).Infof("Created EC volume metric for volume %d, size=%d", volumeID, metric.Size)