Subject: Re: bug#52516: Avoiding race condition between partprobe and getting PARTUUID using lsblk?
From: "Brian C. Lane" <[email-masked]>
To: [email-masked]
Date: Wed, 15 Dec 2021 08:54:50 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

On Wed, Dec 15, 2021 at 01:12:43PM +0000, Anton Hvornum wrote:

[snip]

> My question boils down to:
>  1. Is there a way to get an indication of when the partprobe (or
> kernel) has completed its task of populating the partition
> information?

udevadm settle should help. The problem is that partprobe tells the
kernel about all the partitions, the kernel then tells udev about the
changes and then udev updates device nodes. So you cannot depend on
anything being stable until udev is finished.

>  2. Is there a way to tell partprobe/kernel to not clear the old
> struct before the new information is available (leaving "old
> information" intact until new exists, rather than wiping it and then
> populating)

No. It has to refresh everything, otherwise some parts of it might get
out of sync.

> If none of the two above is possible, I would like to consider those
> being a feature as it would greatly help to verify when disk
> operations are 100% complete. I don't mind optionally hanging
> applications/scripts until parted is complete, as I would like to
> avoid continuing based on parted exit code if the exit code is not a
> guarantee of the process being completed in this case.

There's not much you can do other than wait for udev, or check to make
sure device nodes you expect to be present are there. We used to hit
problems like this in the parted test suite all the time, until we added
loops to wait for the partitions to appear.

Good Luck!

Brian

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart