From e0947cec67730e6d6dc7d1cddff84a38f0806ca6 Mon Sep 17 00:00:00 2001 From: "changlin.shi" Date: Tue, 11 Jul 2023 14:27:17 +0800 Subject: [PATCH] refresh max volume count after adjust Signed-off-by: changlin.shi --- weed/storage/store.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weed/storage/store.go b/weed/storage/store.go index 40bb7bbe7..711ab623b 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -574,6 +574,7 @@ func (s *Store) MaybeAdjustVolumeMax() (hasChanges bool) { if volumeSizeLimit == 0 { return } + var newMaxVolumeCount int32 for _, diskLocation := range s.Locations { if diskLocation.OriginalMaxVolumeCount == 0 { currentMaxVolumeCount := atomic.LoadInt32(&diskLocation.MaxVolumeCount) @@ -585,11 +586,15 @@ func (s *Store) MaybeAdjustVolumeMax() (hasChanges bool) { if unclaimedSpaces > int64(volumeSizeLimit) { maxVolumeCount += int32(uint64(unclaimedSpaces)/volumeSizeLimit) - 1 } + newMaxVolumeCount = newMaxVolumeCount + maxVolumeCount atomic.StoreInt32(&diskLocation.MaxVolumeCount, maxVolumeCount) glog.V(4).Infof("disk %s max %d unclaimedSpace:%dMB, unused:%dMB volumeSizeLimit:%dMB", diskLocation.Directory, maxVolumeCount, unclaimedSpaces/1024/1024, unusedSpace/1024/1024, volumeSizeLimit/1024/1024) hasChanges = hasChanges || currentMaxVolumeCount != atomic.LoadInt32(&diskLocation.MaxVolumeCount) + } else { + newMaxVolumeCount = newMaxVolumeCount + diskLocation.OriginalMaxVolumeCount } } + stats.VolumeServerMaxVolumeCounter.Set(float64(newMaxVolumeCount)) return }