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
volume: dataFileAccessLock change to RW Lock
Chris Lu6827cabfbb63
diff --git a/weed/storage/volume.go b/weed/storage/volume.goindex f936519820..7edcacebd2 100644--- a/weed/storage/volume.go+++ b/weed/storage/volume.go@@ -30,7 +30,7 @@ type Volume struct {SuperBlock- dataFileAccessLock sync.Mutex+ dataFileAccessLock sync.RWMutexlastModifiedTsSeconds uint64 //unix time in secondslastAppendAtNs uint64 //unix time in nanoseconds@@ -72,8 +72,8 @@ func (v *Volume) Version() needle.Version {}func (v *Volume) FileStat() (datSize uint64, idxSize uint64, modTime time.Time) {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.DataBackend == nil {return@@ -88,8 +88,8 @@ func (v *Volume) FileStat() (datSize uint64, idxSize uint64, modTime time.Time)}func (v *Volume) ContentSize() uint64 {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.nm == nil {return 0}@@ -97,8 +97,8 @@ func (v *Volume) ContentSize() uint64 {}func (v *Volume) DeletedSize() uint64 {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.nm == nil {return 0}@@ -106,8 +106,8 @@ func (v *Volume) DeletedSize() uint64 {}func (v *Volume) FileCount() uint64 {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.nm == nil {return 0}@@ -115,8 +115,8 @@ func (v *Volume) FileCount() uint64 {}func (v *Volume) DeletedCount() uint64 {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.nm == nil {return 0}@@ -124,8 +124,8 @@ func (v *Volume) DeletedCount() uint64 {}func (v *Volume) MaxFileKey() types.NeedleId {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.nm == nil {return 0}@@ -133,8 +133,8 @@ func (v *Volume) MaxFileKey() types.NeedleId {}func (v *Volume) IndexFileSize() uint64 {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()if v.nm == nil {return 0}diff --git a/weed/storage/volume_backup.go b/weed/storage/volume_backup.goindex fe05069179..efe1345c60 100644--- a/weed/storage/volume_backup.go+++ b/weed/storage/volume_backup.go@@ -15,8 +15,8 @@ import ()func (v *Volume) GetVolumeSyncStatus() *volume_server_pb.VolumeSyncStatusResponse {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()var syncStatus = &volume_server_pb.VolumeSyncStatusResponse{}if datSize, _, err := v.DataBackend.GetStat(); err == nil {diff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.goindex c1758c18bb..f5cdd0944f 100644--- a/weed/storage/volume_read_write.go+++ b/weed/storage/volume_read_write.go@@ -136,8 +136,8 @@ func (v *Volume) deleteNeedle(n *needle.Needle) (uint32, error) {// read fills in Needle content by looking up n.Id from NeedleMapperfunc (v *Volume) readNeedle(n *needle.Needle) (int, error) {- v.dataFileAccessLock.Lock()- defer v.dataFileAccessLock.Unlock()+ v.dataFileAccessLock.RLock()+ defer v.dataFileAccessLock.RUnlock()nv, ok := v.nm.Get(n.Id)if !ok || nv.Offset.IsZero() {