Skip to content

Commit

Permalink
lxd/storage/drivers/powerflex: Add usage information support for moun…
Browse files Browse the repository at this point in the history
…ted volumes

Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Oct 17, 2023
1 parent 1ed8558 commit 9e20bca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lxd/storage/drivers/driver_powerflex_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,22 @@ func (d *powerflex) UpdateVolume(vol Volume, changedConfig map[string]string) er
}

// GetVolumeUsage returns the disk space used by the volume.
// TODO: Query statistics from PowerFlex if not mounted.
func (d *powerflex) GetVolumeUsage(vol Volume) (int64, error) {
isSnap := vol.IsSnapshot()

// If mounted, use the filesystem stats for pretty accurate usage information.
if !isSnap && vol.contentType == ContentTypeFS && filesystem.IsMountPoint(vol.MountPath()) {
var stat unix.Statfs_t

err := unix.Statfs(vol.MountPath(), &stat)
if err != nil {
return -1, err
}

return int64(stat.Blocks-stat.Bfree) * int64(stat.Bsize), nil
}

return 0, ErrNotSupported
}

Expand Down

0 comments on commit 9e20bca

Please sign in to comment.