]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Manage.c
mdadm: load default sysfs attributes after assemblation
[thirdparty/mdadm.git] / Manage.c
index 14276b709d1cfbfedd1c852da4a29eef060647e1..21536f5ee4e92554a72b71bea5cfedd5d831d238 100644 (file)
--- a/Manage.c
+++ b/Manage.c
 #include "md_p.h"
 #include <ctype.h>
 
-#define REGISTER_DEV           _IO (MD_MAJOR, 1)
-#define START_MD               _IO (MD_MAJOR, 2)
-#define STOP_MD                        _IO (MD_MAJOR, 3)
-
 int Manage_ro(char *devname, int fd, int readonly)
 {
        /* switch to readonly or rw
@@ -208,11 +204,9 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
        count = 5;
        while (((fd = ((devname[0] == '/')
                       ?open(devname, O_RDONLY|O_EXCL)
-                      :open_dev_flags(devnm, O_RDONLY|O_EXCL))) < 0
-               || strcmp(fd2devnm(fd), devnm) != 0)
-              && container[0]
-              && mdmon_running(container)
-              && count) {
+                      :open_dev_flags(devnm, O_RDONLY|O_EXCL))) < 0 ||
+               strcmp(fd2devnm(fd), devnm) != 0) && container[0] &&
+              mdmon_running(container) && count) {
                /* Can't open, so something might be wrong.  However it
                 * is a container, so we might be racing with mdmon, so
                 * retry for a bit.
@@ -248,8 +242,8 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
                while (count &&
                       (err = sysfs_set_str(mdi, NULL,
                                            "array_state",
-                                           "inactive")) < 0
-                      && errno == EBUSY) {
+                                           "inactive")) < 0 &&
+                      errno == EBUSY) {
                        usleep(200000);
                        count--;
                }
@@ -451,9 +445,8 @@ done:
         * so it is reasonable to retry for a while - 5 seconds.
         */
        count = 25; err = 0;
-       while (count && fd >= 0
-              && (err = ioctl(fd, STOP_ARRAY, NULL)) < 0
-              && errno == EBUSY) {
+       while (count && fd >= 0 &&
+              (err = ioctl(fd, STOP_ARRAY, NULL)) < 0 && errno == EBUSY) {
                usleep(200000);
                count --;
        }
@@ -662,8 +655,8 @@ int attempt_re_add(int fd, int tfd, struct mddev_dev *dv,
                if (dv->failfast == FlagClear)
                        disc.state &= ~(1 << MD_DISK_FAILFAST);
                remove_partitions(tfd);
-               if (update || dv->writemostly != FlagDefault
-                       || dv->failfast != FlagDefault) {
+               if (update || dv->writemostly != FlagDefault ||
+                   dv->failfast != FlagDefault) {
                        int rv = -1;
                        tfd = dev_open(dv->devname, O_RDWR);
                        if (tfd < 0) {
@@ -799,8 +792,8 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
                                break;
                        }
                /* FIXME this is a bad test to be using */
-               if (!tst->sb && (dv->disposition != 'a'
-                                && dv->disposition != 'S')) {
+               if (!tst->sb && (dv->disposition != 'a' &&
+                                dv->disposition != 'S')) {
                        /* we are re-adding a device to a
                         * completely dead array - have to depend
                         * on kernel to check
@@ -918,7 +911,6 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
 
        /* only add journal to array that supports journaling */
        if (dv->disposition == 'j') {
-               struct mdinfo mdi;
                struct mdinfo *mdp;
 
                mdp = sysfs_read(fd, NULL, GET_ARRAY_STATE);
@@ -935,11 +927,6 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
 
                sysfs_free(mdp);
 
-               tst->ss->getinfo_super(tst, &mdi, NULL);
-               if (mdi.journal_device_required == 0) {
-                       pr_err("%s does not support journal device.\n", devname);
-                       return -1;
-               }
                disc.raid_disk = 0;
        }
 
@@ -1380,7 +1367,7 @@ int Manage_subdevs(char *devname, int fd,
        }
 
        for (dv = devlist; dv; dv = dv->next) {
-               unsigned long rdev = 0; /* device to add/remove etc */
+               dev_t rdev = 0; /* device to add/remove etc */
                int rv;
                int mj,mn;
 
@@ -1397,8 +1384,7 @@ int Manage_subdevs(char *devname, int fd,
 
                if (strcmp(dv->devname, "failed") == 0 ||
                    strcmp(dv->devname, "faulty") == 0) {
-                       if (dv->disposition != 'A'
-                           && dv->disposition != 'r') {
+                       if (dv->disposition != 'A' && dv->disposition != 'r') {
                                pr_err("%s only meaningful with -r or --re-add, not -%c\n",
                                        dv->devname, dv->disposition);
                                goto abort;
@@ -1431,7 +1417,7 @@ int Manage_subdevs(char *devname, int fd,
                        }
                        add_devlist = conf_get_devs();
                        if (add_devlist == NULL) {
-                               pr_err("no devices to scan for missing members.");
+                               pr_err("no devices to scan for missing members.\n");
                                continue;
                        }
                        for (dp = &add_devlist; *dp; dp = & (*dp)->next)
@@ -1503,8 +1489,9 @@ int Manage_subdevs(char *devname, int fd,
                                        goto abort;
                                }
                        }
-               } else if ((dv->disposition == 'r' || dv->disposition == 'f')
-                          && get_maj_min(dv->devname, &mj, &mn)) {
+               } else if ((dv->disposition == 'r' ||
+                           dv->disposition == 'f') &&
+                          get_maj_min(dv->devname, &mj, &mn)) {
                        /* for 'fail' and 'remove', the device might
                         * not exist.
                         */