Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1149775rwe; Thu, 1 Sep 2022 13:23:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR4u6eEsjFlsz1QVS5wRC1KazNDkBZp1fgjd4RKJ3lqlEFDmNLJJv7MsE9k5ooUj07F9zO96 X-Received: by 2002:a17:907:9712:b0:731:67db:1b48 with SMTP id jg18-20020a170907971200b0073167db1b48mr24797006ejc.754.1662063811132; Thu, 01 Sep 2022 13:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662063811; cv=none; d=google.com; s=arc-20160816; b=GKGlJhc5Zw8ywX93uknYI2Rr1Mz9zdxrFUU8WoLQkb0FH9XEb0IC0AjjdQasQqLPsd 96tLz5LgVqQ93ylJv/CO73iotN9p3xeZRYFPcVtARmKoktQxAmiYFN1UqkfaWtVvjCto 3AS+P/IoAK7d1p/zTBY2h5juuY/3Gxa4DBKvAhav8McNxgcTSYMjAF9Z7kDT/BuGgupH DCI5LiVnGyKnSwSODd1e3+UqDk0lMy9TDgw8M27O7odOuIYQE0duco1oAht6AeZEnma+ 0iIfQwiBieetsMhR3QXrtmhdBBTlUdeVCMN/5r50iYYSTIvHaMehzcoxXgPGIYhszhX/ +hZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yDHzEYFqAKf8wDX5bZiEmg0+i6WsMr7NDvxZECaRGFg=; b=qwd9doJEh6NFAhi05uqAlR9IGTZTNj/D59LEP2nLFil5Nhf4QYRuBYNXcGD+64Y03f SlM4Gv9NulYKjLrQETlv+/DzutOBIquo7KiqjJw7sCU4adYIq6AhvknxldBk9Y/fsiA+ JI0w5XbDd+LkDMDbEROccvid85yhGqrFMe63Ei9Htvh17TtXUT31hTdkjIw3v/4WazQQ Zbs+aywl2MTRfyCRg/sqgvcdUXKWBcp+xzdP28+rskFWfYCPFUzro9dFviYIv42vTFRh rjbqF3JDcIdKzgL6x8JatmbhhoNM49dHr5yEBWxET7ntlJdwGVSTi+TFlxa53aC9Zplj qmkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XwbBVLCC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a05640226cc00b00446fdce2a62si70438edd.420.2022.09.01.13.22.55; Thu, 01 Sep 2022 13:23:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XwbBVLCC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234499AbiIATk7 (ORCPT + 99 others); Thu, 1 Sep 2022 15:40:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233652AbiIATk4 (ORCPT ); Thu, 1 Sep 2022 15:40:56 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BFF242AEF; Thu, 1 Sep 2022 12:40:55 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 6-20020a9d0106000000b0063963134d04so38893otu.3; Thu, 01 Sep 2022 12:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=yDHzEYFqAKf8wDX5bZiEmg0+i6WsMr7NDvxZECaRGFg=; b=XwbBVLCC4oOoUR6PqROVU/E5/I2lBrkSxhphBOtb1WwdUjHdHH/sO8l6AgjCf6oGBX q+LHD5M4UrEqNOmZwjLMVaOT0WTKu4PgdtQf7e51UfrqKQI0lkSKMc9qywvMXuNWUW71 1L+OzdMhCF5790o+xGGNDuKj3G/yvGgR5u7iPiB/NsdMuokSrV+zciNyByo9274ow/9x eD4NSmMQHbp8F/S5P1QYl2rM9hQQlEcraqh14412NOjcI8aeayzFA67ygdV8F2lIIwaK onaNfeg6jOgBLzrkMhVXO8E4GhIMvNqGKvHsxJpEyF2s3ly7Gl9xiguNKNlIEq8dcBux w3Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=yDHzEYFqAKf8wDX5bZiEmg0+i6WsMr7NDvxZECaRGFg=; b=cyGEgvs8cf57d4ysZET9VcL7SObLi7q/ID9Kbgjo6MWBWtL9jnV+goA+p2rcnBBMd6 yjze8B+dRYA5GB+l1osGSan16s5U5zzY9hdUgtGirrldlN2iff5EPDMtgktWVluOfHk1 pT5kD0qZF/+iUNQMhjQvI6c/yAas2jCNBI5yO5kOXgmXuPk+V+nXToN5uy3e1mKMx9RO lij+te9XsN0l5g0YLVz/qSm2XNJhQjLLIu8nbUDwCGLx4igRy4UKzB6Ha23/QS1qEKWR HFkQvm5NJ1A0becPADX92C3myQOg/KwhvHkulFqwZ5GFo8KYHDvlAh872O3NLy/16At7 Fm9g== X-Gm-Message-State: ACgBeo1dbatfn8VjkU2+zkFUfDD8BluwAqXk54k973i/H7gJhdqqdHMF bZm0vhNKocOFrx+c0T2WT4A= X-Received: by 2002:a05:6830:4ce:b0:638:f7cb:2f80 with SMTP id s14-20020a05683004ce00b00638f7cb2f80mr12759200otd.172.1662061254337; Thu, 01 Sep 2022 12:40:54 -0700 (PDT) Received: from ian.penurio.us ([47.184.51.90]) by smtp.gmail.com with ESMTPSA id z125-20020aca3383000000b00326cb6225f8sm39989oiz.44.2022.09.01.12.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 12:40:54 -0700 (PDT) From: Ian Pilcher To: pavel@ucw.cz Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, kabel@kernel.org, lee.jones@linaro.org Subject: [PATCH v10 1/2] docs: Add block device (blkdev) LED trigger documentation Date: Thu, 1 Sep 2022 14:40:50 -0500 Message-Id: <20220901194051.1116975-2-arequipeno@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220901194051.1116975-1-arequipeno@gmail.com> References: <20220901194051.1116975-1-arequipeno@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Documentation/ABI/testing/sysfs-class-led-trigger-blkdev to document: * /sys/class/leds//blink_time * /sys/class/leds//check_interval * /sys/class/leds//blink_on_{read,write,discard,flush} * /sys/class/leds//link_dev_by_path * /sys/class/leds//unlink_dev_by_path * /sys/class/leds//linked_devices Add /sys/block//linked_leds to Documentation/ABI/stable/sysfs-block. Add overview in Documentation/leds/ledtrig-blkdev.rst. Signed-off-by: Ian Pilcher --- Documentation/ABI/stable/sysfs-block | 10 ++ .../testing/sysfs-class-led-trigger-blkdev | 68 ++++++++ Documentation/leds/index.rst | 1 + Documentation/leds/ledtrig-blkdev.rst | 155 ++++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-trigger-blkdev create mode 100644 Documentation/leds/ledtrig-blkdev.rst diff --git a/Documentation/ABI/stable/sysfs-block b/Documentation/ABI/stable/sysfs-block index cd14ecb3c9a5..d11d04d804fe 100644 --- a/Documentation/ABI/stable/sysfs-block +++ b/Documentation/ABI/stable/sysfs-block @@ -101,6 +101,16 @@ Description: devices that support receiving integrity metadata. +What: /sys/block//linked_leds +Date: September 2022 +Contact: Ian Pilcher +Description: + Directory that contains symbolic links to all LEDs that + are associated with (linked to) this block device by the + blkdev LED trigger. Only present when at least one LED + is linked. (See Documentation/leds/ledtrig-blkdev.rst.) + + What: /sys/block///alignment_offset Date: April 2009 Contact: Martin K. Petersen diff --git a/Documentation/ABI/testing/sysfs-class-led-trigger-blkdev b/Documentation/ABI/testing/sysfs-class-led-trigger-blkdev new file mode 100644 index 000000000000..d8d403569b21 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-led-trigger-blkdev @@ -0,0 +1,68 @@ +What: /sys/class/leds//blink_time +Date: September 2022 +Contact: Ian Pilcher +Description: + Time (in milliseconds) that the LED will be on during a single + "blink". + +What: /sys/class/leds//check_interval +Date: September 2022 +Contact: Ian Pilcher +Description: + Frequency (in milliseconds) with which block devices linked to + this LED will be checked for activity and the LED will + (potentially) be blinked. + +What: /sys/class/leds//blink_on_read +Date: September 2022 +Contact: Ian Pilcher +Description: + Boolean that determines whether the LED will blink in response + to read activity on any of its linked block devices. + +What: /sys/class/leds//blink_on_write +Date: September 2022 +Contact: Ian Pilcher +Description: + Boolean that determines whether the LED will blink in response + to write activity on any of its linked block devices. + +What: /sys/class/leds//blink_on_discard +Date: September 2022 +Contact: Ian Pilcher +Description: + Boolean that determines whether the LED will blink in response + to discard activity on any of its linked block devices. + +What: /sys/class/leds//blink_on_flush +Date: September 2022 +Contact: Ian Pilcher +Description: + Boolean that determines whether the LED will blink in response + to cache flush activity on any of its linked block devices. + +What: /sys/class/leds//link_dev_by_path +Date: September 2022 +Contact: Ian Pilcher +Description: + Associate a block device with this LED by writing the path to + the device special file (e.g. /dev/sda) to this attribute. + Symbolic links are followed. + +What: /sys/class/leds//unlink_dev_by_path +Date: September 2022 +Contact: Ian Pilcher +Description: + Remove the association between this LED and a block device by + writing the path to the device special file (e.g. /dev/sda) to + this attribute. Symbolic links are followed. + +What: /sys/class/leds//linked_devices +Date: September 2022 +Contact: Ian Pilcher +Description: + Directory containing links to all block devices that are + associated with this LED. (Note that the names of the + symbolic links in this directory are *kernel* names, which + may not match the device special file paths written to + link_device and unlink_device.) diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst index e5d63b940045..e3c24e468cbc 100644 --- a/Documentation/leds/index.rst +++ b/Documentation/leds/index.rst @@ -10,6 +10,7 @@ LEDs leds-class leds-class-flash leds-class-multicolor + ledtrig-blkdev ledtrig-oneshot ledtrig-transient ledtrig-usbport diff --git a/Documentation/leds/ledtrig-blkdev.rst b/Documentation/leds/ledtrig-blkdev.rst new file mode 100644 index 000000000000..ae92aa559257 --- /dev/null +++ b/Documentation/leds/ledtrig-blkdev.rst @@ -0,0 +1,155 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================= +Block Device (blkdev) LED Trigger +================================= + +Available when ``CONFIG_LEDS_TRIGGER_BLKDEV=y`` or +``CONFIG_LEDS_TRIGGER_BLKDEV=m``. + +See also: + +* ``Documentation/ABI/testing/sysfs-class-led-trigger-blkdev`` +* ``Documentation/ABI/stable/sysfs-block`` (``/sys/block//linked_leds``) + +Overview +======== + +.. note:: + The examples below use ```` 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. (See ``Documentation/leds/uleds.rst``.) + +Verify that the ``blkdev`` LED trigger is available:: + + # grep blkdev /sys/class/leds//trigger + ... rfkill-none blkdev + +(If the previous command produces no output, you may need to load the trigger +module - ``modprobe ledtrig_blkdev``. If the module is not available, check +the value of ``CONFIG_LEDS_TRIGGER_BLKDEV`` in your kernel configuration.) + +Associate the LED with the ``blkdev`` LED trigger:: + + # echo blkdev > /sys/class/leds//trigger + + # cat /sys/class/leds//trigger + ... rfkill-none [blkdev] + +Note that several new device attributes are available in the +``/sys/class/leds/`` directory. + +* ``link_dev_by_path`` and ``unlink_dev_by_path`` are used to manage the set of + block devices associated with this LED. The LED will blink in response to + read or write activity on its linked devices. + +* ``blink_on_read``, ``blink_on_write``, ``blink_on_discard``, and + ``blink_on_flush`` are boolean values that determine whether the LED will + blink when a particular type of activity is detected on one of its linked + block devices. + +* ``blink_time`` is the duration (in milliseconds) of each blink of this LED. + (The minimum value is 10 milliseconds.) + +* ``check_interval`` is the frequency (in milliseconds) with which block devices + linked to this LED will be checked for activity and the LED blinked (if the + correct type of activity has occurred). + +* The ``linked_devices`` directory will contain a symbolic link to every device + that is associated with this LED. + +Link a block device to the LED:: + + # echo /dev/sda > /sys/class/leds//link_dev_by_path + + # ls /sys/class/leds//linked_devices + sda + +(The value written to ``link_dev_by_path`` must be the path of the device +special file, such as ``/dev/sda``, that represents the block device - or the +path of a symbolic link to such a device special file.) + +Activity on the device will now cause the LED to blink. The duration of each +blink (in milliseconds) can be adjusted by setting +``/sys/class/leds//blink_time``. (But see **check_interval and +blink_time** below.) + +Associate a second device with the LED:: + + # echo /dev/sdb > /sys/class/leds//link_dev_by_path + + # ls /sys/class/leds//linked_devices + sda sdb + +When a block device is linked to one or more LEDs, the LEDs are linked from +the device's ``linked_leds`` directory:: + + # ls /sys/class/block/sd{a,b}/linked_leds + /sys/class/block/sda/linked_leds: + + + /sys/class/block/sdb/linked_leds: + + +(The ``linked_leds`` directory only exists when the block device is linked to +at least one LED.) + +``check_interval`` and ``blink_time`` +===================================== + +* By default, linked block devices are checked for activity every 100 + milliseconds. This frequency can be changed for an LED via the + ``/sys/class/leds//check_interval`` attribute. (The minimum value is 25 + milliseconds.) + +* All block devices associated with an LED are checked for activity every + ``check_interval`` milliseconds, and a blink is triggered if the correct type + of activity (as determined by the LED's ``blink_on_*`` attributes) is + detected. The duration of an LED's blink is determined by its ``blink_time`` + attribute. Thus (when the correct type of activity is detected), the LED will + be on for ``blink_time`` milliseconds and off for + ``check_interval - blink_time`` milliseconds. + +* The LED subsystem ignores new blink requests for an LED that is already in + in the process of blinking, so setting a ``blink_time`` greater than or equal + to ``check_interval`` will cause some blinks to be missed. + +* Because of processing times, scheduling latencies, etc., avoiding missed + blinks actually requires a difference of at least a few milliseconds between + the ``blink_time`` and ``check_interval``. The required difference is likely + to vary from system to system. As a reference, a Thecus N5550 NAS requires a + difference of 7 milliseconds (e.g. ``check_interval == 100``, + ``blink_time == 93``). + +* The default values (``check_interval == 100``, ``blink_time == 75``) cause the + LED associated with a continuously active device to blink rapidly. For a more + "always on" effect, increase the ``blink_time`` (but not too much; see the + previous bullet). + +Other Notes +=========== + +* Many (possibly all) 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 + * NVMe SSDs + * SD cards + * loopback block devices (``/dev/loop*``) + * device mapper devices, such as LVM logical volumes + * MD RAID devices + * zRAM compressed RAM-disks + * partitions on block devics that support them + +* The names of the symbolic links in ``/sys/class/leds//linked_devices`` + are **kernel** names, which may not match the paths used for + ``link_dev_by_path`` and ``unlink_dev_by_path``. This is most likely when a + symbolic link is used to refer to the device (as is common with logical + volumes), but it can be true for any device, because nothing prevents the + creation of device special files with arbitrary names (e.g. + ``sudo mknod /foo b 8 0``). + +* The ``blkdev`` LED trigger supports many-to-many device/LED associations. + A device can be associated with multiple LEDs, and an LED can be associated + with multiple devices. -- 2.37.2