The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8131
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From ce44bbbbe0d7ef2f07c31db3142c6be715ec4ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Sun, 8 Nov 2020 16:59:32 -0500 Subject: [PATCH 1/2] lxd/cgroup: Add V2 for GetBlkioWeight and SetBlkioWeight MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/cgroup/abstraction.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lxd/cgroup/abstraction.go b/lxd/cgroup/abstraction.go index bc9b085375..e2acd6ce08 100644 --- a/lxd/cgroup/abstraction.go +++ b/lxd/cgroup/abstraction.go @@ -376,7 +376,12 @@ func (cg *CGroup) GetBlkioWeight() (int64, error) { return strconv.ParseInt(val, 10, 64) case V2: - return -1, ErrControllerMissing + val, err := cg.rw.Get(version, "io", "io.weight") + if err != nil { + return -1, err + } + + return strconv.ParseInt(val, 10, 64) } return -1, ErrUnknownVersion @@ -391,7 +396,7 @@ func (cg *CGroup) SetBlkioWeight(limit int64) error { case V1: return cg.rw.Set(version, "blkio", "blkio.weight", fmt.Sprintf("%d", limit)) case V2: - return ErrControllerMissing + return cg.rw.Set(version, "blkio", "io.weight", fmt.Sprintf("%d", limit)) } return ErrUnknownVersion From 8830827fb9bfae94fc098daee6e3e8c537b5362e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Sun, 8 Nov 2020 18:18:22 -0500 Subject: [PATCH 2/2] lxd/device: Move disk priority back to lxc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/device/disk.go | 25 ------------------------- lxd/instance/drivers/driver_lxc.go | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lxd/device/disk.go b/lxd/device/disk.go index da3f862a68..7981de70e3 100644 --- a/lxd/device/disk.go +++ b/lxd/device/disk.go @@ -716,31 +716,6 @@ func (d *disk) applyQuota(newSize string) error { // generateLimits adds a set of cgroup rules to apply specified limits to the supplied RunConfig. func (d *disk) generateLimits(runConf *deviceConfig.RunConfig) error { - // Disk priority limits. - diskPriority := d.inst.ExpandedConfig()["limits.disk.priority"] - if diskPriority != "" { - if d.state.OS.CGInfo.Supports(cgroup.BlkioWeight, nil) { - priorityInt, err := strconv.Atoi(diskPriority) - if err != nil { - return err - } - - priority := priorityInt * 100 - - // Minimum valid value is 10 - if priority == 0 { - priority = 10 - } - - runConf.CGroups = append(runConf.CGroups, deviceConfig.RunConfigItem{ - Key: "blkio.weight", - Value: fmt.Sprintf("%d", priority), - }) - } else { - return fmt.Errorf("Cannot apply limits.disk.priority as blkio.weight cgroup controller is missing") - } - } - // Disk throttle limits. hasDiskLimits := false for _, dev := range d.inst.ExpandedDevices() { diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go index 74657da7a8..31d1961697 100644 --- a/lxd/instance/drivers/driver_lxc.go +++ b/lxd/instance/drivers/driver_lxc.go @@ -1224,6 +1224,31 @@ func (c *lxc) initLXC(config bool) error { } } + // Disk priority limits. + diskPriority := c.ExpandedConfig()["limits.disk.priority"] + if diskPriority != "" { + if c.state.OS.CGInfo.Supports(cgroup.BlkioWeight, nil) { + priorityInt, err := strconv.Atoi(diskPriority) + if err != nil { + return err + } + + priority := priorityInt * 100 + + // Minimum valid value is 10 + if priority == 0 { + priority = 10 + } + + err = cg.SetBlkioWeight(int64(priority)) + if err != nil { + return err + } + } else { + return fmt.Errorf("Cannot apply limits.disk.priority as blkio.weight cgroup controller is missing") + } + } + // Processes if c.state.OS.CGInfo.Supports(cgroup.Pids, cg) { processes := c.expandedConfig["limits.processes"]
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel