bd1529
From af9f03ba48dd75be8c6a923f70da9804b3a3a2c3 Mon Sep 17 00:00:00 2001
bd1529
From: Pavel Hrdina <phrdina@redhat.com>
bd1529
Date: Wed, 25 Nov 2020 09:05:36 +0100
bd1529
Subject: [PATCH] cgroup: Also set blkio.bfq.weight
bd1529
bd1529
Commit [1] added a workaround when unified cgroups are used but missed
bd1529
legacy cgroups where there is the same issue.
bd1529
bd1529
[1] <https://github.com/systemd/systemd/commit/2dbc45aea747f25cc1c3848fded2ec0062f96bcf>
bd1529
bd1529
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
bd1529
(cherry picked from commit 35e7a62ca32a30169a94693b831e53c832251984)
bd1529
bd1529
Resolves: #1657810
bd1529
---
bd1529
 src/core/cgroup.c | 8 ++++++++
bd1529
 1 file changed, 8 insertions(+)
bd1529
bd1529
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
bd1529
index f1ce070f9a..71e30fd4db 100644
bd1529
--- a/src/core/cgroup.c
bd1529
+++ b/src/core/cgroup.c
bd1529
@@ -1063,6 +1063,14 @@ static void cgroup_context_apply(
bd1529
                                 log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
bd1529
                                               "Failed to set blkio.weight: %m");
bd1529
 
bd1529
+                        /* FIXME: drop this when distro kernels properly support BFQ through "blkio.weight"
bd1529
+                         * See also: https://github.com/systemd/systemd/pull/13335 */
bd1529
+                        xsprintf(buf, "%" PRIu64 "\n", weight);
bd1529
+                        r = cg_set_attribute("blkio", path, "blkio.bfq.weight", buf);
bd1529
+                        if (r < 0)
bd1529
+                                log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
bd1529
+                                              "Failed to set blkio.bfq.weight: %m");
bd1529
+
bd1529
                         if (has_io) {
bd1529
                                 CGroupIODeviceWeight *w;
bd1529