]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Grow.c
mdadm: Fixup a large number of bad formatting of logical operators
[thirdparty/mdadm.git] / Grow.c
diff --git a/Grow.c b/Grow.c
old mode 100755 (executable)
new mode 100644 (file)
index 15f4ed1..39110b8
--- a/Grow.c
+++ b/Grow.c
@@ -109,7 +109,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
         */
        struct mdinfo info;
 
-       struct stat stb;
+       dev_t rdev;
        int nfd, fd2;
        int d, nd;
        struct supertype *st = NULL;
@@ -145,9 +145,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
                free(st);
                return 1;
        }
-       fstat(nfd, &stb);
-       if ((stb.st_mode & S_IFMT) != S_IFBLK) {
-               pr_err("%s is not a block device!\n", newdev);
+       if (!fstat_is_blkdev(nfd, newdev, &rdev)) {
                close(nfd);
                free(st);
                return 1;
@@ -198,8 +196,8 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
         */
 
        info.disk.number = d;
-       info.disk.major = major(stb.st_rdev);
-       info.disk.minor = minor(stb.st_rdev);
+       info.disk.major = major(rdev);
+       info.disk.minor = minor(rdev);
        info.disk.raid_disk = d;
        info.disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE);
        st->ss->update_super(st, &info, "linear-grow-new", newdev,
@@ -815,8 +813,8 @@ static void unfreeze(struct supertype *st)
                char buf[20];
 
                if (sra &&
-                   sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0
-                   && strcmp(buf, "frozen\n") == 0)
+                   sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
+                   strcmp(buf, "frozen\n") == 0)
                        sysfs_set_str(sra, NULL, "sync_action", "idle");
                sysfs_free(sra);
        }
@@ -2904,8 +2902,8 @@ static int impose_level(int fd, int level, char *devname, int verbose)
                        if (disk.major == 0 && disk.minor == 0)
                                continue;
                        found++;
-                       if ((disk.state & (1 << MD_DISK_ACTIVE))
-                           && disk.raid_disk < data_disks)
+                       if ((disk.state & (1 << MD_DISK_ACTIVE)) &&
+                           disk.raid_disk < data_disks)
                                /* keep this */
                                continue;
                        ioctl(fd, HOT_REMOVE_DISK,
@@ -2923,8 +2921,8 @@ static int impose_level(int fd, int level, char *devname, int verbose)
                        if (disk.major == 0 && disk.minor == 0)
                                continue;
                        found++;
-                       if ((disk.state & (1 << MD_DISK_ACTIVE))
-                           && disk.raid_disk < data_disks)
+                       if ((disk.state & (1 << MD_DISK_ACTIVE)) &&
+                           disk.raid_disk < data_disks)
                                /* keep this */
                                continue;
                        ioctl(fd, SET_DISK_FAULTY,
@@ -3599,9 +3597,8 @@ started:
        }
 
        if (!st->ss->external &&
-           !(reshape.before.data_disks != reshape.after.data_disks
-             && info->custom_array_size) &&
-           info->new_level == reshape.level &&
+           !(reshape.before.data_disks != reshape.after.data_disks &&
+             info->custom_array_size) && info->new_level == reshape.level &&
            !forked) {
                /* no need to wait for the reshape to finish as
                 * there is nothing more to do.
@@ -4094,14 +4091,14 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
                 * before setting 'sync_action' to 'idle'.
                 * So we need these extra tests.
                 */
-               if (completed == 0 && advancing
-                   && strncmp(action, "idle", 4) == 0
-                   && info->reshape_progress > 0)
+               if (completed == 0 && advancing &&
+                   strncmp(action, "idle", 4) == 0 &&
+                   info->reshape_progress > 0)
                        break;
-               if (completed == 0 && !advancing
-                   && strncmp(action, "idle", 4) == 0
-                   && info->reshape_progress < (info->component_size
-                                                * reshape->after.data_disks))
+               if (completed == 0 && !advancing &&
+                   strncmp(action, "idle", 4) == 0 &&
+                   info->reshape_progress < (info->component_size
+                                             * reshape->after.data_disks))
                        break;
                sysfs_wait(fd, NULL);
                if (sysfs_fd_get_ll(fd, &completed) < 0)
@@ -4789,8 +4786,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
                                /* reshape_progress is increasing */
                                if ((__le64_to_cpu(bsb.arraystart)
                                     + __le64_to_cpu(bsb.length)
-                                    < info->reshape_progress)
-                                   &&
+                                    < info->reshape_progress) &&
                                    (__le64_to_cpu(bsb.arraystart2)
                                     + __le64_to_cpu(bsb.length2)
                                     < info->reshape_progress))
@@ -5002,6 +4998,7 @@ int Grow_continue_command(char *devname, int fd,
                        goto Grow_continue_command_exit;
                }
                content = &array;
+               sysfs_init(content, fd, NULL);
                /* Need to load a superblock.
                 * FIXME we should really get what we need from
                 * sysfs
@@ -5074,7 +5071,7 @@ int Grow_continue_command(char *devname, int fd,
 
                cc = st->ss->container_content(st, subarray);
                for (content = cc; content ; content = content->next) {
-                       char *array;
+                       char *array_name;
                        int allow_reshape = 1;
 
                        if (content->reshape_active == 0)
@@ -5099,8 +5096,8 @@ int Grow_continue_command(char *devname, int fd,
                                goto Grow_continue_command_exit;
                        }
 
-                       array = strchr(content->text_version+1, '/')+1;
-                       mdstat = mdstat_by_subdev(array, container);
+                       array_name = strchr(content->text_version+1, '/')+1;
+                       mdstat = mdstat_by_subdev(array_name, container);
                        if (!mdstat)
                                continue;
                        if (mdstat->active == 0) {