2018-02-05 16:05:59 -05:00
|
|
|
package vfs // import "github.com/docker/docker/daemon/graphdriver/vfs"
|
2017-10-30 16:18:14 -04:00
|
|
|
|
2017-12-19 16:47:12 -05:00
|
|
|
import (
|
2020-08-09 16:04:43 -04:00
|
|
|
"github.com/docker/docker/quota"
|
2017-12-19 16:47:12 -05:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
2017-10-30 16:18:14 -04:00
|
|
|
|
2019-08-28 11:11:30 -04:00
|
|
|
//nolint:structcheck
|
2017-10-30 16:18:14 -04:00
|
|
|
type driverQuota struct {
|
|
|
|
quotaCtl *quota.Control
|
2019-01-15 06:49:23 -05:00
|
|
|
quotaOpt quota.Quota
|
2017-10-30 16:18:14 -04:00
|
|
|
}
|
|
|
|
|
2017-12-19 16:47:12 -05:00
|
|
|
func setupDriverQuota(driver *Driver) {
|
2017-10-30 16:18:14 -04:00
|
|
|
if quotaCtl, err := quota.NewControl(driver.home); err == nil {
|
|
|
|
driver.quotaCtl = quotaCtl
|
|
|
|
} else if err != quota.ErrQuotaNotSupported {
|
2017-12-19 16:47:12 -05:00
|
|
|
logrus.Warnf("Unable to setup quota: %v\n", err)
|
2017-10-30 16:18:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 06:49:23 -05:00
|
|
|
func (d *Driver) setQuotaOpt(size uint64) error {
|
|
|
|
d.quotaOpt.Size = size
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Driver) getQuotaOpt() uint64 {
|
|
|
|
return d.quotaOpt.Size
|
|
|
|
}
|
|
|
|
|
2017-10-30 16:18:14 -04:00
|
|
|
func (d *Driver) setupQuota(dir string, size uint64) error {
|
|
|
|
return d.quotaCtl.SetQuota(dir, quota.Quota{Size: size})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Driver) quotaSupported() bool {
|
|
|
|
return d.quotaCtl != nil
|
|
|
|
}
|