From: Luca Boccassi Date: Mon, 10 Aug 2020 10:22:30 +0000 (+0100) Subject: dissect: yield for 2ms when a verity device cannot be opened before retrying X-Git-Tag: v247-rc1~429^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ecab4c470cae07a65a10e9aa2aec3878a06f2904;p=thirdparty%2Fsystemd.git dissect: yield for 2ms when a verity device cannot be opened before retrying 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. --- diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 97f0e46e788..66b7ec52846 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -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.