Skip to content

Commit

Permalink
fix performance degradation of NFS
Browse files Browse the repository at this point in the history
Signed-off-by: fusida <[email protected]>
  • Loading branch information
fusida committed Jul 21, 2023
1 parent 248756c commit aacbb13
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func (i *RealFsInfo) GetFsInfoForPath(mountSet map[string]struct{}) ([]Fs, error
if err != nil {
return nil, err
}
nfsInfo := make(map[string]Fs, 0)
for device, partition := range i.partitions {
_, hasMount := mountSet[partition.mountpoint]
_, hasDevice := deviceSet[device]
Expand All @@ -410,10 +411,21 @@ func (i *RealFsInfo) GetFsInfoForPath(mountSet map[string]struct{}) ([]Fs, error
default:
var inodes, inodesFree uint64
if utils.FileExists(partition.mountpoint) {
if strings.HasPrefix(partition.fsType, "nfs") {
devId := fmt.Sprintf("%d:%d", partition.major, partition.minor)
if v, ok := nfsInfo[devId]; ok {
fs = v
break
}
}
fs.Capacity, fs.Free, fs.Available, inodes, inodesFree, err = getVfsStats(partition.mountpoint)
fs.Inodes = &inodes
fs.InodesFree = &inodesFree
fs.Type = VFS
if strings.HasPrefix(partition.fsType, "nfs") {
devId := fmt.Sprintf("%d:%d", partition.major, partition.minor)
nfsInfo[devId] = fs
}
} else {
klog.V(4).Infof("unable to determine file system type, partition mountpoint does not exist: %v", partition.mountpoint)
}
Expand Down

0 comments on commit aacbb13

Please sign in to comment.