[lxc-devel] [lxd/master] blkio limits fixes

stgraber on Github lxc-bot at linuxcontainers.org
Tue Oct 9 19:05:11 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181009/1ab15578/attachment.bin>
-------------- next part --------------
From 56d417c185ce9bbe0716cd0a74084e8ef3c4bd4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 9 Oct 2018 15:03:23 -0400
Subject: [PATCH 1/2] devices: Fix bad disk limits

---
 lxd/devices.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/devices.go b/lxd/devices.go
index 73f774b000..c0ae53dc4e 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -1310,7 +1310,7 @@ func deviceParseDiskLimit(readSpeed string, writeSpeed string) (int64, int64, in
 		bps := int64(0)
 		iops := int64(0)
 
-		if readSpeed == "" {
+		if value == "" {
 			return bps, iops, nil
 		}
 

From c4f02c3fd5666fac122ed2de2b0f499917627b2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 9 Oct 2018 15:03:31 -0400
Subject: [PATCH 2/2] Fix root disk limits on container startup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5115

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index f70f4497af..26e3193fc7 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1395,6 +1395,7 @@ func (c *containerLXC) initLXC(config bool) error {
 		}
 
 		hasDiskLimits := false
+		hasRootLimit := false
 		for _, name := range c.expandedDevices.DeviceNames() {
 			m := c.expandedDevices[name]
 			if m["type"] != "disk" {
@@ -1402,17 +1403,36 @@ func (c *containerLXC) initLXC(config bool) error {
 			}
 
 			if m["limits.read"] != "" || m["limits.write"] != "" || m["limits.max"] != "" {
+				if m["path"] == "/" {
+					hasRootLimit = true
+				}
+
 				hasDiskLimits = true
-				break
 			}
 		}
 
 		if hasDiskLimits {
+			ourStart := false
+
+			if hasRootLimit {
+				ourStart, err = c.StorageStart()
+				if err != nil {
+					return err
+				}
+			}
+
 			diskLimits, err := c.getDiskLimits()
 			if err != nil {
 				return err
 			}
 
+			if hasRootLimit && ourStart {
+				_, err = c.StorageStop()
+				if err != nil {
+					return err
+				}
+			}
+
 			for block, limit := range diskLimits {
 				if limit.readBps > 0 {
 					err = lxcSetConfigItem(cc, "lxc.cgroup.blkio.throttle.read_bps_device", fmt.Sprintf("%s %d", block, limit.readBps))


More information about the lxc-devel mailing list