Documentation ¶
Index ¶
- Constants
- Variables
- func CheckMountpoint(devID uint64) (string, bool, string)
- func GetDefaultQuota(quotas map[string]string) string
- func GetNextQuotaID() (uint32, error)
- func GetQuotaIDInFileAttr(dir string) uint32
- func SetDiskQuota(dir string, size string, quotaID uint32) error
- func SetQuotaDriver(name string)
- func SetQuotaIDInFileAttr(dir string, id uint32) error
- func SetQuotaIDInFileAttrNoOutput(dir string, quotaID uint32)
- func SetRootfsDiskQuota(basefs, size string, quotaID uint32) (uint32, error)
- func SetSubtree(dir string, qid uint32) (uint32, error)
- func StartQuotaDriver(dir string) (string, error)
- type BaseQuota
- type GrpQuotaDriver
- func (quota *GrpQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)
- func (quota *GrpQuotaDriver) EnforceQuota(dir string) (string, error)
- func (quota *GrpQuotaDriver) GetNextQuotaID() (uint32, error)
- func (quota *GrpQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32
- func (quota *GrpQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error
- func (quota *GrpQuotaDriver) SetQuotaIDInFileAttr(dir string, id uint32) error
- func (quota *GrpQuotaDriver) SetQuotaIDInFileAttrNoOutput(dir string, quotaID uint32)
- func (quota *GrpQuotaDriver) SetSubtree(dir string, qid uint32) (uint32, error)
- type OverlayMount
- type PrjQuotaDriver
- func (quota *PrjQuotaDriver) CheckMountpoint(devID uint64) (string, bool, string)
- func (quota *PrjQuotaDriver) EnforceQuota(dir string) (string, error)
- func (quota *PrjQuotaDriver) GetNextQuotaID() (uint32, error)
- func (quota *PrjQuotaDriver) GetQuotaIDInFileAttr(dir string) uint32
- func (quota *PrjQuotaDriver) SetDiskQuota(dir string, size string, quotaID uint32) error
- func (quota *PrjQuotaDriver) SetQuotaIDInFileAttr(dir string, quotaID uint32) error
- func (quota *PrjQuotaDriver) SetQuotaIDInFileAttrNoOutput(dir string, quotaID uint32)
- func (quota *PrjQuotaDriver) SetSubtree(dir string, qid uint32) (uint32, error)
- type RegExp
Constants ¶
const ( // QuotaMinID represents the minimize quota id. // The value is unit32(2^24). QuotaMinID = uint32(16777216) )
Variables ¶
var ( // GQuotaDriver represents global quota driver. GQuotaDriver = NewQuotaDriver("") )
Functions ¶
func CheckMountpoint ¶
CheckMountpoint is used to check mount point.
func GetDefaultQuota ¶
GetDefaultQuota returns the default quota size.
func GetNextQuotaID ¶
GetNextQuotaID returns the next available quota id.
func GetQuotaIDInFileAttr ¶
GetQuotaIDInFileAttr returns the directory attributes of quota ID.
func SetDiskQuota ¶
SetDiskQuota is used to set quota for directory.
func SetQuotaDriver ¶
func SetQuotaDriver(name string)
SetQuotaDriver is used to set global quota driver.
func SetQuotaIDInFileAttr ¶
SetQuotaIDInFileAttr is used to set file attributes of quota ID.
func SetQuotaIDInFileAttrNoOutput ¶
SetQuotaIDInFileAttrNoOutput is used to set file attribute of quota ID without error.
func SetRootfsDiskQuota ¶
SetRootfsDiskQuota is to set container rootfs dir disk quota.
func SetSubtree ¶
SetSubtree is used to set quota id for directory.
func StartQuotaDriver ¶
StartQuotaDriver is used to start quota driver.
Types ¶
type BaseQuota ¶
type BaseQuota interface { // EnforceQuota is used to enforce disk quota effect on specified directory. EnforceQuota(dir string) (string, error) // SetSubtree sets quota for container root dir which is a subtree of host's dir mapped on a device. SetSubtree(dir string, qid uint32) (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. 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 // SetQuotaIDInFileAttrNoOutput sets file attributes of quota ID for the input directory without returning error if exists. // The input attributes is quota ID. SetQuotaIDInFileAttrNoOutput(dir string, quotaID uint32) // GetNextQuotaID gets next quota ID in global scope of host. GetNextQuotaID() (uint32, error) }
BaseQuota defines the quota operation interface. It abstracts the common operation ways a quota driver should implement.
func NewQuotaDriver ¶
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) (string, 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) SetQuotaIDInFileAttr ¶
func (quota *GrpQuotaDriver) SetQuotaIDInFileAttr(dir string, id uint32) error
SetQuotaIDInFileAttr is used to set quota ID in file attributes.
func (*GrpQuotaDriver) SetQuotaIDInFileAttrNoOutput ¶
func (quota *GrpQuotaDriver) SetQuotaIDInFileAttrNoOutput(dir string, quotaID uint32)
SetQuotaIDInFileAttrNoOutput is used to set file attributes without error.
func (*GrpQuotaDriver) SetSubtree ¶
func (quota *GrpQuotaDriver) SetSubtree(dir string, qid uint32) (uint32, error)
SetSubtree is used to set quota id for directory, setfattr -n system.subtree -v $QUOTAID
type OverlayMount ¶
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) (string, error)
EnforceQuota is used to enforce disk quota effect on specified directory.
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) 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.
func (*PrjQuotaDriver) SetQuotaIDInFileAttrNoOutput ¶
func (quota *PrjQuotaDriver) SetQuotaIDInFileAttrNoOutput(dir string, quotaID uint32)
SetQuotaIDInFileAttrNoOutput is used to set file attributes without error.
func (*PrjQuotaDriver) SetSubtree ¶
func (quota *PrjQuotaDriver) SetSubtree(dir string, qid uint32) (uint32, error)
SetSubtree is used to set quota id for substree dir which is container's root dir. For container, it has its own root dir. And this dir is a subtree of the host dir which is mapped to a device. chattr -p qid +P $QUOTAID