mirror of
https://github.com/minio/minio.git
synced 2025-11-06 20:33:07 -05:00
Relax minio server start when disk threshold is reached and adds space check in FS (#3865)
* fs: Rename tempObjPath variable in fsCreateFile() * fs/posix: Factor checkDiskFree() function * fs: Add disk free check in fsCreateFile() * posix: Move free disk check to createFile() * xl: Relax free disk check in POSIX initialization * fs: checkDiskFree checks for space to store data
This commit is contained in:
committed by
Harshavardhana
parent
29ff9674a0
commit
79e0b9e69a
30
cmd/posix.go
30
cmd/posix.go
@@ -40,11 +40,9 @@ const (
|
||||
|
||||
// posix - implements StorageAPI interface.
|
||||
type posix struct {
|
||||
ioErrCount int32 // ref: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
|
||||
diskPath string
|
||||
minFreeSpace int64
|
||||
minFreeInodes int64
|
||||
pool sync.Pool
|
||||
ioErrCount int32 // ref: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
|
||||
diskPath string
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
// checkPathLength - returns error if given path name length more than 255
|
||||
@@ -109,9 +107,7 @@ func newPosix(path string) (StorageAPI, error) {
|
||||
return nil, err
|
||||
}
|
||||
fs := &posix{
|
||||
diskPath: diskPath,
|
||||
minFreeSpace: fsMinFreeSpace,
|
||||
minFreeInodes: fsMinFreeInodes,
|
||||
diskPath: diskPath,
|
||||
// 1MiB buffer pool for posix internal operations.
|
||||
pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
@@ -133,9 +129,6 @@ func newPosix(path string) (StorageAPI, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err = fs.checkDiskFree(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fs, nil
|
||||
}
|
||||
|
||||
@@ -161,7 +154,7 @@ var ignoreDiskFreeOS = []string{
|
||||
}
|
||||
|
||||
// checkDiskFree verifies if disk path has sufficient minimum free disk space and files.
|
||||
func (s *posix) checkDiskFree() (err error) {
|
||||
func checkDiskFree(diskPath string, neededSpace int64) (err error) {
|
||||
// We don't validate disk space or inode utilization on windows.
|
||||
// Each windows calls to 'GetVolumeInformationW' takes around 3-5seconds.
|
||||
// And StatFS is not supported by Go for solaris and netbsd.
|
||||
@@ -170,14 +163,14 @@ func (s *posix) checkDiskFree() (err error) {
|
||||
}
|
||||
|
||||
var di disk.Info
|
||||
di, err = getDiskInfo(preparePath(s.diskPath))
|
||||
di, err = getDiskInfo(preparePath(diskPath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove 5% from free space for cumulative disk space used for journalling, inodes etc.
|
||||
availableDiskSpace := float64(di.Free) * 0.95
|
||||
if int64(availableDiskSpace) <= s.minFreeSpace {
|
||||
if int64(availableDiskSpace) <= fsMinFreeSpace {
|
||||
return errDiskFull
|
||||
}
|
||||
|
||||
@@ -187,11 +180,16 @@ func (s *posix) checkDiskFree() (err error) {
|
||||
// total inodes are provided by the underlying filesystem.
|
||||
if di.Files != 0 && di.FSType != "NFS" {
|
||||
availableFiles := int64(di.Ffree)
|
||||
if availableFiles <= s.minFreeInodes {
|
||||
if availableFiles <= fsMinFreeInodes {
|
||||
return errDiskFull
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have enough space to store data
|
||||
if neededSpace > int64(availableDiskSpace) {
|
||||
return errDiskFull
|
||||
}
|
||||
|
||||
// Success.
|
||||
return nil
|
||||
}
|
||||
@@ -676,7 +674,7 @@ func (s *posix) PrepareFile(volume, path string, fileSize int64) (err error) {
|
||||
}
|
||||
|
||||
// Validate if disk is indeed free.
|
||||
if err = s.checkDiskFree(); err != nil {
|
||||
if err = checkDiskFree(s.diskPath, fileSize); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user