10000 mmc: cache open file descriptors to block devices by hnez · Pull Request #4053 · collectd/collectd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

mmc: cache open file descriptors to block devices #4053

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

Merged
merged 1 commit into from
Sep 28, 2022

Conversation

hnez
Copy link
Contributor
@hnez hnez commented Sep 27, 2022

ChangeLog: mmc plugin: cache file descriptors to reduce udev events generated as side-effect

Hi,

there is a slight annoyance when using the eMMC health info support for Micron and Sandisk chips introduced by me in #4006: an udev event is generated on every call to the read callback.

This is due to to the watch option that can be used in udev rules, which is described in the man page as:

Watch the device node with inotify; when the node is closed after being opened for writing, a change uevent is synthesized.

This watch option is enabled by default for all block devices. The intention behind this is to be notified about changes to the partition table. The mmc plugin does however also need to open the block device for writing, even though it never modifies its content, in order to be able to issue ioctls with vendor defined MMC-commands.

Reduce the amount of generated change events from one per read to one per collectd runtime by caching the open file descriptor.

Fixes: 2f15c70 (mmc: add more vendor specific and generic data sources (#4006))
Signed-off-by: Leonard Göhrs l.goehrs@pengutronix.de

@hnez hnez requested a review from a team as a code owner September 27, 2022 11:20
Udev rules can contain a "watch" option, which is described in the man page as:

  Watch the device node with inotify; when the node is closed after being
  opened for writing, a change uevent is synthesized.

This watch option is enabled by default for all block devices[1].
The intention behind this is to be notified about changes to the partition
table. The mmc plugin does however also need to open the block device for
writing, even though it never modifies its content, in order to be able to
issue ioctls with vendor defined MMC-commands.

Reduce the amount of generated change events from one per read to one per
collectd runtime by caching the open file descriptor.

[1]: https://github.com/systemd/systemd/blob/ef2ad30aee9fa99b0fdb8fe7efda397513cec6af/rules.d/60-block.rules

Fixes: 2f15c70 (mmc: add more vendor specific and generic data sources (collectd#4006))
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez hnez force-pushed the topic/lgo/mmc-udev-fix branch from ad8ef8c to 245c191 Compare September 28, 2022 05:38
@mrunge
Copy link
Member
mrunge commented Sep 28, 2022

Thank you. The failed CI checks are not related to this PR.

@mrunge mrunge merged commit 2b5e8c8 into collectd:main Sep 28, 2022
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
0