Browse Source

[master] refactor HasGrowRequest to atomic bool (#5782)

refactor HasGrowRequest to atomit bool
pull/5792/head
Konstantin Lebedev 5 months ago
committed by GitHub
parent
commit
a53e406c99
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      weed/topology/volume_layout.go

8
weed/topology/volume_layout.go

@ -106,7 +106,7 @@ func (v *volumesBinaryState) copyState(list *VolumeLocationList) copyState {
// mapping from volume to its locations, inverted from server to volume // mapping from volume to its locations, inverted from server to volume
type VolumeLayout struct { type VolumeLayout struct {
growRequestCount int32
growRequest atomic.Bool
rp *super_block.ReplicaPlacement rp *super_block.ReplicaPlacement
ttl *needle.TTL ttl *needle.TTL
diskType types.DiskType diskType types.DiskType
@ -345,13 +345,13 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
} }
func (vl *VolumeLayout) HasGrowRequest() bool { func (vl *VolumeLayout) HasGrowRequest() bool {
return atomic.LoadInt32(&vl.growRequestCount) > 0
return vl.growRequest.Load()
} }
func (vl *VolumeLayout) AddGrowRequest() { func (vl *VolumeLayout) AddGrowRequest() {
atomic.AddInt32(&vl.growRequestCount, 1)
vl.growRequest.Store(true)
} }
func (vl *VolumeLayout) DoneGrowRequest() { func (vl *VolumeLayout) DoneGrowRequest() {
atomic.AddInt32(&vl.growRequestCount, -1)
vl.growRequest.Store(false)
} }
func (vl *VolumeLayout) ShouldGrowVolumes(option *VolumeGrowOption) bool { func (vl *VolumeLayout) ShouldGrowVolumes(option *VolumeGrowOption) bool {

Loading…
Cancel
Save