mdadm/mdadm-3.2.6-cgroup.patch
Jes Sorensen ecbec5e0c4 Fix build issue with cgroups workaround patch
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2012-11-30 15:54:40 +01:00

38 lines
934 B
Diff

diff -up mdadm-3.2.6/util.c.cgroup mdadm-3.2.6/util.c
--- mdadm-3.2.6/util.c.cgroup 2012-11-15 16:48:03.327035349 -0500
+++ mdadm-3.2.6/util.c 2012-11-15 17:07:16.628751041 -0500
@@ -1611,6 +1611,25 @@ int mdmon_running(int devnum)
return 0;
}
+int set_cgroup(char *group)
+{
+ char pid[8];
+ char pathbuf[PATH_MAX];
+ int tasks_fd, n;
+
+ snprintf(pathbuf, PATH_MAX, "/sys/fs/cgroup/%s/tasks", group);
+ tasks_fd = open(pathbuf, O_WRONLY);
+ if (tasks_fd >= 0) {
+ snprintf(pid, sizeof(pid), "%d", getpid());
+ n = write(tasks_fd, pid, strlen(pid));
+ close(tasks_fd);
+ if (n != (int)strlen(pid)) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
int start_mdmon(int devnum)
{
int i, skipped;
@@ -1653,6 +1668,7 @@ int start_mdmon(int devnum)
for (i=0; paths[i]; i++)
if (paths[i][0]) {
+ set_cgroup("systemd");
if (__offroot) {
execl(paths[i], "mdmon", "--offroot",
devnum2devname(devnum),