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
Revert "sort writables to be able to skew write probability to lesser ids (older volumes)"
Chris Lu50fafa3a2c4b
diff --git a/weed-fs/src/pkg/topology/volume_layout.go b/weed-fs/src/pkg/topology/volume_layout.goindex 23802ca819..314aca69f9 100644--- a/weed-fs/src/pkg/topology/volume_layout.go+++ b/weed-fs/src/pkg/topology/volume_layout.go@@ -5,15 +5,12 @@ import ("fmt""math/rand""pkg/storage"- "sort")-type volumeIdList []storage.VolumeId-type VolumeLayout struct {repType storage.ReplicationTypevid2location map[storage.VolumeId]*VolumeLocationList- writables volumeIdList // transient (sorted!) array of writable volume Ids+ writables []storage.VolumeId // transient array of writable volume idpulse int64volumeSizeLimit uint64}@@ -22,7 +19,7 @@ func NewVolumeLayout(repType storage.ReplicationType, volumeSizeLimit uint64, pureturn &VolumeLayout{repType: repType,vid2location: make(map[storage.VolumeId]*VolumeLocationList),- writables: make(volumeIdList, 0, 4),+ writables: *new([]storage.VolumeId),pulse: pulse,volumeSizeLimit: volumeSizeLimit,}@@ -36,16 +33,13 @@ func (vl *VolumeLayout) RegisterVolume(v *storage.VolumeInfo, dn *DataNode) {if len(vl.vid2location[v.Id].list) == v.RepType.GetCopyCount() {if vl.isWritable(v) {vl.writables = append(vl.writables, v.Id)- if len(vl.writables) > 1 {- vl.writables.Sort()- }}}}}-func (vl *VolumeLayout) isWritable(v *storage.VolumeInfo) bool {- return uint64(v.Size) < vl.volumeSizeLimit && v.Version == storage.CurrentVersion+func (vl *VolumeLayout) isWritable(v *storage.VolumeInfo) bool{+ return uint64(v.Size) < vl.volumeSizeLimit && v.Version == storage.CurrentVersion}func (vl *VolumeLayout) Lookup(vid storage.VolumeId) []*DataNode {@@ -58,13 +52,7 @@ func (vl *VolumeLayout) PickForWrite(count int) (*storage.VolumeId, int, *Volumefmt.Println("No more writable volumes!")return nil, 0, nil, errors.New("No more writable volumes!")}- var vid storage.VolumeId- if len_writers == 1 {- vid = vl.writables[0]- } else {- // skew for lesser indices- vid = vl.writables[rand.Intn(len_writers+1)%len_writers]- }+ vid := vl.writables[rand.Intn(len_writers)]locationList := vl.vid2location[vid]if locationList != nil {return &vid, count, locationList, nil@@ -94,9 +82,6 @@ func (vl *VolumeLayout) setVolumeWritable(vid storage.VolumeId) bool {}fmt.Println("Volume", vid, "becomes writable")vl.writables = append(vl.writables, vid)- if len(vl.writables) > 1 {- vl.writables.Sort()- }return true}@@ -129,18 +114,3 @@ func (vl *VolumeLayout) ToMap() interface{} {//m["locations"] = vl.vid2locationreturn m}--func (vls volumeIdList) Len() int { return len(vls) }--func (vls volumeIdList) Less(i, j int) bool {- return vls[i] < vls[j]-}--func (vls volumeIdList) Swap(i, j int) {- vls[i], vls[j] = vls[j], vls[i]-}--// convienence sorting-func (vls volumeIdList) Sort() {- sort.Sort(vls)-}