2012-11-15 22:13:35 +00:00
|
|
|
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
|
2012-11-30 14:54:40 +00:00
|
|
|
@@ -1611,6 +1611,25 @@ int mdmon_running(int devnum)
|
2012-11-15 22:13:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-30 14:54:40 +00:00
|
|
|
+int set_cgroup(char *group)
|
2012-11-15 22:13:35 +00:00
|
|
|
+{
|
|
|
|
+ char pid[8];
|
|
|
|
+ char pathbuf[PATH_MAX];
|
2012-11-30 14:54:40 +00:00
|
|
|
+ int tasks_fd, n;
|
2012-11-15 22:13:35 +00:00
|
|
|
+
|
|
|
|
+ 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());
|
2012-11-30 14:54:40 +00:00
|
|
|
+ n = write(tasks_fd, pid, strlen(pid));
|
2012-11-15 22:13:35 +00:00
|
|
|
+ close(tasks_fd);
|
2012-11-30 14:54:40 +00:00
|
|
|
+ if (n != (int)strlen(pid)) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
2012-11-15 22:13:35 +00:00
|
|
|
+ }
|
2012-11-30 14:54:40 +00:00
|
|
|
+ return 0;
|
2012-11-15 22:13:35 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
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),
|