aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/disk_location.go
diff options
context:
space:
mode:
authorDan <dan@zem.org.uk>2024-07-10 08:30:28 +0100
committerGitHub <noreply@github.com>2024-07-10 00:30:28 -0700
commitbd54669d58eb02dba5fa75d39971b9e7e32c1c0e (patch)
tree1f1dde800a4bda3a212447e02742d88f087a04f1 /weed/storage/disk_location.go
parent0a2f4896cfc451989080b0705cb27bdcfff46b28 (diff)
downloadseaweedfs-bd54669d58eb02dba5fa75d39971b9e7e32c1c0e.tar.xz
seaweedfs-bd54669d58eb02dba5fa75d39971b9e7e32c1c0e.zip
Detect underflow when calculating unused space (#5758)
* Detect underflow when calculating unused space * Detect underflow when calculating unused space
Diffstat (limited to 'weed/storage/disk_location.go')
-rw-r--r--weed/storage/disk_location.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index 9f61ad872..dd78735d2 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -60,6 +60,7 @@ func GenerateDirUuid(dir string) (dirUuidString string, err error) {
}
func NewDiskLocation(dir string, maxVolumeCount int32, minFreeSpace util.MinFreeSpace, idxDir string, diskType types.DiskType) *DiskLocation {
+ glog.V(4).Infof("Added new Disk %s: maxVolumes=%d", dir, maxVolumeCount)
dir = util.ResolvePath(dir)
if idxDir == "" {
idxDir = dir
@@ -417,7 +418,6 @@ func (l *DiskLocation) LocateVolume(vid needle.VolumeId) (os.DirEntry, bool) {
}
func (l *DiskLocation) UnUsedSpace(volumeSizeLimit uint64) (unUsedSpace uint64) {
-
l.volumesLock.RLock()
defer l.volumesLock.RUnlock()
@@ -426,7 +426,11 @@ func (l *DiskLocation) UnUsedSpace(volumeSizeLimit uint64) (unUsedSpace uint64)
continue
}
datSize, idxSize, _ := vol.FileStat()
- unUsedSpace += volumeSizeLimit - (datSize + idxSize)
+ unUsedSpaceVolume := int64(volumeSizeLimit) - int64(datSize+idxSize)
+ glog.V(4).Infof("Volume stats for %d: volumeSizeLimit=%d, datSize=%d idxSize=%d unused=%d", vol.Id, volumeSizeLimit, datSize, idxSize, unUsedSpaceVolume)
+ if unUsedSpaceVolume >= 0 {
+ unUsedSpace += uint64(unUsedSpaceVolume)
+ }
}
return