SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
master: avoid creating too many volumes
Chris Lud2d36a3f9dd3
diff --git a/weed/topology/node.go b/weed/topology/node.goindex a23729dd30..4556b41657 100644--- a/weed/topology/node.go+++ b/weed/topology/node.go@@ -242,9 +242,9 @@ func (n *NodeImpl) CollectDeadNodeAndFullVolumes(freshThreshHold int64, volumeSifor _, v := range dn.GetVolumes() {if v.Size >= volumeSizeLimit {//fmt.Println("volume",v.Id,"size",v.Size,">",volumeSizeLimit)- n.GetTopology().chanFullVolumes <- &v+ n.GetTopology().chanFullVolumes <- v}else if float64(v.Size) > float64(volumeSizeLimit) * growThreshold {- n.GetTopology().chanCrowdedVolumes <- &v+ n.GetTopology().chanCrowdedVolumes <- v}}}diff --git a/weed/topology/topology.go b/weed/topology/topology.goindex 3932e3fbb4..d704a56363 100644--- a/weed/topology/topology.go+++ b/weed/topology/topology.go@@ -34,8 +34,8 @@ type Topology struct {Sequence sequence.Sequencer- chanFullVolumes chan *storage.VolumeInfo- chanCrowdedVolumes chan *storage.VolumeInfo+ chanFullVolumes chan storage.VolumeInfo+ chanCrowdedVolumes chan storage.VolumeInfoConfiguration *Configuration@@ -57,8 +57,8 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, pulst.Sequence = seq- t.chanFullVolumes = make(chan *storage.VolumeInfo)- t.chanCrowdedVolumes = make(chan *storage.VolumeInfo)+ t.chanFullVolumes = make(chan storage.VolumeInfo)+ t.chanCrowdedVolumes = make(chan storage.VolumeInfo)t.Configuration = &Configuration{}diff --git a/weed/topology/topology_event_handling.go b/weed/topology/topology_event_handling.goindex 2f4fba932b..0f1db74dff 100644--- a/weed/topology/topology_event_handling.go+++ b/weed/topology/topology_event_handling.go@@ -39,7 +39,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, g}}()}-func (t *Topology) SetVolumeCapacityFull(volumeInfo *storage.VolumeInfo) bool {+func (t *Topology) SetVolumeCapacityFull(volumeInfo storage.VolumeInfo) bool {diskType := types.ToDiskType(volumeInfo.DiskType)vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType)if !vl.SetVolumeCapacityFull(volumeInfo.Id) {@@ -68,7 +68,7 @@ func (t *Topology) SetVolumeCapacityFull(volumeInfo *storage.VolumeInfo) bool {return true}-func (t *Topology) SetVolumeCrowded(volumeInfo *storage.VolumeInfo) {+func (t *Topology) SetVolumeCrowded(volumeInfo storage.VolumeInfo) {diskType := types.ToDiskType(volumeInfo.DiskType)vl := t.GetVolumeLayout(volumeInfo.Collection, volumeInfo.ReplicaPlacement, volumeInfo.Ttl, diskType)vl.SetVolumeCrowded(volumeInfo.Id)diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.goindex 57e511fa0a..f315cb7e4c 100644--- a/weed/topology/volume_layout.go+++ b/weed/topology/volume_layout.go@@ -108,7 +108,7 @@ type VolumeLayout struct {diskType types.DiskTypevid2location map[needle.VolumeId]*VolumeLocationListwritables []needle.VolumeId // transient array of writable volume id- crowded map[needle.VolumeId]interface{}+ crowded map[needle.VolumeId]struct{}readonlyVolumes *volumesBinaryState // readonly volumesoversizedVolumes *volumesBinaryState // oversized volumesvolumeSizeLimit uint64@@ -129,7 +129,7 @@ func NewVolumeLayout(rp *super_block.ReplicaPlacement, ttl *needle.TTL, diskTypediskType: diskType,vid2location: make(map[needle.VolumeId]*VolumeLocationList),writables: *new([]needle.VolumeId),- crowded: make(map[needle.VolumeId]interface{}),+ crowded: make(map[needle.VolumeId]struct{}),readonlyVolumes: NewVolumesBinaryState(readOnlyState, rp, ExistCopies()),oversizedVolumes: NewVolumesBinaryState(oversizedState, rp, ExistCopies()),volumeSizeLimit: volumeSizeLimit,@@ -421,7 +421,7 @@ func (vl *VolumeLayout) removeFromCrowded(vid needle.VolumeId) {func (vl *VolumeLayout) setVolumeCrowded(vid needle.VolumeId) {if _, ok := vl.crowded[vid]; !ok {- vl.crowded[vid] = nil+ vl.crowded[vid] = struct{}{}glog.V(0).Infoln("Volume", vid, "becomes crowded")}}