From: NeilBrown Subject: Make wait_for faster References: bnc#816382 When we crete or assemble an array, we wait for udev to create the device file in /dev so that as soon as mdadm complete, the device can be used. This waiting is performed in multiples of 200ms, which can sometimes be too long to wait. So change to an exponential backoff. Wait 1, then 2, then 4 msec etc. Once we get to 256msec, stop backing off and continue waiting 256ms at a time until we reach the limit which is now 4.608sec rather than 5sec which it was before. Signed-off-by: NeilBrown --- util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- mdadm-3.2.6.orig/util.c +++ mdadm-3.2.6/util.c @@ -912,6 +912,7 @@ void wait_for(char *dev, int fd) { int i; struct stat stb_want; + long delay = 1000; if (fstat(fd, &stb_want) != 0 || (stb_want.st_mode & S_IFMT) != S_IFBLK) @@ -923,7 +924,9 @@ void wait_for(char *dev, int fd) (stb.st_mode & S_IFMT) == S_IFBLK && (stb.st_rdev == stb_want.st_rdev)) return; - usleep(200000); + usleep(delay); + if (delay < 200000) + delay *= 2; } if (i == 25) dprintf("%s: timeout waiting for %s\n", __func__, dev);