diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2021-04-27 10:37:24 +0800 |
|---|---|---|
| committer | bingoohuang <bingoo.huang@gmail.com> | 2021-04-27 10:37:24 +0800 |
| commit | cf552417a7a422d1313c53972fd1175684e758e0 (patch) | |
| tree | 621d6f4f432cefe75c455939e084193eb7462001 /weed/storage/disk_location.go | |
| parent | 31f1cdeac281fb88a3d03743f9796f81e1d74378 (diff) | |
| download | seaweedfs-cf552417a7a422d1313c53972fd1175684e758e0.tar.xz seaweedfs-cf552417a7a422d1313c53972fd1175684e758e0.zip | |
minFreeSpace refactored
Diffstat (limited to 'weed/storage/disk_location.go')
| -rw-r--r-- | weed/storage/disk_location.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go index 3246718c8..33dd272ce 100644 --- a/weed/storage/disk_location.go +++ b/weed/storage/disk_location.go @@ -23,10 +23,9 @@ type DiskLocation struct { DiskType types.DiskType MaxVolumeCount int OriginalMaxVolumeCount int - // MinFreeSpace limits the minimum free space (<=100 as percentage, > 100 as bytes) - MinFreeSpace float32 - volumes map[needle.VolumeId]*Volume - volumesLock sync.RWMutex + MinFreeSpace util.MinFreeSpace + volumes map[needle.VolumeId]*Volume + volumesLock sync.RWMutex // erasure coding ecVolumes map[needle.VolumeId]*erasure_coding.EcVolume @@ -35,7 +34,7 @@ type DiskLocation struct { isDiskSpaceLow bool } -func NewDiskLocation(dir string, maxVolumeCount int, minFreeSpace float32, idxDir string, diskType types.DiskType) *DiskLocation { +func NewDiskLocation(dir string, maxVolumeCount int, minFreeSpace util.MinFreeSpace, idxDir string, diskType types.DiskType) *DiskLocation { dir = util.ResolvePath(dir) if idxDir == "" { idxDir = dir @@ -363,7 +362,7 @@ func (l *DiskLocation) CheckDiskSpace() { stats.VolumeServerResourceGauge.WithLabelValues(l.Directory, "used").Set(float64(s.Used)) stats.VolumeServerResourceGauge.WithLabelValues(l.Directory, "free").Set(float64(s.Free)) - isLow := l.MinFreeSpace < 100 && s.PercentFree < l.MinFreeSpace || s.Free < uint64(l.MinFreeSpace) + isLow, desc := l.MinFreeSpace.IsLow(s.Free, s.PercentFree) if isLow != l.isDiskSpaceLow { l.isDiskSpaceLow = !l.isDiskSpaceLow } @@ -373,8 +372,7 @@ func (l *DiskLocation) CheckDiskSpace() { logLevel = glog.Level(0) } - glog.V(logLevel).Infof("dir %s freePercent %.2f%% < min %.2f%%, isLowDiskSpace: %v", - dir, s.PercentFree, l.MinFreeSpace, l.isDiskSpaceLow) + glog.V(logLevel).Infof("dir %s %s", dir, desc) } time.Sleep(time.Minute) } |
