From 8d5a6d7e74eba7f63ce6466033d24e66d19ddd32 Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 3 Sep 2024 22:30:11 -0700 Subject: [PATCH] fix for spreading ec shards --- weed/server/volume_grpc_erasure_coding.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/weed/server/volume_grpc_erasure_coding.go b/weed/server/volume_grpc_erasure_coding.go index 546bf8109..dd51894c5 100644 --- a/weed/server/volume_grpc_erasure_coding.go +++ b/weed/server/volume_grpc_erasure_coding.go @@ -143,10 +143,17 @@ func (vs *VolumeServer) VolumeEcShardsCopy(ctx context.Context, req *volume_serv glog.V(0).Infof("VolumeEcShardsCopy: %v", req) - location := vs.store.FindFreeLocation(func(location *storage.DiskLocation) bool { - _, found := location.FindEcVolume(needle.VolumeId(req.VolumeId)) - return found - }) + var location *storage.DiskLocation + if req.CopyEcxFile { + location = vs.store.FindFreeLocation(func(location *storage.DiskLocation) bool { + return location.DiskType == types.HardDriveType + }) + } else { + location = vs.store.FindFreeLocation(func(location *storage.DiskLocation) bool { + _, found := location.FindEcVolume(needle.VolumeId(req.VolumeId)) + return found + }) + } if location == nil { return nil, fmt.Errorf("no space left") }