summaryrefslogtreecommitdiffstats
path: root/mdmon.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2008-07-12 20:27:40 +1000
committerNeil Brown <neilb@suse.de>2008-07-12 20:27:40 +1000
commit4d43913ce07ffbcb1ae8e7bdd06a4bd67cd07791 (patch)
treecc1f8daee6e0817a778fbaa1064b2afad50351a7 /mdmon.c
parent2f64e61a507ee4c1a8e2fcdbc2ce0ec89fcb7902 (diff)
downloadmdadm-4d43913ce07ffbcb1ae8e7bdd06a4bd67cd07791.tar.gz
mdadm-4d43913ce07ffbcb1ae8e7bdd06a4bd67cd07791.tar.xz
mdadm-4d43913ce07ffbcb1ae8e7bdd06a4bd67cd07791.zip
Remove mgr_pipe for communicating from manage to monitor.
Data is being passed in shared memory, so the pipe is only being use as a wakeup. This can more easily be done with a thread-signal.
Diffstat (limited to 'mdmon.c')
-rw-r--r--mdmon.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/mdmon.c b/mdmon.c
index bb0c4f7..08f4445 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -26,10 +26,12 @@
#include <unistd.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/mman.h>
+#include <sys/syscall.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -43,17 +45,14 @@
struct active_array *discard_this;
struct active_array *pending_discard;
-struct md_generic_cmd *active_cmd;
+
+int mon_tid, mgr_tid;
int run_child(void *v)
{
struct supertype *c = v;
- sigset_t set;
- /* SIGUSR is sent from child to parent, So child must block it */
- sigemptyset(&set);
- sigaddset(&set, SIGUSR1);
- sigprocmask(SIG_BLOCK, &set, NULL);
+ mon_tid = syscall(SYS_gettid);
do_monitor(c);
return 0;
}
@@ -63,22 +62,13 @@ int clone_monitor(struct supertype *container)
static char stack[4096];
int rv;
- rv = pipe(container->mgr_pipe);
- if (rv < 0)
- return rv;
rv = clone(run_child, stack+4096-64,
CLONE_FS|CLONE_FILES|CLONE_VM|CLONE_SIGHAND|CLONE_THREAD,
container);
- if (rv < 0)
- goto err_clone;
- else
- return rv;
-
- err_clone:
- close(container->mgr_pipe[0]);
- close(container->mgr_pipe[1]);
+ mgr_tid = syscall(SYS_gettid);
+
return rv;
}
@@ -176,11 +166,18 @@ static int make_control_sock(char *devname)
return sfd;
}
+static void wake_me(int sig)
+{
+
+}
+
int main(int argc, char *argv[])
{
int mdfd;
struct mdinfo *mdi, *di;
struct supertype *container;
+ sigset_t set;
+
if (argc != 2) {
fprintf(stderr, "Usage: md-manage /device/name/for/container\n");
exit(2);
@@ -277,6 +274,14 @@ int main(int argc, char *argv[])
mlockall(MCL_FUTURE);
+ /* SIGUSR is sent between parent and child. So both block it
+ * and enable it only with pselect.
+ */
+ sigemptyset(&set);
+ sigaddset(&set, SIGUSR1);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+ signal(SIGUSR1, wake_me);
+
if (clone_monitor(container) < 0) {
fprintf(stderr, "md-manage: failed to start monitor process: %s\n",
strerror(errno));