]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Merge branch 'master' of git://github.com/djbw/mdadm into devel-3.0
authorNeilBrown <neilb@suse.de>
Tue, 2 Jun 2009 05:28:41 +0000 (15:28 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 2 Jun 2009 05:28:41 +0000 (15:28 +1000)
33 files changed:
Assemble.c
Build.c
Create.c
Detail.c
Examine.c
Grow.c
Incremental.c
Kill.c
Makefile
Manage.c
Monitor.c
Query.c
ReadMe.c
config.c
managemon.c
md.4
mdadm.8
mdadm.c
mdadm.conf.5
mdadm.h
mdassemble.c
mdmon.8
mdmon.c
mdmon.h
mdopen.c
mdstat.c
monitor.c
restripe.c
super-ddf.c
super0.c
super1.c
sysfs.c
util.c

index e75c7e5eaf9c7615f062f6d61bcf20dfa9538772..3c3a004fc8045a67b16351a4bde7d7d3b67f8c04 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
@@ -188,6 +183,8 @@ int Assemble(struct supertype *st, char *mddev,
        if (!devlist &&
            ident->uuid_set == 0 &&
            ident->super_minor < 0 &&
+           ident->name[0] == 0 &&
+           (ident->container == NULL || ident->member == NULL) &&
            ident->devices == NULL) {
                fprintf(stderr, Name ": No identity information available for %s - cannot assemble.\n",
                        mddev ? mddev : "further assembly");
diff --git a/Build.c b/Build.c
index 2d9f68f0311515c5ae48f64c40130e850e445147..7f3925864731bf63e0c1c1a10357a3476a95a2fe 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include "mdadm.h"
index 36df10ddc65681b34b1fb021793f68c307b0121e..8a73799c4448c727308228dc51c34049093ebe65 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include "mdadm.h"
index 54db558b48dd8664f9f660d3a3a25642ecc32e8e..ab01cfb4b59092cfbd84c19808135ed995aa681a 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
index bc06b40c5c662a31e6f28555655e06905b948444..f0e98f974d2e58885ebc238cdd796690bf4a9dee 100644 (file)
--- a/Examine.c
+++ b/Examine.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
diff --git a/Grow.c b/Grow.c
index 15cec5f103bf874bdb4669a97086dce333089bee..18056047819ad4d6affe74b42b7b950151bc2913 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 #include       "mdadm.h"
 #include       "dlink.h"
index b6f527ab518193aa7b492d4ff5010968346ff306..8c686f7e8e6bde1d426d8731f3bdeca8a9d5c1d3 100644 (file)
@@ -2,7 +2,7 @@
  * Incremental.c - support --incremental.  Part of:
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2006-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
diff --git a/Kill.c b/Kill.c
index 96b270f278db10d6361a8c45d17798db75dd3068..f5c582180ac28d7a8593657f42b02d481aa352be 100644 (file)
--- a/Kill.c
+++ b/Kill.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  *
  *    Added by Dale Stephenson
  *    steph@snapserver.com
index a0d50b5e1bdb29f58bed609dbb0cb1cff909f0a3..56363926031af63254271289b3883fab604aafa4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,7 +88,7 @@ SRCS =  mdadm.c config.c mdstat.c  ReadMe.c util.c Manage.c Assemble.c Build.c \
 
 MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
        Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
-       super-ddf.o sha1.o crc32.o msg.o Monitor.o bitmap.o \
+       super-ddf.o sha1.o crc32.o msg.o bitmap.o \
        platform-intel.o probe_roms.o
 
 
@@ -105,7 +105,7 @@ ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
 endif
 
-all : mdadm mdmon mdadm.man md.man mdadm.conf.man
+all : mdadm mdmon mdadm.man md.man mdadm.conf.man mdmon.man
 
 everything: all mdadm.static swap_super test_stripe \
        mdassemble mdassemble.auto mdassemble.static mdassemble.man \
@@ -167,6 +167,9 @@ mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
 mdadm.man : mdadm.8
        nroff -man mdadm.8 > mdadm.man
 
+mdmon.man : mdmon.8
+       nroff -man mdmon.8 > mdmon.man
+
 md.man : md.4
        nroff -man md.4 > md.man
 
@@ -198,8 +201,9 @@ install-uclibc : mdadm.uclibc install-man
 install-klibc : mdadm.klibc install-man
        $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
 
-install-man: mdadm.8 md.4 mdadm.conf.5
+install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
        $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
+       $(INSTALL) -D -m 644 mdmon.8 $(DESTDIR)$(MAN8DIR)/mdmon.8
        $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
        $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
 
@@ -207,7 +211,7 @@ install-udev: udev-md-raid.rules
        $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
 
 uninstall:
-       rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 md.4 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
+       rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
 
 test: mdadm mdmon test_stripe swap_super
        @echo "Please run 'sh ./test' as root"
index 65235bc1836f5e02c22c3e703cea2f39789b8023..3aa09bcba241caba52b989abd6804de9e65a056e 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include "mdadm.h"
@@ -446,11 +441,15 @@ int Manage_subdevs(char *devname, int fd,
                } else {
                        j = 0;
 
-                       if (stat(dv->devname, &stb)) {
+                       tfd = dev_open(dv->devname, O_RDONLY);
+                       if (tfd < 0 || fstat(tfd, &stb) != 0) {
                                fprintf(stderr, Name ": cannot find %s: %s\n",
                                        dv->devname, strerror(errno));
+                               if (tfd >= 0)
+                                       close(tfd);
                                return 1;
                        }
+                       close(tfd);
                        if ((stb.st_mode & S_IFMT) != S_IFBLK) {
                                fprintf(stderr, Name ": %s is not a "
                                        "block device.\n",
@@ -472,7 +471,7 @@ int Manage_subdevs(char *devname, int fd,
                                return 1;
                        }
                        /* Make sure it isn't in use (in 2.6 or later) */
-                       tfd = open(dv->devname, O_RDONLY|O_EXCL|O_DIRECT);
+                       tfd = dev_open(dv->devname, O_RDONLY|O_EXCL|O_DIRECT);
                        if (tfd < 0) {
                                fprintf(stderr, Name ": Cannot open %s: %s\n",
                                        dv->devname, strerror(errno));
@@ -628,7 +627,7 @@ int Manage_subdevs(char *devname, int fd,
                                int dfd;
                                if (dv->writemostly == 1)
                                        disc.state |= 1 << MD_DISK_WRITEMOSTLY;
-                               dfd = open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
+                               dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
                                if (tst->ss->add_to_super(tst, &disc, dfd,
                                                          dv->devname)) {
                                        close(dfd);
index e43175f186d878acc6c0f5591ea1187f5bc8e0b9..f6fd95cdfa9401c9bef67bdefd3403f8a3a5e852 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
@@ -284,6 +279,10 @@ int Monitor(mddev_dev_t devlist,
                                        mse = mse2;
                                }
 
+                       if (array.utime == 0)
+                               /* external arrays don't update utime */
+                               array.utime = time(0);
+
                        if (st->utime == array.utime &&
                            st->failed == array.failed_disks &&
                            st->working == array.working_disks &&
@@ -481,16 +480,25 @@ int Monitor(mddev_dev_t devlist,
                                                        }
                                                }
                                                if (dev > 0) {
-                                                       if (ioctl(fd2, HOT_REMOVE_DISK,
-                                                                 (unsigned long)dev) == 0) {
-                                                               if (ioctl(fd1, HOT_ADD_DISK,
-                                                                         (unsigned long)dev) == 0) {
+                                                       struct mddev_dev_s devlist;
+                                                       char devname[20];
+                                                       devlist.next = NULL;
+                                                       devlist.used = 0;
+                                                       devlist.re_add = 0;
+                                                       devlist.writemostly = 0;
+                                                       devlist.devname = devname;
+                                                       sprintf(devname, "%d:%d", major(dev), minor(dev));
+
+                                                       devlist.disposition = 'r';
+                                                       if (Manage_subdevs(st2->devname, fd2, &devlist, -1) == 0) {
+                                                               devlist.disposition = 'a';
+                                                               if (Manage_subdevs(st->devname, fd1, &devlist, -1) == 0) {
                                                                        alert("MoveSpare", st->devname, st2->devname, mailaddr, mailfrom, alert_cmd, dosyslog);
                                                                        close(fd1);
                                                                        close(fd2);
                                                                        break;
                                                                }
-                                                               else ioctl(fd2, HOT_ADD_DISK, (unsigned long) dev);
+                                                               else Manage_subdevs(st2->devname, fd2, &devlist, -1);
                                                        }
                                                }
                                                close(fd1);
@@ -641,107 +649,3 @@ int Wait(char *dev)
                mdstat_wait(5);
        }
 }
-
-static char *clean_states[] = {
-       "clear", "inactive", "readonly", "read-auto", "clean", NULL };
-
-int WaitClean(char *dev, int verbose)
-{
-       int fd;
-       struct mdinfo *mdi;
-       int rv = 1;
-       int devnum;
-
-       fd = open(dev, O_RDONLY); 
-       if (fd < 0) {
-               if (verbose)
-                       fprintf(stderr, Name ": Couldn't open %s: %s\n", dev, strerror(errno));
-               return 1;
-       }
-
-       devnum = fd2devnum(fd);
-       mdi = sysfs_read(fd, devnum, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
-       if (!mdi) {
-               if (verbose)
-                       fprintf(stderr, Name ": Failed to read sysfs attributes for "
-                               "%s\n", dev);
-               close(fd);
-               return 0;
-       }
-
-       switch(mdi->array.level) {
-       case LEVEL_LINEAR:
-       case LEVEL_MULTIPATH:
-       case 0:
-               /* safemode delay is irrelevant for these levels */
-               rv = 0;
-               
-       }
-
-       /* for internal metadata the kernel handles the final clean
-        * transition, containers can never be dirty
-        */
-       if (!is_subarray(mdi->text_version))
-               rv = 0;
-
-       /* safemode disabled ? */
-       if (mdi->safe_mode_delay == 0)
-               rv = 0;
-
-       if (rv) {
-               int state_fd = sysfs_open(fd2devnum(fd), NULL, "array_state");
-               char buf[20];
-               fd_set fds;
-               struct timeval tm;
-
-               /* minimize the safe_mode_delay and prepare to wait up to 5s
-                * for writes to quiesce
-                */
-               sysfs_set_safemode(mdi, 1);
-               tm.tv_sec = 5;
-               tm.tv_usec = 0;
-
-               /* give mdmon a chance to checkpoint resync */
-               sysfs_set_str(mdi, NULL, "sync_action", "idle");
-
-               FD_ZERO(&fds);
-
-               /* wait for array_state to be clean */
-               while (1) {
-                       rv = read(state_fd, buf, sizeof(buf));
-                       if (rv < 0)
-                               break;
-                       if (sysfs_match_word(buf, clean_states) <= 4)
-                               break;
-                       FD_SET(state_fd, &fds);
-                       rv = select(state_fd + 1, NULL, NULL, &fds, &tm);
-                       if (rv < 0 && errno != EINTR)
-                               break;
-                       lseek(state_fd, 0, SEEK_SET);
-               }
-               if (rv < 0)
-                       rv = 1;
-               else if (ping_monitor(mdi->text_version) == 0) {
-                       /* we need to ping to close the window between array
-                        * state transitioning to clean and the metadata being
-                        * marked clean
-                        */
-                       rv = 0;
-               } else
-                       rv = 1;
-               if (rv && verbose)
-                       fprintf(stderr, Name ": Error waiting for %s to be clean\n",
-                               dev);
-
-               /* restore the original safe_mode_delay */
-               sysfs_set_safemode(mdi, mdi->safe_mode_delay);
-               close(state_fd);
-       }
-
-       sysfs_free(mdi);
-       close(fd);
-
-       return rv;
-}
-
-
diff --git a/Query.c b/Query.c
index dc69eb8271ec171c35a418bf883b52cfacb04b6d..8847be7ec0b6a1e0880865d672b38f9f0374d2e2 100644 (file)
--- a/Query.c
+++ b/Query.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2002-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2002-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
index a1944796f588fc7ba592d6306a1d33cc6e521993..b8734d106cb9c54e317e9363bda808861806879a 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2007 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
@@ -139,7 +139,9 @@ struct option long_options[] = {
     {"write-mostly",0, 0, 'W'},
     {"re-add",    0, 0,  ReAdd},
     {"homehost",  1, 0,  HomeHost},
+#if 0
     {"auto-update-homehost", 0, 0, AutoHomeHost},
+#endif
     {"symlinks",  1, 0,  Symlinks},
 
     /* For assemble */
index 275ca21865fd4f98a3cfb8b73327e231d0533d76..c962afdaaed829d0122550166ce0f072d9ccea97 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"
index 3835c995cfa8803ac135a005581ef0a6feb32d73..f9d545d46fbac9142c06f1ea540896a78980e01d 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * mdmon - monitor external metadata arrays
  *
- * Copyright (C) 2007-2008 Neil Brown <neilb@suse.de>
- * Copyright (C) 2007-2008 Intel Corporation
+ * Copyright (C) 2007-2009 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2007-2009 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
diff --git a/md.4 b/md.4
index ea12eaffaf1570f040801ff518c5a62b4b655d12..04b5308c11076374dd2f4f0896cfbce79bb304a5 100644 (file)
--- a/md.4
+++ b/md.4
@@ -11,6 +11,8 @@ md \- Multiple Device driver aka Linux Software RAID
 .BI /dev/md n
 .br
 .BI /dev/md/ n
+.br
+.BR /dev/md/ name
 .SH DESCRIPTION
 The
 .B md
@@ -37,15 +39,17 @@ including RAID0 (striped array), LINEAR (catenated array),
 MULTIPATH (a set of different interfaces to the same device),
 and FAULTY (a layer over a single device into which errors can be injected).
 
-.SS MD SUPER BLOCK
-Each device in an array may have a
-.I superblock
-which records information about the structure and state of the array.
+.SS MD METADATA
+Each device in an array may have some 
+.I metadata
+stored in the device.  This metadata is sometimes called a
+.BR superblock .
+The metadata records information about the structure and state of the array.
 This allows the array to be reliably re-assembled after a shutdown.
 
 From Linux kernel version 2.6.10,
 .B md
-provides support for two different formats of this superblock, and
+provides support for two different formats of metadata, and
 other formats can be added.  Prior to this release, only one format is
 supported.
 
@@ -66,11 +70,11 @@ normally 1K long, but can be longer.  It is normally stored between 8K
 and 12K from the end of the device, on a 4K boundary, though
 variations can be stored at the start of the device (version 1.1) or 4K from
 the start of the device (version 1.2).
-This superblock format stores multibyte data in a
+This metadata format stores multibyte data in a
 processor-independent format and supports up to hundreds of
 component devices (version 0.90 only supports 28).
 
-The superblock contains, among other things:
+The metadata contains, among other things:
 .TP
 LEVEL
 The manner in which the devices are arranged into the array
@@ -80,6 +84,7 @@ UUID
 a 128 bit Universally Unique Identifier that identifies the array that
 contains this device.
 
+.PP
 When a version 0.90 array is being reshaped (e.g. adding extra devices
 to a RAID5), the version number is temporarily set to 0.91.  This
 ensures that if the reshape process is stopped in the middle (e.g. by
@@ -88,7 +93,7 @@ not support reshaping, then the array will not be assembled (which
 would cause data corruption) but will be left untouched until a kernel
 that can complete the reshape processes is used.
 
-.SS ARRAYS WITHOUT SUPERBLOCKS
+.SS ARRAYS WITHOUT METADATA
 While it is usually best to create arrays with superblocks so that
 they can be assembled reliably, there are some circumstances when an
 array without superblocks is preferred.  These include:
@@ -118,6 +123,40 @@ configuration that does not use a superblock, and to maintain the state of
 the array elsewhere.  While not encouraged for general us, it does
 have special-purpose uses and is supported.
 
+.SS ARRAYS WITH EXTERNAL METADATA
+
+From release 2.6.28, the
+.I md
+driver supports arrays with externally managed metadata.  That is,
+the metadata is not managed by the kernel by rather by a user-space
+program which is external to the kernel.  This allows support for a
+variety of metadata formats without cluttering the kernel with lots of
+details.
+.PP
+.I md
+is able to communicate with the user-space program through various
+sysfs attributes so that it can make appropriate changes to the
+metadata \- for example to make a device as faulty.  When necessary,
+.I md
+will wait for the program to acknowledge the event by writing to a
+sysfs attribute.
+The manual page for
+.IR mdmon (8)
+contains more detail about this interaction.
+
+.SS CONTAINERS
+Many metadata formats use a single block of metadata to describe a
+number of different arrays which all use the same set of devices.
+In this case it is helpful for the kernel to know about the full set
+of devices as a whole.  This set is known to md as a
+.IR container .
+A container is an
+.I md
+array with externally managed metadata and with device offset and size
+so that it just covers the metadata part of the devices.  The
+remainder of each device is available to be incorporated into various
+arrays.
+
 .SS LINEAR
 
 A linear array simply catenates the available space on each
@@ -138,12 +177,12 @@ A RAID0 array (which has zero redundancy) is also known as a
 striped array.
 A RAID0 array is configured at creation with a
 .B "Chunk Size" 
-which must be a power of two, and at least 4 kibibytes.
+which must be a power of two (prior to Linux 2.6.31), and at least 4
+kibibytes.
 
 The RAID0 driver assigns the first chunk of the array to the first
 device, the second chunk to the second device, and so on until all
-drives have been assigned one chunk.  This collection of chunks forms
-a
+drives have been assigned one chunk.  This collection of chunks forms a
 .BR stripe .
 Further chunks are gathered into stripes in the same way, and are
 assigned to the remaining space in the drives.
@@ -175,6 +214,11 @@ multiple sequential streams or a random workload will use more than one
 spindle. In theory, having an N-disk RAID1 will allow N sequential
 threads to read from all disks.
 
+Individual devices in a RAID1 can be marked as "write-mostly".
+This drives are excluded from the normal read balancing and will only
+be read from when there is no other option.  This can be useful for
+devices connected over a slow link.
+
 .SS RAID4
 
 A RAID4 array is like a RAID0 array with an extra device for storing
@@ -274,7 +318,11 @@ A MULTIPATH array is composed of a number of logically different
 devices, often fibre channel interfaces, that all refer the the same
 real device. If one of these interfaces fails (e.g. due to cable
 problems), the multipath driver will attempt to redirect requests to
-another interface. 
+another interface.
+
+The MULTIPATH drive is not receiving any ongoing development and
+should be considered a legacy driver.  The device-mapper based
+multipath drivers should be preferred for new installations.
 
 .SS FAULTY
 The FAULTY md module is provided for testing purposes.  A faulty array
@@ -569,6 +617,8 @@ in
 
 .TP
 .B md_mod.start_ro=1
+.TP
+.B /sys/module/md_mod/parameters/start_ro
 This tells md to start all arrays in read-only mode.  This is a soft
 read-only that will automatically switch to read-write on the first
 write request.  However until that write request, nothing is written
@@ -577,6 +627,8 @@ operation is started.
 
 .TP
 .B md_mod.start_dirty_degraded=1
+.TP
+.B /sys/module/md_mod/parameters/start_dirty_degraded
 As mentioned above, md will not normally start a RAID4, RAID5, or
 RAID6 that is both dirty and degraded as this situation can imply
 hidden data loss.  This can be awkward if the root filesystem is
@@ -626,13 +678,13 @@ A readable and writable file that reflects the current "goal" rebuild
 speed for times when non-rebuild activity is current on an array.
 The speed is in Kibibytes per second, and is a per-device rate, not a
 per-array rate (which means that an array with more disks will shuffle
-more data for a given speed).   The default is 100.
+more data for a given speed).   The default is 1000.
 
 .TP
 .B /proc/sys/dev/raid/speed_limit_max
 A readable and writable file that reflects the current "goal" rebuild
 speed for times when no non-rebuild activity is current on an array.
-The default is 100,000.
+The default is 200,000.
 
 .SH SEE ALSO
 .BR mdadm (8),
diff --git a/mdadm.8 b/mdadm.8
index 3b4f47d8264368881c26616436803d892f80196e..2607c8f47fdb70bc92553bb4c5ac2b3a8505d63d 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -17,7 +17,7 @@ Linux Software RAID
 
 .SH DESCRIPTION
 RAID devices are virtual devices created from two or more
-real block devices. This allows multiple devices (typically disk
+real block devices.  This allows multiple devices (typically disk
 drives or partitions thereof) to be combined into a single device to
 hold (for example) a single filesystem.
 Some RAID levels include redundancy and so can survive some degree of
@@ -81,7 +81,7 @@ mdadm has several major modes of operation:
 .TP
 .B Assemble
 Assemble the components of a previously created
-array into an active array. Components can be explicitly given
+array into an active array.  Components can be explicitly given
 or can be searched for.
 .I mdadm
 checks that the components
@@ -90,7 +90,7 @@ information so as to assemble a faulty array.
 
 .TP
 .B Build
-Build an array that doesn't have per-device superblocks.  For these
+Build an array that doesn't have per-device metadata (superblocks).  For these
 sorts of arrays,
 .I mdadm
 cannot differentiate between initial creation and subsequent assembly
@@ -102,15 +102,20 @@ what you are doing.
 
 .TP
 .B Create
-Create a new array with per-device superblocks.
-.\"It can progress
-.\"in several step create-add-add-run or it can all happen with one command.
+Create a new array with per-device metadata (superblocks).
+Appropriate metadata is written to each device, and then the array
+comprising those devices is activated.  A 'resync' process is started
+to make sure that the array is consistent (e.g. both sides of a mirror
+contain the same data) but the content of the device is left otherwise
+untouched.
+The array can be used as soon as it has been created.  There is no
+need to wait for the initial resync to finish.
 
 .TP
 .B "Follow or Monitor"
 Monitor one or more md devices and act on any state changes.  This is
-only meaningful for raid1, 4, 5, 6, 10 or multipath arrays, as
-only these have interesting state.  raid0 or linear never have
+only meaningful for RAID1, 4, 5, 6, 10 or multipath arrays, as
+only these have interesting state.  RAID0 or Linear never have
 missing, spare, or failed drives, so there is nothing to monitor.
 
 .TP
@@ -192,7 +197,8 @@ work if
 is compiled into the kernel \(em not if it is a module.
 Arrays can be auto-detected by the kernel if all the components are in
 primary MS-DOS partitions with partition type
-.BR FD .
+.BR FD ,
+and all use v0.90 metadata.
 In-kernel autodetect is not recommended for new installations.  Using
 .I mdadm
 to detect and assemble arrays \(em possibly in an
@@ -205,7 +211,7 @@ If a device is given before any options, or if the first option is
 .BR \-\-fail ,
 or
 .BR \-\-remove ,
-then the MANAGE mode is assume.
+then the MANAGE mode is assumed.
 Anything other than these will cause the
 .B Misc
 mode to be assumed.
@@ -302,7 +308,7 @@ says to get a list of array devices from
 
 .TP
 .B \-e ", " \-\-metadata=
-Declare the style of superblock (raid metadata) to be used.  The
+Declare the style of RAID metadata (superblock) to be used.  The
 default is 0.90 for
 .BR \-\-create ,
 and to guess for other operations.
@@ -325,8 +331,9 @@ The different sub-versions store the superblock at different locations
 on the device, either at the end (for 1.0), at the start (for 1.1) or
 4K from the start (for 1.2).
 .IP ddf
-Use the "Industry Standard" DDF (Disk Data Format) format.  When
-creating a DDF array a
+Use the "Industry Standard" DDF (Disk Data Format) format defined by
+SNIA.
+When creating a DDF array a
 .B CONTAINER
 will be created, and normal arrays can be created in that container.
 .IP imsm
@@ -348,7 +355,7 @@ should be considered the home for any arrays.
 
 When creating an array, the
 .B homehost
-will be recorded in the superblock.  For version-1 superblocks, it will
+will be recorded in the metadata.  For version-1 superblocks, it will
 be prefixed to the array name.  For version-0.90 superblocks, part of
 the SHA1 hash of the hostname will be stored in the later half of the
 UUID.
@@ -358,7 +365,8 @@ for the given homehost will be reported as such.
 
 When using Auto-Assemble, only arrays tagged for the given homehost
 will be allowed to use 'local' names (i.e. not ending in '_' followed
-by a digit string).
+by a digit string).  See below under
+.BR "Auto Assembly" .
 
 .SH For create, build, or grow:
 
@@ -369,30 +377,29 @@ number of spare devices (see below) must equal the number of
 .I component-devices
 (including "\fBmissing\fP" devices)
 that are listed on the command line for
-.BR  \-\-create .
+.BR \-\-create .
 Setting a value of 1 is probably
 a mistake and so requires that
 .B \-\-force
 be specified first.  A value of 1 will then be allowed for linear,
-multipath, raid0 and raid1.  It is never allowed for raid4 or raid5.
+multipath, RAID0 and RAID1.  It is never allowed for RAID4, RAID5 or RAID6.
 .br
 This number can only be changed using
 .B \-\-grow
-for RAID1, RAID5 and RAID6 arrays, and only on kernels which provide
-necessary support.
+for RAID1, RAID4, RAID5 and RAID6 arrays, and only on kernels which provide
+the necessary support.
 
 .TP
 .BR \-x ", " \-\-spare\-devices=
 Specify the number of spare (eXtra) devices in the initial array.
 Spares can also be added
 and removed later.  The number of component devices listed
-on the command line must equal the number of raid devices plus the
+on the command line must equal the number of RAID devices plus the
 number of spare devices.
 
-
 .TP
 .BR \-z ", " \-\-size=
-Amount (in Kibibytes) of space to use from each drive in RAID level 1/4/5/6.
+Amount (in Kibibytes) of space to use from each drive in RAID levels 1/4/5/6.
 This must be a multiple of the chunk size, and must leave about 128Kb
 of space at the end of the drive for the RAID superblock.
 If this is not specified
@@ -402,7 +409,7 @@ issued.
 
 This value can be set with
 .B \-\-grow
-for RAID level 1/4/5/6. If the array was created with a size smaller
+for RAID level 1/4/5/6.  If the array was created with a size smaller
 than the currently active drives, the extra space can be accessed
 using
 .BR \-\-grow .
@@ -417,14 +424,20 @@ metadata such as DDF and IMSM.
 .TP
 .BR \-c ", " \-\-chunk=
 Specify chunk size of kibibytes.  The default is 64.
+This is only meaningful for RAID0, RAID4, RAID5, RAID6, and RAID10.
 
 .TP
 .BR \-\-rounding=
-Specify rounding factor for linear array (==chunk size)
+Specify rounding factor for a Linear array.  The size of each
+component will be rounded down to a multiple of this size.
+This is a synonym for
+.B \-\-chunk
+but highlights the different meaning for Linear as compared to other
+RAID levels.
 
 .TP
 .BR \-l ", " \-\-level=
-Set raid level.  When used with
+Set RAID level.  When used with
 .BR \-\-create ,
 options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4,
 raid5, 5, raid6, 6, raid10, 10, multipath, mp, faulty, container.
@@ -445,11 +458,11 @@ Not yet supported with
 
 .TP
 .BR \-p ", " \-\-layout=
-This option configures the fine details of data layout for raid5,
-and raid10 arrays, and controls the failure modes for
+This option configures the fine details of data layout for RAID5, RAID6,
+and RAID10 arrays, and controls the failure modes for
 .IR faulty .
 
-The layout of the raid5 parity block can be one of
+The layout of the RAID5 parity block can be one of
 .BR left\-asymmetric ,
 .BR left\-symmetric ,
 .BR right\-asymmetric ,
@@ -458,6 +471,31 @@ The layout of the raid5 parity block can be one of
 The default is
 .BR left\-symmetric .
 
+It is also possibly to cause RAID5 to use a RAID4-like layout by
+choosing
+.BR parity\-first ,
+or
+.BR parity\-last .
+
+Finally for RAID5 there are DDF\-compatible layouts,
+.BR ddf\-zero\-restart ,
+.BR ddf\-N\-restart ,
+and
+.BR ddf\-N\-continue .
+
+These same layouts are available for RAID6.  There are also 4 layouts
+that will provide an intermediate stage for converting between RAID5
+and RAID6.  These provide a layout which is identical to the
+corresponding RAID5 layout on the first N\-1 devices, and has the 'Q'
+syndrome (the second 'parity' block used by RAID6) on the last device.
+These layouts are:
+.BR left\-symmetric\-6 ,
+.BR right\-symmetric\-6 ,
+.BR left\-asymmetric\-6 ,
+.BR right\-asymmetric\-6 ,
+and
+.BR pairty\-first\-6 .
+
 When setting the failure mode for level
 .I faulty,
 the options are:
@@ -491,7 +529,7 @@ Finally, the layout options for RAID10 are one of 'n', 'o' or 'f' followed
 by a small number.  The default is 'n2'.  The supported options are:
 
 .I 'n'
-signals 'near' copies. Multiple copies of one data block are at
+signals 'near' copies.  Multiple copies of one data block are at
 similar offsets in different devices.
 
 .I 'o'
@@ -504,7 +542,7 @@ down.
 .I 'f'
 signals 'far' copies
 (multiple copies have very different offsets).
-See md(4) for more detail about 'near' and 'far'.
+See md(4) for more detail about 'near', 'offset', and 'far'.
 
 The number is the number of copies of each datablock.  2 is normal, 3
 can be useful.  This number can be at most equal to the number of
@@ -542,7 +580,7 @@ Storing bitmap files on other filesystems may result in serious problems.
 
 .TP
 .BR \-\-bitmap\-chunk=
-Set the chunksize of the bitmap. Each bit corresponds to that many
+Set the chunksize of the bitmap.  Each bit corresponds to that many
 Kilobytes of storage.
 When using a file based bitmap, the default is to use the smallest
 size that is at-least 4 and requires no more than 2^21 chunks.
@@ -551,10 +589,9 @@ When using an
 bitmap, the chunksize is automatically determined to make best use of
 available space.
 
-
 .TP
 .BR \-W ", " \-\-write\-mostly
-subsequent devices lists in a
+subsequent devices listed in a
 .BR \-\-build ,
 .BR \-\-create ,
 or
@@ -567,8 +604,8 @@ slow link.
 .TP
 .BR \-\-write\-behind=
 Specify that write-behind mode should be enabled (valid for RAID1
-only). If an argument is specified, it will set the maximum number
-of outstanding writes allowed. The default value is 256.
+only).  If an argument is specified, it will set the maximum number
+of outstanding writes allowed.  The default value is 256.
 A write-intent bitmap is required in order to use write-behind
 mode, and write-behind is only attempted on drives marked as
 .IR write-mostly .
@@ -582,24 +619,33 @@ when trying to recover from a major failure as you can be sure that no
 data will be affected unless you actually write to the array.  It can
 also be used when creating a RAID1 or RAID10 if you want to avoid the
 initial resync, however this practice \(em while normally safe \(em is not
-recommended.   Use this only if you really know what you are doing.
+recommended.  Use this only if you really know what you are doing.
 
 .TP
 .BR \-\-backup\-file=
 This is needed when
 .B \-\-grow
 is used to increase the number of
-raid-devices in a RAID5 if there  are no spare devices available.
-See the section below on RAID_DEVICE CHANGES.  The file should be
-stored on a separate device, not on the raid array being reshaped.
+raid-devices in a RAID5 if there are no spare devices available.
+See the GROW MODE section below on RAID\-DEVICES CHANGES.  The file
+should be stored on a separate device, not on the RAID array being
+reshaped.
 
 .TP
 .BR \-N ", " \-\-name=
 Set a
 .B name
 for the array.  This is currently only effective when creating an
-array with a version-1 superblock.  The name is a simple textual
-string that can be used to identify array components when assembling.
+array with a version-1 superblock, or an array in a DDF container.
+The name is a simple textual string that can be used to identify array
+components when assembling.  If name is needed but not specified, it
+is taken from the basename of the device that is being created.
+e.g. when creating
+.I /dev/md/home
+the
+.B name
+will default to
+.IR home .
 
 .TP
 .BR \-R ", " \-\-run
@@ -618,7 +664,7 @@ Insist that
 accept the geometry and layout specified without question.  Normally
 .I mdadm
 will not allow creation of an array with only one device, and will try
-to create a raid5 array with one missing drive (as this makes the
+to create a RAID5 array with one missing drive (as this makes the
 initial resync work faster).  With
 .BR \-\-force ,
 .I mdadm
@@ -661,46 +707,48 @@ partitions.  A different number of partitions can be specified at the
 end of this option (e.g.
 .BR \-\-auto=p7 ).
 If the device name ends with a digit, the partition names add a 'p',
-and a number, e.g. "/dev/md/home1p3".  If there is no
-trailing digit, then the partition names just have a number added,
-e.g. "/dev/md/scratch3".
+and a number, e.g.
+.IR /dev/md/home1p3 .
+If there is no trailing digit, then the partition names just have a
+number added, e.g.
+.IR /dev/md/scratch3 .
 
 If the md device name is in a 'standard' format as described in DEVICE
 NAMES, then it will be created, if necessary, with the appropriate
-number based on that name.  If the device name is not in one of these
-formats, then a unused minor number will be allocated.  The minor
+device number based on that name.  If the device name is not in one of these
+formats, then a unused device number will be allocated.  The device
 number will be considered unused if there is no active array for that
 number, and there is no entry in /dev for that number and with a
-non-standard name.  Name that are not in 'standard' format are only
+non-standard name.  Names that are not in 'standard' format are only
 allowed in "/dev/md/".
 
-\".TP
-\".BR \-\-symlink = no
-\"Normally when
-\".B \-\-auto
-\"causes
-\".I mdadm
-\"to create devices in
-\".B /dev/md/
-\"it will also create symlinks from
-\".B /dev/
-\"with names starting with
-\".B md
-\"or
-\".BR md_ .
-\"Use
-\".B \-\-symlink=no
-\"to suppress this, or
-\".B \-\-symlink=yes
-\"to enforce this even if it is suppressing
-\".IR mdadm.conf .
-\"
+.\".TP
+.\".BR \-\-symlink = no
+.\"Normally when
+.\".B \-\-auto
+.\"causes
+.\".I mdadm
+.\"to create devices in
+.\".B /dev/md/
+.\"it will also create symlinks from
+.\".B /dev/
+.\"with names starting with
+.\".B md
+.\"or
+.\".BR md_ .
+.\"Use
+.\".B \-\-symlink=no
+.\"to suppress this, or
+.\".B \-\-symlink=yes
+.\"to enforce this even if it is suppressing
+.\".IR mdadm.conf .
+.\"
 
 .SH For assemble:
 
 .TP
 .BR \-u ", " \-\-uuid=
-uuid of array to assemble. Devices which don't have this uuid are
+uuid of array to assemble.  Devices which don't have this uuid are
 excluded
 
 .TP
@@ -720,6 +768,12 @@ e.g. when assembling
 .B \-\-super\-minor=dev
 will look for super blocks with a minor number of 0.
 
+.B \-\-super\-minor
+is only relevant for v0.90 metadata, and should not normally be used.
+Using
+.B \-\-uuid
+is much safer.
+
 .TP
 .BR \-N ", " \-\-name=
 Specify the name of the array to assemble.  This must be the name
@@ -731,7 +785,15 @@ prefixed to the start of the given name.
 
 .TP
 .BR \-f ", " \-\-force
-Assemble the array even if some superblocks appear out-of-date
+Assemble the array even if the metadata on some devices appears to be
+out-of-date.  If
+.I mdadm
+cannot find enough working devices to start the array, but can find
+some devices that are recorded as having failed, then it will mark
+those devices as working so that the array can be started.
+An array which requires
+.B \-\-force
+to be started may contain data corruption.  Use it carefully.
 
 .TP
 .BR \-R ", " \-\-run
@@ -812,7 +874,7 @@ This can be useful if
 reports a different "Preferred Minor" to
 .BR \-\-detail .
 In some cases this update will be performed automatically
-by the kernel driver. In particular the update happens automatically
+by the kernel driver.  In particular the update happens automatically
 at the first write to an array with redundancy (RAID level 1 or
 greater) on a 2.6 (or later) kernel.
 
@@ -846,8 +908,8 @@ The
 .B resync
 option will cause the array to be marked
 .I dirty
-meaning that any redundancy in the array (e.g. parity for raid5,
-copies for raid1) may be incorrect.  This will cause the raid system
+meaning that any redundancy in the array (e.g. parity for RAID5,
+copies for RAID1) may be incorrect.  This will cause the RAID system
 to perform a "resync" pass to make sure that all redundant information
 is correct.
 
@@ -865,7 +927,7 @@ with original (Version 0.90) superblocks.
 
 The
 .B summaries
-option will correct the summaries in the superblock. That is the
+option will correct the summaries in the superblock.  That is the
 counts of total, working, active, failed, and spare devices.
 
 The
@@ -884,6 +946,7 @@ This will cause
 to determine the maximum usable amount of space on each device and
 update the relevant field in the metadata.
 
+.ig XX
 .TP
 .B \-\-auto\-update\-homehost
 This flag is only meaningful with auto-assembly (see discussion below).
@@ -891,16 +954,27 @@ In that situation, if no suitable arrays are found for this homehost,
 .I mdadm
 will rescan for any arrays at all and will assemble them and update the
 homehost to match the current host.
+.XX
 
 .SH For Manage mode:
 
 .TP
 .BR \-a ", " \-\-add
-hot-add listed devices.
+hot-add listed devices.  For arrays with redundancy, the listed
+devices become available as spares.  If the array is degraded, it will
+immediately start recovering data on to one of these spares.
 
 .TP
 .BR \-\-re\-add
-re-add a device that was recently removed from an array.
+re-add a device that was recently removed from an array.  This is only
+needed for arrays that have be built (i.e. with
+.BR --build ).
+For created arrays, devices are always re-added if that is possible.
+When re-adding a device, if nothing has changed on the array since the
+device was removed, no recovery is performed.  Also, if the array has
+a write-intent bitmap, then the recovery performed after a re-add will
+be limited to those blocks which, according to the bitmap, might have
+changed since the device was removed.
 
 .TP
 .BR \-r ", " \-\-remove
@@ -937,18 +1011,17 @@ same as
 .TP
 .BR \-\-write\-mostly
 Subsequent devices that are added or re-added will have the 'write-mostly'
-flag set.  This is only valid for RAID! and means that the 'md' driver
+flag set.  This is only valid for RAID1 and means that the 'md' driver
 will avoid reading from these devices if possible.
 .TP
 .BR \-\-readwrite
 Subsequent devices that are added or re-added will have the 'write-mostly'
 flag cleared.
 
-
 .P
-Each of these options require that the first device listed is the array
+Each of these options requires that the first device listed is the array
 to be acted upon, and the remainder are component devices to be added,
-removed, or marked as faulty.  Several different operations can be
+removed, marked as faulty, etc.  Several different operations can be
 specified for different devices, e.g.
 .in +5
 mdadm /dev/md0 \-\-add /dev/sda1 \-\-fail /dev/sdb1 \-\-remove /dev/sdb1
@@ -981,11 +1054,11 @@ Information about what is discovered is presented.
 
 .TP
 .BR \-D ", " \-\-detail
-Print detail of one or more md devices.
+Print details of one or more md devices.
 
 .TP
 .BR \-\-detail\-platform
-Print detail of the platform's raid capabilities (firmware / hardware
+Print details of the platform's RAID capabilities (firmware / hardware
 topology) for a given metadata format.
 
 .TP
@@ -1000,12 +1073,21 @@ pairs for easy import into the environment.
 
 .TP
 .BR \-E ", " \-\-examine
-Print content of md superblock on device(s).
+Print contents of the metadata stored on the named device(s).
+Note the contrast between
+.B \-\-examine
+and
+.BR \-\-detail .
+.B \-\-examine
+applies to devices which are components of an array, while
+.B \-\-detail
+applies to a whole array which is currently active.
 .TP
 .B \-\-sparc2.2
-If an array was created on a 2.2 Linux kernel patched with RAID
-support, the superblock will have been created incorrectly, or at
-least incompatibly with 2.4 and later kernels.  Using the
+If an array was created on a SPARC machine with a 2.2 Linux kernel
+patched with RAID support, the superblock will have been created
+incorrectly, or at least incompatibly with 2.4 and later kernels.
+Using the
 .B \-\-sparc2.2
 flag with
 .B \-\-examine
@@ -1017,11 +1099,19 @@ the right thing, then the array can be successfully assembled using
 .BR \-X ", " \-\-examine\-bitmap
 Report information about a bitmap file.
 The argument is either an external bitmap file or an array component
-in case of an internal bitmap.
+in case of an internal bitmap.  Note that running this on an array
+device (e.g.
+.BR /dev/md0 )
+does not report the bitmap for that array.
 
 .TP
 .BR \-R ", " \-\-run
-start a partially built array.
+start a partially assembled array.  If
+.B \-\-assemble
+did not find enough devices to fully start the array, it might leaving
+it partially assembled.  If you wish, you can then use
+.B \-\-run
+to start the array in degraded mode.
 
 .TP
 .BR \-S ", " \-\-stop
@@ -1049,7 +1139,9 @@ When used with
 .BR \-\-detail ,
 the exit status of
 .I mdadm
-is set to reflect the status of the device.
+is set to reflect the status of the device.  See below in
+.B MISC MODE
+for details.
 
 .TP
 .BR \-W ", " \-\-wait
@@ -1123,14 +1215,17 @@ facility of 'daemon' and varying priorities.
 Give a delay in seconds.
 .I mdadm
 polls the md arrays and then waits this many seconds before polling
-again.  The default is 60 seconds.
+again.  The default is 60 seconds.  Since 2.6.16, there is no need to
+reduce this as the kernel alerts
+.I mdadm
+immediately when there is any change.
 
 .TP
 .BR \-f ", " \-\-daemonise
 Tell
 .I mdadm
 to run as a background daemon if it decides to monitor anything.  This
-causes it to fork and run in the child, and to disconnect form the
+causes it to fork and run in the child, and to disconnect from the
 terminal.  The process id of the child is written to stdout.
 This is useful with
 .B \-\-scan
@@ -1175,16 +1270,16 @@ Usage:
 .HP 12
 Usage:
 .B mdadm \-\-assemble \-\-scan
-.I  md-devices-and-options...
+.I md-devices-and-options...
 .HP 12
 Usage:
 .B mdadm \-\-assemble \-\-scan
-.I  options...
+.I options...
 
 .PP
-This usage assembles one or more raid arrays from pre-existing components.
+This usage assembles one or more RAID arrays from pre-existing components.
 For each array, mdadm needs to know the md device, the identity of the
-array, and a number of component-devices. These can be found in a number of ways.
+array, and a number of component-devices.  These can be found in a number of ways.
 
 In the first usage example (without the
 .BR \-\-scan )
@@ -1192,8 +1287,9 @@ the first device given is the md device.
 In the second usage example, all devices listed are treated as md
 devices and assembly is attempted.
 In the third (where no devices are listed) all md devices that are
-listed in the configuration file are assembled.  Then any arrays that
-can be found on unused devices will also be assembled.
+listed in the configuration file are assembled.  If not arrays are
+described by the configuration file, then any arrays that
+can be found on unused devices will be assembled.
 
 If precisely one device is listed, but
 .B \-\-scan
@@ -1205,7 +1301,9 @@ was given and identity information is extracted from the configuration file.
 
 The identity can be given with the
 .B \-\-uuid
-option, with the
+option, the
+.B \-\-name
+option, or the
 .B \-\-super\-minor
 option, will be taken from the md-device record in the config file, or
 will be taken from the super block of the first component-device
@@ -1213,7 +1311,7 @@ listed on the command line.
 
 Devices can be given on the
 .B \-\-assemble
-command line or in the config file. Only devices which have an md
+command line or in the config file.  Only devices which have an md
 superblock which contains the right identity will be considered for
 any array.
 
@@ -1234,50 +1332,59 @@ identity of md arrays.
 
 Normally the array will be started after it is assembled.  However if
 .B \-\-scan
-is not given and insufficient drives were listed to start a complete
-(non-degraded) array, then the array is not started (to guard against
-usage errors).  To insist that the array be started in this case (as
-may work for RAID1, 4, 5, 6, or 10), give the
+is not given and not all expected drives were listed, then the array
+is not started (to guard against usage errors).  To insist that the
+array be started in this case (as may work for RAID1, 4, 5, 6, or 10),
+give the
 .B \-\-run
 flag.
 
-If the md device does not exist, then it will be created providing the
-intent is clear. i.e. the name must be in a standard form, or the
-.B \-\-auto
-option must be given to clarify how and whether the device should be
-created.
-This can be useful for handling partitioned devices (which don't have
-a stable device number \(em it can change after a reboot) and when using
-"udev" to manage your
+If
+.I udev
+is active,
+.I mdadm
+does not create any entries in
 .B /dev
-tree (udev cannot handle md devices because of the unusual device
-initialisation conventions).
+but leaves that to
+.IR udev .
+It does record information in
+.B /var/run/mdadm/map
+which will allow
+.I udev
+to choose the correct name.
 
-If the option to "auto" is "mdp" or "part" or (on the command line
-only) "p", then mdadm will create a partitionable array, using the
-first free one that is not in use and does not already have an entry
-in /dev (apart from numeric /dev/md* entries).
+If
+.I mdadm
+detects that udev is not configured, it will create the devices in
+.B /dev
+itself.
 
-If the option to "auto" is "yes" or "md" or (on the command line)
-nothing, then mdadm will create a traditional, non-partitionable md
-array.
+In Linux kernels prior to version 2.6.28 there were two distinctly
+different types of md devices that could be created: one that could be
+partitioned using standard partitioning tools and one that could not.
+Since 2.6.28 that distinction is no longer relevant as both type of
+devices can be partitioned.
+.I mdadm
+will normally create the type that originally could not be partitioned
+as it has a well defined major number (9).
 
-It is expected that the "auto" functionality will be used to create
-device entries with meaningful names such as "/dev/md/home" or
-"/dev/md/root", rather than names based on the numerical array number.
+Prior to 2.6.28, it is important that mdadm chooses the correct type
+of array device to use.  This can be controlled with the
+.B \-\-auto
+option.  In particular, a value of "mdp" or "part" or "p" tells mdadm
+to use a partitionable device rather than the default.
 
-When using option "auto" to create a partitionable array, the device
-files for the first 4 partitions are also created. If a different
-number is required it can be simply appended to the auto option.
-e.g. "auto=part8".  Partition names are created by appending a digit
-string to the device name, with an intervening "p" if the device name
-ends with a digit.
+In the no-udev case, the value given to
+.B \-\-auto
+can be suffixed by a number.  This tells
+.I mdadm
+to create that number of partition devices rather than the default of 4.
 
-The
+The value given to
 .B \-\-auto
-option is also available in Build and Create modes.  As those modes do
-not use a config file, the "auto=" config option does not apply to
-these modes.
+can also be given in the configuration file as a word starting
+.B auto=
+on the ARRAY line for the relevant array.
 
 .SS Auto Assembly
 When
@@ -1289,13 +1396,15 @@ and no devices are listed,
 will first attempt to assemble all the arrays listed in the config
 file.
 
-It will then look further for possible arrays and will try to assemble
-anything that it finds. Arrays which are tagged as belonging to the given
-homehost will be assembled and started normally.  Arrays which do not
-obviously belong to this host are given names that are expected not to
-conflict with anything local, and are started "read-auto" so that
-nothing is written to any device until the array is written to. i.e.
-automatic resync etc is delayed.
+In no array at listed in the config (other than those marked
+.BR <ignore> )
+it will look through the available devices for possible arrays and
+will try to assemble anything that it finds.  Arrays which are tagged
+as belonging to the given homehost will be assembled and started
+normally.  Arrays which do not obviously belong to this host are given
+names that are expected not to conflict with anything local, and are
+started "read-auto" so that nothing is written to any device until the
+array is written to. i.e.  automatic resync etc is delayed.
 
 If
 .I mdadm
@@ -1311,9 +1420,10 @@ so for example
 If the array uses version-1 metadata, then the
 .B name
 from the superblock is used to similarly create a name in
-.BR /dev/md
+.B /dev/md/
 (the name will have any 'host' prefix stripped first).
 
+.ig XX
 If
 .I mdadm
 cannot find any array for the given host at all, and if
@@ -1331,6 +1441,7 @@ homehost tagging.
 The reason for requiring arrays to be tagged with the homehost for
 auto assembly is to guard against problems that can arise when moving
 devices from one host to another.
+.XX
 
 .SH BUILD MODE
 
@@ -1346,14 +1457,16 @@ Usage:
 .PP
 This usage is similar to
 .BR \-\-create .
-The difference is that it creates an array without a superblock. With
+The difference is that it creates an array without a superblock.  With
 these arrays there is no difference between initially creating the array and
 subsequently assembling the array, except that hopefully there is useful
 data there in the second case.
 
-The level may raid0, linear, multipath, or faulty, or one of their
-synonyms. All devices must be listed and the array will be started
-once complete.
+The level may raid0, linear, raid1, raid10, multipath, or faulty, or
+one of their synonyms.  All devices must be listed and the array will
+be started once complete.  It will often be appropriate to use
+.B \-\-assume\-clean
+with levels raid1 or raid10.
 
 .SH CREATE MODE
 
@@ -1365,20 +1478,20 @@ Usage:
 .BI \-\-level= Y
 .br
 .BI \-\-raid\-devices= Z
-.I  devices
+.I devices
 
 .PP
 This usage will initialise a new md array, associate some devices with
 it, and activate the array.
 
-If the
-.B \-\-auto
-option is given (as described in more detail in the section on
-Assemble mode), then the md device will be created with a suitable
-device number if necessary.
+The named device will normally not exist when
+.I "mdadm \-\-create"
+is run, but will be created by
+.I udev
+once the array becomes active.
 
-As devices are added, they are checked to see if they contain raid
-superblocks or filesystems. They are also checked to see if the variance in
+As devices are added, they are checked to see if they contain RAID
+superblocks or filesystems.  They are also checked to see if the variance in
 device size exceeds 1%.
 
 If any discrepancy is found, the array will not automatically be run, though
@@ -1400,9 +1513,9 @@ others can be
 When creating a RAID5 array,
 .I mdadm
 will automatically create a degraded array with an extra spare drive.
-This is because building the spare into a degraded array is in general faster than resyncing
-the parity on a non-degraded, but not clean, array.  This feature can
-be overridden with the
+This is because building the spare into a degraded array is in general
+faster than resyncing the parity on a non-degraded, but not clean,
+array.  This feature can be overridden with the
 .B \-\-force
 option.
 
@@ -1424,11 +1537,11 @@ is being created, then the name
 .B home
 will be used.
 
-When creating a partition based array, using 
-.I mdadm 
-with version-1.x metadata, the partition type should be set to 
+When creating a partition based array, using
+.I mdadm
+with version-1.x metadata, the partition type should be set to
 .B 0xDA
-(non fs-data). This type selection allows for greater precision since
+(non fs-data).  This type selection allows for greater precision since
 using any other [RAID auto-detect (0xFD) or a GNU/Linux partition (0x83)],
 might create problems in the event of array recovery through a live cdrom.
 
@@ -1473,7 +1586,6 @@ be in use.
 .B \-\-readonly
 start the array readonly \(em not supported yet.
 
-
 .SH MANAGE MODE
 .HP 12
 Usage:
@@ -1484,7 +1596,7 @@ Usage:
 
 This usage will allow individual devices in an array to be failed,
 removed or added.  It is possible to perform multiple operations with
-on command. For example:
+on command.  For example:
 .br
 .B "  mdadm /dev/md0 \-f /dev/hda1 \-r /dev/hda1 \-a /dev/hda1"
 .br
@@ -1496,12 +1608,20 @@ and will then remove it from the array and finally add it back
 in as a spare.  However only one md array can be affected by a single
 command.
 
+When a device is added to an active array, mdadm checks to see if it
+has metadata on it which suggests that it was recently a member of the
+array.  If it does, it tried to "re-add" the device.  If there have
+been no changes since the device was removed, or if the array has a
+write-intent bitmap which has recorded whatever changes there were,
+then the device will immediately become a full member of the array and
+those differences recorded in the bitmap will be resolved.
+
 .SH MISC MODE
 .HP 12
 Usage:
 .B mdadm
 .I options ...
-.I devices  ...
+.I devices ...
 .PP
 
 MISC mode includes a number of distinct operations that
@@ -1516,7 +1636,7 @@ The information discovered is reported.
 .TP
 .B \-\-detail
 The device should be an active md device.
-.B   mdadm
+.B mdadm
 will display a detailed description of the array.
 .B \-\-brief
 or
@@ -1548,7 +1668,7 @@ There was an error while trying to get information about the device.
 
 .TP
 .B \-\-detail\-platform
-Print detail of the platform's raid capabilities (firmware / hardware
+Print detail of the platform's RAID capabilities (firmware / hardware
 topology).  If the metadata is specified with
 .B \-e
 or
@@ -1617,7 +1737,6 @@ For
 .B \-\-scan
 causes all devices listed in the config file to be examined.
 
-
 .SH MONITOR MODE
 
 .HP 12
@@ -1643,7 +1762,7 @@ and if the destination array has a failed drive but no spares.
 
 If any devices are listed on the command line,
 .I mdadm
-will only monitor those devices. Otherwise all arrays listed in the
+will only monitor those devices.  Otherwise all arrays listed in the
 configuration file will be monitored.  Further, if
 .B \-\-scan
 is given, then any other md devices that appear in
@@ -1727,7 +1846,7 @@ device has been successfully rebuilt and has been made active.
 .B NewArray
 A new md array has been detected in the
 .B /proc/mdstat
-file.   (syslog priority: Info)
+file.  (syslog priority: Info)
 
 .TP
 .B DegradedArray
@@ -1816,7 +1935,7 @@ The GROW mode is used for changing the size or shape of an active
 array.
 For this to work, the kernel must support the necessary change.
 Various types of growth are being added during 2.6 development,
-including restructuring a raid5 array to have more active devices.
+including restructuring a RAID5 array to have more active devices.
 
 Currently the only support available is to
 .IP \(bu 4
@@ -1847,7 +1966,11 @@ Note that when an array changes size, any filesystem that may be
 stored in the array will not automatically grow to use the space.  The
 filesystem will need to be explicitly told to use the extra space.
 
-.SS RAID-DEVICES CHANGES
+Also the size of an array cannot be changed while it has an active
+bitmap.  If an array has a bitmap, it must be removed before the size
+can be changed. Once the change it complete a new bitmap can be created.
+
+.SS RAID\-DEVICES CHANGES
 
 A RAID1 array can work with any number of devices from 1 upwards
 (though 1 is not very useful).  There may be times which you want to
@@ -1865,9 +1988,9 @@ present will be activated immediately.
 Increasing the number of active devices in a RAID5 is much more
 effort.  Every block in the array will need to be read and written
 back to a new location.  From 2.6.17, the Linux Kernel is able to do
-this safely, including restart and interrupted "reshape".
+this safely, including restarting an interrupted "reshape".
 
-When relocating the first few stripes on a raid5, it is not possible
+When relocating the first few stripes on a RAID5, it is not possible
 to keep the data on disk completely consistent and crash-proof.  To
 provide the required safety, mdadm disables writes to the array while
 this "critical section" is reshaped, and takes a backup of the data
@@ -1885,7 +2008,7 @@ to restore the backup and reassemble the array.
 A write-intent bitmap can be added to, or removed from, an active
 array.  Either internal bitmaps, or bitmaps stored in a separate file,
 can be added.  Note that if you add a bitmap stored in a file which is
-in a filesystem that is on the raid array being affected, the system
+in a filesystem that is on the RAID array being affected, the system
 will deadlock.  The bitmap must be on a separate filesystem.
 
 .SH INCREMENTAL MODE
@@ -1903,7 +2026,6 @@ Usage:
 Usage:
 .B mdadm \-\-incremental \-\-run \-\-scan
 
-
 .PP
 This mode is designed to be used in conjunction with a device
 discovery system.  As devices are found in a system, they can be
@@ -1963,6 +2085,7 @@ finds any known version of metadata.  If no
 .I md
 metadata is found, the device is rejected.
 
+.ig XX
 .IP +
 Does the metadata match an expected array?
 The metadata can match in two ways.  Either there is an array listed
@@ -1980,14 +2103,16 @@ If
 .I mdadm
 is not able to positively identify the array as belonging to the
 current host, the device will be rejected.
+.XX
 
-.IP +
 .I mdadm
 keeps a list of arrays that it has partially assembled in
 .B /var/run/mdadm/map
 (or
 .B /var/run/mdadm.map
-if the directory doesn't exist).  If no array exists which matches
+if the directory doesn't exist.  Or maybe even
+.BR /dev/.mdadm.map ).
+If no array exists which matches
 the metadata on the new device,
 .I mdadm
 must choose a device name and unit number.  It does this based on any
@@ -2004,7 +2129,13 @@ line in
 suggests that a non-partitionable array is preferred, that will be
 honoured.
 
-.IP +
+If the array is not found in the config file and its metadata does not
+identify it as belonging to the "homehost", then
+.I mdadm
+will choose a name for the array which is certain not to conflict with
+any array which does belong to this host.  It does this be adding an
+underscore and a small number to the name preferred by the metadata.
+
 Once an appropriate array is found or created and the device is added,
 .I mdadm
 must decide if the array is ready to be started.  It will
@@ -2018,8 +2149,8 @@ As an alternative,
 may be passed to
 .I mdadm
 in which case the array will be run as soon as there are enough
-devices present for the data to be accessible.  For a raid1, that
-means one device will start the array.  For a clean raid5, the array
+devices present for the data to be accessible.  For a RAID1, that
+means one device will start the array.  For a clean RAID5, the array
 will be started as soon as all but one drive is present.
 
 Note that neither of these approaches is really ideal.  If it can
@@ -2034,7 +2165,6 @@ that no metadata updates are made and no attempt at resync or recovery
 happens.  Further devices that are found before the first write can
 still be added safely.
 
-
 .SH ENVIRONMENT
 This section describes environment variables that affect how mdadm
 operates.
@@ -2061,7 +2191,7 @@ will create and devices that are needed.
 
 .B "  mdadm \-\-query /dev/name-of-device"
 .br
-This will find out if a given device is a raid array, or is part of
+This will find out if a given device is a RAID array, or is part of
 one, and will provide brief information about the device.
 
 .B "  mdadm \-\-assemble \-\-scan"
@@ -2153,7 +2283,7 @@ Create a DDF array over 6 devices.
 
 .B "  mdadm --create /dev/md/home -n3 -l5 -z 30000000 /dev/md/ddf"
 .br
-Create a raid5 array over any 3 devices in the given DDF set.  Use
+Create a RAID5 array over any 3 devices in the given DDF set.  Use
 only 30 gigabytes of each device.
 
 .B "  mdadm -A /dev/md/ddf1 /dev/sd[a-f]"
@@ -2177,7 +2307,6 @@ Provide help about the format of the config file.
 .br
 Provide general help.
 
-
 .SH FILES
 
 .SS /proc/mdstat
@@ -2193,7 +2322,6 @@ uses this to find arrays when
 is given in Misc mode, and to monitor array reconstruction
 on Monitor mode.
 
-
 .SS /etc/mdadm.conf
 
 The config file lists which devices may be scanned to see if
@@ -2210,7 +2338,13 @@ If
 .B /var/run/mdadm
 does not exist as a directory, then
 .B /var/run/mdadm.map
-is used instead.
+is used instead.  If
+.B /var/run
+is not available (as may be the case during early boot),
+.B /dev/.mdadm.map
+is used on the basis that
+.B /dev
+is usually available very early in boot.
 
 .SH DEVICE NAMES
 
@@ -2235,13 +2369,18 @@ can be given.
 
 When
 .I mdadm
-chooses device names during auto-assembly, it will normally add a
-small sequence number to the end of the name to avoid conflicted
-between multiple arrays that have the same name.  If
+chooses device names during auto-assembly or incremental assembly, it
+will sometimes add a small sequence number to the end of the name to
+avoid conflicted between multiple arrays that have the same name.  If
 .I mdadm
 can reasonably determine that the array really is meant for this host,
 either by a hostname in the metadata, or by the presence of the array
-in /etc/mdadm.conf, then it will leave of the suffix if possible.
+in /etc/mdadm.conf, then it will leave off the suffix if possible.
+Also if the homehost is specified as
+.B <ignore>
+.I mdadm
+will only use a suffix if a different array of the same name already
+exists or is listed in the config file.
 
 The standard names for non-partitioned arrays (the only sort of md
 array available in 2.4 and earlier) are of the form
@@ -2283,7 +2422,7 @@ RAID, see:
 .\"for new releases of the RAID driver check out:
 .\"
 .\".IP
-.\".UR  ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
+.\".UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
 .\"ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
 .\".UE
 .\".PP
@@ -2301,6 +2440,7 @@ should always be available from
 .PP
 Related man pages:
 .PP
+.IR mdmon (8),
 .IR mdadm.conf (5),
 .IR md (4).
 .PP
diff --git a/mdadm.c b/mdadm.c
index 99a177186bb60fd336ea2a4a10801eafce2fa7fd..bb3e5bb1821827d246ef88f542b2e873cd3c91b4 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  *
  *    Additions for bitmap and write-behind RAID options, Copyright (C) 2003-2004,
  *    Paul Clements, SteelEye Technology, Inc.
@@ -343,9 +338,11 @@ int main(int argc, char *argv[])
                        }
                        continue;
 
+#if 0
                case O(ASSEMBLE,AutoHomeHost):
                        auto_update_home = 1;
                        continue;
+#endif
                case O(INCREMENTAL, 'e'):
                case O(CREATE,'e'):
                case O(ASSEMBLE,'e'):
@@ -411,7 +408,10 @@ int main(int argc, char *argv[])
                                        optarg);
                                exit(2);
                        }
-                       if (level != 0 && level != -1 && level != 1 && level != -4 && level != -5 && mode == BUILD) {
+                       if (level != 0 && level != LEVEL_LINEAR && level != 1 &&
+                           level != LEVEL_MULTIPATH && level != LEVEL_FAULTY &&
+                           level != 10 &&
+                           mode == BUILD) {
                                fprintf(stderr, Name ": Raid level %s not permitted with --build.\n",
                                        optarg);
                                exit(2);
@@ -1150,6 +1150,7 @@ int main(int argc, char *argv[])
                                        } while (rv2!=2);
                                        /* Incase there are stacked devices, we need to go around again */
                                } while (acnt);
+#if 0
                                if (cnt == 0 && auto_update_home && homehost) {
                                        /* Nothing found, maybe we need to bootstrap homehost info */
                                        do {
@@ -1169,6 +1170,7 @@ int main(int argc, char *argv[])
                                                /* Incase there are stacked devices, we need to go around again */
                                        } while (acnt);
                                }
+#endif
                                if (cnt == 0 && rv == 0) {
                                        fprintf(stderr, Name ": No arrays found in config file or automatically\n");
                                        rv = 1;
@@ -1366,6 +1368,13 @@ int main(int argc, char *argv[])
                        rv = 1;
                        break;
                }
+               if (delay == 0) {
+                       if (get_linux_version() > 20616)
+                               /* mdstat responds to poll */
+                               delay = 1000;
+                       else
+                               delay = 60;
+               }
                rv= Monitor(devlist, mailaddr, program,
                            delay?delay:60, daemonise, scan, oneshot,
                            dosyslog, test, pidfile);
index 87a8c1bade0aadbbbb6a0abacf327a45b3bd98d9..002e2b37f85050c5c295c854b11c71b1624c011d 100644 (file)
@@ -63,7 +63,7 @@ will cause
 .I mdadm
 to look for assembled CONTAINER arrays and included them as a source
 for assembling further arrays.
-.PP
+
 The word
 .I partitions
 will cause
@@ -86,7 +86,7 @@ DEVICE /dev/hda* /dev/hdc*
 .br
 DEV    /dev/sd*
 .br
-DEVICE /dev/discs/disc*/disc
+DEVICE /dev/disk/by-path/pci*
 .br
 DEVICE partitions
 
@@ -109,13 +109,12 @@ which matches the rest of the line will never be automatically assembled.
 If no device name is given,
 .I mdadm
 will use various heuristics to determine an appropriate name.
-.PP
+
 Subsequent words identify the array, or identify the array as a member
 of a group. If multiple identities are given,
 then a component device must match ALL identities to be considered a
 match.  Each identity word has a tag, and equals sign, and some value.
 The tags are:
-
 .RS 4
 .TP
 .B uuid=
@@ -160,6 +159,7 @@ this is mainly for compatibility with the output of
 .TP
 .B spares=
 The value is a number of spare devices to expect the array to have.
+The sole use of this keyword and value is as follows:
 .B mdadm \-\-monitor
 will report an array if it is found to have fewer than this number of
 spares when
@@ -225,12 +225,12 @@ Specify that this array is a member array of some container.  The
 value given can be either a path name in /dev, or a UUID of the
 container array.
 
-.IP
+.TP
 .B member=
 Specify that this array is a member array of some container.  Each
 type of container has some way to enumerate member arrays, often a
 simple sequence number.  The value identifies which member of a
-container the array is.  It will usually accompany a 'container=' word.
+container the array is.  It will usually accompany a "container=" word.
 .RE
 
 .TP
@@ -337,7 +337,7 @@ The
 .B homehost
 line gives a default value for the
 .B --homehost=
-option to mdadm.  There should be exactly one other word on the line.
+option to mdadm.  There should normally be only one other word on the line.
 It should either be a host name, or one of the special words
 .B <system>
 and
@@ -351,19 +351,26 @@ systemcall is used to get the host name.
 If
 .B <ignore>
 is given, then a flag is set so that when arrays are being
-auto-assemble the checking of the recorded
+auto-assembled the checking of the recorded
 .I homehost
 is disabled.
+If
+.B <ignore>
+is given it is also possible to give an explicit name which will be
+used when creating arrays.  This is the only case when there can be
+more that one other word on the
+.B HOMEHOST
+line.
 
 When arrays are created, this host name will be stored in the
 metadata.  When arrays are assembled using auto-assembly, arrays which
 do not record the correct homehost name in their metadata will be
-assembled using a 'foreign' name.  A 'foreign' name alway ends with a
-digit string (possibly preceded by an underscore) to differentiate it
+assembled using a "foreign" name.  A "foreign" name alway ends with a
+digit string preceded by an underscore to differentiate it
 from any possible local name. e.g.
 .B /dev/md/1_1
 or
-.BR /dev/md/home0 .
+.BR /dev/md/home_0 .
 .TP
 .B AUTO
 A list of names of metadata format can be given, each preceded by a
diff --git a/mdadm.h b/mdadm.h
index 89ec77a4b140815af8019b84e0de2ec0b7a78763..e564deeaa8f2eb97dddf676a5f6287da61b24058 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #define        _GNU_SOURCE
index 45ff9c57526af875f7048366a0edda2b1a3debb2..cf83795789158a28e41f441dac40dd060f067681 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * mdassemble - assemble Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  * Copyright (C) 2003 Luca Berra <bluca@vodka.it>
  *
  *
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include "mdadm.h"
diff --git a/mdmon.8 b/mdmon.8
index 2129dc78ec1b1806e07cc9036f84f68161674148..c9cb5de8561b6e618a3afe9067cf117645913506 100644 (file)
--- a/mdmon.8
+++ b/mdmon.8
@@ -15,11 +15,12 @@ occurs, like disk failures and clean-to-dirty transitions.  The kernel, in
 important cases, waits for user space to take action on these notifications.
 
 .SH DESCRIPTION
-.P
-.B Metadata updates:
-.P
-To service metadata update requests a daemon, mdmon, is introduced.
-Mdmon is tasked with polling the sysfs namespace looking for changes in
+.SS Metadata updates:
+To service metadata update requests a daemon,
+.IR mdmon ,
+is introduced.
+.I Mdmon
+is tasked with polling the sysfs namespace looking for changes in
 .BR array_state , 
 .BR sync_action ,
 and per disk
@@ -48,7 +49,9 @@ The safe mode timer has expired so set array state to clean to block writes to t
 Clear the dirty bit for the volume
 .TP
 .B array_state \- read-only
-This is the initial state that all arrays start at.  mdmon takes one of the three actions:
+This is the initial state that all arrays start at.
+.I mdmon
+takes one of the three actions:
 .RS
 .TP
 1/
@@ -72,8 +75,8 @@ checkpoint resync.
 .TP
 .B sync_action \- recover\-to\-idle
 A spare may have completed rebuilding so tell the metadata handler about the
-state of each disk.  This is the metadata handler’s opportunity to clear any
-"out-of-sync" bits and clear the volume’s degraded status.  If a recovery
+state of each disk.  This is the metadata handler's opportunity to clear
+any "out-of-sync" bits and clear the volume's degraded status.  If a recovery
 process is idled before it completes this event allows the metadata handler to
 checkpoint recovery.
 .TP
@@ -81,10 +84,10 @@ checkpoint recovery.
 A disk failure kicks off a series of events.  First, notify the metadata
 handler that a disk has failed, and then notify the kernel that it can unblock
 writes that were dependent on this disk.  After unblocking the kernel this disk
-is set to be removed* from the member array.  Finally the disk is marked failed
+is set to be removed+ from the member array.  Finally the disk is marked failed
 in all other member arrays in the container.
 .IP
-\* Note This behavior differs slightly from native MD arrays where
++ Note This behavior differs slightly from native MD arrays where
 removal is reserved for a
 .B mdadm --remove
 event.  In the external metadata case the container holds the final
@@ -93,8 +96,7 @@ reference on a block device and a
 call is still required.
 .RE
 
-.P
-.B Containers:
+.SS Containers:
 .P
 External metadata formats, like DDF, differ from the native MD metadata
 formats in that they define a set of disks and a series of sub-arrays
@@ -106,7 +108,9 @@ each array can created be created with a subset of those partitions.  The
 supported external formats perform this disk carving internally.
 .P
 Container devices simply hold references to all member disks and allow
-tools like mdmon to determine which active arrays belong to which
+tools like
+.I mdmon
+to determine which active arrays belong to which
 container.  Some array management commands like disk removal and disk
 add are now only valid at the container level.  Attempts to perform
 these actions on member arrays are blocked with error messages like:
@@ -125,14 +129,36 @@ CONTAINER
 The
 .B container
 device to monitor.  It can be a full path like /dev/md/container, a simple md
-device name like md127, or /proc/mdstat which tells mdmon to scan for
-containers and launch an mdmon instance for each one found.
+device name like md127, or /proc/mdstat which tells
+.I mdmon
+to scan for containers and launch an
+.I mdmon
+instance for each one found.
 .TP
 [NEWROOT]
-In order to support an external metadata raid array as the rootfs mdmon needs
-to be started in the initramfs environment.  Once the initramfs environment
-mounts the final rootfs mdmon needs to be restarted in the new namespace.  When
-NEWROOT is specified mdmon will terminate any mdmon instances that are running
-in the current namespace, chroot(2) to NEWROOT, and continue monitoring the
-container.
+In order to support an external metadata raid array as the rootfs
+.I mdmon
+needs to be started in the initramfs environment.  Once the initramfs
+environment mounts the final rootfs
+.I mdmon
+needs to be restarted in the new namespace.  When NEWROOT is specified
+.I mdmon
+will terminate any
+.I mdmon
+instances that are running in the current namespace,
+.IR chroot (2)
+to NEWROOT, and continue monitoring the container.
+.PP
+Note that
+.I mdmon
+is automatically started by
+.I mdadm
+when needed and so does not need to be considered when working with
+RAID arrays.  The only times it is run other that by
+.I  mdadm
+is when the boot scripts need to restart it after mounting the new
+root filesystem.
 
+.SH SEE ALSO
+.IR mdadm (8),
+.IR md (4).
diff --git a/mdmon.c b/mdmon.c
index 5e39437c01b14986f1d9bdd446909700ba175641..37f97af1761721230127ca65ee65a96c6a776301 100644 (file)
--- a/mdmon.c
+++ b/mdmon.c
@@ -1,8 +1,8 @@
 /*
  * mdmon - monitor external metadata arrays
  *
- * Copyright (C) 2007-2008 Neil Brown <neilb@suse.de>
- * Copyright (C) 2007-2008 Intel Corporation
+ * Copyright (C) 2007-2009 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2007-2009 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
diff --git a/mdmon.h b/mdmon.h
index e4904baa438b389e3837f2498e80ad909248d8bd..7cfee3535878a40795bcaaf52c2e16b3bd6b43ef 100644 (file)
--- a/mdmon.h
+++ b/mdmon.h
@@ -1,8 +1,8 @@
 /*
  * mdmon - monitor external metadata arrays
  *
- * Copyright (C) 2007-2008 Neil Brown <neilb@suse.de>
- * Copyright (C) 2007-2008 Intel Corporation
+ * Copyright (C) 2007-2009 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2007-2009 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
index 293ac25d6a5fb02b9b0b8e100060c0b09d45f544..d322cf42ad515327800290b2c6c1787d243212c2 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include "mdadm.h"
index 8de51cf755fa0e718f321d54c3714abd92f04cd9..4d2f473eb09a5b4714dda91fad6c222609c866b2 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -2,7 +2,7 @@
  * mdstat - parse /proc/mdstat file. Part of:
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2002-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2002-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 /*
index 66fea80e808f0475293bc01807f5c0fcfe2226de..0cafc3ac3418c66e191a8eb72eeda4875d4eac5b 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -1,8 +1,8 @@
 /*
  * mdmon - monitor external metadata arrays
  *
- * Copyright (C) 2007-2008 Neil Brown <neilb@suse.de>
- * Copyright (C) 2007-2008 Intel Corporation
+ * Copyright (C) 2007-2009 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2007-2009 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
index 509b45087bed453b6f76aa23e4a2d4639a6d1405..29c7336192a12bf9d4664758c53e8bb7ee1059ec 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2006-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
index 77a481f37461cc8411b01b530764a53d6fcf0833..bcd44d1ea4b5ab074fe3f7320808800e688fb2b2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2006-2007 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2006-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
index 3f02ed403435bcaf4c5196e931539627c7ba8495..2b4942f4ecdfa28c40cdefdcec89567451773219 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #define HAVE_STDINT_H 1
index 35ef771a613c9b29db436737ae621a9ada692822..056b93bb7dafdb9ba541903fec515e7bede42df6 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include "mdadm.h"
diff --git a/sysfs.c b/sysfs.c
index b6156636f9811c1df344f484e126ac60e3ccae2f..81ccb53fe5d23bfd64a60ebb74c753c58e547e40 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -2,7 +2,7 @@
  * sysfs - extract md related information from sysfs.  Part of:
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2006-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
@@ -758,3 +758,108 @@ int sysfs_unique_holder(int devnum, long rdev)
        else
                return found;
 }
+
+#ifndef MDASSEMBLE
+
+static char *clean_states[] = {
+       "clear", "inactive", "readonly", "read-auto", "clean", NULL };
+
+int WaitClean(char *dev, int verbose)
+{
+       int fd;
+       struct mdinfo *mdi;
+       int rv = 1;
+       int devnum;
+
+       fd = open(dev, O_RDONLY); 
+       if (fd < 0) {
+               if (verbose)
+                       fprintf(stderr, Name ": Couldn't open %s: %s\n", dev, strerror(errno));
+               return 1;
+       }
+
+       devnum = fd2devnum(fd);
+       mdi = sysfs_read(fd, devnum, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
+       if (!mdi) {
+               if (verbose)
+                       fprintf(stderr, Name ": Failed to read sysfs attributes for "
+                               "%s\n", dev);
+               close(fd);
+               return 0;
+       }
+
+       switch(mdi->array.level) {
+       case LEVEL_LINEAR:
+       case LEVEL_MULTIPATH:
+       case 0:
+               /* safemode delay is irrelevant for these levels */
+               rv = 0;
+               
+       }
+
+       /* for internal metadata the kernel handles the final clean
+        * transition, containers can never be dirty
+        */
+       if (!is_subarray(mdi->text_version))
+               rv = 0;
+
+       /* safemode disabled ? */
+       if (mdi->safe_mode_delay == 0)
+               rv = 0;
+
+       if (rv) {
+               int state_fd = sysfs_open(fd2devnum(fd), NULL, "array_state");
+               char buf[20];
+               fd_set fds;
+               struct timeval tm;
+
+               /* minimize the safe_mode_delay and prepare to wait up to 5s
+                * for writes to quiesce
+                */
+               sysfs_set_safemode(mdi, 1);
+               tm.tv_sec = 5;
+               tm.tv_usec = 0;
+
+               /* give mdmon a chance to checkpoint resync */
+               sysfs_set_str(mdi, NULL, "sync_action", "idle");
+
+               FD_ZERO(&fds);
+
+               /* wait for array_state to be clean */
+               while (1) {
+                       rv = read(state_fd, buf, sizeof(buf));
+                       if (rv < 0)
+                               break;
+                       if (sysfs_match_word(buf, clean_states) <= 4)
+                               break;
+                       FD_SET(state_fd, &fds);
+                       rv = select(state_fd + 1, NULL, NULL, &fds, &tm);
+                       if (rv < 0 && errno != EINTR)
+                               break;
+                       lseek(state_fd, 0, SEEK_SET);
+               }
+               if (rv < 0)
+                       rv = 1;
+               else if (ping_monitor(mdi->text_version) == 0) {
+                       /* we need to ping to close the window between array
+                        * state transitioning to clean and the metadata being
+                        * marked clean
+                        */
+                       rv = 0;
+               } else
+                       rv = 1;
+               if (rv && verbose)
+                       fprintf(stderr, Name ": Error waiting for %s to be clean\n",
+                               dev);
+
+               /* restore the original safe_mode_delay */
+               sysfs_set_safemode(mdi, mdi->safe_mode_delay);
+               close(state_fd);
+       }
+
+       sysfs_free(mdi);
+       close(fd);
+
+       return rv;
+}
+#endif /* MDASSEMBLE */
diff --git a/util.c b/util.c
index f09fd843c9aa8bec32aeb0e39da7e6c47e9ba5c2..00bf80378de615e8ece5d40ab4d56990062ea4c8 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 
 #include       "mdadm.h"