From aaef18b1a3990d5f8c834c916be7cec83e03a788 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 13 Aug 2019 02:58:43 -0700 Subject: [PATCH] Fail for disks which overflow upon usage calculation (#8056) Fixes #8035 --- pkg/disk/stat_linux.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/disk/stat_linux.go b/pkg/disk/stat_linux.go index 66bddaef9..055c4242a 100644 --- a/pkg/disk/stat_linux.go +++ b/pkg/disk/stat_linux.go @@ -19,6 +19,7 @@ package disk import ( + "fmt" "syscall" ) @@ -37,5 +38,12 @@ func GetInfo(path string) (info Info, err error) { Ffree: uint64(s.Ffree), FSType: getFSType(int64(s.Type)), } + // Check for overflows. + // https://github.com/minio/minio/issues/8035 + // XFS can show wrong values at times error out + // in such scenarios. + if info.Free > info.Total { + return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path) + } return info, nil }