aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2024-07-15 22:51:21 +0500
committerGitHub <noreply@github.com>2024-07-15 10:51:21 -0700
commita53e406c994ed6c655e4a576855f31dbc883aadb (patch)
tree936ba2d2db27910d5495cd4083814b75c4a6ba85
parentfeb911a0b4057c40555af5fd67f6f41945a60f70 (diff)
downloadseaweedfs-a53e406c994ed6c655e4a576855f31dbc883aadb.tar.xz
seaweedfs-a53e406c994ed6c655e4a576855f31dbc883aadb.zip
[master] refactor HasGrowRequest to atomic bool (#5782)
refactor HasGrowRequest to atomit bool
-rw-r--r--weed/topology/volume_layout.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index f2c341b7c..5711a6a9b 100644
--- a/weed/topology/volume_layout.go
+++ b/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
type VolumeLayout struct {
- growRequestCount int32
+ growRequest atomic.Bool
rp *super_block.ReplicaPlacement
ttl *needle.TTL
diskType types.DiskType
@@ -345,13 +345,13 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
}
func (vl *VolumeLayout) HasGrowRequest() bool {
- return atomic.LoadInt32(&vl.growRequestCount) > 0
+ return vl.growRequest.Load()
}
func (vl *VolumeLayout) AddGrowRequest() {
- atomic.AddInt32(&vl.growRequestCount, 1)
+ vl.growRequest.Store(true)
}
func (vl *VolumeLayout) DoneGrowRequest() {
- atomic.AddInt32(&vl.growRequestCount, -1)
+ vl.growRequest.Store(false)
}
func (vl *VolumeLayout) ShouldGrowVolumes(option *VolumeGrowOption) bool {