From ecab4c470cae07a65a10e9aa2aec3878a06f2904 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 10 Aug 2020 11:22:30 +0100 Subject: [PATCH] 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. --- src/shared/dissect-image.c | 3 +++ 1 file changed, 3 insertions(+) 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. -- 2.47.3