diff --git a/.gitignore b/.gitignore index 34fb3da..3b6b56f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ clog *.src.rpm */ /mdadm-4.*.tar.xz +/mdadm-4.3.tar.sign diff --git a/0001-Revert-mdadm-Follow-POSIX-Portable-Character-Set.patch b/0001-Revert-mdadm-Follow-POSIX-Portable-Character-Set.patch new file mode 100644 index 0000000..e5cd419 --- /dev/null +++ b/0001-Revert-mdadm-Follow-POSIX-Portable-Character-Set.patch @@ -0,0 +1,428 @@ +From 857ad175fe025f026a1173e38de0b482110fdce5 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Sun, 6 Apr 2025 14:13:45 -0700 +Subject: [PATCH] Revert "mdadm: Follow POSIX Portable Character Set" + +This reverts commit e2eb503bd797908f515b58428b274f1ba6a05349. +--- + Detail.c | 17 +++++++----- + config.c | 13 +++------ + lib.c | 58 +++++++++++----------------------------- + mdadm.8.in | 70 ++++++++++++++++++++++++++++--------------------- + mdadm.conf.5.in | 4 +++ + mdadm.h | 2 +- + super-intel.c | 47 +++++++++++++++++---------------- + 7 files changed, 100 insertions(+), 111 deletions(-) + +diff --git a/Detail.c b/Detail.c +index aaa3dd6e..6d675152 100644 +--- a/Detail.c ++++ b/Detail.c +@@ -254,9 +254,11 @@ int Detail(char *dev, struct context *c) + fname_from_uuid(st, info, nbuf, ':'); + printf("MD_UUID=%s\n", nbuf + 5); + mp = map_by_uuid(&map, info->uuid); +- +- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) +- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN); ++ if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) { ++ printf("MD_DEVNAME="); ++ print_escape(mp->path + DEV_MD_DIR_LEN); ++ putchar('\n'); ++ } + + if (st->ss->export_detail_super) + st->ss->export_detail_super(st); +@@ -269,9 +271,12 @@ int Detail(char *dev, struct context *c) + __fname_from_uuid(mp->uuid, 0, nbuf, ':'); + printf("MD_UUID=%s\n", nbuf+5); + } +- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) +- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN); +- ++ if (mp && mp->path && ++ strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) { ++ printf("MD_DEVNAME="); ++ print_escape(mp->path + DEV_MD_DIR_LEN); ++ putchar('\n'); ++ } + map_free(map); + } + if (!c->no_devices && sra) { +diff --git a/config.c b/config.c +index 44f7dd2f..0a80eedb 100644 +--- a/config.c ++++ b/config.c +@@ -199,9 +199,9 @@ inline void ident_init(struct mddev_ident *ident) + * /dev/md_d{number} (legacy) + * /dev/md_{name} + * /dev/md/{name} +- * {name} ++ * {name} - anything that doesn't start from '/' or '<'. + * +- * {name} must follow name's criteria and be POSIX compatible. ++ * {name} must follow name's criteria. + * If criteria passed, duplicate memory and set devname in @ident. + * + * Return: %MDADM_STATUS_SUCCESS or %MDADM_STATUS_ERROR. +@@ -241,8 +241,8 @@ mdadm_status_t _ident_set_devname(struct mddev_ident *ident, const char *devname + else + name = devname; + +- if (is_name_posix_compatible(name) == false) { +- ident_log(prop_name, name, "Not POSIX compatible", cmdline); ++ if (*name == '/' || *name == '<') { ++ ident_log(prop_name, devname, "Cannot be started from \'/\' or \'<\'", cmdline); + return MDADM_STATUS_ERROR; + } + +@@ -284,11 +284,6 @@ static mdadm_status_t _ident_set_name(struct mddev_ident *ident, const char *nam + return MDADM_STATUS_ERROR; + } + +- if (is_name_posix_compatible(name) == false) { +- ident_log(prop_name, name, "Not POSIX compatible", cmdline); +- return MDADM_STATUS_ERROR; +- } +- + snprintf(ident->name, MD_NAME_MAX + 1, "%s", name); + return MDADM_STATUS_SUCCESS; + } +diff --git a/lib.c b/lib.c +index 2b09293c..95e3511f 100644 +--- a/lib.c ++++ b/lib.c +@@ -454,50 +454,24 @@ void print_quoted(char *str) + putchar(q); + } + +-/** +- * is_alphanum() - Check if sign is letter or digit. +- * @c: char to analyze. +- * +- * Similar to isalnum() but additional locales are excluded. +- * +- * Return: %true on success, %false otherwise. +- */ +-bool is_alphanum(const char c) +-{ +- if (isupper(c) || islower(c) || isdigit(c) != 0) +- return true; +- return false; +-} +- +-/** +- * is_name_posix_compatible() - Check if name is POSIX compatible. +- * @name: name to check. +- * +- * POSIX portable file name character set contains ASCII letters, +- * digits, '_', '.', and '-'. Also forbid leading '-'. +- * The length of the name cannot exceed NAME_MAX - 1 (ensure NULL ending). +- * +- * Return: %true on success, %false otherwise. +- */ +-bool is_name_posix_compatible(const char * const name) ++void print_escape(char *str) + { +- assert(name); +- +- char allowed_symbols[] = "-_."; +- const char *n = name; +- +- if (!is_string_lq(name, NAME_MAX)) +- return false; +- +- if (*n == '-') +- return false; +- +- while (*n != '\0') { +- if (!is_alphanum(*n) && !strchr(allowed_symbols, *n)) +- return false; +- n++; ++ /* print str, but change space and tab to '_' ++ * as is suitable for device names ++ */ ++ for (; *str; str++) { ++ switch (*str) { ++ case ' ': ++ case '\t': ++ putchar('_'); ++ break; ++ case '/': ++ putchar('-'); ++ break; ++ default: ++ putchar(*str); ++ } + } +- return true; + } + + int check_env(char *name) +diff --git a/mdadm.8.in b/mdadm.8.in +index 96a4a08e..4af90c48 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -364,7 +364,7 @@ Use the Intel(R) Matrix Storage Manager metadata format. This creates a + which is managed in a similar manner to DDF, and is supported by an + option-rom on some platforms: + .IP +-.B https://www.intel.com/content/www/us/en/support/products/122484 ++.B https://www.intel.com/content/www/us/en/support/products/122484/memory-and-storage/ssd-software/intel-virtual-raid-on-cpu-intel-vroc.html + .PP + .RE + +@@ -932,14 +932,17 @@ option will be ignored. + .BR \-N ", " \-\-name= + Set a + .B name +-for the array. It must be +-.BR "POSIX PORTABLE NAME" +-compatible and cannot be longer than 32 chars. This is effective when creating an array +-with a v1 metadata, or an external array. +- +-If name is needed but not specified, it is taken from the basename of the device +-that is being created. See +-.BR "DEVICE NAMES" ++for the array. This is currently only effective when creating an ++array with a version-1 superblock, or an array in a DDF container. ++The name is a simple textual string that can be used to identify array ++components when assembling. If name is needed but not specified, it ++is taken from the basename of the device that is being created. ++e.g. when creating ++.I /dev/md/home ++the ++.B name ++will default to ++.IR home . + + .TP + .BR \-R ", " \-\-run +@@ -1129,10 +1132,8 @@ is much safer. + + .TP + .BR \-N ", " \-\-name= +-Specify the name of the array to assemble. It must be +-.BR "POSIX PORTABLE NAME" +-compatible and cannot be longer than 32 chars. This must be the name +-that was specified when creating the array. It must either match ++Specify the name of the array to assemble. This must be the name ++that was specified when creating the array. It must either match + the name stored in the superblock exactly, or it must match + with the current + .I homehost +@@ -2178,17 +2179,14 @@ Usage: + .I md-device + .BI \-\-chunk= X + .BI \-\-level= Y ++.br + .BI \-\-raid\-devices= Z + .I devices + + .PP +-This usage will initialize a new md array, associate some devices with ++This usage will initialise a new md array, associate some devices with + it, and activate the array. + +-.I md-device +-is a new device. This could be standard name or chosen name. For details see: +-.BR "DEVICE NAMES" +- + The named device will normally not exist when + .I "mdadm \-\-create" + is run, but will be created by +@@ -2229,6 +2227,24 @@ array. This feature can be overridden with the + .B \-\-force + option. + ++When creating an array with version-1 metadata a name for the array is ++required. ++If this is not given with the ++.B \-\-name ++option, ++.I mdadm ++will choose a name based on the last component of the name of the ++device being created. So if ++.B /dev/md3 ++is being created, then the name ++.B 3 ++will be chosen. ++If ++.B /dev/md/home ++is being created, then the name ++.B home ++will be used. ++ + When creating a partition based array, using + .I mdadm + with version-1.x metadata, the partition type should be set to +@@ -2413,10 +2429,12 @@ and + + The + .B name +-option updates the subarray name in the metadata. It must be +-.BR "POSIX PORTABLE NAME" +-compatible and cannot be longer than 32 chars. If successes, new value will be respected after +-next assembly. ++option updates the subarray name in the metadata, it may not affect the ++device node name or the device node symlink until the subarray is ++re\-assembled. If updating ++.B name ++would change the UUID of an active subarray this operation is blocked, ++and the command will end in an error. + + The + .B ppl +@@ -3377,10 +3395,6 @@ When + .B \-\-incremental + mode is used, this file gets a list of arrays currently being created. + +-.SH POSIX PORTABLE NAME +-A valid name can only consist of characters "A-Za-z0-9.-_". +-The name cannot start with a leading "-" and cannot exceed 255 chars. +- + .SH DEVICE NAMES + + .I mdadm +@@ -3402,10 +3416,6 @@ can be given, or just the suffix of the second sort of name, such as + .I home + can be given. + +-In every style, raw name must be compatible with +-.BR "POSIX PORTABLE NAME" +-and has to be no longer than 32 chars. +- + When + .I mdadm + chooses device names during auto-assembly or incremental assembly, it +diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in +index 787e51e9..032b8010 100644 +--- a/mdadm.conf.5.in ++++ b/mdadm.conf.5.in +@@ -710,6 +710,10 @@ ARRAY /dev/md/home UUID=9187a482:5dde19d9:eea3cc4a:d646ab8b + .br + auto=part + .br ++# The name of this array contains a space. ++.br ++ARRAY /dev/md9 name='Data Storage' ++.sp + POLICY domain=domain1 metadata=imsm path=pci-0000:00:1f.2-scsi-* + .br + action=spare +diff --git a/mdadm.h b/mdadm.h +index 1f28b3e7..3b3168d4 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1623,7 +1623,6 @@ extern int check_raid(int fd, char *name); + extern int check_partitions(int fd, char *dname, + unsigned long long freesize, + unsigned long long size); +-extern bool is_name_posix_compatible(const char *path); + extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev); + extern int stat_is_blkdev(char *devname, dev_t *rdev); + +@@ -1664,6 +1663,7 @@ extern int conf_get_monitor_delay(void); + extern char *conf_line(FILE *file); + extern char *conf_word(FILE *file, int allow_key); + extern void print_quoted(char *str); ++extern void print_escape(char *str); + extern int use_udev(void); + extern void print_escape(char *str); + extern unsigned long GCD(unsigned long a, unsigned long b); +diff --git a/super-intel.c b/super-intel.c +index dbea235d..33f1469f 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -5533,37 +5533,40 @@ static void imsm_update_version_info(struct intel_super *super) + } + } + +-/** +- * imsm_check_name() - check imsm naming criteria. +- * @super: &intel_super pointer, not NULL. +- * @name: name to check. +- * @verbose: verbose level. +- * +- * Name must be no longer than &MAX_RAID_SERIAL_LEN and must be unique across volumes. +- * +- * Returns: &true if @name matches, &false otherwise. +- */ +-static bool imsm_is_name_allowed(struct intel_super *super, const char * const name, +- const int verbose) ++static int check_name(struct intel_super *super, char *name, int quiet) + { + struct imsm_super *mpb = super->anchor; ++ char *reason = NULL; ++ char *start = name; ++ size_t len = strlen(name); + int i; + +- if (is_string_lq(name, MAX_RAID_SERIAL_LEN + 1) == false) { +- pr_vrb("imsm: Name \"%s\" is too long\n", name); +- return false; ++ if (len > 0) { ++ while (isspace(start[len - 1])) ++ start[--len] = 0; ++ while (*start && isspace(*start)) ++ ++start, --len; ++ memmove(name, start, len + 1); + } + ++ if (len > MAX_RAID_SERIAL_LEN) ++ reason = "must be 16 characters or less"; ++ else if (len == 0) ++ reason = "must be a non-empty string"; ++ + for (i = 0; i < mpb->num_raid_devs; i++) { + struct imsm_dev *dev = get_imsm_dev(super, i); + + if (strncmp((char *) dev->volume, name, MAX_RAID_SERIAL_LEN) == 0) { +- pr_vrb("imsm: Name \"%s\" already exists\n", name); +- return false; ++ reason = "already exists"; ++ break; + } + } + +- return true; ++ if (reason && !quiet) ++ pr_err("imsm volume name %s\n", reason); ++ ++ return !reason; + } + + static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, +@@ -5658,9 +5661,8 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, + } + } + +- if (imsm_is_name_allowed(super, name, 1) == false) ++ if (!check_name(super, name, 0)) + return 0; +- + dv = xmalloc(sizeof(*dv)); + dev = xcalloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1)); + /* +@@ -7988,7 +7990,7 @@ static int update_subarray_imsm(struct supertype *st, char *subarray, + char *ep; + int vol; + +- if (imsm_is_name_allowed(super, name, 1) == false) ++ if (!check_name(super, name, 0)) + return 2; + + vol = strtoul(subarray, &ep, 10); +@@ -10298,8 +10300,7 @@ static void imsm_process_update(struct supertype *st, + if (a->info.container_member == target) + break; + dev = get_imsm_dev(super, u->dev_idx); +- +- if (a || !dev || imsm_is_name_allowed(super, name, 0) == false) { ++ if (a || !check_name(super, name, 1)) { + dprintf("failed to rename subarray-%d\n", target); + break; + } +-- +2.49.0 + diff --git a/0002-dont-stop-in-assemble.patch b/0002-dont-stop-in-assemble.patch new file mode 100644 index 0000000..6eaf564 --- /dev/null +++ b/0002-dont-stop-in-assemble.patch @@ -0,0 +1,11 @@ +--- a/Assemble.c~ 2025-08-13 22:05:00.416132027 -0400 ++++ b/Assemble.c 2025-08-13 22:13:16.650837070 -0400 +@@ -1597,8 +1597,6 @@ + goto try_again; + goto out; + } +- /* just incase it was started but has no content */ +- ioctl(mdfd, STOP_ARRAY, NULL); + } + + if (content != &info) { diff --git a/6F9E3E9D4EDEBB11.asc b/6F9E3E9D4EDEBB11.asc new file mode 100644 index 0000000..7f7afe8 --- /dev/null +++ b/6F9E3E9D4EDEBB11.asc @@ -0,0 +1,72 @@ +pub rsa2048 2023-11-03 [SC] + EED84966493AEEAF4B466F696F9E3E9D4EDEBB11 +uid Mariusz Tkaczyk (First Key) +sub rsa2048 2023-11-03 [E] + F07BC7F109D51D72E3A4B8779CF5038718DB4BA7 +sub ed25519 2023-11-03 [S] + A2320B82F9D51E3BB0E2B3B201C8BB2357D15E24 + +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQENBGVE65YBCADQsm/xGlWh9vid1zLH4fGNA74rlvlE3X7Lbq8KLzufFOpV7+y0 +E0btNHs8ur0lt+3Emj3T9rh0lDC1ikYrEzQiwtGGSFoo30MRE6dqHyZPPzXVeI9c +8SAcz2LNwTPP3WQYv3b+ZxJrhOMyIqXD+upAZYRHVI02GpixJa8XavUtD5GglfIU +yRnF3KNkZRnYeJ1qRMe0WoaAl2W9IAM4rKWJq+xDNZCeGEX5zqAeHO/aNgA2m1Oo +2kDZz+GO0+W1zeMOiHJwW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R7IGL +Rmvpq3F+RBALah9F0YuTTU4Ixz1qBUvPCACFwmg8zxoqd2nf2t05vjtdeFbahRqu +3Gu5b5QqzCRB4zGBNVSX110SvDOtCJ0xNUAHU0Gh0o2meCREc9xg/qCujs7CKD5u +OzukbPpIZ++cXg5gPJ7+H1L20VrbFjiz/wdzV0iNBPfQ7mP+CeqjmpNyZKUqGF1t +xTHbJ99Ls2/hS1o1P1aktfOj2WBTND3Xx2oysczhqyGpaciDR30A2SEhcutjcPUl +mUPaTp7+nP/5+v8u2drlkyhzxCyQbcIwNQEaIWxQq5pKrq8HpQ8u/SUW6ERKZISV +Y6o0MdrugFPqAmerHvL2hCrMelqHCCVInJIXBL0SSCgHZyh9NTuo2OUQ +=PmkW +-----END PGP PUBLIC KEY BLOCK----- diff --git a/mdadm-2.5.2-static.patch b/mdadm-2.5.2-static.patch index 1eb335a..188b478 100644 --- a/mdadm-2.5.2-static.patch +++ b/mdadm-2.5.2-static.patch @@ -1,7 +1,7 @@ ---- mdadm-3.2.1/Makefile.static 2011-03-27 22:31:20.000000000 -0400 -+++ mdadm-3.2.1/Makefile 2011-03-28 10:16:55.277900184 -0400 -@@ -238,16 +238,16 @@ install : mdadm mdmon install-man instal - $(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon +--- mdadm-3.2.1/Makefile.static 2021-01-11 15:46:47.292126848 +0800 ++++ mdadm-3.2.1/Makefile 2021-01-11 15:46:10.720192519 +0800 +@@ -248,16 +248,16 @@ + install : install-bin install-man install-udev install-static : mdadm.static install-man - $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm diff --git a/mdadm-cron b/mdadm-cron deleted file mode 100644 index 4e05d68..0000000 --- a/mdadm-cron +++ /dev/null @@ -1,3 +0,0 @@ -# Run system wide raid-check once a week on Sunday at 1am by default -0 1 * * Sun root /usr/sbin/raid-check - diff --git a/mdadm-udev.patch b/mdadm-udev.patch new file mode 100644 index 0000000..a9d4d93 --- /dev/null +++ b/mdadm-udev.patch @@ -0,0 +1,26 @@ +--- mdadm/udev-md-raid-assembly.rules.orig 2023-01-06 16:37:03.780756100 +0800 ++++ mdadm/udev-md-raid-assembly.rules 2023-01-06 17:04:09.536159980 +0800 +@@ -5,6 +5,9 @@ + ENV{ANACONDA}=="?*", GOTO="md_inc_end" + # assemble md arrays + ++# Also don't process disks that are slated to be a multipath device ++ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="md_inc_end" ++ + SUBSYSTEM!="block", GOTO="md_inc_end" + + # skip non-initialized devices +@@ -33,6 +36,13 @@ + + LABEL="md_inc" + ++# Make sure we don't handle dm devices when some limits are set. ++# And linux_raid_member only be set when change/remove event happen. ++# So we don't need to consider add event here. ++KERNEL=="dm-*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="md_inc_end" ++KERNEL=="dm-*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="md_inc_end" ++KERNEL=="dm-*", ENV{DM_SUSPENDED}=="1", GOTO="md_inc_end" ++ + # Bare disks are ready when add event happens, the raid can be assembled. + ACTION=="change", KERNEL!="dm-*|md*", GOTO="md_inc_end" + diff --git a/mdadm.rules b/mdadm.rules deleted file mode 100644 index 682e9e8..0000000 --- a/mdadm.rules +++ /dev/null @@ -1,67 +0,0 @@ -# This file causes block devices with Linux RAID (mdadm) signatures to -# automatically cause mdadm to be run. -# See udev(8) for syntax - -# Don't process any events if anaconda is running as anaconda brings up -# raid devices manually -ENV{ANACONDA}=="?*", GOTO="md_end" - -# Also don't process disks that are slated to be a multipath device -ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="md_end" - -# We process add events on block devices (since they are ready as soon as -# they are added to the system), but we must process change events as well -# on any dm devices (like LUKS partitions or LVM logical volumes) and on -# md devices because both of these first get added, then get brought live -# and trigger a change event. The reason we don't process change events -# on bare hard disks is because if you stop all arrays on a disk, then -# run fdisk on the disk to change the partitions, when fdisk exits it -# triggers a change event, and we want to wait until all the fdisks on -# all member disks are done before we do anything. Unfortunately, we have -# no way of knowing that, so we just have to let those arrays be brought -# up manually after fdisk has been run on all of the disks. - -# First, process all add events (md and dm devices will not really do -# anything here, just regular disks, and this also won't get any imsm -# array members either) -SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="linux_raid_member", \ - IMPORT{program}="/sbin/mdadm -I $env{DEVNAME} --export $devnode --offroot $${DEVLINKS}" -SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="linux_raid_member", \ - ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer" -SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}=="?*", \ - ENV{ID_FS_TYPE}=="linux_raid_member", \ - RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" -SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}!="?*", \ - ENV{ID_FS_TYPE}=="linux_raid_member", \ - RUN+="/sbin/mdadm -If $name" - -# Next, check to make sure the BIOS raid stuff wasn't turned off via cmdline -IMPORT{cmdline}="noiswmd" -IMPORT{cmdline}="nodmraid" -ENV{noiswmd}=="?*", GOTO="md_imsm_inc_end" -ENV{nodmraid}=="?*", GOTO="md_imsm_inc_end" -SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="isw_raid_member", \ - RUN+="/sbin/mdadm -I $env{DEVNAME}" -SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}=="?*", \ - ENV{ID_FS_TYPE}=="isw_raid_member", \ - RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" -SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}!="?*", \ - ENV{ID_FS_TYPE}=="isw_raid_member", \ - RUN+="/sbin/mdadm -If $name" -LABEL="md_imsm_inc_end" - -# Next make sure that this isn't a dm device we should skip for some reason -ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_change_end" -ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_change_end" -ENV{DM_SUSPENDED}=="1", GOTO="dm_change_end" -KERNEL=="dm-*", SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="linux_raid_member", \ - ACTION=="change", RUN+="/sbin/mdadm -I $env{DEVNAME}" -LABEL="dm_change_end" - -# Finally catch any nested md raid arrays. If we brought up an md raid -# array that's part of another md raid array, it won't be ready to be used -# until the change event that occurs when it becomes live -KERNEL=="md*", SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="linux_raid_member", \ - ACTION=="change", RUN+="/sbin/mdadm -I $env{DEVNAME}" - -LABEL="md_end" diff --git a/mdadm.spec b/mdadm.spec index 537de7c..c04bb8c 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,93 +1,231 @@ +%bcond abrt %{undefined rhel} + Name: mdadm -Version: 4.1 -#define subversion rc2 -Release: 1%{?subversion:.%{subversion}}%{?dist} +Version: 4.3 +Release: 9%{?dist} Summary: The mdadm program controls Linux md devices (software RAID arrays) URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ -License: GPLv2+ +License: GPL-2.0-or-later -Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}%{?subversion:-%{subversion}}.tar.xz +Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.xz Source1: raid-check -Source2: mdadm.rules -Source3: mdadm-raid-check-sysconfig -Source4: mdadm-cron -Source5: mdmonitor.service -Source6: mdadm.conf -Source7: mdadm_event.conf +Source2: mdadm-raid-check-sysconfig +Source3: mdmonitor.service +Source4: mdadm.conf +Source5: mdadm_event.conf +Source6: raid-check.timer +Source7: raid-check.service +Source8: mdcheck +Source10: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.sign +Source11: https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys/6F9E3E9D4EDEBB11.asc -# Build without -Werror. From Debian. -Patch00: https://sources.debian.org/data/main/m/mdadm/4.1-2/debian/patches/debian-no-Werror.diff#/mdadm-4.1-no-Werror.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=2325906 +# see: https://github.com/md-raid-utilities/mdadm/pull/165 +# https://github.com/md-raid-utilities/mdadm/pull/160 +# https://github.com/md-raid-utilities/mdadm/pull/159 +# this is a reversion of the initial 'posix check' patch +# that causes all the trouble +Patch: 0001-Revert-mdadm-Follow-POSIX-Portable-Character-Set.patch +Patch: 0002-dont-stop-in-assemble.patch # Fedora customization patches -Patch97: mdadm-3.3-udev.patch -Patch98: mdadm-2.5.2-static.patch +Patch: mdadm-udev.patch +Patch: mdadm-2.5.2-static.patch -BuildRequires: systemd binutils-devel gcc -Requires: libreport-filesystem -Requires(post): systemd coreutils -Requires(preun): systemd -Requires(postun): systemd coreutils +BuildRequires: make +BuildRequires: systemd-rpm-macros +BuildRequires: binutils-devel +BuildRequires: gcc +BuildRequires: systemd-devel +BuildRequires: gnupg2 +BuildRequires: mandoc +%if %{with abrt} +Requires: libreport-filesystem +%endif +Requires(post): coreutils +Requires(postun): coreutils -%description + +%description The mdadm program is used to create, manage, and monitor Linux MD (software RAID) devices. As such, it provides similar functionality to the raidtools package. However, mdadm is a single program, and it can perform almost all functions without a configuration file, though a configuration file can be used to help with some common tasks. + %prep -%autosetup -p1 -n %{name}-%{version}%{?subversion:_%{subversion}} +# because the tarball is what is signed, not the compressed tarball +# keyring should be one from https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys +# which will vary depending on who did the release +%{_bindir}/xz -dcT0 %{SOURCE0} | %{gpgverify} --keyring='%{SOURCE11}' --signature='%{SOURCE10}' --data=- +%autosetup -p1 + %build -make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon +# CXFLAGS is NOT a typo, it's baked into the makefile, not to be confused with CXXFLAGS +%make_build CXFLAGS="%{optflags} -std=gnu17 -Wno-error=unterminated-string-initialization" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon raid6check raid6check.man + %install -make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=%{_sbindir} SYSTEMD_DIR=%{_unitdir} install install-systemd +%make_install MANDIR=%{_mandir} BINDIR=%{_sbindir} SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_prefix}/lib/udev/ install install-systemd install -Dp -m 755 %{SOURCE1} %{buildroot}%{_sbindir}/raid-check -install -Dp -m 644 %{SOURCE2} %{buildroot}%{_udevrulesdir}/65-md-incremental.rules -install -Dp -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/raid-check -install -Dp -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/cron.d/raid-check -mkdir -p -m 710 %{buildroot}/run/mdadm +install -Dp -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/raid-check +mkdir -p -m 710 %{buildroot}/run/%{name} +mkdir -p -m 755 %{buildroot}%{_datadir}/%{name} +install -Dp -m 755 %{SOURCE8} %{buildroot}%{_datadir}/%{name}/mdcheck # systemd -mkdir -p %{buildroot}%{_unitdir} -install -m644 %{SOURCE5} %{buildroot}%{_unitdir} +install -Dm644 %{SOURCE3} %{buildroot}%{_unitdir} +install -Dm644 %{SOURCE6} %{buildroot}%{_unitdir} +install -Dm644 %{SOURCE7} %{buildroot}%{_unitdir} # tmpfile -mkdir -p %{buildroot}%{_tmpfilesdir} -install -m 0644 %{SOURCE6} %{buildroot}%{_tmpfilesdir}/%{name}.conf +install -Dm 0644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/%{name}.conf mkdir -p %{buildroot}%{_localstatedir}/run/ install -d -m 0710 %{buildroot}/run/%{name}/ # abrt -mkdir -p %{buildroot}/etc/libreport/events.d -install -m644 %{SOURCE7} %{buildroot}/etc/libreport/events.d +%if %{with abrt} +install -Dm644 %{SOURCE5} %{buildroot}%{_sysconfdir}/libreport/events.d/%{name}_event.conf +%endif + +# raid6check +install -Dm755 raid6check %{buildroot}/%{_sbindir}/raid6check +install -Dm644 raid6check.man %{buildroot}/%{_mandir}/man8/raid6check.man %post -%systemd_post mdmonitor.service -/usr/bin/systemctl disable mdmonitor-takeover.service >/dev/null 2>&1 || : +%systemd_post mdmonitor.service raid-check.timer +# leftover from this service removal years ago (f18 era). +# we probably don't really need this anymore. +# https://bugzilla.redhat.com/show_bug.cgi?id=901651 +%{_bindir}/systemctl disable mdmonitor-takeover.service >/dev/null 2>&1 || : + %preun -%systemd_preun mdmonitor.service +%systemd_preun mdmonitor.service raid-check.timer + %postun %systemd_postun_with_restart mdmonitor.service + %files %license COPYING %doc mdadm.conf-example misc/* -%{_udevrulesdir}/* -%{_sbindir}/* -%{_unitdir}/* +%{_udevrulesdir}/*-md-* +%{_sbindir}/%{name} +%{_sbindir}/mdmon +%{_sbindir}/raid-check +%{_sbindir}/raid6check +%{_unitdir}/md* +%{_unitdir}/raid-check.* %{_mandir}/man*/md* -/usr/lib/systemd/system-shutdown/* -%config(noreplace) %{_sysconfdir}/cron.d/* -%config(noreplace) %{_sysconfdir}/sysconfig/* -%dir /run/%{name}/ +%{_mandir}/man8/raid6check* +%{_prefix}/lib/systemd/system-shutdown/mdadm.shutdown +%config(noreplace) %{_sysconfdir}/sysconfig/raid-check +%{_rundir}/%{name}/ %config(noreplace) %{_tmpfilesdir}/%{name}.conf -/etc/libreport/events.d/* +%if %{with abrt} +%{_sysconfdir}/libreport/events.d/mdadm_event.conf +%endif +%{_datadir}/%{name}/ + %changelog +* Thu Aug 14 2025 Xiao Ni - 4.3-9 +- Don't submit stop ioctl in assemble +- Resolves bz#2388480 + +* Thu Jul 24 2025 Fedora Release Engineering - 4.3-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Sun Apr 06 2025 Adam Williamson - 4.3-7 +- revert 'posix' name check to fix rhbz#2325906 + +* Thu Jan 23 2025 Jonathan Wright - 4.3-6 +- fix FTBFS on gcc15 rhbz#2340833 +- fix permissions on /usr/share/mdadm to be world-readable rhbz#2322402 + +* Fri Jan 17 2025 Fedora Release Engineering - 4.3-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Thu Jul 18 2024 Fedora Release Engineering - 4.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Wed May 08 2024 Jonathan Wright - 4.3-3 +- use URLs for signature and pub key +- build and install raid6check and man page rhbz#2264741 + +* Wed May 08 2024 Jonathan Wright - 4.3-2 +- add source signature verification +- change source URL to https + +* Wed May 08 2024 Jonathan Wright - 4.3-1 +- update to 4.3 rhbz#2267100 +- modernize spec + +* Wed May 08 2024 Jonathan Wright - 4.2-9 +- Fixes rhbz#2279743 +- Use more macros in %files definitions + +* Thu Jan 25 2024 Fedora Release Engineering - 4.2-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sun Jan 21 2024 Fedora Release Engineering - 4.2-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Thu Jul 20 2023 Fedora Release Engineering - 4.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Wed Apr 12 2023 Xiao Ni - 4.2-5 +- Update to latest upstream for rawhide(f39) and fix mdcheck service bug +- Resolves bz#2175540 + +* Mon Jan 30 2023 Xiao Ni - 4.2-4 +- Update to latest upstream for f38 +- Resolves bz#2163711 + +* Thu Jan 19 2023 Fedora Release Engineering - 4.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Thu Jul 21 2022 Fedora Release Engineering - 4.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Mon Mar 21 2022 Xiao Ni - 4.2-1 +- Update to mdadm-4.2 +- Resolves bz#2066150 + +* Thu Jan 20 2022 Fedora Release Engineering - 4.2-rc2.1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Mon Aug 09 2021 Xiao Ni - 4.2-rc2 +- Update to mdadm-4.2-rc2 +- Resolves bz#1988236 + +* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek - 4.1-8 +- Rebuilt for updated systemd-rpm-macros + See https://pagure.io/fesco/issue/2583. + +* Tue Jan 26 2021 Fedora Release Engineering - 4.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Tue Jul 28 2020 Fedora Release Engineering - 4.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Wed May 27 2020 Xiao Ni - 4.1-5 +- Don't enable raid-check.service to avoid raid check after every boot +- Resolves bz1838409 + +* Sun Mar 08 2020 Peter Robinson - 4.1-4 +- Fix install location of udev rules (rhbz 1809117) + +* Fri Feb 07 2020 Alejandro Domínguez Muñoz - 4.1-3 +- Replace raid-check cron job with systemd timer + +* Wed Jan 29 2020 Fedora Release Engineering - 4.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + * Mon Jan 13 2020 Peter Robinson 4.1-1 - Update to 4.1 GA - Spec cleanups and updates diff --git a/mdcheck b/mdcheck new file mode 100644 index 0000000..700c3e2 --- /dev/null +++ b/mdcheck @@ -0,0 +1,166 @@ +#!/bin/bash + +# Copyright (C) 2014-2017 Neil Brown +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that 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. +# +# Author: Neil Brown +# Email: + +# This script should be run periodically to automatically +# perform a 'check' on any md arrays. +# +# It supports a 'time budget' such that any incomplete 'check' +# will be checkpointed when that time has expired. +# A subsequent invocation can allow the 'check' to continue. +# +# Options are: +# --continue Don't start new checks, only continue old ones. +# --duration This is passed to "date --date=$duration" to find out +# when to finish +# +# To support '--continue', arrays are identified by UUID and the 'sync_completed' +# value is stored in /var/lib/mdcheck/$UUID + +# convert a /dev/md name into /sys/.../md equivalent +sysname() { + set `ls -lLd $1` + maj=${5%,} + min=$6 + readlink -f /sys/dev/block/$maj:$min +} + +args=$(getopt -o hcd: -l help,continue,duration: -n mdcheck -- "$@") +rv=$? +if [ $rv -ne 0 ]; then exit $rv; fi + +eval set -- $args + +cont= +endtime= +while [ " $1" != " --" ] +do + case $1 in + --help ) + echo >&2 'Usage: mdcheck [--continue] [--duration time-offset]' + echo >&2 ' time-offset must be understood by "date --date"' + exit 0 + ;; + --continue ) cont=yes ;; + --duration ) shift; dur=$1 + endtime=$(date --date "$dur" "+%s") + ;; + esac + shift +done +shift + +# We need a temp file occasionally... +tmp=/var/lib/mdcheck/.md-check-$$ +trap 'rm -f "$tmp"' 0 2 3 15 + + +# firstly, clean out really old state files +mkdir -p /var/lib/mdcheck +find /var/lib/mdcheck -name "MD_UUID*" -type f -mtime +180 -exec rm {} \; + +# Now look at each md device. +cnt=0 +for dev in /dev/md?* +do + [ -e "$dev" ] || continue + sys=`sysname $dev` + if [ ! -f "$sys/md/sync_action" ] + then # cannot check this array + continue + fi + if [ "`cat $sys/md/sync_action`" != 'idle' ] + then # This array is busy + continue + fi + + mdadm --detail --export "$dev" | grep '^MD_UUID=' > $tmp || continue + source $tmp + fl="/var/lib/mdcheck/MD_UUID_$MD_UUID" + if [ -z "$cont" ] + then + start=0 + logger -p daemon.info mdcheck start checking $dev + elif [ -z "$MD_UUID" -o ! -f "$fl" ] + then + # Nothing to continue here + continue + else + start=`cat "$fl"` + logger -p daemon.info mdcheck continue checking $dev from $start + fi + + cnt=$[cnt+1] + eval MD_${cnt}_fl=\$fl + eval MD_${cnt}_sys=\$sys + eval MD_${cnt}_dev=\$dev + echo $start > $fl + echo $start > $sys/md/sync_min + echo check > $sys/md/sync_action +done + +if [ -z "$endtime" ] +then + exit 0 +fi + +while [ `date +%s` -lt $endtime ] +do + any= + for i in `eval echo {1..$cnt}` + do + eval fl=\$MD_${i}_fl + eval sys=\$MD_${i}_sys + eval dev=\$MD_${i}_dev + + if [ -z "$fl" ]; then continue; fi + + if [ "`cat $sys/md/sync_action`" != 'check' ] + then + logger -p daemon.info mdcheck finished checking $dev + eval MD_${i}_fl= + rm -f $fl + continue; + fi + read a rest < $sys/md/sync_completed + echo $a > $fl + any=yes + done + if [ -z "$any" ]; then exit 0; fi + sleep 120 +done + +# We've waited, and there are still checks running. +# Time to stop them. +for i in `eval echo {1..$cnt}` +do + eval fl=\$MD_${i}_fl + eval sys=\$MD_${i}_sys + eval dev=\$MD_${i}_dev + + if [ -z "$fl" ]; then continue; fi + + if [ "`cat $sys/md/sync_action`" != 'check' ] + then + eval MD_${i}_fl= + rm -f $fl + continue; + fi + echo idle > $sys/md/sync_action + cat $sys/md/sync_min > $fl + logger -p daemon.info pause checking $dev at `cat $fl` +done diff --git a/mdmonitor.service b/mdmonitor.service index 2ddd1de..a2f53d9 100644 --- a/mdmonitor.service +++ b/mdmonitor.service @@ -6,7 +6,7 @@ ConditionPathExists=/etc/mdadm.conf Type=forking PIDFile=/run/mdadm/mdadm.pid EnvironmentFile=-/etc/sysconfig/mdmonitor -ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/run/mdadm/mdadm.pid +ExecStart=/sbin/mdadm --monitor --scan --syslog -f --pid-file=/run/mdadm/mdadm.pid [Install] WantedBy=multi-user.target diff --git a/raid-check.service b/raid-check.service new file mode 100644 index 0000000..f8ed5ac --- /dev/null +++ b/raid-check.service @@ -0,0 +1,6 @@ +[Unit] +Description=RAID setup health check + +[Service] +Type=oneshot +ExecStart=/usr/sbin/raid-check diff --git a/raid-check.timer b/raid-check.timer new file mode 100644 index 0000000..c33bc24 --- /dev/null +++ b/raid-check.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Weekly RAID setup health check + +[Timer] +OnCalendar=Sun *-*-* 01:00:00 +Persistent=true +AccuracySec=24h + +[Install] +WantedBy=timers.target diff --git a/sources b/sources index 8f50f97..1c4b506 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ -SHA512 (mdadm-4.1.tar.xz) = 0859c5d3e786345d93ff2c3b291ca8866ba60f1375479e5b4d343124f6824140a8268d42b8ae603b069edba761aa30aaf20d49e9ec54dfcbad34bad3bea0e433 +SHA512 (mdadm-4.3.tar.xz) = e44977f2f80d2471cb313803a60c92dafe8282ac06bbbfd41ae90ca493c64a3da94db924538788d045fd7f0667333912dabedb0b070f9abf5c0540b32e0fa08f +SHA512 (mdadm-4.3.tar.sign) = c0ae042399974c360ffbf4f15928e59591eb88f97faac1d7892066fefb8f8c525fe0948a4fd6ddd3781d0b27d8891e1bd2e0cd9e6a2dbf17b9f8d8c4879dc6b1