Skip to content

Commit

Permalink
resize fs only if needed
Browse files Browse the repository at this point in the history
mount-utils now provides a function to check if a filesystem needs
resizing which helps optimize the flow and eliminate unnecessary
resize attempts.
  • Loading branch information
RomanBednar committed Oct 13, 2022
1 parent fbd2844 commit b8a22ac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/ibmcsidriver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,14 @@ func (su *VolumeStatUtils) IsDevicePathNotExist(devicePath string) bool {
// Resize expands the fs
func (volMountUtils *VolumeMountUtils) Resize(mounter mountmanager.Mounter, devicePath string, deviceMountPath string) (bool, error) {
r := mount.NewResizeFs(mounter.NewSafeFormatAndMount().Exec)
if _, err := r.Resize(devicePath, deviceMountPath); err != nil {
return false, err
needResize, err := r.NeedResize(devicePath, deviceMountPath)
if err != nil {
return false, status.Errorf(codes.Internal, "Could not determine if device %q needs to be resized: %v", devicePath, err)
}
if needResize {
if _, err := r.Resize(devicePath, deviceMountPath); err != nil {
return false, err
}
}
return true, nil
}

0 comments on commit b8a22ac

Please sign in to comment.