]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - managemon.c
mdadm: Fixup a large number of bad formatting of logical operators
[thirdparty/mdadm.git] / managemon.c
index ec4586b2f5fffbc39fe4d473e3f8b6da324a4331..0a33fc9b41ca70534a6f93590ee7dfc9a7b5e6a8 100644 (file)
@@ -115,6 +115,8 @@ static void close_aa(struct active_array *aa)
        for (d = aa->info.devs; d; d = d->next) {
                close(d->recovery_fd);
                close(d->state_fd);
+               close(d->bb_fd);
+               close(d->ubb_fd);
        }
 
        if (aa->action_fd >= 0)
@@ -410,7 +412,9 @@ static int sysfs_open2(char *devnum, char *name, char *attr)
                 * never needs too.
                 */
                char buf[200];
-               read(fd, buf, sizeof(buf));
+               if (read(fd, buf, sizeof(buf)) < 0)
+                       /* pretend not to ignore return value */
+                       return fd;
        }
        return fd;
 }
@@ -431,6 +435,21 @@ static int disk_init_and_add(struct mdinfo *disk, struct mdinfo *clone,
                close(disk->recovery_fd);
                return -1;
        }
+       disk->bb_fd = sysfs_open2(aa->info.sys_name, disk->sys_name,
+                                "bad_blocks");
+       if (disk->bb_fd < 0) {
+               close(disk->recovery_fd);
+               close(disk->state_fd);
+               return -1;
+       }
+       disk->ubb_fd = sysfs_open2(aa->info.sys_name, disk->sys_name,
+                                 "unacknowledged_bad_blocks");
+       if (disk->ubb_fd < 0) {
+               close(disk->recovery_fd);
+               close(disk->state_fd);
+               close(disk->bb_fd);
+               return -1;
+       }
        disk->prev_state = read_dev_state(disk->state_fd);
        disk->curr_state = disk->prev_state;
        disk->next = aa->info.devs;
@@ -480,9 +499,9 @@ static void manage_member(struct mdstat_ent *mdstat,
                frozen = 1; /* can't read metadata_version assume the worst */
 
        /* If sync_action is not 'idle' then don't try recovery now */
-       if (!frozen
-           && sysfs_get_str(&a->info, NULL, "sync_action", buf, sizeof(buf)) > 0
-           && strncmp(buf, "idle", 4) != 0)
+       if (!frozen &&
+           sysfs_get_str(&a->info, NULL, "sync_action",
+                         buf, sizeof(buf)) > 0 && strncmp(buf, "idle", 4) != 0)
                frozen = 1;
 
        if (mdstat->level) {
@@ -607,8 +626,8 @@ static void manage_member(struct mdstat_ent *mdstat,
                        newd = xmalloc(sizeof(*newd));
                        disk_init_and_add(newd, d, newa);
                }
-               if (sysfs_get_ll(info, NULL, "array_size", &array_size) == 0
-                   && a->info.custom_array_size > array_size*2) {
+               if (sysfs_get_ll(info, NULL, "array_size", &array_size) == 0 &&
+                   a->info.custom_array_size > array_size*2) {
                        sysfs_set_num(info, NULL, "array_size",
                                      a->info.custom_array_size/2);
                }