2012-11-15 22:13:35 +00:00
|
|
|
diff -up mdadm-3.2.6/util.c.cgroup mdadm-3.2.6/util.c
|
2013-01-08 15:35:00 +00:00
|
|
|
--- mdadm-3.2.6/mdmon.c.cgroup 2012-11-15 16:48:03.327035349 -0500
|
|
|
|
+++ mdadm-3.2.6/mdmon.c 2012-11-15 17:07:16.628751041 -0500
|
|
|
|
@@ -386,6 +386,25 @@
|
|
|
|
return mdmon(devname, devnum, do_fork(), takeover);
|
2012-11-15 22:13:35 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
+}
|
|
|
|
+
|
2013-01-08 15:35:00 +00:00
|
|
|
static int mdmon(char *devname, int devnum, int must_fork, int takeover)
|
2012-11-15 22:13:35 +00:00
|
|
|
{
|
2013-01-08 15:35:00 +00:00
|
|
|
int mdfd;
|
|
|
|
@@ -438,6 +457,8 @@
|
|
|
|
} else
|
|
|
|
pfd[0] = pfd[1] = -1;
|
2012-11-15 22:13:35 +00:00
|
|
|
|
2013-01-08 15:35:00 +00:00
|
|
|
+ set_cgroup("systemd");
|
|
|
|
+
|
|
|
|
container = calloc(1, sizeof(*container));
|
|
|
|
container->devnum = devnum;
|
|
|
|
container->devname = devname;
|