LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC PATCH v3 00/18] Add block device LED trigger
@ 2021-08-19  2:50 Ian Pilcher
  2021-08-19  2:50 ` [RFC PATCH v3 01/18] docs: Add block device (blkdev) LED trigger documentation Ian Pilcher
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: Ian Pilcher @ 2021-08-19  2:50 UTC (permalink / raw)
  To: linux-block, linux-leds; +Cc: axboe, pavel, kabel, linux-kernel, kernelnewbies

Ridiculous or not, here is version 3 of the block device trigger for
"freaking blinkenlights".  It addresses basically all of the points
raised in response to the v2 patchset.

* The main body of the code is moved from the block directory into
  the LED triggers directory (drivers/leds/trigger/ledtrig-blkdev.c)

  The downside of this is that it requires adding an API to the
  block subsystem - get_disk_by_name() - which allows the trigger
  code to resolve a gendisk when asked to monitor it.  I know of
  no good way to do this today, and I don't know of a good way to
  implement the sysfs API requested by Pavel and Marek without
  something like this API.

  Other than that, changes to the block subsystem are as minimal as
  I can make them - a single pointer added to struct gendisk and
  init/cleanup calls when a gendisk is added or deleted.

* This also implements Marek's suggestion of periodically checking
  devices for activity, rather than directly blinking LEDs in the
  I/O path.  This change has the unanticipated benefit of making the
  trigger work on pretty much all types of virtual block devices
  (device mapper, MD RAID, zRAM, etc.), as well as NVMe SSDs.

* Relationships between devices and LEDs are now many-to-many.  An
  LED can monitor multiple devices, and multiple LEDs can monitor
  any one device.  The current "associations" are reflected in two
  sysfs directories.

  - /sys/class/leds/<led>/block_devices contains links to all devices
    associated with an LED, and

  - /sys/block/<disk>/blkdev_leds contains links to all LEDs with
    which the device is associated.

  (The latter directory only exists when the device is associated
  with at least one LED.)

* Each LED can be set to show read activity, write activity, or both.
  Discards and cache flushes are considered to be writes, as they
  affect the state of the device's non-volatile storage.

Ian Pilcher (18):
  docs: Add block device (blkdev) LED trigger documentation
  block: Add get_disk_by_name() for use by blkdev LED trigger
  ledtrig-blkdev: Add file (ledtrig-blkdev.c) for block device LED
    trigger
  ledtrig-blkdev: Add misc. helper functions to blkdev LED trigger
  ledtrig-blkdev: Periodically check devices for activity & blink LEDs
  block: Add LED trigger pointer to struct gendisk
  ledtrig-blkdev: Add function to initialize gendisk ledtrig member
  ledtrig-blkdev: Add function to remove LED/device association
  ledtrig-blkdev: Add function to disassociate a device from all LEDs
  block: Call LED trigger init/cleanup functions
  ledtrig-blkdev: Add function to associate a device with an LED
  ledtrig-blkdev: Add sysfs attributes to [dis]associate LEDs & devices
  ledtrig-blkdev: Add blink_time & interval sysfs attributes
  ledtrig-blkdev: Add mode (read/write/rw) sysfs attributue
  ledtrig-blkdev: Add function to associate blkdev trigger with LED
  ledtrig-blkdev: Add function to disassociate an LED from the trigger
  ledtrig-blkdev: Add initialization function
  ledtrig-blkdev: Add config option to enable the trigger

 Documentation/ABI/testing/sysfs-block         |   9 +
 .../testing/sysfs-class-led-trigger-blkdev    |  48 ++
 Documentation/leds/index.rst                  |   1 +
 Documentation/leds/ledtrig-blkdev.rst         | 132 +++
 block/genhd.c                                 |  28 +
 drivers/leds/trigger/Kconfig                  |   9 +
 drivers/leds/trigger/Makefile                 |   1 +
 drivers/leds/trigger/ledtrig-blkdev.c         | 770 ++++++++++++++++++
 include/linux/genhd.h                         |  13 +
 include/linux/leds.h                          |  20 +
 10 files changed, 1031 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-blkdev
 create mode 100644 Documentation/leds/ledtrig-blkdev.rst
 create mode 100644 drivers/leds/trigger/ledtrig-blkdev.c

-- 
2.31.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-08-19  2:51 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19  2:50 [RFC PATCH v3 00/18] Add block device LED trigger Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 01/18] docs: Add block device (blkdev) LED trigger documentation Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 02/18] block: Add get_disk_by_name() for use by blkdev LED trigger Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 03/18] ledtrig-blkdev: Add file (ledtrig-blkdev.c) for block device " Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 04/18] ledtrig-blkdev: Add misc. helper functions to blkdev " Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 05/18] ledtrig-blkdev: Periodically check devices for activity & blink LEDs Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 06/18] block: Add LED trigger pointer to struct gendisk Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 07/18] ledtrig-blkdev: Add function to initialize gendisk ledtrig member Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 08/18] ledtrig-blkdev: Add function to remove LED/device association Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 09/18] ledtrig-blkdev: Add function to disassociate a device from all LEDs Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 10/18] block: Call LED trigger init/cleanup functions Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 11/18] ledtrig-blkdev: Add function to associate a device with an LED Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 12/18] ledtrig-blkdev: Add sysfs attributes to [dis]associate LEDs & devices Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 13/18] ledtrig-blkdev: Add blink_time & interval sysfs attributes Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 14/18] ledtrig-blkdev: Add mode (read/write/rw) sysfs attributue Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 15/18] ledtrig-blkdev: Add function to associate blkdev trigger with LED Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 16/18] ledtrig-blkdev: Add function to disassociate an LED from the trigger Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 17/18] ledtrig-blkdev: Add initialization function Ian Pilcher
2021-08-19  2:50 ` [RFC PATCH v3 18/18] ledtrig-blkdev: Add config option to enable the trigger Ian Pilcher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).