From: Ian Pilcher <hidden> Date: 2021-08-09 03:32:54
This is a significant rewrite of the patchset that I originally posted
back on 28 July. It incorporates almost all of the suggestions that I
received as feedback to my original patchset (largely because I was
finally able to wrap my head around how complex LED triggers work).
One thing that has not changed is that associations between block
devices and LEDs are still set via an attribute on the device, rather
than the LED. This is much simpler, as the device attribute only has
to handle a single value (the name of the associated LED), rather than
potentially handling multiple device names.
More importantly, it avoids the need to iterate through all of the
block devices on the system, searching by name. This was proposed
fairly recently, and the reaction was not positive.[1][2]
I have modeled the interface for the /sys/block/<DEVICE>/led
attribute on the sysfs interface used for selecting a trigger. All
available LEDs (all LEDs associated with the blkdev trigger) are
shown when the attribute is read, with the currently selected LED
enclosed in square brackets ([]).
As before, this is all very new to me (particularly the RCU stuff), so
I welcome feedback.
Thanks!
Changes from the original patchset:
* Use a single complex LED trigger ("blkdev"), rather than multiple
user-defined triggers.
* Configurable blink time and interval for each LED:
/sys/class/leds/<LED>/blink_{on,off}
* Associated block devices linked from LED subdirectory:
/sys/class/leds/<LED>/block_devices
(Avoids violating the "one value per entry" sysfs rule.)
* Device-LED associations set via /sys/block/<DEVICE>/led
* Document all sysfs attributes in Documentation/ABI/testing (but also kept
the overview doc)
* Removed unnecessary [un]likely macros
* Reduced number of "user error" log messages and changed level to INFO
* More detailed commit messages
* Add Kconfig option in final commit
* Use RCU-protected pointer (rather than mutex)
* No in-kernel APIs for now
[1] https://www.spinics.net/lists/linux-leds/msg18256.html
[2] https://www.spinics.net/lists/linux-leds/msg18261.html
Ian Pilcher (10):
docs: Add block device LED trigger documentation
block: Add file (blk-ledtrig.c) for block device LED trigger
implementation
block: Add block device LED trigger fields to gendisk structure
block: Add functions to set & clear block device LEDs
block: Add block device sysfs attribute to set/clear/show LED
block: Add activate and deactivate functions for block device LED
trigger
block: Add sysfs attributes to LEDs associated with blkdev trigger
block: Add init function for block device LED trigger
block: Blink device LED (if any) when request is sent to its driver
block: Add config option to enable block device LED triggers
Documentation/ABI/testing/sysfs-block | 16 +
.../testing/sysfs-class-led-trigger-blkdev | 28 ++
Documentation/block/blk-ledtrig.rst | 79 +++
Documentation/block/index.rst | 1 +
block/Kconfig | 8 +
block/Makefile | 1 +
block/blk-ledtrig.c | 469 ++++++++++++++++++
block/blk-ledtrig.h | 45 ++
block/blk-mq.c | 2 +
block/genhd.c | 11 +
include/linux/genhd.h | 4 +
11 files changed, 664 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-blkdev
create mode 100644 Documentation/block/blk-ledtrig.rst
create mode 100644 block/blk-ledtrig.c
create mode 100644 block/blk-ledtrig.h
--
2.31.1
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
@@ -316,3 +316,19 @@ Description: does not complete in this time then the block driver timeout handler is invoked. That timeout handler can decide to retry the request, to fail it or to start a device recovery strategy.++What: /sys/block/<disk>/led+Date: August 2021+Contact: Ian Pilcher <arequipeno@gmail.com>+Description:+ Set the LED associated with this block device (or show available+ LEDs and the currently selected LED, if any).++ Reading the attribute will display the available LEDs (LEDs that+ are associated with the blkdev LED trigger). The currently+ selected LED is enclosed in square brackets. To clear the+ device's LED association write 'none' (without the quotes) or+ an empty string/line to the attribute.++ See Documentation/ABI/testing/sysfs-class-led-trigger-blkdev and+ Documentation/block/blk-ledtrig.rst.)
@@ -0,0 +1,28 @@+What: /sys/class/leds/<led>/blink_on+Date: August 2021+Contact: Ian Pilcher <arequipeno@gmail.com>+Description:+ Time (in milliseconds) that the LED will be on during a single+ "blink".++What: /sys/class/leds/<led>/blink_off+Date: August 2021+Contact: Ian Pilcher <arequipeno@gmail.com>+Description:+ Time (in milliseconds) that the LED will be off during a single+ "blink". Effectively the amount of time that the LED will be+ off before the next blink, when the associated block device(s)+ are continuously active.++What: /sys/class/leds/<led>/block_devices+Date: August 2021+Contact: Ian Pilcher <arequipeno@gmail.com>+Description:+ Directory containing links to all block devices that are+ associated with this LED.++ Once an LED has been associated with the blkdev trigger, a block+ device can be associated with that LED by writing the LED name+ to the device's /sys/[class/]block/<disk>/led attribute. (See+ Documentation/ABI/testing/sysfs-block and+ Documentation/block/blk-ledtrig.rst.)
@@ -0,0 +1,79 @@+.. SPDX-License-Identifier: GPL-2.0++=================================+Block Device (blkdev) LED Trigger+=================================++Available when ``CONFIG_BLK_LED_TRIGGERS=y``.++See also:++*``Documentation/ABI/testing/sysfs-class-led-trigger-blkdev``+*``Documentation/ABI/testing/sysfs-block`` (``/sys/block/<disk>/led``)++..note::+ The examples below use ``<LED>`` to refer to the name of a+ system-specific LED. If no suitable LED is available on a test+ system (in a virtual machine, for example), it is possible to+ use a userspace LED (``Documentation/leds/uleds.rst``).++Associate the LED with the ``blkdev`` LED trigger::++ # echo blkdev > /sys/class/leds/<LED>/trigger++ # cat /sys/class/leds/<LED>/trigger+ ... kbd-ctrlrlock [blkdev] disk-activity ...++Note that the ``blink_on`` and ``blink_off`` attributes have been added to the+LED, along with the ``block_devices`` subdirectory.++The LED is now available for association with block devices::++ # cat /sys/block/sda/led+ [none] <LED>++Associate the LED with the block device::++ # echo <LED> > /sys/block/sda/led++ # cat /sys/block/sda/led+ none [<LED>]++Reads and write activity on the device should cause the LED to blink. The+duration of each blink (in milliseconds) can be adjusted by setting+``/sys/class/leds/<LED>/blink_on``, and the minimum delay between blinks can+be set via ``/sys/class/leds/<LED>/blink_off``.++Associate a second device with the LED::++ # echo <LED> > /sys/block/sdb/led++ # cat /sys/block/sdb/led+ none [<LED>]++Note that both block devices are linked from the LED's ``block_devices``+subdirectory::++ # ls /sys/class/leds/<LED>/block_devices+ sda sdb++Other notes:++* Many types of block devices work with this trigger, including:++* SCSI (including SATA and USB) hard disk drives and SSDs+* SCSI (including SATA and USB) optical drives+* SD cards+* loopback block devices (``/dev/loop*``)++* NVMe SSDs and most virtual block devices can be associated with LEDs, but+ they will produce little or no LED activity.++* Multiple LEDs can be associated with the ``blkdev`` trigger; different block+ devices can be associated with different LEDs.++* This trigger causes associated LED(s) to blink (per the LED's ``blink_on``+ and ``blink_off`` attributes) when a request is sent to an associated+ block device's low-level driver. It does not track the duration (or+ result) of requests further. Thus, it provides an approximate visual+ indication of device activity, not an exact measurement.
From: Ian Pilcher <hidden> Date: 2021-08-09 03:32:58
Define data structure for all associated LEDs
Add list of associated LEDs and list search helper
Add trigger mutex - must be held when accessing trigger/LED or device/LED
associations
Signed-off-by: Ian Pilcher <redacted>
---
block/blk-ledtrig.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 block/blk-ledtrig.c
@@ -0,0 +1,48 @@+// SPDX-License-Identifier: GPL-2.0-only++/*+*BlockdeviceLEDtriggers+*+*Copyright2021IanPilcher<arequipeno@gmail.com>+*/++#include<linux/leds.h>+#include<linux/mutex.h>++/*+*+*TriggermutexandLEDlist+*+*/++// Must hold when doing anything with LED/trigger/block device+// associations+staticDEFINE_MUTEX(blk_ledtrig_mutex);++staticLIST_HEAD(blk_ledtrig_leds);++// Every LED associated with the blkdev trigger gets one of these+structblk_ledtrig_led{+structkobject*dir;// block_devices subdirectory+structled_classdev*led;+unsignedintblink_on;+unsignedintblink_off;+structlist_headleds_list_node;+structlist_headdev_list;+};++// Caller must hold blk_ledtrig_mutex+staticstructblk_ledtrig_led*blk_ledtrig_find(constchar*constled_name,+constsize_tname_len)+{+structblk_ledtrig_led*bd_led;++list_for_each_entry(bd_led,&blk_ledtrig_leds,leds_list_node){+if(strlen(bd_led->led->name)!=name_len)+continue;+if(memcmp(bd_led->led->name,led_name,name_len)==0)+returnbd_led;+}++returnNULL;+}
--
2.31.1
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Ian Pilcher <hidden> Date: 2021-08-09 03:33:04
Set up activated LED:
* Allocate per-LED data structure
* Add LED to list of LEDs associated with blkdev trigger
* Create block_devices subdirectory for links to associated devices
Clean up deactivated LED:
* Clear LED of any associated devices
* Remove from LED from blkdev trigger list
* Remove block_devices subdirectory
* Wait for any blinks using LED to complete (synchronize_rcu())
* Free per-LED structure
Signed-off-by: Ian Pilcher <redacted>
---
block/blk-ledtrig.c | 95 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
From: Ian Pilcher <hidden> Date: 2021-08-09 03:33:10
Create a symlink from /sys/class/leds/<LED>/block_devices to each block
device that is associated with that LED
Ensure device LED is cleared when device is removed
Signed-off-by: Ian Pilcher <redacted>
---
block/blk-ledtrig.c | 93 +++++++++++++++++++++++++++++++++++++++++++++
block/blk-ledtrig.h | 3 ++
block/genhd.c | 1 +
3 files changed, 97 insertions(+)
@@ -46,3 +50,92 @@ static struct blk_ledtrig_led *blk_ledtrig_find(const char *const led_name,returnNULL;}+++/*+*+*Clearablockdevice'sLED+*+*/++// Also called from blk_ledtrig_dev_set()+staticvoidblk_ledtrig_dev_cleanup(structgendisk*constdisk,+structblk_ledtrig_led*constold_led)+{+sysfs_remove_link(old_led->dir,disk->disk_name);+list_del(&disk->led_dev_list_node);+}++// Also called from blk_ledtrig_deactivate()+staticvoidblk_ledtrig_dev_clear_locked(structgendisk*constdisk,+structblk_ledtrig_led*constold_led)+{+RCU_INIT_POINTER(disk->led,NULL);+if(old_led!=NULL)+blk_ledtrig_dev_cleanup(disk,old_led);+}++// Also called from genhd.c:del_gendisk()+voidblk_ledtrig_dev_clear(structgendisk*constdisk)+{+structblk_ledtrig_led*old_led;++mutex_lock(&blk_ledtrig_mutex);+old_led=rcu_dereference_protected(disk->led,+lockdep_is_held(&blk_ledtrig_mutex));+blk_ledtrig_dev_clear_locked(disk,old_led);+mutex_unlock(&blk_ledtrig_mutex);+}+++/*+*+*Setablockdevice'sLED+*+*/++staticintblk_ledtrig_dev_set(structgendisk*constdisk,+constchar*constled_name,+constsize_tname_len)+{+structblk_ledtrig_led*new_led,*old_led;+intret;++ret=mutex_lock_interruptible(&blk_ledtrig_mutex);+if(ret!=0)+gotoled_set_exit_return;++new_led=blk_ledtrig_find(led_name,name_len);+if(new_led==NULL){+pr_info("no LED named %.*s associated with blkdev trigger\n",+(int)name_len,led_name);+ret=-ENODEV;+gotoled_set_exit_unlock;+}++old_led=rcu_dereference_protected(disk->led,+lockdep_is_held(&blk_ledtrig_mutex));++if(old_led==new_led){+ret=0;+gotoled_set_exit_unlock;+}++ret=sysfs_create_link(new_led->dir,&disk_to_dev(disk)->kobj,+disk->disk_name);+if(ret!=0)+gotoled_set_exit_unlock;++if(old_led!=NULL)+blk_ledtrig_dev_cleanup(disk,old_led);++rcu_assign_pointer(disk->led,new_led);+list_add(&disk->led_dev_list_node,&new_led->dev_list);++ret=0;++led_set_exit_unlock:+mutex_unlock(&blk_ledtrig_mutex);+led_set_exit_return:+returnret;+}
From: Ian Pilcher <hidden> Date: 2021-08-09 03:33:12
Add show & store functions in blk-ledtrig.c (attributes defined in genhd.c)
Show function shows all available LEDs (LEDs associated with blkdev trigger);
currently associated LED is shown in square brackets ([])
Store function accepts either all whitespace or "none" to clear LED
Signed-off-by: Ian Pilcher <redacted>
---
block/blk-ledtrig.c | 109 ++++++++++++++++++++++++++++++++++++++++++++
block/blk-ledtrig.h | 8 ++++
block/genhd.c | 8 ++++
3 files changed, 125 insertions(+)
@@ -139,3 +140,111 @@ static int blk_ledtrig_dev_set(struct gendisk *const disk,led_set_exit_return:returnret;}+++/*+*+*sysfsattributestorefunctiontosetorcleardeviceLED+*+*/++// Returns a pointer to the first non-whitespace character in s (or a pointer+// to the terminating null).+staticconstchar*blk_ledtrig_skip_whitespace(constchar*s)+{+while(*s!=0&&isspace(*s))+++s;++returns;+}++// Returns a pointer to the first whitespace character in s (or a pointer to+// the terminating null), which is effectively a pointer to the position *after*+// the last character in the non-whitespace token at the beginning of s. (s is+// expected to be the result of a previous call to blk_ledtrig_skip_whitespace.)+staticconstchar*blk_ledtrig_find_whitespace(constchar*s)+{+while(*s!=0&&!isspace(*s))+++s;++returns;+}++staticboolblk_ledtrig_name_is_none(constchar*constname,constsize_tlen)+{+staticconstcharnone[4]="none";// no terminating null++returnlen==sizeof(none)&&memcmp(name,none,sizeof(none))==0;+}++ssize_tblk_ledtrig_dev_led_store(structdevice*constdev,+structdevice_attribute*constattr,+constchar*constbuf,constsize_tcount)+{+structgendisk*constdisk=dev_to_disk(dev);+constchar*constled_name=blk_ledtrig_skip_whitespace(buf);+constchar*constendp=blk_ledtrig_find_whitespace(led_name);+constptrdiff_tname_len=endp-led_name;// always >= 0+intret;++if(name_len==0||blk_ledtrig_name_is_none(led_name,name_len)){+blk_ledtrig_dev_clear(disk);+ret=0;+}else{+ret=blk_ledtrig_dev_set(disk,led_name,name_len);+}++if(ret<0)+returnret;++returncount;+}+++/*+*+*sysfsattributeshowfunctionfordeviceLED+*+*/++ssize_tblk_ledtrig_dev_led_show(structdevice*constdev,+structdevice_attribute*constattr,+char*constbuf)+{+structgendisk*constdisk=dev_to_disk(dev);+structblk_ledtrig_led*bd_led,*disk_led;+intret,c=0;++ret=mutex_lock_interruptible(&blk_ledtrig_mutex);+if(ret!=0)+gotoled_show_exit_return;++disk_led=rcu_dereference_protected(disk->led,+lockdep_is_held(&blk_ledtrig_mutex));++if(disk_led==NULL)+c+=sprintf(buf,"[none]");+else+c+=sprintf(buf,"none");++list_for_each_entry(bd_led,&blk_ledtrig_leds,leds_list_node){++ret=snprintf(buf+c,PAGE_SIZE-c-1,+bd_led==disk_led?" [%s]":" %s",+bd_led->led->name);+if(ret>=PAGE_SIZE-c-1){+ret=-EOVERFLOW;+gotoled_show_exit_unlock;+}++c+=ret;+}++buf[c]='\n';+ret=c+1;++led_show_exit_unlock:+mutex_unlock(&blk_ledtrig_mutex);+led_show_exit_return:+returnret;+}
From: Ian Pilcher <hidden> Date: 2021-08-09 03:33:14
Add blink_on & blink_off attributes to control the duration of each LED blink
(blink_on) and the minimum time between blinks (blink_off) in milliseconds
Signed-off-by: Ian Pilcher <redacted>
---
block/blk-ledtrig.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
From: Jackie Liu <hidden> Date: 2021-08-09 04:21:55
�� 2021/8/9 ����11:32, Ian Pilcher ����:
quoted hunk
Add show & store functions in blk-ledtrig.c (attributes defined in genhd.c)
Show function shows all available LEDs (LEDs associated with blkdev trigger);
currently associated LED is shown in square brackets ([])
Store function accepts either all whitespace or "none" to clear LED
Signed-off-by: Ian Pilcher <redacted>
---
block/blk-ledtrig.c | 109 ++++++++++++++++++++++++++++++++++++++++++++
block/blk-ledtrig.h | 8 ++++
block/genhd.c | 8 ++++
3 files changed, 125 insertions(+)
@@ -139,3 +140,111 @@ static int blk_ledtrig_dev_set(struct gendisk *const disk,led_set_exit_return:returnret;}+++/*+*+*sysfsattributestorefunctiontosetorcleardeviceLED+*+*/++// Returns a pointer to the first non-whitespace character in s (or a pointer+// to the terminating null).+staticconstchar*blk_ledtrig_skip_whitespace(constchar*s)+{+while(*s!=0&&isspace(*s))+++s;++returns;+}++// Returns a pointer to the first whitespace character in s (or a pointer to+// the terminating null), which is effectively a pointer to the position *after*+// the last character in the non-whitespace token at the beginning of s. (s is+// expected to be the result of a previous call to blk_ledtrig_skip_whitespace.)
From: Ian Pilcher <hidden> Date: 2021-08-09 15:44:14
On 8/8/21 11:21 PM, Jackie Liu wrote:
quoted
+// Returns a pointer to the first whitespace character in s (or a pointer to
+// the terminating null), which is effectively a pointer to the position *after*
+// the last character in the non-whitespace token at the beginning of s. (s is
+// expected to be the result of a previous call to blk_ledtrig_skip_whitespace.)
These are not linux kernel style comments.
Do you mean kernel-doc comments? If so, they're not supposed to be, as
the functions are not exported.
--
========================================================================
In Soviet Russia, Google searches you!
========================================================================
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Marek Behún <kabel@kernel.org> Date: 2021-08-09 18:56:52
Hello Ian,
thank you for your proposal. Some comments below:
On Sun, 8 Aug 2021 22:32:07 -0500
Ian Pilcher [off-list ref] wrote:
One thing that has not changed is that associations between block
devices and LEDs are still set via an attribute on the device, rather
than the LED. This is much simpler, as the device attribute only has
to handle a single value (the name of the associated LED), rather than
potentially handling multiple device names.
It may be simpler, but it is in contrast to how the netdev trigger
works, which already is in upstream for many years. I really think we
should try to have similar sysfs ABIs here. (I understand that the
netdev trigger is currently unable to handle multiple network
interfaces - but it is possible to extend it so.)
I have modeled the interface for the /sys/block/<DEVICE>/led
attribute on the sysfs interface used for selecting a trigger. All
available LEDs (all LEDs associated with the blkdev trigger) are
shown when the attribute is read, with the currently selected LED
enclosed in square brackets ([]).
I think it is reasonable to be able to set something like this:
led0 : blink on activity on any of [sda, sdb, sdc]
led1 : blink on activity on sda
led2 : blink on activity on sdb
led3 : blink on activity on sdc
If I am reading your code correctly, it looks that only one LED can be
configured for a block device. Is this true? If so, then the above
configuration cannot be set.
Also you are blinking the LED on any request to the block device. I
would rather expect to be able to set the LED to blink on read and on
write. (And possibly on other functions, like discard, or critical
temperature, or error, ...) I would like to know what other people
think about this.
Marek
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Monday 09 August 2021 20:56:33 Marek Behún wrote:
Hello Ian,
thank you for your proposal. Some comments below:
On Sun, 8 Aug 2021 22:32:07 -0500
Ian Pilcher [off-list ref] wrote:
quoted
One thing that has not changed is that associations between block
devices and LEDs are still set via an attribute on the device, rather
than the LED. This is much simpler, as the device attribute only has
to handle a single value (the name of the associated LED), rather than
potentially handling multiple device names.
It may be simpler, but it is in contrast to how the netdev trigger
works, which already is in upstream for many years. I really think we
should try to have similar sysfs ABIs here. (I understand that the
netdev trigger is currently unable to handle multiple network
interfaces - but it is possible to extend it so.)
quoted
I have modeled the interface for the /sys/block/<DEVICE>/led
attribute on the sysfs interface used for selecting a trigger. All
available LEDs (all LEDs associated with the blkdev trigger) are
shown when the attribute is read, with the currently selected LED
enclosed in square brackets ([]).
I think it is reasonable to be able to set something like this:
led0 : blink on activity on any of [sda, sdb, sdc]
led1 : blink on activity on sda
led2 : blink on activity on sdb
led3 : blink on activity on sdc
If I am reading your code correctly, it looks that only one LED can be
configured for a block device. Is this true? If so, then the above
configuration cannot be set.
Also you are blinking the LED on any request to the block device. I
would rather expect to be able to set the LED to blink on read and on
write. (And possibly on other functions, like discard, or critical
temperature, or error, ...) I would like to know what other people
think about this.
Hello!
HP EliteBook laptops had dedicated LED for some kind of error and
encryption indication. And there is kernel acpi/wmi driver which can
control this LED. I do not know if recent HP laptops still have these
LEDs, but I would suggest to design API in a way that would allow to use
these dedicated LEDs for their original "vendor" purpose.
I'm mentioning it just because this functionality and design is already
on existing production mainstream laptops, and not something imaginary.
If Linux distributions are still cooperating with laptop vendors and
doing "official" Linux preloads then they may be interested in having
"native" LED functionality support in kernel.
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Ian Pilcher <hidden> Date: 2021-08-09 19:54:31
Marek -
Thanks for taking the time to look at this.
On 8/9/21 1:56 PM, Marek Behún wrote:
It may be simpler, but it is in contrast to how the netdev trigger
works, which already is in upstream for many years. I really think we
should try to have similar sysfs ABIs here. (I understand that the
netdev trigger is currently unable to handle multiple network
interfaces - but it is possible to extend it so.)
I'm not unalterably opposed to the idea, but I don't currently see a way
to do that without resolving block devices (struct gendisk) by name, and
that seems to be a no-no.
If you (or anyone else) has a suggestion on how to get around this
obstacle, I'd be willing to give it a shot.
I think it is reasonable to be able to set something like this:
led0 : blink on activity on any of [sda, sdb, sdc]
led1 : blink on activity on sda
led2 : blink on activity on sdb
led3 : blink on activity on sdc
If I am reading your code correctly, it looks that only one LED can be
configured for a block device. Is this true? If so, then the above
configuration cannot be set.
You're correct that it's not possible with the current code. Multiple
devices can be associated to with a single LED, but there's not
currently a way to drive more than 1 LED from a single device. This
is something that could be changed.
Also you are blinking the LED on any request to the block device. I
would rather expect to be able to set the LED to blink on read and on
write. (And possibly on other functions, like discard, or critical
temperature, or error, ...) I would like to know what other people
think about this.
I wanted to keep things as simple as possible for now. I don't think
that there's any particular reason that separated LEDs couldn't be
configured for read and write requests. (It looks like it should be
pretty easy to distinguish reads vs writes in a struct request.)
My feeling is that things like temperature, errors, etc. are better
monitored from user space, as they tend to require actively querying
the drive.
Like you, I'm interested in knowing if there is actually hardware out
there that has separate read/write LEDs.
All in all, I feel like I should be able to implement almost everything
that you've suggested, *if* I can figure out the block device lookup
issue, but I really don't have any ideas on that.
Thanks for your patience and feedback!
--
========================================================================
In Soviet Russia, Google searches you!
========================================================================
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Marek Behún <kabel@kernel.org> Date: 2021-08-09 22:43:51
On Mon, 9 Aug 2021 14:54:26 -0500
Ian Pilcher [off-list ref] wrote:
I'm not unalterably opposed to the idea, but I don't currently see a way
to do that without resolving block devices (struct gendisk) by name, and
that seems to be a no-no.
So a name like "sda1" is not viable? Why? What about "MAJOR:MINOR"?
I confess that I am not very familiar with internal blkdev API.
Quick look reveals that there is a struct block_device, containing a
member bd_disk, which is a pointer to struct gendisk.
What is the relationship between these two? Can there be a block device
without a gendisk, for example?
Marek
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Ian Pilcher <hidden> Date: 2021-08-09 23:50:49
On 8/9/21 5:43 PM, Marek Behún wrote:
I confess that I am not very familiar with internal blkdev API.
It's mainly a matter of symbol visibility. See this thread from a few
months ago:
https://www.spinics.net/lists/linux-leds/msg18244.html
Now ... my code currently lives in block/, so there isn't actually
anything technically preventing it from iterating through the block
devices.
The reactions to Enzo's patch (which you can see in that thread) make me
think that anything that iterates through all block devices is likely to
be rejected, but maybe I'm reading too much into it.
Greg / Christoph -
(As you were the people who expressed disapproval of Enzo's patch to
export block_class and disk_type ...)
Can you weigh in on the acceptability of iterating through the block
devices (searching by name) from LED trigger code within the block
subsystem (i.e. no new symbols would need to be exported)?
This would allow the trigger to implement the sysfs API that Marek and
Pavel want.
Thanks!
--
========================================================================
In Soviet Russia, Google searches you!
========================================================================
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Mon, Aug 09, 2021 at 06:50:44PM -0500, Ian Pilcher wrote:
On 8/9/21 5:43 PM, Marek Behún wrote:
quoted
I confess that I am not very familiar with internal blkdev API.
It's mainly a matter of symbol visibility. See this thread from a few
months ago:
https://www.spinics.net/lists/linux-leds/msg18244.html
Now ... my code currently lives in block/, so there isn't actually
anything technically preventing it from iterating through the block
devices.
The reactions to Enzo's patch (which you can see in that thread) make me
think that anything that iterates through all block devices is likely to
be rejected, but maybe I'm reading too much into it.
Greg / Christoph -
(As you were the people who expressed disapproval of Enzo's patch to
export block_class and disk_type ...)
Can you weigh in on the acceptability of iterating through the block
devices (searching by name) from LED trigger code within the block
subsystem (i.e. no new symbols would need to be exported)?
This would allow the trigger to implement the sysfs API that Marek and
Pavel want.
No idea, let's see the change first, we can never promise anything :)
thanks,
greg k-h
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Marek Behún <kabel@kernel.org> Date: 2021-08-10 13:39:54
On Tue, 10 Aug 2021 08:35:08 +0200
Greg KH [off-list ref] wrote:
On Mon, Aug 09, 2021 at 06:50:44PM -0500, Ian Pilcher wrote:
quoted
On 8/9/21 5:43 PM, Marek Behún wrote:
quoted
I confess that I am not very familiar with internal blkdev API.
It's mainly a matter of symbol visibility. See this thread from a few
months ago:
https://www.spinics.net/lists/linux-leds/msg18244.html
Now ... my code currently lives in block/, so there isn't actually
anything technically preventing it from iterating through the block
devices.
The reactions to Enzo's patch (which you can see in that thread) make me
think that anything that iterates through all block devices is likely to
be rejected, but maybe I'm reading too much into it.
Greg / Christoph -
(As you were the people who expressed disapproval of Enzo's patch to
export block_class and disk_type ...)
Can you weigh in on the acceptability of iterating through the block
devices (searching by name) from LED trigger code within the block
subsystem (i.e. no new symbols would need to be exported)?
This would allow the trigger to implement the sysfs API that Marek and
Pavel want.
No idea, let's see the change first, we can never promise anything :)
Hi Greg,
Can't we use blkdev_get_by_path() (or blk_lookup_devt() with
blkdev_get_by_dev())?
This would open the block device and return a struct block_device *.
When the LED trigger is disabled, it would also have to release the
device.
Marek
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Pavel Machek <hidden> Date: 2021-08-10 13:49:14
Hi!
quoted hunk
+++ b/Documentation/ABI/testing/sysfs-block
@@ -316,3 +316,19 @@ Description: does not complete in this time then the block driver timeout handler is invoked. That timeout handler can decide to retry the request, to fail it or to start a device recovery strategy.++What: /sys/block/<disk>/led+Date: August 2021+Contact: Ian Pilcher <arequipeno@gmail.com>+Description:+ Set the LED associated with this block device (or show available+ LEDs and the currently selected LED, if any).++ Reading the attribute will display the available LEDs (LEDs that+ are associated with the blkdev LED trigger). The currently+ selected LED is enclosed in square brackets. To clear the+ device's LED association write 'none' (without the quotes) or+ an empty string/line to the attribute.++ See Documentation/ABI/testing/sysfs-class-led-trigger-blkdev and+ Documentation/block/blk-ledtrig.rst.)
On Tue, Aug 10, 2021 at 03:38:40PM +0200, Marek Behún wrote:
On Tue, 10 Aug 2021 08:35:08 +0200
Greg KH [off-list ref] wrote:
quoted
On Mon, Aug 09, 2021 at 06:50:44PM -0500, Ian Pilcher wrote:
quoted
On 8/9/21 5:43 PM, Marek Behún wrote:
quoted
I confess that I am not very familiar with internal blkdev API.
It's mainly a matter of symbol visibility. See this thread from a few
months ago:
https://www.spinics.net/lists/linux-leds/msg18244.html
Now ... my code currently lives in block/, so there isn't actually
anything technically preventing it from iterating through the block
devices.
The reactions to Enzo's patch (which you can see in that thread) make me
think that anything that iterates through all block devices is likely to
be rejected, but maybe I'm reading too much into it.
Greg / Christoph -
(As you were the people who expressed disapproval of Enzo's patch to
export block_class and disk_type ...)
Can you weigh in on the acceptability of iterating through the block
devices (searching by name) from LED trigger code within the block
subsystem (i.e. no new symbols would need to be exported)?
This would allow the trigger to implement the sysfs API that Marek and
Pavel want.
No idea, let's see the change first, we can never promise anything :)
Hi Greg,
Can't we use blkdev_get_by_path() (or blk_lookup_devt() with
blkdev_get_by_dev())?
This would open the block device and return a struct block_device *.
When the LED trigger is disabled, it would also have to release the
device.
But what about when the device is removed from the system first? Be
careful about that...
Anyway, sure, try those functions, I really do not know, all I
originally complained about was those exports which did not need to be
exported.
thanks,
greg k-h
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Ian Pilcher <hidden> Date: 2021-08-10 15:55:38
On 8/10/21 9:48 AM, Greg KH wrote:
But what about when the device is removed from the system first? Be
careful about that...
Anyway, sure, try those functions, I really do not know, all I
originally complained about was those exports which did not need to be
exported.
Sounds good. I'll work something up. (I'm actually thinking that
class_find_device() may be the best way to go, as it grabs a reference
to the device.)
--
========================================================================
In Soviet Russia, Google searches you!
========================================================================
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Tue, Aug 10, 2021 at 10:55:33AM -0500, Ian Pilcher wrote:
On 8/10/21 9:48 AM, Greg KH wrote:
quoted
But what about when the device is removed from the system first? Be
careful about that...
Anyway, sure, try those functions, I really do not know, all I
originally complained about was those exports which did not need to be
exported.
Sounds good. I'll work something up. (I'm actually thinking that
class_find_device() may be the best way to go, as it grabs a reference
to the device.)
There should not be anything "odd" about block devices here, just do
whatever all other LED drivers do when referencing a device.
thanks,
greg k-h
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Marek Behún <kabel@kernel.org> Date: 2021-08-10 16:39:27
On Tue, 10 Aug 2021 18:24:12 +0200
Greg KH [off-list ref] wrote:
quoted
Sounds good. I'll work something up. (I'm actually thinking that
class_find_device() may be the best way to go, as it grabs a reference
to the device.)
There should not be anything "odd" about block devices here, just do
whatever all other LED drivers do when referencing a device.
From: Ian Pilcher <hidden> Date: 2021-08-10 16:43:57
On 8/10/21 11:24 AM, Greg KH wrote:
There should not be anything "odd" about block devices here, just do
whatever all other LED drivers do when referencing a device.
AFAIK, the only LED trigger that does anything similar is the netdev
trigger. It uses dev_get_by_name(), which is specific to network
devices.
The block subsystem doesn't appear to have any similar API, which is
why Enzo submitted his patch to export block_class and disk_type back
in April[1], when he wanted to do something similar.
I'm basically bypassing the need to export the symbols, because my
trigger code is actually in the block subsystem, rather than the LEDs
subsystem.
[1] https://www.spinics.net/lists/linux-leds/msg18244.html
--
========================================================================
In Soviet Russia, Google searches you!
========================================================================
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Christoph Hellwig <hch@lst.de> Date: 2021-08-11 06:26:48
On Mon, Aug 09, 2021 at 06:50:44PM -0500, Ian Pilcher wrote:
On 8/9/21 5:43 PM, Marek Behún wrote:
quoted
I confess that I am not very familiar with internal blkdev API.
It's mainly a matter of symbol visibility. See this thread from a few
months ago:
https://www.spinics.net/lists/linux-leds/msg18244.html
Now ... my code currently lives in block/, so there isn't actually
anything technically preventing it from iterating through the block
devices.
The reactions to Enzo's patch (which you can see in that thread) make me
think that anything that iterates through all block devices is likely to
be rejected, but maybe I'm reading too much into it.
I think the main issue with this series is that it adds a shitload of
code and a hook in the absolute I/O fastpath for fricking blinkenlights.
I don't think it is even worth wasting time on something this ridiculous.
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
From: Marek Behún <kabel@kernel.org> Date: 2021-08-11 10:51:19
On Wed, 11 Aug 2021 08:26:42 +0200
Christoph Hellwig [off-list ref] wrote:
On Mon, Aug 09, 2021 at 06:50:44PM -0500, Ian Pilcher wrote:
quoted
On 8/9/21 5:43 PM, Marek Behún wrote:
quoted
I confess that I am not very familiar with internal blkdev API.
It's mainly a matter of symbol visibility. See this thread from a few
months ago:
https://www.spinics.net/lists/linux-leds/msg18244.html
Now ... my code currently lives in block/, so there isn't actually
anything technically preventing it from iterating through the block
devices.
The reactions to Enzo's patch (which you can see in that thread) make me
think that anything that iterates through all block devices is likely to
be rejected, but maybe I'm reading too much into it.
I think the main issue with this series is that it adds a shitload of
code and a hook in the absolute I/O fastpath for fricking blinkenlights.
I don't think it is even worth wasting time on something this ridiculous.
That's why I think we should do this the way the netdev trigger does.
Periodically reading block_device's stats, and if they are greater,
blink the LED.
Marek
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies