quota

package
v0.0.0-...-ba854f2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 31

Documentation

Index

Constants

View Source
const (
	// QuotaMinID represents the minimize quota id.
	// The value is unit32(2^24).
	QuotaMinID = uint32(16777216)
)

Variables

View Source
var (
	// GQuotaDriver represents global quota driver.
	GQuotaDriver = NewQuotaDriver("")
)

Functions

func CheckMountpoint

func CheckMountpoint(devID uint64) (string, bool, string)

CheckMountpoint is used to check mount point.

func CheckRegularFile

func CheckRegularFile(file string) (bool, error)

CheckRegularFile is used to check the file is regular file or directory.

func GetNextQuotaID

func GetNextQuotaID() (uint32, error)

GetNextQuotaID returns the next available quota id.

func GetQuotaID

func GetQuotaID(dir string) (uint32, error)

GetQuotaID returns the quota id of directory, if no quota id, it will alloc the next available quota id.

func GetQuotaIDInFileAttr

func GetQuotaIDInFileAttr(dir string) uint32

GetQuotaIDInFileAttr returns the directory attributes of quota ID.

func IsSetQuotaID

func IsSetQuotaID(id string) bool

IsSetQuotaID returns whether set quota id

func SetDiskQuota

func SetDiskQuota(dir string, size string, quotaID uint32) error

SetDiskQuota is used to set quota for directory.

func SetFileAttrRecursive

func SetFileAttrRecursive(dir string, quotaID uint32) error

SetFileAttrRecursive set the file attr by recursively.

func SetQuotaDriver

func SetQuotaDriver(name string)

SetQuotaDriver is used to set global quota driver.

func SetRootfsDiskQuota

func SetRootfsDiskQuota(basefs, size string, quotaID uint32, update bool) (uint32, error)

SetRootfsDiskQuota is to set container rootfs dir disk quota.

Types

type BaseQuota

type BaseQuota interface {
	// EnforceQuota is used to enforce disk quota effect on specified directory.
	EnforceQuota(dir string) (*MountInfo, error)

	// SetDiskQuota uses the following two parameters to set disk quota for a directory.
	// * quota size: a byte size of requested quota.
	// * quota ID: an ID represent quota attr which is used in the global scope.
	SetDiskQuota(dir string, size string, quotaID uint32) error

	// CheckMountpoint is used to check mount point.
	// It returns mointpoint, enable quota and filesystem type of the device.
	CheckMountpoint(devID uint64) (string, bool, string)

	// GetQuotaIDInFileAttr gets attributes of the file which is in the inode.
	// The returned result is quota ID.
	GetQuotaIDInFileAttr(dir string) uint32

	// SetQuotaIDInFileAttr sets file attributes of quota ID for the input directory.
	// The input attributes is quota ID.
	SetQuotaIDInFileAttr(dir string, quotaID uint32) error

	// GetNextQuotaID gets next quota ID in global scope of host.
	GetNextQuotaID() (uint32, error)

	// SetFileAttrRecursive set the file attr by recursively.
	SetFileAttrRecursive(dir string, quotaID uint32) error
}

BaseQuota defines the quota operation interface. It abstracts the common operation ways a quota driver should implement.

func NewQuotaDriver

func NewQuotaDriver(name string) BaseQuota

NewQuotaDriver returns a quota instance.

type GrpQuotaDriver

type GrpQuotaDriver struct {
	// contains filtered or unexported fields
}

GrpQuotaDriver represents group quota driver.

func (*GrpQuotaDriver) CheckMountpoint

func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)

CheckMountpoint is used to check mount point. It returns mointpoint, enable quota and filesystem type of the device.

cat /proc/mounts as follows: /dev/sda3 / ext4 rw,relatime,data=ordered 0 0 /dev/sda2 /boot/grub2 ext4 rw,relatime,stripe=4,data=ordered 0 0 /dev/sda5 /home ext4 rw,relatime,data=ordered 0 0 /dev/sdb1 /home/pouch ext4 rw,relatime,prjquota,data=ordered 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/cpuset,cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu,cpuset 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0

func (*GrpQuotaDriver) EnforceQuota

func (quota *GrpQuotaDriver) EnforceQuota(dir string) (*MountInfo, error)

EnforceQuota is used to enforce disk quota effect on specified directory.

func (*GrpQuotaDriver) GetNextQuotaID

func (quota *GrpQuotaDriver) GetNextQuotaID() (uint32, error)

GetNextQuotaID returns the next available quota id.

func (*GrpQuotaDriver) GetQuotaIDInFileAttr

func (quota *GrpQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32

GetQuotaIDInFileAttr returns quota ID in the directory attributes. getfattr -n system.subtree --only-values --absolute-names /

func (*GrpQuotaDriver) SetDiskQuota

func (quota *GrpQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error

SetDiskQuota is used to set quota for directory.

func (*GrpQuotaDriver) SetFileAttrRecursive

func (quota *GrpQuotaDriver) SetFileAttrRecursive(dir string, quotaID uint32) error

SetFileAttrRecursive set the file attr by recursively.

func (*GrpQuotaDriver) SetQuotaIDInFileAttr

func (quota *GrpQuotaDriver) SetQuotaIDInFileAttr(dir string, id uint32) error

SetQuotaIDInFileAttr is used to set quota ID in file attributes.

type MountInfo

type MountInfo struct {
	MountPoint string
	FsType     string
	DeviceID   uint64
}

MountInfo defines the information of device mount.

type OverlayMount

type OverlayMount struct {
	Merged string
	Lower  string
	Upper  string
	Work   string
}

OverlayMount represents the parameters of overlay mount.

type PrjQuotaDriver

type PrjQuotaDriver struct {
	// contains filtered or unexported fields
}

PrjQuotaDriver represents project quota driver.

func (*PrjQuotaDriver) CheckMountpoint

func (quota *PrjQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)

CheckMountpoint is used to check mount point. It returns mointpoint, enable quota and filesystem type of the device.

cat /proc/mounts as follows: /dev/sda3 / ext4 rw,relatime,data=ordered 0 0 /dev/sda2 /boot/grub2 ext4 rw,relatime,stripe=4,data=ordered 0 0 /dev/sda5 /home ext4 rw,relatime,data=ordered 0 0 /dev/sdb1 /home/pouch ext4 rw,relatime,prjquota,data=ordered 0 0 tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/cpuset,cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu,cpuset 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0

func (*PrjQuotaDriver) EnforceQuota

func (quota *PrjQuotaDriver) EnforceQuota(dir string) (*MountInfo, error)

EnforceQuota is used to enforce disk quota effect on specified directory. it returns the mountpoint and error.

func (*PrjQuotaDriver) GetNextQuotaID

func (quota *PrjQuotaDriver) GetNextQuotaID() (uint32, error)

GetNextQuotaID returns the next available quota id.

func (*PrjQuotaDriver) GetQuotaIDInFileAttr

func (quota *PrjQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32

GetQuotaIDInFileAttr gets attributes of the file which is in the inode. The returned result is quota ID. return 0 if failure happens, since quota ID must be positive. execution command: `lsattr -p $dir`

func (*PrjQuotaDriver) SetDiskQuota

func (quota *PrjQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error

SetDiskQuota uses the following two parameters to set disk quota for a directory. * quota size: a byte size of requested quota. * quota ID: an ID represent quota attr which is used in the global scope.

func (*PrjQuotaDriver) SetFileAttrRecursive

func (quota *PrjQuotaDriver) SetFileAttrRecursive(dir string, quotaID uint32) error

SetFileAttrRecursive set the file attr by recursively.

func (*PrjQuotaDriver) SetQuotaIDInFileAttr

func (quota *PrjQuotaDriver) SetQuotaIDInFileAttr(dir string, quotaID uint32) error

SetQuotaIDInFileAttr sets file attributes of quota ID for the input directory. The input attributes is quota ID.

type QMap

type QMap struct {
	Source      string
	Destination string
	Expression  string
	Size        string
	QuotaID     uint32
}

QMap defines the path set quota size and quota id.

Jump to

Keyboard shortcuts

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