public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/mdadm] f45: Use upstream mdcheck instead of old copy.
@ 2026-11-26 13:01 Peter Rajnoha
  0 siblings, 0 replies; only message in thread
From: Peter Rajnoha @ 2026-11-26 13:01 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/mdadm
            Branch : f45
            Commit : 112dc3ad7f4860b15bd3151a5a22a84bbec1b71b
            Author : Peter Rajnoha <prajnoha@redhat.com>
            Date   : 2026-11-26T14:01:21+01:00
            Stats  : +116/-3 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/mdadm/c/112dc3ad7f4860b15bd3151a5a22a84bbec1b71b?branch=f45

            Log:
            Use upstream mdcheck instead of old copy.

Resolves: bz#2581234

---
diff --git a/0001-mdcheck-avoid-checking-arrays-without-metadata.patch b/0001-mdcheck-avoid-checking-arrays-without-metadata.patch
new file mode 100644
index 0000000..061aa61
--- /dev/null
+++ b/0001-mdcheck-avoid-checking-arrays-without-metadata.patch
@@ -0,0 +1,33 @@
+From aa7d11a2731776d50d4e892fd5987d60589c08d1 Mon Sep 17 00:00:00 2001
+From: Corey Hickey <bugfood-c@fatooh.org>
+Date: Thu, 12 Nov 2026 20:10:36 -0800
+Subject: [PATCH] mdcheck: avoid checking arrays without metadata
+
+For these arrays, mdadm returns a zeroed-out UUID. The kernel does
+provide a UUID via sysfs, but this UUID is regenerated each time the
+array is built, so is not valid for tracking.
+
+Signed-off-by: Corey Hickey <bugfood-c@fatooh.org>
+---
+ misc/mdcheck | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/misc/mdcheck b/misc/mdcheck
+index 839ca6a1..8d1c3675 100644
+--- a/misc/mdcheck
++++ b/misc/mdcheck
+@@ -184,6 +184,14 @@ do
+ 
+ 	sys=${sync_act%/md/*}
+ 	dev=$(devname "$sys") || continue
++
++	read -r metadata_version < "$sys/md/metadata_version"
++	if [[ "$metadata_version" = none ]] ; then
++		# Do not check arrays without metadata; they do not have a
++		# stable UUID, so cannot be tracked properly.
++		continue
++	fi
++
+ 	BINDIR/mdadm --detail --export "$dev" | grep '^MD_UUID=' > $tmp || continue
+ 	source $tmp
+ 	[[ "$MD_UUID" ]] || continue

diff --git a/0002-mdcheck-read-UUID-from-sysfs-when-possible.patch b/0002-mdcheck-read-UUID-from-sysfs-when-possible.patch
new file mode 100644
index 0000000..c82c33c
--- /dev/null
+++ b/0002-mdcheck-read-UUID-from-sysfs-when-possible.patch
@@ -0,0 +1,76 @@
+From ab170bdcec0d339e4f8f55968df228a8bb08b8ab Mon Sep 17 00:00:00 2001
+From: Corey Hickey <bugfood-c@fatooh.org>
+Date: Thu, 12 Nov 2026 20:16:11 -0800
+Subject: [PATCH] mdcheck: read UUID from sysfs when possible
+
+mdadm reads the UUID directly from a component device. This can result
+in bringing a device out of a low-power mode, e.g. spinning up a hard
+disk. In particular, this happens when mdcheck_continue.timer triggers
+daily at a time when disks are normally in standby mode.
+
+Linux versions >= 5.9 provide the UUID via sysfs; read this when
+possible.
+
+Don't attempt to read the UUID from arrays with version-0 metadata.
+While this would be possible, the script would need to do some
+byte-swapping, depending on endianness. The complexity needed would not
+be worthwhile.
+
+Signed-off-by: Corey Hickey <bugfood-c@fatooh.org>
+---
+ misc/mdcheck | 35 +++++++++++++++++++++++++++++++++--
+ 1 file changed, 33 insertions(+), 2 deletions(-)
+
+diff --git a/misc/mdcheck b/misc/mdcheck
+index 8d1c3675..e01948cf 100644
+--- a/misc/mdcheck
++++ b/misc/mdcheck
+@@ -166,6 +166,33 @@ cleanup() {
+     rm -f "$tmp"
+ }
+ 
++# Read the UUID of an array at the given sysfs path. Print the UUID when
++# possible, or else the empty string.
++read_uuid_sysfs() {
++	local sys=$1
++	local metadata_version=$2
++	local uuid_file="$sys/md/uuid"
++	local uuid=''
++
++	# Avoid version-0 metadata. The kernel's representation of UUID for
++	# these can depend on host endianness, thus differing from that of
++	# mdadm.
++	if [[ ! "$metadata_version" =~ ^0 ]] ; then
++		# Kernels older than 5.9 do not provide the UUID in sysfs.
++		if [ -f "$uuid_file" ] ; then
++			# Normalize to form provided by mdadm.
++			uuid=$(< "$uuid_file" tr -d - | sed -E 's/(.{8})(.{8})(.{8})(.{8})/\1:\2:\3:\4/')
++			if [[ "$uuid" = "00000000:00000000:00000000:00000000" ]] ; then
++				# This can happen for arrays where the kernel
++				# does not know the UUID, e.g. arrays that are
++				# part of a DDF container.
++				uuid=''
++			fi
++		fi
++	fi
++	printf "%s\n" "$uuid"
++}
++
+ trap 'exit 129' 2 3 15
+ trap 'cleanup' 0
+ 
+@@ -192,8 +219,12 @@ do
+ 		continue
+ 	fi
+ 
+-	BINDIR/mdadm --detail --export "$dev" | grep '^MD_UUID=' > $tmp || continue
+-	source $tmp
++	MD_UUID=$(read_uuid_sysfs "$sys" "$metadata_version")
++	if [[ -z "$MD_UUID" ]] ; then
++		# fall back to mdadm
++		BINDIR/mdadm --detail --export "$dev" | grep '^MD_UUID=' > $tmp || continue
++		source $tmp
++	fi
+ 	[[ "$MD_UUID" ]] || continue
+ 
+ 	fl="/var/lib/mdcheck/MD_UUID_$MD_UUID"

diff --git a/mdadm.spec b/mdadm.spec
index 4285a1d..213d38d 100644
--- a/mdadm.spec
+++ b/mdadm.spec
@@ -2,7 +2,7 @@
 
 Name:        mdadm
 Version:     4.6
-Release:     2%{?dist}
+Release:     3%{?dist}
 Summary:     The mdadm program controls Linux md devices (software RAID arrays)
 URL:         http://www.kernel.org/pub/linux/utils/raid/mdadm/
 License:     GPL-2.0-or-later
@@ -15,13 +15,14 @@ Source4:     mdadm.conf
 Source5:     mdadm_event.conf
 Source6:     raid-check.timer
 Source7:     raid-check.service
-Source8:     mdcheck
 Source10:    https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/snapshot/%{name}-%{version}.tar.asc
 Source11:    https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys/9CE05640D703A136.asc
 
 # Fedora customization patches
 Patch:       mdadm-udev.patch
 Patch:       mdadm-2.5.2-static.patch
+Patch:       0001-mdcheck-avoid-checking-arrays-without-metadata.patch
+Patch:       0002-mdcheck-read-UUID-from-sysfs-when-possible.patch
 
 BuildRequires:    make
 BuildRequires:    systemd-rpm-macros
@@ -64,7 +65,6 @@ install -Dp -m 755 %{SOURCE1} %{buildroot}%{_sbindir}/raid-check
 install -Dp -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
 mkdir -p -m 710 %{buildroot}/run/%{name}
 mkdir -p -m 755 %{buildroot}%{_datadir}/%{name}
-install -Dp -m 755 %{SOURCE8} %{buildroot}%{_datadir}/%{name}/mdcheck
 
 # systemd
 install -Dm644 %{SOURCE3} %{buildroot}%{_unitdir}
@@ -124,6 +124,10 @@ install -Dm644 raid6check.man %{buildroot}/%{_mandir}/man8/raid6check.man
 
 
 %changelog
+* Thu Nov 26 2026 Peter Rajnoha <prajnoha@redhat.com> - 4.6-3
+- Install upstream mdcheck script instead of the stale Fedora copy.
+- Backport mdcheck fixes to skip arrays without metadata and read the UUID from sysfs.
+
 * Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 4.6-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26 13:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 13:01 [rpms/mdadm] f45: Use upstream mdcheck instead of old copy Peter Rajnoha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox