mtd-utils: add a UBI health monitor service
The ubihealthd daemon, present in mtd-utils does random scans of the UBI devices on a given interval. This helps to deal with 'read disturb' problem on NAND flashes. The service runs a ubihealthd thread for every UBI device with a read interval of 1 hour by default. Signed-off-by: Hector Palacios <hector.palacios@digi.com> https://onedigi.atlassian.net/browse/DEL-9571
This commit is contained in:
parent
63e7031614
commit
ec52e7a19f
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
DAEMON="/usr/sbin/ubihealthd"
|
||||||
|
CMD="$1"
|
||||||
|
INTERVAL="${2:-3600}" # Optional (default to 1 hour if not specified)
|
||||||
|
|
||||||
|
[ -z "$CMD" ] && usage
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 {start|stop|restart} [interval_sec]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$CMD" in
|
||||||
|
start)
|
||||||
|
for dev in $(ls /sys/class/ubi/ | grep -E '^ubi[0-9]+$'); do
|
||||||
|
PIDFILE="/run/ubihealthd-${dev}.pid"
|
||||||
|
echo -n "Starting UBI health monitor on ${dev} (interval ${INTERVAL} s): "
|
||||||
|
start-stop-daemon -S -b -x "${DAEMON}" -m -p "${PIDFILE}" -- -d /dev/"${dev}" -i "${INTERVAL}" -f
|
||||||
|
echo "done."
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
for dev in $(ls /sys/class/ubi/ | grep -E '^ubi[0-9]+$'); do
|
||||||
|
PIDFILE="/run/ubihealthd-${dev}.pid"
|
||||||
|
start-stop-daemon -K -x "${DAEMON}" -p "${PIDFILE}"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
$0 stop
|
||||||
|
sleep 1
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=UBI health monitor
|
||||||
|
After=ubi.mount
|
||||||
|
ConditionDirectoryNotEmpty=/sys/class/ubi
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/etc/ubihealthd-init start
|
||||||
|
ExecStop=/etc/ubihealthd-init stop
|
||||||
|
RemainAfterExit=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -1,3 +1,33 @@
|
||||||
# Copyright (C) 2023, Digi International Inc.
|
# Copyright (C) 2023-2025, Digi International Inc.
|
||||||
|
|
||||||
PACKAGECONFIG:append = " crypto"
|
PACKAGECONFIG:append = " crypto"
|
||||||
|
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||||
|
|
||||||
|
SRC_URI += " \
|
||||||
|
file://ubihealthd-init \
|
||||||
|
file://ubihealthd.service \
|
||||||
|
"
|
||||||
|
|
||||||
|
inherit systemd update-rc.d
|
||||||
|
|
||||||
|
do_install:append:class-target() {
|
||||||
|
install -d ${D}${sysconfdir}/init.d/
|
||||||
|
install -m 0755 ${WORKDIR}/ubihealthd-init ${D}${sysconfdir}/
|
||||||
|
ln -sf ${sysconfdir}/ubihealthd-init ${D}${sysconfdir}/init.d/ubihealthd-init
|
||||||
|
|
||||||
|
install -d ${D}${systemd_unitdir}/system/
|
||||||
|
install -m 0644 ${WORKDIR}/ubihealthd.service ${D}${systemd_unitdir}/system/
|
||||||
|
}
|
||||||
|
|
||||||
|
FILES:mtd-utils-ubifs += " \
|
||||||
|
${sysconfdir}/ubihealthd-init \
|
||||||
|
${sysconfdir}/init.d/ubihealthd-init \
|
||||||
|
${systemd_unitdir}/system/ubihealthd.service \
|
||||||
|
"
|
||||||
|
|
||||||
|
INITSCRIPT_PACKAGES += "mtd-utils-ubifs"
|
||||||
|
INITSCRIPT_NAME:mtd-utils-ubifs = "ubihealthd-init"
|
||||||
|
INITSCRIPT_PARAMS:mtd-utils-ubifs = "start 19 2 3 4 5 . stop 21 0 1 6 ."
|
||||||
|
|
||||||
|
SYSTEMD_PACKAGES = "mtd-utils-ubifs"
|
||||||
|
SYSTEMD_SERVICE:mtd-utils-ubifs = "ubihealthd.service"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue