aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.go
diff options
context:
space:
mode:
authorLisandro Pin <lisandro.pin@proton.ch>2025-02-28 16:35:28 +0100
committerGitHub <noreply@github.com>2025-02-28 07:35:28 -0800
commit76a111f0a2fb6113d6c173758db5a91afa92e58d (patch)
tree3b97c56cb26b863e6a694e2f8e5774de2a0607b1 /weed/shell/command_ec_common.go
parent314f211260a7e4cf64a1cbfda652abd90d4ff90f (diff)
downloadseaweedfs-76a111f0a2fb6113d6c173758db5a91afa92e58d.tar.xz
seaweedfs-76a111f0a2fb6113d6c173758db5a91afa92e58d.zip
Fix calculation of node's free EC shard slots. (#6584)
Diffstat (limited to 'weed/shell/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index f655a163a..f2845224e 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -429,7 +429,13 @@ func countFreeShardSlots(dn *master_pb.DataNodeInfo, diskType types.DiskType) (c
if diskInfo == nil {
return 0
}
- return int(diskInfo.MaxVolumeCount-diskInfo.VolumeCount)*erasure_coding.DataShardsCount - countShards(diskInfo.EcShardInfos)
+
+ slots := int(diskInfo.MaxVolumeCount-diskInfo.VolumeCount)*erasure_coding.DataShardsCount - countShards(diskInfo.EcShardInfos)
+ if slots < 0 {
+ return 0
+ }
+
+ return slots
}
func (ecNode *EcNode) localShardIdCount(vid uint32) int {