diff options
| author | chrislu <chris.lu@gmail.com> | 2022-08-25 22:20:34 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-08-25 22:20:34 -0700 |
| commit | 6f483a4d36c77d986d1163a4132d2e117c1e2f01 (patch) | |
| tree | 838315041aa64c8678e91779539f3dff4dc14e32 /weed/topology/disk.go | |
| parent | 7394f7feeea6477bb38aa887c35300e0c0b5e7b3 (diff) | |
| download | seaweedfs-6f483a4d36c77d986d1163a4132d2e117c1e2f01.tar.xz seaweedfs-6f483a4d36c77d986d1163a4132d2e117c1e2f01.zip | |
atomic add
fix https://github.com/seaweedfs/seaweedfs/issues/3514
Diffstat (limited to 'weed/topology/disk.go')
| -rw-r--r-- | weed/topology/disk.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/weed/topology/disk.go b/weed/topology/disk.go index 99ea980d8..1917d7126 100644 --- a/weed/topology/disk.go +++ b/weed/topology/disk.go @@ -5,6 +5,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/util" "sync" + "sync/atomic" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding" @@ -100,11 +101,11 @@ type DiskUsageCounts struct { } func (a *DiskUsageCounts) addDiskUsageCounts(b *DiskUsageCounts) { - a.volumeCount += b.volumeCount - a.remoteVolumeCount += b.remoteVolumeCount - a.activeVolumeCount += b.activeVolumeCount - a.ecShardCount += b.ecShardCount - a.maxVolumeCount += b.maxVolumeCount + atomic.AddInt64(&a.volumeCount, b.volumeCount) + atomic.AddInt64(&a.remoteVolumeCount, b.remoteVolumeCount) + atomic.AddInt64(&a.activeVolumeCount, b.activeVolumeCount) + atomic.AddInt64(&a.ecShardCount, b.ecShardCount) + atomic.AddInt64(&a.maxVolumeCount, b.maxVolumeCount) } func (a *DiskUsageCounts) FreeSpace() int64 { |
