]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: yield for 2ms when a verity device cannot be opened before retrying
authorLuca Boccassi <luca.boccassi@microsoft.com>
Mon, 10 Aug 2020 10:22:30 +0000 (11:22 +0100)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Fri, 14 Aug 2020 14:26:04 +0000 (15:26 +0100)
If we don't succeed on the first try it's because another process is
opening the same device. Do a microsleep for 2ms to increase the
chances it has completed the next time around the loop.

src/shared/dissect-image.c

index 97f0e46e7887a3f864258f9fdfdbaafcd1b8f61d..66b7ec528461b6982d0aa62dd622684c3e34ef0b 100644 (file)
@@ -1475,6 +1475,9 @@ static int verity_partition(
                 }
                 if (r == 0)
                         break;
+
+                /* Device is being opened by another process, but it has not finished yet, yield for 2ms */
+                (void) usleep(2 * USEC_PER_MSEC);
         }
 
         /* An existing verity device was reported by libcryptsetup/libdevmapper, but we can't use it at this time.