Set md_mod parameter legacy_async_del_gendisk only when the running kernel provides it
This commit is contained in:
parent
e5ed63f397
commit
ae80d5bc3b
72
SOURCES/mdadm-get-MD_MOD_ASYNC_DEL_GENDISK.patch
Normal file
72
SOURCES/mdadm-get-MD_MOD_ASYNC_DEL_GENDISK.patch
Normal file
@ -0,0 +1,72 @@
|
||||
Subject: Set legacy_async_del_gendisk only when the kernel supports it
|
||||
|
||||
0042-mdadm-Create-array-with-sync-del-gendisk-mode.patch switches mdadm to
|
||||
the sync del_gendisk mode by writing N to the md_mod parameter
|
||||
legacy_async_del_gendisk. Upstream gates this on get_linux_version() >=
|
||||
6018000, which never matches a RHEL 9 kernel (5.14.0), and the RHEL patch
|
||||
mdadm-get-rhel-version.patch replaced it with a check for the z-stream
|
||||
number of the running kernel (>= 28), assuming kernel-5.14.0-611.28.1.el9_7
|
||||
or newer.
|
||||
|
||||
Both variants are wrong for AlmaLinux 9:
|
||||
|
||||
- the z-stream number is only comparable within a single minor release, so
|
||||
9.6 kernels (5.14.0-570.x) and 9.8 kernels (5.14.0-6xx.y, y restarting
|
||||
from a low number) are misdetected;
|
||||
- when the check passes but the running kernel does not provide the
|
||||
parameter, set_md_mod_parameter() fails and init_md_mod() returns false,
|
||||
which makes create_mddev() fail, i.e. arrays can't be created or
|
||||
assembled at all.
|
||||
|
||||
The parameter is added by kernel commit 25db5f284fb8 ("md: add
|
||||
legacy_async_del_gendisk mod"), which comes together with 9e59d609763f
|
||||
("md: call del_gendisk in control path"). Its presence in sysfs is
|
||||
therefore the exact condition mdadm needs, and it works for every kernel
|
||||
regardless of upstream or downstream versioning. If the parameter is not
|
||||
there, the kernel has the old async-only behaviour and nothing has to be
|
||||
set.
|
||||
|
||||
--- a/util.c
|
||||
+++ b/util.c
|
||||
@@ -2580,6 +2580,21 @@ bool set_md_mod_parameter(const char *name, const char *value)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Check if md_mod parameter is supported by the running kernel
|
||||
+ * @name: name of the parameter
|
||||
+ *
|
||||
+ * Return: true if /sys/module/md_mod/parameters/<name> exists, false if not
|
||||
+ */
|
||||
+static bool md_mod_parameter_exists(const char *name)
|
||||
+{
|
||||
+ char path[256];
|
||||
+
|
||||
+ snprintf(path, sizeof(path), "/sys/module/md_mod/parameters/%s", name);
|
||||
+
|
||||
+ return access(path, F_OK) == 0;
|
||||
+}
|
||||
+
|
||||
/* Init kernel md_mod and parameters here if needed */
|
||||
bool init_md_mod(void)
|
||||
{
|
||||
@@ -2624,10 +2639,16 @@ bool init_md_mod(void)
|
||||
* update mdadm and update to new kernel, they can't assemble array
|
||||
* anymore. So kernel adds a kernel parameter legacy_async_del_gendisk
|
||||
* and uses async as default.
|
||||
- * We'll use sync mode since 6.18 rather than async mode. So in future
|
||||
- * the kernel parameter will be removed.
|
||||
+ * We'll use sync mode rather than async mode. So in future the kernel
|
||||
+ * parameter will be removed.
|
||||
+ *
|
||||
+ * The kernel version can't be used to decide whether the parameter is
|
||||
+ * supported, because the two commits mentioned above are backported to
|
||||
+ * various downstream kernels which keep their own versioning. Check
|
||||
+ * sysfs to know if the running kernel provides the parameter and only
|
||||
+ * set it then, otherwise keep the kernel default.
|
||||
*/
|
||||
- if (get_linux_version() >= 6018000)
|
||||
+ if (md_mod_parameter_exists(MD_MOD_ASYNC_DEL_GENDISK))
|
||||
ret = set_md_mod_parameter(MD_MOD_ASYNC_DEL_GENDISK, "N");
|
||||
|
||||
return ret;
|
||||
@ -1,51 +0,0 @@
|
||||
--- a/util.c.orig 2026-02-10 10:32:30.910233101 +0800
|
||||
+++ b/util.c 2026-02-10 10:33:48.024018165 +0800
|
||||
@@ -2580,6 +2580,38 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
+int get_rhel_version(void)
|
||||
+{
|
||||
+ struct utsname name;
|
||||
+ char *cp;
|
||||
+ int rhel = 0;
|
||||
+
|
||||
+ if (uname(&name) < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ cp = name.release;
|
||||
+
|
||||
+ /* 5.14.0-611.28 */
|
||||
+ strtoul(cp, &cp, 10);
|
||||
+ if (*cp == '.') {
|
||||
+ strtoul(cp+1, &cp, 10);
|
||||
+ if (*cp == '.') {
|
||||
+ strtoul(cp+1, &cp, 10);
|
||||
+ } else
|
||||
+ return -1;
|
||||
+ } else
|
||||
+ return -1;
|
||||
+
|
||||
+ /* -611.28 */
|
||||
+ if (*cp == '-') {
|
||||
+ strtoul(cp+1, &cp, 10);
|
||||
+ if (*cp == '.')
|
||||
+ rhel = strtoul(cp+1, &cp, 10);
|
||||
+ }
|
||||
+
|
||||
+ return rhel;
|
||||
+}
|
||||
+
|
||||
/* Init kernel md_mod and parameters here if needed */
|
||||
bool init_md_mod(void)
|
||||
{
|
||||
@@ -2627,7 +2659,8 @@
|
||||
* We'll use sync mode since 6.18 rather than async mode. So in future
|
||||
* the kernel parameter will be removed.
|
||||
*/
|
||||
- if (get_linux_version() >= 6018000)
|
||||
+ /* kernel-5.14.0-611.28.1.el9_7 merged del sync mode */
|
||||
+ if (get_rhel_version() >= 28)
|
||||
ret = set_md_mod_parameter(MD_MOD_ASYNC_DEL_GENDISK, "N");
|
||||
|
||||
return ret;
|
||||
@ -2,7 +2,7 @@ Name: mdadm
|
||||
Version: 4.4
|
||||
# extraversion is used to define rhel internal version
|
||||
%define extraversion 4
|
||||
Release: %{extraversion}%{?dist}
|
||||
Release: %{extraversion}%{?dist}.alma.1
|
||||
Summary: The mdadm program controls Linux md devices (software RAID arrays)
|
||||
URL: https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git
|
||||
License: GPLv2+
|
||||
@ -69,7 +69,9 @@ Patch196: mdadm-fix-building-errors.patch
|
||||
Patch197: mdadm-check-posix-name-before-setting-name-and-devna.patch
|
||||
Patch200: mdadm-udev.patch
|
||||
Patch201: mdadm-2.5.2-static.patch
|
||||
Patch202: mdadm-get-rhel-version.patch
|
||||
|
||||
# AlmaLinux Patch
|
||||
Patch202: mdadm-get-MD_MOD_ASYNC_DEL_GENDISK.patch
|
||||
|
||||
BuildRequires: make
|
||||
BuildRequires: systemd-rpm-macros binutils-devel gcc systemd-devel
|
||||
@ -143,6 +145,10 @@ install -m644 %{SOURCE5} %{buildroot}/etc/libreport/events.d
|
||||
/usr/share/mdadm/mdcheck
|
||||
|
||||
%changelog
|
||||
* Tue Jul 28 2026 Andrew Lukoshko <alukoshko@almalinux.org> - 4.4-4.alma.1
|
||||
- Set md_mod parameter legacy_async_del_gendisk only when the running kernel
|
||||
provides it
|
||||
|
||||
* Tue Feb 10 2026 Xiao Ni <xni@redhat.com> 4.4-4
|
||||
- enable sync del mode and some booting fixes
|
||||
- Resolves RHEL-106747 RHEL-130808
|
||||
|
||||
Loading…
Reference in New Issue
Block a user