Update to latest upstream

Resolves: RHEL-59101

Signed-off-by: Xiao Ni <xni@redhat.com>
This commit is contained in:
Xiao Ni 2024-10-19 06:16:31 -04:00
parent aba27b5983
commit b71904193f
45 changed files with 4715 additions and 85 deletions

View File

@ -0,0 +1,193 @@
From 3f90be087fa62c0c7ed76c2ac26752f0ac3a89e7 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Tue, 7 May 2024 17:35:09 +0200
Subject: [PATCH 067/201] mdadm: Change main repository to Github
Now github will be used for tracking mdadm, adjust README.md.
Daily routines will be automated on Github, there is not need to
decribe them.
Adjust release process, it must be published to both repositories.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
MAINTAINERS.md | 41 ++++++++----------------
README.md | 86 ++++++++++++++++++++++++++++----------------------
2 files changed, 61 insertions(+), 66 deletions(-)
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index 9c79ba87..e5b635f0 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -1,44 +1,29 @@
# Maintainer tools
-Useful tools used in daily routines:
+Useful tools for mdadm maintenance:
- [checkpatch](https://docs.kernel.org/dev-tools/checkpatch.html)
- [kup](https://korg.docs.kernel.org/kup.html)
- [Auto-publishing](https://korg.docs.kernel.org/kup.html#auto-publishing-with-git-archive-signer)
- [b4](https://b4.docs.kernel.org/en/latest/)
-# Checklist before applying patch
-
-We don't have CI testing yet, so all those steps must be performed manually:
-- Style check with [checkpatch](https://docs.kernel.org/dev-tools/checkpatch.html):
-
- This is the current code style follows. We are not strict to all rules. It must be run
- by **checkpatch --no-tree**, see README.md.
-
-- [Commit style](https://www.kernel.org/doc/html/v4.10/process/submitting-patches.html):
-
- It doesn't need to be followed as strictly as is in kernel but changes should be logically
- separated. Submitter should care at least to mention "It is used in next patches" if unused
- externs/files are added in patch. We love: *Reported-by:*, *Suggested-by:*, *Fixes:* tags.
-
-- Compilation, ideally on various gcc versions.
-- Mdadm test suite execution.
-- Consider requesting new tests from submitter, especially for new functionalities.
-- Ensure that maintainer *sign-off* is added, before pushing.
-
# Making a release
Assuming that maintainer is certain that release is safe, following steps must be done:
-- Update versions strings in release commit, please refer to previous releases for examples.
+- Make and push release commit:
+ - Update versions strings, refer to previous releases for examples.
+ - Update CHANGELOG.md.
+
+- Create GPG signed tag and push it to both remotes. Use same format as was used previously,
+ prefixed by **mdadm-**, e.g. **mdadm-3.1.2**, **mdadm-4.1**.
-- Create GPG signed tag and push it to repo. Use same format as was used previously, prefixed by
- **mdadm-**, e.g. **mdadm-3.1.2**, **mdadm-4.1**.
+- Run kernel.org
+ [Auto-publishing](https://korg.docs.kernel.org/kup.html#auto-publishing-with-git-archive-signer):
-- [Auto-publishing](https://korg.docs.kernel.org/kup.html#auto-publishing-with-git-archive-signer):
+ Adopt script to our release tag model. When ready, push signed note to kernel.org repository. If
+ it is done correctly, then *(sig)* is added to the package automatically generated by
+ kernel.org automation. There is no need to upload archive manually.
- Adopt script to our release tag model. When ready, push signed note to repository. If it is done
- correctly, then *(sig)* is added to the package automatically generated by kernel.org automation.
- There is no need to upload archive manually.
+- Add release entry on Github.
-- Update CHANGELOG.md.
- Write "ANNOUNCE" mail to linux-raid@kernel.org to notify community.
diff --git a/README.md b/README.md
index 64f2ecec..486c8929 100644
--- a/README.md
+++ b/README.md
@@ -20,58 +20,68 @@
**IMPORTANT:** DDF is in **maintenance only** mode. There is no active development around it.
Please do not use it in new solutions.
-# How to Contribute
-
- **mdadm** is hosted on [kernel.org](https://kernel.org/). You can access repository
-[here](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git).
+# Questions and Support
+
+This Github site is **not** right place to ask if your are looking for:
+- support from Linux Raid Community;
+- support with kernel issues;
+
+This is the place where development of mdadm application is done. Please, do not use for
+looking for support. You should always ask on [Mailing List](https://lore.kernel.org/linux-raid/).
+
+Please use issues if you have confirmation that issue you are experiencing is related to mdadm
+components:
+- mdadm;
+- mdmon;
+- raid6check;
+- swap_super;
+- test_stripe;
+- systemd services ( see systemd/);
+- udev rules;
+- manual pages (including md.man)
+
+For example:
+- mdadm issues (e.g segfaults, memory leaks, crashes, bad communication with MD driver);
+- feature requests for mdadm;
+- suggestions or minor fixes requested (e.g. better error messages);
+
+Generally, if you are not sure it is better to ask on
+[Mailing List](https://lore.kernel.org/linux-raid/) first.
-It is maintained similarly to kernel, using *mailing list*. Patches must be send through email.
-Please familiarize with general kernel
-[submitting patches](https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html)
-documentation. Formatting, tags and commit message guidelines applies to **mdadm**.
+# How to Contribute
-## Sending patches step-by-step
+Effective immediately [Github](https://github.com/md-raid-utilities/mdadm) is the primary
+location for **mdadm**. Use pull request to contribute.
-To maximize change of patches being taken, follow this instruction when submitting:
+It was originally hosted on [kernel.org](https://kernel.org/). You can access the old repository
+[here](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git).
-1. Create possibly logically separated commits and generate patches:
+Patches sent through Mailing list are accepted but Github is preferred. Sent then to ML only
+if you cannot use Github. Please add "mdadm:" to the subject to allow automation to create Github
+Pull Request and run checks.
- Use ``git format-patch --cover-letter --signoff -v <nr>`` to create patches:
- * ``--cover-letter`` can be skipped if it is only one patch;
- * ``--signoff`` adds sign-off tag;
- * ``-v <nr>`` indicates review revision number, sender should increment it before resending.
+**NOTE:** Maintainers may ask you to send RFC to mailing list if the proposed code requires
+consultation with kernel developers.
-2. Check style of every patch with kernel
- [checkpatch](https://docs.kernel.org/dev-tools/checkpatch.html) script:
+Kernel coding style is used. Please familiarize with general kernel
+[submitting patches](https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html)
+documentation. Formatting, tags and commit message guidelines applies to **mdadm**.
- It is important to keep same coding style that is why in **mdadm**
- [kernel coding style](https://www.kernel.org/doc/html/v4.10/process/coding-style.html)
- is preferred. ``checkpath --no-tree <patch_file>`` can be used to verify patches.
- Following checkpatch issues can be ignored:
- - New typedefs.
- - comparing with *True/False*.
- - kernel *MAINTAINERS* file warning.
- - *extern* keyword in headers.
+[Checkpatch](https://docs.kernel.org/dev-tools/checkpatch.html) script is run on
+every patch in pull request so be sure that your commits are not generating
+issues. There are some excludes, so the best is to follow github checkpatch action result.
-3. Send patches using ``git send-mail --to=linux-raid@vger.kernel.org <cover-letter> <patch1> <patch2> (...)``
+Pull Request are closed by `Rebase and Merge` option, so it requires to keep every commit
+meaningful. Kernel style requires that. The review changes must be pushed with **push --force**
+to the chosen branch, then Pull Request will be automatically updated.
-# Maintainers
+# Maintainers of mdadm repository on kernel.org
-It is good practice to add **mdadm maintainers** to recipients for patches:
+If there are differences between github and kernel.org, please contact kernel.org mdadm maintainers:
- Jes Sorensen <jes@trained-monkey.org>;
- Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>;
-Adding **MD maintainers** could be reasonable, especially if patches may affect MD driver:
-
-- Song Liu <song@kernel.org>;
-- Yu Kuai <yukuai3@huawei.com>;
-
-# Reviewers
-
-**mdadm** utility is not part of kernel tree, so there is no certificated *Reviewers* list. Everyone
-can comment on mailing list, last decision (and merging) belongs to maintainers.
-
# Minimal supported kernel version
We do not support kernel versions below **v3.10**. Please be aware that maintainers may remove
--
2.41.0

View File

@ -0,0 +1,28 @@
From 1f49ecbf3d2ab8003d37eb1c0454c5cfbe335ee5 Mon Sep 17 00:00:00 2001
From: Nicolas Roeser <nicolas.roeser@alumni.uni-ulm.de>
Date: Sun, 4 Aug 2024 14:34:44 +0200
Subject: [PATCH 158/201] md.4: replace wrong word
There is a wrong word in the md(4) man page, this commit corrects it.
Signed-off-by: Nicolas Roeser <nicolas.roeser@alumni.uni-ulm.de>
---
md.4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/md.4 b/md.4
index 7a0bc7e6..7aef1577 100644
--- a/md.4
+++ b/md.4
@@ -224,7 +224,7 @@ option. If you use this option to
while running a newer kernel, the array will NOT assemble, but the
metadata will be update so that it can be assembled on an older kernel.
-No that setting the layout to "unspecified" removes protections against
+Note that setting the layout to "unspecified" removes protections against
this bug, and you must be sure that the kernel you use matches the
layout of the array.
--
2.41.0

View File

@ -0,0 +1,134 @@
From ea076e7c4bc8b3122ad9d7131098c4b85902a299 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Wed, 7 Aug 2024 11:33:23 -0400
Subject: [PATCH 159/201] mdadm: util.c fix coverity issues
Fixing the following coding errors the coverity tools found:
* Event check_return: Calling "open" without checking return value
* Event check_return: Calling "lseek(fd, sector_size, 0)" without
checking return value.
* Event leaked_handle: Handle variable "fd" going out of scope leaks
the handle.
* Event leaked_storage: Variable "dir" going out of scope leaks the
storage it points to.
* Event fixed_size_dest: You might overrun the 32-character fixed-size
string "st->devnm" by copying "_devnm" without checking the length.
* Event fixed_size_dest: You might overrun the 32-character fixed-size
string "container" by copying "dev" without checking the length.
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
util.c | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/util.c b/util.c
index 83d42833..1cee0feb 100644
--- a/util.c
+++ b/util.c
@@ -1253,7 +1253,7 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
*subarray++ = '\0';
subarray = xstrdup(subarray);
}
- strcpy(container, dev);
+ snprintf(container, sizeof(container), "%s", dev);
sysfs_free(sra);
sra = sysfs_read(-1, container, GET_VERSION);
if (sra && sra->text_version[0])
@@ -1430,7 +1430,8 @@ static int get_gpt_last_partition_end(int fd, unsigned long long *endofpart)
/* skip protective MBR */
if (!get_dev_sector_size(fd, NULL, &sector_size))
return 0;
- lseek(fd, sector_size, SEEK_SET);
+ if (lseek(fd, sector_size, SEEK_SET) == -1L)
+ return 0;
/* read GPT header */
if (read(fd, &gpt, 512) != 512)
return 0;
@@ -1451,7 +1452,8 @@ static int get_gpt_last_partition_end(int fd, unsigned long long *endofpart)
part = (struct GPT_part_entry *)buf;
/* set offset to third block (GPT entries) */
- lseek(fd, sector_size*2, SEEK_SET);
+ if (lseek(fd, sector_size*2, SEEK_SET) == -1L)
+ return 0;
for (part_nr = 0; part_nr < all_partitions; part_nr++) {
/* read partition entry */
if (read(fd, buf, entry_size) != (ssize_t)entry_size)
@@ -1486,7 +1488,8 @@ static int get_last_partition_end(int fd, unsigned long long *endofpart)
BUILD_BUG_ON(sizeof(boot_sect) != 512);
/* read MBR */
- lseek(fd, 0, 0);
+ if (lseek(fd, 0, 0) == -1L)
+ goto abort;
if (read(fd, &boot_sect, 512) != 512)
goto abort;
@@ -1715,7 +1718,7 @@ int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet)
dev);
goto close_fd;
}
- strcpy(st->devnm, _devnm);
+ snprintf(st->devnm, sizeof(st->devnm), "%s", _devnm);
mdi = sysfs_read(fd, st->devnm, GET_VERSION|GET_LEVEL);
if (!mdi) {
@@ -2293,14 +2296,16 @@ void manage_fork_fds(int close_all)
{
DIR *dir;
struct dirent *dirent;
+ int fd = open("/dev/null", O_RDWR);
- close(0);
- open("/dev/null", O_RDWR);
-
+ if (is_fd_valid(fd)) {
+ dup2(fd, 0);
#ifndef DEBUG
dup2(0, 1);
dup2(0, 2);
+ close_fd(&fd);
#endif
+ }
if (close_all == 0)
return;
@@ -2319,8 +2324,10 @@ void manage_fork_fds(int close_all)
fd = strtol(dirent->d_name, NULL, 10);
if (fd > 2)
- close(fd);
+ close_fd(&fd);
}
+ closedir(dir);
+ return;
}
/* In a systemd/udev world, it is best to get systemd to
@@ -2367,13 +2374,15 @@ void reopen_mddev(int mdfd)
/* Re-open without any O_EXCL, but keep
* the same fd
*/
- char *devnm;
- int fd;
- devnm = fd2devnm(mdfd);
- close(mdfd);
- fd = open_dev(devnm);
- if (fd >= 0 && fd != mdfd)
- dup2(fd, mdfd);
+ char *devnm = fd2devnm(mdfd);
+ int fd = open_dev(devnm);
+
+ if (!is_fd_valid(fd))
+ return;
+
+ dup2(fd, mdfd);
+
+ close_fd(&fd);
}
static struct cmap_hooks *cmap_hooks = NULL;
--
2.41.0

View File

@ -0,0 +1,56 @@
From 18eaf6c5206a37ad059c930d1ee2dbc9b7297513 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Thu, 18 Jul 2024 13:05:57 -0400
Subject: [PATCH 160/201] mdadm: sysfs.c fix coverity issues
Fixing the following coding errors the coverity tools found:
* Event fixed_size_dest: You might overrun the 32-character
fixed-size string "mdi->sys_name" by copying "devnm" without
checking the length
* Event fixed_size_dest: You might overrun the 50-character
fixed-size string "sra->text_version" by copying "buf + 9"
without checking the length.
* Event string_overflow: You might overrun the 32-character
destination string "dev->sys_name" by writing 256 characters
from "de->d_name".
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sysfs.c b/sysfs.c
index 20fe1e9e..b3c8b10d 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -139,7 +139,7 @@ int sysfs_init(struct mdinfo *mdi, int fd, char *devnm)
goto out;
if (!S_ISDIR(stb.st_mode))
goto out;
- strcpy(mdi->sys_name, devnm);
+ strncpy(mdi->sys_name, devnm, sizeof(mdi->sys_name) - 1);
retval = 0;
out:
@@ -179,6 +179,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
sra->array.major_version = -1;
sra->array.minor_version = -2;
strcpy(sra->text_version, buf+9);
+ sra->text_version[sizeof(sra->text_version) - 1] = '\0';
} else {
sscanf(buf, "%d.%d",
&sra->array.major_version,
@@ -340,6 +341,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
}
strcpy(dev->sys_name, de->d_name);
+ dev->sys_name[sizeof(dev->sys_name) - 1] = '\0';
dev->disk.raid_disk = strtoul(buf, &ep, 10);
if (*ep) dev->disk.raid_disk = -1;
--
2.41.0

View File

@ -0,0 +1,405 @@
From 91845dab52c3f9ab56710338c0c38e9c1473df1d Mon Sep 17 00:00:00 2001
From: Blazej Kucman <blazej.kucman@intel.com>
Date: Thu, 11 Jul 2024 18:45:41 +0200
Subject: [PATCH 161/201] imsm: add read OROM form ACPI UEFI tables
OROM - IMSM hardware capabilities
EFI vars depends on userspace, they need to be mounted to be accessible.
Sporadic problems have been observed with availability at an early
assemble stage. It is not possible to fully synchronize EFI vars mounts
with udev rules processing.
For the reason above, read of IMSM OROM from ACPI tables as secondary
option is added. This method will be used for SATA and VMD family
controllers.
ACPI tables are generated by sysfs, earlier in the boot process, before
the stage of RAID assembly. The way of loading OROM via EFI vars is
retained, ACPI tables will be a backup way.
Two paths will be maintained, because IMSM hardware capabilities are
necessary for RAID assembly during booting, so access to them must be
provided.
Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
---
platform-intel.c | 324 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 299 insertions(+), 25 deletions(-)
diff --git a/platform-intel.c b/platform-intel.c
index d6a53533..9705c925 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -577,6 +577,9 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba)
#define SYS_EFI_VAR_PATH "/sys/firmware/efi/vars"
#define SYS_EFIVARS_PATH "/sys/firmware/efi/efivars"
+#define ACPI_TABLES_PATH "/sys/firmware/acpi/tables/"
+#define ACPI_UEFI_TABLE_BASE_NAME "UEFI"
+#define ACPI_UEFI_DATA_OFFSET 52
#define SCU_PROP "RstScuV"
#define AHCI_PROP "RstSataV"
#define AHCI_SSATA_PROP "RstsSatV"
@@ -584,10 +587,73 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba)
#define VROC_VMD_PROP "RstUefiV"
#define RST_VMD_PROP "RstVmdV"
-#define VENDOR_GUID \
+#define PCI_CLASS_RAID_CNTRL 0x010400
+
+/* GUID length in Bytes */
+#define GUID_LENGTH 16
+
+/* GUID entry in 'UEFI' for Sata controller. */
+#define RST_SATA_V_GUID \
+ EFI_GUID(0xe4dd92e0, 0xac7d, 0x11df, 0x94, 0xe2, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66)
+
+/* GUID entry in 'UEFI' for sSata controller. */
+#define RST_SSATA_V_GUID \
+ EFI_GUID(0xb002be42, 0x901d, 0x4018, 0xb4, 0x1e, 0xd7, 0x04, 0xab, 0x3a, 0x0f, 0x15)
+
+/* GUID entry in 'UEFI' for tSata controller. */
+#define RST_TSATA_V_GUID \
+ EFI_GUID(0x101ce8f1, 0xb873, 0x4362, 0xa9, 0x76, 0xb5, 0x54, 0x31, 0x74, 0x52, 0x7e)
+
+/* GUID entry in 'UEFI' for Intel(R) VROC VMD. */
+#define RST_UEFI_V_GUID \
+ EFI_GUID(0x4bf2da96, 0xde6e, 0x4d8a, 0xa8, 0x8b, 0xb3, 0xd, 0x33, 0xf6, 0xf, 0x3e)
+
+/**
+ * GUID entry in 'UEFI' for Intel(R) RST VMD.
+ * Currently is the same like in 'UEFI' for Sata controller.
+ */
+#define RST_VMD_V_GUID RST_SATA_V_GUID
+
+/* GUID of intel RST vendor EFI var. */
+#define INTEL_RST_VENDOR_GUID \
EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6)
-#define PCI_CLASS_RAID_CNTRL 0x010400
+/*
+ * Unified Extensible Firmware Interface (UEFI) Specification Release 2.10
+ * UEFI ACPI DATA TABLE, Table O.1
+ */
+typedef struct uefi_acpi_table {
+ char signature[4];
+ __u32 length;
+ __u8 revision;
+ __u8 checksum;
+ char oemid[6];
+ /* controller name */
+ char oem_table_id[8];
+ __u32 oem_revision;
+ __u32 creator_id;
+ __u32 creator_revision;
+ /* controller GUID */
+ struct efi_guid identifier;
+ /* OROM data offeset */
+ __u16 dataOffset;
+} uefi_acpi_table_t;
+
+typedef struct uefi_acpi_table_with_orom {
+ struct uefi_acpi_table table;
+ struct imsm_orom orom;
+} uefi_acpi_table_with_orom_t;
+
+/* imsm_orom_id - Identifier used to match imsm efi var or acpi table
+ * @name: name of the UEFI property, it is part of efivar name or ACPI table oem_table_id
+ * @guid: acpi table guid identifier
+ *
+ * vendor guid (second part of evifar name) is not added here because it is cost.
+ */
+typedef struct imsm_orom_id {
+ char *name;
+ struct efi_guid guid;
+} imsm_orom_id_t;
static int read_efi_var(void *buffer, ssize_t buf_size,
const char *variable_name, struct efi_guid guid)
@@ -669,14 +735,238 @@ static int read_efi_variable(void *buffer, ssize_t buf_size,
return 0;
}
+/**
+ * is_efi_guid_equal() - check if EFI guids are equal.
+ * @guid: EFI guid.
+ * @guid1: EFI guid to compare.
+ *
+ * Return: %true if guid are equal, %false otherwise.
+ */
+static inline bool is_efi_guid_equal(struct efi_guid guid, struct efi_guid guid1)
+{
+ if (memcmp(guid.b, guid1.b, GUID_LENGTH) == 0)
+ return true;
+ return false;
+}
+
+/**
+ * acpi_any_imsm_orom_id_matching() - match ACPI table with any of given imsm_orom_id.
+ * @imsm_orom_ids: array of IMSM OROM Identifiers.
+ * @imsm_orom_ids_number: number of IMSM OROM Identifiers.
+ * @table: struct with read ACPI UEFI table.
+ *
+ * Check if read UEFI table contains requested OROM id.
+ * EFI GUID and controller name are compared with expected.
+ *
+ * Return: %true if length is proper table, %false otherwise.
+ */
+bool acpi_any_imsm_orom_id_matching(imsm_orom_id_t *imsm_orom_ids, int imsm_orom_ids_number,
+ struct uefi_acpi_table table)
+{
+ int index;
+
+ for (index = 0; index < imsm_orom_ids_number; index++)
+ if (strncmp(table.oem_table_id, imsm_orom_ids[index].name,
+ strlen(imsm_orom_ids[index].name)) == 0 &&
+ is_efi_guid_equal(table.identifier,
+ imsm_orom_ids[index].guid) == true)
+ return true;
+ return false;
+}
+
+/**
+ * read_uefi_acpi_orom_data() - read OROM data from UEFI ACPI table.
+ * @fd: file descriptor.
+ * @uefi_table: struct to fill out.
+ *
+ * Read OROM from ACPI UEFI table under given file descriptor.
+ * Table must have the appropriate OROM data, which should be confirmed before call this function.
+ * In case of success, &orom in structure in &uefi_table will be filled..
+ *
+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise.
+ */
+mdadm_status_t
+read_uefi_acpi_orom_data(int fd, uefi_acpi_table_with_orom_t *uefi_table)
+{
+ assert(is_fd_valid(fd));
+
+ if (lseek(fd, uefi_table->table.dataOffset, 0) == -1L)
+ return MDADM_STATUS_ERROR;
+
+ if (read(fd, &uefi_table->orom, sizeof(uefi_table->orom)) == -1)
+ return MDADM_STATUS_ERROR;
+
+ return MDADM_STATUS_SUCCESS;
+}
+
+/**
+ * verify_uefi_acpi_table_length() - verify if ACPI UEFI table have correct length with focus at
+ * OROM.
+ * @table: struct with UEFI table.
+ *
+ * Verify if ACPI UEFI table have correct length with focus at OROM. Make sure that the file is
+ * correct and contains the appropriate length data based on the length of the OROM.
+ *
+ * Return: %true if length is correct, %false otherwise.
+ */
+bool verify_uefi_acpi_table_length(struct uefi_acpi_table table)
+{
+ if (table.length < ACPI_UEFI_DATA_OFFSET)
+ return false;
+
+ if (table.length - table.dataOffset != sizeof(struct imsm_orom))
+ return false;
+ return true;
+}
+
+/**
+ * find_orom_in_acpi_uefi_tables() - find OROM in UEFI ACPI tables based on requested OROM ids.
+ * @imsm_orom_ids: array of IMSM OROM Identifiers.
+ * @imsm_orom_ids_number: number of IMSM OROM Identifiers.
+ * @orom: OROM struct buffer to fill out.
+ *
+ * Find OROM in UEFI ACPI tables provided by Intel, based on requested controllers.
+ * The first one to be matched, will be used.
+ * If found, the buffer with the OROM structure will be filled.
+ *
+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise.
+ */
+mdadm_status_t
+find_orom_in_acpi_uefi_tables(imsm_orom_id_t *imsm_orom_ids, int imsm_orom_ids_number,
+ struct imsm_orom *orom)
+{
+ mdadm_status_t status = MDADM_STATUS_ERROR;
+ uefi_acpi_table_with_orom_t uefi_table;
+ char path[PATH_MAX];
+ struct dirent *ent;
+ int fd = -1;
+ DIR *dir;
+
+ dir = opendir(ACPI_TABLES_PATH);
+ if (!dir)
+ return MDADM_STATUS_ERROR;
+
+ for (ent = readdir(dir); ent; ent = readdir(dir)) {
+ close_fd(&fd);
+
+ /* Check if file is a UEFI table */
+ if (strncmp(ent->d_name, ACPI_UEFI_TABLE_BASE_NAME,
+ strlen(ACPI_UEFI_TABLE_BASE_NAME)) != 0)
+ continue;
+
+ snprintf(path, PATH_MAX, "%s/%s", ACPI_TABLES_PATH, ent->d_name);
+
+ fd = open(path, O_RDONLY);
+ if (!is_fd_valid(fd)) {
+ pr_err("Fail to open ACPI UEFI table file. File: %s, Error: %s\n",
+ ent->d_name, strerror(errno));
+ continue;
+ }
+
+ if (read(fd, &uefi_table.table, sizeof(struct uefi_acpi_table)) == -1) {
+ pr_err("Fail to read IMSM OROM from ACPI UEFI table file. File: %s\n",
+ ent->d_name);
+ continue;
+ }
+
+ if (!acpi_any_imsm_orom_id_matching(imsm_orom_ids, imsm_orom_ids_number,
+ uefi_table.table))
+ continue;
+
+ if (!verify_uefi_acpi_table_length(uefi_table.table))
+ continue;
+
+ if (read_uefi_acpi_orom_data(fd, &uefi_table)) {
+ pr_err("Fail to read IMSM OROM from ACPI UEFI table file. File: %s\n",
+ ent->d_name);
+ continue;
+ }
+
+ memcpy(orom, &uefi_table.orom, sizeof(uefi_table.orom));
+ status = MDADM_STATUS_SUCCESS;
+ break;
+ }
+
+ close_fd(&fd);
+ closedir(dir);
+ return status;
+}
+
+/**
+ * find_orom_in_efi_variables() - find first IMSM OROM in EFI vars that matches any imsm_orom_id.
+ * @imsm_orom_ids: array of IMSM OROM Identifiers.
+ * @imsm_orom_ids_number: number of IMSM OROM Identifiers.
+ * @orom: OROM struct buffer to fill out.
+ *
+ * Find IMSM OROM that matches on of imsm_orom_id in EFI variables. The first match is used.
+ * If found, the buffer with the OROM structure is filled.
+ *
+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise.
+ */
+mdadm_status_t
+find_orom_in_efi_variables(imsm_orom_id_t *imsm_orom_ids, int imsm_orom_ids_number,
+ struct imsm_orom *orom)
+{
+ int index;
+
+ for (index = 0; index < imsm_orom_ids_number; index++)
+ if (!read_efi_variable(orom, sizeof(struct imsm_orom), imsm_orom_ids[index].name,
+ INTEL_RST_VENDOR_GUID))
+ return MDADM_STATUS_SUCCESS;
+ return MDADM_STATUS_ERROR;
+}
+
+/**
+ * find_imsm_efi_orom() - find OROM for requested controller.
+ * @orom: buffer for OROM.
+ * @controller_type: requested controller type.
+ *
+ * Based on controller type, function first search in EFI vars then in ACPI UEFI tables.
+ * For each controller there is defined an array of OROM ids from which we can read OROM,
+ * the first one to be matched, will be used.
+ * In case of success, the structure &orom will be filed out.
+ *
+ * Return: %MDADM_STATUS_SUCCESS on success.
+ */
+static mdadm_status_t
+find_imsm_efi_orom(struct imsm_orom *orom, enum sys_dev_type controller_type)
+{
+ static imsm_orom_id_t sata_imsm_orrom_ids[] = {
+ {AHCI_PROP, RST_SATA_V_GUID},
+ {AHCI_SSATA_PROP, RST_SSATA_V_GUID},
+ {AHCI_TSATA_PROP, RST_TSATA_V_GUID},
+ };
+ static imsm_orom_id_t vmd_imsm_orom_ids[] = {
+ {VROC_VMD_PROP, RST_UEFI_V_GUID},
+ {RST_VMD_PROP, RST_VMD_V_GUID},
+ };
+ static imsm_orom_id_t *imsm_orom_ids;
+ int imsm_orom_ids_number;
+
+ switch (controller_type) {
+ case SYS_DEV_SATA:
+ imsm_orom_ids = sata_imsm_orrom_ids;
+ imsm_orom_ids_number = ARRAY_SIZE(sata_imsm_orrom_ids);
+ break;
+ case SYS_DEV_VMD:
+ case SYS_DEV_SATA_VMD:
+ imsm_orom_ids = vmd_imsm_orom_ids;
+ imsm_orom_ids_number = ARRAY_SIZE(vmd_imsm_orom_ids);
+ break;
+ default:
+ return MDADM_STATUS_UNDEF;
+ }
+
+ if (!find_orom_in_efi_variables(imsm_orom_ids, imsm_orom_ids_number, orom))
+ return MDADM_STATUS_SUCCESS;
+
+ return find_orom_in_acpi_uefi_tables(imsm_orom_ids, imsm_orom_ids_number, orom);
+}
+
const struct imsm_orom *find_imsm_efi(struct sys_dev *hba)
{
struct imsm_orom orom;
struct orom_entry *ret;
- static const char * const sata_efivars[] = {AHCI_PROP, AHCI_SSATA_PROP,
- AHCI_TSATA_PROP};
- static const char * const vmd_efivars[] = {VROC_VMD_PROP, RST_VMD_PROP};
- unsigned long i;
if (check_env("IMSM_TEST_AHCI_EFI") || check_env("IMSM_TEST_SCU_EFI"))
return imsm_platform_test(hba);
@@ -687,36 +977,20 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba)
switch (hba->type) {
case SYS_DEV_SAS:
- if (!read_efi_variable(&orom, sizeof(orom), SCU_PROP,
- VENDOR_GUID))
+ if (!read_efi_variable(&orom, sizeof(orom), SCU_PROP, INTEL_RST_VENDOR_GUID))
break;
-
return NULL;
case SYS_DEV_SATA:
if (hba->class != PCI_CLASS_RAID_CNTRL)
return NULL;
- for (i = 0; i < ARRAY_SIZE(sata_efivars); i++) {
- if (!read_efi_variable(&orom, sizeof(orom),
- sata_efivars[i], VENDOR_GUID))
- break;
-
- }
- if (i == ARRAY_SIZE(sata_efivars))
+ if (find_imsm_efi_orom(&orom, hba->type))
return NULL;
-
break;
case SYS_DEV_VMD:
case SYS_DEV_SATA_VMD:
- for (i = 0; i < ARRAY_SIZE(vmd_efivars); i++) {
- if (!read_efi_variable(&orom, sizeof(orom),
- vmd_efivars[i], VENDOR_GUID))
- break;
- }
-
- if (i == ARRAY_SIZE(vmd_efivars))
+ if (find_imsm_efi_orom(&orom, hba->type))
return NULL;
-
break;
default:
return NULL;
--
2.41.0

View File

@ -0,0 +1,146 @@
From 6e793aeace463d7687656f7ac6968300ba106228 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Thu, 8 Aug 2024 13:07:50 +0200
Subject: [PATCH 162/201] imsm: get bus from VMD driver directory
Enumeration of VMD child devices is started early, kernel is not waiting
for VMD enumeration to finish. It causes that:
/sys/bus/pci/drivers/vmd/{dev}/domain/device link might be not yet ready.
With PCI gen5 devices we can observe that mdadm is failing to start IMSM
raid arrays because of that. In that case, it needs to find bus path
manually.
Look for bus device in VMD driver directory if realpath() failed with
ENOENT.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
platform-intel.c | 88 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 77 insertions(+), 11 deletions(-)
diff --git a/platform-intel.c b/platform-intel.c
index 9705c925..d0ef9111 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -105,12 +105,75 @@ static void free_sys_dev(struct sys_dev **list)
}
}
+/**
+ * vmd_find_pci_bus() - look for PCI bus created by VMD.
+ * @vmd_path: path to vmd driver.
+ * @buf: return buffer, must be PATH_MAX.
+ *
+ * Each VMD device represents one domain and each VMD device adds separate PCI bus.
+ * IMSM must know VMD domains, therefore it needs to determine and follow buses.
+ *
+ */
+mdadm_status_t vmd_find_pci_bus(char *vmd_path, char *buf)
+{
+ char tmp[PATH_MAX];
+ struct dirent *ent;
+ DIR *vmd_dir;
+ char *rp_ret;
+
+ snprintf(tmp, PATH_MAX, "%s/domain/device", vmd_path);
+
+ rp_ret = realpath(tmp, buf);
+
+ if (rp_ret)
+ return MDADM_STATUS_SUCCESS;
+
+ if (errno != ENOENT)
+ return MDADM_STATUS_ERROR;
+
+ /*
+ * If it is done early, there is a chance that kernel is still enumerating VMD device but
+ * kernel did enough to start enumerating child devices, {vmd_path}/domain/device link may
+ * not exist yet. We have to look into @vmd_path directory and find it ourselves.
+ */
+
+ vmd_dir = opendir(vmd_path);
+
+ if (!vmd_dir)
+ return MDADM_STATUS_ERROR;
+
+ for (ent = readdir(vmd_dir); ent; ent = readdir(vmd_dir)) {
+ static const char pci[] = "pci";
+
+ /**
+ * Pci bus must have form pciXXXXX:XX, where X is a digit i.e pci10000:00.
+ * We do not check digits here, it is sysfs so it should be safe to check
+ * length and ':' position only.
+ */
+ if (strncmp(ent->d_name, pci, strlen(pci)) != 0)
+ continue;
+
+ if (ent->d_name[8] != ':' || ent->d_name[11] != 0)
+ continue;
+ break;
+ }
+
+ if (!ent) {
+ closedir(vmd_dir);
+ return MDADM_STATUS_ERROR;
+ }
+
+ snprintf(buf, PATH_MAX, "%s/%s", vmd_path, ent->d_name);
+ closedir(vmd_dir);
+ return MDADM_STATUS_SUCCESS;
+}
+
struct sys_dev *find_driver_devices(const char *bus, const char *driver)
{
/* search sysfs for devices driven by 'driver' */
char path[PATH_MAX];
char link[PATH_MAX];
- char *c, *p;
+ char *c;
DIR *driver_dir;
struct dirent *de;
struct sys_dev *head = NULL;
@@ -142,8 +205,9 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
return NULL;
}
for (de = readdir(driver_dir); de; de = readdir(driver_dir)) {
- int n;
int skip = 0;
+ char *p;
+ int n;
/* is 'de' a device? check that the 'subsystem' link exists and
* that its target matches 'bus'
@@ -195,18 +259,20 @@ struct sys_dev *find_driver_devices(const char *bus, const char *driver)
if (devpath_to_ll(path, "class", &class) != 0)
continue;
- /*
- * Each VMD device (domain) adds separate PCI bus, it is better
- * to store path as a path to that bus (easier further
- * determination which NVMe dev is connected to this particular
- * VMD domain).
- */
if (type == SYS_DEV_VMD) {
- sprintf(path, "/sys/bus/%s/drivers/%s/%s/domain/device",
- bus, driver, de->d_name);
+ char vmd_path[PATH_MAX];
+
+ sprintf(vmd_path, "/sys/bus/%s/drivers/%s/%s", bus, driver, de->d_name);
+
+ if (vmd_find_pci_bus(vmd_path, path)) {
+ pr_err("Cannot determine VMD bus for %s\n", vmd_path);
+ continue;
+ }
}
+
p = realpath(path, NULL);
- if (p == NULL) {
+
+ if (!p) {
pr_err("Unable to get real path for '%s'\n", path);
continue;
}
--
2.41.0

View File

@ -0,0 +1,129 @@
From a6392b419f38a0144a03df90371d6890540a55cf Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Tue, 7 May 2024 12:05:43 -0400
Subject: [PATCH 163/201] platform-intel: refactor path_attached_to_hba()
dprintf() call in path_attached_to_hba() is too noisy. Remove the call
and refactor the function. Remove obsolete env variables check.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
---
platform-intel.c | 31 ++++++++++++++-----------------
platform-intel.h | 2 +-
super-intel.c | 8 ++++----
3 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/platform-intel.c b/platform-intel.c
index d0ef9111..3a86f785 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -1331,31 +1331,28 @@ char *diskfd_to_devpath(int fd, int dev_level, char *buf)
return devt_to_devpath(st.st_rdev, dev_level, buf);
}
-
-int path_attached_to_hba(const char *disk_path, const char *hba_path)
+/**
+ * is_path_attached_to_hba() - Check if disk is attached to hba
+ *
+ * @disk_path: Path to disk.
+ * @hba_path: Path to hba.
+ *
+ * Returns: true if disk is attached to hba, false otherwise.
+ */
+bool is_path_attached_to_hba(const char *disk_path, const char *hba_path)
{
- int rc;
-
- if (check_env("IMSM_TEST_AHCI_DEV") ||
- check_env("IMSM_TEST_SCU_DEV")) {
- return 1;
- }
-
if (!disk_path || !hba_path)
- return 0;
- dprintf("hba: %s - disk: %s\n", hba_path, disk_path);
+ return false;
if (strncmp(disk_path, hba_path, strlen(hba_path)) == 0)
- rc = 1;
- else
- rc = 0;
+ return true;
- return rc;
+ return false;
}
int devt_attached_to_hba(dev_t dev, const char *hba_path)
{
char *disk_path = devt_to_devpath(dev, 1, NULL);
- int rc = path_attached_to_hba(disk_path, hba_path);
+ int rc = is_path_attached_to_hba(disk_path, hba_path);
if (disk_path)
free(disk_path);
@@ -1366,7 +1363,7 @@ int devt_attached_to_hba(dev_t dev, const char *hba_path)
int disk_attached_to_hba(int fd, const char *hba_path)
{
char *disk_path = diskfd_to_devpath(fd, 1, NULL);
- int rc = path_attached_to_hba(disk_path, hba_path);
+ int rc = is_path_attached_to_hba(disk_path, hba_path);
if (disk_path)
free(disk_path);
diff --git a/platform-intel.h b/platform-intel.h
index dcc5aaa7..344624d7 100644
--- a/platform-intel.h
+++ b/platform-intel.h
@@ -257,7 +257,7 @@ const struct imsm_orom *find_imsm_orom(void);
int disk_attached_to_hba(int fd, const char *hba_path);
int devt_attached_to_hba(dev_t dev, const char *hba_path);
char *devt_to_devpath(dev_t dev, int dev_level, char *buf);
-int path_attached_to_hba(const char *disk_path, const char *hba_path);
+bool is_path_attached_to_hba(const char *disk_path, const char *hba_path);
const struct orom_entry *get_orom_entry_by_device_id(__u16 dev_id);
const struct imsm_orom *get_orom_by_device_id(__u16 device_id);
struct sys_dev *device_by_id(__u16 device_id);
diff --git a/super-intel.c b/super-intel.c
index 354c292a..75d7c060 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -800,7 +800,7 @@ static struct sys_dev* find_disk_attached_hba(int fd, const char *devname)
return 0;
for (elem = list; elem; elem = elem->next)
- if (path_attached_to_hba(disk_path, elem->path))
+ if (is_path_attached_to_hba(disk_path, elem->path))
break;
if (disk_path != devname)
@@ -2412,7 +2412,7 @@ static int ahci_enumerate_ports(struct sys_dev *hba, unsigned long port_count, i
path = devt_to_devpath(makedev(major, minor), 1, NULL);
if (!path)
continue;
- if (!path_attached_to_hba(path, hba->path)) {
+ if (!is_path_attached_to_hba(path, hba->path)) {
free(path);
path = NULL;
continue;
@@ -2563,7 +2563,7 @@ static int print_nvme_info(struct sys_dev *hba)
!diskfd_to_devpath(fd, 1, cntrl_path))
goto skip;
- if (!path_attached_to_hba(cntrl_path, hba->path))
+ if (!is_path_attached_to_hba(cntrl_path, hba->path))
goto skip;
if (!imsm_is_nvme_namespace_supported(fd, 0))
@@ -7077,7 +7077,7 @@ get_devices(const char *hba_path)
path = devt_to_devpath(makedev(major, minor), 1, NULL);
if (!path)
continue;
- if (!path_attached_to_hba(path, hba_path)) {
+ if (!is_path_attached_to_hba(path, hba_path)) {
free(path);
path = NULL;
continue;
--
2.41.0

View File

@ -0,0 +1,44 @@
From bd5511c792ecc73de8897fbd8713e8c6eaf3e835 Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Wed, 28 Aug 2024 12:04:35 +0200
Subject: [PATCH 164/201] mdadm: Change displaying of devices in --detail
The counts of active, working, failed and spare devices were not
printed when the number was zero.
Refactor the code to always display the counts of all device types,
regardless of their number. This way, it is more reliable for users.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
Detail.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/Detail.c b/Detail.c
index f8b9e847..331e1da3 100644
--- a/Detail.c
+++ b/Detail.c
@@ -549,16 +549,10 @@ int Detail(char *dev, struct context *c)
} else if (inactive && !is_container) {
printf(" State : inactive\n");
}
- if (array.raid_disks)
- printf(" Active Devices : %d\n", array.active_disks);
- if (array.working_disks > 0)
- printf(" Working Devices : %d\n",
- array.working_disks);
- if (array.raid_disks) {
- printf(" Failed Devices : %d\n", array.failed_disks);
- if (!external)
- printf(" Spare Devices : %d\n", array.spare_disks);
- }
+ printf(" Active Devices : %d\n", array.active_disks);
+ printf(" Working Devices : %d\n", array.working_disks);
+ printf(" Failed Devices : %d\n", array.failed_disks);
+ printf(" Spare Devices : %d\n", array.spare_disks);
printf("\n");
if (array.level == 5) {
str = map_num(r5layout, array.layout);
--
2.41.0

View File

@ -0,0 +1,196 @@
From 734e7db4dfc502044d2a3dacfab67aeab0081cf9 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Thu, 22 Aug 2024 11:55:15 +0200
Subject: [PATCH 165/201] imsm: Remove warning and refactor add_to_super_imsm
code
Intel x8 drives are not supported, remove unnecessary warning and
refactor add_to_super_imsm code.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
super-intel.c | 102 +++++++++++++++++++-------------------------------
1 file changed, 39 insertions(+), 63 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 75d7c060..50fd56d0 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5976,12 +5976,12 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
unsigned long long data_offset)
{
struct intel_super *super = st->sb;
- struct dl *dd;
- unsigned long long size;
unsigned int member_sector_size;
+ unsigned long long size;
+ struct stat stb;
+ struct dl *dd;
__u32 id;
int rv;
- struct stat stb;
/* If we are on an RAID enabled platform check that the disk is
* attached to the raid controller.
@@ -5991,114 +5991,86 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
rv = find_intel_hba_capability(fd, super, devname);
/* no orom/efi or non-intel hba of the disk */
if (rv != 0) {
- dprintf("capability: %p fd: %d ret: %d\n",
- super->orom, fd, rv);
- return 1;
+ dprintf("capability: %p fd: %d ret: %d\n", super->orom, fd, rv);
+ return MDADM_STATUS_ERROR;
}
if (super->current_vol >= 0)
return add_to_super_imsm_volume(st, dk, fd, devname);
if (fstat(fd, &stb) != 0)
- return 1;
+ return MDADM_STATUS_ERROR;
+
dd = xcalloc(sizeof(*dd), 1);
+
+ if (devname)
+ dd->devname = xstrdup(devname);
+
+ if (sysfs_disk_to_scsi_id(fd, &id) == 0)
+ dd->disk.scsi_id = __cpu_to_le32(id);
+
dd->major = major(stb.st_rdev);
dd->minor = minor(stb.st_rdev);
- dd->devname = devname ? xstrdup(devname) : NULL;
- dd->fd = fd;
- dd->e = NULL;
dd->action = DISK_ADD;
+ dd->fd = fd;
+
rv = imsm_read_serial(fd, devname, dd->serial, MAX_RAID_SERIAL_LEN);
if (rv) {
pr_err("failed to retrieve scsi serial, aborting\n");
- __free_imsm_disk(dd, 0);
- abort();
+ goto error;
}
if (super->hba && ((super->hba->type == SYS_DEV_NVME) ||
(super->hba->type == SYS_DEV_VMD))) {
- int i;
- char cntrl_path[PATH_MAX];
- char *cntrl_name;
char pci_dev_path[PATH_MAX];
+ char cntrl_path[PATH_MAX];
if (!diskfd_to_devpath(fd, 2, pci_dev_path) ||
!diskfd_to_devpath(fd, 1, cntrl_path)) {
pr_err("failed to get dev paths, aborting\n");
- __free_imsm_disk(dd, 0);
- return 1;
+ goto error;
}
- cntrl_name = basename(cntrl_path);
if (is_multipath_nvme(fd))
pr_err("%s controller supports Multi-Path I/O, Intel (R) VROC does not support multipathing\n",
- cntrl_name);
+ basename(cntrl_path));
- if (devpath_to_vendor(pci_dev_path) == 0x8086) {
- /*
- * If Intel's NVMe drive has serial ended with
- * "-A","-B","-1" or "-2" it means that this is "x8"
- * device (double drive on single PCIe card).
- * User should be warned about potential data loss.
- */
- for (i = MAX_RAID_SERIAL_LEN-1; i > 0; i--) {
- /* Skip empty character at the end */
- if (dd->serial[i] == 0)
- continue;
-
- if (((dd->serial[i] == 'A') ||
- (dd->serial[i] == 'B') ||
- (dd->serial[i] == '1') ||
- (dd->serial[i] == '2')) &&
- (dd->serial[i-1] == '-'))
- pr_err("\tThe action you are about to take may put your data at risk.\n"
- "\tPlease note that x8 devices may consist of two separate x4 devices "
- "located on a single PCIe port.\n"
- "\tRAID 0 is the only supported configuration for this type of x8 device.\n");
- break;
- }
- } else if (super->hba->type == SYS_DEV_VMD && super->orom &&
+ if (super->hba->type == SYS_DEV_VMD && super->orom &&
!imsm_orom_has_tpv_support(super->orom)) {
pr_err("\tPlatform configuration does not support non-Intel NVMe drives.\n"
"\tPlease refer to Intel(R) RSTe/VROC user guide.\n");
- __free_imsm_disk(dd, 0);
- return 1;
+ goto error;
}
}
- get_dev_size(fd, NULL, &size);
- if (!get_dev_sector_size(fd, NULL, &member_sector_size)) {
- __free_imsm_disk(dd, 0);
- return 1;
- }
+ if (!get_dev_size(fd, NULL, &size) || !get_dev_sector_size(fd, NULL, &member_sector_size))
+ goto error;
- if (super->sector_size == 0) {
+ if (super->sector_size == 0)
/* this a first device, so sector_size is not set yet */
super->sector_size = member_sector_size;
- }
/* clear migr_rec when adding disk to container */
- memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE);
- if (lseek64(fd, size - MIGR_REC_SECTOR_POSITION*member_sector_size,
- SEEK_SET) >= 0) {
- if ((unsigned int)write(fd, super->migr_rec_buf,
- MIGR_REC_BUF_SECTORS*member_sector_size) !=
- MIGR_REC_BUF_SECTORS*member_sector_size)
+ memset(super->migr_rec_buf, 0, MIGR_REC_BUF_SECTORS * MAX_SECTOR_SIZE);
+
+ if (lseek64(fd, (size - MIGR_REC_SECTOR_POSITION * member_sector_size), SEEK_SET) >= 0) {
+ unsigned int nbytes = MIGR_REC_BUF_SECTORS * member_sector_size;
+
+ if ((unsigned int)write(fd, super->migr_rec_buf, nbytes) != nbytes)
perror("Write migr_rec failed");
}
size /= 512;
serialcpy(dd->disk.serial, dd->serial);
set_total_blocks(&dd->disk, size);
+
if (__le32_to_cpu(dd->disk.total_blocks_hi) > 0) {
struct imsm_super *mpb = super->anchor;
+
mpb->attributes |= MPB_ATTRIB_2TB_DISK;
}
+
mark_spare(dd);
- if (sysfs_disk_to_scsi_id(fd, &id) == 0)
- dd->disk.scsi_id = __cpu_to_le32(id);
- else
- dd->disk.scsi_id = __cpu_to_le32(0);
if (st->update_tail) {
dd->next = super->disk_mgmt_list;
@@ -6113,7 +6085,11 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
write_super_imsm_spare(super, dd);
}
- return 0;
+ return MDADM_STATUS_SUCCESS;
+
+error:
+ __free_imsm_disk(dd, 0);
+ return MDADM_STATUS_ERROR;
}
static int remove_from_super_imsm(struct supertype *st, mdu_disk_info_t *dk)
--
2.41.0

View File

@ -0,0 +1,192 @@
From b1d38b512aa3162b5089fbf6b02357ed5fdf5760 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Thu, 22 Aug 2024 12:18:06 +0200
Subject: [PATCH 166/201] imsm: add IMSM_OROM_CAPABILITIES_TPV to nvme orom
Add it to avoid excluding. It has some value for users even if it is
always true for nvme virtual orom.
Rework detail-platform printing code, move printing 3rd party nvmes
to print_imsm_capability (as it should be), but keep it meaningful
only for nvme controllers (NVME and VMD hba types). Pass whole
orom_entry instead of orom there.
Squash code responsible for printing NVME and VMD hbas.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
platform-intel.c | 3 +-
super-intel.c | 76 +++++++++++++++++++++++-------------------------
2 files changed, 39 insertions(+), 40 deletions(-)
diff --git a/platform-intel.c b/platform-intel.c
index 3a86f785..21591317 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -1089,7 +1089,8 @@ const struct imsm_orom *find_imsm_nvme(struct sys_dev *hba)
.vpa = IMSM_OROM_VOLUMES_PER_ARRAY,
.vphba = IMSM_OROM_TOTAL_DISKS_NVME / 2 * IMSM_OROM_VOLUMES_PER_ARRAY,
.attr = IMSM_OROM_ATTR_2TB | IMSM_OROM_ATTR_2TB_DISK,
- .driver_features = IMSM_OROM_CAPABILITIES_EnterpriseSystem
+ .driver_features = IMSM_OROM_CAPABILITIES_EnterpriseSystem |
+ IMSM_OROM_CAPABILITIES_TPV
};
nvme_orom = add_orom(&nvme_orom_compat);
}
diff --git a/super-intel.c b/super-intel.c
index 50fd56d0..744715d5 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2663,9 +2663,12 @@ static void print_imsm_chunk_size_capability(const struct imsm_orom *orom)
}
-static void print_imsm_capability(const struct imsm_orom *orom)
+static void print_imsm_capability(const struct orom_entry *entry)
{
+ const struct imsm_orom *orom = &entry->orom;
+
printf(" Platform : Intel(R) ");
+
if (orom->capabilities == 0 && orom->driver_features == 0)
printf("Matrix Storage Manager\n");
else if (imsm_orom_is_enterprise(orom) && orom->major_ver >= 6)
@@ -2673,6 +2676,7 @@ static void print_imsm_capability(const struct imsm_orom *orom)
else
printf("Rapid Storage Technology%s\n",
imsm_orom_is_enterprise(orom) ? " enterprise" : "");
+
if (orom->major_ver || orom->minor_ver || orom->hotfix_ver || orom->build) {
if (imsm_orom_is_vmd_without_efi(orom))
printf(" Version : %d.%d\n", orom->major_ver, orom->minor_ver);
@@ -2690,11 +2694,19 @@ static void print_imsm_capability(const struct imsm_orom *orom)
printf("\n");
printf(" 2TB volumes :%s supported\n", (orom->attr & IMSM_OROM_ATTR_2TB) ? "" : " not");
+
printf(" 2TB disks :%s supported\n",
(orom->attr & IMSM_OROM_ATTR_2TB_DISK) ? "" : " not");
+
printf(" Max Disks : %d\n", orom->tds);
+
printf(" Max Volumes : %d per array, %d per %s\n", orom->vpa, orom->vphba,
imsm_orom_is_nvme(orom) ? "platform" : "controller");
+
+ if (entry->type == SYS_DEV_VMD || entry->type == SYS_DEV_NVME)
+ /* This is only meaningful for controllers with nvme support */
+ printf(" 3rd party NVMe :%s supported\n",
+ imsm_orom_has_tpv_support(&entry->orom) ? "" : " not");
return;
}
@@ -2733,26 +2745,25 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
* platform capabilities. If raid support is disabled in the BIOS the
* option-rom capability structure will not be available.
*/
+ const struct orom_entry *entry;
struct sys_dev *list, *hba;
- int host_base = 0;
+ struct devid_list *devid;
int port_count = 0;
- int result=1;
+ int host_base = 0;
+ int result = 1;
if (enumerate_only) {
if (check_no_platform())
return 0;
+
list = find_intel_devices();
if (!list)
return 2;
- for (hba = list; hba; hba = hba->next) {
- if (find_imsm_capability(hba)) {
- result = 0;
- break;
- }
- else
- result = 2;
- }
- return result;
+
+ for (hba = list; hba; hba = hba->next)
+ if (find_imsm_capability(hba))
+ return 0;
+ return 2;
}
list = find_intel_devices();
@@ -2768,6 +2779,7 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
continue;
if (!find_imsm_capability(hba)) {
char buf[PATH_MAX];
+
pr_err("imsm capabilities not found for controller: %s (type %s)\n",
hba->type == SYS_DEV_VMD || hba->type == SYS_DEV_SATA_VMD ?
vmd_domain_to_controller(hba, buf) :
@@ -2783,40 +2795,27 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle
return result;
}
- const struct orom_entry *entry;
-
for (entry = orom_entries; entry; entry = entry->next) {
- if (entry->type == SYS_DEV_VMD) {
- print_imsm_capability(&entry->orom);
- printf(" 3rd party NVMe :%s supported\n",
- imsm_orom_has_tpv_support(&entry->orom)?"":" not");
+ print_imsm_capability(entry);
+
+ if (entry->type == SYS_DEV_VMD || entry->type == SYS_DEV_NVME) {
for (hba = list; hba; hba = hba->next) {
- if (hba->type == SYS_DEV_VMD) {
- char buf[PATH_MAX];
+ char buf[PATH_MAX];
+
+ if (hba->type != entry->type)
+ continue;
+
+ if (hba->type == SYS_DEV_VMD)
printf(" I/O Controller : %s (%s)\n",
- vmd_domain_to_controller(hba, buf), get_sys_dev_type(hba->type));
- if (print_nvme_info(hba)) {
- if (verbose > 0)
- pr_err("failed to get devices attached to VMD domain.\n");
- result |= 2;
- }
- }
- }
- printf("\n");
- continue;
- }
+ vmd_domain_to_controller(hba, buf),
+ get_sys_dev_type(hba->type));
- print_imsm_capability(&entry->orom);
- if (entry->type == SYS_DEV_NVME) {
- for (hba = list; hba; hba = hba->next) {
- if (hba->type == SYS_DEV_NVME)
- print_nvme_info(hba);
+ print_nvme_info(hba);
}
printf("\n");
continue;
}
- struct devid_list *devid;
for (devid = entry->devid_list; devid; devid = devid->next) {
hba = device_by_id(devid->devid);
if (!hba)
@@ -6035,8 +6034,7 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
pr_err("%s controller supports Multi-Path I/O, Intel (R) VROC does not support multipathing\n",
basename(cntrl_path));
- if (super->hba->type == SYS_DEV_VMD && super->orom &&
- !imsm_orom_has_tpv_support(super->orom)) {
+ if (super->orom && !imsm_orom_has_tpv_support(super->orom)) {
pr_err("\tPlatform configuration does not support non-Intel NVMe drives.\n"
"\tPlease refer to Intel(R) RSTe/VROC user guide.\n");
goto error;
--
2.41.0

View File

@ -0,0 +1,33 @@
From f786072a3e2928766a9b4f1b7d3372a601c259ea Mon Sep 17 00:00:00 2001
From: Shminderjit Singh <shminderjit.singh@oracle.com>
Date: Mon, 26 Aug 2024 10:06:50 +0000
Subject: [PATCH 167/201] mdadm: Increase number limit in md device name to
1024.
Updated the maximum device number in md device names from 127 to 1024.
The previous limit was causing issues in the automation framework.
This change ensures backward compatibility and allows for future
scalability.
Fixes: 25aa7329141c ("mdadm: numbered names verification")
Signed-off-by: Shminderjit Singh <shminderjit.singh@oracle.com>
---
util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 1cee0feb..2fc0e9f8 100644
--- a/util.c
+++ b/util.c
@@ -1003,7 +1003,7 @@ static bool is_devname_numbered(const char *devname, const char *pref, const int
if (parse_num(&val, devname + pref_len) != 0)
return false;
- if (val > 127)
+ if (val > 1024)
return false;
return true;
--
2.41.0

View File

@ -0,0 +1,44 @@
From dd0d193ad8722140e240c95a4fd1e214077dd719 Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Mon, 2 Sep 2024 12:27:56 -0400
Subject: [PATCH 168/201] imsm: save checkpoint prior to exit
If reshape (eg. chunksize migration) is gracefully stopped via SIGTERM
the checkpoint is not saved and reshape cannot be resumed due to "data
being present in copy area". This is because UNIT_SRC_NORMAL isn't set
if SIGTERM occurred.
Move SIGTERM handling at the end of the loop to allow saving checkpoint
(and state) so reshapes can be properly resumed.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
---
super-intel.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 744715d5..30c2939a 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -12631,8 +12631,6 @@ static int imsm_manage_reshape(
dprintf("wait_for_reshape_imsm returned error!\n");
goto abort;
}
- if (sigterm)
- goto abort;
if (save_checkpoint_imsm(st, sra, UNIT_SRC_NORMAL) == 1) {
/* ignore error == 2, this can mean end of reshape here
@@ -12641,6 +12639,9 @@ static int imsm_manage_reshape(
goto abort;
}
+ if (sigterm)
+ goto abort;
+
}
/* clear migr_rec on disks after successful migration */
--
2.41.0

View File

@ -0,0 +1,116 @@
From da26064bfe4457d5037f3a1f1bb83a54225c6375 Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Thu, 8 Aug 2024 17:02:38 +0200
Subject: [PATCH 169/201] Examine.c: Fix memory leaks in Examine()
Fix memory leaks in Examine() reported by SAST analysis. Implement a
method to traverse and free all the nodes of the doubly linked list.
Replace for loop with while loop in order to improve redability of the
code and free allocated memory correctly.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
Examine.c | 22 +++++++++++++++++-----
dlink.c | 15 +++++++++++++++
dlink.h | 1 +
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/Examine.c b/Examine.c
index c9605a60..fe162167 100644
--- a/Examine.c
+++ b/Examine.c
@@ -111,8 +111,10 @@ int Examine(struct mddev_dev *devlist,
close(fd);
if (err) {
- if (st)
+ if (st) {
st->ss->free_super(st);
+ free(st);
+ }
continue;
}
@@ -152,19 +154,24 @@ int Examine(struct mddev_dev *devlist,
if (st->ss->export_examine_super)
st->ss->export_examine_super(st);
st->ss->free_super(st);
+ free(st);
} else {
printf("%s:\n",devlist->devname);
st->ss->examine_super(st, c->homehost);
st->ss->free_super(st);
+ free(st);
}
}
if (c->brief) {
- struct array *ap;
- for (ap = arrays; ap; ap = ap->next) {
+ struct array *ap = arrays, *next;
+
+ while (ap) {
char sep='=';
char *d;
int newline = 0;
+ next = ap->next;
+
ap->st->ss->brief_examine_super(ap->st, c->verbose > 0);
if (ap->spares && !ap->st->ss->external)
newline += printf(" spares=%d", ap->spares);
@@ -182,10 +189,15 @@ int Examine(struct mddev_dev *devlist,
printf("\n");
ap->st->ss->brief_examine_subarrays(ap->st, c->verbose);
}
- ap->st->ss->free_super(ap->st);
- /* FIXME free ap */
if (ap->spares || c->verbose > 0)
printf("\n");
+
+ ap->st->ss->free_super(ap->st);
+ free(ap->st);
+ dl_free_all(ap->devs);
+ free(ap);
+
+ ap = next;
}
}
return rv;
diff --git a/dlink.c b/dlink.c
index 69aa7aa3..34633672 100644
--- a/dlink.c
+++ b/dlink.c
@@ -26,6 +26,21 @@ void dl_free(void *v)
free(vv-1);
}
+void dl_free_all(void *head)
+{
+ /* The list head is linked with the list tail so in order to free
+ * all the elements properly there is a need to keep starting point.
+ */
+ void *d = dl_next(head), *next;
+
+ while (d != head) {
+ next = dl_next(d);
+ dl_free(d);
+ d = next;
+ }
+ dl_free(head);
+}
+
void dl_init(void *v)
{
dl_next(v) = v;
diff --git a/dlink.h b/dlink.h
index ab2a9459..ce667839 100644
--- a/dlink.h
+++ b/dlink.h
@@ -23,3 +23,4 @@ void dl_add(void*, void*);
void dl_del(void*);
void dl_free(void*);
void dl_init(void*);
+void dl_free_all(void *head);
--
2.41.0

View File

@ -0,0 +1,39 @@
From be1b4ff0957b287b2d8494967a7f0a1e3401dd8a Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Mon, 9 Sep 2024 09:36:47 +0200
Subject: [PATCH 170/201] dlink.h: Fix checkpatch warnings for function args
Checkpatch issued a warning due to missing function argument names.
Add the names to resolve the warnings.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
dlink.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlink.h b/dlink.h
index ce667839..18cc294a 100644
--- a/dlink.h
+++ b/dlink.h
@@ -16,11 +16,11 @@ struct __dl_head
#define dl_prev(p) *(&(((struct __dl_head*)(p))[-1].dh_prev))
void *dl_head(void);
-char *dl_strdup(char *);
-char *dl_strndup(char *, int);
-void dl_insert(void*, void*);
-void dl_add(void*, void*);
-void dl_del(void*);
-void dl_free(void*);
-void dl_init(void*);
+char *dl_strdup(char *s);
+char *dl_strndup(char *s, int l);
+void dl_insert(void *head, void *val);
+void dl_add(void *head, void *val);
+void dl_del(void *val);
+void dl_free(void *v);
+void dl_init(void *v);
void dl_free_all(void *head);
--
2.41.0

View File

@ -0,0 +1,151 @@
From 9b8933bb6dbfcae1bd5a2f933c87684de99412de Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Tue, 25 Jun 2024 12:53:46 +0200
Subject: [PATCH 171/201] Incremental: support devnode in IncrementalRemove.
There are no reasons to keep this interface different than others.
Allow to use devnode but keep old way for backward compatibility.
Method is added to verify that only devnode or kernel name is used.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Incremental.c | 60 ++++++++++++++++++++++++-------------
mdadm.h | 5 ++++
udev-md-raid-assembly.rules | 4 +--
3 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index fc4e68ff..c1389a15 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1674,33 +1674,52 @@ static void remove_from_member_array(struct mdstat_ent *memb,
}
}
-/*
- * IncrementalRemove - Attempt to see if the passed in device belongs to any
- * raid arrays, and if so first fail (if needed) and then remove the device.
+/**
+ * is_devnode_path() - check if the devname passed might be devnode path.
+ * @devnode: the path to check.
*
- * @devname - The device we want to remove
- * @id_path - name as found in /dev/disk/by-path for this device
+ * Devnode must be located directly in /dev directory. It is not checking existence of the file
+ * because the device might no longer exist during removal from raid array.
+ */
+static bool is_devnode_path(char *devnode)
+{
+ char *devnm = strrchr(devnode, '/');
+
+ if (!devnm || *(devnm + 1) == 0)
+ return false;
+
+ if (strncmp(devnode, DEV_DIR, DEV_DIR_LEN) == 0 && devnode + DEV_DIR_LEN - 1 == devnm)
+ return true;
+
+ return false;
+}
+
+/**
+ * IncrementalRemove() - Remove the device from all raid arrays.
+ * @devname: the device we want to remove, it could be kernel device name or devnode.
+ * @id_path: optional, /dev/disk/by-path path to save for bare scenarios support.
+ * @verbose: verbose flag.
*
- * Note: the device name must be a kernel name like "sda", so
- * that we can find it in /proc/mdstat
+ * First, fail the device (if needed) and then remove the device from native raid array or external
+ * container. If it is external container, the device is removed from each subarray first.
*/
int IncrementalRemove(char *devname, char *id_path, int verbose)
{
- struct mdstat_ent *ent = NULL;
+ char *devnm = basename(devname);
+ struct mddev_dev devlist = {0};
char buf[SYSFS_MAX_BUF_SIZE];
struct mdstat_ent *mdstat;
- struct mddev_dev devlist;
+ struct mdstat_ent *ent;
struct mdinfo mdi;
int rv = 1;
int mdfd;
- if (!id_path)
- dprintf("incremental removal without --path <id_path> lacks the possibility to re-add new device in this port\n");
-
- if (strchr(devname, '/')) {
- pr_err("incremental removal requires a kernel device name, not a file: %s\n", devname);
- return 1;
- }
+ if (strcmp(devnm, devname) != 0)
+ if (!is_devnode_path(devname)) {
+ pr_err("Cannot remove \"%s\", devnode path or kernel device name is allowed.\n",
+ devname);
+ return 1;
+ }
mdstat = mdstat_read(0, 0);
if (!mdstat) {
@@ -1708,15 +1727,15 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
return 1;
}
- ent = mdstat_find_by_member_name(mdstat, devname);
+ ent = mdstat_find_by_member_name(mdstat, devnm);
if (!ent) {
if (verbose >= 0)
- pr_err("%s does not appear to be a component of any array\n", devname);
+ pr_vrb("%s does not appear to be a component of any array\n", devnm);
goto out;
}
if (sysfs_init(&mdi, -1, ent->devnm)) {
- pr_err("unable to initialize sysfs for: %s\n", devname);
+ pr_err("unable to initialize sysfs for: %s\n", devnm);
goto out;
}
@@ -1746,8 +1765,7 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
map_free(map);
}
- memset(&devlist, 0, sizeof(devlist));
- devlist.devname = devname;
+ devlist.devname = devnm;
devlist.disposition = 'I';
/* for a container, we must fail each member array */
if (is_mdstat_ent_external(ent)) {
diff --git a/mdadm.h b/mdadm.h
index 5c3a9836..f3b9f54c 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -100,6 +100,11 @@ struct dlm_lksb {
#define DEFAULT_BITMAP_DELAY 5
#define DEFAULT_MAX_WRITE_BEHIND 256
+#ifndef DEV_DIR
+#define DEV_DIR "/dev/"
+#define DEV_DIR_LEN (sizeof(DEV_DIR) - 1)
+#endif /* DEV_DIR */
+
/* DEV_NUM_PREF is a subpath to numbered MD devices, e.g. /dev/md1 or directory name.
* DEV_NUM_PREF_LEN is a length with Null byte excluded.
*/
diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules
index d4a7f0a5..4cd2c6f4 100644
--- a/udev-md-raid-assembly.rules
+++ b/udev-md-raid-assembly.rules
@@ -41,7 +41,7 @@ ACTION=="change", KERNEL!="dm-*|md*", GOTO="md_inc_end"
ACTION!="remove", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}"
ACTION!="remove", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
-ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="BINDIR/mdadm -If $name --path $env{ID_PATH}"
-ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="BINDIR/mdadm -If $name"
+ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="BINDIR/mdadm -If $devnode --path $env{ID_PATH}"
+ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="BINDIR/mdadm -If $devnode"
LABEL="md_inc_end"
--
2.41.0

View File

@ -0,0 +1,75 @@
From 7b65dd6d71dfff35847440e19d309990dfcb29d3 Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Mon, 29 Jul 2024 07:47:39 +0200
Subject: [PATCH 172/201] Detail.c: Fix divide_by_zero issue
Fix divide_by_zero issue reported by SAST analysis in Detail.c when
calling enough() from util.c. Also add missing spaces for better code
readability.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
util.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/util.c b/util.c
index 2fc0e9f8..cc162278 100644
--- a/util.c
+++ b/util.c
@@ -513,6 +513,9 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail)
int i;
int avail_disks = 0;
+ if (raid_disks <= 0)
+ return 0;
+
for (i = 0; i < raid_disks; i++)
avail_disks += !!avail[i];
@@ -521,7 +524,7 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail)
/* This is the tricky one - we need to check
* which actual disks are present.
*/
- copies = (layout&255)* ((layout>>8) & 255);
+ copies = (layout & 255) * ((layout >> 8) & 255);
first = 0;
do {
/* there must be one of the 'copies' form 'first' */
@@ -531,16 +534,16 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail)
while (n--) {
if (avail[this])
cnt++;
- this = (this+1) % raid_disks;
+ this = (this + 1) % raid_disks;
}
if (cnt == 0)
return 0;
- first = (first+(layout&255)) % raid_disks;
+ first = (first + (layout & 255)) % raid_disks;
} while (first != 0);
return 1;
case LEVEL_MULTIPATH:
- return avail_disks>= 1;
+ return avail_disks >= 1;
case LEVEL_LINEAR:
case 0:
return avail_disks == raid_disks;
@@ -556,12 +559,12 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail)
/* FALL THROUGH */
case 5:
if (clean)
- return avail_disks >= raid_disks-1;
+ return avail_disks >= raid_disks - 1;
else
return avail_disks >= raid_disks;
case 6:
if (clean)
- return avail_disks >= raid_disks-2;
+ return avail_disks >= raid_disks - 2;
else
return avail_disks >= raid_disks;
default:
--
2.41.0

View File

@ -0,0 +1,81 @@
From 983e9226fb02a91692c2c55a19b5cd06d8ddd005 Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Tue, 6 Aug 2024 10:44:01 +0200
Subject: [PATCH 173/201] mdadm: Add compilation process to README.md
Add compilation process and dependencies to README.md.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/README.md b/README.md
index 486c8929..870ecb7e 100644
--- a/README.md
+++ b/README.md
@@ -87,6 +87,61 @@ If there are differences between github and kernel.org, please contact kernel.or
We do not support kernel versions below **v3.10**. Please be aware that maintainers may remove
workarounds and fixes for legacy issues.
+# Dependencies
+
+The following packages are required for compilation:
+
+| RHEL | SLES | Debian/Ubuntu |
+| :---: | :---: | :---: |
+| `pkgconf` | `pkg-config` | `pkg-config` |
+| `gcc` | `gcc` | `gcc` |
+| `make` | `make` | `make` |
+| `libudev-devel` | `libudev-devel` | `libudev-dev` |
+
+# Compiling mdadm
+
+Run `make` command to compile mdadm.
+
+Specifying more jobs e.g. `make -j4` can decrease compilation time significantly.
+
+Various values can be specified for the `CXFLAGS` variable to customize the build process:
+- Run `make CXFLAGS=-ggdb` to include gdb debugging information.
+- Run `make CXFLAGS=-DDEBUG` to enable additional debug information through dprintf statements
+and call traces.
+- Run `make CXFLAGS=-DNO_LIBUDEV` to compile without `libudev`.
+
+To build with more than one option specified in `CXFLAGS`, separate each option with a space, e.g.
+`make CXFLAGS="-ggdb -DDEBUG"`.
+
+Additionally, the `EXTRAVERSION` variable can be set to build with user-friendly version label,
+useful when customizing mdadm builds or labeling some instance in between major releases,
+e.g. `make EXTRAVERSION="custom-label"`.
+
+# Installing mdadm
+
+Before installing mdadm, it is advised to uninstall vendor-provided packages (mdadm.deb, mdadm.rpm
+etc.) in order to avoid configuration issues.
+
+Run `make install` command to install mdadm. This command invokes the following targets:
+- `install-bin`
+- `install-man`
+- `install-udev`
+
+After installing mdadm, consider rebuilding initramfs to ensure the changes take effect.
+
+List of installation targets:
+- Run `make install-bin` to install the mdadm and mdmon binary files.
+- Run `make install-systemd` to install the systemd services.
+- Run `make install-udev` to install the udev rules.
+- Run `make install-man` to install the manual pages (`mdadm.8`, `md.4`, `mdadm.conf.5`,
+`mdmon.8`).
+
+The following targets are deprecated and should not be used:
+- `install-static`
+- `install-tcc`
+- `install-uclibc`
+- `install-klibc`
+
# License
It is released under the terms of the **GNU General Public License version 2** as published
--
2.41.0

View File

@ -0,0 +1,53 @@
From 21212f6ad7c634f5f114f342ca84fe8c42a13f40 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:23 +0800
Subject: [PATCH 174/201] mdadm/Grow: Update new level when starting reshape
Reshape needs to specify a backup file when it can't update data offset
of member disks. For this situation, first, it starts reshape and then
it kicks off mdadm-grow-continue service which does backup job and
monitors the reshape process. The service is a new process, so it needs
to read superblock from member disks to get information.
But in the first step, it doesn't update new level in superblock. So
it can't change level after reshape finishes, because the new level is
not right. So records the new level in the first step.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Grow.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Grow.c b/Grow.c
index 5810b128..533f3014 100644
--- a/Grow.c
+++ b/Grow.c
@@ -2941,15 +2941,24 @@ static int impose_reshape(struct mdinfo *sra,
* persists from some earlier problem.
*/
int err = 0;
+
if (sysfs_set_num(sra, NULL, "chunk_size", info->new_chunk) < 0)
err = errno;
+
if (!err && sysfs_set_num(sra, NULL, "layout",
reshape->after.layout) < 0)
err = errno;
+
+ /* new_level is introduced in kernel 6.12 */
+ if (!err && get_linux_version() >= 6012000 &&
+ sysfs_set_num(sra, NULL, "new_level", info->new_level) < 0)
+ err = errno;
+
if (!err && subarray_set_num(container, sra, "raid_disks",
reshape->after.data_disks +
reshape->parity) < 0)
err = errno;
+
if (err) {
pr_err("Cannot set device shape for %s\n", devname);
--
2.41.0

View File

@ -0,0 +1,57 @@
From 568259859cafeefbf54354c19405cf2292da4b4a Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:24 +0800
Subject: [PATCH 175/201] mdadm/Grow: Update reshape_progress to need_back
after reshape finishes
It tries to update data offset when kicking off reshape. If it can't
change data offset, it needs to use child_monitor to monitor reshape
progress and do back up job. And it needs to update reshape_progress
to need_back when reshape finishes. If not, it will be in a infinite
loop.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Grow.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/Grow.c b/Grow.c
index 533f3014..3b9f9942 100644
--- a/Grow.c
+++ b/Grow.c
@@ -4148,8 +4148,8 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
* waiting forever on a dead array
*/
char action[SYSFS_MAX_BUF_SIZE];
- if (sysfs_get_str(info, NULL, "sync_action", action, sizeof(action)) <= 0 ||
- strncmp(action, "reshape", 7) != 0)
+
+ if (sysfs_get_str(info, NULL, "sync_action", action, sizeof(action)) <= 0)
break;
/* Some kernels reset 'sync_completed' to zero
* before setting 'sync_action' to 'idle'.
@@ -4157,12 +4157,18 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
*/
if (completed == 0 && advancing &&
strncmp(action, "idle", 4) == 0 &&
- info->reshape_progress > 0)
+ info->reshape_progress > 0) {
+ info->reshape_progress = need_backup;
break;
+ }
if (completed == 0 && !advancing &&
strncmp(action, "idle", 4) == 0 &&
info->reshape_progress <
- (info->component_size * reshape->after.data_disks))
+ (info->component_size * reshape->after.data_disks)) {
+ info->reshape_progress = need_backup;
+ break;
+ }
+ if (strncmp(action, "reshape", 7) != 0)
break;
sysfs_wait(fd, NULL);
if (sysfs_fd_get_ll(fd, &completed) < 0)
--
2.41.0

View File

@ -0,0 +1,38 @@
From cd94b9adf7d53457d86cdc39b983b18713f24032 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:25 +0800
Subject: [PATCH 176/201] mdadm/Grow: Can't open raid when running --grow
--continue
It passes 'array' as devname in Grow_continue. So it fails to
open raid device. Use mdinfo to open raid device.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Grow.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Grow.c b/Grow.c
index 3b9f9942..ebb53a0d 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3694,9 +3694,12 @@ started:
set_array_size(st, info, info->text_version);
if (info->new_level != reshape.level) {
- if (fd < 0)
- fd = open(devname, O_RDONLY);
- impose_level(fd, info->new_level, devname, verbose);
+ fd = open_dev(sra->sys_name);
+ if (fd < 0) {
+ pr_err("Can't open %s\n", sra->sys_name);
+ goto out;
+ }
+ impose_level(fd, info->new_level, sra->sys_name, verbose);
close(fd);
if (info->new_level == 0)
st->update_tail = NULL;
--
2.41.0

View File

@ -0,0 +1,39 @@
From 166e5e2fc4b634df100ccc0010035f925bb2ad63 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:26 +0800
Subject: [PATCH 177/201] mdadm/Grow: sleep a while after removing disk in
impose_level
It needs to remove disks when reshaping from raid456 to raid0. In
kernel space it sets MD_RECOVERY_RUNNING. And it will fail to change
level. So wait sometime to let md thread to clear this flag.
This is found by test case 05r6tor0.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Grow.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Grow.c b/Grow.c
index ebb53a0d..60076f56 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3034,6 +3034,13 @@ static int impose_level(int fd, int level, char *devname, int verbose)
makedev(disk.major, disk.minor));
hot_remove_disk(fd, makedev(disk.major, disk.minor), 1);
}
+ /*
+ * hot_remove_disk lets kernel set MD_RECOVERY_RUNNING
+ * and it can't set level. It needs to wait sometime
+ * to let md thread to clear the flag.
+ */
+ pr_info("wait 5 seconds to give kernel space to finish job\n");
+ sleep_for(5, 0, true);
}
c = map_num(pers, level);
if (c) {
--
2.41.0

View File

@ -0,0 +1,33 @@
From 098337f31de3f0683cd99727104c81db81fda9cd Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:27 +0800
Subject: [PATCH 178/201] mdadm/tests: wait until level changes
check wait waits reshape finishes, but it doesn't wait level changes.
The level change happens in a forked child progress. So we need to
search the child progress and monitor it.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
tests/05r6tor0 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/05r6tor0 b/tests/05r6tor0
index 2fd51f2e..b2685b72 100644
--- a/tests/05r6tor0
+++ b/tests/05r6tor0
@@ -13,6 +13,10 @@ check raid5
testdev $md0 3 19456 512
mdadm -G $md0 -l0
check wait; sleep 1
+while ps auxf | grep "mdadm -G" | grep -v grep
+do
+ sleep 1
+done
check raid0
testdev $md0 3 19456 512
mdadm -G $md0 -l5 --add $dev3 $dev4
--
2.41.0

View File

@ -0,0 +1,179 @@
From f5b2dddd258084836634e169c84400e82825996c Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:28 +0800
Subject: [PATCH 179/201] mdadm/tests: 07changelevels fix
There are five changes to this case.
1. remove testdev check. It can't work anymore and check if it's a
block device directly.
2. It can't change level and chunk size at the same time
3. Sleep more than 10s before check wait.
The test devices are small. Sometimes it can finish so quickly once
the reshape just starts. mdadm will be stuck before it waits reshape
to start. So the sync speed is limited. And it restores the sync speed
when it waits reshape to finish. It's good for case without backup
file.
It uses systemd service mdadm-grow-continue to monitor reshape
progress when specifying backup file. If reshape finishes so quickly
before it starts monitoring reshape progress, the daemon will be stuck
too. Because reshape_progress is 0 which means the reshape hasn't been
started. So give more time to let service can get right information
from kernel space.
But before getting these information. It needs to suspend array. At
the same time the reshape is running. The kernel reshape daemon will
update metadata 10s. So it needs to limit the sync speed more than 10s
before restoring sync speed. Then systemd service can suspend array
and start monitoring reshape progress.
4. Wait until mdadm-grow-continue service exits
mdadm --wait doesn't wait systemd service. For the case that needs
backup file, systemd service deletes the backup file after reshape
finishes. In this test case, it runs next case when reshape finishes.
And it fails because it can't create backup file because the backup
file exits.
5. Don't reshape from raid5 to raid1. It can't work now.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
dev/null | 0
tests/07changelevels | 27 ++++++++++++---------------
tests/07changelevels.broken | 9 ---------
tests/func.sh | 4 ++++
4 files changed, 16 insertions(+), 24 deletions(-)
create mode 100644 dev/null
delete mode 100644 tests/07changelevels.broken
diff --git a/dev/null b/dev/null
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/07changelevels b/tests/07changelevels
index a328874a..3df8660e 100644
--- a/tests/07changelevels
+++ b/tests/07changelevels
@@ -10,7 +10,6 @@ export MDADM_GROW_VERIFY=1
dotest() {
sleep 2
check wait
- testdev $md0 $1 19968 64 nd
blockdev --flushbufs $md0
cmp -s -n $[textK*1024] $md0 /tmp/RandFile || { echo cmp failed; exit 2; }
# write something new - shift chars 4 space
@@ -24,7 +23,7 @@ checkgeo() {
# level raid_disks chunk_size layout
dev=$1
shift
- sleep 0.5
+ sleep 15
check wait
sleep 1
for attr in level raid_disks chunk_size layout
@@ -43,22 +42,25 @@ checkgeo() {
bu=/tmp/md-test-backup
rm -f $bu
-mdadm -CR $md0 -l1 -n2 -x1 $dev0 $dev1 $dev2 -z 19968
-testdev $md0 1 $mdsize1a 64
+mdadm -CR $md0 -l1 -n2 -x1 $dev0 $dev1 $dev2
+[ -b $md0 ] || die "$1 isn't a block device."
dd if=/tmp/RandFile of=$md0
dotest 1
-mdadm --grow $md0 -l5 -n3 --chunk 64
+mdadm --grow $md0 -l5 -n3
+checkgeo md0 raid5 3
dotest 2
mdadm $md0 --add $dev3 $dev4
mdadm --grow $md0 -n4 --chunk 32
+checkgeo md0 raid5 4 $[32*1024]
dotest 3
mdadm -G $md0 -l6 --backup-file $bu
+checkgeo md0 raid6 5 $[32*1024]
dotest 3
-mdadm -G /dev/md0 --array-size 39936
+mdadm -G /dev/md0 --array-size 37888
mdadm -G $md0 -n4 --backup-file $bu
checkgeo md0 raid6 4 $[32*1024]
dotest 2
@@ -67,14 +69,11 @@ mdadm -G $md0 -l5 --backup-file $bu
checkgeo md0 raid5 3 $[32*1024]
dotest 2
-mdadm -G /dev/md0 --array-size 19968
+mdadm -G /dev/md0 --array-size 18944
mdadm -G $md0 -n2 --backup-file $bu
checkgeo md0 raid5 2 $[32*1024]
dotest 1
-mdadm -G --level=1 $md0
-dotest 1
-
# now repeat that last few steps only with a degraded array.
mdadm -S $md0
mdadm -CR $md0 -l6 -n5 $dev0 $dev1 $dev2 $dev3 $dev4
@@ -83,7 +82,7 @@ dotest 3
mdadm $md0 --fail $dev0
-mdadm -G /dev/md0 --array-size 37888
+mdadm -G /dev/md0 --array-size 35840
mdadm -G $md0 -n4 --backup-file $bu
dotest 2
checkgeo md0 raid6 4 $[512*1024]
@@ -103,12 +102,10 @@ dotest 2
mdadm -G $md0 -l5 --backup-file $bu
dotest 2
-mdadm -G /dev/md0 --array-size 18944
+mdadm -G /dev/md0 --array-size 17920
mdadm -G $md0 -n2 --backup-file $bu
dotest 1
checkgeo md0 raid5 2 $[512*1024]
mdadm $md0 --fail $dev2
-mdadm -G --level=1 $md0
-dotest 1
-checkgeo md0 raid1 2
+mdadm -S $md0
diff --git a/tests/07changelevels.broken b/tests/07changelevels.broken
deleted file mode 100644
index 9b930d93..00000000
--- a/tests/07changelevels.broken
+++ /dev/null
@@ -1,9 +0,0 @@
-always fails
-
-Fails with errors:
-
- mdadm: /dev/loop0 is smaller than given size. 18976K < 19968K + metadata
- mdadm: /dev/loop1 is smaller than given size. 18976K < 19968K + metadata
- mdadm: /dev/loop2 is smaller than given size. 18976K < 19968K + metadata
-
- ERROR: /dev/md0 isn't a block device.
diff --git a/tests/func.sh b/tests/func.sh
index e7ccc4fc..567d91d9 100644
--- a/tests/func.sh
+++ b/tests/func.sh
@@ -362,6 +362,10 @@ check() {
do
sleep 0.5
done
+ while ps auxf | grep "mdadm --grow --continue" | grep -v grep
+ do
+ sleep 1
+ done
echo $min > /proc/sys/dev/raid/speed_limit_min
echo $max > /proc/sys/dev/raid/speed_limit_max
;;
--
2.41.0

View File

@ -0,0 +1,68 @@
From 01f5aefd830d6ad5357de4d6f5ce139b415a62b9 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:29 +0800
Subject: [PATCH 180/201] mdadm/tests: Remove 07reshape5intr.broken
07reshape5intr can run successfully now.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
tests/07reshape5intr.broken | 45 -------------------------------------
1 file changed, 45 deletions(-)
delete mode 100644 tests/07reshape5intr.broken
diff --git a/tests/07reshape5intr.broken b/tests/07reshape5intr.broken
deleted file mode 100644
index efe52a66..00000000
--- a/tests/07reshape5intr.broken
+++ /dev/null
@@ -1,45 +0,0 @@
-always fails
-
-This patch, recently added to md-next causes the test to always fail:
-
-7e6ba434cc60 ("md: don't unregister sync_thread with reconfig_mutex
-held")
-
-The new error is simply:
-
- ERROR: no reshape happening
-
-Before the patch, the error seen is below.
-
---
-
-fails infrequently
-
-Fails roughly 1 in 4 runs with errors:
-
- mdadm: Merging with already-assembled /dev/md/0
- mdadm: cannot re-read metadata from /dev/loop6 - aborting
-
- ERROR: no reshape happening
-
-Also have seen a random deadlock:
-
- INFO: task mdadm:109702 blocked for more than 30 seconds.
- Not tainted 5.18.0-rc3-eid-vmlocalyes-dbg-00095-g3c2b5427979d #2040
- "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
- task:mdadm state:D stack: 0 pid:109702 ppid: 1 flags:0x00004000
- Call Trace:
- <TASK>
- __schedule+0x67e/0x13b0
- schedule+0x82/0x110
- mddev_suspend+0x2e1/0x330
- suspend_lo_store+0xbd/0x140
- md_attr_store+0xcb/0x130
- sysfs_kf_write+0x89/0xb0
- kernfs_fop_write_iter+0x202/0x2c0
- new_sync_write+0x222/0x330
- vfs_write+0x3bc/0x4d0
- ksys_write+0xd9/0x180
- __x64_sys_write+0x43/0x50
- do_syscall_64+0x3b/0x90
- entry_SYSCALL_64_after_hwframe+0x44/0xae
--
2.41.0

View File

@ -0,0 +1,48 @@
From fe3e4809476ab4e2e0e905e36f6bb1a45c16a2c3 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:30 +0800
Subject: [PATCH 181/201] mdadm/tests: 07testreshape5 fix
Init dir to avoid test failure.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
tests/07testreshape5 | 1 +
tests/07testreshape5.broken | 12 ------------
2 files changed, 1 insertion(+), 12 deletions(-)
delete mode 100644 tests/07testreshape5.broken
diff --git a/tests/07testreshape5 b/tests/07testreshape5
index 0e1f25f9..d90fd15e 100644
--- a/tests/07testreshape5
+++ b/tests/07testreshape5
@@ -4,6 +4,7 @@
# kernel md code to move data into and out of variously
# shaped md arrays.
set -x
+dir="."
layouts=(la ra ls rs)
for level in 5 6
do
diff --git a/tests/07testreshape5.broken b/tests/07testreshape5.broken
deleted file mode 100644
index a8ce03e4..00000000
--- a/tests/07testreshape5.broken
+++ /dev/null
@@ -1,12 +0,0 @@
-always fails
-
-Test seems to run 'test_stripe' at $dir directory, but $dir is never
-set. If $dir is adjusted to $PWD, the test still fails with:
-
- mdadm: /dev/loop2 is not suitable for this array.
- mdadm: create aborted
- ++ return 1
- ++ cmp -s -n 8192 /dev/md0 /tmp/RandFile
- ++ echo cmp failed
- cmp failed
- ++ exit 2
--
2.41.0

View File

@ -0,0 +1,29 @@
From 5cafbc8b3a7f352be80c5dc22d59d26b06f57680 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:31 +0800
Subject: [PATCH 182/201] mdadm/tests: remove 09imsm-assemble.broken
09imsm-assemble can run successfully.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
tests/09imsm-assemble.broken | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 tests/09imsm-assemble.broken
diff --git a/tests/09imsm-assemble.broken b/tests/09imsm-assemble.broken
deleted file mode 100644
index a6d4d5cf..00000000
--- a/tests/09imsm-assemble.broken
+++ /dev/null
@@ -1,6 +0,0 @@
-fails infrequently
-
-Fails roughly 1 in 10 runs with errors:
-
- mdadm: /dev/loop2 is still in use, cannot remove.
- /dev/loop2 removal from /dev/md/container should have succeeded
--
2.41.0

View File

@ -0,0 +1,56 @@
From e3c3cfb64b8ec8b616e2eefbc69fbc3de29b64b6 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 11 Sep 2024 16:54:32 +0800
Subject: [PATCH 183/201] mdadm/Manage: record errno
Sometimes it reports:
mdadm: failed to stop array /dev/md0: Success
It's the reason the errno is reset. So record errno during the loop.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Manage.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Manage.c b/Manage.c
index 241de055..aba97df8 100644
--- a/Manage.c
+++ b/Manage.c
@@ -238,13 +238,14 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
"array_state",
"inactive")) < 0 &&
errno == EBUSY) {
+ err = errno;
sleep_for(0, MSEC_TO_NSEC(200), true);
count--;
}
if (err) {
if (verbose >= 0)
pr_err("failed to stop array %s: %s\n",
- devname, strerror(errno));
+ devname, strerror(err));
rv = 1;
goto out;
}
@@ -438,14 +439,15 @@ done:
count = 25; err = 0;
while (count && fd >= 0 &&
(err = ioctl(fd, STOP_ARRAY, NULL)) < 0 && errno == EBUSY) {
+ err = errno;
sleep_for(0, MSEC_TO_NSEC(200), true);
count --;
}
if (fd >= 0 && err) {
if (verbose >= 0) {
pr_err("failed to stop array %s: %s\n",
- devname, strerror(errno));
- if (errno == EBUSY)
+ devname, strerror(err));
+ if (err == EBUSY)
cont_err("Perhaps a running process, mounted filesystem or active volume group?\n");
}
rv = 1;
--
2.41.0

View File

@ -0,0 +1,43 @@
From 2c2a9d63d07102e54608ad7691072ebbed0f8be8 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Mon, 23 Sep 2024 11:12:53 +0200
Subject: [PATCH 184/201] Remove INSTALL and dev/null
INSTALL is not needed because it added to README.md
dev/null was created accidentally.
Remove them.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
INSTALL | 13 -------------
dev/null | 0
2 files changed, 13 deletions(-)
delete mode 100644 INSTALL
delete mode 100644 dev/null
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index f7bcc3e6..00000000
--- a/INSTALL
+++ /dev/null
@@ -1,13 +0,0 @@
-
-To build mdadm, simply run:
-
- make
-
-to install, run
-
- make install
-
-as root.
-
-
-No configuration is necessary.
diff --git a/dev/null b/dev/null
deleted file mode 100644
index e69de29b..00000000
--
2.41.0

View File

@ -0,0 +1,67 @@
From 60923d5cae78447902e9ec10c44504e0588cf447 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Mon, 23 Sep 2024 14:15:31 +0200
Subject: [PATCH 186/201] Incremental: Rename IncrementalRemove
Rename it to Incremental_remove for better readability.
No functional changes.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Incremental.c | 4 ++--
mdadm.c | 3 +--
mdadm.h | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index c1389a15..e7987d1d 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1695,7 +1695,7 @@ static bool is_devnode_path(char *devnode)
}
/**
- * IncrementalRemove() - Remove the device from all raid arrays.
+ * Incremental_remove() - Remove the device from all raid arrays.
* @devname: the device we want to remove, it could be kernel device name or devnode.
* @id_path: optional, /dev/disk/by-path path to save for bare scenarios support.
* @verbose: verbose flag.
@@ -1703,7 +1703,7 @@ static bool is_devnode_path(char *devnode)
* First, fail the device (if needed) and then remove the device from native raid array or external
* container. If it is external container, the device is removed from each subarray first.
*/
-int IncrementalRemove(char *devname, char *id_path, int verbose)
+int Incremental_remove(char *devname, char *id_path, int verbose)
{
char *devnm = basename(devname);
struct mddev_dev devlist = {0};
diff --git a/mdadm.c b/mdadm.c
index 0b99fad4..90fd1575 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1703,8 +1703,7 @@ int main(int argc, char *argv[])
rv = 1;
break;
}
- rv = IncrementalRemove(devlist->devname, remove_path,
- c.verbose);
+ rv = Incremental_remove(devlist->devname, remove_path, c.verbose);
} else
rv = Incremental(devlist, &c, ss);
break;
diff --git a/mdadm.h b/mdadm.h
index f3b9f54c..d4f5702c 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1606,7 +1606,7 @@ extern int Incremental(struct mddev_dev *devlist, struct context *c,
struct supertype *st);
extern void RebuildMap(void);
extern int IncrementalScan(struct context *c, char *devnm);
-extern int IncrementalRemove(char *devname, char *path, int verbose);
+extern int Incremental_remove(char *devname, char *path, int verbose);
extern int CreateBitmap(char *filename, int force, char uuid[16],
unsigned long chunksize, unsigned long daemon_sleep,
unsigned long write_behind,
--
2.41.0

View File

@ -0,0 +1,315 @@
From d95edceb362a6b647ec454c2a83add11c4ed4e64 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Tue, 24 Sep 2024 15:53:18 +0200
Subject: [PATCH 187/201] sysfs: add function for writing to sysfs fd
Proposed function sysfs_wrte_descriptor() unifies error handling for
write() done to sysfs files. Main purpose is to use it with MD sysfs
file but it can be used elsewhere.
No functional changes.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Manage.c | 45 +++++++++++++++++++++----------------
managemon.c | 13 +++--------
mdadm.h | 3 +++
monitor.c | 12 ++--------
sysfs.c | 65 +++++++++++++++++++++++++++++++++++++++++++----------
util.c | 19 +++++++++++-----
6 files changed, 101 insertions(+), 56 deletions(-)
diff --git a/Manage.c b/Manage.c
index aba97df8..0f232a57 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1439,7 +1439,7 @@ int Manage_subdevs(char *devname, int fd,
for (dv = devlist; dv; dv = dv->next) {
dev_t rdev = 0; /* device to add/remove etc */
- int rv;
+ int rv, err = 0;
int mj,mn;
raid_slot = -1;
@@ -1670,9 +1670,8 @@ int Manage_subdevs(char *devname, int fd,
rv = Manage_remove(tst, fd, dv, sysfd,
rdev, verbose, force,
devname);
- if (sysfd >= 0)
- close_fd(&sysfd);
- sysfd = -1;
+ close_fd(&sysfd);
+
if (rv < 0)
goto abort;
if (rv > 0)
@@ -1686,23 +1685,31 @@ int Manage_subdevs(char *devname, int fd,
close_fd(&sysfd);
goto abort;
}
- case 'I': /* incremental fail */
- if ((sysfd >= 0 && write(sysfd, "faulty", 6) != 6) ||
- (sysfd < 0 && ioctl(fd, SET_DISK_FAULTY,
- rdev))) {
- if (errno == EBUSY)
- busy = 1;
- pr_err("set device faulty failed for %s: %s\n",
- dv->devname, strerror(errno));
- close_fd(&sysfd);
- goto abort;
+ case 'I':
+ if (is_fd_valid(sysfd)) {
+ static const char val[] = "faulty";
+
+ rv = sysfs_write_descriptor(sysfd, val, strlen(val), &err);
+ } else {
+ rv = ioctl(fd, SET_DISK_FAULTY, rdev);
+ if (rv)
+ err = errno;
}
+
close_fd(&sysfd);
- count++;
- if (verbose >= 0)
- pr_err("set %s faulty in %s\n",
- dv->devname, devname);
- break;
+
+ if (rv == MDADM_STATUS_SUCCESS) {
+ count++;
+
+ pr_vrb("set %s faulty in %s\n", dv->devname, devname);
+ break;
+ }
+
+ if (err == EBUSY)
+ busy = 1;
+
+ pr_err("set device faulty failed for %s: %s\n", dv->devname, strerror(err));
+ goto abort;
case 'R': /* Mark as replaceable */
if (subarray) {
pr_err("Cannot replace disks in a \'member\' array, perform this operation on the parent container\n");
diff --git a/managemon.c b/managemon.c
index add6a79e..877e8605 100644
--- a/managemon.c
+++ b/managemon.c
@@ -512,16 +512,9 @@ static void manage_member(struct mdstat_ent *mdstat,
if (a->container == NULL)
return;
- if (sigterm && a->info.safe_mode_delay != 1 &&
- a->safe_mode_delay_fd >= 0) {
- long int new_delay = 1;
- char delay[10];
- ssize_t len;
-
- len = snprintf(delay, sizeof(delay), "0.%03ld\n", new_delay);
- if (write(a->safe_mode_delay_fd, delay, len) == len)
- a->info.safe_mode_delay = new_delay;
- }
+ if (sigterm && a->info.safe_mode_delay != 1 && a->safe_mode_delay_fd >= 0)
+ if (write_attr("0.001", a->safe_mode_delay_fd) == MDADM_STATUS_SUCCESS)
+ a->info.safe_mode_delay = 1;
/* We don't check the array while any update is pending, as it
* might container a change (such as a spare assignment) which
diff --git a/mdadm.h b/mdadm.h
index d4f5702c..ce8155b5 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -803,6 +803,9 @@ enum sysfs_read_flags {
#define SYSFS_MAX_BUF_SIZE 64
+extern mdadm_status_t sysfs_write_descriptor(const int fd, const char *value,
+ const ssize_t len, int *errno_p);
+extern mdadm_status_t write_attr(const char *value, const int fd);
extern void sysfs_get_container_devnm(struct mdinfo *mdi, char *buf);
/* If fd >= 0, get the array it is open on,
diff --git a/monitor.c b/monitor.c
index be0bec78..a4f707cc 100644
--- a/monitor.c
+++ b/monitor.c
@@ -35,11 +35,6 @@ enum bb_action {
COMPARE_BB,
};
-static int write_attr(char *attr, int fd)
-{
- return write(fd, attr, strlen(attr));
-}
-
static void add_fd(fd_set *fds, int *maxfd, int fd)
{
struct stat st;
@@ -173,7 +168,7 @@ int process_ubb(struct active_array *a, struct mdinfo *mdi, const unsigned long
* via sysfs file
*/
if ((ss->record_bad_block(a, mdi->disk.raid_disk, sector, length)) &&
- (write(mdi->bb_fd, buf, buf_len) == buf_len))
+ (sysfs_write_descriptor(mdi->bb_fd, buf, buf_len, NULL) == MDADM_STATUS_SUCCESS))
return 1;
/*
@@ -622,14 +617,11 @@ static int read_and_act(struct active_array *a, fd_set *fds)
}
if ((mdi->next_state & DS_REMOVE) && mdi->state_fd >= 0) {
- int remove_result;
-
/* The kernel may not be able to immediately remove the
* disk. In that case we wait a little while and
* try again.
*/
- remove_result = write_attr("remove", mdi->state_fd);
- if (remove_result > 0) {
+ if (write_attr("remove", mdi->state_fd) == MDADM_STATUS_SUCCESS) {
dprintf_cont(" %d:removed", mdi->disk.raid_disk);
close(mdi->state_fd);
close(mdi->recovery_fd);
diff --git a/sysfs.c b/sysfs.c
index b3c8b10d..7a81cc5b 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -73,6 +73,47 @@ void sysfs_free(struct mdinfo *sra)
sra = sra2;
}
}
+/**
+ * write_attr() - write value to fd, don't check errno.
+ * @attr: value to write.
+ * @fd: file descriptor write to.
+ *
+ * Size to write is calculated by strlen().
+ */
+mdadm_status_t write_attr(const char *value, const int fd)
+{
+ return sysfs_write_descriptor(fd, value, strlen(value), NULL);
+}
+
+/**
+ * sysfs_write_descriptor()- wrapper for write(), projected to be used with sysfs.
+ * @fd: file descriptor.
+ * @value: value to set.
+ * @len: length of the value.
+ * @errno_p: On write() failure, buffer to copy errno value, might be NULL.
+ *
+ * Errors are differentiated, because (at least theoretically) kernel may not process whole string
+ * and it may or may not be a problem (it depends on implementation in kernel). Decision belongs to
+ * caller then.
+ * Generally, it should be safe to check if @errno_p changed to determine if error occurred.
+ */
+mdadm_status_t sysfs_write_descriptor(const int fd, const char *value, const ssize_t len,
+ int *errno_p)
+{
+ ssize_t ret;
+
+ ret = write(fd, value, len);
+ if (ret == -1) {
+ if (errno_p)
+ *errno_p = errno;
+ return MDADM_STATUS_ERROR;
+ }
+
+ if (ret != len)
+ return MDADM_STATUS_UNDEF;
+
+ return MDADM_STATUS_SUCCESS;
+}
/**
* sysfs_get_container_devnm() - extract container device name.
@@ -486,7 +527,6 @@ int sysfs_set_str(struct mdinfo *sra, struct mdinfo *dev,
char *name, char *val)
{
char fname[MAX_SYSFS_PATH_LEN];
- unsigned int n;
int fd;
snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/%s/%s",
@@ -494,13 +534,14 @@ int sysfs_set_str(struct mdinfo *sra, struct mdinfo *dev,
fd = open(fname, O_WRONLY);
if (fd < 0)
return -1;
- n = write(fd, val, strlen(val));
- close(fd);
- if (n != strlen(val)) {
- dprintf("failed to write '%s' to '%s' (%s)\n",
- val, fname, strerror(errno));
+
+ if (write_attr(val, fd)) {
+ pr_err("failed to write '%s' to '%s' (%s)\n", val, fname, strerror(errno));
+ close(fd);
return -1;
}
+
+ close(fd);
return 0;
}
@@ -523,7 +564,6 @@ int sysfs_set_num_signed(struct mdinfo *sra, struct mdinfo *dev,
int sysfs_uevent(struct mdinfo *sra, char *event)
{
char fname[MAX_SYSFS_PATH_LEN];
- int n;
int fd;
snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/uevent",
@@ -531,13 +571,14 @@ int sysfs_uevent(struct mdinfo *sra, char *event)
fd = open(fname, O_WRONLY);
if (fd < 0)
return -1;
- n = write(fd, event, strlen(event));
- close(fd);
- if (n != (int)strlen(event)) {
- dprintf("failed to write '%s' to '%s' (%s)\n",
- event, fname, strerror(errno));
+
+ if (write_attr(event, fd)) {
+ pr_err("failed to write '%s' to '%s' (%s)\n", event, fname, strerror(errno));
+ close(fd);
return -1;
}
+
+ close(fd);
return 0;
}
diff --git a/util.c b/util.c
index cc162278..2b660725 100644
--- a/util.c
+++ b/util.c
@@ -1854,13 +1854,22 @@ int hot_remove_disk(int mdfd, unsigned long dev, int force)
int sys_hot_remove_disk(int statefd, int force)
{
int cnt = force ? 500 : 5;
- int ret;
+ static const char val[] = "faulty";
+
+ while (cnt--) {
+ int err = 0;
+ int ret = sysfs_write_descriptor(statefd, val, strlen(val), &err);
+
+ if (ret == MDADM_STATUS_SUCCESS)
+ return 0;
+
+ if (err != EBUSY)
+ break;
- while ((ret = write(statefd, "remove", 6)) == -1 &&
- errno == EBUSY &&
- cnt-- > 0)
sleep_for(0, MSEC_TO_NSEC(10), true);
- return ret == 6 ? 0 : -1;
+ }
+
+ return -1;
}
int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info)
--
2.41.0

View File

@ -0,0 +1,61 @@
From 344690313ae4e66f760b14afafda663ec750dfe0 Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Tue, 3 Sep 2024 13:01:04 +0200
Subject: [PATCH 188/201] Mdmonitor: Fix startup with missing directory
Commit 0a07dea8d3b78 ("Mdmonitor: Refactor check_one_sharer() for
better error handling") introduced an issue, if directory /run/mdadm
is missing, monitor fails to start. Move the directory creation
earlier to ensure it is always created.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
Monitor.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index cf14fbb3..d260b0f1 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -225,6 +225,11 @@ int Monitor(struct mddev_dev *devlist,
return 1;
}
+ if (mkdir(MDMON_DIR, 0700) < 0 && errno != EEXIST) {
+ pr_err("Failed to create directory " MDMON_DIR ": %s\n", strerror(errno));
+ return 1;
+ }
+
if (share){
if (check_one_sharer(c->scan) == 2)
return 1;
@@ -432,12 +437,12 @@ static int make_daemon(char *pidfile)
}
/*
- * check_one_sharer() - Checks for other mdmon processes running.
+ * check_one_sharer() - Checks for other mdmonitor processes running.
*
* Return:
* 0 - no other processes running,
* 1 - warning,
- * 2 - error, or when scan mode is enabled, and one mdmon process already exists
+ * 2 - error, or when scan mode is enabled, and one mdmonitor process already exists
*/
static int check_one_sharer(int scan)
{
@@ -513,11 +518,6 @@ static int write_autorebuild_pid(void)
FILE *fp;
int fd;
- if (mkdir(MDMON_DIR, 0700) < 0 && errno != EEXIST) {
- pr_err("%s: %s\n", strerror(errno), MDMON_DIR);
- return 1;
- }
-
if (!is_directory(MDMON_DIR)) {
pr_err("%s is not a regular directory.\n", MDMON_DIR);
return 1;
--
2.41.0

View File

@ -0,0 +1,590 @@
From ee3a6cab09c8acaf6706b3710f5652e9be43b57e Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Wed, 25 Sep 2024 13:16:10 +0200
Subject: [PATCH 189/201] mdadm: add xmalloc.h
Move memory declaration helpers outside mdadm.h. They seems to be
useful so keep them but include separatelly. Rework them to not reffer
to Name[] declared internally in mdadm/mdmon.
This is first step to start decomplexing mdadm.h.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Assemble.c | 2 ++
Create.c | 4 +++-
Detail.c | 2 ++
Examine.c | 8 ++++---
Grow.c | 2 ++
Incremental.c | 2 ++
Manage.c | 2 ++
Monitor.c | 4 +++-
bitmap.c | 1 +
config.c | 2 ++
lib.c | 2 ++
managemon.c | 2 ++
mapfile.c | 2 ++
mdadm.c | 2 ++
mdadm.h | 5 ----
mdmon.c | 1 +
mdopen.c | 2 ++
mdstat.c | 2 ++
msg.c | 1 +
platform-intel.c | 2 ++
policy.c | 2 ++
restripe.c | 2 ++
super-ddf.c | 2 ++
super-gpt.c | 1 +
super-intel.c | 2 ++
super-mbr.c | 1 +
super0.c | 2 ++
super1.c | 2 ++
sysfs.c | 4 +++-
udev.c | 2 ++
util.c | 2 ++
xmalloc.c | 59 +++++++++++++++++++++---------------------------
xmalloc.h | 13 +++++++++++
33 files changed, 100 insertions(+), 44 deletions(-)
create mode 100644 xmalloc.h
diff --git a/Assemble.c b/Assemble.c
index a2bb7b64..d3dbfbc6 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -23,6 +23,8 @@
*/
#include "mdadm.h"
+#include "xmalloc.h"
+
#include <ctype.h>
mapping_t assemble_statuses[] = {
diff --git a/Create.c b/Create.c
index 7fde1c16..1640f21e 100644
--- a/Create.c
+++ b/Create.c
@@ -23,9 +23,11 @@
*/
#include "mdadm.h"
-#include "udev.h"
#include "md_u.h"
#include "md_p.h"
+#include "udev.h"
+#include "xmalloc.h"
+
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
diff --git a/Detail.c b/Detail.c
index 331e1da3..5819ced9 100644
--- a/Detail.c
+++ b/Detail.c
@@ -25,6 +25,8 @@
#include "mdadm.h"
#include "md_p.h"
#include "md_u.h"
+#include "xmalloc.h"
+
#include <ctype.h>
#include <dirent.h>
diff --git a/Examine.c b/Examine.c
index fe162167..036b7a56 100644
--- a/Examine.c
+++ b/Examine.c
@@ -22,14 +22,16 @@
* Email: <neilb@suse.de>
*/
-#include "mdadm.h"
#include "dlink.h"
+#include "mdadm.h"
+#include "md_u.h"
+#include "md_p.h"
+#include "xmalloc.h"
#if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN)
#error no endian defined
#endif
-#include "md_u.h"
-#include "md_p.h"
+
int Examine(struct mddev_dev *devlist,
struct context *c,
struct supertype *forcest)
diff --git a/Grow.c b/Grow.c
index 60076f56..ef1285ec 100644
--- a/Grow.c
+++ b/Grow.c
@@ -23,6 +23,8 @@
*/
#include "mdadm.h"
#include "dlink.h"
+#include "xmalloc.h"
+
#include <sys/mman.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Incremental.c b/Incremental.c
index e7987d1d..8c915783 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -29,6 +29,8 @@
*/
#include "mdadm.h"
+#include "xmalloc.h"
+
#include <sys/wait.h>
#include <dirent.h>
#include <ctype.h>
diff --git a/Manage.c b/Manage.c
index 0f232a57..246ef319 100644
--- a/Manage.c
+++ b/Manage.c
@@ -26,6 +26,8 @@
#include "md_u.h"
#include "md_p.h"
#include "udev.h"
+#include "xmalloc.h"
+
#include <ctype.h>
int Manage_ro(char *devname, int fd, int readonly)
diff --git a/Monitor.c b/Monitor.c
index d260b0f1..d1cfbf94 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -23,9 +23,11 @@
*/
#include "mdadm.h"
-#include "udev.h"
#include "md_p.h"
#include "md_u.h"
+#include "udev.h"
+#include "xmalloc.h"
+
#include <sys/wait.h>
#include <limits.h>
#include <syslog.h>
diff --git a/bitmap.c b/bitmap.c
index 9a7ffe3b..5110ae2f 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -19,6 +19,7 @@
*/
#include "mdadm.h"
+#include "xmalloc.h"
static inline void sb_le_to_cpu(bitmap_super_t *sb)
{
diff --git a/config.c b/config.c
index 5411a480..022fb2a0 100644
--- a/config.c
+++ b/config.c
@@ -24,6 +24,8 @@
#include "mdadm.h"
#include "dlink.h"
+#include "xmalloc.h"
+
#include <dirent.h>
#include <glob.h>
#include <fnmatch.h>
diff --git a/lib.c b/lib.c
index 13d4e4f1..f36ae03a 100644
--- a/lib.c
+++ b/lib.c
@@ -24,6 +24,8 @@
#include "mdadm.h"
#include "dlink.h"
+#include "xmalloc.h"
+
#include <ctype.h>
#include <limits.h>
diff --git a/managemon.c b/managemon.c
index 877e8605..6ca592b1 100644
--- a/managemon.c
+++ b/managemon.c
@@ -104,6 +104,8 @@
#endif
#include "mdadm.h"
#include "mdmon.h"
+#include "xmalloc.h"
+
#include <sys/syscall.h>
#include <sys/socket.h>
diff --git a/mapfile.c b/mapfile.c
index 632cf5e8..33d40d9e 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -43,6 +43,8 @@
* at compile time via MAP_DIR and MAP_FILE.
*/
#include "mdadm.h"
+#include "xmalloc.h"
+
#include <sys/file.h>
#include <ctype.h>
diff --git a/mdadm.c b/mdadm.c
index 90fd1575..de7cde07 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -27,6 +27,8 @@
#include "mdadm.h"
#include "md_p.h"
+#include "xmalloc.h"
+
#include <ctype.h>
/**
diff --git a/mdadm.h b/mdadm.h
index ce8155b5..bbc1b97f 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1937,11 +1937,6 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
#define pr_vrb(fmt, arg...) ((void)(verbose && pr_err(fmt, ##arg)))
-void *xmalloc(size_t len);
-void *xrealloc(void *ptr, size_t len);
-void *xcalloc(size_t num, size_t size);
-char *xstrdup(const char *str);
-
#define LEVEL_MULTIPATH (-4)
#define LEVEL_LINEAR (-1)
#define LEVEL_FAULTY (-5)
diff --git a/mdmon.c b/mdmon.c
index 6e28b56e..a16647c6 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -65,6 +65,7 @@
#include "mdadm.h"
#include "mdmon.h"
+#include "xmalloc.h"
char const Name[] = "mdmon";
diff --git a/mdopen.c b/mdopen.c
index e49defb6..8587524b 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -25,6 +25,8 @@
#include "mdadm.h"
#include "udev.h"
#include "md_p.h"
+#include "xmalloc.h"
+
#include <ctype.h>
void make_parts(char *dev, int cnt)
diff --git a/mdstat.c b/mdstat.c
index 29e78362..8d97a2fc 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -80,6 +80,8 @@
#include "mdadm.h"
#include "dlink.h"
+#include "xmalloc.h"
+
#include <sys/select.h>
#include <ctype.h>
diff --git a/msg.c b/msg.c
index b6da91d3..0cc7fc5d 100644
--- a/msg.c
+++ b/msg.c
@@ -30,6 +30,7 @@
#include <sys/un.h>
#include "mdadm.h"
#include "mdmon.h"
+#include "xmalloc.h"
static const __u32 start_magic = 0x5a5aa5a5;
static const __u32 end_magic = 0xa5a55a5a;
diff --git a/platform-intel.c b/platform-intel.c
index 21591317..95bc4929 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -19,6 +19,8 @@
#include "mdadm.h"
#include "platform-intel.h"
#include "probe_roms.h"
+#include "xmalloc.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/policy.c b/policy.c
index 4d4b248d..f417a9af 100644
--- a/policy.c
+++ b/policy.c
@@ -23,6 +23,8 @@
*/
#include "mdadm.h"
+#include "xmalloc.h"
+
#include <dirent.h>
#include <fnmatch.h>
#include <ctype.h>
diff --git a/restripe.c b/restripe.c
index a7a7229f..5e126eb7 100644
--- a/restripe.c
+++ b/restripe.c
@@ -23,6 +23,8 @@
*/
#include "mdadm.h"
+#include "xmalloc.h"
+
#include <stdint.h>
/* To restripe, we read from old geometry to a buffer, and
diff --git a/super-ddf.c b/super-ddf.c
index d870102d..6cd099ab 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -29,6 +29,8 @@
#include "mdadm.h"
#include "mdmon.h"
#include "sha1.h"
+#include "xmalloc.h"
+
#include <values.h>
#include <stddef.h>
diff --git a/super-gpt.c b/super-gpt.c
index ec3cf53f..50c267f6 100644
--- a/super-gpt.c
+++ b/super-gpt.c
@@ -40,6 +40,7 @@
#include "mdadm.h"
#include "part.h"
+#include "xmalloc.h"
static void free_gpt(struct supertype *st)
{
diff --git a/super-intel.c b/super-intel.c
index 30c2939a..7c5119c5 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -23,6 +23,8 @@
#include "dlink.h"
#include "sha1.h"
#include "platform-intel.h"
+#include "xmalloc.h"
+
#include <values.h>
#include <scsi/sg.h>
#include <ctype.h>
diff --git a/super-mbr.c b/super-mbr.c
index 839f0003..98810170 100644
--- a/super-mbr.c
+++ b/super-mbr.c
@@ -41,6 +41,7 @@
#include "mdadm.h"
#include "part.h"
+#include "xmalloc.h"
static void free_mbr(struct supertype *st)
{
diff --git a/super0.c b/super0.c
index c428e2a6..ff4905b9 100644
--- a/super0.c
+++ b/super0.c
@@ -25,6 +25,8 @@
#define HAVE_STDINT_H 1
#include "mdadm.h"
#include "sha1.h"
+#include "xmalloc.h"
+
/*
* All handling for the 0.90.0 version superblock is in
* this file.
diff --git a/super1.c b/super1.c
index 9c9c7dd1..fe3c4c64 100644
--- a/super1.c
+++ b/super1.c
@@ -24,6 +24,8 @@
#include <stddef.h>
#include "mdadm.h"
+#include "xmalloc.h"
+
/*
* The version-1 superblock :
* All numeric fields are little-endian.
diff --git a/sysfs.c b/sysfs.c
index 7a81cc5b..0f0506ca 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -24,9 +24,11 @@
*/
#include "mdadm.h"
+#include "dlink.h"
+#include "xmalloc.h"
+
#include <dirent.h>
#include <ctype.h>
-#include "dlink.h"
#define MAX_SYSFS_PATH_LEN 120
diff --git a/udev.c b/udev.c
index 066e6ab1..88a99781 100644
--- a/udev.c
+++ b/udev.c
@@ -22,6 +22,8 @@
#include "udev.h"
#include "md_p.h"
#include "md_u.h"
+#include "xmalloc.h"
+
#include <sys/wait.h>
#include <signal.h>
#include <limits.h>
diff --git a/util.c b/util.c
index 2b660725..4dfe757d 100644
--- a/util.c
+++ b/util.c
@@ -24,6 +24,8 @@
#include "mdadm.h"
#include "md_p.h"
+#include "xmalloc.h"
+
#include <sys/socket.h>
#include <sys/utsname.h>
#include <sys/wait.h>
diff --git a/xmalloc.c b/xmalloc.c
index 8b3f78a6..dac30eb6 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -21,64 +21,57 @@
* Email: <neilb@suse.de>
*/
-#include "mdadm.h"
-/*#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <sys/wait.h>
-#include <sys/un.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <signal.h>
-*/
+#include "xmalloc.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void *exit_memory_alloc_failure(void)
+{
+ fprintf(stderr, "Memory allocation failure - aborting\n");
+
+ /* TODO: replace with MDADM_STATUS_MEM_FAIL */
+ exit(1);
+}
void *xmalloc(size_t len)
{
void *rv = malloc(len);
- char *msg;
- int n;
+
if (rv)
return rv;
- msg = ": memory allocation failure - aborting\n";
- n = write(2, Name, strlen(Name));
- n += write(2, msg, strlen(msg));
- exit(4+!!n);
+
+ return exit_memory_alloc_failure();
}
void *xrealloc(void *ptr, size_t len)
{
void *rv = realloc(ptr, len);
- char *msg;
- int n;
+
if (rv)
return rv;
- msg = ": memory allocation failure - aborting\n";
- n = write(2, Name, strlen(Name));
- n += write(2, msg, strlen(msg));
- exit(4+!!n);
+
+ return exit_memory_alloc_failure();
}
void *xcalloc(size_t num, size_t size)
{
void *rv = calloc(num, size);
- char *msg;
- int n;
+
if (rv)
return rv;
- msg = ": memory allocation failure - aborting\n";
- n = write(2, Name, strlen(Name));
- n += write(2, msg, strlen(msg));
- exit(4+!!n);
+
+ return exit_memory_alloc_failure();
}
char *xstrdup(const char *str)
{
char *rv = strdup(str);
- char *msg;
- int n;
+
if (rv)
return rv;
- msg = ": memory allocation failure - aborting\n";
- n = write(2, Name, strlen(Name));
- n += write(2, msg, strlen(msg));
- exit(4+!!n);
+
+ return exit_memory_alloc_failure();
}
diff --git a/xmalloc.h b/xmalloc.h
new file mode 100644
index 00000000..0904b0ab
--- /dev/null
+++ b/xmalloc.h
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef XMALLOC_H
+#define XMALLOC_H
+
+#include <stddef.h>
+
+void *xmalloc(size_t len);
+void *xrealloc(void *ptr, size_t len);
+void *xcalloc(size_t num, size_t size);
+char *xstrdup(const char *str);
+
+#endif
--
2.41.0

View File

@ -0,0 +1,43 @@
From 4157e8da40ce976883c5b6e51e2352732e709b52 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Tue, 10 Sep 2024 14:17:58 +0200
Subject: [PATCH 190/201] md.man: update refference to raid5-ppl.rst
Documentation/md has moved to Documentation/driver-api/md.
Update and and rework sentence.
Remove refference to not supported kernel close to updated text.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
md.4 | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/md.4 b/md.4
index 7aef1577..9d5e55bf 100644
--- a/md.4
+++ b/md.4
@@ -937,18 +937,12 @@ Partial parity for a write operation is the XOR of stripe data chunks not
modified by the write. PPL is stored in the metadata region of RAID member drives,
no additional journal drive is needed.
After crashes, if one of the not modified data disks of
-the stripe is missing, this updated parity can be used to recover its
-data.
+the stripe is missing, this updated parity can be used to recover its data.
-This mechanism is documented more fully in the file
-Documentation/md/raid5-ppl.rst
+See Documentation/driver-api/md/raid5-ppl.rst for implementation details.
.SS WRITE-BEHIND
-From Linux 2.6.14,
-.I md
-supports WRITE-BEHIND on RAID1 arrays.
-
This allows certain devices in the array to be flagged as
.IR write-mostly .
MD will only read from such devices if there is no
--
2.41.0

View File

@ -0,0 +1,30 @@
From 6f227de0a17369d3d6667591241c49140d5239b2 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Fri, 4 Oct 2024 13:57:48 +0200
Subject: [PATCH 191/201] util: fix sys_hot_remove_disk()
Instead of "remove", "faulty" was called.
Fixes: d95edceb362a ("sysfs: add function for writing to sysfs fd")
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 4dfe757d..7c5c5c8f 100644
--- a/util.c
+++ b/util.c
@@ -1855,8 +1855,8 @@ int hot_remove_disk(int mdfd, unsigned long dev, int force)
int sys_hot_remove_disk(int statefd, int force)
{
+ static const char val[] = "remove";
int cnt = force ? 500 : 5;
- static const char val[] = "faulty";
while (cnt--) {
int err = 0;
--
2.41.0

View File

@ -0,0 +1,35 @@
From da826501c708b49a6e03394cf56f070160ea59d9 Mon Sep 17 00:00:00 2001
From: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Date: Mon, 30 Sep 2024 15:48:11 +0200
Subject: [PATCH 192/201] Rename Monitor.c to mdmonitor.c
Rename Monitor.c to mdmonitor.c to avoid errors during compilation on
case-insensitive filesystems.
Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
---
Makefile | 2 +-
Monitor.c => mdmonitor.c | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename Monitor.c => mdmonitor.c (100%)
diff --git a/Makefile b/Makefile
index a914b178..32f579de 100644
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@ endif
OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o uuid.o util.o maps.o lib.o udev.o \
Manage.o Assemble.o Build.o \
- Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
+ Create.o Detail.o Examine.o Grow.o mdmonitor.o dlink.o Kill.o Query.o \
Incremental.o Dump.o \
mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
super-mbr.o super-gpt.o \
diff --git a/Monitor.c b/mdmonitor.c
similarity index 100%
rename from Monitor.c
rename to mdmonitor.c
--
2.41.0

View File

@ -0,0 +1,178 @@
From bafa5ccfa56d776d431f766c765178eda0a4900d Mon Sep 17 00:00:00 2001
From: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Date: Fri, 4 Oct 2024 10:23:57 +0200
Subject: [PATCH 193/201] super-intel: move scsi_get_serial from sg_io
scsi_get_serial() function is used only by super-intel.c. Move function
to this file and remove sg_io.c file.
Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
---
Makefile | 4 ++--
sg_io.c | 60 ---------------------------------------------------
super-intel.c | 47 ++++++++++++++++++++++++++++++++++++----
3 files changed, 45 insertions(+), 66 deletions(-)
delete mode 100644 sg_io.c
diff --git a/Makefile b/Makefile
index 32f579de..24367b0f 100644
--- a/Makefile
+++ b/Makefile
@@ -190,7 +190,7 @@ OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o uuid.o util.o maps.o lib.o u
Incremental.o Dump.o \
mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
super-mbr.o super-gpt.o \
- restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o xmalloc.o \
+ restripe.o sysfs.o sha1.o mapfile.o crc32.o msg.o xmalloc.o \
platform-intel.o probe_roms.o crc32c.o drive_encryption.o
CHECK_OBJS = restripe.o uuid.o sysfs.o maps.o lib.o xmalloc.o dlink.o
@@ -201,7 +201,7 @@ INCL = mdadm.h part.h bitmap.h
MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o config.o mapfile.o mdopen.o\
policy.o lib.o udev.o \
- Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \
+ Kill.o dlink.o ReadMe.o super-intel.o \
super-mbr.o super-gpt.o \
super-ddf.o sha1.o crc32.o msg.o bitmap.o xmalloc.o \
platform-intel.o probe_roms.o crc32c.o drive_encryption.o
diff --git a/sg_io.c b/sg_io.c
deleted file mode 100644
index 7889a95e..00000000
--- a/sg_io.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2007-2008 Intel Corporation
- *
- * Retrieve drive serial numbers for scsi disks
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#include <string.h>
-#include <scsi/scsi.h>
-#include <scsi/sg.h>
-#include <sys/ioctl.h>
-
-int scsi_get_serial(int fd, void *buf, size_t buf_len)
-{
- unsigned char rsp_buf[255];
- unsigned char inq_cmd[] = {INQUIRY, 1, 0x80, 0, sizeof(rsp_buf), 0};
- unsigned char sense[32];
- struct sg_io_hdr io_hdr;
- int rv;
- unsigned int rsp_len;
-
- memset(&io_hdr, 0, sizeof(io_hdr));
- io_hdr.interface_id = 'S';
- io_hdr.cmdp = inq_cmd;
- io_hdr.cmd_len = sizeof(inq_cmd);
- io_hdr.dxferp = rsp_buf;
- io_hdr.dxfer_len = sizeof(rsp_buf);
- io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
- io_hdr.sbp = sense;
- io_hdr.mx_sb_len = sizeof(sense);
- io_hdr.timeout = 5000;
-
- rv = ioctl(fd, SG_IO, &io_hdr);
-
- if (rv)
- return rv;
-
- if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK)
- return -1;
-
- rsp_len = rsp_buf[3];
-
- if (!rsp_len || buf_len < rsp_len)
- return -1;
-
- memcpy(buf, &rsp_buf[4], rsp_len);
-
- return 0;
-}
diff --git a/super-intel.c b/super-intel.c
index 7c5119c5..3b856ad0 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -21,15 +21,18 @@
#include "mdadm.h"
#include "mdmon.h"
#include "dlink.h"
+#include "drive_encryption.h"
#include "sha1.h"
#include "platform-intel.h"
#include "xmalloc.h"
-#include <values.h>
-#include <scsi/sg.h>
#include <ctype.h>
#include <dirent.h>
-#include "drive_encryption.h"
+#include <scsi/scsi.h>
+#include <scsi/sg.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <values.h>
/* MPB == Metadata Parameter Block */
#define MPB_SIGNATURE "Intel Raid ISM Cfg Sig. "
@@ -4131,7 +4134,43 @@ static int nvme_get_serial(int fd, void *buf, size_t buf_len)
return devpath_to_char(path, "serial", buf, buf_len, 0);
}
-extern int scsi_get_serial(int fd, void *buf, size_t buf_len);
+mdadm_status_t scsi_get_serial(int fd, void *buf, size_t buf_len)
+{
+ struct sg_io_hdr io_hdr = {0};
+ unsigned char rsp_buf[255];
+ unsigned char inq_cmd[] = {INQUIRY, 1, 0x80, 0, sizeof(rsp_buf), 0};
+ unsigned char sense[32];
+ unsigned int rsp_len;
+ int rv;
+
+ io_hdr.interface_id = 'S';
+ io_hdr.cmdp = inq_cmd;
+ io_hdr.cmd_len = sizeof(inq_cmd);
+ io_hdr.dxferp = rsp_buf;
+ io_hdr.dxfer_len = sizeof(rsp_buf);
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ io_hdr.sbp = sense;
+ io_hdr.mx_sb_len = sizeof(sense);
+ io_hdr.timeout = 5000;
+
+ rv = ioctl(fd, SG_IO, &io_hdr);
+
+ if (rv)
+ return MDADM_STATUS_ERROR;
+
+ if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK)
+ return MDADM_STATUS_ERROR;
+
+ rsp_len = rsp_buf[3];
+
+ if (!rsp_len || buf_len < rsp_len)
+ return MDADM_STATUS_ERROR;
+
+ memcpy(buf, &rsp_buf[4], rsp_len);
+
+ return MDADM_STATUS_SUCCESS;
+}
+
static int imsm_read_serial(int fd, char *devname,
__u8 *serial, size_t serial_buf_len)
--
2.41.0

View File

@ -0,0 +1,120 @@
From a7a5e676a7eb2ac97acd31b13f75515e9573f891 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Thu, 26 Sep 2024 09:01:55 +0200
Subject: [PATCH 194/201] mdmonitor: Abandon custom configuration files
Operating system vendors are customizing mdmonitor service beacause
the default form is not satifying for them (expect SUSE). As a result,
support is complicated (maintainers have to check the system) and man page
is not detailed.
I propose to abandon custom configuration files via sysconfig and keep
it inside mdadm.conf only.
Detailed comment in service for OSV maintainers is added to help with
transition.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Makefile | 1 -
systemd/SUSE-mdadm_env.sh | 48 ---------------------------------------
systemd/mdmonitor.service | 19 ++++++++++++----
3 files changed, 15 insertions(+), 53 deletions(-)
delete mode 100644 systemd/SUSE-mdadm_env.sh
diff --git a/Makefile b/Makefile
index 24367b0f..bcd092de 100644
--- a/Makefile
+++ b/Makefile
@@ -341,7 +341,6 @@ install-systemd: systemd/mdmon@.service
$(INSTALL) -D -m 755 .install.tmp.3 $(DESTDIR)$(SYSTEMD_DIR)-shutdown/$$file ; \
rm -f .install.tmp.3; \
done
- if [ -f /etc/SuSE-release -o -n "$(SUSE)" ] ;then $(INSTALL) -D -m 755 systemd/SUSE-mdadm_env.sh $(DESTDIR)$(LIB_DIR)/mdadm_env.sh ;fi
install-bin: mdadm mdmon
$(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
diff --git a/systemd/SUSE-mdadm_env.sh b/systemd/SUSE-mdadm_env.sh
deleted file mode 100644
index c13b48ab..00000000
--- a/systemd/SUSE-mdadm_env.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-# extract configuration from /etc/sysconfig/mdadm and write
-# environment to /run/sysconfig/mdadm to be used by
-# systemd unit files.
-
-MDADM_SCAN="yes"
-
-# Following adapted from /etc/init.d/mdadmd on openSUSE
-
-mdadmd_CONFIG=/etc/sysconfig/mdadm
-if test -r $mdadmd_CONFIG; then
- . $mdadmd_CONFIG
-fi
-
-if [ x$MDADM_DELAY != x"" ]; then
- MDADM_DELAY="-d "$MDADM_DELAY;
-fi
-
-if [ x$MDADM_MAIL != x"" ]; then
- MDADM_MAIL="-m \"$MDADM_MAIL\""
-fi
-
-if [ x$MDADM_PROGRAM != x"" ]; then
- MDADM_PROGRAM="-p \"$MDADM_PROGRAM\""
-fi
-
-if [ x$MDADM_SCAN = x"yes" ]; then
- MDADM_SCAN="--scan"
-else
- MDADM_SCAN=""
-fi
-
-if [ x$MDADM_SEND_MAIL_ON_START = x"yes" ]; then
- MDADM_SEND_MAIL="-t"
-else
- MDADM_SEND_MAIL=""
-fi
-
-if [ x$MDADM_CONFIG != x"" ]; then
- MDADM_CONFIG="-c \"$MDADM_CONFIG\""
-fi
-
-mkdir -p /run/sysconfig
-echo "MDADM_MONITOR_ARGS=$MDADM_RAIDDEVICES $MDADM_DELAY $MDADM_MAIL $MDADM_PROGRAM $MDADM_SCAN $MDADM_SEND_MAIL $MDADM_CONFIG" > /run/sysconfig/mdadm
-if [ -n "$MDADM_CHECK_DURATION" ]; then
- echo "MDADM_CHECK_DURATION=$MDADM_CHECK_DURATION" >> /run/sysconfig/mdadm
-fi
diff --git a/systemd/mdmonitor.service b/systemd/mdmonitor.service
index 9c364785..6d0c0039 100644
--- a/systemd/mdmonitor.service
+++ b/systemd/mdmonitor.service
@@ -11,7 +11,18 @@ DefaultDependencies=no
Documentation=man:mdadm(8)
[Service]
-Environment= MDADM_MONITOR_ARGS=--scan
-EnvironmentFile=-/run/sysconfig/mdadm
-ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
-ExecStart=BINDIR/mdadm --monitor $MDADM_MONITOR_ARGS
+# For Maintainers:
+# We need to provide consistent mdmonitor configuration man page to the users. We don't want to get
+# asked continuously how it can be configured.
+# /etc/sysconfig/mdadm or /etc/sysconfig/mdmonitor or whatever else, should be abandoned.
+# Following parameters should be customized via mdadm.conf only:
+# - MONITORDELAY (do not set --delay in service)
+# - MAILADDR (do not set --mail in service)
+# - MAILFROM (not settable from cmdline)
+# - PROGRAM (do not set --program or --alert in service)
+#
+# Following parameters can be customized in service:
+# - --syslog (configure syslog logging)
+# - --fork (Type=forking must be added, not recommended and not needed with systemd)
+# - --pid-file (allowed only when --fork selected)
+ExecStart=BINDIR/mdadm --monitor --scan
--
2.41.0

View File

@ -0,0 +1,131 @@
From 70f3a1bcb0ff3b740f986b5819931b93c8bed24d Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Tue, 10 Sep 2024 15:35:03 +0200
Subject: [PATCH 195/201] mdadm.man: elaborate more about mdmonitor.service
Describe how it behaves and how it can be configured to work.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
mdadm.8.in | 52 ++++++++++++++++++++-------------------
systemd/mdmonitor.service | 11 ++++++---
2 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/mdadm.8.in b/mdadm.8.in
index aa0c5403..ee5b9bd4 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -1878,11 +1878,15 @@ script.
.SH For Monitor mode:
.TP
.BR \-m ", " \-\-mail
-Give a mail address to send alerts to.
+Give an mail address to send alerts to. Can be configured in
+.B mdadm.conf
+as MAILADDR.
.TP
.BR \-p ", " \-\-program ", " \-\-alert
-Give a program to be run whenever an event is detected.
+Give a program to be run whenever an event is detected. Can be configured in
+.B mdadm.conf
+as PROGRAM.
.TP
.BR \-y ", " \-\-syslog
@@ -1891,13 +1895,12 @@ facility of 'daemon' and varying priorities.
.TP
.BR \-d ", " \-\-delay
-Give a delay in seconds.
-.I mdadm
-polls the md arrays and then waits this many seconds before polling
-again. The default is 60 seconds. Since 2.6.16, there is no need to
-reduce this as the kernel alerts
+Give a delay in seconds. The default is 60 seconds.
.I mdadm
-immediately when there is any change.
+polls the md arrays and then waits this many seconds before polling again if no event happened.
+Can be configured in
+.B mdadm.conf
+as MONITORDELAY.
.TP
.BR \-r ", " \-\-increment
@@ -2595,30 +2598,29 @@ is given, then a
.B program
or an
.B e-mail
-address must be specified on the
-command line or in the config file. If neither are available, then
+address must be specified on the command line or in the config file. If neither are available, then
.I mdadm
-will not monitor anything.
-For devices given directly in command line, without
+will not monitor anything. For devices given directly in command line, without
.B program
or
.B email
specified, each event is reported to
.BR stdout.
-Note: For systems where
-.If mdadm monitor
-is configured via systemd,
-.B mdmonitor(mdmonitor.service)
-should be configured. The service is designed to be primary solution for array monitoring,
-it is configured to work in system wide mode.
-It is automatically started and stopped according to current state and types of MD arrays in system.
-The service may require additional configuration, like
-.B e-mail
-or
-.B delay.
-That should be done in
-.B mdadm.conf.
+Note: On systems where mdadm monitoring is managed through systemd, the mdmonitor.service
+should be present. This service is designed to be the primary solution for array monitoring.
+It is configured to operate in system-wide mode. It is initiated by udev when start criteria are
+met, e.g.
+.B mdadm.conf
+exists and necessary configuration parameters are set.
+It is kept alive as long as a redundant RAID array is active; it stops otherwise. User should
+customize MAILADDR in
+.B mdadm.conf
+to receive mail notifications. MONITORDELAY, MAILFROM and PROGRAM are optional. See
+.BR mdadm.conf (5)
+for detailed description of these options.
+Use systemctl status mdmonitor.service to verify status or determine if additional configuration
+is needed.
The different events are:
diff --git a/systemd/mdmonitor.service b/systemd/mdmonitor.service
index 6d0c0039..95046bc5 100644
--- a/systemd/mdmonitor.service
+++ b/systemd/mdmonitor.service
@@ -12,10 +12,12 @@ Documentation=man:mdadm(8)
[Service]
# For Maintainers:
-# We need to provide consistent mdmonitor configuration man page to the users. We don't want to get
-# asked continuously how it can be configured.
-# /etc/sysconfig/mdadm or /etc/sysconfig/mdmonitor or whatever else, should be abandoned.
-# Following parameters should be customized via mdadm.conf only:
+# We need to ensure that the mdmonitor configuration aligns with the guidelines provided
+# in the man page for users.
+# /etc/sysconfig/mdadm, /etc/sysconfig/mdmonitor, or any other similar configuration file should
+# not be supported because non upstream components are not described in man pages.
+
+# Parameters designed to be customized by user, should be settable via mdadm.conf:
# - MONITORDELAY (do not set --delay in service)
# - MAILADDR (do not set --mail in service)
# - MAILFROM (not settable from cmdline)
@@ -25,4 +27,5 @@ Documentation=man:mdadm(8)
# - --syslog (configure syslog logging)
# - --fork (Type=forking must be added, not recommended and not needed with systemd)
# - --pid-file (allowed only when --fork selected)
+
ExecStart=BINDIR/mdadm --monitor --scan
--
2.41.0

View File

@ -0,0 +1,85 @@
From f2f938b0b2755bb2c558eef87f5767beb2ff2ca1 Mon Sep 17 00:00:00 2001
From: Anna Sztukowska <anna.sztukowska@intel.com>
Date: Wed, 9 Oct 2024 08:14:05 +0200
Subject: [PATCH 196/201] mdadm: Add mdadm_status.h
Move mdadm_status_t to mdadm_status.h file. Add status for memory
allocation failure.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
---
mdadm.h | 7 +------
mdadm_status.h | 13 +++++++++++++
xmalloc.c | 4 ++--
3 files changed, 16 insertions(+), 8 deletions(-)
create mode 100644 mdadm_status.h
diff --git a/mdadm.h b/mdadm.h
index bbc1b97f..5781948e 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -166,6 +166,7 @@ struct dlm_lksb {
#include "md_p.h"
#include "bitmap.h"
#include "msg.h"
+#include "mdadm_status.h"
#include <endian.h>
/* Redhat don't like to #include <asm/byteorder.h>, and
@@ -449,12 +450,6 @@ struct spare_criteria {
struct dev_policy *pols;
};
-typedef enum mdadm_status {
- MDADM_STATUS_SUCCESS = 0,
- MDADM_STATUS_ERROR,
- MDADM_STATUS_UNDEF,
-} mdadm_status_t;
-
enum mode {
ASSEMBLE=1,
BUILD,
diff --git a/mdadm_status.h b/mdadm_status.h
new file mode 100644
index 00000000..905105e2
--- /dev/null
+++ b/mdadm_status.h
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef MDADM_STATUS_H
+#define MDADM_STATUS_H
+
+typedef enum mdadm_status {
+ MDADM_STATUS_SUCCESS = 0,
+ MDADM_STATUS_ERROR,
+ MDADM_STATUS_UNDEF,
+ MDADM_STATUS_MEM_FAIL
+} mdadm_status_t;
+
+#endif
diff --git a/xmalloc.c b/xmalloc.c
index dac30eb6..e28d3bd6 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -22,6 +22,7 @@
*/
#include "xmalloc.h"
+#include "mdadm_status.h"
#include <string.h>
#include <stdio.h>
@@ -32,8 +33,7 @@ static void *exit_memory_alloc_failure(void)
{
fprintf(stderr, "Memory allocation failure - aborting\n");
- /* TODO: replace with MDADM_STATUS_MEM_FAIL */
- exit(1);
+ exit(MDADM_STATUS_MEM_FAIL);
}
void *xmalloc(size_t len)
--
2.41.0

View File

@ -0,0 +1,67 @@
From 13378ba880c251aa65dac12a5d366230cb7ea039 Mon Sep 17 00:00:00 2001
From: Andre Paiusco <github@paiusco.org>
Date: Sat, 12 Oct 2024 16:28:29 +0200
Subject: [PATCH 197/201] mdadm.conf.man: Explain udev rule
Clarify a filename is accepted and the need of reloading the
udev rules.
Small correction on example order.
Signed-off-by: Andre Paiusco <github@paiusco.org>
---
mdadm.conf.5.in | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in
index 14302a91..97862fdb 100644
--- a/mdadm.conf.5.in
+++ b/mdadm.conf.5.in
@@ -506,8 +506,12 @@ of the new disk or if both arrays have the same
.IR spare-group .
To update hot plug configuration it is necessary to execute
-.B mdadm \-\-udev\-rules
-command after changing the config file
+.B mdadm \-\-udev\-rules\=<path_to_file>
+e.g.
+.B /etc/udev/rules.d/65-md-bare.rules
+command after changing the config file. And also run
+.B udevadm control \-\-reload
+otherwise, a reboot is needed.
Keywords used in the
.I POLICY
@@ -724,14 +728,6 @@ ARRAY /dev/md/home UUID=9187a482:5dde19d9:eea3cc4a:d646ab8b
.br
auto=part
.br
-POLICY domain=domain1 metadata=imsm path=pci-0000:00:1f.2-scsi-*
-.br
- action=spare
-.br
-POLICY domain=domain1 metadata=imsm path=pci-0000:04:00.0-scsi-[01]*
-.br
- action=include
-.br
# One domain comprising of devices attached to specified paths is defined.
.br
# Bare device matching first path will be made an imsm spare on hot plug.
@@ -742,6 +738,14 @@ POLICY domain=domain1 metadata=imsm path=pci-0000:04:00.0-scsi-[01]*
.br
# given domain name can be migrated.
.br
+POLICY domain=domain1 metadata=imsm path=pci-0000:00:1f.2-scsi-*
+.br
+ action=spare
+.br
+POLICY domain=domain1 metadata=imsm path=pci-0000:04:00.0-scsi-[01]*
+.br
+ action=include
+.br
MAILADDR root@mydomain.tld
.br
PROGRAM /usr/sbin/handle\-mdadm\-events
--
2.41.0

View File

@ -0,0 +1,37 @@
From cb4acfa372a8d66703706ef54f985bd588d8bb99 Mon Sep 17 00:00:00 2001
From: Andre Paiusco <github@paiusco.org>
Date: Sat, 12 Oct 2024 16:29:01 +0200
Subject: [PATCH 198/201] mdadm.man: Add udev-rules flag
--udev-rules flag is added and point to mdadm.conf man page
for further explanations about POLICY.
Signed-off-by: Andre Paiusco <github@paiusco.org>
---
mdadm.8.in | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mdadm.8.in b/mdadm.8.in
index ee5b9bd4..43d6fe05 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -1830,6 +1830,16 @@ can be found it
under
.BR "SCRUBBING AND MISMATCHES" .
+.TP
+.B \-\-udev\-rules=
+it generates the udev rules to the file that handles hot-plug bare devices.
+Given the POLICYs defined under
+.IR {CONFFILE}\ (or {CONFFILE2})
+
+See
+.BR mdadm.conf (5)
+for more details and usage examples about POLICY.
+
.SH For Incremental Assembly mode:
.TP
.BR \-\-rebuild\-map ", " \-r
--
2.41.0

View File

@ -0,0 +1,40 @@
From 0d29e12553cd9f51c1d4428ea373cdb8c62fbcf2 Mon Sep 17 00:00:00 2001
From: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Date: Wed, 9 Oct 2024 08:48:20 +0200
Subject: [PATCH 199/201] util: use only /dev directory in open_dev()
Previously, open_dev() tried to open device in two ways - using /dev and
/tmp directory. This method could be used by users which have no access
to /tmp directory (e.g. udev) and dev_open() fails which may affect many
processes. Remove try to open in /tmp directory.
Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
---
util.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/util.c b/util.c
index 7c5c5c8f..f05392a2 100644
--- a/util.c
+++ b/util.c
@@ -1111,17 +1111,6 @@ int dev_open(char *dev, int flags)
fd = open(devname, flags);
unlink(devname);
}
- if (fd < 0) {
- /* Try /tmp as /dev appear to be read-only */
- snprintf(devname, sizeof(devname),
- "/tmp/.tmp.md.%d:%d:%d",
- (int)getpid(), major, minor);
- if (mknod(devname, S_IFBLK|0600,
- makedev(major, minor)) == 0) {
- fd = open(devname, flags);
- unlink(devname);
- }
- }
} else
fd = open(dev, flags);
return fd;
--
2.41.0

View File

@ -0,0 +1,47 @@
From c6ca5b31e18f92490e639de0e5eae88985628633 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Fri, 18 Oct 2024 16:48:16 +0800
Subject: [PATCH 200/201] mdadm/Manage: Clear superblock if adding new device
fails
The superblock is kept if adding new device fails. It should clear the
superblock if it fails to add a new disk.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Manage.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Manage.c b/Manage.c
index 246ef319..8c58683b 100644
--- a/Manage.c
+++ b/Manage.c
@@ -793,6 +793,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
int j;
mdu_disk_info_t disc;
struct map_ent *map = NULL;
+ bool add_new_super = false;
if (!get_dev_size(tfd, dv->devname, &ldsize)) {
if (dv->disposition == 'M')
@@ -1011,6 +1012,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
goto unlock;
if (tst->ss->write_init_super(tst))
goto unlock;
+ add_new_super = true;
} else if (dv->disposition == 'A') {
/* this had better be raid1.
* As we are "--re-add"ing we must find a spare slot
@@ -1078,6 +1080,8 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
map_unlock(&map);
return 1;
unlock:
+ if (add_new_super)
+ Kill(dv->devname, tst, 0, -1, 0);
map_unlock(&map);
return -1;
}
--
2.41.0

View File

@ -0,0 +1,31 @@
From b278b2fc172bb8d50f607adef4d515af1f52d913 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Fri, 18 Oct 2024 16:48:17 +0800
Subject: [PATCH 201/201] mdadm/Grow: Check new_level interface rather than
kernel version
Different os distributions have different kernel version themselves.
Check new_level sysfs interface rather than kernel version.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
Grow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index ef1285ec..9032c3e9 100644
--- a/Grow.c
+++ b/Grow.c
@@ -2952,7 +2952,7 @@ static int impose_reshape(struct mdinfo *sra,
err = errno;
/* new_level is introduced in kernel 6.12 */
- if (!err && get_linux_version() >= 6012000 &&
+ if (!err && sysfs_attribute_available(sra, NULL, "new_level") &&
sysfs_set_num(sra, NULL, "new_level", info->new_level) < 0)
err = errno;
--
2.41.0

View File

@ -3,7 +3,7 @@
Name: mdadm Name: mdadm
Version: 4.3 Version: 4.3
# extraversion is used to define rhel internal version # extraversion is used to define rhel internal version
%define extraversion 3 %define extraversion 4
Release: %{extraversion}%{?dist} Release: %{extraversion}%{?dist}
Summary: The mdadm program controls Linux md devices (software RAID arrays) Summary: The mdadm program controls Linux md devices (software RAID arrays)
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
@ -87,90 +87,134 @@ Patch062: 0063-Makefile-Move-pie-to-LDFLAGS.patch
Patch063: 0064-tests-23rdev-lifetime-fix-a-typo.patch Patch063: 0064-tests-23rdev-lifetime-fix-a-typo.patch
Patch064: 0065-util.c-change-devnm-to-const-in-mdmon-functions.patch Patch064: 0065-util.c-change-devnm-to-const-in-mdmon-functions.patch
Patch065: 0066-Wait-for-mdmon-when-it-is-stared-via-systemd.patch Patch065: 0066-Wait-for-mdmon-when-it-is-stared-via-systemd.patch
Patch066: 0069-mdadm-Fix-compilation-for-32-bit-arch.patch Patch066: 0067-mdadm-Change-main-repository-to-Github.patch
Patch067: 0070-add-checking-of-return-status-on-fstat-calls.patch Patch067: 0069-mdadm-Fix-compilation-for-32-bit-arch.patch
Patch068: 0071-super-intel-fix-typo-in-error-msg.patch Patch068: 0070-add-checking-of-return-status-on-fstat-calls.patch
Patch069: 0072-mdadm-super-intel-remove-dead-code.patch Patch069: 0071-super-intel-fix-typo-in-error-msg.patch
Patch070: 0073-mdadm-super-intel-fix-bad-shift.patch Patch070: 0072-mdadm-super-intel-remove-dead-code.patch
Patch071: 0074-mdadm-deprecate-bitmap-custom-file.patch Patch071: 0073-mdadm-super-intel-fix-bad-shift.patch
Patch072: 0075-Makefile-fix-make-s-detection.patch Patch072: 0074-mdadm-deprecate-bitmap-custom-file.patch
Patch073: 0076-Change-some-error-messages-to-info-level.patch Patch073: 0075-Makefile-fix-make-s-detection.patch
Patch074: 0077-mdadm-Start-update_opt-from-0.patch Patch074: 0076-Change-some-error-messages-to-info-level.patch
Patch075: 0078-Don-t-control-reshape-speed-in-daemon.patch Patch075: 0077-mdadm-Start-update_opt-from-0.patch
Patch076: 0079-mdadm-tests-test-enhance.patch Patch076: 0078-Don-t-control-reshape-speed-in-daemon.patch
Patch077: 0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch Patch077: 0079-mdadm-tests-test-enhance.patch
Patch078: 0081-mdadm-tests-names_template-enhance.patch Patch078: 0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch
Patch079: 0082-mdadm-tests-03assem-incr-enhance.patch Patch079: 0081-mdadm-tests-names_template-enhance.patch
Patch080: 0083-mdadm-tests-03r0assem-enhance.patch Patch080: 0082-mdadm-tests-03assem-incr-enhance.patch
Patch081: 0084-mdadm-tests-remove-03r5assem-failed.patch Patch081: 0083-mdadm-tests-03r0assem-enhance.patch
Patch082: 0085-mdadm-tests-03r5assemV1.patch Patch082: 0084-mdadm-tests-remove-03r5assem-failed.patch
Patch083: 0086-mdadm-tests-remove-04r5swap.broken.patch Patch083: 0085-mdadm-tests-03r5assemV1.patch
Patch084: 0087-tests-04update-metadata-skip-linear.patch Patch084: 0086-mdadm-tests-remove-04r5swap.broken.patch
Patch085: 0088-mdadm-tests-05r5-internalbitmap.patch Patch085: 0087-tests-04update-metadata-skip-linear.patch
Patch086: 0089-mdadm-tests-06name-enhance.patch Patch086: 0088-mdadm-tests-05r5-internalbitmap.patch
Patch087: 0090-mdadm-tests-07autoassemble.patch Patch087: 0089-mdadm-tests-06name-enhance.patch
Patch088: 0091-mdadm-tests-07autodetect.broken-can-be-removed.patch Patch088: 0090-mdadm-tests-07autoassemble.patch
Patch089: 0092-mdadm-tests-07changelevelintr.patch Patch089: 0091-mdadm-tests-07autodetect.broken-can-be-removed.patch
Patch090: 0093-mdadm-tests-disable-selinux.patch Patch090: 0092-mdadm-tests-07changelevelintr.patch
Patch091: 0094-mdadm-platform-intel-buffer-overflow-detected.patch Patch091: 0093-mdadm-tests-disable-selinux.patch
Patch092: 0095-mdadm-tests-bitmap-cases-enhance.patch Patch092: 0094-mdadm-platform-intel-buffer-overflow-detected.patch
Patch093: 0096-mdadm-tests-04update-uuid.patch Patch093: 0095-mdadm-tests-bitmap-cases-enhance.patch
Patch094: 0097-mdadm-tests-05r1-re-add-nosuper.patch Patch094: 0096-mdadm-tests-04update-uuid.patch
Patch095: 0098-mdadm-tests-remove-strace-test.patch Patch095: 0097-mdadm-tests-05r1-re-add-nosuper.patch
Patch096: 0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch Patch096: 0098-mdadm-tests-remove-strace-test.patch
Patch097: 0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch Patch097: 0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch
Patch098: 0101-imsm-make-freesize-required-to-volume-autolayout.patch Patch098: 0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch
Patch099: 0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch Patch099: 0101-imsm-make-freesize-required-to-volume-autolayout.patch
Patch100: 0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch Patch100: 0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch
Patch101: 0104-test-pass-flags-to-services.patch Patch101: 0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch
Patch102: 0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch Patch102: 0104-test-pass-flags-to-services.patch
Patch103: 0106-Makefile-Do-not-call-gcc-directly.patch Patch103: 0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch
Patch104: 0107-mdadm-tests-judge-foreign-array-in-test-cases.patch Patch104: 0106-Makefile-Do-not-call-gcc-directly.patch
Patch105: 0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch Patch105: 0107-mdadm-tests-judge-foreign-array-in-test-cases.patch
Patch106: 0109-mdadm-Assemble.c-fix-coverity-issues.patch Patch106: 0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch
Patch107: 0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch Patch107: 0109-mdadm-Assemble.c-fix-coverity-issues.patch
Patch108: 0113-config.c-Fix-memory-leak-in-load_containers.patch Patch108: 0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch
Patch109: 0114-mdadm-Build.c-fix-coverity-issues.patch Patch109: 0113-config.c-Fix-memory-leak-in-load_containers.patch
Patch110: 0115-mdadm-Create.c-fix-coverity-issues.patch Patch110: 0114-mdadm-Build.c-fix-coverity-issues.patch
Patch111: 0116-mdadm-super-ddf.c-fix-coverity-issues.patch Patch111: 0115-mdadm-Create.c-fix-coverity-issues.patch
Patch112: 0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch Patch112: 0116-mdadm-super-ddf.c-fix-coverity-issues.patch
Patch113: 0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch Patch113: 0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch
Patch114: 0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch Patch114: 0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch
Patch115: 0120-mdadm-Manage.c-fix-coverity-issues.patch Patch115: 0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch
Patch116: 0121-Manage-fix-is_remove_safe.patch Patch116: 0120-mdadm-Manage.c-fix-coverity-issues.patch
Patch117: 0122-imsm-add-indent-for-encryption-details.patch Patch117: 0121-Manage-fix-is_remove_safe.patch
Patch118: 0123-mdadm-Monitor.c-fix-coverity-issues.patch Patch118: 0122-imsm-add-indent-for-encryption-details.patch
Patch119: 0124-mdadm-Query.c-fix-coverity-issues.patch Patch119: 0123-mdadm-Monitor.c-fix-coverity-issues.patch
Patch120: 0125-mdadm-lib.c-fix-coverity-issues.patch Patch120: 0124-mdadm-Query.c-fix-coverity-issues.patch
Patch121: 0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch Patch121: 0125-mdadm-lib.c-fix-coverity-issues.patch
Patch122: 0128-Detail-fix-detail-export-for-uuid_zero.patch Patch122: 0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch
Patch123: 0129-drive_encryption-Fix-ata-passthrough12-verify.patch Patch123: 0128-Detail-fix-detail-export-for-uuid_zero.patch
Patch124: 0130-super0-use-define-for-char-array-in-examine_super0.patch Patch124: 0129-drive_encryption-Fix-ata-passthrough12-verify.patch
Patch125: 0131-Makefile-add-more-compiler-flags.patch Patch125: 0130-super0-use-define-for-char-array-in-examine_super0.patch
Patch126: 0133-mdstat-Rework-mdstat-external-arrays-handling.patch Patch126: 0131-Makefile-add-more-compiler-flags.patch
Patch127: 0134-mdadm-managemon.c-fix-coverity-issues.patch Patch127: 0133-mdstat-Rework-mdstat-external-arrays-handling.patch
Patch128: 0135-mdadm-msg.c-fix-coverity-issues.patch Patch128: 0134-mdadm-managemon.c-fix-coverity-issues.patch
Patch129: 0136-imsm-refactor-chunk-size-print.patch Patch129: 0135-mdadm-msg.c-fix-coverity-issues.patch
Patch130: 0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch Patch130: 0136-imsm-refactor-chunk-size-print.patch
Patch131: 0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch Patch131: 0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch
Patch132: 0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch Patch132: 0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch
Patch133: 0140-mdadm-Incremental-fix-coverity-issues.patch Patch133: 0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch
Patch134: 0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch Patch134: 0140-mdadm-Incremental-fix-coverity-issues.patch
Patch135: 0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch Patch135: 0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch
Patch136: 0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch Patch136: 0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch
Patch137: 0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch Patch137: 0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch
Patch138: 0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch Patch138: 0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch
Patch139: 0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch Patch139: 0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch
Patch140: 0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch Patch140: 0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch
Patch141: 0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch Patch141: 0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch
Patch142: 0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch Patch142: 0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch
Patch143: 0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch Patch143: 0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch
Patch144: 0151-policy.c-Fix-check_return-issue-in-Write_rules.patch Patch144: 0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch
Patch145: 0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch Patch145: 0151-policy.c-Fix-check_return-issue-in-Write_rules.patch
Patch146: 0153-super-intel-fix-compilation-error.patch Patch146: 0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch
Patch147: 0154-super-intel-add-define-for-migr_state.patch Patch147: 0153-super-intel-fix-compilation-error.patch
Patch148: 0156-Grow_reshape-set-only-component_size-for-size-grow.patch Patch148: 0154-super-intel-add-define-for-migr_state.patch
Patch149: 0157-mdstat-fix-list-detach-issues.patch Patch149: 0156-Grow_reshape-set-only-component_size-for-size-grow.patch
Patch150: 0157-mdstat-fix-list-detach-issues.patch
Patch151: 0158-md.4-replace-wrong-word.patch
Patch152: 0159-mdadm-util.c-fix-coverity-issues.patch
Patch153: 0160-mdadm-sysfs.c-fix-coverity-issues.patch
Patch154: 0161-imsm-add-read-OROM-form-ACPI-UEFI-tables.patch
Patch155: 0162-imsm-get-bus-from-VMD-driver-directory.patch
Patch156: 0163-platform-intel-refactor-path_attached_to_hba.patch
Patch157: 0164-mdadm-Change-displaying-of-devices-in-detail.patch
Patch158: 0165-imsm-Remove-warning-and-refactor-add_to_super_imsm-c.patch
Patch159: 0166-imsm-add-IMSM_OROM_CAPABILITIES_TPV-to-nvme-orom.patch
Patch160: 0167-mdadm-Increase-number-limit-in-md-device-name-to-102.patch
Patch161: 0168-imsm-save-checkpoint-prior-to-exit.patch
Patch162: 0169-Examine.c-Fix-memory-leaks-in-Examine.patch
Patch163: 0170-dlink.h-Fix-checkpatch-warnings-for-function-args.patch
Patch164: 0171-Incremental-support-devnode-in-IncrementalRemove.patch
Patch165: 0172-Detail.c-Fix-divide_by_zero-issue.patch
Patch166: 0173-mdadm-Add-compilation-process-to-README.md.patch
Patch167: 0174-mdadm-Grow-Update-new-level-when-starting-reshape.patch
Patch168: 0175-mdadm-Grow-Update-reshape_progress-to-need_back-afte.patch
Patch169: 0176-mdadm-Grow-Can-t-open-raid-when-running-grow-continu.patch
Patch170: 0177-mdadm-Grow-sleep-a-while-after-removing-disk-in-impo.patch
Patch171: 0178-mdadm-tests-wait-until-level-changes.patch
Patch172: 0179-mdadm-tests-07changelevels-fix.patch
Patch173: 0180-mdadm-tests-Remove-07reshape5intr.broken.patch
Patch174: 0181-mdadm-tests-07testreshape5-fix.patch
Patch175: 0182-mdadm-tests-remove-09imsm-assemble.broken.patch
Patch176: 0183-mdadm-Manage-record-errno.patch
Patch177: 0184-Remove-INSTALL-and-dev-null.patch
Patch178: 0186-Incremental-Rename-IncrementalRemove.patch
Patch179: 0187-sysfs-add-function-for-writing-to-sysfs-fd.patch
Patch180: 0188-Mdmonitor-Fix-startup-with-missing-directory.patch
Patch181: 0189-mdadm-add-xmalloc.h.patch
Patch182: 0190-md.man-update-refference-to-raid5-ppl.rst.patch
Patch183: 0191-util-fix-sys_hot_remove_disk.patch
Patch184: 0192-Rename-Monitor.c-to-mdmonitor.c.patch
Patch185: 0193-super-intel-move-scsi_get_serial-from-sg_io.patch
Patch186: 0194-mdmonitor-Abandon-custom-configuration-files.patch
Patch187: 0195-mdadm.man-elaborate-more-about-mdmonitor.service.patch
Patch188: 0196-mdadm-Add-mdadm_status.h.patch
Patch189: 0197-mdadm.conf.man-Explain-udev-rule.patch
Patch190: 0198-mdadm.man-Add-udev-rules-flag.patch
Patch191: 0199-util-use-only-dev-directory-in-open_dev.patch
Patch192: 0200-mdadm-Manage-Clear-superblock-if-adding-new-device-f.patch
Patch193: 0201-mdadm-Grow-Check-new_level-interface-rather-than-ker.patch
# Fedora customization patches # Fedora customization patches
Patch197: mdadm-udev.patch Patch197: mdadm-udev.patch
@ -254,6 +298,10 @@ install -m644 %{SOURCE5} %{buildroot}/etc/libreport/events.d
/usr/share/mdadm/mdcheck /usr/share/mdadm/mdcheck
%changelog %changelog
* Sat Oct 19 2024 Xiao Ni <xni@redhat.com> - 4.3-4
- Update to latest upstream
- Resolves: RHEL-59101
* Sun Aug 11 2024 Xiao Ni <xni@redhat.com> - 4.3-3 * Sun Aug 11 2024 Xiao Ni <xni@redhat.com> - 4.3-3
- Fix coverity issue and update to latest upstream - Fix coverity issue and update to latest upstream
- Resolves: RHEL-34533, RHEL-50776 - Resolves: RHEL-34533, RHEL-50776