]> git.ipfire.org Git - thirdparty/collectd.git/commit
mmc: cache open file descriptors to block devices 3934/head
authorLeonard Göhrs <leonard@goehrs.eu>
Tue, 27 Sep 2022 06:03:14 +0000 (08:03 +0200)
committerMatthias Runge <mrunge@matthias-runge.de>
Wed, 28 Sep 2022 07:55:09 +0000 (09:55 +0200)
commit2b5e8c85a7253b325ba7b084d7f76eb155475de4
treed611b0c3acc1783eba3b09f03cae00ba6ba69465
parent49b0764efdd55b267bfd630b669087ae3aebdc38
mmc: cache open file descriptors to block devices

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: 2f15c704 (mmc: add more vendor specific and generic data sources (#4006))
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
src/mmc.c