From 9606cb9bcd28dbddd99a821466a3c2c7130973ca Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 13 Aug 2016 02:30:15 -0700 Subject: [PATCH] posix: Disk free verification should have relaxed handling of inodes. (#2431) Some filesystems do not implement a way to provide total inodes available, instead inodes are allocated based on available disk space. For example CephFS, StoreNext CVSFS, AzureFile driver. Allow for the available disk to be separately validate and we will validate inodes only if the total inodes are provided by the underlying filesystem. Fixes #2364 --- posix.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/posix.go b/posix.go index 84732023a..2cafe07e7 100644 --- a/posix.go +++ b/posix.go @@ -143,11 +143,21 @@ func checkDiskFree(diskPath string, minFreeDisk int64) (err error) { // Remove 5% from total space for cumulative disk // space used for journalling, inodes etc. availableDiskSpace := (float64(di.Free) / (float64(di.Total) - (0.05 * float64(di.Total)))) * 100 - availableFiles := (float64(di.Ffree) / (float64(di.Files) - (0.05 * float64(di.Files)))) * 100 - if int64(availableDiskSpace) <= minFreeDisk || int64(availableFiles) <= minFreeDisk { + if int64(availableDiskSpace) <= minFreeDisk { return errDiskFull } + // Some filesystems do not implement a way to provide total inodes available, instead inodes + // are allocated based on available disk space. For example CephFS, StoreNext CVFS, AzureFile driver. + // Allow for the available disk to be separately validate and we will validate inodes only if + // total inodes are provided by the underlying filesystem. + if di.Files != 0 { + availableFiles := (float64(di.Ffree) / (float64(di.Files) - (0.05 * float64(di.Files)))) * 100 + if int64(availableFiles) <= minFreeDisk { + return errDiskFull + } + } + // Success. return nil }