disk

package
v0.0.0-...-fb0f190 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignedBlock

func AlignedBlock(blockSize int) []byte

AlignedBlock - pass through to directio implementation.

func DisableDirectIO

func DisableDirectIO(f *os.File) error

DisableDirectIO - disables directio mode.

func FadviseDontNeed

func FadviseDontNeed(f *os.File) error

FadviseDontNeed invalidates page-cache

func Fdatasync

func Fdatasync(f *os.File) error

Fdatasync - fdatasync() is similar to fsync(), but does not flush modified metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled. For example, changes to st_atime or st_mtime (respectively, time of last access and time of last modification; see inode(7)) do not require flushing because they are not necessary for a subsequent data read to be handled correctly. On the other hand, a change to the file size (st_size, as made by say ftruncate(2)), would require a metadata flush.

The aim of fdatasync() is to reduce disk activity for applications that do not require all metadata to be synchronized with the disk.

func IsRootDisk

func IsRootDisk(diskPath string, rootDisk string) (bool, error)

IsRootDisk returns if diskPath belongs to root-disk, i.e the disk mounted at "/"

func OpenFileDirectIO

func OpenFileDirectIO(filePath string, flag int, perm os.FileMode) (*os.File, error)

OpenFileDirectIO - bypass kernel cache.

func SameDisk

func SameDisk(disk1, disk2 string) (bool, error)

SameDisk reports whether di1 and di2 describe the same disk.

Types

type AllDrivesIOStats

type AllDrivesIOStats map[DevID]IOStats

AllDrivesIOStats is map between drive devices and IO stats

func GetAllDrivesIOStats

func GetAllDrivesIOStats() (info AllDrivesIOStats, err error)

GetAllDrivesIOStats returns IO stats of all drives found in the machine

type DevID

type DevID struct {
	Major uint32
	Minor uint32
}

DevID is the drive major and minor ids

type IOStats

type IOStats struct {
	ReadIOs        uint64
	ReadMerges     uint64
	ReadSectors    uint64
	ReadTicks      uint64
	WriteIOs       uint64
	WriteMerges    uint64
	WriteSectors   uint64
	WriteTicks     uint64
	CurrentIOs     uint64
	TotalTicks     uint64
	ReqTicks       uint64
	DiscardIOs     uint64
	DiscardMerges  uint64
	DiscardSectors uint64
	DiscardTicks   uint64
	FlushIOs       uint64
	FlushTicks     uint64
}

IOStats contains stats of a single drive

type Info

type Info struct {
	Total  uint64
	Free   uint64
	Used   uint64
	Files  uint64
	Ffree  uint64
	FSType string
	Major  uint32
	Minor  uint32
}

Info stat fs struct is container which holds following values Total - total size of the volume / disk Free - free size of the volume / disk Files - total inodes available Ffree - free inodes available FSType - file system type

func GetInfo

func GetInfo(path string) (info Info, err error)

GetInfo returns total and free bytes available in a directory, e.g. `/`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL