mdadm/mdadm-2.6.4-incremental.patch
Bill Nottingham 8fe36f4e44 - make /dev/md if necessary in incremental mode (#429604)
- open RAID devices with O_EXCL to avoid racing against other --incremental
    processes (#433932)
2008-04-17 16:27:33 +00:00

36 lines
789 B
Diff

diff -ru mdadm-2.6.4/mdopen.c mdadm-2.6.4-fixed/mdopen.c
--- mdadm-2.6.4/mdopen.c 2007-10-16 05:47:25.000000000 -0400
+++ mdadm-2.6.4-fixed/mdopen.c 2008-04-16 19:04:08.000000000 -0400
@@ -302,6 +302,7 @@
*/
int major_num, minor_num;
struct stat stb;
+ int i;
if (devname)
strcpy(chosen_name, devname);
@@ -333,11 +334,22 @@
return -1;
}
} else {
+ if (strncmp(chosen_name, "/dev/md/", 8) == 0) {
+ mkdir("/dev/md", 0755);
+ }
if (mknod(chosen_name, S_IFBLK | 0600,
makedev(major_num, minor_num)) != 0) {
return -1;
}
/* FIXME chown/chmod ?? */
}
- return open(chosen_name, O_RDWR);
+ for (i = 0; i < 25 ; i++) {
+ int fd;
+
+ fd = open(chosen_name, O_RDWR|O_EXCL);
+ if (fd >= 0)
+ return fd;
+ usleep(200000);
+ }
+ return -1;
}