d047b34df2
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
39 lines
942 B
Diff
39 lines
942 B
Diff
diff -up mdadm-3.2.6/util.c.cgroup mdadm-3.2.6/util.c
|
|
--- 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);
|
|
}
|
|
|
|
+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;
|
|
+}
|
|
+
|
|
static int mdmon(char *devname, int devnum, int must_fork, int takeover)
|
|
{
|
|
int mdfd;
|
|
@@ -438,6 +457,8 @@
|
|
} else
|
|
pfd[0] = pfd[1] = -1;
|
|
|
|
+ set_cgroup("systemd");
|
|
+
|
|
container = calloc(1, sizeof(*container));
|
|
container->devnum = devnum;
|
|
container->devname = devname;
|