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
Merge pull request #10 from chrislusf/master
joeslayd53aee179b66
diff --cc weed/storage/volume_super_block.goindex 414d55f681,47cddaba47..e4dc985b04--- a/weed/storage/volume_super_block.go+++ b/weed/storage/volume_super_block.go@@@ -71,30 -69,24 +71,34 @@@ func (s *SuperBlock) Bytes() []bytereturn header}+ func (s *SuperBlock) Initialized() bool {+ return s.ReplicaPlacement != nil && s.Ttl != nil+ }+func (v *Volume) maybeWriteSuperBlock() error {- stat, e := v.dataFile.Stat()- if e != nil {- glog.V(0).Infof("failed to stat datafile %s: %v", v.dataFile.Name(), e)- return e- }- if stat.Size() == 0 {- v.SuperBlock.version = needle.CurrentVersion- _, e = v.dataFile.Write(v.SuperBlock.Bytes())- if e != nil && os.IsPermission(e) {- //read-only, but zero length - recreate it!- if v.dataFile, e = os.Create(v.dataFile.Name()); e == nil {- if _, e = v.dataFile.Write(v.SuperBlock.Bytes()); e == nil {- v.readOnly = false++ mMap, exists := memory_map.FileMemoryMap[v.dataFile.Name()]+ if exists {+ if mMap.End_of_file == -1 {+ v.SuperBlock.version = needle.CurrentVersion+ mMap.WriteMemory(0, uint64(len(v.SuperBlock.Bytes())), v.SuperBlock.Bytes())+ }+ return nil+ } else {+ stat, e := v.dataFile.Stat()+ if e != nil {+ glog.V(0).Infof("failed to stat datafile %s: %v", v.dataFile.Name(), e)+ return e+ }+ if stat.Size() == 0 {+ v.SuperBlock.version = needle.CurrentVersion+ _, e = v.dataFile.Write(v.SuperBlock.Bytes())+ if e != nil && os.IsPermission(e) {+ //read-only, but zero length - recreate it!+ if v.dataFile, e = os.Create(v.dataFile.Name()); e == nil {+ if _, e = v.dataFile.Write(v.SuperBlock.Bytes()); e == nil {+ v.readOnly = false+ }}}}