Fix concurrent map access in EC shards info (#8222)
* fix concurrent map access in EC shards info #8219 * refactor: simplify Disk.ToDiskInfo to use ecShards snapshot and avoid redundant locking * refactor: improve GetEcShards with pre-allocation and defer
This commit is contained in:
@@ -7,11 +7,12 @@ import (
|
||||
)
|
||||
|
||||
func (d *Disk) GetEcShards() (ret []*erasure_coding.EcVolumeInfo) {
|
||||
d.RLock()
|
||||
d.ecShardsLock.RLock()
|
||||
defer d.ecShardsLock.RUnlock()
|
||||
ret = make([]*erasure_coding.EcVolumeInfo, 0, len(d.ecShards))
|
||||
for _, ecVolumeInfo := range d.ecShards {
|
||||
ret = append(ret, ecVolumeInfo)
|
||||
}
|
||||
d.RUnlock()
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user