Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os-helpers: fs: replace wait4file w/ inotifywait #3081

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakogut
Copy link
Contributor

@jakogut jakogut commented Mar 24, 2023

Previously, scripts that required a file that is created asynchronously, such as the by-state links created by a udev rule, would busy loop until the file existed using wait4file(), part of os-helpers-fs.

This is time consuming and inefficient, as the minimum wait time adds latency to the following operations. Instead, use inotifywait to receive an event from the kernel when the relevant file or path is modified to prevent unnecessary resource usage and busy waiting.

Change-type: patch


Contributor checklist

Reviewer Guidelines

  • When submitting a review, please pick:
    • 'Approve' if this change would be acceptable in the codebase (even if there are minor or cosmetic tweaks that could be improved).
    • 'Request Changes' if this change would not be acceptable in our codebase (e.g. bugs, changes that will make development harder in future, security/performance issues, etc).
    • 'Comment' if you don't feel you have enough information to decide either way (e.g. if you have major questions, or you don't understand the context of the change sufficiently to fully review yourself, but want to make a comment)

Previously, scripts that required a file that is created asynchronously,
such as the by-state links created by a udev rule, would busy loop until
the file existed using wait4file(), part of os-helpers-fs.

This is time consuming and inefficient, as the minimum wait time adds
latency to the following operations. Instead, use inotifywait to receive
an event from the kernel when the relevant file or path is modified to
prevent unnecessary resource usage and busy waiting.

Change-type: patch
Signed-off-by: Joseph Kogut <[email protected]>
done
return 0
}

# Output the UUID for the specified block device.
Copy link
Contributor

@alexgg alexgg Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakogut I think the change is an improvement, but why not keep the wait4file abstraction and just re-implement it using inotifywait?
Also, as the include option is only supported from inotify-tools 3.21.9.0, if you abstract it in wait4file you can check that a specific version is installed and if not fallback to the current method for backwards compatibility with older Yocto versions that include older versions of inotifywait (or don't have an inotify-tools recipe)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thoughts, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants