GNU bug report logs -
#52516
Avoiding race condition between partprobe and getting PARTUUID using lsblk?
Previous Next
Reported by: Anton Hvornum <anton <at> hvornum.se>
Date: Wed, 15 Dec 2021 15:59:02 UTC
Severity: normal
Done: "Brian C. Lane" <bcl <at> redhat.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52516 in the body.
You can then email your comments to 52516 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-parted <at> gnu.org
:
bug#52516
; Package
parted
.
(Wed, 15 Dec 2021 15:59:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Anton Hvornum <anton <at> hvornum.se>
:
New bug report received and forwarded. Copy sent to
bug-parted <at> gnu.org
.
(Wed, 15 Dec 2021 15:59:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi.
So I've been struggling a bit with optimizing applications calling
partprobe right after lsblk to retrieve PARTUUID of newly generated
partitions using parted.
Assuming the following loop:
* partprobe
* lsblk
* if !result: sleep + loop
It feels as if every partprobe (indirectly or directly) flushes a
cache/struct of information somewhere, which makes lsblk "fail" to
retrieve certain information if executed too quickly in succession. A
normal approach to solving this is adding a delay between partprobe
and lsblk, something I wanted to avoid by putting the sleep at the
very end of the loop, and instead do many quick loops until the
information is available. I could also put partprobe before the loop,
and continue looping until the information becomes available. But that
poses an issue if the disk-operation (parted) completes after
partprobe performs it's tasks. Leaving the loop in a dead state until
a new partprobe is called (or that seems to be the issue at least).
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?
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)
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.
Best wishes:
Anton Hvornum
Reply sent
to
"Brian C. Lane" <bcl <at> redhat.com>
:
You have taken responsibility.
(Wed, 15 Dec 2021 16:56:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
Anton Hvornum <anton <at> hvornum.se>
:
bug acknowledged by developer.
(Wed, 15 Dec 2021 16:56:03 GMT)
Full text and
rfc822 format available.
Message #10 received at 52516-close <at> debbugs.gnu.org (full text, mbox):
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
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 13 Jan 2022 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 244 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.