]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - raid6check.c
sysfs: Use the presence of /sys/block/<dev>/md as indicator of valid device
[thirdparty/mdadm.git] / raid6check.c
index f01944053cda6505a9c091b3a5f6609fbbb50ffe..551f8355bd69d45275ba443695883838e94f5870 100644 (file)
@@ -266,16 +266,12 @@ int manual_repair(int chunk_size, int syndrome_disks,
                                failed_data = failed_slot2;
                        else
                                failed_data = failed_slot1;
-                               printf("Repairing D(%d) and P\n", failed_data);
+
+                       printf("Repairing D(%d) and P\n", failed_data);
                        raid6_datap_recov(syndrome_disks+2, chunk_size,
                                          failed_data, (uint8_t**)blocks, 1);
                } else {
                        printf("Repairing D and D\n");
-                       if (failed_slot1 > failed_slot2) {
-                               int t = failed_slot1;
-                               failed_slot1 = failed_slot2;
-                               failed_slot2 = t;
-                       }
                        raid6_2data_recov(syndrome_disks+2, chunk_size,
                                          failed_slot1, failed_slot2,
                                          (uint8_t**)blocks, 1);
@@ -317,7 +313,7 @@ int check_stripes(struct mdinfo *info, int *source, unsigned long long *offsets,
        /* read the data and p and q blocks, and check we got them right */
        int data_disks = raid_disks - 2;
        int syndrome_disks = data_disks + is_ddf(layout) * 2;
-       char *stripe_buf = xmalloc(raid_disks * chunk_size);
+       char *stripe_buf;
 
        /* stripes[] is indexed by raid_disk and holds chunks from each device */
        char **stripes = xmalloc(raid_disks * sizeof(char*));
@@ -354,6 +350,8 @@ int check_stripes(struct mdinfo *info, int *source, unsigned long long *offsets,
        if (!tables_ready)
                make_tables();
 
+       if (posix_memalign((void**)&stripe_buf, 4096, raid_disks * chunk_size) != 0)
+               exit(4);
        block_index_for_slot += 2;
        blocks += 2;
        blocks_page += 2;
@@ -680,7 +678,7 @@ int main(int argc, char *argv[])
                if(disk_slot >= 0) {
                        disk_name[disk_slot] = map_dev(comp->disk.major, comp->disk.minor, 0);
                        offsets[disk_slot] = comp->data_offset * 512;
-                       fds[disk_slot] = open(disk_name[disk_slot], O_RDWR | O_SYNC);
+                       fds[disk_slot] = open(disk_name[disk_slot], O_RDWR | O_DIRECT);
                        if (fds[disk_slot] < 0) {
                                perror(disk_name[disk_slot]);
                                fprintf(stderr,"%s: cannot open %s\n", prg, disk_name[disk_slot]);