summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-07-22 17:43:35 +1000
committerNeilBrown <neilb@suse.de>2010-07-22 17:43:35 +1000
commit8562409dd17ab4910befcbfaba8fe8b751418b6b (patch)
tree188593c4058dbcb31c193ce52603ef94d13f9157
parentc43f7d91cc15a1eb202e40e435623bf14dc2adb8 (diff)
parent1dccfff910ce9d854330302b9a34636d63cdac7b (diff)
downloadmdadm-master.zip
mdadm-master.tar.gz
mdadm-master.tar.xz
Merge branch 'master' of git://github.com/djbw/mdadmHEADmaster
-rw-r--r--Incremental.c11
-rw-r--r--Makefile14
-rw-r--r--mdadm.h1
-rw-r--r--mdmon.c42
-rw-r--r--super-intel.c4
-rw-r--r--util.c7
6 files changed, 69 insertions, 10 deletions
diff --git a/Incremental.c b/Incremental.c
index eb27784..35490e7 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -376,7 +376,16 @@ int Incremental(char *devname, int verbose, int runstop,
* statement about this.
*/
if (runstop < 1) {
- if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+ int active = 0;
+
+ if (st->ss->external) {
+ char *devname = devnum2devname(fd2devnum(mdfd));
+
+ active = devname && is_container_active(devname);
+ free(devname);
+ } else if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0)
+ active = 1;
+ if (active) {
fprintf(stderr, Name
": not adding %s to active array (without --run) %s\n",
devname, chosen_name);
diff --git a/Makefile b/Makefile
index 237f4fc..0f42f88 100644
--- a/Makefile
+++ b/Makefile
@@ -75,6 +75,14 @@ ALTFLAGS = -DALT_RUN=\"$(ALT_RUN)\" -DALT_MAPFILE=\"$(ALT_MAPFILE)\"
VARFLAGS = -DVAR_RUN=\"$(VAR_RUN)\"
CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(ALTFLAGS) $(VARFLAGS)
+# The glibc TLS ABI requires applications that call clone(2) to set up
+# TLS data structures, use pthreads until mdmon implements this support
+USE_PTHREADS = 1
+ifdef USE_PTHREADS
+CFLAGS += -DUSE_PTHREADS
+LDFLAGS += -pthread
+endif
+
# If you want a static binary, you might uncomment these
# LDFLAGS = -static
# STRIP = -s
@@ -149,13 +157,13 @@ mdadm.klibc : $(SRCS) mdadm.h
$(CC) -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
mdadm.Os : $(SRCS) mdadm.h
- $(CC) -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
+ $(CC) -o mdadm.Os $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
mdadm.O2 : $(SRCS) mdadm.h mdmon.O2
- $(CC) -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(SRCS)
+ $(CC) -o mdadm.O2 $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(SRCS)
mdmon.O2 : $(MON_SRCS) mdadm.h mdmon.h
- $(CC) -o mdmon.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(MON_SRCS)
+ $(CC) -o mdmon.O2 $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(MON_SRCS)
# use '-z now' to guarantee no dynamic linker interactions with the monitor thread
mdmon : $(MON_OBJS)
diff --git a/mdadm.h b/mdadm.h
index 55e9e46..f1fe24f 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -930,6 +930,7 @@ extern int open_mddev(char *dev, int report_errors);
extern int open_container(int fd);
extern int is_container_member(struct mdstat_ent *ent, char *devname);
extern int is_subarray_active(char *subarray, char *devname);
+int is_container_active(char *devname);
extern int open_subarray(char *dev, struct supertype *st, int quiet);
extern struct superswitch *version_to_superswitch(char *vers);
diff --git a/mdmon.c b/mdmon.c
index 0c37426..c4c0181 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -58,8 +58,11 @@
#include <fcntl.h>
#include <signal.h>
#include <dirent.h>
-
+#ifdef USE_PTHREADS
+#include <pthread.h>
+#else
#include <sched.h>
+#endif
#include "mdadm.h"
#include "mdmon.h"
@@ -71,7 +74,39 @@ int mon_tid, mgr_tid;
int sigterm;
-int run_child(void *v)
+#ifdef USE_PTHREADS
+static void *run_child(void *v)
+{
+ struct supertype *c = v;
+
+ mon_tid = syscall(SYS_gettid);
+ do_monitor(c);
+ return 0;
+}
+
+static int clone_monitor(struct supertype *container)
+{
+ pthread_attr_t attr;
+ pthread_t thread;
+ int rc;
+
+ mon_tid = -1;
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, 4096);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ rc = pthread_create(&thread, &attr, run_child, container);
+ if (rc)
+ return rc;
+ while (mon_tid == -1)
+ usleep(10);
+ pthread_attr_destroy(&attr);
+
+ mgr_tid = syscall(SYS_gettid);
+
+ return mon_tid;
+}
+#else /* USE_PTHREADS */
+static int run_child(void *v)
{
struct supertype *c = v;
@@ -85,7 +120,7 @@ int __clone2(int (*fn)(void *),
int flags, void *arg, ...
/* pid_t *pid, struct user_desc *tls, pid_t *ctid */ );
#endif
- int clone_monitor(struct supertype *container)
+static int clone_monitor(struct supertype *container)
{
static char stack[4096];
@@ -103,6 +138,7 @@ int __clone2(int (*fn)(void *),
return mon_tid;
}
+#endif /* USE_PTHREADS */
static int make_pidfile(char *devname)
{
diff --git a/super-intel.c b/super-intel.c
index daf811f..6826d9b 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4830,8 +4830,8 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot,
struct extent *ex;
int i, j;
int found;
- __u32 array_start;
- __u32 array_end;
+ __u32 array_start = 0;
+ __u32 array_end = 0;
struct dl *dl;
for (dl = super->disks; dl; dl = dl->next) {
diff --git a/util.c b/util.c
index d22b0d0..1ce6a7a 100644
--- a/util.c
+++ b/util.c
@@ -1427,7 +1427,7 @@ int is_subarray_active(char *subarray, char *container)
if (is_container_member(ent, container)) {
char *inst = &ent->metadata_version[10+strlen(container)+1];
- if (strcmp(inst, subarray) == 0)
+ if (!subarray || strcmp(inst, subarray) == 0)
break;
}
}
@@ -1437,6 +1437,11 @@ int is_subarray_active(char *subarray, char *container)
return ent != NULL;
}
+int is_container_active(char *container)
+{
+ return is_subarray_active(NULL, container);
+}
+
/* open_subarray - opens a subarray in a container
* @dev: container device name
* @st: supertype with only ->subarray set