diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.go index e41529174..d66bbdba9 100644 --- a/weed/shell/command_ec_encode.go +++ b/weed/shell/command_ec_encode.go @@ -315,15 +315,31 @@ func collectVolumeIdsForEcEncode(commandEnv *CommandEnv, selectedCollection stri } if v.Collection == selectedCollection && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds { if float64(v.Size) > fullPercentage/100*float64(volumeSizeLimitMb)*1024*1024 { - vidMap[v.Id] = true + if good, found := vidMap[v.Id]; found { + if good { + if diskInfo.FreeVolumeCount < 1 { + glog.V(0).Infof("skip %d.%d on %s, no free disk", v.Id, v.Collection, dn.Id) + vidMap[v.Id] = false + } + } + } else { + if diskInfo.FreeVolumeCount < 1 { + glog.V(0).Infof("skip %d.%d on %s, no free disk", v.Id, v.Collection, dn.Id) + vidMap[v.Id] = false + } else { + vidMap[v.Id] = true + } + } } } } } }) - for vid := range vidMap { - vids = append(vids, needle.VolumeId(vid)) + for vid, good := range vidMap { + if good { + vids = append(vids, needle.VolumeId(vid)) + } } return diff --git a/weed/topology/disk.go b/weed/topology/disk.go index 6d789e34b..80a4aaa2d 100644 --- a/weed/topology/disk.go +++ b/weed/topology/disk.go @@ -66,7 +66,7 @@ func (d *DiskUsages) ToDiskInfo() map[string]*master_pb.DiskInfo { m := &master_pb.DiskInfo{ VolumeCount: diskUsageCounts.volumeCount, MaxVolumeCount: diskUsageCounts.maxVolumeCount, - FreeVolumeCount: diskUsageCounts.maxVolumeCount - diskUsageCounts.volumeCount, + FreeVolumeCount: diskUsageCounts.maxVolumeCount - (diskUsageCounts.volumeCount - diskUsageCounts.remoteVolumeCount) - (diskUsageCounts.ecShardCount+1)/erasure_coding.DataShardsCount, ActiveVolumeCount: diskUsageCounts.activeVolumeCount, RemoteVolumeCount: diskUsageCounts.remoteVolumeCount, } @@ -250,7 +250,7 @@ func (d *Disk) ToDiskInfo() *master_pb.DiskInfo { Type: string(d.Id()), VolumeCount: diskUsage.volumeCount, MaxVolumeCount: diskUsage.maxVolumeCount, - FreeVolumeCount: diskUsage.maxVolumeCount - diskUsage.volumeCount, + FreeVolumeCount: diskUsage.maxVolumeCount - (diskUsage.volumeCount - diskUsage.remoteVolumeCount) - (diskUsage.ecShardCount+1)/erasure_coding.DataShardsCount, ActiveVolumeCount: diskUsage.activeVolumeCount, RemoteVolumeCount: diskUsage.remoteVolumeCount, }