From e778d07c4cc68806732e764cc7a2a84dd2e07928 Mon Sep 17 00:00:00 2001 From: Xiao Ni Date: Wed, 30 Apr 2025 06:54:31 -0400 Subject: [PATCH] Update to mdadm 4.4 Resolves: RHEL-86676, RHEL-72803, RHEL-88793, RHEL-88791 Signed-off-by: Xiao Ni --- .gitignore | 1 + 0001-Coverity-fixes-resources-leaks.patch | 91 + ...rdcoded-checkpoint-interval-checking.patch | 64 - 0002-Incremental-Document-workaround.patch | 64 + 0002-monitor-refactor-checkpoint-update.patch | 96 - ...r-intel-Fix-first-checkpoint-restart.patch | 47 - ...-functions-for-writing-md-memb-state.patch | 164 ++ ...e-update_tail-assign-to-Grow_reshape.patch | 61 - 0004-Incremental-Simplify-remove-logic.patch | 259 +++ ...-understanding-output-section-in-man.patch | 56 - ...-checkpatch.conf-ignore-NEW_TYPEDEFS.patch | 24 + ...-add_disk_to_super-fix-resource-leak.patch | 48 - 0006-mdadm-add-MAINTAINERS-file.patch | 55 + 0007-mdadm-signal_s-init-variables.patch | 35 - 0007-mdadm.man-Remove-external-bitmap.patch | 127 ++ ...ile-before-check-in-check_one_sharer.patch | 48 - 0008-Remove-freeze-reshape-logic.patch | 223 ++ 0009-Detail-Export-reshape-status.patch | 33 + ...emove-dead-condition-in-Grow_reshape.patch | 34 - ...-not-start-reshape-before-switchroot.patch | 217 ++ ...before-passing-to-get_dev_size-in-ad.patch | 34 - ...er-error-messages-for-broken-reshape.patch | 48 + ...efactor-md-device-name-check-in-main.patch | 66 - 0012-Refactor-continue_via_systemd.patch | 117 + ...test-run-tests-on-system-level-mdadm.patch | 138 -- ...tor-Allow-no-PID-in-check_one_sharer.patch | 43 - ...6check-add-xmalloc.h-to-raid6check.c.patch | 32 + ...path-to-env-PATH-when-call-system-mo.patch | 56 + ...-respect-IMSM_DEVNAME_AS_SERIAL-flag.patch | 47 - 0015-mdadm-remove-TODO.patch | 236 -- ...perties-of-MD-devices-after-switch_r.patch | 40 + 0016-mdadm-fix-grow-with-add-for-linear.patch | 36 + 0016-mdadm-remove-makedist.patch | 119 - 0017-mdadm-remove-mdadm.spec.patch | 69 - ...isable-legacy-option-ROM-scan-on-UEF.patch | 41 + 0018-mdadm-remove-mkinitramfs-stuff.patch | 209 -- ...ent-crash-when-handling-DDF-metadata.patch | 61 + 0019-mdadm-move-documentation-to-folder.patch | 1044 --------- ...ze-DDF-header-search-for-widely-used.patch | 297 +++ 0020-Detail-remove-duplicated-code.patch | 75 - ...map.h-clear-__KERNEL__-based-headers.patch | 200 ++ 0021-bitmap.h-Minor-fixes.patch | 206 ++ ...ions-for-spare-criteria-verification.patch | 286 --- ...-Move-release-steps-to-documentation.patch | 20 + ...adm-drop-get_required_spare_criteria.patch | 357 --- ...ge-fix-check-after-dereference-issue.patch | 64 - 0023-Rework-MAINTAINERS-file.patch | 102 + ...Manage-implement-manage_add_external.patch | 184 -- ...etadata-corruption-when-managing-new.patch | 122 + 0025-Regression-fix-156.patch | 217 ++ ...-introduce-sysfs_get_container_devnm.patch | 138 -- ...m.h-Introduce-custom-device-policies.patch | 115 - ...tra-flags-when-initializing-metadata.patch | 72 + 0027-imsm-Fix-RAID0-to-RAID10-migration.patch | 74 + ...d_add-device-policies-implementation.patch | 144 -- ...o-be-created-with-v0.90-metadata-161.patch | 193 ++ 0028-Create-Use-device-policies.patch | 124 - ...vice-policies-in-manage_add_external.patch | 60 - 0029-Update-tests.yml.patch | 45 + ...itor-Incremental-use-device-policies.patch | 142 -- 0030-Update-tests.yml.patch | 26 + 0031-Update-tests.yml.patch | 26 + ...d_add_device_policies-implementation.patch | 187 -- 0032-Update-tests.yml.patch | 29 + ...dadm-drop-get_disk_controller_domain.patch | 75 - ...Avoid-to-take-spare-without-defined-.patch | 42 - 0033-This-is-a-test-for-CI-do-not-merge.patch | 22 + 0034-Update-README.md.patch | 24 + 0034-mdadm-remove-inventory-file.patch | 307 --- ...dadm-Remove-klibc-and-uclibc-support.patch | 183 ++ ...not-require-libudev.h-if-DNO_LIBUDEV.patch | 31 - 0036-mdadm-include-asm-byteorder.h.patch | 96 + ...ts.h-include-for-NAME_MAX-definition.patch | 29 - 0037-mdadm-set-swapuuid-in-all-handlers.patch | 59 - 0037-mdadm-use-kernel-raid-headers.patch | 346 +++ 0038-mdadm-Fix-native-detail-export.patch | 247 -- ...-vers-parameter-from-sysfs_set_array.patch | 87 - 0040-mdadm-fix-grow-segfault-for-IMSM.patch | 55 - 0041-Remove-all-if-zeros-pt.2.patch | 85 - ...-mdadm-Move-pr_vrb-define-to-mdadm.h.patch | 44 - ...ing-Opal-NVMe-encryption-information.patch | 463 ---- ...-reading-SATA-encryption-information.patch | 459 ---- ...Add-key-ENCRYPTION_NO_VERIFY-to-conf.patch | 163 -- ...sm-print-disk-encryption-information.patch | 217 -- ...ive-encryption-policy-implementation.patch | 114 - 0048-mdadm-add-CHANGELOG.md.patch | 2010 ----------------- 0049-mdadm-Add-MAINTAINERS.md.patch | 66 - 0050-mdadm-Add-README.md.patch | 106 - 0051-Create.c-fix-uclibc-build.patch | 41 - ...struct-context-for-external-reshapes.patch | 309 --- ...-use-struct-context-in-reshape_super.patch | 296 --- ...imsm-add-support-for-literal-RAID-10.patch | 184 -- 0055-imsm-refactor-RAID-level-handling.patch | 345 --- 0056-imsm-bump-minimal-version.patch | 180 -- 0057-imsm-define-RAID_10-attribute.patch | 67 - ...-imsm-simplify-imsm_check_attributes.patch | 153 -- ...port-RAID-10-with-more-than-4-drives.patch | 168 -- 0060-tests-01r5fail-enhance.patch | 41 - 0061-tests-01r5integ.broken.patch | 32 - ...s-01raid6integ.broken-can-be-removed.patch | 31 - 0063-Makefile-Move-pie-to-LDFLAGS.patch | 38 - 0064-tests-23rdev-lifetime-fix-a-typo.patch | 30 - ...ge-devnm-to-const-in-mdmon-functions.patch | 55 - ...-mdmon-when-it-is-stared-via-systemd.patch | 121 - ...adm-Change-main-repository-to-Github.patch | 193 -- ...dadm-Fix-compilation-for-32-bit-arch.patch | 62 - ...king-of-return-status-on-fstat-calls.patch | 267 --- 0071-super-intel-fix-typo-in-error-msg.patch | 28 - 0072-mdadm-super-intel-remove-dead-code.patch | 45 - 0073-mdadm-super-intel-fix-bad-shift.patch | 55 - 0074-mdadm-deprecate-bitmap-custom-file.patch | 438 ---- 0075-Makefile-fix-make-s-detection.patch | 31 - ...ge-some-error-messages-to-info-level.patch | 81 - 0077-mdadm-Start-update_opt-from-0.patch | 40 - ...on-t-control-reshape-speed-in-daemon.patch | 49 - 0079-mdadm-tests-test-enhance.patch | 119 - ...-don-t-fail-when-systemd-reports-err.patch | 31 - 0081-mdadm-tests-names_template-enhance.patch | 109 - 0082-mdadm-tests-03assem-incr-enhance.patch | 67 - 0083-mdadm-tests-03r0assem-enhance.patch | 38 - ...-mdadm-tests-remove-03r5assem-failed.patch | 35 - 0085-mdadm-tests-03r5assemV1.patch | 52 - 0086-mdadm-tests-remove-04r5swap.broken.patch | 30 - ...-tests-04update-metadata-skip-linear.patch | 116 - 0088-mdadm-tests-05r5-internalbitmap.patch | 68 - 0089-mdadm-tests-06name-enhance.patch | 38 - 0090-mdadm-tests-07autoassemble.patch | 108 - ...s-07autodetect.broken-can-be-removed.patch | 28 - 0092-mdadm-tests-07changelevelintr.patch | 73 - 0093-mdadm-tests-disable-selinux.patch | 68 - ...tform-intel-buffer-overflow-detected.patch | 44 - 0095-mdadm-tests-bitmap-cases-enhance.patch | 279 --- 0096-mdadm-tests-04update-uuid.patch | 39 - 0097-mdadm-tests-05r1-re-add-nosuper.patch | 30 - 0098-mdadm-tests-remove-strace-test.patch | 44 - ...e-basename-if-GLIBC-is-not-avialable.patch | 37 - ...olume-autolayout-with-IMSM_NO_PLATFO.patch | 79 - ...eesize-required-to-volume-autolayout.patch | 50 - ...ace-condition-in-wait_for_zero_forks.patch | 86 - ...HLD-processes-before-starting-childr.patch | 37 - 0104-test-pass-flags-to-services.patch | 137 -- ...-connection-failure-when-mdmon-runs-.patch | 68 - 0106-Makefile-Do-not-call-gcc-directly.patch | 50 - ...ts-judge-foreign-array-in-test-cases.patch | 103 - ...-socket-connection-failure-when-mdmo.patch | 58 - ...mdadm-Assemble.c-fix-coverity-issues.patch | 149 -- ...-connection-failure-when-mdmon-runs-.patch | 118 - ...c-Fix-memory-leak-in-load_containers.patch | 28 - 0114-mdadm-Build.c-fix-coverity-issues.patch | 40 - 0115-mdadm-Create.c-fix-coverity-issues.patch | 45 - ...dadm-super-ddf.c-fix-coverity-issues.patch | 473 ---- ...tests-add-some-APIs-in-func.sh-to-su.patch | 102 - ...tests-adjust-test-cases-to-support-m.patch | 81 - ...-mapfile.c-Fix-STRING_OVERFLOW-issue.patch | 40 - 0120-mdadm-Manage.c-fix-coverity-issues.patch | 484 ---- 0121-Manage-fix-is_remove_safe.patch | 29 - ...sm-add-indent-for-encryption-details.patch | 28 - ...-mdadm-Monitor.c-fix-coverity-issues.patch | 67 - 0124-mdadm-Query.c-fix-coverity-issues.patch | 42 - 0125-mdadm-lib.c-fix-coverity-issues.patch | 43 - ...-allow-leading-dot-in-MD-device-name.patch | 158 -- ...tail-fix-detail-export-for-uuid_zero.patch | 36 - ...ryption-Fix-ata-passthrough12-verify.patch | 84 - ...ine-for-char-array-in-examine_super0.patch | 46 - 0131-Makefile-add-more-compiler-flags.patch | 61 - ...work-mdstat-external-arrays-handling.patch | 575 ----- ...dadm-managemon.c-fix-coverity-issues.patch | 56 - 0135-mdadm-msg.c-fix-coverity-issues.patch | 40 - 0136-imsm-refactor-chunk-size-print.patch | 150 -- ...ow-fix-coverity-issue-CHECKED_RETURN.patch | 109 - ...row-fix-coverity-issue-RESOURCE_LEAK.patch | 166 -- ...w-fix-coverity-issue-STRING_OVERFLOW.patch | 29 - ...dadm-Incremental-fix-coverity-issues.patch | 87 - ...on-fix-coverity-issue-CHECKED_RETURN.patch | 46 - ...mon-fix-coverity-issue-RESOURCE_LEAK.patch | 49 - ...en-fix-coverity-issue-CHECKED_RETURN.patch | 33 - ...n-fix-coverity-issue-STRING_OVERFLOW.patch | 29 - ...at-fix-coverity-issue-CHECKED_RETURN.patch | 46 - ...-coverity-issue-CHECKED_RETURN-and-E.patch | 56 - ...r1-fix-coverity-issue-CHECKED_RETURN.patch | 67 - ...m-super1-fix-coverity-issue-DEADCODE.patch | 29 - ...-fix-coverity-issue-EVALUATION_ORDER.patch | 46 - ...er1-fix-coverity-issue-RESOURCE_LEAK.patch | 41 - ...ix-check_return-issue-in-Write_rules.patch | 66 - ...c-Fix-check_return-issue-in-load_gpt.patch | 40 - 0153-super-intel-fix-compilation-error.patch | 46 - ...uper-intel-add-define-for-migr_state.patch | 92 - ...et-only-component_size-for-size-grow.patch | 52 - 0157-mdstat-fix-list-detach-issues.patch | 43 - 0158-md.4-replace-wrong-word.patch | 28 - 0159-mdadm-util.c-fix-coverity-issues.patch | 134 -- 0160-mdadm-sysfs.c-fix-coverity-issues.patch | 56 - ...-add-read-OROM-form-ACPI-UEFI-tables.patch | 405 ---- ...sm-get-bus-from-VMD-driver-directory.patch | 146 -- ...-intel-refactor-path_attached_to_hba.patch | 129 -- ...ange-displaying-of-devices-in-detail.patch | 44 - ...ing-and-refactor-add_to_super_imsm-c.patch | 196 -- ...M_OROM_CAPABILITIES_TPV-to-nvme-orom.patch | 192 -- ...umber-limit-in-md-device-name-to-102.patch | 33 - 0168-imsm-save-checkpoint-prior-to-exit.patch | 44 - ...xamine.c-Fix-memory-leaks-in-Examine.patch | 116 - ...heckpatch-warnings-for-function-args.patch | 39 - ...support-devnode-in-IncrementalRemove.patch | 151 -- 0172-Detail.c-Fix-divide_by_zero-issue.patch | 75 - ...Add-compilation-process-to-README.md.patch | 81 - ...date-new-level-when-starting-reshape.patch | 53 - ...e-reshape_progress-to-need_back-afte.patch | 57 - ...-open-raid-when-running-grow-continu.patch | 38 - ...-a-while-after-removing-disk-in-impo.patch | 39 - ...mdadm-tests-wait-until-level-changes.patch | 33 - 0179-mdadm-tests-07changelevels-fix.patch | 179 -- ...m-tests-Remove-07reshape5intr.broken.patch | 68 - 0181-mdadm-tests-07testreshape5-fix.patch | 48 - ...-tests-remove-09imsm-assemble.broken.patch | 29 - 0183-mdadm-Manage-record-errno.patch | 56 - 0184-Remove-INSTALL-and-dev-null.patch | 43 - ...Incremental-Rename-IncrementalRemove.patch | 67 - ...add-function-for-writing-to-sysfs-fd.patch | 315 --- ...r-Fix-startup-with-missing-directory.patch | 61 - 0189-mdadm-add-xmalloc.h.patch | 590 ----- ...n-update-refference-to-raid5-ppl.rst.patch | 43 - 0191-util-fix-sys_hot_remove_disk.patch | 30 - 0192-Rename-Monitor.c-to-mdmonitor.c.patch | 35 - ...ntel-move-scsi_get_serial-from-sg_io.patch | 178 -- ...r-Abandon-custom-configuration-files.patch | 120 - ...aborate-more-about-mdmonitor.service.patch | 131 -- 0196-mdadm-Add-mdadm_status.h.patch | 85 - 0197-mdadm.conf.man-Explain-udev-rule.patch | 67 - 0198-mdadm.man-Add-udev-rules-flag.patch | 37 - ...l-use-only-dev-directory-in-open_dev.patch | 40 - ...ar-superblock-if-adding-new-device-f.patch | 47 - ...-new_level-interface-rather-than-ker.patch | 31 - 0202-platform-intel-fix-buffer-overflow.patch | 48 - ...fix-tpv-drvies-check-in-add_to_super.patch | 39 - mdadm-2.5.2-static.patch | 22 +- mdadm-fix-building-errors.patch | 64 + mdadm.spec | 246 +- sources | 2 +- 238 files changed, 4105 insertions(+), 23371 deletions(-) create mode 100644 0001-Coverity-fixes-resources-leaks.patch delete mode 100644 0001-Remove-hardcoded-checkpoint-interval-checking.patch create mode 100644 0002-Incremental-Document-workaround.patch delete mode 100644 0002-monitor-refactor-checkpoint-update.patch delete mode 100644 0003-Super-intel-Fix-first-checkpoint-restart.patch create mode 100644 0003-sysfs-functions-for-writing-md-memb-state.patch delete mode 100644 0004-Grow-Move-update_tail-assign-to-Grow_reshape.patch create mode 100644 0004-Incremental-Simplify-remove-logic.patch delete mode 100644 0005-Add-understanding-output-section-in-man.patch create mode 100644 0005-checkpatch.conf-ignore-NEW_TYPEDEFS.patch delete mode 100644 0006-Create-add_disk_to_super-fix-resource-leak.patch create mode 100644 0006-mdadm-add-MAINTAINERS-file.patch delete mode 100644 0007-mdadm-signal_s-init-variables.patch create mode 100644 0007-mdadm.man-Remove-external-bitmap.patch delete mode 100644 0008-Monitor-open-file-before-check-in-check_one_sharer.patch create mode 100644 0008-Remove-freeze-reshape-logic.patch create mode 100644 0009-Detail-Export-reshape-status.patch delete mode 100644 0009-Grow-remove-dead-condition-in-Grow_reshape.patch create mode 100644 0010-mdadm-Do-not-start-reshape-before-switchroot.patch delete mode 100644 0010-super1-check-fd-before-passing-to-get_dev_size-in-ad.patch create mode 100644 0011-Better-error-messages-for-broken-reshape.patch delete mode 100644 0011-mdmon-refactor-md-device-name-check-in-main.patch create mode 100644 0012-Refactor-continue_via_systemd.patch delete mode 100644 0012-test-run-tests-on-system-level-mdadm.patch delete mode 100644 0013-Monitor-Allow-no-PID-in-check_one_sharer.patch create mode 100644 0013-mdadm-raid6check-add-xmalloc.h-to-raid6check.c.patch create mode 100644 0014-mdopen-add-sbin-path-to-env-PATH-when-call-system-mo.patch delete mode 100644 0014-super-intel-respect-IMSM_DEVNAME_AS_SERIAL-flag.patch delete mode 100644 0015-mdadm-remove-TODO.patch create mode 100644 0015-udev-persist-properties-of-MD-devices-after-switch_r.patch create mode 100644 0016-mdadm-fix-grow-with-add-for-linear.patch delete mode 100644 0016-mdadm-remove-makedist.patch delete mode 100644 0017-mdadm-remove-mdadm.spec.patch create mode 100644 0017-platform-intel-Disable-legacy-option-ROM-scan-on-UEF.patch delete mode 100644 0018-mdadm-remove-mkinitramfs-stuff.patch create mode 100644 0018-super-ddf-Prevent-crash-when-handling-DDF-metadata.patch delete mode 100644 0019-mdadm-move-documentation-to-folder.patch create mode 100644 0019-super-ddf-optimize-DDF-header-search-for-widely-used.patch delete mode 100644 0020-Detail-remove-duplicated-code.patch create mode 100644 0020-bitmap.h-clear-__KERNEL__-based-headers.patch create mode 100644 0021-bitmap.h-Minor-fixes.patch delete mode 100644 0021-mdadm-Add-functions-for-spare-criteria-verification.patch create mode 100644 0022-Move-release-steps-to-documentation.patch delete mode 100644 0022-mdadm-drop-get_required_spare_criteria.patch delete mode 100644 0023-Manage-fix-check-after-dereference-issue.patch create mode 100644 0023-Rework-MAINTAINERS-file.patch delete mode 100644 0024-Manage-implement-manage_add_external.patch create mode 100644 0024-mdmon-imsm-fix-metadata-corruption-when-managing-new.patch create mode 100644 0025-Regression-fix-156.patch delete mode 100644 0025-mdadm-introduce-sysfs_get_container_devnm.patch delete mode 100644 0026-mdadm.h-Introduce-custom-device-policies.patch create mode 100644 0026-super1-Clear-extra-flags-when-initializing-metadata.patch create mode 100644 0027-imsm-Fix-RAID0-to-RAID10-migration.patch delete mode 100644 0027-mdadm-test_and_add-device-policies-implementation.patch create mode 100644 0028-Allow-RAID0-to-be-created-with-v0.90-metadata-161.patch delete mode 100644 0028-Create-Use-device-policies.patch delete mode 100644 0029-Manage-check-device-policies-in-manage_add_external.patch create mode 100644 0029-Update-tests.yml.patch delete mode 100644 0030-Monitor-Incremental-use-device-policies.patch create mode 100644 0030-Update-tests.yml.patch create mode 100644 0031-Update-tests.yml.patch delete mode 100644 0031-imsm-test_and_add_device_policies-implementation.patch create mode 100644 0032-Update-tests.yml.patch delete mode 100644 0032-mdadm-drop-get_disk_controller_domain.patch delete mode 100644 0033-Revert-policy.c-Avoid-to-take-spare-without-defined-.patch create mode 100644 0033-This-is-a-test-for-CI-do-not-merge.patch create mode 100644 0034-Update-README.md.patch delete mode 100644 0034-mdadm-remove-inventory-file.patch create mode 100644 0035-mdadm-Remove-klibc-and-uclibc-support.patch delete mode 100644 0035-udev.c-Do-not-require-libudev.h-if-DNO_LIBUDEV.patch create mode 100644 0036-mdadm-include-asm-byteorder.h.patch delete mode 100644 0036-util.c-add-limits.h-include-for-NAME_MAX-definition.patch delete mode 100644 0037-mdadm-set-swapuuid-in-all-handlers.patch create mode 100644 0037-mdadm-use-kernel-raid-headers.patch delete mode 100644 0038-mdadm-Fix-native-detail-export.patch delete mode 100644 0039-sysfs-remove-vers-parameter-from-sysfs_set_array.patch delete mode 100644 0040-mdadm-fix-grow-segfault-for-IMSM.patch delete mode 100644 0041-Remove-all-if-zeros-pt.2.patch delete mode 100644 0042-mdadm-Move-pr_vrb-define-to-mdadm.h.patch delete mode 100644 0043-Add-reading-Opal-NVMe-encryption-information.patch delete mode 100644 0044-Add-reading-SATA-encryption-information.patch delete mode 100644 0045-Add-key-ENCRYPTION_NO_VERIFY-to-conf.patch delete mode 100644 0046-imsm-print-disk-encryption-information.patch delete mode 100644 0047-imsm-drive-encryption-policy-implementation.patch delete mode 100644 0048-mdadm-add-CHANGELOG.md.patch delete mode 100644 0049-mdadm-Add-MAINTAINERS.md.patch delete mode 100644 0050-mdadm-Add-README.md.patch delete mode 100644 0051-Create.c-fix-uclibc-build.patch delete mode 100644 0052-mdadm-pass-struct-context-for-external-reshapes.patch delete mode 100644 0053-mdadm-use-struct-context-in-reshape_super.patch delete mode 100644 0054-imsm-add-support-for-literal-RAID-10.patch delete mode 100644 0055-imsm-refactor-RAID-level-handling.patch delete mode 100644 0056-imsm-bump-minimal-version.patch delete mode 100644 0057-imsm-define-RAID_10-attribute.patch delete mode 100644 0058-imsm-simplify-imsm_check_attributes.patch delete mode 100644 0059-imsm-support-RAID-10-with-more-than-4-drives.patch delete mode 100644 0060-tests-01r5fail-enhance.patch delete mode 100644 0061-tests-01r5integ.broken.patch delete mode 100644 0062-tests-01raid6integ.broken-can-be-removed.patch delete mode 100644 0063-Makefile-Move-pie-to-LDFLAGS.patch delete mode 100644 0064-tests-23rdev-lifetime-fix-a-typo.patch delete mode 100644 0065-util.c-change-devnm-to-const-in-mdmon-functions.patch delete mode 100644 0066-Wait-for-mdmon-when-it-is-stared-via-systemd.patch delete mode 100644 0067-mdadm-Change-main-repository-to-Github.patch delete mode 100644 0069-mdadm-Fix-compilation-for-32-bit-arch.patch delete mode 100644 0070-add-checking-of-return-status-on-fstat-calls.patch delete mode 100644 0071-super-intel-fix-typo-in-error-msg.patch delete mode 100644 0072-mdadm-super-intel-remove-dead-code.patch delete mode 100644 0073-mdadm-super-intel-fix-bad-shift.patch delete mode 100644 0074-mdadm-deprecate-bitmap-custom-file.patch delete mode 100644 0075-Makefile-fix-make-s-detection.patch delete mode 100644 0076-Change-some-error-messages-to-info-level.patch delete mode 100644 0077-mdadm-Start-update_opt-from-0.patch delete mode 100644 0078-Don-t-control-reshape-speed-in-daemon.patch delete mode 100644 0079-mdadm-tests-test-enhance.patch delete mode 100644 0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch delete mode 100644 0081-mdadm-tests-names_template-enhance.patch delete mode 100644 0082-mdadm-tests-03assem-incr-enhance.patch delete mode 100644 0083-mdadm-tests-03r0assem-enhance.patch delete mode 100644 0084-mdadm-tests-remove-03r5assem-failed.patch delete mode 100644 0085-mdadm-tests-03r5assemV1.patch delete mode 100644 0086-mdadm-tests-remove-04r5swap.broken.patch delete mode 100644 0087-tests-04update-metadata-skip-linear.patch delete mode 100644 0088-mdadm-tests-05r5-internalbitmap.patch delete mode 100644 0089-mdadm-tests-06name-enhance.patch delete mode 100644 0090-mdadm-tests-07autoassemble.patch delete mode 100644 0091-mdadm-tests-07autodetect.broken-can-be-removed.patch delete mode 100644 0092-mdadm-tests-07changelevelintr.patch delete mode 100644 0093-mdadm-tests-disable-selinux.patch delete mode 100644 0094-mdadm-platform-intel-buffer-overflow-detected.patch delete mode 100644 0095-mdadm-tests-bitmap-cases-enhance.patch delete mode 100644 0096-mdadm-tests-04update-uuid.patch delete mode 100644 0097-mdadm-tests-05r1-re-add-nosuper.patch delete mode 100644 0098-mdadm-tests-remove-strace-test.patch delete mode 100644 0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch delete mode 100644 0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch delete mode 100644 0101-imsm-make-freesize-required-to-volume-autolayout.patch delete mode 100644 0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch delete mode 100644 0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch delete mode 100644 0104-test-pass-flags-to-services.patch delete mode 100644 0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch delete mode 100644 0106-Makefile-Do-not-call-gcc-directly.patch delete mode 100644 0107-mdadm-tests-judge-foreign-array-in-test-cases.patch delete mode 100644 0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch delete mode 100644 0109-mdadm-Assemble.c-fix-coverity-issues.patch delete mode 100644 0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch delete mode 100644 0113-config.c-Fix-memory-leak-in-load_containers.patch delete mode 100644 0114-mdadm-Build.c-fix-coverity-issues.patch delete mode 100644 0115-mdadm-Create.c-fix-coverity-issues.patch delete mode 100644 0116-mdadm-super-ddf.c-fix-coverity-issues.patch delete mode 100644 0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch delete mode 100644 0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch delete mode 100644 0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch delete mode 100644 0120-mdadm-Manage.c-fix-coverity-issues.patch delete mode 100644 0121-Manage-fix-is_remove_safe.patch delete mode 100644 0122-imsm-add-indent-for-encryption-details.patch delete mode 100644 0123-mdadm-Monitor.c-fix-coverity-issues.patch delete mode 100644 0124-mdadm-Query.c-fix-coverity-issues.patch delete mode 100644 0125-mdadm-lib.c-fix-coverity-issues.patch delete mode 100644 0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch delete mode 100644 0128-Detail-fix-detail-export-for-uuid_zero.patch delete mode 100644 0129-drive_encryption-Fix-ata-passthrough12-verify.patch delete mode 100644 0130-super0-use-define-for-char-array-in-examine_super0.patch delete mode 100644 0131-Makefile-add-more-compiler-flags.patch delete mode 100644 0133-mdstat-Rework-mdstat-external-arrays-handling.patch delete mode 100644 0134-mdadm-managemon.c-fix-coverity-issues.patch delete mode 100644 0135-mdadm-msg.c-fix-coverity-issues.patch delete mode 100644 0136-imsm-refactor-chunk-size-print.patch delete mode 100644 0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch delete mode 100644 0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch delete mode 100644 0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch delete mode 100644 0140-mdadm-Incremental-fix-coverity-issues.patch delete mode 100644 0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch delete mode 100644 0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch delete mode 100644 0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch delete mode 100644 0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch delete mode 100644 0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch delete mode 100644 0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch delete mode 100644 0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch delete mode 100644 0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch delete mode 100644 0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch delete mode 100644 0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch delete mode 100644 0151-policy.c-Fix-check_return-issue-in-Write_rules.patch delete mode 100644 0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch delete mode 100644 0153-super-intel-fix-compilation-error.patch delete mode 100644 0154-super-intel-add-define-for-migr_state.patch delete mode 100644 0156-Grow_reshape-set-only-component_size-for-size-grow.patch delete mode 100644 0157-mdstat-fix-list-detach-issues.patch delete mode 100644 0158-md.4-replace-wrong-word.patch delete mode 100644 0159-mdadm-util.c-fix-coverity-issues.patch delete mode 100644 0160-mdadm-sysfs.c-fix-coverity-issues.patch delete mode 100644 0161-imsm-add-read-OROM-form-ACPI-UEFI-tables.patch delete mode 100644 0162-imsm-get-bus-from-VMD-driver-directory.patch delete mode 100644 0163-platform-intel-refactor-path_attached_to_hba.patch delete mode 100644 0164-mdadm-Change-displaying-of-devices-in-detail.patch delete mode 100644 0165-imsm-Remove-warning-and-refactor-add_to_super_imsm-c.patch delete mode 100644 0166-imsm-add-IMSM_OROM_CAPABILITIES_TPV-to-nvme-orom.patch delete mode 100644 0167-mdadm-Increase-number-limit-in-md-device-name-to-102.patch delete mode 100644 0168-imsm-save-checkpoint-prior-to-exit.patch delete mode 100644 0169-Examine.c-Fix-memory-leaks-in-Examine.patch delete mode 100644 0170-dlink.h-Fix-checkpatch-warnings-for-function-args.patch delete mode 100644 0171-Incremental-support-devnode-in-IncrementalRemove.patch delete mode 100644 0172-Detail.c-Fix-divide_by_zero-issue.patch delete mode 100644 0173-mdadm-Add-compilation-process-to-README.md.patch delete mode 100644 0174-mdadm-Grow-Update-new-level-when-starting-reshape.patch delete mode 100644 0175-mdadm-Grow-Update-reshape_progress-to-need_back-afte.patch delete mode 100644 0176-mdadm-Grow-Can-t-open-raid-when-running-grow-continu.patch delete mode 100644 0177-mdadm-Grow-sleep-a-while-after-removing-disk-in-impo.patch delete mode 100644 0178-mdadm-tests-wait-until-level-changes.patch delete mode 100644 0179-mdadm-tests-07changelevels-fix.patch delete mode 100644 0180-mdadm-tests-Remove-07reshape5intr.broken.patch delete mode 100644 0181-mdadm-tests-07testreshape5-fix.patch delete mode 100644 0182-mdadm-tests-remove-09imsm-assemble.broken.patch delete mode 100644 0183-mdadm-Manage-record-errno.patch delete mode 100644 0184-Remove-INSTALL-and-dev-null.patch delete mode 100644 0186-Incremental-Rename-IncrementalRemove.patch delete mode 100644 0187-sysfs-add-function-for-writing-to-sysfs-fd.patch delete mode 100644 0188-Mdmonitor-Fix-startup-with-missing-directory.patch delete mode 100644 0189-mdadm-add-xmalloc.h.patch delete mode 100644 0190-md.man-update-refference-to-raid5-ppl.rst.patch delete mode 100644 0191-util-fix-sys_hot_remove_disk.patch delete mode 100644 0192-Rename-Monitor.c-to-mdmonitor.c.patch delete mode 100644 0193-super-intel-move-scsi_get_serial-from-sg_io.patch delete mode 100644 0194-mdmonitor-Abandon-custom-configuration-files.patch delete mode 100644 0195-mdadm.man-elaborate-more-about-mdmonitor.service.patch delete mode 100644 0196-mdadm-Add-mdadm_status.h.patch delete mode 100644 0197-mdadm.conf.man-Explain-udev-rule.patch delete mode 100644 0198-mdadm.man-Add-udev-rules-flag.patch delete mode 100644 0199-util-use-only-dev-directory-in-open_dev.patch delete mode 100644 0200-mdadm-Manage-Clear-superblock-if-adding-new-device-f.patch delete mode 100644 0201-mdadm-Grow-Check-new_level-interface-rather-than-ker.patch delete mode 100644 0202-platform-intel-fix-buffer-overflow.patch delete mode 100644 0203-imsm-fix-tpv-drvies-check-in-add_to_super.patch create mode 100644 mdadm-fix-building-errors.patch diff --git a/.gitignore b/.gitignore index 34fb3da..c493125 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ clog *.src.rpm */ /mdadm-4.*.tar.xz +/mdadm-4.4.tar.gz diff --git a/0001-Coverity-fixes-resources-leaks.patch b/0001-Coverity-fixes-resources-leaks.patch new file mode 100644 index 0000000..6bc5606 --- /dev/null +++ b/0001-Coverity-fixes-resources-leaks.patch @@ -0,0 +1,91 @@ +From 8f54ce5b7eb0ca982803e270082e33f50897b9a6 Mon Sep 17 00:00:00 2001 +From: Nigel Croxon +Date: Mon, 4 Nov 2024 11:17:46 -0500 +Subject: [PATCH 01/37] Coverity fixes resources leaks + +Handle variable going out of scope leaks the handle. + +Signed-off-by: Nigel Croxon +--- + Assemble.c | 3 ++- + Incremental.c | 2 +- + bitmap.c | 7 +++++-- + 3 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 37a530ee..f8099cd3 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -753,6 +753,7 @@ static int load_devices(struct devs *devices, char *devmap, + tst->ss->free_super(tst); + free(tst); + *stp = st; ++ free(best); + return -1; + } + close(dfd); +@@ -834,7 +835,6 @@ static int load_devices(struct devs *devices, char *devmap, + inargv ? "the list" : + "the\n DEVICE list in mdadm.conf" + ); +- free(best); + *stp = st; + goto error; + } +@@ -857,6 +857,7 @@ error: + close(mdfd); + free(devices); + free(devmap); ++ free(best); + return -1; + + } +diff --git a/Incremental.c b/Incremental.c +index aa5db3bf..9b455a12 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -282,7 +282,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, + * clustering resource agents + */ + if (info.array.state & (1 << MD_SB_CLUSTERED)) +- goto out; ++ goto out_unlock; + + /* Couldn't find an existing array, maybe make a new one */ + mdfd = create_mddev(match ? match->devname : NULL, name_to_use, trustworthy, +diff --git a/bitmap.c b/bitmap.c +index c62d18d4..3f8da63d 100644 +--- a/bitmap.c ++++ b/bitmap.c +@@ -260,8 +260,11 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) + return rv; + + info = bitmap_fd_read(fd, brief); +- if (!info) ++ if (!info) { ++ close_fd(&fd); ++ free(info); + return rv; ++ } + sb = &info->sb; + if (sb->magic != BITMAP_MAGIC) { + pr_err("This is an md array. To view a bitmap you need to examine\n"); +@@ -336,7 +339,6 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) + printf(" Cluster name : %-64s\n", sb->cluster_name); + for (i = 0; i < (int)sb->nodes; i++) { + st = NULL; +- free(info); + fd = bitmap_file_open(filename, &st, i, fd); + if (fd < 0) { + printf(" Unable to open bitmap file on node: %i\n", i); +@@ -347,6 +349,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) + printf(" Unable to read bitmap on node: %i\n", i); + continue; + } ++ free(sb); + sb = &info->sb; + if (sb->magic != BITMAP_MAGIC) + pr_err("invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic); +-- +2.41.0 + diff --git a/0001-Remove-hardcoded-checkpoint-interval-checking.patch b/0001-Remove-hardcoded-checkpoint-interval-checking.patch deleted file mode 100644 index c797842..0000000 --- a/0001-Remove-hardcoded-checkpoint-interval-checking.patch +++ /dev/null @@ -1,64 +0,0 @@ -From aec3b907de48be54106600a1ecb69d1231f4801d Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Thu, 18 Jan 2024 11:30:15 +0100 -Subject: [PATCH 01/41] Remove hardcoded checkpoint interval checking - -Mdmon assumes that kernel marks checkpoint every 1/16 of the volume size -and that the checkpoints are equal in size. This is not true, kernel may -mark checkpoints more frequently depending on several factors, including -sync speed. This results in checkpoints reported by mdadm --examine -falling behind the one reported by kernel. - -Remove hardcoded checkpoint interval checking. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - monitor.c | 22 ++++++---------------- - 1 file changed, 6 insertions(+), 16 deletions(-) - -diff --git a/monitor.c b/monitor.c -index 4acec678..b8d9e881 100644 ---- a/monitor.c -+++ b/monitor.c -@@ -564,22 +564,10 @@ static int read_and_act(struct active_array *a, fd_set *fds) - } - } - -- /* Check for recovery checkpoint notifications. We need to be a -- * minimum distance away from the last checkpoint to prevent -- * over checkpointing. Note reshape checkpointing is handled -- * in the second branch. -+ /* Handle reshape checkpointing - */ -- if (sync_completed > a->last_checkpoint && -- sync_completed - a->last_checkpoint > a->info.component_size >> 4 && -- a->curr_action > reshape) { -- /* A (non-reshape) sync_action has reached a checkpoint. -- * Record the updated position in the metadata -- */ -- a->last_checkpoint = sync_completed; -- a->container->ss->set_array_state(a, a->curr_state <= clean); -- } else if ((a->curr_action == idle && a->prev_action == reshape) || -- (a->curr_action == reshape && -- sync_completed > a->last_checkpoint)) { -+ if ((a->curr_action == idle && a->prev_action == reshape) || -+ (a->curr_action == reshape && sync_completed > a->last_checkpoint)) { - /* Reshape has progressed or completed so we need to - * update the array state - and possibly the array size - */ -@@ -607,8 +595,10 @@ static int read_and_act(struct active_array *a, fd_set *fds) - a->last_checkpoint = sync_completed; - } - -- if (sync_completed > a->last_checkpoint) -+ if (sync_completed > a->last_checkpoint) { - a->last_checkpoint = sync_completed; -+ a->container->ss->set_array_state(a, a->curr_state <= clean); -+ } - - if (sync_completed >= a->info.component_size) - a->last_checkpoint = 0; --- -2.40.1 - diff --git a/0002-Incremental-Document-workaround.patch b/0002-Incremental-Document-workaround.patch new file mode 100644 index 0000000..5cbb90a --- /dev/null +++ b/0002-Incremental-Document-workaround.patch @@ -0,0 +1,64 @@ +From 7de5dc53bfbc3bae7d43fc81e51c7c56638004f6 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Mon, 4 Nov 2024 11:37:41 +0100 +Subject: [PATCH 02/37] Incremental: Document workaround + +Keep it documented in code. + +Signed-off-by: Mariusz Tkaczyk +--- + Incremental.c | 28 ++++++++++++++++++++++------ + 1 file changed, 22 insertions(+), 6 deletions(-) + +diff --git a/Incremental.c b/Incremental.c +index 9b455a12..60d6f8cb 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -1693,15 +1693,30 @@ int Incremental_remove(char *devname, char *id_path, int verbose) + + mdfd = open_dev_excl(ent->devnm); + if (is_fd_valid(mdfd)) { ++ char *array_state_file = "array_state"; ++ ++ /** ++ * This is a workaround for the old issue. ++ * Incremental_remove() triggered from udev rule when disk is removed from OS ++ * tries to set array in auto-read-only mode. This can interrupt rebuild ++ * process which is started automatically, e.g. if array is mounted and ++ * spare disk is available (I/O errors limit might be achieved faster than disk is ++ * removed by mdadm). Prevent Incremental_remove() from setting array ++ * into "auto-read-only", by requiring exclusive open to succeed. ++ */ + close_fd(&mdfd); +- if (sysfs_get_str(&mdi, NULL, "array_state", +- buf, sizeof(buf)) > 0) { +- if (strncmp(buf, "active", 6) == 0 || +- strncmp(buf, "clean", 5) == 0) +- sysfs_set_str(&mdi, NULL, +- "array_state", "read-auto"); ++ ++ if (sysfs_get_str(&mdi, NULL, array_state_file, buf, sizeof(buf)) > 0) { ++ char *str_read_auto = map_num_s(sysfs_array_states, ARRAY_READ_AUTO); ++ char *str_active = map_num_s(sysfs_array_states, ARRAY_ACTIVE); ++ char *str_clean = map_num_s(sysfs_array_states, ARRAY_CLEAN); ++ ++ if (strncmp(buf, str_active, strlen(str_active)) == 0 || ++ strncmp(buf, str_clean, strlen(str_clean)) == 0) ++ sysfs_set_str(&mdi, NULL, array_state_file, str_read_auto); + } + } ++ + mdfd = open_dev(ent->devnm); + if (mdfd < 0) { + if (verbose >= 0) +@@ -1711,6 +1726,7 @@ int Incremental_remove(char *devname, char *id_path, int verbose) + + if (id_path) { + struct map_ent *map = NULL, *me; ++ + me = map_by_devnm(&map, ent->devnm); + if (me) + policy_save_path(id_path, me); +-- +2.41.0 + diff --git a/0002-monitor-refactor-checkpoint-update.patch b/0002-monitor-refactor-checkpoint-update.patch deleted file mode 100644 index 236be98..0000000 --- a/0002-monitor-refactor-checkpoint-update.patch +++ /dev/null @@ -1,96 +0,0 @@ -From cf87fe75fd83dac008ea116c2c52ec69783fdf6a Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Thu, 18 Jan 2024 11:30:16 +0100 -Subject: [PATCH 02/41] monitor: refactor checkpoint update - -"if" statements of checkpoint updates have too many responsibilties. -This results in unclear code flow and duplicated code. - -Refactor checkpoint update code and simplify "if" statements. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - monitor.c | 51 +++++++++++++++++++++++++-------------------------- - 1 file changed, 25 insertions(+), 26 deletions(-) - -diff --git a/monitor.c b/monitor.c -index b8d9e881..be0bec78 100644 ---- a/monitor.c -+++ b/monitor.c -@@ -412,6 +412,7 @@ static int read_and_act(struct active_array *a, fd_set *fds) - int ret = 0; - int count = 0; - struct timeval tv; -+ bool write_checkpoint = false; - - a->next_state = bad_word; - a->next_action = bad_action; -@@ -564,40 +565,38 @@ static int read_and_act(struct active_array *a, fd_set *fds) - } - } - -- /* Handle reshape checkpointing -- */ -- if ((a->curr_action == idle && a->prev_action == reshape) || -- (a->curr_action == reshape && sync_completed > a->last_checkpoint)) { -- /* Reshape has progressed or completed so we need to -- * update the array state - and possibly the array size -- */ -+ /* Update reshape checkpoint, depending if it finished or progressed */ -+ if (a->curr_action == idle && a->prev_action == reshape) { -+ char buf[SYSFS_MAX_BUF_SIZE]; -+ - if (sync_completed != 0) - a->last_checkpoint = sync_completed; -- /* We might need to update last_checkpoint depending on -- * the reason that reshape finished. -- * if array reshape is really finished: -- * set check point to the end, this allows -- * set_array_state() to finalize reshape in metadata -- * if reshape if broken: do not set checkpoint to the end -- * this allows for reshape restart from checkpoint -+ -+ /* -+ * If reshape really finished, set checkpoint to the end to finalize it. -+ * Do not set checkpoint if reshape is broken. -+ * Reshape will restart from last checkpoint. - */ -- if ((a->curr_action != reshape) && -- (a->prev_action == reshape)) { -- char buf[SYSFS_MAX_BUF_SIZE]; -- if ((sysfs_get_str(&a->info, NULL, -- "reshape_position", -- buf, -- sizeof(buf)) >= 0) && -- str_is_none(buf) == true) -+ if (sysfs_get_str(&a->info, NULL, "reshape_position", buf, sizeof(buf)) >= 0) -+ if (str_is_none(buf) == true) - a->last_checkpoint = a->info.component_size; -- } -- a->container->ss->set_array_state(a, a->curr_state <= clean); -- a->last_checkpoint = sync_completed; -+ -+ write_checkpoint = true; - } - -- if (sync_completed > a->last_checkpoint) { -+ if (a->curr_action >= reshape && sync_completed > a->last_checkpoint) { -+ /* Update checkpoint if neither reshape nor idle action */ - a->last_checkpoint = sync_completed; -+ -+ write_checkpoint = true; -+ } -+ -+ /* Save checkpoint */ -+ if (write_checkpoint) { - a->container->ss->set_array_state(a, a->curr_state <= clean); -+ -+ if (a->curr_action <= reshape) -+ a->last_checkpoint = sync_completed; - } - - if (sync_completed >= a->info.component_size) --- -2.40.1 - diff --git a/0003-Super-intel-Fix-first-checkpoint-restart.patch b/0003-Super-intel-Fix-first-checkpoint-restart.patch deleted file mode 100644 index 0a347ea..0000000 --- a/0003-Super-intel-Fix-first-checkpoint-restart.patch +++ /dev/null @@ -1,47 +0,0 @@ -From fdb7e802f4cf64d067c3abaafa35056e2bc1ed43 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Thu, 18 Jan 2024 11:30:17 +0100 -Subject: [PATCH 03/41] Super-intel: Fix first checkpoint restart - -When imsm based array is stopped after reaching first checkpoint and -then assembled, first checkpoint is reported as 0. - -This behaviour is valid only for initial checkpoint, if the array was -stopped while performing some action. - -Last checkpoint value is not taken from metadata but always starts -with 0 and it's incremented when sync_completed in sysfs changes. - -In simplification, read_and_act() is responsible for checkpoint updates -and is executed each time sysfs checkpoint update happens. For first -checkpoint it is executed twice and due to marking checkpoint before -triggering any action on the array, it is impossible to read -sync_completed from sysfs in just two iterations. - -The workaround to this is not marking any checkpoint for first -sysfs checkpoint after RAID assembly, to preserve checkpoint value -stored in metadata. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index dbea235d..e61f3f6f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -8771,6 +8771,9 @@ static int imsm_set_array_state(struct active_array *a, int consistent) - super->updates_pending++; - } - -+ if (a->prev_action == idle) -+ goto skip_mark_checkpoint; -+ - mark_checkpoint: - /* skip checkpointing for general migration, - * it is controlled in mdadm --- -2.40.1 - diff --git a/0003-sysfs-functions-for-writing-md-memb-state.patch b/0003-sysfs-functions-for-writing-md-memb-state.patch new file mode 100644 index 0000000..b951f59 --- /dev/null +++ b/0003-sysfs-functions-for-writing-md-memb-state.patch @@ -0,0 +1,164 @@ +From 42db5429cba52c7d86db965100873928e29c512b Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Mon, 4 Nov 2024 15:08:30 +0100 +Subject: [PATCH 03/37] sysfs: functions for writing md//state + +Add dedicated enum to reflect possible values for mentioned file. +Not all values are mapped. Add map to present sysfs keywords. + +Signed-off-by: Mariusz Tkaczyk +--- + Manage.c | 4 +--- + mdadm.h | 19 +++++++++++++++++++ + monitor.c | 12 ++++++------ + sysfs.c | 32 ++++++++++++++++++++++++++++++++ + util.c | 3 +-- + 5 files changed, 59 insertions(+), 11 deletions(-) + +diff --git a/Manage.c b/Manage.c +index b14a9ab9..d618a2f0 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -1675,9 +1675,7 @@ int Manage_subdevs(char *devname, int fd, + } + case 'I': + if (is_fd_valid(sysfd)) { +- static const char val[] = "faulty"; +- +- rv = sysfs_write_descriptor(sysfd, val, strlen(val), &err); ++ rv = sysfs_set_memb_state_fd(sysfd, MEMB_STATE_FAULTY, &err); + } else { + rv = ioctl(fd, SET_DISK_FAULTY, rdev); + if (rv) +diff --git a/mdadm.h b/mdadm.h +index ebb2ca18..218056c8 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -807,9 +807,28 @@ enum sysfs_read_flags { + + #define SYSFS_MAX_BUF_SIZE 64 + ++/** ++ * Defines md//state possible values. ++ * Note that remove can't be read-back from the file. ++ * ++ * This is not complete list. ++ */ ++typedef enum memb_state { ++ MEMB_STATE_EXTERNAL_BBL, ++ MEMB_STATE_BLOCKED, ++ MEMB_STATE_SPARE, ++ MEMB_STATE_WRITE_MOSTLY, ++ MEMB_STATE_IN_SYNC, ++ MEMB_STATE_FAULTY, ++ MEMB_STATE_REMOVE, ++ MEMB_STATE_UNKNOWN ++} memb_state_t; ++char *map_memb_state(memb_state_t state); ++ + 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 mdadm_status_t sysfs_set_memb_state_fd(int fd, memb_state_t state, int *err); + extern void sysfs_get_container_devnm(struct mdinfo *mdi, char *buf); + + extern int sysfs_open(char *devnm, char *devname, char *attr); +diff --git a/monitor.c b/monitor.c +index 3c54f8cb..b771707a 100644 +--- a/monitor.c ++++ b/monitor.c +@@ -140,17 +140,17 @@ int read_dev_state(int fd) + + cp = buf; + while (cp) { +- if (sysfs_attr_match(cp, "faulty")) ++ if (sysfs_attr_match(cp, map_memb_state(MEMB_STATE_FAULTY))) + rv |= DS_FAULTY; +- if (sysfs_attr_match(cp, "in_sync")) ++ if (sysfs_attr_match(cp, map_memb_state(MEMB_STATE_IN_SYNC))) + rv |= DS_INSYNC; +- if (sysfs_attr_match(cp, "write_mostly")) ++ if (sysfs_attr_match(cp, map_memb_state(MEMB_STATE_WRITE_MOSTLY))) + rv |= DS_WRITE_MOSTLY; +- if (sysfs_attr_match(cp, "spare")) ++ if (sysfs_attr_match(cp, map_memb_state(MEMB_STATE_SPARE))) + rv |= DS_SPARE; +- if (sysfs_attr_match(cp, "blocked")) ++ if (sysfs_attr_match(cp, map_memb_state(MEMB_STATE_BLOCKED))) + rv |= DS_BLOCKED; +- if (sysfs_attr_match(cp, "external_bbl")) ++ if (sysfs_attr_match(cp, map_memb_state(MEMB_STATE_EXTERNAL_BBL))) + rv |= DS_EXTERNAL_BB; + cp = strchr(cp, ','); + if (cp) +diff --git a/sysfs.c b/sysfs.c +index a3bcb432..60b27459 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -75,6 +75,23 @@ void sysfs_free(struct mdinfo *sra) + sra = sra2; + } + } ++ ++mapping_t sysfs_memb_states[] = { ++ {"external_bbl", MEMB_STATE_EXTERNAL_BBL}, ++ {"blocked", MEMB_STATE_BLOCKED}, ++ {"spare", MEMB_STATE_SPARE}, ++ {"write_mostly", MEMB_STATE_WRITE_MOSTLY}, ++ {"in_sync", MEMB_STATE_IN_SYNC}, ++ {"faulty", MEMB_STATE_FAULTY}, ++ {"remove", MEMB_STATE_REMOVE}, ++ {NULL, MEMB_STATE_UNKNOWN} ++}; ++ ++char *map_memb_state(memb_state_t state) ++{ ++ return map_num_s(sysfs_memb_states, state); ++} ++ + /** + * write_attr() - write value to fd, don't check errno. + * @attr: value to write. +@@ -117,6 +134,21 @@ mdadm_status_t sysfs_write_descriptor(const int fd, const char *value, const ssi + return MDADM_STATUS_SUCCESS; + } + ++/** ++ * sysfs_set_memb_state_fd() - write to md//state file. ++ * @fd: open file descriptor to the file. ++ * @state: enum value describing value to write ++ * @err: errno value pointer in case of error. ++ * ++ * This is helper to avoid inlining values, they are extracted from map now. ++ */ ++mdadm_status_t sysfs_set_memb_state_fd(int fd, memb_state_t state, int *err) ++{ ++ const char *val = map_memb_state(state); ++ ++ return sysfs_write_descriptor(fd, val, strlen(val), err); ++} ++ + /** + * sysfs_get_container_devnm() - extract container device name. + * @mdi: md_info describes member array, with GET_VERSION option. +diff --git a/util.c b/util.c +index a120c985..6aa44a80 100644 +--- a/util.c ++++ b/util.c +@@ -1808,12 +1808,11 @@ 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; + + while (cnt--) { + int err = 0; +- int ret = sysfs_write_descriptor(statefd, val, strlen(val), &err); ++ int ret = sysfs_set_memb_state_fd(statefd, MEMB_STATE_REMOVE, &err); + + if (ret == MDADM_STATUS_SUCCESS) + return 0; +-- +2.41.0 + diff --git a/0004-Grow-Move-update_tail-assign-to-Grow_reshape.patch b/0004-Grow-Move-update_tail-assign-to-Grow_reshape.patch deleted file mode 100644 index 3ccc2ae..0000000 --- a/0004-Grow-Move-update_tail-assign-to-Grow_reshape.patch +++ /dev/null @@ -1,61 +0,0 @@ -From ea2ca7ed3dbbf881ce08d80fe371f2aaf05011c3 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Thu, 18 Jan 2024 11:30:18 +0100 -Subject: [PATCH 04/41] Grow: Move update_tail assign to Grow_reshape() - -Due to e919fb0af245 ("FIX: Enable metadata updates for raid0") code -can't enter super-intel.c:3415, resulting in checkpoint not being -saved to metadata for second volume in matrix raid array. -This results in checkpoint being stuck at last value for the -first volume. - -Move st->update_tail to Grow_reshape() so it is assigned for each -volume. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -diff --git a/Grow.c b/Grow.c -index f95dae82..5498e54f 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -2085,9 +2085,10 @@ int Grow_reshape(char *devname, int fd, - if (!mdmon_running(st->container_devnm)) - start_mdmon(st->container_devnm); - ping_monitor(container); -- if (mdmon_running(st->container_devnm) && -- st->update_tail == NULL) -- st->update_tail = &st->updates; -+ if (mdmon_running(st->container_devnm) == false) { -+ pr_err("No mdmon found. Grow cannot continue.\n"); -+ goto release; -+ } - } - - if (s->size == MAX_SIZE) -@@ -3048,6 +3049,8 @@ static int reshape_array(char *container, int fd, char *devname, - dprintf("Cannot get array information.\n"); - goto release; - } -+ if (st->update_tail == NULL) -+ st->update_tail = &st->updates; - if (array.level == 0 && info->component_size == 0) { - get_dev_size(fd, NULL, &array_size); - info->component_size = array_size / array.raid_disks; -@@ -5152,9 +5155,7 @@ int Grow_continue_command(char *devname, int fd, - start_mdmon(container); - ping_monitor(container); - -- if (mdmon_running(container)) -- st->update_tail = &st->updates; -- else { -+ if (mdmon_running(container) == false) { - pr_err("No mdmon found. Grow cannot continue.\n"); - ret_val = 1; - goto Grow_continue_command_exit; --- -2.40.1 - diff --git a/0004-Incremental-Simplify-remove-logic.patch b/0004-Incremental-Simplify-remove-logic.patch new file mode 100644 index 0000000..fb105ef --- /dev/null +++ b/0004-Incremental-Simplify-remove-logic.patch @@ -0,0 +1,259 @@ +From b9888145987e273a7613209721a68f75e060263e Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 5 Nov 2024 13:07:16 +0100 +Subject: [PATCH 04/37] Incremental: Simplify remove logic + +Incremental_remove() does not execute Manage_subdevs() now. + +Signed-off-by: Mariusz Tkaczyk +--- + Incremental.c | 116 ++++++++++++++++++++++++++++++++------------------ + Manage.c | 10 ++--- + mdadm.h | 1 + + sysfs.c | 23 ++++++++++ + 4 files changed, 102 insertions(+), 48 deletions(-) + +diff --git a/Incremental.c b/Incremental.c +index 60d6f8cb..228d2bdd 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -1610,22 +1610,6 @@ release: + return rv; + } + +-static void remove_from_member_array(struct mdstat_ent *memb, +- struct mddev_dev *devlist, int verbose) +-{ +- int subfd = open_dev(memb->devnm); +- +- if (subfd >= 0) { +- /* +- * Ignore the return value because it's necessary +- * to handle failure condition here. +- */ +- Manage_subdevs(memb->devnm, subfd, devlist, verbose, +- 0, UOPT_UNDEFINED, 0); +- close(subfd); +- } +-} +- + /** + * is_devnode_path() - check if the devname passed might be devnode path. + * @devnode: the path to check. +@@ -1646,25 +1630,81 @@ static bool is_devnode_path(char *devnode) + return false; + } + ++/** ++ * Incremental_remove_external() - Remove the device from external container. ++ * @device_devnm: block device to remove. ++ * @container_devnm: the parent container ++ * @mdstat: mdstat file content. ++ * @verbose: verbose flag. ++ * ++ * Fail member device in each subarray and remove member device from external container. ++ * The resposibility of removing member disks from external subararys belongs to mdmon. ++ */ ++static mdadm_status_t Incremental_remove_external(char *device_devnm, char *container_devnm, ++ struct mdstat_ent *mdstat, int verbose) ++{ ++ mdadm_status_t rv = MDADM_STATUS_SUCCESS; ++ struct mdstat_ent *memb; ++ ++ for (memb = mdstat ; memb ; memb = memb->next) { ++ mdadm_status_t ret = MDADM_STATUS_SUCCESS; ++ int state_fd; ++ ++ if (!is_container_member(memb, container_devnm)) ++ continue; ++ ++ /* ++ * Checking mdstat is pointles because it might be outdated, try open descriptor ++ * instead. If it fails, we are fine with that, device is already gone. ++ */ ++ state_fd = sysfs_open_memb_attr(memb->devnm, device_devnm, "state", O_RDWR); ++ if (!is_fd_valid(state_fd)) ++ continue; ++ ++ ret = sysfs_set_memb_state_fd(state_fd, MEMB_STATE_FAULTY, NULL); ++ if (ret && verbose >= 0) ++ pr_err("Cannot fail member device %s in external subarray %s.\n", ++ device_devnm, memb->devnm); ++ ++ close_fd(&state_fd); ++ ++ /* ++ * Don't remove member device from container if it failed to remove it ++ * from any member array. ++ */ ++ rv |= ret; ++ } ++ ++ if (rv == MDADM_STATUS_SUCCESS) ++ rv = sysfs_set_memb_state(container_devnm, device_devnm, MEMB_STATE_REMOVE); ++ ++ if (rv && verbose >= 0) ++ pr_err("Cannot remove member device %s from container %s.\n", device_devnm, ++ container_devnm); ++ ++ return rv; ++} ++ + /** + * 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. + * +- * 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. ++ * First, fail the device (if needed) and then remove the device. This code is critical for system ++ * funtionality and that is why it is keept as simple as possible. We do not load devices using ++ * sysfs_read() because any unerelated failure may lead us to abort. We also do not call ++ * Manage_Subdevs(). + */ + int Incremental_remove(char *devname, char *id_path, int verbose) + { ++ mdadm_status_t rv = MDADM_STATUS_SUCCESS; + char *devnm = basename(devname); +- struct mddev_dev devlist = {0}; + char buf[SYSFS_MAX_BUF_SIZE]; + struct mdstat_ent *mdstat; + struct mdstat_ent *ent; + struct mdinfo mdi; +- int rv = 1; +- int mdfd; ++ int mdfd = -1; + + if (strcmp(devnm, devname) != 0) + if (!is_devnode_path(devname)) { +@@ -1733,32 +1773,24 @@ int Incremental_remove(char *devname, char *id_path, int verbose) + map_free(map); + } + +- devlist.devname = devnm; +- devlist.disposition = 'I'; +- /* for a container, we must fail each member array */ + if (is_mdstat_ent_external(ent)) { +- struct mdstat_ent *memb; +- for (memb = mdstat ; memb ; memb = memb->next) { +- if (is_container_member(memb, ent->devnm)) +- remove_from_member_array(memb, +- &devlist, verbose); +- } +- } else { +- /* +- * This 'I' incremental remove is a try-best effort, +- * the failure condition can be safely ignored +- * because of the following up 'r' remove. +- */ +- Manage_subdevs(ent->devnm, mdfd, &devlist, +- verbose, 0, UOPT_UNDEFINED, 0); ++ rv = Incremental_remove_external(devnm, ent->devnm, mdstat, verbose); ++ goto out; + } + +- devlist.disposition = 'r'; +- rv = Manage_subdevs(ent->devnm, mdfd, &devlist, +- verbose, 0, UOPT_UNDEFINED, 0); ++ /* Native arrays are handled separatelly to provide more detailed error handling */ ++ rv = sysfs_set_memb_state(ent->devnm, devnm, MEMB_STATE_FAULTY); ++ if (rv && verbose >= 0) ++ pr_err("Cannot fail member device %s in array %s.\n", devnm, ent->devnm); ++ ++ if (rv == MDADM_STATUS_SUCCESS) ++ rv = sysfs_set_memb_state(ent->devnm, devnm, MEMB_STATE_REMOVE); ++ ++ if (rv && verbose >= 0) ++ pr_err("Cannot remove member device %s from %s.\n", devnm, ent->devnm); + +- close_fd(&mdfd); + out: ++ close_fd(&mdfd); + free_mdstat(mdstat); + return rv; + } +diff --git a/Manage.c b/Manage.c +index d618a2f0..034eb00c 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -1381,8 +1381,6 @@ bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const + * 'f' - set the device faulty SET_DISK_FAULTY + * device can be 'detached' in which case any device that + * is inaccessible will be marked faulty. +- * 'I' - remove device by using incremental fail +- * which is executed when device is removed surprisingly. + * 'R' - mark this device as wanting replacement. + * 'W' - this device is added if necessary and activated as + * a replacement for a previous 'R' device. +@@ -1544,9 +1542,9 @@ int Manage_subdevs(char *devname, int fd, + + /* This is a kernel-internal name like 'sda1' */ + +- if (!strchr("rfI", dv->disposition)) { +- pr_err("%s only meaningful with -r, -f or -I, not -%c\n", +- dv->devname, dv->disposition); ++ if (!strchr("rf", dv->disposition)) { ++ pr_err("%s only meaningful with -r, -f, not -%c\n", dv->devname, ++ dv->disposition); + goto abort; + } + +@@ -1673,7 +1671,7 @@ int Manage_subdevs(char *devname, int fd, + close_fd(&sysfd); + goto abort; + } +- case 'I': ++ + if (is_fd_valid(sysfd)) { + rv = sysfs_set_memb_state_fd(sysfd, MEMB_STATE_FAULTY, &err); + } else { +diff --git a/mdadm.h b/mdadm.h +index 218056c8..77705b11 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -829,6 +829,7 @@ 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 mdadm_status_t sysfs_set_memb_state_fd(int fd, memb_state_t state, int *err); ++extern mdadm_status_t sysfs_set_memb_state(char *array_devnm, char *memb_devnm, memb_state_t state); + extern void sysfs_get_container_devnm(struct mdinfo *mdi, char *buf); + + extern int sysfs_open(char *devnm, char *devname, char *attr); +diff --git a/sysfs.c b/sysfs.c +index 60b27459..c030d634 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -149,6 +149,29 @@ mdadm_status_t sysfs_set_memb_state_fd(int fd, memb_state_t state, int *err) + return sysfs_write_descriptor(fd, val, strlen(val), err); + } + ++/** ++ * sysfs_set_memb_state() - write to member disk state file. ++ * @array_devnm: kernel name of the array. ++ * @memb_devnm: kernel name of member device. ++ * @state: value to write. ++ * ++ * Function expects that the device exists, error is unconditionally printed. ++ */ ++mdadm_status_t sysfs_set_memb_state(char *array_devnm, char *memb_devnm, memb_state_t state) ++{ ++ int state_fd = sysfs_open_memb_attr(array_devnm, memb_devnm, "state", O_RDWR); ++ ++ if (!is_fd_valid(state_fd)) { ++ pr_err("Cannot open file descriptor to %s in array %s, aborting.\n", ++ memb_devnm, array_devnm); ++ return MDADM_STATUS_ERROR; ++ } ++ ++ return sysfs_set_memb_state_fd(state_fd, state, NULL); ++ ++ close_fd(&state_fd); ++} ++ + /** + * sysfs_get_container_devnm() - extract container device name. + * @mdi: md_info describes member array, with GET_VERSION option. +-- +2.41.0 + diff --git a/0005-Add-understanding-output-section-in-man.patch b/0005-Add-understanding-output-section-in-man.patch deleted file mode 100644 index fa4fd55..0000000 --- a/0005-Add-understanding-output-section-in-man.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 37eeae381a8ed07a1fabb64184fe45d95a861496 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Thu, 18 Jan 2024 11:30:19 +0100 -Subject: [PATCH 05/41] Add understanding output section in man - -Add new section in man for explaining mdadm outputs. -Describe checkpoint entry. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.8.in | 21 ++++++++++++++++++++- - 1 file changed, 20 insertions(+), 1 deletion(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index 96a4a08e..9ba66825 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -3179,7 +3179,7 @@ environment. This can be useful for testing or for disaster - recovery. You should be aware that interoperability may be - compromised by setting this value. - --These change can also be suppressed by adding -+These change can also be suppressed by adding - .B mdadm.imsm.test=1 - to the kernel command line. This makes it easy to test IMSM - code in a virtual machine that doesn't have IMSM virtual hardware. -@@ -3454,6 +3454,25 @@ is any string. These names are supported by - since version 3.3 provided they are enabled in - .IR mdadm.conf . - -+.SH UNDERSTANDING OUTPUT -+ -+.TP -+EXAMINE -+ -+.TP -+.B checkpoint -+Checkpoint value is reported when array is performing some action including -+resync, recovery or reshape. Checkpoints allow resuming action from certain -+point if it was interrupted. -+ -+Checkpoint is reported as combination of two values: current migration unit -+and number of blocks per unit. By multiplying those values and dividing by -+array size checkpoint progress percentage can be obtained in relation to -+current progress reported in /proc/mdstat. Checkpoint is also related to (and -+sometimes based on) sysfs entry sync_completed but depending on action units -+may differ. Even if units are the same, it should not be expected that -+checkpoint and sync_completed will be exact match nor updated simultaneously. -+ - .SH NOTE - .I mdadm - was previously known as --- -2.40.1 - diff --git a/0005-checkpatch.conf-ignore-NEW_TYPEDEFS.patch b/0005-checkpatch.conf-ignore-NEW_TYPEDEFS.patch new file mode 100644 index 0000000..0c43ad4 --- /dev/null +++ b/0005-checkpatch.conf-ignore-NEW_TYPEDEFS.patch @@ -0,0 +1,24 @@ +From 143d94f684b738d1aa89024b182ad4cfa1b9018b Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 12 Nov 2024 14:05:11 +0100 +Subject: [PATCH 05/37] checkpatch.conf: ignore NEW_TYPEDEFS + +In mdadm, we have more flexible apporach to typedefs. + +Signed-off-by: Mariusz Tkaczyk +--- + .github/tools/.checkpatch.conf | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/.github/tools/.checkpatch.conf b/.github/tools/.checkpatch.conf +index d6e3bc44..03114847 100644 +--- a/.github/tools/.checkpatch.conf ++++ b/.github/tools/.checkpatch.conf +@@ -8,3 +8,4 @@ + --exclude tests + --ignore FILE_PATH_CHANGES + --ignore EMAIL_SUBJECT ++--ignore NEW_TYPEDEFS +-- +2.41.0 + diff --git a/0006-Create-add_disk_to_super-fix-resource-leak.patch b/0006-Create-add_disk_to_super-fix-resource-leak.patch deleted file mode 100644 index 13eb094..0000000 --- a/0006-Create-add_disk_to_super-fix-resource-leak.patch +++ /dev/null @@ -1,48 +0,0 @@ -From b8f5523a795b8f7e56dfbc139ce7f64728b67726 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 11:56:07 +0100 -Subject: [PATCH 06/41] Create: add_disk_to_super() fix resource leak - -Fixes resource leak in add_disk_to_super(). - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/Create.c b/Create.c -index 8082f54a..7e9170b6 100644 ---- a/Create.c -+++ b/Create.c -@@ -279,8 +279,10 @@ static int add_disk_to_super(int mdfd, struct shape *s, struct context *c, - dv->devname); - return 1; - } -- if (!fstat_is_blkdev(fd, dv->devname, &rdev)) -+ if (!fstat_is_blkdev(fd, dv->devname, &rdev)) { -+ close(fd); - return 1; -+ } - info->disk.major = major(rdev); - info->disk.minor = minor(rdev); - } -@@ -289,6 +291,7 @@ static int add_disk_to_super(int mdfd, struct shape *s, struct context *c, - if (st->ss->add_to_super(st, &info->disk, fd, dv->devname, - dv->data_offset)) { - ioctl(mdfd, STOP_ARRAY, NULL); -+ close(fd); - return 1; - } - st->ss->getinfo_super(st, info, NULL); -@@ -297,6 +300,7 @@ static int add_disk_to_super(int mdfd, struct shape *s, struct context *c, - *zero_pid = write_zeroes_fork(fd, s, st, dv); - if (*zero_pid <= 0) { - ioctl(mdfd, STOP_ARRAY, NULL); -+ close(fd); - return 1; - } - } --- -2.40.1 - diff --git a/0006-mdadm-add-MAINTAINERS-file.patch b/0006-mdadm-add-MAINTAINERS-file.patch new file mode 100644 index 0000000..016ab92 --- /dev/null +++ b/0006-mdadm-add-MAINTAINERS-file.patch @@ -0,0 +1,55 @@ +From 7f57f9b79dada30cdc64de1d2fe7541093c5b4e3 Mon Sep 17 00:00:00 2001 +From: Nigel Croxon +Date: Thu, 9 Jan 2025 15:09:51 -0500 +Subject: [PATCH 06/37] mdadm: add MAINTAINERS file + +Create a maintainers file to keep track of people +to contact when dealing with mdadm questions/issues. + +Signed-off-by: Nigel Croxon +--- + MAINTAINERS | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + create mode 100644 MAINTAINERS + +diff --git a/MAINTAINERS b/MAINTAINERS +new file mode 100644 +index 00000000..0a1229fd +--- /dev/null ++++ b/MAINTAINERS +@@ -0,0 +1,32 @@ ++ ++# List of maintainers for mdadm ++ ++ ++Descriptions of section entries: ++ ++M: Mail patches to: FullName ++L: Mailing list that is relevant to mdadm ++ ++ ++Alphabetical Order: ++ ++M: Blazej Kucman ++L: linux-raid@vger.kernel.org ++ ++M: Mateusz Kusiak ++L: linux-raid@vger.kernel.org ++ ++M: Mariusz Tkaczyk ++L: linux-raid@vger.kernel.org ++ ++M: Nigel Croxon ++L: linux-raid@vger.kernel.org ++ ++M: Song Liu ++L: linux-raid@vger.kernel.org ++ ++M: Xiao Ni ++L: linux-raid@vger.kernel.org ++ ++M: Yu Kuai ++L: linux-raid@vger.kernel.org +-- +2.41.0 + diff --git a/0007-mdadm-signal_s-init-variables.patch b/0007-mdadm-signal_s-init-variables.patch deleted file mode 100644 index 6be72c2..0000000 --- a/0007-mdadm-signal_s-init-variables.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 38cb95dd28fa790ae6d90b169f1fd2b1d09a02f2 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 11:56:08 +0100 -Subject: [PATCH 07/41] mdadm: signal_s() init variables - -Init sigaction structs in signal_s(). -This approach might throw warnings for GCC 4.x and lower. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index 1f28b3e7..75c887e4 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1856,11 +1856,10 @@ static inline char *to_subarray(struct mdstat_ent *ent, char *container) - */ - static inline sighandler_t signal_s(int sig, sighandler_t handler) - { -- struct sigaction new_act; -- struct sigaction old_act; -+ struct sigaction new_act = {0}; -+ struct sigaction old_act = {0}; - - new_act.sa_handler = handler; -- new_act.sa_flags = 0; - - if (sigaction(sig, &new_act, &old_act) == 0) - return old_act.sa_handler; --- -2.40.1 - diff --git a/0007-mdadm.man-Remove-external-bitmap.patch b/0007-mdadm.man-Remove-external-bitmap.patch new file mode 100644 index 0000000..556089f --- /dev/null +++ b/0007-mdadm.man-Remove-external-bitmap.patch @@ -0,0 +1,127 @@ +From ef4b6a23189d804bfd8fa81f5038afe6ce825bde Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 7 Jan 2025 10:09:16 +0100 +Subject: [PATCH 07/37] mdadm.man: Remove external bitmap + +Remove external bitmap support from manual. + +Signed-off-by: Mariusz Tkaczyk +--- + mdadm.8.in | 55 ++++++------------------------------------------------ + 1 file changed, 6 insertions(+), 49 deletions(-) + +diff --git a/mdadm.8.in b/mdadm.8.in +index 2b6f3e50..83c0689f 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -740,27 +740,11 @@ parameter and are stored internally. + .B none + - create array with no bitmap or remove any present bitmap (grow mode). + +-Setting bitmap for file is deprecated and should not be used. The file should not exist unless +-.B \-\-force +-is also given. The same file should be provided when assembling the array. The file name must +-contain at least one slash ('/'). Bitmap files are only known to work on ext2 and ext3. Storing +-bitmap files on other filesystems may result in serious problems. +- +-When creating an array on devices which are 100G or larger, +-.I mdadm +-automatically adds an internal bitmap as it will usually be +-beneficial. This can be suppressed with +-.B "\-\-bitmap=none" +-or by selecting a different consistency policy with +-.BR \-\-consistency\-policy . +- + .TP + .BR \-\-bitmap\-chunk= + Set the chunk size of the bitmap. Each bit corresponds to that many + Kilobytes of storage. +-When using a file-based bitmap, the default is to use the smallest +-size that is at least 4 and requires no more than 2^21 chunks. +-When using an ++ + .B internal + bitmap, the chunk size defaults to 64Meg, or larger if necessary to + fit the bitmap into the available space. +@@ -1108,13 +1092,6 @@ are present. This is only needed with + and can be used if the physical connections to devices are + not as reliable as you would like. + +-.TP +-.BR \-b ", " \-\-bitmap= +-Specify the bitmap file that was given when the array was created. If +-an array has an +-.B internal +-bitmap, there is no need to specify this when assembling the array. +- + .TP + .BR \-\-backup\-file= + If +@@ -1614,9 +1591,8 @@ applies to a whole array which is currently active. + + .TP + .BR \-X ", " \-\-examine\-bitmap +-Report information about a bitmap file. +-The argument is either an external bitmap file or an array component +-in case of an internal bitmap. Note that running this on an array ++Report information about a bitmap. ++The argument is an array component. Note that running this on an array + device (e.g. + .BR /dev/md0 ) + does not report the bitmap for that array. +@@ -1774,10 +1750,7 @@ Only meaningful with + this will scan the + .B map + file for arrays that are being incrementally assembled and will try to +-start any that are not already started. If any such array is listed +-in +-.B mdadm.conf +-as requiring an external bitmap, that bitmap will be attached first. ++start any that are not already started. + + .TP + .BR \-\-fail ", " \-f +@@ -2151,15 +2124,7 @@ setting. + .\".B \-\-size + .\"is given, the apparent size of the smallest drive given is used. + +-If the array type supports a write-intent bitmap, and if the devices +-in the array exceed 100G is size, an internal write-intent bitmap +-will automatically be added unless some other option is explicitly +-requested with the +-.B \-\-bitmap +-option or a different consistency policy is selected with the +-.B \-\-consistency\-policy +-option. In any case, space for a bitmap will be reserved so that one +-can be added later with ++Space for a bitmap will be reserved so that one can be added later with + .BR "\-\-grow \-\-bitmap=internal" . + + If the metadata type supports it (currently only 1.x and IMSM metadata), +@@ -2735,11 +2700,6 @@ Also, the size of an array cannot be changed while it has an active + bitmap. If an array has a bitmap, it must be removed before the size + can be changed. Once the change is complete a new bitmap can be created. + +-.PP +-Note: +-.B "--grow --size" +-is not yet supported for external file bitmap. +- + .SS RAID\-DEVICES CHANGES + + A RAID1 array can work with any number of devices from 1 upwards +@@ -2834,10 +2794,7 @@ stored on the device being reshaped. + .SS BITMAP CHANGES + + A write-intent bitmap can be added to, or removed from, an active +-array. Either internal bitmaps, or bitmaps stored in a separate file, +-can be added. Note that if you add a bitmap stored in a file which is +-in a filesystem that is on the RAID array being affected, the system +-will deadlock. The bitmap must be on a separate filesystem. ++array. + + .SS CONSISTENCY POLICY CHANGES + +-- +2.41.0 + diff --git a/0008-Monitor-open-file-before-check-in-check_one_sharer.patch b/0008-Monitor-open-file-before-check-in-check_one_sharer.patch deleted file mode 100644 index 2ca98c4..0000000 --- a/0008-Monitor-open-file-before-check-in-check_one_sharer.patch +++ /dev/null @@ -1,48 +0,0 @@ -From b7d7837128e90c8b496ebc3d88eda1a8ff477392 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 11:56:09 +0100 -Subject: [PATCH 08/41] Monitor: open file before check in check_one_sharer() - -Open file before performing checks in check_one_sharer() to avoid -file tampering. -Remove redundant access check. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Monitor.c | 13 +++++-------- - 1 file changed, 5 insertions(+), 8 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index 824a69fc..7cee95d4 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -451,20 +451,17 @@ static int check_one_sharer(int scan) - return 2; - } - -- if (access(AUTOREBUILD_PID_PATH, F_OK) != 0) -- return 0; -- -- if (!is_file(AUTOREBUILD_PID_PATH)) { -- pr_err("%s is not a regular file.\n", AUTOREBUILD_PID_PATH); -- return 2; -- } -- - fp = fopen(AUTOREBUILD_PID_PATH, "r"); - if (!fp) { - pr_err("Cannot open %s file.\n", AUTOREBUILD_PID_PATH); - return 2; - } - -+ if (!is_file(AUTOREBUILD_PID_PATH)) { -+ pr_err("%s is not a regular file.\n", AUTOREBUILD_PID_PATH); -+ return 2; -+ } -+ - if (fscanf(fp, "%d", &pid) != 1) { - pr_err("Cannot read pid from %s file.\n", AUTOREBUILD_PID_PATH); - fclose(fp); --- -2.40.1 - diff --git a/0008-Remove-freeze-reshape-logic.patch b/0008-Remove-freeze-reshape-logic.patch new file mode 100644 index 0000000..aecf111 --- /dev/null +++ b/0008-Remove-freeze-reshape-logic.patch @@ -0,0 +1,223 @@ +From cbc1cd589496a4ae16eb226a7fbad71a7d3d842d Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Wed, 16 Oct 2024 10:48:08 +0000 +Subject: [PATCH 08/37] Remove --freeze-reshape logic + +This commit removes --freeze-reshape logic, it basicaly reverts +commit b76b30e0f950 ("Do not continue reshape during initrd phase"). +--freeze-reshape was supposed to be used to restore critical sector in +incremental and assemble operations without starting a reshape process, +but it's meaning has been lost through the years and it is not +currently used. + +A replacement for this logic will be added in incoming patches, so +reshapes won't be started in initrd phrase. + +Signed-off-by: Mateusz Kusiak +--- + Grow.c | 30 +++++++----------------------- + ReadMe.c | 1 - + mdadm.8.in | 37 ------------------------------------- + mdadm.c | 6 ------ + mdadm.h | 2 -- + 5 files changed, 7 insertions(+), 69 deletions(-) + +diff --git a/Grow.c b/Grow.c +index cc1be6cc..0d9e3b53 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -1746,7 +1746,7 @@ static int reshape_array(char *container, int fd, char *devname, + int force, struct mddev_dev *devlist, + unsigned long long data_offset, + char *backup_file, int verbose, int forked, +- int restart, int freeze_reshape); ++ int restart); + static int reshape_container(char *container, char *devname, + int mdfd, + struct supertype *st, +@@ -2341,7 +2341,7 @@ size_change_error: + sync_metadata(st); + rv = reshape_array(container, fd, devname, st, &info, c->force, + devlist, s->data_offset, c->backup_file, +- c->verbose, 0, 0, 0); ++ c->verbose, 0, 0); + frozen = 0; + } + release: +@@ -3000,7 +3000,7 @@ static int reshape_array(char *container, int fd, char *devname, + int force, struct mddev_dev *devlist, + unsigned long long data_offset, + char *backup_file, int verbose, int forked, +- int restart, int freeze_reshape) ++ int restart) + { + struct reshape reshape; + int spares_needed; +@@ -3484,14 +3484,6 @@ started: + } + if (restart) + sysfs_set_str(sra, NULL, "array_state", "active"); +- if (freeze_reshape) { +- free(fdlist); +- free(offsets); +- sysfs_free(sra); +- pr_err("Reshape has to be continued from location %llu when root filesystem has been mounted.\n", +- sra->reshape_progress); +- return 1; +- } + + if (!forked) + if (continue_via_systemd(container ?: sra->sys_name, +@@ -3688,7 +3680,7 @@ int reshape_container(char *container, char *devname, + */ + ping_monitor(container); + +- if (!forked && !c->freeze_reshape) ++ if (!forked) + if (continue_via_systemd(container, GROW_SERVICE, NULL)) + return 0; + +@@ -3698,8 +3690,7 @@ int reshape_container(char *container, char *devname, + unfreeze(st); + return 1; + default: /* parent */ +- if (!c->freeze_reshape) +- printf("%s: multi-array reshape continues in background\n", Name); ++ printf("%s: multi-array reshape continues in background\n", Name); + return 0; + case 0: /* child */ + manage_fork_fds(0); +@@ -3797,15 +3788,9 @@ int reshape_container(char *container, char *devname, + + rv = reshape_array(container, fd, adev, st, + content, c->force, NULL, INVALID_SECTORS, +- c->backup_file, c->verbose, 1, restart, +- c->freeze_reshape); ++ c->backup_file, c->verbose, 1, restart); + close(fd); + +- if (c->freeze_reshape) { +- sysfs_free(cc); +- exit(0); +- } +- + restart = 0; + if (rv) + break; +@@ -5220,8 +5205,7 @@ int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info, + } else + ret_val = reshape_array(NULL, mdfd, "array", st, info, 1, + NULL, INVALID_SECTORS, c->backup_file, +- 0, forked, 1 | info->reshape_active, +- c->freeze_reshape); ++ 0, forked, 1 | info->reshape_active); + + return ret_val; + } +diff --git a/ReadMe.c b/ReadMe.c +index 9c29723f..c2415c26 100644 +--- a/ReadMe.c ++++ b/ReadMe.c +@@ -158,7 +158,6 @@ struct option long_options[] = { + {"scan", 0, 0, 's'}, + {"force", 0, 0, Force}, + {"update", 1, 0, 'U'}, +- {"freeze-reshape", 0, 0, FreezeReshape}, + + /* Management */ + {"add", 0, 0, Add}, +diff --git a/mdadm.8.in b/mdadm.8.in +index 83c0689f..45255521 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -880,31 +880,6 @@ different versions of + .I mdadm + are used to add different devices). + +-.TP +-.BR \-\-continue +-This option is complementary to the +-.B \-\-freeze-reshape +-option for assembly. It is needed when +-.B \-\-grow +-operation is interrupted and it is not restarted automatically due to +-.B \-\-freeze-reshape +-usage during array assembly. This option is used together with +-.BR \-G +-, ( +-.BR \-\-grow +-) command and device for a pending reshape to be continued. +-All parameters required for reshape continuation will be read from array metadata. +-If initial +-.BR \-\-grow +-command had required +-.BR \-\-backup\-file= +-option to be set, continuation option will require to have exactly the same +-backup file given as well. +-.IP +-Any other parameter passed together with +-.BR \-\-continue +-option will be ignored. +- + .TP + .BR \-N ", " \-\-name= + Set a +@@ -1302,18 +1277,6 @@ or + and allows the array to be again used on a kernel prior to Linux 5.3. + This option should be used with great caution. + +-.TP +-.BR \-\-freeze\-reshape +-This option is intended to be used in start-up scripts during the initrd boot phase. +-When the array under reshape is assembled during the initrd phase, this option +-stops the reshape after the reshape-critical section has been restored. This happens +-before the file system pivot operation and avoids loss of filesystem context. +-Losing file system context would cause reshape to be broken. +- +-Reshape can be continued later using the +-.B \-\-continue +-option for the grow command. +- + .SH For Manage mode: + + .TP +diff --git a/mdadm.c b/mdadm.c +index 7d3b656b..a72058b4 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -710,12 +710,6 @@ int main(int argc, char *argv[]) + case O(MANAGE,Force): /* add device which is too large */ + c.force = 1; + continue; +- /* now for the Assemble options */ +- case O(ASSEMBLE, FreezeReshape): /* Freeze reshape during +- * initrd phase */ +- case O(INCREMENTAL, FreezeReshape): +- c.freeze_reshape = 1; +- continue; + case O(CREATE,'u'): /* uuid of array */ + case O(ASSEMBLE,'u'): /* uuid of array */ + if (ident.uuid_set) { +diff --git a/mdadm.h b/mdadm.h +index 77705b11..6062e167 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -530,7 +530,6 @@ enum special_options { + RebuildMapOpt, + InvalidBackup, + UdevRules, +- FreezeReshape, + Continue, + OffRootOpt, + Prefer, +@@ -680,7 +679,6 @@ struct context { + int scan; + int SparcAdjust; + int delay; +- int freeze_reshape; + char *backup_file; + int invalid_backup; + char *action; +-- +2.41.0 + diff --git a/0009-Detail-Export-reshape-status.patch b/0009-Detail-Export-reshape-status.patch new file mode 100644 index 0000000..824eb81 --- /dev/null +++ b/0009-Detail-Export-reshape-status.patch @@ -0,0 +1,33 @@ +From 25267bcc1eb403b2d837069289990afdc097031f Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Wed, 9 Oct 2024 11:24:13 +0000 +Subject: [PATCH 09/37] Detail: Export reshape status + +Display if there's an ongoing reshape happening in mdadm --detail +--export output. + +This change is needed for incoming patches that will change "grow +continue" udev rules, to be based on actual array state. + +Signed-off-by: Mateusz Kusiak +--- + Detail.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Detail.c b/Detail.c +index 5819ced9..b804a624 100644 +--- a/Detail.c ++++ b/Detail.c +@@ -290,6 +290,9 @@ int Detail(char *dev, struct context *c) + + map_free(map); + if (st && st->sb) { ++ if (info) ++ printf("MD_RESHAPE_ACTIVE=%s\n", ++ info->reshape_active ? "True" : "False"); + if (st->ss->export_detail_super) + st->ss->export_detail_super(st); + } +-- +2.41.0 + diff --git a/0009-Grow-remove-dead-condition-in-Grow_reshape.patch b/0009-Grow-remove-dead-condition-in-Grow_reshape.patch deleted file mode 100644 index 437143e..0000000 --- a/0009-Grow-remove-dead-condition-in-Grow_reshape.patch +++ /dev/null @@ -1,34 +0,0 @@ -From e44d13f466e30c018887cd5aaf1212ed9f510813 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 11:56:10 +0100 -Subject: [PATCH 09/41] Grow: remove dead condition in Grow_reshape() - -Remove dead "if" condition from Grow_reshape(). Sysfs read check is -performed earlier in the code. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/Grow.c b/Grow.c -index 5498e54f..c69a342d 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -2098,11 +2098,7 @@ int Grow_reshape(char *devname, int fd, - /* got truncated to 32bit, write to - * component_size instead - */ -- if (sra) -- rv = sysfs_set_num(sra, NULL, -- "component_size", s->size); -- else -- rv = -1; -+ rv = sysfs_set_num(sra, NULL, "component_size", s->size); - } else { - rv = md_set_array_info(fd, &array); - --- -2.40.1 - diff --git a/0010-mdadm-Do-not-start-reshape-before-switchroot.patch b/0010-mdadm-Do-not-start-reshape-before-switchroot.patch new file mode 100644 index 0000000..61b42a7 --- /dev/null +++ b/0010-mdadm-Do-not-start-reshape-before-switchroot.patch @@ -0,0 +1,217 @@ +From 8a0d3fea424c1c19c51993c0849ea76ea41e8003 Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Thu, 10 Oct 2024 10:31:06 +0000 +Subject: [PATCH 10/37] mdadm: Do not start reshape before switchroot + +There are numerous issues for --grow --continue in switchroot phrase, +they include: +* Events being missed for restarting grow-continue service. This is + apparent mostly on OS on RAID scenarios. When a checkpoint (next step) + is committed, we have no reliable way to gracefully stop reshape until + it reaches that checkpoint. During boot, there's heavy I/O utilisation, + which causes sync speed drop, and naturally checkpoint takes longer to + reach. This further causes systemd to forcefully kill grow-continue + service due to timeouts, which results in udev event being missed for + grow-continue service restart. +* Grow-continue (seemingly) was not designed to be restarted without + reassembly, some things like stopping chunksize (to lower) migration + were straight up not working until recently. +This patch makes grow-continue (actual reshape) start after switchroot +phrase. This way we should not encounter issues related to restarting +the service. + +Add checks not start a reshape if in initrd, let it initialise only. +Change grow-continue udev rule to be triggered whenever there's a +reshape happening in metadata, rely on udev event to kick reshape after +switchroot. Add handle_forking helper function for reshapes to avoid +duplicating code. + +Signed-off-by: Mateusz Kusiak +--- + Grow.c | 81 +++++++++++++++++++++++++++------------ + mdadm_status.h | 3 +- + udev-md-raid-arrays.rules | 3 +- + util.c | 1 + + 4 files changed, 61 insertions(+), 27 deletions(-) + +diff --git a/Grow.c b/Grow.c +index 0d9e3b53..2719346c 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -2995,6 +2995,34 @@ static void catch_term(int sig) + sigterm = 1; + } + ++ ++/** ++ * handle_forking() - Handle reshape forking. ++ * ++ * @forked: if already forked. ++ * @devname: device name. ++ * Returns: -1 if fork() failed, ++ * 0 if child process, ++ * 1 if job delegated to forked process or systemd. ++ * ++ * This function is a helper function for reshapes for fork handling. ++ */ ++static mdadm_status_t handle_forking(bool forked, char *devname) ++{ ++ if (forked) ++ return MDADM_STATUS_FORKED; ++ ++ if (devname && continue_via_systemd(devname, GROW_SERVICE, NULL)) ++ return MDADM_STATUS_SUCCESS; ++ ++ switch (fork()) { ++ case -1: return MDADM_STATUS_ERROR; /* error */ ++ case 0: return MDADM_STATUS_FORKED; /* child */ ++ default: return MDADM_STATUS_SUCCESS; /* parent */ ++ } ++ ++} ++ + static int reshape_array(char *container, int fd, char *devname, + struct supertype *st, struct mdinfo *info, + int force, struct mddev_dev *devlist, +@@ -3485,33 +3513,35 @@ started: + if (restart) + sysfs_set_str(sra, NULL, "array_state", "active"); + +- if (!forked) +- if (continue_via_systemd(container ?: sra->sys_name, +- GROW_SERVICE, NULL)) { +- free(fdlist); +- free(offsets); +- sysfs_free(sra); +- return 0; +- } ++ /* Do not run in initrd */ ++ if (in_initrd()) { ++ free(fdlist); ++ free(offsets); ++ sysfs_free(sra); ++ pr_info("Reshape has to be continued from location %llu when root filesystem has been mounted.\n", ++ sra->reshape_progress); ++ return 1; ++ } + + /* Now we just need to kick off the reshape and watch, while + * handling backups of the data... + * This is all done by a forked background process. + */ +- switch(forked ? 0 : fork()) { +- case -1: ++ switch (handle_forking(forked, container ? container : sra->sys_name)) { ++ default: /* Unused, only to satisfy compiler. */ ++ case MDADM_STATUS_ERROR: /* error */ + pr_err("Cannot run child to monitor reshape: %s\n", + strerror(errno)); + abort_reshape(sra); + goto release; +- default: ++ case MDADM_STATUS_FORKED: /* child */ ++ map_fork(); ++ break; ++ case MDADM_STATUS_SUCCESS: /* parent */ + free(fdlist); + free(offsets); + sysfs_free(sra); + return 0; +- case 0: +- map_fork(); +- break; + } + + /* Close unused file descriptor in the forked process */ +@@ -3680,22 +3710,19 @@ int reshape_container(char *container, char *devname, + */ + ping_monitor(container); + +- if (!forked) +- if (continue_via_systemd(container, GROW_SERVICE, NULL)) +- return 0; +- +- switch (forked ? 0 : fork()) { +- case -1: /* error */ ++ switch (handle_forking(forked, container)) { ++ default: /* Unused, only to satisfy compiler. */ ++ case MDADM_STATUS_ERROR: /* error */ + perror("Cannot fork to complete reshape\n"); + unfreeze(st); + return 1; +- default: /* parent */ +- printf("%s: multi-array reshape continues in background\n", Name); +- return 0; +- case 0: /* child */ ++ case MDADM_STATUS_FORKED: /* child */ + manage_fork_fds(0); + map_fork(); + break; ++ case MDADM_STATUS_SUCCESS: /* parent */ ++ printf("%s: multi-array reshape continues in background\n", Name); ++ return 0; + } + + /* close unused handle in child process +@@ -3791,6 +3818,12 @@ int reshape_container(char *container, char *devname, + c->backup_file, c->verbose, 1, restart); + close(fd); + ++ /* Do not run reshape in initrd but let it initialize.*/ ++ if (in_initrd()) { ++ sysfs_free(cc); ++ exit(0); ++ } ++ + restart = 0; + if (rv) + break; +diff --git a/mdadm_status.h b/mdadm_status.h +index 905105e2..e244127c 100644 +--- a/mdadm_status.h ++++ b/mdadm_status.h +@@ -7,7 +7,8 @@ typedef enum mdadm_status { + MDADM_STATUS_SUCCESS = 0, + MDADM_STATUS_ERROR, + MDADM_STATUS_UNDEF, +- MDADM_STATUS_MEM_FAIL ++ MDADM_STATUS_MEM_FAIL, ++ MDADM_STATUS_FORKED + } mdadm_status_t; + + #endif +diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules +index 4e64b249..d8de6d00 100644 +--- a/udev-md-raid-arrays.rules ++++ b/udev-md-raid-arrays.rules +@@ -15,7 +15,6 @@ ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" + ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" + TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" + ATTR{md/array_state}=="clear*|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" +-ATTR{md/sync_action}=="reshape", ENV{RESHAPE_ACTIVE}="yes" + LABEL="md_ignore_state" + + IMPORT{program}="BINDIR/mdadm --detail --no-devices --export $devnode" +@@ -40,6 +39,6 @@ ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" + ENV{MD_LEVEL}=="raid[1-9]*", ENV{MD_CONTAINER}=="?*", PROGRAM="/usr/bin/readlink $env{MD_CONTAINER}", ENV{MD_MON_THIS}="%c" + ENV{MD_MON_THIS}=="?*", TEST=="/etc/initrd-release", PROGRAM="/usr/bin/basename $env{MD_MON_THIS}", ENV{SYSTEMD_WANTS}+="mdmon@initrd-%c.service" + ENV{MD_MON_THIS}=="?*", TEST!="/etc/initrd-release", PROGRAM="/usr/bin/basename $env{MD_MON_THIS}", ENV{SYSTEMD_WANTS}+="mdmon@%c.service" +-ENV{RESHAPE_ACTIVE}=="yes", PROGRAM="/usr/bin/basename $env{MD_MON_THIS}", ENV{SYSTEMD_WANTS}+="mdadm-grow-continue@%c.service" ++ENV{MD_RESHAPE_ACTIVE}=="True", PROGRAM="/usr/bin/basename $env{MD_MON_THIS}", ENV{SYSTEMD_WANTS}+="mdadm-grow-continue@%c.service" + + LABEL="md_end" +diff --git a/util.c b/util.c +index 6aa44a80..8099852f 100644 +--- a/util.c ++++ b/util.c +@@ -2307,6 +2307,7 @@ int continue_via_systemd(char *devnm, char *service_name, char *prefix) + int pid, status; + char pathbuf[1024]; + ++ dprintf("Start %s service\n", service_name); + /* Simply return that service cannot be started */ + if (check_env("MDADM_NO_SYSTEMCTL")) + return 0; +-- +2.41.0 + diff --git a/0010-super1-check-fd-before-passing-to-get_dev_size-in-ad.patch b/0010-super1-check-fd-before-passing-to-get_dev_size-in-ad.patch deleted file mode 100644 index 256b233..0000000 --- a/0010-super1-check-fd-before-passing-to-get_dev_size-in-ad.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 7ccf947eb595c1bb729c32ba18ce171dada76a68 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 11:56:11 +0100 -Subject: [PATCH 10/41] super1: check fd before passing to get_dev_size() in - add_to_super1() - -Check if file descriptor is valid before passing it to get_dev_size() in -add_to_super(). - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - super1.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/super1.c b/super1.c -index 871d19f0..5439b7bb 100644 ---- a/super1.c -+++ b/super1.c -@@ -1752,7 +1752,10 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk, - di->devname = devname; - di->disk = *dk; - di->data_offset = data_offset; -- get_dev_size(fd, NULL, &di->dev_size); -+ -+ if (is_fd_valid(fd)) -+ get_dev_size(fd, NULL, &di->dev_size); -+ - di->next = NULL; - *dip = di; - --- -2.40.1 - diff --git a/0011-Better-error-messages-for-broken-reshape.patch b/0011-Better-error-messages-for-broken-reshape.patch new file mode 100644 index 0000000..46a1fbe --- /dev/null +++ b/0011-Better-error-messages-for-broken-reshape.patch @@ -0,0 +1,48 @@ +From 70cba6ba8e83f2971d17ce6e36076d46191766d9 Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Thu, 10 Oct 2024 12:45:11 +0000 +Subject: [PATCH 11/37] Better error messages for broken reshape + +mdadm --grow --continue has no functionality to restore critical sectors +if reshape was stopped during operation. This functionality belongs to +assemble or incremental. + +This patch adds hints to error messages, to try to reassemble array in +case of reshape failure to restore critical sector, so assemble can +handle restoration. + +Signed-off-by: Mateusz Kusiak +--- + Grow.c | 1 + + super-intel.c | 3 ++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Grow.c b/Grow.c +index 2719346c..818eb6a4 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -2387,6 +2387,7 @@ static int verify_reshape_position(struct mdinfo *info, int level) + } else if (info->reshape_progress > position) { + pr_err("Fatal error: array reshape was not properly frozen (expected reshape position is %llu, but reshape progress is %llu.\n", + position, info->reshape_progress); ++ pr_err("Reassemble array to try to restore critical sector.\n"); + ret_val = -1; + } else { + dprintf("Reshape position in md and metadata are the same;"); +diff --git a/super-intel.c b/super-intel.c +index 7e3c5f2b..cab84198 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -12596,7 +12596,8 @@ static int imsm_manage_reshape( + init_migr_record_imsm(st, dev, sra); + else { + if (__le32_to_cpu(migr_rec->rec_status) != UNIT_SRC_NORMAL) { +- dprintf("imsm: cannot restart migration when data are present in copy area.\n"); ++ pr_err("imsm: Cannot restart migration when data are present in copy area.\n" ++ " Reassemble array to try to restore critical sector.\n"); + goto abort; + } + /* Save checkpoint to update migration record for current +-- +2.41.0 + diff --git a/0011-mdmon-refactor-md-device-name-check-in-main.patch b/0011-mdmon-refactor-md-device-name-check-in-main.patch deleted file mode 100644 index 7038b2d..0000000 --- a/0011-mdmon-refactor-md-device-name-check-in-main.patch +++ /dev/null @@ -1,66 +0,0 @@ -From c8772da4b53307546a9a374507bcec3398fc82c4 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 11:56:12 +0100 -Subject: [PATCH 11/41] mdmon: refactor md device name check in main() - -Refactor mdmon main function to verify if fd is valid prior to checking -device name. This is due to static code analysis complaining after -change b938519e7719 ("util: remove obsolete code from get_md_name"). - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - mdmon.c | 21 +++++++++++---------- - 1 file changed, 11 insertions(+), 10 deletions(-) - -diff --git a/mdmon.c b/mdmon.c -index a2038fe6..5fdb5cdb 100644 ---- a/mdmon.c -+++ b/mdmon.c -@@ -302,12 +302,12 @@ static int mdmon(char *devnm, int must_fork, int takeover); - int main(int argc, char *argv[]) - { - char *container_name = NULL; -- char *devnm = NULL; - int status = 0; - int opt; - int all = 0; - int takeover = 0; - int dofork = 1; -+ int mdfd = -1; - bool help = false; - static struct option options[] = { - {"all", 0, NULL, 'a'}, -@@ -410,19 +410,20 @@ int main(int argc, char *argv[]) - free_mdstat(mdstat); - - return status; -- } else { -- int mdfd = open_mddev(container_name, 0); -- devnm = fd2devnm(mdfd); -+ } -+ -+ mdfd = open_mddev(container_name, 0); -+ if (is_fd_valid(mdfd)) { -+ char *devnm = fd2devnm(mdfd); - - close(mdfd); -- } - -- if (!devnm) { -- pr_err("%s is not a valid md device name\n", -- container_name); -- return 1; -+ if (devnm) -+ return mdmon(devnm, dofork && do_fork(), takeover); - } -- return mdmon(devnm, dofork && do_fork(), takeover); -+ -+ pr_err("%s is not a valid md device name\n", container_name); -+ return 1; - } - - static int mdmon(char *devnm, int must_fork, int takeover) --- -2.40.1 - diff --git a/0012-Refactor-continue_via_systemd.patch b/0012-Refactor-continue_via_systemd.patch new file mode 100644 index 0000000..2ca2031 --- /dev/null +++ b/0012-Refactor-continue_via_systemd.patch @@ -0,0 +1,117 @@ +From 82ccad68d46d4b10a928bc860c0feedf26e483e3 Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Wed, 20 Nov 2024 19:01:30 +0000 +Subject: [PATCH 12/37] Refactor continue_via_systemd() + +Refactor continue_via_systemd() and it's calls to make it more readable. +No functional changes. + +Signed-off-by: Mateusz Kusiak +--- + Grow.c | 2 +- + mdadm.h | 2 +- + util.c | 43 ++++++++++++++++++++++++------------------- + 3 files changed, 26 insertions(+), 21 deletions(-) + +diff --git a/Grow.c b/Grow.c +index 818eb6a4..53b0b387 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -3013,7 +3013,7 @@ static mdadm_status_t handle_forking(bool forked, char *devname) + if (forked) + return MDADM_STATUS_FORKED; + +- if (devname && continue_via_systemd(devname, GROW_SERVICE, NULL)) ++ if (devname && continue_via_systemd(devname, GROW_SERVICE, NULL) == MDADM_STATUS_SUCCESS) + return MDADM_STATUS_SUCCESS; + + switch (fork()) { +diff --git a/mdadm.h b/mdadm.h +index 6062e167..e84c341c 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1694,7 +1694,7 @@ extern int same_dev(char *one, char *two); + extern int compare_paths (char* path1,char* path2); + extern void enable_fds(int devices); + extern void manage_fork_fds(int close_all); +-extern int continue_via_systemd(char *devnm, char *service_name, char *prefix); ++extern mdadm_status_t continue_via_systemd(char *devnm, char *service_name, char *prefix); + + extern void ident_init(struct mddev_ident *ident); + extern mdadm_status_t ident_set_devname(struct mddev_ident *ident, const char *devname); +diff --git a/util.c b/util.c +index 8099852f..8c45f0e1 100644 +--- a/util.c ++++ b/util.c +@@ -1982,7 +1982,7 @@ int start_mdmon(char *devnm) + + if (check_env("MDADM_NO_MDMON")) + return 0; +- if (continue_via_systemd(devnm, MDMON_SERVICE, prefix)) ++ if (continue_via_systemd(devnm, MDMON_SERVICE, prefix) == MDADM_STATUS_SUCCESS) + return 0; + + /* That failed, try running mdmon directly */ +@@ -2299,36 +2299,41 @@ void manage_fork_fds(int close_all) + /* In a systemd/udev world, it is best to get systemd to + * run daemon rather than running in the background. + * Returns: +- * 1- if systemd service has been started +- * 0- otherwise ++ * MDADM_STATUS_SUCCESS - if systemd service has been started. ++ * MDADM_STATUS_ERROR - otherwise. + */ +-int continue_via_systemd(char *devnm, char *service_name, char *prefix) ++mdadm_status_t continue_via_systemd(char *devnm, char *service_name, char *prefix) + { + int pid, status; +- char pathbuf[1024]; ++ char pathbuf[PATH_MAX]; + + dprintf("Start %s service\n", service_name); + /* Simply return that service cannot be started */ + if (check_env("MDADM_NO_SYSTEMCTL")) +- return 0; ++ return MDADM_STATUS_SUCCESS; ++ ++ /* Fork in attempt to start services */ + switch (fork()) { +- case 0: +- manage_fork_fds(1); +- snprintf(pathbuf, sizeof(pathbuf), +- "%s@%s%s.service", service_name, prefix ?: "", devnm); +- status = execl("/usr/bin/systemctl", "systemctl", "restart", +- pathbuf, NULL); +- status = execl("/bin/systemctl", "systemctl", "restart", +- pathbuf, NULL); +- exit(1); +- case -1: /* Just do it ourselves. */ ++ case -1: /* Fork failed, just do it ourselves. */ + break; +- default: /* parent - good */ ++ case 0: /* child */ ++ manage_fork_fds(1); ++ snprintf(pathbuf, sizeof(pathbuf), "%s@%s%s.service", ++ service_name, prefix ? prefix : "", devnm); ++ ++ /* Attempt to start service. ++ * On success execl() will "kill" the fork, and return status of systemctl call. ++ */ ++ execl("/usr/bin/systemctl", "systemctl", "restart", pathbuf, NULL); ++ execl("/bin/systemctl", "systemctl", "restart", pathbuf, NULL); ++ exit(MDADM_STATUS_ERROR); ++ default: /* parent */ ++ /* Check if forked process successfully trigered service */ + pid = wait(&status); + if (pid >= 0 && status == 0) +- return 1; ++ return MDADM_STATUS_SUCCESS; + } +- return 0; ++ return MDADM_STATUS_ERROR; + } + + int in_initrd(void) +-- +2.41.0 + diff --git a/0012-test-run-tests-on-system-level-mdadm.patch b/0012-test-run-tests-on-system-level-mdadm.patch deleted file mode 100644 index 8dea720..0000000 --- a/0012-test-run-tests-on-system-level-mdadm.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 4c12714d1ca06533fe7a887966df2558fd2f96b2 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 20 Feb 2024 17:04:44 +0100 -Subject: [PATCH 12/41] test: run tests on system level mdadm - -The tests run with MDADM_NO_SYSTEMCTL flag by default, however it has -no effect on udev. In case of external metadata, even if flag is set, -udev will trigger systemd to launch mdmon. - -This commit changes test execution level, so the tests are run on system -level mdadm, meaning local build must be installed prior to running -tests. - -Add warning that the tests are run on system level mdadm and local -build must be installed first. - -Do not call mdadm with "quiet" as it makes it not display critical -messages necessary for debug. - -Remove forcing speed_limit and add restoring system speed_limit_max -after test execution. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - test | 27 ++++++++++++++++++--------- - tests/func.sh | 1 - - 2 files changed, 18 insertions(+), 10 deletions(-) - -diff --git a/test b/test -index 49a36c3b..338c2db4 100755 ---- a/test -+++ b/test -@@ -1,11 +1,12 @@ - #!/bin/bash - # - # run test suite for mdadm --mdadm=$PWD/mdadm -+mdadm=`which mdadm` - targetdir="/var/tmp" - logdir="$targetdir" - config=/tmp/mdadm.conf - testdir=$PWD/tests -+system_speed_limit=`cat /proc/sys/dev/raid/speed_limit_max` - devlist= - - savelogs=0 -@@ -20,9 +21,6 @@ DEVTYPE=loop - INTEGRITY=yes - LVM_VOLGROUP=mdtest - --# make sure to test local mdmon, not system one --export MDADM_NO_SYSTEMCTL=1 -- - # assume md0, md1, md2 exist in /dev - md0=/dev/md0 - md1=/dev/md1 -@@ -41,7 +39,10 @@ ctrl_c() { - ctrl_c_error=1 - } - --# mdadm always adds --quiet, and we want to see any unexpected messages -+restore_system_speed_limit() { -+ echo $system_speed_limit > /proc/sys/dev/raid/speed_limit_max -+} -+ - mdadm() { - rm -f $targetdir/stderr - case $* in -@@ -63,10 +64,10 @@ mdadm() { - $mdadm --zero $args > /dev/null - } - done -- $mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes -+ $mdadm 2> $targetdir/stderr "$@" --auto=yes - ;; - * ) -- $mdadm 2> $targetdir/stderr --quiet "$@" -+ $mdadm 2> $targetdir/stderr "$@" - ;; - esac - rv=$? -@@ -99,8 +100,6 @@ do_test() { - fi - - rm -f $targetdir/stderr -- # this might have been reset: restore the default. -- echo 2000 > /proc/sys/dev/raid/speed_limit_max - do_clean - # source script in a subshell, so it has access to our - # namespace, but cannot change it. -@@ -122,6 +121,7 @@ do_test() { - echo " (KNOWN BROKEN TEST: $_broken_msg)" - fi - fi -+ restore_system_speed_limit - [ "$savelogs" == "1" ] && - mv -f $targetdir/log $logdir/$_basename.log - [ "$ctrl_c_error" == "1" ] && exit 1 -@@ -299,7 +299,15 @@ parse_args() { - done - } - -+print_warning() { -+ cat <<-EOF -+ Warning! Tests are performed on system level mdadm! -+ If you want to test local build, you need to install it first! -+ EOF -+} -+ - main() { -+ print_warning - do_setup - - echo "Testing on linux-$(uname -r) kernel" -@@ -329,6 +337,7 @@ main() { - break - fi - done -+ - exit 0 - } - -diff --git a/tests/func.sh b/tests/func.sh -index 1c1a28a2..b474442b 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -213,7 +213,6 @@ do_setup() { - path1=$dev7 - ulimit -c unlimited - [ -f /proc/mdstat ] || modprobe md_mod -- echo 2000 > /proc/sys/dev/raid/speed_limit_max - echo 0 > /sys/module/md_mod/parameters/start_ro - } - --- -2.40.1 - diff --git a/0013-Monitor-Allow-no-PID-in-check_one_sharer.patch b/0013-Monitor-Allow-no-PID-in-check_one_sharer.patch deleted file mode 100644 index 78650d7..0000000 --- a/0013-Monitor-Allow-no-PID-in-check_one_sharer.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 3c3ddeeccc1eb4accb62ce9920de430a564be806 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Wed, 28 Feb 2024 16:37:20 +0100 -Subject: [PATCH 13/41] Monitor: Allow no PID in check_one_sharer() - -Commit 5fb5479ad100 ("Monitor: open file before check in -check_one_sharer()") introduced a regression that prohibits monitor -from starting if PID file does not exist. - -Add check for no PID file. -Add missing fclose(). - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Monitor.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/Monitor.c b/Monitor.c -index 7cee95d4..9be2b528 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -453,12 +453,17 @@ static int check_one_sharer(int scan) - - fp = fopen(AUTOREBUILD_PID_PATH, "r"); - if (!fp) { -+ /* PID file does not exist */ -+ if (errno == ENOENT) -+ return 0; -+ - pr_err("Cannot open %s file.\n", AUTOREBUILD_PID_PATH); - return 2; - } - - if (!is_file(AUTOREBUILD_PID_PATH)) { - pr_err("%s is not a regular file.\n", AUTOREBUILD_PID_PATH); -+ fclose(fp); - return 2; - } - --- -2.40.1 - diff --git a/0013-mdadm-raid6check-add-xmalloc.h-to-raid6check.c.patch b/0013-mdadm-raid6check-add-xmalloc.h-to-raid6check.c.patch new file mode 100644 index 0000000..bbbd4ec --- /dev/null +++ b/0013-mdadm-raid6check-add-xmalloc.h-to-raid6check.c.patch @@ -0,0 +1,32 @@ +From e0df6c4c984d564e9e40913727e916a6cd8f466e Mon Sep 17 00:00:00 2001 +From: Xiao Ni +Date: Fri, 17 Jan 2025 15:15:40 +0800 +Subject: [PATCH 13/37] mdadm/raid6check: add xmalloc.h to raid6check.c + +It reports building error: +raid6check.c:324:26: error: implicit declaration of function xmalloc + +Add xmalloc.h to raid6check.c file to fix this. + +Signed-off-by: Xiao Ni +Link: https://lore.kernel.org/r/20250117071540.4094-1-xni@redhat.com +Signed-off-by: Song Liu +--- + raid6check.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/raid6check.c b/raid6check.c +index 99477761..95533f7d 100644 +--- a/raid6check.c ++++ b/raid6check.c +@@ -23,6 +23,7 @@ + */ + + #include "mdadm.h" ++#include "xmalloc.h" + #include + #include + +-- +2.41.0 + diff --git a/0014-mdopen-add-sbin-path-to-env-PATH-when-call-system-mo.patch b/0014-mdopen-add-sbin-path-to-env-PATH-when-call-system-mo.patch new file mode 100644 index 0000000..53b83ee --- /dev/null +++ b/0014-mdopen-add-sbin-path-to-env-PATH-when-call-system-mo.patch @@ -0,0 +1,56 @@ +From b1ee932b89a16c881a3336f9fd728d46c1f8c65d Mon Sep 17 00:00:00 2001 +From: Coly Li +Date: Wed, 22 Jan 2025 23:18:59 +0800 +Subject: [PATCH 14/37] mdopen: add sbin path to env PATH when call + system("modprobe md_mod") + +During the boot process if mdadm is called in udev context, sbin paths +like /sbin, /usr/sbin, /usr/local/sbin normally not defined in PATH env +variable, calling system("modprobe md_mod") in create_named_array() may +fail with 'sh: modprobe: command not found' error message. + +We don't want to move modprobe binary into udev private directory, so +setting the PATH env is a more proper method to avoid the above issue. + +This patch sets PATH env variable with "/sbin:/usr/sbin:/usr/local/sbin" +before calling system("modprobe md_mod"). The change only takes effect +within the udev worker context, not seen by global udev environment. + +Signed-off-by: Coly Li +Signed-off-by: Mariusz Tkaczyk +--- + mdopen.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/mdopen.c b/mdopen.c +index 26f0c716..57252b64 100644 +--- a/mdopen.c ++++ b/mdopen.c +@@ -39,6 +39,24 @@ int create_named_array(char *devnm) + + fd = open(new_array_file, O_WRONLY); + if (fd < 0 && errno == ENOENT) { ++ char buf[PATH_MAX] = {0}; ++ char *env_ptr; ++ ++ env_ptr = getenv("PATH"); ++ /* ++ * When called by udev worker context, path of modprobe ++ * might not be in env PATH. Set sbin paths into PATH ++ * env to avoid potential failure when run modprobe here. ++ */ ++ if (env_ptr) ++ snprintf(buf, PATH_MAX - 1, "%s:%s", env_ptr, ++ "/sbin:/usr/sbin:/usr/local/sbin"); ++ else ++ snprintf(buf, PATH_MAX - 1, "%s", ++ "/sbin:/usr/sbin:/usr/local/sbin"); ++ ++ setenv("PATH", buf, 1); ++ + if (system("modprobe md_mod") == 0) + fd = open(new_array_file, O_WRONLY); + } +-- +2.41.0 + diff --git a/0014-super-intel-respect-IMSM_DEVNAME_AS_SERIAL-flag.patch b/0014-super-intel-respect-IMSM_DEVNAME_AS_SERIAL-flag.patch deleted file mode 100644 index 5047232..0000000 --- a/0014-super-intel-respect-IMSM_DEVNAME_AS_SERIAL-flag.patch +++ /dev/null @@ -1,47 +0,0 @@ -From d1cd231ae41d98b2555dbff08d0c79876b5059fe Mon Sep 17 00:00:00 2001 -From: Kinga Tanska -Date: Tue, 27 Feb 2024 07:36:39 +0100 -Subject: [PATCH 14/41] super-intel: respect IMSM_DEVNAME_AS_SERIAL flag - -IMSM_DEVNAME_AS_SERIAL flag was respected only when searching -serial using nvme or scsi device wasn't successful. This -flag shall be applied first, to have user settings with -the highest priority. - -Signed-off-by: Kinga Tanska -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index e61f3f6f..4babec9f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -4174,17 +4174,17 @@ static int imsm_read_serial(int fd, char *devname, - - memset(buf, 0, sizeof(buf)); - -+ if (check_env("IMSM_DEVNAME_AS_SERIAL")) { -+ memset(serial, 0, serial_buf_len); -+ fd2devname(fd, (char *) serial); -+ return 0; -+ } -+ - rv = nvme_get_serial(fd, buf, sizeof(buf)); - - if (rv) - rv = scsi_get_serial(fd, buf, sizeof(buf)); - -- if (rv && check_env("IMSM_DEVNAME_AS_SERIAL")) { -- memset(serial, 0, MAX_RAID_SERIAL_LEN); -- fd2devname(fd, (char *) serial); -- return 0; -- } -- - if (rv != 0) { - if (devname) - pr_err("Failed to retrieve serial for %s\n", --- -2.40.1 - diff --git a/0015-mdadm-remove-TODO.patch b/0015-mdadm-remove-TODO.patch deleted file mode 100644 index 7c3e1c8..0000000 --- a/0015-mdadm-remove-TODO.patch +++ /dev/null @@ -1,236 +0,0 @@ -From a944da4e1a56cd926e6b21f5aaebc13198265419 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 23 Feb 2024 15:51:42 +0100 -Subject: [PATCH 15/41] mdadm: remove TODO - -This file is not updated in 16 years. -No reasons to keep it. Remove it. - -Signed-off-by: Mariusz Tkaczyk ---- - TODO | 213 ----------------------------------------------------------- - 1 file changed, 213 deletions(-) - delete mode 100644 TODO - -diff --git a/TODO b/TODO -deleted file mode 100644 -index 279d20db..00000000 ---- a/TODO -+++ /dev/null -@@ -1,213 +0,0 @@ -- - add 'name' field to metadata type and use it. -- - use validate_geometry more -- - metadata should be able to check/reject bitmap stuff. -- --DDF: -- Three new metadata types: -- ddf - used only to create a container. -- ddf-bvd - used to create an array in a container -- ddf-svd - used to create a secondary array from bvds. -- -- Usage: -- mdadm -C /dev/ddf1 /dev/sd[abcdef] -- mdadm -C /dev/md1 -e ddf /dev/sd[a-f] -- mdadm -C /dev/md1 -l container /dev/sd[a-f] -- -- Each of these create a new ddf container using all those -- devices. The name 'ddf*' signals that ddf metadata should be used. -- '-e ddf' only supports one level - 'container'. 'container' is only -- supported by ddf. -- -- mdadm -C /dev/md1 -l0 -n4 /dev/ddf1 # or maybe not ??? -- mdadm -C /dev/md1 -l1 -n2 /dev/sda /dev/sdb -- If exactly one device is given, and it is a container, we select -- devices from that container. -- If devices are given that are already in use, they must be in use by -- a container, and the array is created in the container. -- If devices given are bvds, we slip under the hood to make -- the svd arrays. -- -- mdadm -A /dev/ddf ...... -- base drives make a container. Anything in that container is started -- auto-read-only. -- if /dev/ddf is already assembled, we assemble bvds and svds inside it. -- -- --2005-dec-20 -- Want an incremental assembly mode to work nicely with udev. -- Core usage would be something like -- mdadm --incr-assemble /dev/newdevice -- This would -- - examine the device to determine uuid etc. -- - look for a match in /etc/mdadm.conf, abort if not found -- - find that device and collect current contents -- - perform an 'assemble' analysis to make sure we have the best set of devices. -- - remove or add devices as appropriate -- - possibly start the array if it was complete -- -- Other usages could involve -- - specify which array to auto-add to. -- This requires an existing array for uuid matching... is there any point? -- -- - -- -- --2004-june-02 -- * Don't print 'errors' flag, it is meaningless. DONE -- * Handle new superblock format -- * create device file on demand, particularly partitionable devices. DONE -- BUT figure a way to create the partition devices. -- auto=partN -- * Use Event: interface to listen for events. DONE, untested -- * Make sure mdadm -As can assemble multi-level RAIDs ok. -- * --build to build raid1 or multipath arrays -- clean or not ??? -- ------------------------------------------------------------------------------ --* mdadm --monitor to monitor failed multipath paths and re-instate them. -- --* Maybe make "--help" fit in 80x24 and have a --long-help with more info. DONE -- -- --* maybe "missing" instead of missing in doco DONE --* possibly wait for resync to start, or even finish while assembling.- NO -- --* -Db should have a devices= entry if possible. - DONE --* when assembling multipath arrays, ignore any error indicators. - DONE --* rationalise --monitor usage: -- mdadm --monitor -- doesn't do as expected. DONE -- --* --assemble could have a --update option. - DONE -- following word can be: -- sparc2.2 -- super-minor -- --* mdadm /dev/md11, where md11 is raid0 can segfault, particularly when looking in the -- [UU_UUU] string ... which doesn't exist ! --It should be more sensible. DONE -- --Example: -- --from Raimund Sacherer -- --mke2fs -m0 -q /dev/ram1 300 --mount -n -t ext2 /dev/ram1 /tmp --echo DEVICE /dev/[sh]* >> /tmp/mdadm.conf --mdadm -Esb /dev/[sh]* 2>/dev/null >> /tmp/mdadm.conf --mdadm -ARsc /tmp/mdadm.conf --umount /tmp -- -- --?? Allow -S /dev/md? - current complains subsequent not a/d/r - DONE -- --* new "Query" mode to subsume --detail and --examine. -- --query or -Q, takes a device and tells if it is an MD device, -- and also tells in a raid superblock is found. -- DONE -- --* write mdstat.c to parse /proc/mdstat file -- Build list of arrays: name, rebuild-percent -- DONE -- --* parse /proc/partitions and map major/minor into /dev/* names, -- and use that for default DEVICE list ???? -- --* --detail --scan to read /proc/mdstat, and then iterate over these, -- but assume --brief. --verbose can override -- check each subdevice to see if it is in conf_get_devs. -- Warn if not. -- DONE, but don't warn yet... -- --* Support multipath ... maybe... -- maybe DONE -- --* --follow to syslog -- --* --follow to move spares around DONE -- --* --follow to notice other events: DONE -- rebuild started -- spare activated -- spare removed -- spare added -- -------------------------------------- --- --examine --scan scans all drives and build an mdadm.conf file DONE -- --- check superblock checksum in examine DONE --- report "chunk" or "rounding" depending on raid level DONE --- report "linear" instead of "-1" for raid level DONE --- decode ayout depending on raid level DONE --- --verbose and --force flags. DONE -- --- set md_minor, *_disks for Create - DONE --- for create raid5, how to choose between -- all working, but not insync -- one missing, one spare, insync DONE (--force) --- and for raid1 - some failed drives... (missing) -- --- when RUN_ARRAY, make sure *_disks counts are right -- --- get --detail to extract extra stuff from superblock, -- like uuid DONE --- --detail --brief to give a config file line DONE --- parse config file. DONE --- test... -- --- when --assemble --scan, if an underlying device is an md device, -- then try to assemble that device first. -- -- --- mdadm -S /dev/md0 /dev/md1 gives internal error FIXED -- --- mdadm --detail --scan print summary of what it can find? DONE -- -- ----------- --Assemble doesn't add spares. - DONE --Create to allow "missing" name for devices. --Create to accept "--force" for do exactly what is requested --- get Assemble to upgrade devices if force flag. --ARRAY lines in config file to have super_minor=n --ARRAY lines in config file to have device=pattern, and only accept -- those devices -- If UUID given, insist on that -- If not, but super_minor given, require all found with that minor -- to have same uuid -- If only device given, all valid supers on those devices must have -- same uuid --allow /dev/mdX as first argument before any options --Possible --dry-run option for create and assemble--force -- --Assemble to check that all devices mentioned in superblock -- are present. -- --New mode: --Monitor (or --Follow) -- Periodically check status of all arrays (listed in config file). -- Log every event and apparent cause - or differences -- Email and alert - or run a program - for important events -- Move spares around if necessary. -- -- An Array line can have a spare-group= field that indicates that -- the array shares spares with other arrays with the same -- spare-group name. -- If an array has a failed and no spares, then check all other -- arrays in the spare group. If one has no failures and a spare, -- then consider that spare. -- Choose the smallest considered spare that is large enough. -- If there is one, then hot-remove it from it's home, and -- hot-add it to the array in question. -- -- --mail-to address -- --alert-handler program -- -- Will also extract information from /proc/mdstat if present, -- and consider 20% marks in rebuild as events. -- -- Events are: -- drive fails - causes mail to be sent -- rebuild started -- spare activated -- spare removed -- spare added --- -2.40.1 - diff --git a/0015-udev-persist-properties-of-MD-devices-after-switch_r.patch b/0015-udev-persist-properties-of-MD-devices-after-switch_r.patch new file mode 100644 index 0000000..6d61792 --- /dev/null +++ b/0015-udev-persist-properties-of-MD-devices-after-switch_r.patch @@ -0,0 +1,40 @@ +From 21e4efb1cd15c4de4a57de26b0ea2e4234aa8ce5 Mon Sep 17 00:00:00 2001 +From: Antonio Alvarez Feijoo +Date: Thu, 23 Jan 2025 19:46:38 +0100 +Subject: [PATCH 15/37] udev: persist properties of MD devices after + switch_root + +dracut installs in the initrd a custom udev rule for MD devices +(59-persistent-storage-md.rules) only to set the db_persist option (see +[1]). The main purpose is that if an MD device is activated in the initrd, +its properties are kept on the udev database after the transition from the +initrd to the rootfs. This was added to fix detection issues when LVM is +on top. + +This patch would allow to remove the custom udev rule shipped by dracut +(63-md-raid-arrays.rules is already being installed in the initrd), and it +will also benefit other initrd generators that do not want to create +custom udev rules. + +[1] https://github.com/dracutdevs/dracut/blob/master/modules.d/90mdraid + +Signed-off-by: Antonio Alvarez Feijoo +--- + udev-md-raid-arrays.rules | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules +index d8de6d00..a8098dc5 100644 +--- a/udev-md-raid-arrays.rules ++++ b/udev-md-raid-arrays.rules +@@ -29,6 +29,7 @@ ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNA + IMPORT{builtin}="blkid" + OPTIONS+="link_priority=100" + OPTIONS+="watch" ++OPTIONS+="db_persist" + ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" + ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" + ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" +-- +2.41.0 + diff --git a/0016-mdadm-fix-grow-with-add-for-linear.patch b/0016-mdadm-fix-grow-with-add-for-linear.patch new file mode 100644 index 0000000..90cb8d7 --- /dev/null +++ b/0016-mdadm-fix-grow-with-add-for-linear.patch @@ -0,0 +1,36 @@ +From c09ae8417dc9e11da1d5bf2867c6498050c6ddb9 Mon Sep 17 00:00:00 2001 +From: Yu Kuai +Date: Fri, 27 Dec 2024 14:07:02 +0800 +Subject: [PATCH 16/37] mdadm: fix --grow with --add for linear + +For the case mdadm --grow with --add, the s.btype should not be +initialized yet, hence BitmapUnknown should be checked instead of +BitmapNone. + +Noted that this behaviour should only support by md-linear, which is +removed from kernel, howerver, it turns out md-linear is used widely +in home NAS and we're planning to reintroduce it soon. + +Fixes: 581ba1341017 ("mdadm: remove bitmap file support") +Signed-off-by: Yu Kuai +Signed-off-by: Mariusz Tkaczyk +--- + mdadm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mdadm.c b/mdadm.c +index a72058b4..6200cd0e 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -1619,7 +1619,7 @@ int main(int argc, char *argv[]) + if (devs_found > 1 && s.raiddisks == 0 && s.level == UnSet) { + /* must be '-a'. */ + if (s.size > 0 || s.chunk || +- s.layout_str || s.btype != BitmapNone) { ++ s.layout_str || s.btype != BitmapUnknown) { + pr_err("--add cannot be used with other geometry changes in --grow mode\n"); + rv = 1; + break; +-- +2.41.0 + diff --git a/0016-mdadm-remove-makedist.patch b/0016-mdadm-remove-makedist.patch deleted file mode 100644 index 5905472..0000000 --- a/0016-mdadm-remove-makedist.patch +++ /dev/null @@ -1,119 +0,0 @@ -From 84d5e05d6fa6bbe6f4a3bdbdb1165dcc463b5207 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 23 Feb 2024 15:51:43 +0100 -Subject: [PATCH 16/41] mdadm: remove makedist - -Archives are generated kernel.org automation, no need to submit -them manually, so remove legacy solution. - -Signed-off-by: Mariusz Tkaczyk ---- - makedist | 96 -------------------------------------------------------- - 1 file changed, 96 deletions(-) - delete mode 100755 makedist - -diff --git a/makedist b/makedist -deleted file mode 100755 -index 0c4b39eb..00000000 ---- a/makedist -+++ /dev/null -@@ -1,96 +0,0 @@ --#!/bin/sh --# avoid silly sorting --export LANG=C --arg=$1 --target=~/public_html/source/mdadm --if [ " $arg" = " test" ] --then -- target=/tmp/mdadm-test -- rm -rf $target -- mkdir -p $target --fi --if [ -d $target ] --then : --else echo $target is not a directory -- exit 2 --fi --set `grep '^#define VERSION' ReadMe.c ` --version=`echo $3 | sed -e 's/"//g'` --grep "^.TH MDADM 8 .. v$version" mdadm.8.in > /dev/null 2>&1 || -- { -- echo mdadm.8.in does not mention version $version. -- exit 1 -- } --grep "^.TH MDMON 8 .. v$version" mdmon.8 > /dev/null 2>&1 || -- { -- echo mdmon.8 does not mention version $version. -- exit 1 -- } --rpmv=`echo $version | tr - _` --grep "^Version: *$rpmv$" mdadm.spec > /dev/null 2>&1 || -- { -- echo mdadm.spec does not mention version $version. -- exit 1 -- } --if [ -f ANNOUNCE-$version ] --then : --else -- echo ANNOUNCE-$version does not exist -- exit 1 --fi --if grep "^ANNOUNCE-$version\$" inventory --then : --else { cat inventory ; echo ANNOUNCE-$version ; } | sort -o inventory --fi -- --echo version = $version --base=mdadm-$rpmv.tar.gz --if [ " $arg" != " diff" ] --then -- if [ -f $target/$base ] -- then -- echo $target/$base exists. -- exit 1 -- fi -- trap "rm $target/$base; exit" 1 2 3 -- git archive --prefix=mdadm-$rpmv/ HEAD | gzip --best > $target/$base -- chmod a+r $target/$base -- ls -l $target/$base -- if tar tzf $target/$base | sed 's,[^/]*/,,' | sort | diff -u inventory - -- then : correct files found -- else echo "Extra files, or inventory is out-of-date" -- rm $target/$base -- exit 1 -- fi -- rpmbuild -ta $target/$base || exit 1 -- find ~/rpmbuild/RPMS -name "*mdadm-$version-*" \ -- -exec cp {} $target/RPM \; -- cp ANNOUNCE-$version $target/ANNOUNCE -- cp ChangeLog $target/ChangeLog -- if [ " $arg" != " test" ] -- then -- echo -n "Confirm signing this release? " -- read a -- if [ " $a" != " y" ]; then echo OK - bye. ; exit 1; fi -- if zcat $target/$base | gpg -ba > $target/$base.sign && gpg -ba $target/ANNOUNCE -- then -- kup put $target/$base $target/$base.sign \ -- /pub/linux/utils/raid/mdadm/mdadm-$version.tar.gz -- kup put $target/ANNOUNCE $target/ANNOUNCE.asc /pub/linux/utils/raid/mdadm/ANNOUNCE -- else -- echo signing failed -- exit 1 -- fi -- fi --else -- if [ ! -f $target/$base ] -- then -- echo $target/$base does not exist. -- exit 1 -- fi -- ( cd .. ; ln -s mdadm.v2 mdadm-$version ; tar chf - --exclude=.git --exclude="TAGS" --exclude='*,v' --exclude='*~' --exclude='*.o' --exclude mdadm --exclude=mdadm'.[^ch0-9]' --exclude=RCS mdadm-$version ; rm mdadm-$version ) | gzip --best > /var/tmp/mdadm-new.tgz -- mkdir /var/tmp/mdadm-old ; zcat $target/$base | ( cd /var/tmp/mdadm-old ; tar xf - ) -- mkdir /var/tmp/mdadm-new ; zcat /var/tmp/mdadm-new.tgz | ( cd /var/tmp/mdadm-new ; tar xf - ) -- diff -ru /var/tmp/mdadm-old /var/tmp/mdadm-new -- rm -rf /var/tmp/mdadm-old /var/tmp/mdadm-new /var/tmp/mdadm-new.tgz --fi --- -2.40.1 - diff --git a/0017-mdadm-remove-mdadm.spec.patch b/0017-mdadm-remove-mdadm.spec.patch deleted file mode 100644 index 7e1de14..0000000 --- a/0017-mdadm-remove-mdadm.spec.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 9cdcc193cec92c624841d5b70f1b96daafdc4314 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 23 Feb 2024 15:51:44 +0100 -Subject: [PATCH 17/41] mdadm: remove mdadm.spec - -This file is outdated, distributions have their own specs. - -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.spec | 47 ----------------------------------------------- - 1 file changed, 47 deletions(-) - delete mode 100644 mdadm.spec - -diff --git a/mdadm.spec b/mdadm.spec -deleted file mode 100644 -index 12e7859a..00000000 ---- a/mdadm.spec -+++ /dev/null -@@ -1,47 +0,0 @@ --Summary: mdadm is used for controlling Linux md devices (aka RAID arrays) --Name: mdadm --Version: 4.3 --Release: 1 --Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.gz --URL: https://neil.brown.name/blog/mdadm --License: GPL --Group: Utilities/System --BuildRoot: %{_tmppath}/%{name}-root --Obsoletes: mdctl -- --%description --mdadm is a program that can be used to create, manage, and monitor --Linux MD (Software RAID) devices. -- --%prep --%setup -q --# we want to install in /sbin, not /usr/sbin... --%define _exec_prefix %{nil} -- --%build --# This is a debatable issue. The author of this RPM spec file feels that --# people who install RPMs (especially given that the default RPM options --# will strip the binary) are not going to be running gdb against the --# program. --make CXFLAGS="$RPM_OPT_FLAGS" SYSCONFDIR="%{_sysconfdir}" -- --%install --make DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} BINDIR=%{_sbindir} install --install -D -m644 mdadm.conf-example $RPM_BUILD_ROOT/%{_sysconfdir}/mdadm.conf -- --%clean --rm -rf $RPM_BUILD_ROOT -- --%files --%defattr(-,root,root) --%doc TODO ChangeLog mdadm.conf-example COPYING --%{_sbindir}/mdadm --%{_sbindir}/mdmon --/usr/lib/udev/rules.d/01-md-raid-creating.rules --/usr/lib/udev/rules.d/63-md-raid-arrays.rules --/usr/lib/udev/rules.d/64-md-raid-assembly.rules --/usr/lib/udev/rules.d/69-md-clustered-confirm-device.rules --%config(noreplace,missingok)/%{_sysconfdir}/mdadm.conf --%{_mandir}/man*/md* -- --%changelog --- -2.40.1 - diff --git a/0017-platform-intel-Disable-legacy-option-ROM-scan-on-UEF.patch b/0017-platform-intel-Disable-legacy-option-ROM-scan-on-UEF.patch new file mode 100644 index 0000000..a15cce3 --- /dev/null +++ b/0017-platform-intel-Disable-legacy-option-ROM-scan-on-UEF.patch @@ -0,0 +1,41 @@ +From 1fc0f290caeb0720aa6c97177ab429953f5bf10f Mon Sep 17 00:00:00 2001 +From: Ross Lagerwall +Date: Wed, 29 Jan 2025 13:31:11 +0000 +Subject: [PATCH 17/37] platform-intel: Disable legacy option ROM scan on UEFI + machines + +The legacy option ROM memory range from 0xc0000-0xeffff is not defined +on UEFI machines so don't attempt to scan it. This avoids lockdown log +spam when Secure Boot is enabled (avoids use of /dev/mem). + +Signed-off-by: Ross Lagerwall +--- + platform-intel.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/platform-intel.c b/platform-intel.c +index 95bc4929..270aef36 100644 +--- a/platform-intel.c ++++ b/platform-intel.c +@@ -607,6 +607,7 @@ const struct imsm_orom *imsm_platform_test(struct sys_dev *hba) + + static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) + { ++ struct stat st; + unsigned long align; + + if (check_env("IMSM_TEST_OROM")) +@@ -616,6 +617,10 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) + if (check_env("IMSM_TEST_AHCI_EFI") || check_env("IMSM_TEST_SCU_EFI")) + return NULL; + ++ /* Skip legacy option ROM scan when EFI booted */ ++ if (stat("/sys/firmware/efi", &st) == 0 && S_ISDIR(st.st_mode)) ++ return NULL; ++ + find_intel_devices(); + + if (intel_devices == NULL) +-- +2.41.0 + diff --git a/0018-mdadm-remove-mkinitramfs-stuff.patch b/0018-mdadm-remove-mkinitramfs-stuff.patch deleted file mode 100644 index 4c32496..0000000 --- a/0018-mdadm-remove-mkinitramfs-stuff.patch +++ /dev/null @@ -1,209 +0,0 @@ -From 9282e1169f19676553a82dd49f780285a16e3b9a Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 23 Feb 2024 15:51:45 +0100 -Subject: [PATCH 18/41] mdadm: remove mkinitramfs stuff - -This script uses mdadm.static which is known to not be abandoned -(probably not working) from years. Mdadm is integrated with dracut -and mkinitramfs these days. - -Signed-off-by: Mariusz Tkaczyk ---- - README.initramfs | 122 ----------------------------------------------- - mkinitramfs | 55 --------------------- - 2 files changed, 177 deletions(-) - delete mode 100644 README.initramfs - delete mode 100644 mkinitramfs - -diff --git a/README.initramfs b/README.initramfs -deleted file mode 100644 -index c5fa6680..00000000 ---- a/README.initramfs -+++ /dev/null -@@ -1,122 +0,0 @@ --Assembling md arrays at boot time. ----------------------------------- --December 2005 -- --These notes apply to 2.6 kernels only and, in some cases, --to 2.6.15 or later. -- --Md arrays can be assembled at boot time using the 'autodetect' functionality --which is triggered by storing components of an array in partitions of type --'fd' - Linux Raid Autodetect. --They can also be assembled by specifying the component devices in a --kernel parameter such as -- md=0,/dev/sda,/dev/sdb --In this case, /dev/md0 will be assembled (because of the 0) from the listed --devices. -- --These mechanisms, while useful, do not provide complete functionality --and are unlikely to be extended. The preferred way to assemble md --arrays at boot time is using 'mdadm'. To assemble an array which --contains the root filesystem, mdadm needs to be run before that --filesystem is mounted, and so needs to be run from an initial-ram-fs. --It is how this can work that is the primary focus of this document. -- --It should be noted up front that only the array containing the root --filesystem should be assembled from the initramfs. Any other arrays --should be assembled under the control of files on the main filesystem --as this enhanced flexibility and maintainability. -- --A minimal initramfs for assembling md arrays can be created using 3 --files and one directory. These are: -- --/bin Directory --/bin/mdadm statically linked mdadm binary --/bin/busybox statically linked busybox binary --/bin/sh hard link to /bin/busybox --/init a shell script which call mdadm appropriately. -- --An example init script is: -- --============================================== --#!/bin/sh -- --echo 'Auto-assembling boot md array' --mkdir /proc --mount -t proc proc /proc --if [ -n "$rootuuid" ] --then arg=--uuid=$rootuuid --elif [ -n "$mdminor" ] --then arg=--super-minor=$mdminor --else arg=--super-minor=0 --fi --echo "Using $arg" --mdadm -Acpartitions $arg --auto=part /dev/mda --cd / --mount /dev/mda1 /root || mount /dev/mda /root --umount /proc --cd /root --exec chroot . /sbin/init < /dev/console > /dev/console 2>&1 --============================================= -- --This could certainly be extended, or merged into a larger init script. --Though tested and in production use, it is not presented here as --"The Right Way" to do it, but as a useful example. --Some key points are: -- -- /proc needs to be mounted so that /proc/partitions can be accessed -- by mdadm, and so that /proc/filesystems can be accessed by mount. -- -- The uuid of the array can be passed in as a kernel parameter -- (rootuuid). As the kernel doesn't use this value, it is made available -- in the environment for /init -- -- If no uuid is given, we default to md0, (--super-minor=0) which is a -- commonly used to store the root filesystem. This may not work in -- all situations. -- -- We assemble the array as a partitionable array (/dev/mda) even if we -- end up using the whole array. There is no cost in using the partitionable -- interface, and in this context it is simpler. -- -- We try mounting both /dev/mda1 and /dev/mda as they are the most like -- part of the array to contain the root filesystem. -- -- The --auto flag is given to mdadm so that it will create /dev/md* -- files automatically. This is needed as /dev will not contain -- and md files, and udev will not create them (as udev only created device -- files after the device exists, and mdadm need the device file to create -- the device). Note that the created md files may not exist in /dev -- of the mounted root filesystem. This needs to be deal with separately -- from mdadm - possibly using udev. -- -- We do not need to create device files for the components which will -- be assembled into /dev/mda. mdadm finds the major/minor numbers from -- /proc/partitions and creates a temporary /dev file if one doesn't already -- exist. -- --The script "mkinitramfs" which is included with the mdadm distribution --can be used to create a minimal initramfs. It creates a file called --'init.cpio.gz' which can be specified as an 'initrd' to lilo or grub --(or whatever boot loader is being used). -- -- -- -- --Resume from an md array ------------------------- -- --If you want to make use of the suspend-to-disk/resume functionality in Linux, --and want to have swap on an md array, you will need to assemble the array --before resume is possible. --However, because the array is active in the resumed image, you do not want --anything written to any drives during the resume process, such as superblock --updates or array resync. -- --This can be achieved in 2.6.15-rc1 and later kernels using the --'start_readonly' module parameter. --Simply include the command -- echo 1 > /sys/module/md_mod/parameters/start_ro --before assembling the array with 'mdadm'. --You can then echo -- 9:0 --or whatever is appropriate to /sys/power/resume to trigger the resume. -diff --git a/mkinitramfs b/mkinitramfs -deleted file mode 100644 -index c6275ddb..00000000 ---- a/mkinitramfs -+++ /dev/null -@@ -1,55 +0,0 @@ --#!/bin/sh -- --# make sure we are being run in the right directory... --if [ -f mkinitramfs ] --then : --else -- echo >&2 mkinitramfs must be run from the mdadm source directory. -- exit 1 --fi --if [ -f /bin/busybox ] --then : good, it exists -- case `file /bin/busybox` in -- *statically* ) : good ;; -- * ) echo >&2 mkinitramfs: /bin/busybox is not statically linked: cannot proceed. -- exit 1 -- esac --else -- echo >&2 "mkinitramfs: /bin/busybox doesn't exist - please install it statically linked." -- exit 1 --fi -- --rm -rf initramfs --mkdir initramfs --mkdir initramfs/bin --make mdadm.static --cp mdadm.static initramfs/bin/mdadm --cp /bin/busybox initramfs/bin/busybox --ln initramfs/bin/busybox initramfs/bin/sh --cat <<- END > initramfs/init -- #!/bin/sh -- -- echo 'Auto-assembling boot md array' -- mkdir /proc -- mount -t proc proc /proc -- if [ -n "$rootuuid" ] -- then arg=--uuid=$rootuuid -- elif [ -n "$mdminor" ] -- then arg=--super-minor=$mdminor -- else arg=--super-minor=0 -- fi -- echo "Using $arg" -- mdadm -Acpartitions $arg --auto=part /dev/mda -- cd / -- mount /dev/mda1 /root || mount /dev/mda /root -- umount /proc -- cd /root -- exec chroot . /sbin/init < /dev/console > /dev/console 2>&1 --END --chmod +x initramfs/init -- --(cd initramfs -- find init bin | cpio -o -H newc | gzip --best --) > init.cpio.gz --rm -rf initramfs --ls -l init.cpio.gz --- -2.40.1 - diff --git a/0018-super-ddf-Prevent-crash-when-handling-DDF-metadata.patch b/0018-super-ddf-Prevent-crash-when-handling-DDF-metadata.patch new file mode 100644 index 0000000..14f40d2 --- /dev/null +++ b/0018-super-ddf-Prevent-crash-when-handling-DDF-metadata.patch @@ -0,0 +1,61 @@ +From 9e8b3b1492cff63dafb759382c74a479460f49e6 Mon Sep 17 00:00:00 2001 +From: lilinzhe +Date: Mon, 16 Dec 2024 12:00:02 +0800 +Subject: [PATCH 18/37] super-ddf: Prevent crash when handling DDF metadata + +A dummy function is defined because availability of ss->update_super is +not always verified. + +This fix addresses a crash reported when assembling a RAID array using +mdadm with DDF metadata. For more details, see the discussion at: +https://lore.kernel.org/all/ +CALHdMH30LuxR4tz9jP2ykDaDJtZ3P7L3LrZ+9e4Fq=Q6NwSM=Q@mail.gmail.com/ + +The discussion centers on an issue with mdadm where attempting to +assemble a RAID array caused a null pointer dereference. The problem +was traced to a missing update_super() function in super-ddf.c, which +led to a crash in Assemble.c. + +Signed-off-by: lilinzhe +--- + super-ddf.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/super-ddf.c b/super-ddf.c +index 6cd099ab..a06ed435 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -5195,6 +5195,21 @@ static void default_geometry_ddf(struct supertype *st, int *level, int *layout, + *layout = ddf_level_to_layout(*level); + } + ++static int update_super_ddf_dummy(struct supertype *st, struct mdinfo *info, ++ enum update_opt update, ++ char *devname, int verbose, ++ int uuid_set, char *homehost) ++{ ++ /* ++ * A dummy update_super function is required to ensure ++ * reliable handling of DDF metadata in mdadm. ++ * This implementation acts as a placeholder for cases ++ * where ss->update_super is not verified. ++ */ ++ dprintf("update_super is not implemented in DDF\n"); ++ return 0; ++} ++ + struct superswitch super_ddf = { + .examine_super = examine_super_ddf, + .brief_examine_super = brief_examine_super_ddf, +@@ -5213,6 +5228,8 @@ struct superswitch super_ddf = { + .uuid_from_super= uuid_from_super_ddf, + .getinfo_super = getinfo_super_ddf, + ++ .update_super = update_super_ddf_dummy, ++ + .avail_size = avail_size_ddf, + + .compare_super = compare_super_ddf, +-- +2.41.0 + diff --git a/0019-mdadm-move-documentation-to-folder.patch b/0019-mdadm-move-documentation-to-folder.patch deleted file mode 100644 index dc9bcc8..0000000 --- a/0019-mdadm-move-documentation-to-folder.patch +++ /dev/null @@ -1,1044 +0,0 @@ -From 3aa5bb0af1051432a83b2f7a9fd5c2763444c937 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 23 Feb 2024 15:51:46 +0100 -Subject: [PATCH 19/41] mdadm: move documentation to folder - -Move documentation text files to directory. - -Signed-off-by: Mariusz Tkaczyk ---- - documentation/external-reshape-design.txt | 280 ++++++++++++++++++++++ - documentation/mdadm.conf-example | 65 +++++ - documentation/mdmon-design.txt | 146 +++++++++++ - external-reshape-design.txt | 280 ---------------------- - mdadm.conf-example | 65 ----- - mdmon-design.txt | 146 ----------- - 6 files changed, 491 insertions(+), 491 deletions(-) - create mode 100644 documentation/external-reshape-design.txt - create mode 100644 documentation/mdadm.conf-example - create mode 100644 documentation/mdmon-design.txt - delete mode 100644 external-reshape-design.txt - delete mode 100644 mdadm.conf-example - delete mode 100644 mdmon-design.txt - -diff --git a/documentation/external-reshape-design.txt b/documentation/external-reshape-design.txt -new file mode 100644 -index 00000000..e4cf4e16 ---- /dev/null -+++ b/documentation/external-reshape-design.txt -@@ -0,0 +1,280 @@ -+External Reshape -+ -+1 Problem statement -+ -+External (third-party metadata) reshape differs from native-metadata -+reshape in three key ways: -+ -+1.1 Format specific constraints -+ -+In the native case reshape is limited by what is implemented in the -+generic reshape routine (Grow_reshape()) and what is supported by the -+kernel. There are exceptional cases where Grow_reshape() may block -+operations when it knows that the kernel implementation is broken, but -+otherwise the kernel is relied upon to be the final arbiter of what -+reshape operations are supported. -+ -+In the external case the kernel, and the generic checks in -+Grow_reshape(), become the super-set of what reshapes are possible. The -+metadata format may not support, or have yet to implement a given -+reshape type. The implication for Grow_reshape() is that it must query -+the metadata handler and effect changes in the metadata before the new -+geometry is posted to the kernel. The ->reshape_super method allows -+Grow_reshape() to validate the requested operation and post the metadata -+update. -+ -+1.2 Scope of reshape -+ -+Native metadata reshape is always performed at the array scope (no -+metadata relationship with sibling arrays on the same disks). External -+reshape, depending on the format, may not allow the number of member -+disks to be changed in a subarray unless the change is simultaneously -+applied to all subarrays in the container. For example the imsm format -+requires all member disks to be a member of all subarrays, so a 4-disk -+raid5 in a container that also houses a 4-disk raid10 array could not be -+reshaped to 5 disks as the imsm format does not support a 5-disk raid10 -+representation. This requires the ->reshape_super method to check the -+contents of the array and ask the user to run the reshape at container -+scope (if all subarrays are agreeable to the change), or report an -+error in the case where one subarray cannot support the change. -+ -+1.3 Monitoring / checkpointing -+ -+Reshape, unlike rebuild/resync, requires strict checkpointing to survive -+interrupted reshape operations. For example when expanding a raid5 -+array the first few stripes of the array will be overwritten in a -+destructive manner. When restarting the reshape process we need to know -+the exact location of the last successfully written stripe, and we need -+to restore the data in any partially overwritten stripe. Native -+metadata stores this backup data in the unused portion of spares that -+are being promoted to array members, or in an external backup file -+(located on a non-involved block device). -+ -+The kernel is in charge of recording checkpoints of reshape progress, -+but mdadm is delegated the task of managing the backup space which -+involves: -+1/ Identifying what data will be overwritten in the next unit of reshape -+ operation -+2/ Suspending access to that region so that a snapshot of the data can -+ be transferred to the backup space. -+3/ Allowing the kernel to reshape the saved region and setting the -+ boundary for the next backup. -+ -+In the external reshape case we want to preserve this mdadm -+'reshape-manager' arrangement, but have a third actor, mdmon, to -+consider. It is tempting to give the role of managing reshape to mdmon, -+but that is counter to its role as a monitor, and conflicts with the -+existing capabilities and role of mdadm to manage the progress of -+reshape. For clarity the external reshape implementation maintains the -+role of mdmon as a (mostly) passive recorder of raid events, and mdadm -+treats it as it would the kernel in the native reshape case (modulo -+needing to send explicit metadata update messages and checking that -+mdmon took the expected action). -+ -+External reshape can use the generic md backup file as a fallback, but in the -+optimal/firmware-compatible case the reshape-manager will use the metadata -+specific areas for managing reshape. The implementation also needs to spawn a -+reshape-manager per subarray when the reshape is being carried out at the -+container level. For these two reasons the ->manage_reshape() method is -+introduced. This method in addition to base tasks mentioned above: -+1/ Processed each subarray one at a time in series - where appropriate. -+2/ Uses either generic routines in Grow.c for md-style backup file -+ support, or uses the metadata-format specific location for storing -+ recovery data. -+This aims to avoid a "midlayer mistake"[1] and lets the metadata handler -+optionally take advantage of generic infrastructure in Grow.c -+ -+2 Details for specific reshape requests -+ -+There are quite a few moving pieces spread out across md, mdadm, and mdmon for -+the support of external reshape, and there are several different types of -+reshape that need to be comprehended by the implementation. A rundown of -+these details follows. -+ -+2.0 General provisions: -+ -+Obtain an exclusive open on the container to make sure we are not -+running concurrently with a Create() event. -+ -+2.1 Freezing sync_action -+ -+ Before making any attempt at a reshape we 'freeze' every array in -+ the container to ensure no spare assignment or recovery happens. -+ This involves writing 'frozen' to sync_action and changing the '/' -+ after 'external:' in metadata_version to a '-'. mdmon knows that -+ this means not to perform any management. -+ -+ Before doing this we check that all sync_actions are 'idle', which -+ is racy but still useful. -+ Afterwards we check that all member arrays have no spares -+ or partial spares (recovery_start != 'none') which would indicate a -+ race. If they do, we unfreeze again. -+ -+ Once this completes we know all the arrays are stable. They may -+ still have failed devices as devices can fail at any time. However -+ we treat those like failures that happen during the reshape. -+ -+2.2 Reshape size -+ -+ 1/ mdadm::Grow_reshape(): checks if mdmon is running and optionally -+ initializes st->update_tail -+ 2/ mdadm::Grow_reshape() calls ->reshape_super() to check that the size change -+ is allowed (being performed at subarray scope / enough room) prepares a -+ metadata update -+ 3/ mdadm::Grow_reshape(): flushes the metadata update (via -+ flush_metadata_update(), or ->sync_metadata()) -+ 4/ mdadm::Grow_reshape(): post the new size to the kernel -+ -+ -+2.3 Reshape level (simple-takeover) -+ -+"simple-takeover" implies the level change can be satisfied without touching -+sync_action -+ -+ 1/ mdadm::Grow_reshape(): checks if mdmon is running and optionally -+ initializes st->update_tail -+ 2/ mdadm::Grow_reshape() calls ->reshape_super() to check that the level change -+ is allowed (being performed at subarray scope) prepares a -+ metadata update -+ 2a/ raid10 --> raid0: degrade all mirror legs prior to calling -+ ->reshape_super -+ 3/ mdadm::Grow_reshape(): flushes the metadata update (via -+ flush_metadata_update(), or ->sync_metadata()) -+ 4/ mdadm::Grow_reshape(): post the new level to the kernel -+ -+2.4 Reshape chunk, layout -+ -+2.5 Reshape raid disks (grow) -+ -+ 1/ mdadm::Grow_reshape(): unconditionally initializes st->update_tail -+ because only redundant raid levels can modify the number of raid disks -+ 2/ mdadm::Grow_reshape(): calls ->reshape_super() to check that the level -+ change is allowed (being performed at proper scope / permissible -+ geometry / proper spares available in the container), chooses -+ the spares to use, and prepares a metadata update. -+ 3/ mdadm::Grow_reshape(): Converts each subarray in the container to the -+ raid level that can perform the reshape and starts mdmon. -+ 4/ mdadm::Grow_reshape(): Pushes the update to mdmon. -+ 5/ mdadm::Grow_reshape(): uses container_content to find details of -+ the spares and passes them to the kernel. -+ 6/ mdadm::Grow_reshape(): gives raid_disks update to the kernel, -+ sets sync_max, sync_min, suspend_lo, suspend_hi all to zero, -+ and starts the reshape by writing 'reshape' to sync_action. -+ 7/ mdmon::monitor notices the sync_action change and tells -+ managemon to check for new devices. managemon notices the new -+ devices, opens relevant sysfs file, and passes them all to -+ monitor. -+ 8/ mdadm::Grow_reshape() calls ->manage_reshape to oversee the -+ rest of the reshape. -+ -+ 9/ mdadm::->manage_reshape(): saves data that will be overwritten by -+ the kernel to either the backup file or the metadata specific location, -+ advances sync_max, waits for reshape, ping mdmon, repeat. -+ Meanwhile mdmon::read_and_act(): records checkpoints. -+ Specifically. -+ -+ 9a/ if the 'next' stripe to be reshaped will over-write -+ itself during reshape then: -+ 9a.1/ increase suspend_hi to cover a suitable number of -+ stripes. -+ 9a.2/ backup those stripes safely. -+ 9a.3/ advance sync_max to allow those stripes to be backed up -+ 9a.4/ when sync_completed indicates that those stripes have -+ been reshaped, manage_reshape must ping_manager -+ 9a.5/ when mdmon notices that sync_completed has been updated, -+ it records the new checkpoint in the metadata -+ 9a.6/ after the ping_manager, manage_reshape will increase -+ suspend_lo to allow access to those stripes again -+ -+ 9b/ if the 'next' stripe to be reshaped will over-write unused -+ space during reshape then we apply same process as above, -+ except that there is no need to back anything up. -+ Note that we *do* need to keep suspend_hi progressing as -+ it is not safe to write to the area-under-reshape. For -+ kernel-managed-metadata this protection is provided by -+ ->reshape_safe, but that does not protect us in the case -+ of user-space-managed-metadata. -+ -+ 10/ mdadm::->manage_reshape(): Once reshape completes changes the raid -+ level back to the nominal raid level (if necessary) -+ -+ FIXME: native metadata does not have the capability to record the original -+ raid level in reshape-restart case because the kernel always records current -+ raid level to the metadata, whereas external metadata can masquerade at an -+ alternate level based on the reshape state. -+ -+2.6 Reshape raid disks (shrink) -+ -+3 Interaction with metadata handle. -+ -+ The following calls are made into the metadata handler to assist -+ with initiating and monitoring a 'reshape'. -+ -+ 1/ ->reshape_super is called quite early (after only minimial -+ checks) to make sure that the metadata can record the new shape -+ and any necessary transitions. It may be passed a 'container' -+ or an individual array within a container, and it should notice -+ the difference and act accordingly. -+ When a reshape is requested against a container it is expected -+ that it should be applied to every array in the container, -+ however it is up to the metadata handler to determine final -+ policy. -+ -+ If the reshape is supportable, the internal copy of the metadata -+ should be updated, and a metadata update suitable for sending -+ to mdmon should be queued. -+ -+ If the reshape will involve converting spares into array members, -+ this must be recorded in the metadata too. -+ -+ 2/ ->container_content will be called to find out the new state -+ of all the array, or all arrays in the container. Any newly -+ added devices (with state==0 and raid_disk >= 0) will be added -+ to the array as spares with the relevant slot number. -+ -+ It is likely that the info returned by ->container_content will -+ have ->reshape_active set, ->reshape_progress set to e.g. 0, and -+ new_* set appropriately. mdadm will use this information to -+ cause the correct reshape to start at an appropriate time. -+ -+ 3/ ->set_array_state will be called by mdmon when reshape has -+ started and again periodically as it progresses. This should -+ record the ->last_checkpoint as the point where reshape has -+ progressed to. When the reshape finished this will be called -+ again and it should notice that ->curr_action is no longer -+ 'reshape' and so should record that the reshape has finished -+ providing 'last_checkpoint' has progressed suitably. -+ -+ 4/ ->manage_reshape will be called once the reshape has been set -+ up in the kernel but before sync_max has been moved from 0, so -+ no actual reshape will have happened. -+ -+ ->manage_reshape should call progress_reshape() to allow the -+ reshape to progress, and should back-up any data as indicated -+ by the return value. See the documentation of that function -+ for more details. -+ ->manage_reshape will be called multiple times when a -+ container is being reshaped, once for each member array in -+ the container. -+ -+ -+ The progress of the metadata is as follows: -+ 1/ mdadm sends a metadata update to mdmon which marks the array -+ as undergoing a reshape. This is set up by -+ ->reshape_super and applied by ->process_update -+ For container-wide reshape, this happens once for the whole -+ container. -+ 2/ mdmon notices progress via the sysfs files and calls -+ ->set_array_state to update the state periodically -+ For container-wide reshape, this happens repeatedly for -+ one array, then repeatedly for the next, etc. -+ 3/ mdmon notices when reshape has finished and call -+ ->set_array_state to record the the reshape is complete. -+ For container-wide reshape, this happens once for each -+ member array. -+ -+ -+ -+... -+ -+[1]: Linux kernel design patterns - part 3, Neil Brown https://lwn.net/Articles/336262/ -diff --git a/documentation/mdadm.conf-example b/documentation/mdadm.conf-example -new file mode 100644 -index 00000000..35a75d12 ---- /dev/null -+++ b/documentation/mdadm.conf-example -@@ -0,0 +1,65 @@ -+# mdadm configuration file -+# -+# mdadm will function properly without the use of a configuration file, -+# but this file is useful for keeping track of arrays and member disks. -+# In general, a mdadm.conf file is created, and updated, after arrays -+# are created. This is the opposite behavior of /etc/raidtab which is -+# created prior to array construction. -+# -+# -+# the config file takes two types of lines: -+# -+# DEVICE lines specify a list of devices of where to look for -+# potential member disks -+# -+# ARRAY lines specify information about how to identify arrays so -+# so that they can be activated -+# -+# You can have more than one device line and use wild cards. The first -+# example includes SCSI the first partition of SCSI disks /dev/sdb, -+# /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second -+# line looks for array slices on IDE disks. -+# -+#DEVICE /dev/sd[bcdjkl]1 -+#DEVICE /dev/hda1 /dev/hdb1 -+# -+# If you mount devfs on /dev, then a suitable way to list all devices is: -+#DEVICE /dev/discs/*/* -+# -+# -+# The AUTO line can control which arrays get assembled by auto-assembly, -+# meaing either "mdadm -As" when there are no 'ARRAY' lines in this file, -+# or "mdadm --incremental" when the array found is not listed in this file. -+# By default, all arrays that are found are assembled. -+# If you want to ignore all DDF arrays (maybe they are managed by dmraid), -+# and only assemble 1.x arrays if which are marked for 'this' homehost, -+# but assemble all others, then use -+#AUTO -ddf homehost -1.x +all -+# -+# ARRAY lines specify an array to assemble and a method of identification. -+# Arrays can currently be identified by using a UUID, superblock minor number, -+# or a listing of devices. -+# -+# super-minor is usually the minor number of the metadevice -+# UUID is the Universally Unique Identifier for the array -+# Each can be obtained using -+# -+# mdadm -D -+# -+#ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371 -+#ARRAY /dev/md1 super-minor=1 -+#ARRAY /dev/md2 devices=/dev/hda1,/dev/hdb1 -+# -+# ARRAY lines can also specify a "spare-group" for each array. mdadm --monitor -+# will then move a spare between arrays in a spare-group if one array has a failed -+# drive but no spare -+#ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1 -+#ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1 -+# -+# When used in --follow (aka --monitor) mode, mdadm needs a -+# mail address and/or a program. This can be given with "mailaddr" -+# and "program" lines to that monitoring can be started using -+# mdadm --follow --scan & echo $! > /run/mdadm/mon.pid -+# If the lines are not found, mdadm will exit quietly -+#MAILADDR root@mydomain.tld -+#PROGRAM /usr/sbin/handle-mdadm-events -diff --git a/documentation/mdmon-design.txt b/documentation/mdmon-design.txt -new file mode 100644 -index 00000000..f09184a9 ---- /dev/null -+++ b/documentation/mdmon-design.txt -@@ -0,0 +1,146 @@ -+ -+When managing a RAID1 array which uses metadata other than the -+"native" metadata understood by the kernel, mdadm makes use of a -+partner program named 'mdmon' to manage some aspects of updating -+that metadata and synchronising the metadata with the array state. -+ -+This document provides some details on how mdmon works. -+ -+Containers -+---------- -+ -+As background: mdadm makes a distinction between an 'array' and a -+'container'. Other sources sometimes use the term 'volume' or -+'device' for an 'array', and may use the term 'array' for a -+'container'. -+ -+For our purposes: -+ - a 'container' is a collection of devices which are described by a -+ single set of metadata. The metadata may be stored equally -+ on all devices, or different devices may have quite different -+ subsets of the total metadata. But there is conceptually one set -+ of metadata that unifies the devices. -+ -+ - an 'array' is a set of datablock from various devices which -+ together are used to present the abstraction of a single linear -+ sequence of block, which may provide data redundancy or enhanced -+ performance. -+ -+So a container has some metadata and provides a number of arrays which -+are described by that metadata. -+ -+Sometimes this model doesn't work perfectly. For example, global -+spares may have their own metadata which is quite different from the -+metadata from any device that participates in one or more arrays. -+Such a global spare might still need to belong to some container so -+that it is available to be used should a failure arise. In that case -+we consider the 'metadata' to be the union of the metadata on the -+active devices which describes the arrays, and the metadata on the -+global spares which only describes the spares. In this case different -+devices in the one container will have quite different metadata. -+ -+ -+Purpose -+------- -+ -+The main purpose of mdmon is to update the metadata in response to -+changes to the array which need to be reflected in the metadata before -+futures writes to the array can safely be performed. -+These include: -+ - transitions from 'clean' to 'dirty'. -+ - recording the devices have failed. -+ - recording the progress of a 'reshape' -+ -+This requires mdmon to be running at any time that the array is -+writable (a read-only array does not require mdmon to be running). -+ -+Because mdmon must be able to process these metadata updates at any -+time, it must (when running) have exclusive write access to the -+metadata. Any other changes (e.g. reconfiguration of the array) must -+go through mdmon. -+ -+A secondary role for mdmon is to activate spares when a device fails. -+This role is much less time-critical than the other metadata updates, -+so it could be performed by a separate process, possibly -+"mdadm --monitor" which has a related role of moving devices between -+arrays. A main reason for including this functionality in mdmon is -+that in the native-metadata case this function is handled in the -+kernel, and mdmon's reason for existence to provide functionality -+which is otherwise handled by the kernel. -+ -+ -+Design overview -+--------------- -+ -+mdmon is structured as two threads with a common address space and -+common data structures. These threads are know as the 'monitor' and -+the 'manager'. -+ -+The 'monitor' has the primary role of monitoring the array for -+important state changes and updating the metadata accordingly. As -+writes to the array can be blocked until 'monitor' completes and -+acknowledges the update, it much be very careful not to block itself. -+In particular it must not block waiting for any write to complete else -+it could deadlock. This means that it must not allocate memory as -+doing this can require dirty memory to be written out and if the -+system choose to write to the array that mdmon is monitoring, the -+memory allocation could deadlock. -+ -+So 'monitor' must never allocate memory and must limit the number of -+other system call it performs. It may: -+ - use select (or poll) to wait for activity on a file descriptor -+ - read from a sysfs file descriptor -+ - write to a sysfs file descriptor -+ - write the metadata out to the block devices using O_DIRECT -+ - send a signal (kill) to the manager thread -+ -+It must not e.g. open files or do anything similar that might allocate -+resources. -+ -+The 'manager' thread does everything else that is needed. If any -+files are to be opened (e.g. because a device has been added to the -+array), the manager does that. If any memory needs to be allocated -+(e.g. to hold data about a new array as can happen when one set of -+metadata describes several arrays), the manager performs that -+allocation. -+ -+The 'manager' is also responsible for communicating with mdadm and -+assigning spares to replace failed devices. -+ -+ -+Handling metadata updates -+------------------------- -+ -+There are a number of cases in which mdadm needs to update the -+metdata which mdmon is managing. These include: -+ - creating a new array in an active container -+ - adding a device to a container -+ - reconfiguring an array -+etc. -+ -+To complete these updates, mdadm must send a message to mdmon which -+will merge the update into the metadata as it is at that moment. -+ -+To achieve this, mdmon creates a Unix Domain Socket which the manager -+thread listens on. mdadm sends a message over this socket. The -+manager thread examines the message to see if it will require -+allocating any memory and allocates it. This is done in the -+'prepare_update' metadata method. -+ -+The update message is then queued for handling by the monitor thread -+which it will do when convenient. The monitor thread calls -+->process_update which should atomically make the required changes to -+the metadata, making use of the pre-allocate memory as required. Any -+memory the is no-longer needed can be placed back in the request and -+the manager thread will free it. -+ -+The exact format of a metadata update is up to the implementer of the -+metadata handlers. It will simply describe a change that needs to be -+made. It will sometimes contain fragments of the metadata to be -+copied in to place. However the ->process_update routine must make -+sure not to over-write any field that the monitor thread might have -+updated, such as a 'device failed' or 'array is dirty' state. -+ -+When the monitor thread has completed the update and written it to the -+devices, an acknowledgement message is sent back over the socket so -+that mdadm knows it is complete. -diff --git a/external-reshape-design.txt b/external-reshape-design.txt -deleted file mode 100644 -index e4cf4e16..00000000 ---- a/external-reshape-design.txt -+++ /dev/null -@@ -1,280 +0,0 @@ --External Reshape -- --1 Problem statement -- --External (third-party metadata) reshape differs from native-metadata --reshape in three key ways: -- --1.1 Format specific constraints -- --In the native case reshape is limited by what is implemented in the --generic reshape routine (Grow_reshape()) and what is supported by the --kernel. There are exceptional cases where Grow_reshape() may block --operations when it knows that the kernel implementation is broken, but --otherwise the kernel is relied upon to be the final arbiter of what --reshape operations are supported. -- --In the external case the kernel, and the generic checks in --Grow_reshape(), become the super-set of what reshapes are possible. The --metadata format may not support, or have yet to implement a given --reshape type. The implication for Grow_reshape() is that it must query --the metadata handler and effect changes in the metadata before the new --geometry is posted to the kernel. The ->reshape_super method allows --Grow_reshape() to validate the requested operation and post the metadata --update. -- --1.2 Scope of reshape -- --Native metadata reshape is always performed at the array scope (no --metadata relationship with sibling arrays on the same disks). External --reshape, depending on the format, may not allow the number of member --disks to be changed in a subarray unless the change is simultaneously --applied to all subarrays in the container. For example the imsm format --requires all member disks to be a member of all subarrays, so a 4-disk --raid5 in a container that also houses a 4-disk raid10 array could not be --reshaped to 5 disks as the imsm format does not support a 5-disk raid10 --representation. This requires the ->reshape_super method to check the --contents of the array and ask the user to run the reshape at container --scope (if all subarrays are agreeable to the change), or report an --error in the case where one subarray cannot support the change. -- --1.3 Monitoring / checkpointing -- --Reshape, unlike rebuild/resync, requires strict checkpointing to survive --interrupted reshape operations. For example when expanding a raid5 --array the first few stripes of the array will be overwritten in a --destructive manner. When restarting the reshape process we need to know --the exact location of the last successfully written stripe, and we need --to restore the data in any partially overwritten stripe. Native --metadata stores this backup data in the unused portion of spares that --are being promoted to array members, or in an external backup file --(located on a non-involved block device). -- --The kernel is in charge of recording checkpoints of reshape progress, --but mdadm is delegated the task of managing the backup space which --involves: --1/ Identifying what data will be overwritten in the next unit of reshape -- operation --2/ Suspending access to that region so that a snapshot of the data can -- be transferred to the backup space. --3/ Allowing the kernel to reshape the saved region and setting the -- boundary for the next backup. -- --In the external reshape case we want to preserve this mdadm --'reshape-manager' arrangement, but have a third actor, mdmon, to --consider. It is tempting to give the role of managing reshape to mdmon, --but that is counter to its role as a monitor, and conflicts with the --existing capabilities and role of mdadm to manage the progress of --reshape. For clarity the external reshape implementation maintains the --role of mdmon as a (mostly) passive recorder of raid events, and mdadm --treats it as it would the kernel in the native reshape case (modulo --needing to send explicit metadata update messages and checking that --mdmon took the expected action). -- --External reshape can use the generic md backup file as a fallback, but in the --optimal/firmware-compatible case the reshape-manager will use the metadata --specific areas for managing reshape. The implementation also needs to spawn a --reshape-manager per subarray when the reshape is being carried out at the --container level. For these two reasons the ->manage_reshape() method is --introduced. This method in addition to base tasks mentioned above: --1/ Processed each subarray one at a time in series - where appropriate. --2/ Uses either generic routines in Grow.c for md-style backup file -- support, or uses the metadata-format specific location for storing -- recovery data. --This aims to avoid a "midlayer mistake"[1] and lets the metadata handler --optionally take advantage of generic infrastructure in Grow.c -- --2 Details for specific reshape requests -- --There are quite a few moving pieces spread out across md, mdadm, and mdmon for --the support of external reshape, and there are several different types of --reshape that need to be comprehended by the implementation. A rundown of --these details follows. -- --2.0 General provisions: -- --Obtain an exclusive open on the container to make sure we are not --running concurrently with a Create() event. -- --2.1 Freezing sync_action -- -- Before making any attempt at a reshape we 'freeze' every array in -- the container to ensure no spare assignment or recovery happens. -- This involves writing 'frozen' to sync_action and changing the '/' -- after 'external:' in metadata_version to a '-'. mdmon knows that -- this means not to perform any management. -- -- Before doing this we check that all sync_actions are 'idle', which -- is racy but still useful. -- Afterwards we check that all member arrays have no spares -- or partial spares (recovery_start != 'none') which would indicate a -- race. If they do, we unfreeze again. -- -- Once this completes we know all the arrays are stable. They may -- still have failed devices as devices can fail at any time. However -- we treat those like failures that happen during the reshape. -- --2.2 Reshape size -- -- 1/ mdadm::Grow_reshape(): checks if mdmon is running and optionally -- initializes st->update_tail -- 2/ mdadm::Grow_reshape() calls ->reshape_super() to check that the size change -- is allowed (being performed at subarray scope / enough room) prepares a -- metadata update -- 3/ mdadm::Grow_reshape(): flushes the metadata update (via -- flush_metadata_update(), or ->sync_metadata()) -- 4/ mdadm::Grow_reshape(): post the new size to the kernel -- -- --2.3 Reshape level (simple-takeover) -- --"simple-takeover" implies the level change can be satisfied without touching --sync_action -- -- 1/ mdadm::Grow_reshape(): checks if mdmon is running and optionally -- initializes st->update_tail -- 2/ mdadm::Grow_reshape() calls ->reshape_super() to check that the level change -- is allowed (being performed at subarray scope) prepares a -- metadata update -- 2a/ raid10 --> raid0: degrade all mirror legs prior to calling -- ->reshape_super -- 3/ mdadm::Grow_reshape(): flushes the metadata update (via -- flush_metadata_update(), or ->sync_metadata()) -- 4/ mdadm::Grow_reshape(): post the new level to the kernel -- --2.4 Reshape chunk, layout -- --2.5 Reshape raid disks (grow) -- -- 1/ mdadm::Grow_reshape(): unconditionally initializes st->update_tail -- because only redundant raid levels can modify the number of raid disks -- 2/ mdadm::Grow_reshape(): calls ->reshape_super() to check that the level -- change is allowed (being performed at proper scope / permissible -- geometry / proper spares available in the container), chooses -- the spares to use, and prepares a metadata update. -- 3/ mdadm::Grow_reshape(): Converts each subarray in the container to the -- raid level that can perform the reshape and starts mdmon. -- 4/ mdadm::Grow_reshape(): Pushes the update to mdmon. -- 5/ mdadm::Grow_reshape(): uses container_content to find details of -- the spares and passes them to the kernel. -- 6/ mdadm::Grow_reshape(): gives raid_disks update to the kernel, -- sets sync_max, sync_min, suspend_lo, suspend_hi all to zero, -- and starts the reshape by writing 'reshape' to sync_action. -- 7/ mdmon::monitor notices the sync_action change and tells -- managemon to check for new devices. managemon notices the new -- devices, opens relevant sysfs file, and passes them all to -- monitor. -- 8/ mdadm::Grow_reshape() calls ->manage_reshape to oversee the -- rest of the reshape. -- -- 9/ mdadm::->manage_reshape(): saves data that will be overwritten by -- the kernel to either the backup file or the metadata specific location, -- advances sync_max, waits for reshape, ping mdmon, repeat. -- Meanwhile mdmon::read_and_act(): records checkpoints. -- Specifically. -- -- 9a/ if the 'next' stripe to be reshaped will over-write -- itself during reshape then: -- 9a.1/ increase suspend_hi to cover a suitable number of -- stripes. -- 9a.2/ backup those stripes safely. -- 9a.3/ advance sync_max to allow those stripes to be backed up -- 9a.4/ when sync_completed indicates that those stripes have -- been reshaped, manage_reshape must ping_manager -- 9a.5/ when mdmon notices that sync_completed has been updated, -- it records the new checkpoint in the metadata -- 9a.6/ after the ping_manager, manage_reshape will increase -- suspend_lo to allow access to those stripes again -- -- 9b/ if the 'next' stripe to be reshaped will over-write unused -- space during reshape then we apply same process as above, -- except that there is no need to back anything up. -- Note that we *do* need to keep suspend_hi progressing as -- it is not safe to write to the area-under-reshape. For -- kernel-managed-metadata this protection is provided by -- ->reshape_safe, but that does not protect us in the case -- of user-space-managed-metadata. -- -- 10/ mdadm::->manage_reshape(): Once reshape completes changes the raid -- level back to the nominal raid level (if necessary) -- -- FIXME: native metadata does not have the capability to record the original -- raid level in reshape-restart case because the kernel always records current -- raid level to the metadata, whereas external metadata can masquerade at an -- alternate level based on the reshape state. -- --2.6 Reshape raid disks (shrink) -- --3 Interaction with metadata handle. -- -- The following calls are made into the metadata handler to assist -- with initiating and monitoring a 'reshape'. -- -- 1/ ->reshape_super is called quite early (after only minimial -- checks) to make sure that the metadata can record the new shape -- and any necessary transitions. It may be passed a 'container' -- or an individual array within a container, and it should notice -- the difference and act accordingly. -- When a reshape is requested against a container it is expected -- that it should be applied to every array in the container, -- however it is up to the metadata handler to determine final -- policy. -- -- If the reshape is supportable, the internal copy of the metadata -- should be updated, and a metadata update suitable for sending -- to mdmon should be queued. -- -- If the reshape will involve converting spares into array members, -- this must be recorded in the metadata too. -- -- 2/ ->container_content will be called to find out the new state -- of all the array, or all arrays in the container. Any newly -- added devices (with state==0 and raid_disk >= 0) will be added -- to the array as spares with the relevant slot number. -- -- It is likely that the info returned by ->container_content will -- have ->reshape_active set, ->reshape_progress set to e.g. 0, and -- new_* set appropriately. mdadm will use this information to -- cause the correct reshape to start at an appropriate time. -- -- 3/ ->set_array_state will be called by mdmon when reshape has -- started and again periodically as it progresses. This should -- record the ->last_checkpoint as the point where reshape has -- progressed to. When the reshape finished this will be called -- again and it should notice that ->curr_action is no longer -- 'reshape' and so should record that the reshape has finished -- providing 'last_checkpoint' has progressed suitably. -- -- 4/ ->manage_reshape will be called once the reshape has been set -- up in the kernel but before sync_max has been moved from 0, so -- no actual reshape will have happened. -- -- ->manage_reshape should call progress_reshape() to allow the -- reshape to progress, and should back-up any data as indicated -- by the return value. See the documentation of that function -- for more details. -- ->manage_reshape will be called multiple times when a -- container is being reshaped, once for each member array in -- the container. -- -- -- The progress of the metadata is as follows: -- 1/ mdadm sends a metadata update to mdmon which marks the array -- as undergoing a reshape. This is set up by -- ->reshape_super and applied by ->process_update -- For container-wide reshape, this happens once for the whole -- container. -- 2/ mdmon notices progress via the sysfs files and calls -- ->set_array_state to update the state periodically -- For container-wide reshape, this happens repeatedly for -- one array, then repeatedly for the next, etc. -- 3/ mdmon notices when reshape has finished and call -- ->set_array_state to record the the reshape is complete. -- For container-wide reshape, this happens once for each -- member array. -- -- -- --... -- --[1]: Linux kernel design patterns - part 3, Neil Brown https://lwn.net/Articles/336262/ -diff --git a/mdadm.conf-example b/mdadm.conf-example -deleted file mode 100644 -index 35a75d12..00000000 ---- a/mdadm.conf-example -+++ /dev/null -@@ -1,65 +0,0 @@ --# mdadm configuration file --# --# mdadm will function properly without the use of a configuration file, --# but this file is useful for keeping track of arrays and member disks. --# In general, a mdadm.conf file is created, and updated, after arrays --# are created. This is the opposite behavior of /etc/raidtab which is --# created prior to array construction. --# --# --# the config file takes two types of lines: --# --# DEVICE lines specify a list of devices of where to look for --# potential member disks --# --# ARRAY lines specify information about how to identify arrays so --# so that they can be activated --# --# You can have more than one device line and use wild cards. The first --# example includes SCSI the first partition of SCSI disks /dev/sdb, --# /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second --# line looks for array slices on IDE disks. --# --#DEVICE /dev/sd[bcdjkl]1 --#DEVICE /dev/hda1 /dev/hdb1 --# --# If you mount devfs on /dev, then a suitable way to list all devices is: --#DEVICE /dev/discs/*/* --# --# --# The AUTO line can control which arrays get assembled by auto-assembly, --# meaing either "mdadm -As" when there are no 'ARRAY' lines in this file, --# or "mdadm --incremental" when the array found is not listed in this file. --# By default, all arrays that are found are assembled. --# If you want to ignore all DDF arrays (maybe they are managed by dmraid), --# and only assemble 1.x arrays if which are marked for 'this' homehost, --# but assemble all others, then use --#AUTO -ddf homehost -1.x +all --# --# ARRAY lines specify an array to assemble and a method of identification. --# Arrays can currently be identified by using a UUID, superblock minor number, --# or a listing of devices. --# --# super-minor is usually the minor number of the metadevice --# UUID is the Universally Unique Identifier for the array --# Each can be obtained using --# --# mdadm -D --# --#ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371 --#ARRAY /dev/md1 super-minor=1 --#ARRAY /dev/md2 devices=/dev/hda1,/dev/hdb1 --# --# ARRAY lines can also specify a "spare-group" for each array. mdadm --monitor --# will then move a spare between arrays in a spare-group if one array has a failed --# drive but no spare --#ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1 --#ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1 --# --# When used in --follow (aka --monitor) mode, mdadm needs a --# mail address and/or a program. This can be given with "mailaddr" --# and "program" lines to that monitoring can be started using --# mdadm --follow --scan & echo $! > /run/mdadm/mon.pid --# If the lines are not found, mdadm will exit quietly --#MAILADDR root@mydomain.tld --#PROGRAM /usr/sbin/handle-mdadm-events -diff --git a/mdmon-design.txt b/mdmon-design.txt -deleted file mode 100644 -index f09184a9..00000000 ---- a/mdmon-design.txt -+++ /dev/null -@@ -1,146 +0,0 @@ -- --When managing a RAID1 array which uses metadata other than the --"native" metadata understood by the kernel, mdadm makes use of a --partner program named 'mdmon' to manage some aspects of updating --that metadata and synchronising the metadata with the array state. -- --This document provides some details on how mdmon works. -- --Containers ------------ -- --As background: mdadm makes a distinction between an 'array' and a --'container'. Other sources sometimes use the term 'volume' or --'device' for an 'array', and may use the term 'array' for a --'container'. -- --For our purposes: -- - a 'container' is a collection of devices which are described by a -- single set of metadata. The metadata may be stored equally -- on all devices, or different devices may have quite different -- subsets of the total metadata. But there is conceptually one set -- of metadata that unifies the devices. -- -- - an 'array' is a set of datablock from various devices which -- together are used to present the abstraction of a single linear -- sequence of block, which may provide data redundancy or enhanced -- performance. -- --So a container has some metadata and provides a number of arrays which --are described by that metadata. -- --Sometimes this model doesn't work perfectly. For example, global --spares may have their own metadata which is quite different from the --metadata from any device that participates in one or more arrays. --Such a global spare might still need to belong to some container so --that it is available to be used should a failure arise. In that case --we consider the 'metadata' to be the union of the metadata on the --active devices which describes the arrays, and the metadata on the --global spares which only describes the spares. In this case different --devices in the one container will have quite different metadata. -- -- --Purpose --------- -- --The main purpose of mdmon is to update the metadata in response to --changes to the array which need to be reflected in the metadata before --futures writes to the array can safely be performed. --These include: -- - transitions from 'clean' to 'dirty'. -- - recording the devices have failed. -- - recording the progress of a 'reshape' -- --This requires mdmon to be running at any time that the array is --writable (a read-only array does not require mdmon to be running). -- --Because mdmon must be able to process these metadata updates at any --time, it must (when running) have exclusive write access to the --metadata. Any other changes (e.g. reconfiguration of the array) must --go through mdmon. -- --A secondary role for mdmon is to activate spares when a device fails. --This role is much less time-critical than the other metadata updates, --so it could be performed by a separate process, possibly --"mdadm --monitor" which has a related role of moving devices between --arrays. A main reason for including this functionality in mdmon is --that in the native-metadata case this function is handled in the --kernel, and mdmon's reason for existence to provide functionality --which is otherwise handled by the kernel. -- -- --Design overview ----------------- -- --mdmon is structured as two threads with a common address space and --common data structures. These threads are know as the 'monitor' and --the 'manager'. -- --The 'monitor' has the primary role of monitoring the array for --important state changes and updating the metadata accordingly. As --writes to the array can be blocked until 'monitor' completes and --acknowledges the update, it much be very careful not to block itself. --In particular it must not block waiting for any write to complete else --it could deadlock. This means that it must not allocate memory as --doing this can require dirty memory to be written out and if the --system choose to write to the array that mdmon is monitoring, the --memory allocation could deadlock. -- --So 'monitor' must never allocate memory and must limit the number of --other system call it performs. It may: -- - use select (or poll) to wait for activity on a file descriptor -- - read from a sysfs file descriptor -- - write to a sysfs file descriptor -- - write the metadata out to the block devices using O_DIRECT -- - send a signal (kill) to the manager thread -- --It must not e.g. open files or do anything similar that might allocate --resources. -- --The 'manager' thread does everything else that is needed. If any --files are to be opened (e.g. because a device has been added to the --array), the manager does that. If any memory needs to be allocated --(e.g. to hold data about a new array as can happen when one set of --metadata describes several arrays), the manager performs that --allocation. -- --The 'manager' is also responsible for communicating with mdadm and --assigning spares to replace failed devices. -- -- --Handling metadata updates --------------------------- -- --There are a number of cases in which mdadm needs to update the --metdata which mdmon is managing. These include: -- - creating a new array in an active container -- - adding a device to a container -- - reconfiguring an array --etc. -- --To complete these updates, mdadm must send a message to mdmon which --will merge the update into the metadata as it is at that moment. -- --To achieve this, mdmon creates a Unix Domain Socket which the manager --thread listens on. mdadm sends a message over this socket. The --manager thread examines the message to see if it will require --allocating any memory and allocates it. This is done in the --'prepare_update' metadata method. -- --The update message is then queued for handling by the monitor thread --which it will do when convenient. The monitor thread calls --->process_update which should atomically make the required changes to --the metadata, making use of the pre-allocate memory as required. Any --memory the is no-longer needed can be placed back in the request and --the manager thread will free it. -- --The exact format of a metadata update is up to the implementer of the --metadata handlers. It will simply describe a change that needs to be --made. It will sometimes contain fragments of the metadata to be --copied in to place. However the ->process_update routine must make --sure not to over-write any field that the monitor thread might have --updated, such as a 'device failed' or 'array is dirty' state. -- --When the monitor thread has completed the update and written it to the --devices, an acknowledgement message is sent back over the socket so --that mdadm knows it is complete. --- -2.40.1 - diff --git a/0019-super-ddf-optimize-DDF-header-search-for-widely-used.patch b/0019-super-ddf-optimize-DDF-header-search-for-widely-used.patch new file mode 100644 index 0000000..850e18a --- /dev/null +++ b/0019-super-ddf-optimize-DDF-header-search-for-widely-used.patch @@ -0,0 +1,297 @@ +From f2197b6b6c14af6c788c628acd1fc6d92c268c53 Mon Sep 17 00:00:00 2001 +From: lilinzhe +Date: Mon, 16 Dec 2024 12:11:41 +0800 +Subject: [PATCH 19/37] super-ddf: optimize DDF header search for widely used + RAID controllers + +Implemented fallback logic to search the last 32MB of the device +for the DDF header (magic). If found, proceeds to load the DDF metadata +from the located position. + +When clearing metadata as required by the mdadm --zero (function Kill), +also erase the last 32MB of data; otherwise, it may result in an +infinite loop. + +According to the specification, the Anchor Header should be placed at +the end of the disk. However,some widely used RAID hardware, such as +LSI and PERC, do not position it within the last 512 bytes of the disk. + +Signed-off-by: lilinzhe +--- + super-ddf.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++----- + xmalloc.c | 11 +++ + xmalloc.h | 1 + + 3 files changed, 185 insertions(+), 17 deletions(-) + +diff --git a/super-ddf.c b/super-ddf.c +index a06ed435..6e7db924 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -272,6 +272,10 @@ struct phys_disk { + #define DDF_ReadErrors 32 + #define DDF_Missing 64 + ++ ++#define SEARCH_BLOCK_SIZE 4096 ++#define SEARCH_REGION_SIZE (32 * 1024 * 1024) ++ + /* The content of the virt_section global scope */ + struct virtual_disk { + be32 magic; /* DDF_VIRT_RECORDS_MAGIC */ +@@ -877,30 +881,180 @@ static void *load_section(int fd, struct ddf_super *super, void *buf, + return buf; + } + +-static int load_ddf_headers(int fd, struct ddf_super *super, char *devname) ++ ++/* ++ * Search for DDF_HEADER_MAGIC in the last 32MB of the device ++ * ++ * According to the specification, the Anchor Header should be placed at ++ * the end of the disk. However,some widely used RAID hardware, such as ++ * LSI and PERC, do not position it within the last 512 bytes of the disk. ++ * ++ */ ++static int search_for_ddf_headers(int fd, char *devname, ++ unsigned long long *out) + { ++ unsigned long long search_start; ++ unsigned long long search_end; ++ size_t bytes_block_to_read; + unsigned long long dsize; ++ unsigned long long pos; ++ int bytes_current_read; ++ size_t offset; ++ ++ void *buffer = NULL; ++ be32 *magic_ptr = NULL; ++ ++ int result = 0; + + get_dev_size(fd, NULL, &dsize); + +- if (lseek64(fd, dsize - 512, 0) == -1L) { +- if (devname) +- pr_err("Cannot seek to anchor block on %s: %s\n", ++ ++ /* Determine the search range */ ++ if (dsize > SEARCH_REGION_SIZE) ++ search_start = dsize - SEARCH_REGION_SIZE; ++ else ++ search_start = 0; ++ ++ search_end = dsize; ++ pos = search_start; ++ ++ ++ buffer = xmemalign(SEARCH_BLOCK_SIZE, SEARCH_BLOCK_SIZE); ++ ++ if (buffer == NULL) { ++ result = 1; ++ goto cleanup; ++ } ++ ++ while (pos < search_end) { ++ /* Calculate the number of bytes to read in the current block */ ++ bytes_block_to_read = SEARCH_BLOCK_SIZE; ++ if (search_end - pos < SEARCH_BLOCK_SIZE) ++ bytes_block_to_read = search_end - pos; ++ ++ if (lseek64(fd, pos, SEEK_SET) < 0) { ++ pr_err("lseek64 for %s failed %d:%s\n", ++ fd2devnm(fd), errno, strerror(errno)); ++ result = 2; ++ goto cleanup; ++ } ++ ++ /*Read data from the device */ ++ bytes_current_read = read(fd, buffer, bytes_block_to_read); ++ ++ if (bytes_current_read <= 0) { ++ pr_err("Failed to read %s. %d:%s, Position=%llu, Bytes to read=%zu. Skipping.\n", ++ fd2devnm(fd), errno, strerror(errno), pos, bytes_block_to_read); ++ pos += SEARCH_BLOCK_SIZE; /* Skip to the next block */ ++ continue; ++ } ++ ++ /* Search for the magic value within the read block */ ++ for (offset = 0; ++ offset + sizeof(be32) <= (size_t)bytes_current_read; ++ offset += sizeof(be32)) { ++ ++ magic_ptr = (be32 *) ((char *)buffer + offset); ++ if (be32_eq(*magic_ptr, DDF_HEADER_MAGIC)) { ++ *out = pos + offset; ++ result = 0; ++ goto cleanup; ++ } ++ } ++ ++ pos += SEARCH_BLOCK_SIZE; ++ } ++ ++cleanup: ++ free(buffer); ++ return result; ++} ++ ++static int load_ddf_headers(int fd, struct ddf_super *super, char *devname) ++{ ++ /* ++ * Load DDF headers from a device. ++ * First, check at dsize - 512, and if not found, search for it. ++ */ ++ unsigned long long dsize = 0; ++ unsigned long long ddfpos = 0; ++ unsigned long long ddffound = 0; ++ bool found_anchor = false; ++ ++ get_dev_size(fd, NULL, &dsize); ++ ++ /* Check the last 512 bytes for the DDF header. */ ++ if (lseek64(fd, dsize - 512, SEEK_SET) == -1L) { ++ if (devname) { ++ pr_err("Cannot seek to last 512 bytes on %s: %s\n", + devname, strerror(errno)); ++ } + return 1; + } +- if (read(fd, &super->anchor, 512) != 512) { +- if (devname) +- pr_err("Cannot read anchor block on %s: %s\n", ++ ++ ++ /* Read the last 512 bytes into the anchor block */ ++ if (read(fd, &super->anchor, 512) == 512) { ++ /* Check if the magic value matches */ ++ if (be32_eq(super->anchor.magic, DDF_HEADER_MAGIC)) ++ found_anchor = true; ++ ++ } else { ++ if (devname) { ++ pr_err("Cannot read last 512 bytes on %s: %s\n", + devname, strerror(errno)); +- return 1; ++ } + } +- if (!be32_eq(super->anchor.magic, DDF_HEADER_MAGIC)) { ++ ++ if (!found_anchor) { ++ /* If not found, perform a full search for DDF headers */ ++ ddffound = search_for_ddf_headers(fd, devname, &ddfpos); ++ if (ddffound != 0) { ++ if (devname) { ++ pr_err ++ ("DDF headers not found during search on %s\n", ++ devname); ++ } ++ return 2; ++ } ++ ++ /* Seek to the found position */ ++ if (lseek64(fd, ddfpos, SEEK_SET) == -1L) { ++ if (devname) { ++ pr_err("Cannot seek to anchor block on %s\n", ++ devname); ++ } ++ return 1; ++ } ++ ++ /* Read the header from the found position */ ++ if (read(fd, &super->anchor, 512) != 512) { ++ if (devname) { ++ pr_err ++ ("Cannot read DDF header at found position on %s: %s\n", ++ devname, strerror(errno)); ++ } ++ return 1; ++ } ++ ++ /* Verify the magic value again */ ++ if (!be32_eq(super->anchor.magic, DDF_HEADER_MAGIC)) { ++ if (devname) { ++ pr_err("Invalid DDF header magic value on %s\n", ++ devname); ++ } ++ return 2; ++ } ++ found_anchor = true; ++ } ++ if (!found_anchor) { ++ + if (devname) +- pr_err("no DDF anchor found on %s\n", +- devname); ++ pr_err("DDF headers not found on %s\n", devname); ++ + return 2; + } ++ + if (!be32_eq(calc_crc(&super->anchor, 512), super->anchor.crc)) { + if (devname) + pr_err("bad CRC on anchor on %s\n", +@@ -3889,16 +4043,17 @@ static int store_super_ddf(struct supertype *st, int fd) + dl->fd = ofd; + return ret; + } ++ // this is used for cleanup (Kill). to clean up 512 bytes ++ // at the end of the disk is not enough. ++ // clears SEARCH_REGION_SIZE bytes at the end of the disk. + +- if (posix_memalign(&buf, 512, 512) != 0) +- return 1; +- memset(buf, 0, 512); +- +- if (lseek64(fd, dsize - 512, 0) == -1L) { ++ buf = xmemalign(SEARCH_BLOCK_SIZE, SEARCH_REGION_SIZE); ++ memset(buf, 0, SEARCH_REGION_SIZE); ++ if (lseek64(fd, dsize - SEARCH_REGION_SIZE, 0) == -1L) { + free(buf); + return 1; + } +- rc = write(fd, buf, 512); ++ rc = write(fd, buf, SEARCH_REGION_SIZE); + free(buf); + if (rc < 0) + return 1; +@@ -5208,6 +5363,7 @@ static int update_super_ddf_dummy(struct supertype *st, struct mdinfo *info, + */ + dprintf("update_super is not implemented in DDF\n"); + return 0; ++ + } + + struct superswitch super_ddf = { +diff --git a/xmalloc.c b/xmalloc.c +index e28d3bd6..9472005e 100644 +--- a/xmalloc.c ++++ b/xmalloc.c +@@ -75,3 +75,14 @@ char *xstrdup(const char *str) + + return exit_memory_alloc_failure(); + } ++ ++void *xmemalign(size_t alignment, size_t size) ++{ ++ void *ptr = NULL; ++ int result = posix_memalign(&ptr, alignment, size); ++ ++ if (result == 0) ++ return ptr; ++ ++ return exit_memory_alloc_failure(); ++} +diff --git a/xmalloc.h b/xmalloc.h +index 0904b0ab..789948ae 100644 +--- a/xmalloc.h ++++ b/xmalloc.h +@@ -9,5 +9,6 @@ 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); ++void *xmemalign(size_t alignment, size_t size); + + #endif +-- +2.41.0 + diff --git a/0020-Detail-remove-duplicated-code.patch b/0020-Detail-remove-duplicated-code.patch deleted file mode 100644 index 17db9ae..0000000 --- a/0020-Detail-remove-duplicated-code.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 60c19530dd7cc6b38a75695a0a3d004bbe60d430 Mon Sep 17 00:00:00 2001 -From: Kinga Tanska -Date: Tue, 27 Feb 2024 03:36:14 +0100 -Subject: [PATCH 20/41] Detail: remove duplicated code - -Remove duplicated code from Detail(), where MD_UUID and MD_DEVNAME -are being set. Superblock is no longer required to print system -properties. Now it tries to obtain map in two ways. - -Signed-off-by: Kinga Tanska -Signed-off-by: Mariusz Tkaczyk ---- - Detail.c | 33 +++++++++++++-------------------- - 1 file changed, 13 insertions(+), 20 deletions(-) - -diff --git a/Detail.c b/Detail.c -index aaa3dd6e..f23ec16f 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -226,6 +226,9 @@ int Detail(char *dev, struct context *c) - str = map_num(pers, array.level); - - if (c->export) { -+ char nbuf[64]; -+ struct map_ent *mp = NULL, *map = NULL; -+ - if (array.raid_disks) { - if (str) - printf("MD_LEVEL=%s\n", str); -@@ -247,32 +250,22 @@ int Detail(char *dev, struct context *c) - array.minor_version); - } - -- if (st && st->sb && info) { -- char nbuf[64]; -- struct map_ent *mp, *map = NULL; -- -- fname_from_uuid(st, info, nbuf, ':'); -- printf("MD_UUID=%s\n", nbuf + 5); -+ if (info) - mp = map_by_uuid(&map, info->uuid); -+ if (!mp) -+ mp = map_by_devnm(&map, fd2devnm(fd)); - -- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) -+ if (mp) { -+ __fname_from_uuid(mp->uuid, 0, nbuf, ':'); -+ printf("MD_UUID=%s\n", nbuf + 5); -+ if (mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) - printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN); -+ } - -+ map_free(map); -+ if (st && st->sb) { - if (st->ss->export_detail_super) - st->ss->export_detail_super(st); -- map_free(map); -- } else { -- struct map_ent *mp, *map = NULL; -- char nbuf[64]; -- mp = map_by_devnm(&map, fd2devnm(fd)); -- if (mp) { -- __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); -- -- map_free(map); - } - if (!c->no_devices && sra) { - struct mdinfo *mdi; --- -2.40.1 - diff --git a/0020-bitmap.h-clear-__KERNEL__-based-headers.patch b/0020-bitmap.h-clear-__KERNEL__-based-headers.patch new file mode 100644 index 0000000..23bc562 --- /dev/null +++ b/0020-bitmap.h-clear-__KERNEL__-based-headers.patch @@ -0,0 +1,200 @@ +From eb9876f58658a107705a689852110903723e4d3b Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Mon, 3 Feb 2025 11:36:01 +0100 +Subject: [PATCH 20/37] bitmap.h - clear __KERNEL__ based headers + +It is unused for years. Clear it. + +Signed-off-by: Mariusz Tkaczyk +--- + bitmap.h | 169 ------------------------------------------------------- + 1 file changed, 169 deletions(-) + +diff --git a/bitmap.h b/bitmap.h +index 7b1f80f2..2614a14e 100644 +--- a/bitmap.h ++++ b/bitmap.h +@@ -78,63 +78,6 @@ + * + */ + +-#ifdef __KERNEL__ +- +-#define PAGE_BITS (PAGE_SIZE << 3) +-#define PAGE_BIT_SHIFT (PAGE_SHIFT + 3) +- +-typedef __u16 bitmap_counter_t; +-#define COUNTER_BITS 16 +-#define COUNTER_BIT_SHIFT 4 +-#define COUNTER_BYTE_RATIO (COUNTER_BITS / 8) +-#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3) +- +-#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1))) +-#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2))) +-#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1) +-#define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK) +-#define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK) +-#define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX) +- +-/* how many counters per page? */ +-#define PAGE_COUNTER_RATIO (PAGE_BITS / COUNTER_BITS) +-/* same, except a shift value for more efficient bitops */ +-#define PAGE_COUNTER_SHIFT (PAGE_BIT_SHIFT - COUNTER_BIT_SHIFT) +-/* same, except a mask value for more efficient bitops */ +-#define PAGE_COUNTER_MASK (PAGE_COUNTER_RATIO - 1) +- +-#define BITMAP_BLOCK_SIZE 512 +-#define BITMAP_BLOCK_SHIFT 9 +- +-/* how many blocks per chunk? (this is variable) */ +-#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->chunksize >> BITMAP_BLOCK_SHIFT) +-#define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT) +-#define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1) +- +-/* when hijacked, the counters and bits represent even larger "chunks" */ +-/* there will be 1024 chunks represented by each counter in the page pointers */ +-#define PAGEPTR_BLOCK_RATIO(bitmap) \ +- (CHUNK_BLOCK_RATIO(bitmap) << PAGE_COUNTER_SHIFT >> 1) +-#define PAGEPTR_BLOCK_SHIFT(bitmap) \ +- (CHUNK_BLOCK_SHIFT(bitmap) + PAGE_COUNTER_SHIFT - 1) +-#define PAGEPTR_BLOCK_MASK(bitmap) (PAGEPTR_BLOCK_RATIO(bitmap) - 1) +- +-/* +- * on-disk bitmap: +- * +- * Use one bit per "chunk" (block set). We do the disk I/O on the bitmap +- * file a page at a time. There's a superblock at the start of the file. +- */ +- +-/* map chunks (bits) to file pages - offset by the size of the superblock */ +-#define CHUNK_BIT_OFFSET(chunk) ((chunk) + (sizeof(bitmap_super_t) << 3)) +- +-#endif +- +-/* +- * bitmap structures: +- */ +- + #define BITMAP_MAGIC 0x6d746962 + + /* use these for bitmap->flags and bitmap->sb->state bit-fields */ +@@ -176,116 +119,4 @@ typedef struct bitmap_super_s { + * devices. For raid10 it is the size of the array. + */ + +-#ifdef __KERNEL__ +- +-/* the in-memory bitmap is represented by bitmap_pages */ +-struct bitmap_page { +- /* +- * map points to the actual memory page +- */ +- char *map; +- /* +- * in emergencies (when map cannot be allocated), hijack the map +- * pointer and use it as two counters itself +- */ +- unsigned int hijacked; +- /* +- * count of dirty bits on the page +- */ +- int count; +-}; +- +-/* keep track of bitmap file pages that have pending writes on them */ +-struct page_list { +- struct list_head list; +- struct page *page; +-}; +- +-/* the main bitmap structure - one per mddev */ +-struct bitmap { +- struct bitmap_page *bp; +- unsigned long pages; /* total number of pages in the bitmap */ +- unsigned long missing_pages; /* number of pages not yet allocated */ +- +- mddev_t *mddev; /* the md device that the bitmap is for */ +- +- int counter_bits; /* how many bits per block counter */ +- +- /* bitmap chunksize -- how much data does each bit represent? */ +- unsigned long chunksize; +- unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ +- unsigned long chunks; /* total number of data chunks for the array */ +- +- /* We hold a count on the chunk currently being synced, and drop +- * it when the last block is started. If the resync is aborted +- * midway, we need to be able to drop that count, so we remember +- * the counted chunk.. +- */ +- unsigned long syncchunk; +- +- __u64 events_cleared; +- +- /* bitmap spinlock */ +- spinlock_t lock; +- +- struct file *file; /* backing disk file */ +- struct page *sb_page; /* cached copy of the bitmap file superblock */ +- struct page **filemap; /* list of cache pages for the file */ +- unsigned long *filemap_attr; /* attributes associated w/ filemap pages */ +- unsigned long file_pages; /* number of pages in the file */ +- +- unsigned long flags; +- +- /* +- * the bitmap daemon - periodically wakes up and sweeps the bitmap +- * file, cleaning up bits and flushing out pages to disk as necessary +- */ +- mdk_thread_t *daemon; +- unsigned long daemon_sleep; /* how many seconds between updates? */ +- +- /* +- * bitmap write daemon - this daemon performs writes to the bitmap file +- * this thread is only needed because of a limitation in ext3 (jbd) +- * that does not allow a task to have two journal transactions ongoing +- * simultaneously (even if the transactions are for two different +- * filesystems) -- in the case of bitmap, that would be the filesystem +- * that the bitmap file resides on and the filesystem that is mounted +- * on the md device -- see current->journal_info in jbd/transaction.c +- */ +- mdk_thread_t *write_daemon; +- mdk_thread_t *writeback_daemon; +- spinlock_t write_lock; +- struct semaphore write_ready; +- struct semaphore write_done; +- unsigned long writes_pending; +- wait_queue_head_t write_wait; +- struct list_head write_pages; +- struct list_head complete_pages; +- mempool_t *write_pool; +-}; +- +-/* the bitmap API */ +- +-/* these are used only by md/bitmap */ +-int bitmap_create(mddev_t *mddev); +-void bitmap_destroy(mddev_t *mddev); +-int bitmap_active(struct bitmap *bitmap); +- +-char *file_path(struct file *file, char *buf, int count); +-void bitmap_print_sb(struct bitmap *bitmap); +-int bitmap_update_sb(struct bitmap *bitmap); +- +-int bitmap_setallbits(struct bitmap *bitmap); +- +-/* these are exported */ +-void bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors); +-void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, +- int success); +-int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks); +-void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); +-void bitmap_close_sync(struct bitmap *bitmap); +- +-int bitmap_unplug(struct bitmap *bitmap); +-#endif +- + #endif +-- +2.41.0 + diff --git a/0021-bitmap.h-Minor-fixes.patch b/0021-bitmap.h-Minor-fixes.patch new file mode 100644 index 0000000..0d88e0d --- /dev/null +++ b/0021-bitmap.h-Minor-fixes.patch @@ -0,0 +1,206 @@ +From 17fed47a64e1890df9820b93548c396b7de54e31 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Wed, 5 Feb 2025 11:34:45 +0100 +Subject: [PATCH 21/37] bitmap.h: Minor fixes + +Move documentation to documentation/bitmap.md. Add Neil's copyrights, +add missing license. Remove unused macros. + +Signed-off-by: Mariusz Tkaczyk +--- + bitmap.h | 94 ++++------------------------------------- + documentation/bitmap.md | 67 +++++++++++++++++++++++++++++ + 2 files changed, 75 insertions(+), 86 deletions(-) + create mode 100644 documentation/bitmap.md + +diff --git a/bitmap.h b/bitmap.h +index 2614a14e..9f3d4f3e 100644 +--- a/bitmap.h ++++ b/bitmap.h +@@ -1,83 +1,19 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++ + /* +- * bitmap.h: Copyright (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003 +- * +- * additions: Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc. ++ * Copyright (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003 ++ * Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc. ++ * Copyright (C) 2005 Neil Brown + */ ++ ++/* See documentation/bitmap.md */ ++ + #ifndef BITMAP_H + #define BITMAP_H 1 + + #define BITMAP_MAJOR_LO 3 +-/* version 4 insists the bitmap is in little-endian order +- * with version 3, it is host-endian which is non-portable +- */ + #define BITMAP_MAJOR_HI 4 +-#define BITMAP_MAJOR_HOSTENDIAN 3 + #define BITMAP_MAJOR_CLUSTERED 5 +- +-#define BITMAP_MINOR 39 +- +-/* +- * in-memory bitmap: +- * +- * Use 16 bit block counters to track pending writes to each "chunk". +- * The 2 high order bits are special-purpose, the first is a flag indicating +- * whether a resync is needed. The second is a flag indicating whether a +- * resync is active. +- * This means that the counter is actually 14 bits: +- * +- * +--------+--------+------------------------------------------------+ +- * | resync | resync | counter | +- * | needed | active | | +- * | (0-1) | (0-1) | (0-16383) | +- * +--------+--------+------------------------------------------------+ +- * +- * The "resync needed" bit is set when: +- * a '1' bit is read from storage at startup. +- * a write request fails on some drives +- * a resync is aborted on a chunk with 'resync active' set +- * It is cleared (and resync-active set) when a resync starts across all drives +- * of the chunk. +- * +- * +- * The "resync active" bit is set when: +- * a resync is started on all drives, and resync_needed is set. +- * resync_needed will be cleared (as long as resync_active wasn't already set). +- * It is cleared when a resync completes. +- * +- * The counter counts pending write requests, plus the on-disk bit. +- * When the counter is '1' and the resync bits are clear, the on-disk +- * bit can be cleared as well, thus setting the counter to 0. +- * When we set a bit, or in the counter (to start a write), if the fields is +- * 0, we first set the disk bit and set the counter to 1. +- * +- * If the counter is 0, the on-disk bit is clear and the stipe is clean +- * Anything that dirties the stipe pushes the counter to 2 (at least) +- * and sets the on-disk bit (lazily). +- * If a periodic sweep find the counter at 2, it is decremented to 1. +- * If the sweep find the counter at 1, the on-disk bit is cleared and the +- * counter goes to zero. +- * +- * Also, we'll hijack the "map" pointer itself and use it as two 16 bit block +- * counters as a fallback when "page" memory cannot be allocated: +- * +- * Normal case (page memory allocated): +- * +- * page pointer (32-bit) +- * +- * [ ] ------+ +- * | +- * +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters) +- * c1 c2 c2048 +- * +- * Hijacked case (page memory allocation failed): +- * +- * hijacked page pointer (32-bit) +- * +- * [ ][ ] (no page memory allocated) +- * counter #1 (16-bit) counter #2 (16-bit) +- * +- */ +- + #define BITMAP_MAGIC 0x6d746962 + + /* use these for bitmap->flags and bitmap->sb->state bit-fields */ +@@ -105,18 +41,4 @@ typedef struct bitmap_super_s { + __u8 pad[256 - 136]; /* set to zero */ + } bitmap_super_t; + +-/* notes: +- * (1) This event counter is updated before the eventcounter in the md superblock +- * When a bitmap is loaded, it is only accepted if this event counter is equal +- * to, or one greater than, the event counter in the superblock. +- * (2) This event counter is updated when the other one is *if*and*only*if* the +- * array is not degraded. As bits are not cleared when the array is degraded, +- * this represents the last time that any bits were cleared. +- * If a device is being added that has an event count with this value or +- * higher, it is accepted as conforming to the bitmap. +- * (3)This is the number of sectors represented by the bitmap, and is the range that +- * resync happens across. For raid1 and raid5/6 it is the size of individual +- * devices. For raid10 it is the size of the array. +- */ +- + #endif +diff --git a/documentation/bitmap.md b/documentation/bitmap.md +new file mode 100644 +index 00000000..bdc146e5 +--- /dev/null ++++ b/documentation/bitmap.md +@@ -0,0 +1,67 @@ ++# Internal bitmap block design ++ ++Use 16 bit block counters to track pending writes to each "chunk". ++The 2 high order bits are special-purpose, the first is a flag indicating ++whether a resync is needed. The second is a flag indicating whether a ++resync is active. This means that the counter is actually 14 bits: ++ ++| resync_needed | resync_active | counter | ++| :----: | :----: | :----: | ++| (0-1) | (0-1) | (0-16383) | ++ ++The `resync_needed` bit is set when: ++- a `1` bit is read from storage at startup; ++- a write request fails on some drives; ++- a resync is aborted on a chunk with `resync_active` set; ++- It is cleared (and `resync_active` set) when a resync starts across all drives of the chunk. ++ ++The `resync_active` bit is set when: ++- a resync is started on all drives, and `resync_needed` is set. ++- `resync_needed` will be cleared (as long as `resync_active` wasn't already set). ++- It is cleared when a resync completes. ++ ++The counter counts pending write requests, plus the on-disk bit. ++When the counter is `1` and the resync bits are clear, the on-disk ++bit can be cleared as well, thus setting the counter to `0`. ++When we set a bit, or in the counter (to start a write), if the fields is ++`0`, we first set the disk bit and set the counter to `1`. ++ ++If the counter is `0`, the on-disk bit is clear and the stipe is clean ++Anything that dirties the stipe pushes the counter to `2` (at least) ++and sets the on-disk bit (lazily). ++If a periodic sweep find the counter at `2`, it is decremented to `1`. ++If the sweep find the counter at `1`, the on-disk bit is cleared and the ++counter goes to `0`. ++ ++Also, we'll hijack the "map" pointer itself and use it as two 16 bit block ++counters as a fallback when "page" memory cannot be allocated: ++ ++Normal case (page memory allocated): ++ ++page pointer (32-bit) ++ ++ [ ] ------+ ++ | ++ +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters) ++ c1 c2 c2048 ++ ++ Hijacked case (page memory allocation failed): ++ ++ hijacked page pointer (32-bit) ++ ++ [ ][ ] (no page memory allocated) ++ counter #1 (16-bit) counter #2 (16-bit) ++ ++ ++## Notes: ++1. bitmap_super_s->events counter is updated before the event counter in the md superblock; ++ When a bitmap is loaded, it is only accepted if this event counter is equal ++ to, or one greater than, the event counter in the superblock. ++2. bitmap_super_s->events is updated when the other one is `if` and `only if` the ++ array is not degraded. As bits are not cleared when the array is degraded, ++ this represents the last time that any bits were cleared. If a device is being ++ added that has an event count with this value or higher, it is accepted ++ as conforming to the bitmap. ++3. bitmap_super_s->chunksize is the number of sectors represented by the bitmap, ++ and is the range that resync happens across. For raid1 and raid5/6 it is the ++ size of individual devices. For raid10 it is the size of the array. +-- +2.41.0 + diff --git a/0021-mdadm-Add-functions-for-spare-criteria-verification.patch b/0021-mdadm-Add-functions-for-spare-criteria-verification.patch deleted file mode 100644 index 97f8115..0000000 --- a/0021-mdadm-Add-functions-for-spare-criteria-verification.patch +++ /dev/null @@ -1,286 +0,0 @@ -From 0c0f09cb035b6a27a1d11c54836742a9945a5014 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:05 +0100 -Subject: [PATCH 21/41] mdadm: Add functions for spare criteria verification - -It is done similar way in few places. As a result, two almost identical -functions (dev_size_from_id() and dev_sector_size_from_id()) are -removed. Now, it uses same file descriptor to send two ioctls. - -Two extern functions are added, in next patches -disk_fd_matches_criteria() is used. - -Next optimization is inline zeroing struct spare_criteria. With that, -we don't need to reset values in get_spare_criteria_imsm(). - -Dedicated boolean field for checking if criteria are filled is added. -We don't need to execute the code if it is not set. - -Signed-off-by: Mariusz Tkaczyk ---- - Incremental.c | 2 +- - Monitor.c | 14 +------ - mdadm.h | 6 ++- - super-intel.c | 4 +- - util.c | 112 ++++++++++++++++++++++++++------------------------ - 5 files changed, 67 insertions(+), 71 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index 30c07c03..2b5a5859 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -874,7 +874,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - struct domainlist *dl = NULL; - struct mdinfo *sra; - unsigned long long devsize, freesize = 0; -- struct spare_criteria sc = {0, 0}; -+ struct spare_criteria sc = {0}; - - if (is_subarray(mp->metadata)) - continue; -diff --git a/Monitor.c b/Monitor.c -index 9be2b528..1ece8712 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -1070,22 +1070,12 @@ static dev_t choose_spare(struct state *from, struct state *to, - for (d = from->raid; !dev && d < MAX_DISKS; d++) { - if (from->devid[d] > 0 && from->devstate[d] == 0) { - struct dev_policy *pol; -- unsigned long long dev_size; -- unsigned int dev_sector_size; - - if (to->metadata->ss->external && - test_partition_from_id(from->devid[d])) - continue; - -- if (sc->min_size && -- dev_size_from_id(from->devid[d], &dev_size) && -- dev_size < sc->min_size) -- continue; -- -- if (sc->sector_size && -- dev_sector_size_from_id(from->devid[d], -- &dev_sector_size) && -- sc->sector_size != dev_sector_size) -+ if (devid_matches_criteria(from->devid[d], sc) == false) - continue; - - pol = devid_policy(from->devid[d]); -@@ -1170,12 +1160,12 @@ static void try_spare_migration(struct state *statelist) - { - struct state *from; - struct state *st; -- struct spare_criteria sc; - - link_containers_with_subarrays(statelist); - for (st = statelist; st; st = st->next) - if (st->active < st->raid && st->spare == 0 && !st->err) { - struct domainlist *domlist = NULL; -+ struct spare_criteria sc = {0}; - int d; - struct state *to = st; - -diff --git a/mdadm.h b/mdadm.h -index 75c887e4..e8abd730 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -430,6 +430,7 @@ struct createinfo { - }; - - struct spare_criteria { -+ bool criteria_set; - unsigned long long min_size; - unsigned int sector_size; - }; -@@ -1368,8 +1369,6 @@ extern struct supertype *dup_super(struct supertype *st); - extern int get_dev_size(int fd, char *dname, unsigned long long *sizep); - extern int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep); - extern int must_be_container(int fd); --extern int dev_size_from_id(dev_t id, unsigned long long *size); --extern int dev_sector_size_from_id(dev_t id, unsigned int *size); - void wait_for(char *dev, int fd); - - /* -@@ -1708,6 +1707,9 @@ extern int assemble_container_content(struct supertype *st, int mdfd, - #define INCR_UNSAFE 2 - #define INCR_ALREADY 4 - #define INCR_YES 8 -+ -+extern bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc); -+extern bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc); - extern struct mdinfo *container_choose_spares(struct supertype *st, - struct spare_criteria *criteria, - struct domainlist *domlist, -diff --git a/super-intel.c b/super-intel.c -index 4babec9f..39ec4754 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1748,9 +1748,6 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c) - int i; - unsigned long long size = 0; - -- c->min_size = 0; -- c->sector_size = 0; -- - if (!super) - return -EINVAL; - /* find first active disk in array */ -@@ -1774,6 +1771,7 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c) - - c->min_size = size * 512; - c->sector_size = super->sector_size; -+ c->criteria_set = true; - - return 0; - } -diff --git a/util.c b/util.c -index b1454473..041e78cf 100644 ---- a/util.c -+++ b/util.c -@@ -1266,40 +1266,6 @@ struct supertype *super_by_fd(int fd, char **subarrayp) - return st; - } - --int dev_size_from_id(dev_t id, unsigned long long *size) --{ -- char buf[20]; -- int fd; -- -- sprintf(buf, "%d:%d", major(id), minor(id)); -- fd = dev_open(buf, O_RDONLY); -- if (fd < 0) -- return 0; -- if (get_dev_size(fd, NULL, size)) { -- close(fd); -- return 1; -- } -- close(fd); -- return 0; --} -- --int dev_sector_size_from_id(dev_t id, unsigned int *size) --{ -- char buf[20]; -- int fd; -- -- sprintf(buf, "%d:%d", major(id), minor(id)); -- fd = dev_open(buf, O_RDONLY); -- if (fd < 0) -- return 0; -- if (get_dev_sector_size(fd, NULL, size)) { -- close(fd); -- return 1; -- } -- close(fd); -- return 0; --} -- - struct supertype *dup_super(struct supertype *orig) - { - struct supertype *st; -@@ -2088,6 +2054,60 @@ void append_metadata_update(struct supertype *st, void *buf, int len) - unsigned int __invalid_size_argument_for_IOC = 0; - #endif - -+/** -+ * disk_fd_matches_criteria() - check if device matches spare criteria. -+ * @disk_fd: file descriptor of the disk. -+ * @sc: criteria to test. -+ * -+ * Return: true if disk matches criteria, false otherwise. -+ */ -+bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc) -+{ -+ unsigned int dev_sector_size = 0; -+ unsigned long long dev_size = 0; -+ -+ if (!sc->criteria_set) -+ return true; -+ -+ if (!get_dev_size(disk_fd, NULL, &dev_size) || dev_size < sc->min_size) -+ return false; -+ -+ if (!get_dev_sector_size(disk_fd, NULL, &dev_sector_size) || -+ sc->sector_size != dev_sector_size) -+ return false; -+ -+ return true; -+} -+ -+/** -+ * devid_matches_criteria() - check if device referenced by devid matches spare criteria. -+ * @devid: devid of the device to check. -+ * @sc: criteria to test. -+ * -+ * Return: true if disk matches criteria, false otherwise. -+ */ -+bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc) -+{ -+ char buf[NAME_MAX]; -+ bool ret; -+ int fd; -+ -+ if (!sc->criteria_set) -+ return true; -+ -+ snprintf(buf, NAME_MAX, "%d:%d", major(devid), minor(devid)); -+ -+ fd = dev_open(buf, O_RDONLY); -+ if (!is_fd_valid(fd)) -+ return false; -+ -+ /* Error code inherited */ -+ ret = disk_fd_matches_criteria(fd, sc); -+ -+ close(fd); -+ return ret; -+} -+ - /* Pick all spares matching given criteria from a container - * if min_size == 0 do not check size - * if domlist == NULL do not check domains -@@ -2111,28 +2131,13 @@ struct mdinfo *container_choose_spares(struct supertype *st, - dp = &disks->devs; - disks->array.spare_disks = 0; - while (*dp) { -- int found = 0; -+ bool found = false; -+ - d = *dp; - if (d->disk.state == 0) { -- /* check if size is acceptable */ -- unsigned long long dev_size; -- unsigned int dev_sector_size; -- int size_valid = 0; -- int sector_size_valid = 0; -- - dev_t dev = makedev(d->disk.major,d->disk.minor); - -- if (!criteria->min_size || -- (dev_size_from_id(dev, &dev_size) && -- dev_size >= criteria->min_size)) -- size_valid = 1; -- -- if (!criteria->sector_size || -- (dev_sector_size_from_id(dev, &dev_sector_size) && -- criteria->sector_size == dev_sector_size)) -- sector_size_valid = 1; -- -- found = size_valid && sector_size_valid; -+ found = devid_matches_criteria(dev, criteria); - - /* check if domain matches */ - if (found && domlist) { -@@ -2141,7 +2146,8 @@ struct mdinfo *container_choose_spares(struct supertype *st, - pol_add(&pol, pol_domain, - spare_group, NULL); - if (domain_test(domlist, pol, metadata) != 1) -- found = 0; -+ found = false; -+ - dev_policy_free(pol); - } - } --- -2.40.1 - diff --git a/0022-Move-release-steps-to-documentation.patch b/0022-Move-release-steps-to-documentation.patch new file mode 100644 index 0000000..a9ac26b --- /dev/null +++ b/0022-Move-release-steps-to-documentation.patch @@ -0,0 +1,20 @@ +From 4b3932487a8dc2e87530e595ccabe48c79446f30 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Wed, 12 Feb 2025 11:29:05 +0100 +Subject: [PATCH 22/37] Move release steps to documentation/ + +Make a room for release MAINTAINERS file. + +Signed-off-by: Mariusz Tkaczyk +--- + MAINTAINERS.md => documentation/HOW_TO_RELEASE.md | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + rename MAINTAINERS.md => documentation/HOW_TO_RELEASE.md (100%) + +diff --git a/MAINTAINERS.md b/documentation/HOW_TO_RELEASE.md +similarity index 100% +rename from MAINTAINERS.md +rename to documentation/HOW_TO_RELEASE.md +-- +2.41.0 + diff --git a/0022-mdadm-drop-get_required_spare_criteria.patch b/0022-mdadm-drop-get_required_spare_criteria.patch deleted file mode 100644 index b3ebb67..0000000 --- a/0022-mdadm-drop-get_required_spare_criteria.patch +++ /dev/null @@ -1,357 +0,0 @@ -From f656201188d73cdc2726265f1348f8ffbf7587be Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:06 +0100 -Subject: [PATCH 22/41] mdadm: drop get_required_spare_criteria() - -Only IMSM implements get_spare_criteria, so load_super() in -get_required_spare_criteria() is dead code. It is moved inside -metadata handler, because only IMSM implements it. - -Give possibility to provide devnode to be opened. With that we can hide -load_container() used only to fill spare criteria inside handler -and simplify implementation in generic code. - -Add helper function for testing spare criteria in Incremental and -error messages. - -File descriptor in get_spare_criteria_imsm() is always opened on purpose. -New functionality added in next patches will require it. For the same -reason, function is moved to other place. - -No functional changes. - -Signed-off-by: Mariusz Tkaczyk ---- - Incremental.c | 77 ++++++++++++++++++++++---------- - Monitor.c | 35 +++------------ - mdadm.h | 5 +-- - super-intel.c | 120 +++++++++++++++++++++++++++++++++----------------- - 4 files changed, 140 insertions(+), 97 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index 2b5a5859..66c2cc86 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -833,6 +833,53 @@ container_members_max_degradation(struct map_ent *map, struct map_ent *me) - return max_degraded; - } - -+/** -+ * incremental_external_test_spare_criteria() - helper to test spare criteria. -+ * @st: supertype, must be not NULL, it is duplicated here. -+ * @container_devnm: devnm of the container. -+ * @disk_fd: file descriptor of device to tested. -+ * @verbose: verbose flag. -+ * -+ * The function is used on new drive verification path to check if it can be added to external -+ * container. To test spare criteria, metadata must be loaded. It duplicates super to not mess in -+ * original one. -+ * Function is executed if superblock supports get_spare_criteria(), otherwise success is returned. -+ */ -+mdadm_status_t incremental_external_test_spare_criteria(struct supertype *st, char *container_devnm, -+ int disk_fd, int verbose) -+{ -+ mdadm_status_t rv = MDADM_STATUS_ERROR; -+ char container_devname[PATH_MAX]; -+ struct spare_criteria sc = {0}; -+ struct supertype *dup; -+ -+ if (!st->ss->get_spare_criteria) -+ return MDADM_STATUS_SUCCESS; -+ -+ dup = dup_super(st); -+ snprintf(container_devname, PATH_MAX, "/dev/%s", container_devnm); -+ -+ if (dup->ss->get_spare_criteria(dup, container_devname, &sc) != 0) { -+ if (verbose > 1) -+ pr_err("Failed to get spare criteria for %s\n", container_devname); -+ goto out; -+ } -+ -+ if (!disk_fd_matches_criteria(disk_fd, &sc)) { -+ if (verbose > 1) -+ pr_err("Disk does not match spare criteria for %s\n", container_devname); -+ goto out; -+ } -+ -+ rv = MDADM_STATUS_SUCCESS; -+ -+out: -+ dup->ss->free_super(dup); -+ free(dup); -+ -+ return rv; -+} -+ - static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - struct map_ent *target, int bare, - struct supertype *st, int verbose) -@@ -873,8 +920,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - struct supertype *st2; - struct domainlist *dl = NULL; - struct mdinfo *sra; -- unsigned long long devsize, freesize = 0; -- struct spare_criteria sc = {0}; -+ unsigned long long freesize = 0; - - if (is_subarray(mp->metadata)) - continue; -@@ -925,34 +971,19 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - if (sra->array.failed_disks == -1) - sra->array.failed_disks = container_members_max_degradation(map, mp); - -- get_dev_size(dfd, NULL, &devsize); - if (sra->component_size == 0) { -- /* true for containers, here we must read superblock -- * to obtain minimum spare size */ -- struct supertype *st3 = dup_super(st2); -- int mdfd = open_dev(mp->devnm); -- if (mdfd < 0) { -- free(st3); -+ /* true for containers */ -+ if (incremental_external_test_spare_criteria(st2, mp->devnm, dfd, verbose)) - goto next; -- } -- if (st3->ss->load_container && -- !st3->ss->load_container(st3, mdfd, mp->path)) { -- if (st3->ss->get_spare_criteria) -- st3->ss->get_spare_criteria(st3, &sc); -- st3->ss->free_super(st3); -- } -- free(st3); -- close(mdfd); - } -- if ((sra->component_size > 0 && -- st2->ss->validate_geometry(st2, sra->array.level, sra->array.layout, -+ -+ if (sra->component_size > 0 && -+ st2->ss->validate_geometry(st2, sra->array.level, sra->array.layout, - sra->array.raid_disks, &sra->array.chunk_size, - sra->component_size, - sra->devs ? sra->devs->data_offset : INVALID_SECTORS, - devname, &freesize, sra->consistency_policy, -- 0) && -- freesize < sra->component_size) || -- (sra->component_size == 0 && devsize < sc.min_size)) { -+ 0) && freesize < sra->component_size) { - if (verbose > 1) - pr_err("not adding %s to %s as it is too small\n", - devname, mp->path); -diff --git a/Monitor.c b/Monitor.c -index 1ece8712..6b4560ae 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -1008,34 +1008,6 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist) - return new_found; - } - --static int get_required_spare_criteria(struct state *st, -- struct spare_criteria *sc) --{ -- int fd; -- -- if (!st->metadata || !st->metadata->ss->get_spare_criteria) { -- sc->min_size = 0; -- sc->sector_size = 0; -- return 0; -- } -- -- fd = open(st->devname, O_RDONLY); -- if (fd < 0) -- return 1; -- if (st->metadata->ss->external) -- st->metadata->ss->load_container(st->metadata, fd, st->devname); -- else -- st->metadata->ss->load_super(st->metadata, fd, st->devname); -- close(fd); -- if (!st->metadata->sb) -- return 1; -- -- st->metadata->ss->get_spare_criteria(st->metadata, sc); -- st->metadata->ss->free_super(st->metadata); -- -- return 0; --} -- - static int check_donor(struct state *from, struct state *to) - { - struct state *sub; -@@ -1178,8 +1150,11 @@ static void try_spare_migration(struct state *statelist) - /* member of a container */ - to = to->parent; - -- if (get_required_spare_criteria(to, &sc)) -- continue; -+ if (to->metadata->ss->get_spare_criteria) -+ if (to->metadata->ss->get_spare_criteria(to->metadata, to->devname, -+ &sc)) -+ continue; -+ - if (to->metadata->ss->external) { - /* We must make sure there is - * no suitable spare in container already. -diff --git a/mdadm.h b/mdadm.h -index e8abd730..cbc586f5 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1116,10 +1116,9 @@ extern struct superswitch { - * Return spare criteria for array: - * - minimum disk size can be used in array; - * - sector size can be used in array. -- * Return values: 0 - for success and -EINVAL on error. - */ -- int (*get_spare_criteria)(struct supertype *st, -- struct spare_criteria *sc); -+ mdadm_status_t (*get_spare_criteria)(struct supertype *st, char *mddev_path, -+ struct spare_criteria *sc); - /* Find somewhere to put a bitmap - possibly auto-size it - and - * update the metadata to record this. The array may be newly - * created, in which case data_size may be updated, or it might -diff --git a/super-intel.c b/super-intel.c -index 39ec4754..7ad391ac 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1736,46 +1736,6 @@ static __u32 imsm_min_reserved_sectors(struct intel_super *super) - return (remainder < rv) ? remainder : rv; - } - --/* -- * Return minimum size of a spare and sector size -- * that can be used in this array -- */ --int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c) --{ -- struct intel_super *super = st->sb; -- struct dl *dl; -- struct extent *e; -- int i; -- unsigned long long size = 0; -- -- if (!super) -- return -EINVAL; -- /* find first active disk in array */ -- dl = super->disks; -- while (dl && (is_failed(&dl->disk) || dl->index == -1)) -- dl = dl->next; -- if (!dl) -- return -EINVAL; -- /* find last lba used by subarrays */ -- e = get_extents(super, dl, 0); -- if (!e) -- return -EINVAL; -- for (i = 0; e[i].size; i++) -- continue; -- if (i > 0) -- size = e[i-1].start + e[i-1].size; -- free(e); -- -- /* add the amount of space needed for metadata */ -- size += imsm_min_reserved_sectors(super); -- -- c->min_size = size * 512; -- c->sector_size = super->sector_size; -- c->criteria_set = true; -- -- return 0; --} -- - static bool is_gen_migration(struct imsm_dev *dev); - - #define IMSM_4K_DIV 8 -@@ -11295,6 +11255,84 @@ static const char *imsm_get_disk_controller_domain(const char *path) - return drv; - } - -+/** -+ * get_spare_criteria_imsm() - set spare criteria. -+ * @st: supertype. -+ * @mddev_path: path to md device devnode, it must be container. -+ * @c: spare_criteria struct to fill, not NULL. -+ * -+ * If superblock is not loaded, use mddev_path to load_container. It must be given in this case. -+ * Filles size and sector size accordingly to superblock. -+ */ -+mdadm_status_t get_spare_criteria_imsm(struct supertype *st, char *mddev_path, -+ struct spare_criteria *c) -+{ -+ mdadm_status_t ret = MDADM_STATUS_ERROR; -+ bool free_superblock = false; -+ unsigned long long size = 0; -+ struct intel_super *super; -+ struct extent *e; -+ struct dl *dl; -+ int i; -+ -+ /* If no superblock and no mddev_path, we cannot load superblock. */ -+ assert(st->sb || mddev_path); -+ -+ if (mddev_path) { -+ int fd = open(mddev_path, O_RDONLY); -+ -+ if (!is_fd_valid(fd)) -+ return MDADM_STATUS_ERROR; -+ -+ if (!st->sb) { -+ if (load_container_imsm(st, fd, st->devnm)) { -+ close(fd); -+ return MDADM_STATUS_ERROR; -+ } -+ free_superblock = true; -+ } -+ close(fd); -+ } -+ -+ super = st->sb; -+ -+ /* find first active disk in array */ -+ dl = super->disks; -+ while (dl && (is_failed(&dl->disk) || dl->index == -1)) -+ dl = dl->next; -+ -+ if (!dl) -+ goto out; -+ -+ /* find last lba used by subarrays */ -+ e = get_extents(super, dl, 0); -+ if (!e) -+ goto out; -+ -+ for (i = 0; e[i].size; i++) -+ continue; -+ if (i > 0) -+ size = e[i - 1].start + e[i - 1].size; -+ free(e); -+ -+ /* add the amount of space needed for metadata */ -+ size += imsm_min_reserved_sectors(super); -+ -+ c->min_size = size * 512; -+ c->sector_size = super->sector_size; -+ c->criteria_set = true; -+ ret = MDADM_STATUS_SUCCESS; -+ -+out: -+ if (free_superblock) -+ free_super_imsm(st); -+ -+ if (ret != MDADM_STATUS_SUCCESS) -+ c->criteria_set = false; -+ -+ return ret; -+} -+ - static char *imsm_find_array_devnm_by_subdev(int subdev, char *container) - { - static char devnm[32]; -@@ -11425,7 +11463,7 @@ static struct mdinfo *get_spares_for_grow(struct supertype *st) - { - struct spare_criteria sc; - -- get_spare_criteria_imsm(st, &sc); -+ get_spare_criteria_imsm(st, NULL, &sc); - return container_choose_spares(st, &sc, NULL, NULL, NULL, 0); - } - --- -2.40.1 - diff --git a/0023-Manage-fix-check-after-dereference-issue.patch b/0023-Manage-fix-check-after-dereference-issue.patch deleted file mode 100644 index eec558c..0000000 --- a/0023-Manage-fix-check-after-dereference-issue.patch +++ /dev/null @@ -1,64 +0,0 @@ -From e97ca3583c96591af0e4863c12c394074a51c84d Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:07 +0100 -Subject: [PATCH 23/41] Manage: fix check after dereference issue - -The code dereferences dev_st earlier without checking, it gives SAST -problem. - -dev_st is needed for attempt_re_add(), but it is executed only if -dv->disposition != 'S', so move disposition check up. - -tst is a must to reach this place, dup_super() have to return valid -pointer, all it needs to check is if load_super() returns superblock. - -Signed-off-by: Mariusz Tkaczyk ---- - Manage.c | 26 ++++++++++++-------------- - 1 file changed, 12 insertions(+), 14 deletions(-) - -diff --git a/Manage.c b/Manage.c -index 30302ac8..77b79cf5 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -794,25 +794,23 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, - * simply re-add it. - */ - -- if (array->not_persistent == 0) { -+ if (array->not_persistent == 0 && dv->disposition != 'S') { -+ int rv = 0; -+ - dev_st = dup_super(tst); - dev_st->ss->load_super(dev_st, tfd, NULL); -- if (dev_st->sb && dv->disposition != 'S') { -- int rv; - -- rv = attempt_re_add(fd, tfd, dv, dev_st, tst, -- rdev, update, devname, -- verbose, array); -- dev_st->ss->free_super(dev_st); -- if (rv) { -- free(dev_st); -- return rv; -- } -- } -- if (dev_st) { -+ if (dev_st->sb) { -+ rv = attempt_re_add(fd, tfd, dv, dev_st, tst, rdev, update, -+ devname, verbose, array); -+ - dev_st->ss->free_super(dev_st); -- free(dev_st); - } -+ -+ free(dev_st); -+ -+ if (rv) -+ return rv; - } - if (dv->disposition == 'M') { - if (verbose > 0) --- -2.40.1 - diff --git a/0023-Rework-MAINTAINERS-file.patch b/0023-Rework-MAINTAINERS-file.patch new file mode 100644 index 0000000..2cf2c07 --- /dev/null +++ b/0023-Rework-MAINTAINERS-file.patch @@ -0,0 +1,102 @@ +From dacce2a0009f3506a5accf91f8fa9956eb36218e Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Wed, 12 Feb 2025 12:41:58 +0100 +Subject: [PATCH 23/37] Rework MAINTAINERS file + +Remove Mateusz. Intergrate it with README.md + +Signed-off-by: Mariusz Tkaczyk +--- + MAINTAINERS | 32 -------------------------------- + MAINTAINERS.md | 23 +++++++++++++++++++++++ + README.md | 5 +---- + 3 files changed, 24 insertions(+), 36 deletions(-) + delete mode 100644 MAINTAINERS + create mode 100644 MAINTAINERS.md + +diff --git a/MAINTAINERS b/MAINTAINERS +deleted file mode 100644 +index 0a1229fd..00000000 +--- a/MAINTAINERS ++++ /dev/null +@@ -1,32 +0,0 @@ +- +-# List of maintainers for mdadm +- +- +-Descriptions of section entries: +- +-M: Mail patches to: FullName +-L: Mailing list that is relevant to mdadm +- +- +-Alphabetical Order: +- +-M: Blazej Kucman +-L: linux-raid@vger.kernel.org +- +-M: Mateusz Kusiak +-L: linux-raid@vger.kernel.org +- +-M: Mariusz Tkaczyk +-L: linux-raid@vger.kernel.org +- +-M: Nigel Croxon +-L: linux-raid@vger.kernel.org +- +-M: Song Liu +-L: linux-raid@vger.kernel.org +- +-M: Xiao Ni +-L: linux-raid@vger.kernel.org +- +-M: Yu Kuai +-L: linux-raid@vger.kernel.org +diff --git a/MAINTAINERS.md b/MAINTAINERS.md +new file mode 100644 +index 00000000..00587484 +--- /dev/null ++++ b/MAINTAINERS.md +@@ -0,0 +1,23 @@ ++If you are sending patch through mailing list, please include everyone listed ++in this file. ++ ++## Github maintainers team ++ ++Github Pull Request must be `approved` by at least 2 maintainers team members: ++ ++ Name | Github Profile | Email address | ++| -- |----------------|---------------| ++| Blazej Kucman | [bkucman](https://github.com/bkucman) | | ++| Mariusz Tkaczyk | [mtkaczyk](https://github.com/mtkaczyk) | | ++| Nigel Croxon | [ncroxon](https://github.com/ncroxon) | | ++| Xiao Ni | [XiaoNi87](https://github.com/XiaoNi87) | | ++ ++## Kernel.org maintainers ++Reach this team specifically if you are observing differences ++between kernel.org and Github. ++ ++| Name | Email address | ++|------|----------------| ++| Mariusz Tkaczyk | | ++| Song Liu | | ++| Yu Kuai | | +diff --git a/README.md b/README.md +index 0c299a9a..029e0ee2 100644 +--- a/README.md ++++ b/README.md +@@ -77,10 +77,7 @@ to the chosen branch, then Pull Request will be automatically updated. + + # Maintainers of mdadm repository on kernel.org + +-If there are differences between github and kernel.org, please contact kernel.org mdadm maintainers: +- +-- Jes Sorensen ; +-- Mariusz Tkaczyk ; ++See [Maintainers File](MAINTAINERS.md). + + # Minimal supported kernel version + +-- +2.41.0 + diff --git a/0024-Manage-implement-manage_add_external.patch b/0024-Manage-implement-manage_add_external.patch deleted file mode 100644 index 9aa3d68..0000000 --- a/0024-Manage-implement-manage_add_external.patch +++ /dev/null @@ -1,184 +0,0 @@ -From 29273f606542d915a3ddf37bb084f4eff54fcc3b Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:08 +0100 -Subject: [PATCH 24/41] Manage: implement manage_add_external() - -Move external add code to separate function. It is easier to control -error path now. Error messages are adjusted. - -No functional changes. - -Signed-off-by: Mariusz Tkaczyk ---- - Manage.c | 147 ++++++++++++++++++++++++++++++++----------------------- - 1 file changed, 86 insertions(+), 61 deletions(-) - -diff --git a/Manage.c b/Manage.c -index 77b79cf5..b3e216cb 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -695,6 +695,91 @@ skip_re_add: - return 0; - } - -+/** -+ * manage_add_external() - Add disk to external container. -+ * @st: external supertype pointer, must not be NULL, superblock is released here. -+ * @fd: container file descriptor, must not have O_EXCL mode. -+ * @disk_fd: device to add file descriptor. -+ * @disk_name: name of the device to add. -+ * @disc: disk info. -+ * -+ * Superblock is released here because any open fd with O_EXCL will block sysfs_add_disk(). -+ */ -+mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name, -+ mdu_disk_info_t *disc) -+{ -+ mdadm_status_t rv = MDADM_STATUS_ERROR; -+ char container_devpath[MD_NAME_MAX]; -+ struct mdinfo new_mdi; -+ struct mdinfo *sra = NULL; -+ int container_fd; -+ int disk_fd = -1; -+ -+ snprintf(container_devpath, MD_NAME_MAX, "%s", fd2devnm(fd)); -+ -+ container_fd = open_dev_excl(container_devpath); -+ if (!is_fd_valid(container_fd)) { -+ pr_err("Failed to get exclusive access to container %s\n", container_devpath); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ /* Check if metadata handler is able to accept the drive */ -+ if (!st->ss->validate_geometry(st, LEVEL_CONTAINER, 0, 1, NULL, 0, 0, disk_name, NULL, -+ 0, 1)) -+ goto out; -+ -+ Kill(disk_name, NULL, 0, -1, 0); -+ -+ disk_fd = dev_open(disk_name, O_RDWR | O_EXCL | O_DIRECT); -+ if (!is_fd_valid(disk_fd)) { -+ pr_err("Failed to exclusively open %s\n", disk_name); -+ goto out; -+ } -+ -+ if (st->ss->add_to_super(st, disc, disk_fd, disk_name, INVALID_SECTORS)) -+ goto out; -+ -+ if (!mdmon_running(st->container_devnm)) -+ st->ss->sync_metadata(st); -+ -+ sra = sysfs_read(container_fd, NULL, 0); -+ if (!sra) { -+ pr_err("Failed to read sysfs for %s\n", disk_name); -+ goto out; -+ } -+ -+ sra->array.level = LEVEL_CONTAINER; -+ /* Need to set data_offset and component_size */ -+ st->ss->getinfo_super(st, &new_mdi, NULL); -+ new_mdi.disk.major = disc->major; -+ new_mdi.disk.minor = disc->minor; -+ new_mdi.recovery_start = 0; -+ -+ st->ss->free_super(st); -+ -+ if (sysfs_add_disk(sra, &new_mdi, 0) != 0) { -+ pr_err("Failed to add %s to container %s\n", disk_name, container_devpath); -+ goto out; -+ } -+ ping_monitor(container_devpath); -+ rv = MDADM_STATUS_SUCCESS; -+ -+out: -+ close(container_fd); -+ -+ if (sra) -+ sysfs_free(sra); -+ -+ if (rv != MDADM_STATUS_SUCCESS && is_fd_valid(disk_fd)) -+ /* Metadata handler records this descriptor, so release it only on failure. */ -+ close(disk_fd); -+ -+ if (st->sb) -+ st->ss->free_super(st); -+ -+ return rv; -+} -+ - int Manage_add(int fd, int tfd, struct mddev_dev *dv, - struct supertype *tst, mdu_array_info_t *array, - int force, int verbose, char *devname, -@@ -966,68 +1051,8 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, - if (dv->failfast == FlagSet) - disc.state |= (1 << MD_DISK_FAILFAST); - if (tst->ss->external) { -- /* add a disk -- * to an external metadata container */ -- struct mdinfo new_mdi; -- struct mdinfo *sra; -- int container_fd; -- char devnm[32]; -- int dfd; -- -- strcpy(devnm, fd2devnm(fd)); -- -- container_fd = open_dev_excl(devnm); -- if (container_fd < 0) { -- pr_err("add failed for %s: could not get exclusive access to container\n", -- dv->devname); -- tst->ss->free_super(tst); -+ if (manage_add_external(tst, fd, dv->devname, &disc) != MDADM_STATUS_SUCCESS) - goto unlock; -- } -- -- /* Check if metadata handler is able to accept the drive */ -- if (!tst->ss->validate_geometry(tst, LEVEL_CONTAINER, 0, 1, NULL, -- 0, 0, dv->devname, NULL, 0, 1)) { -- close(container_fd); -- goto unlock; -- } -- -- Kill(dv->devname, NULL, 0, -1, 0); -- dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT); -- if (tst->ss->add_to_super(tst, &disc, dfd, -- dv->devname, INVALID_SECTORS)) { -- close(dfd); -- close(container_fd); -- goto unlock; -- } -- if (!mdmon_running(tst->container_devnm)) -- tst->ss->sync_metadata(tst); -- -- sra = sysfs_read(container_fd, NULL, 0); -- if (!sra) { -- pr_err("add failed for %s: sysfs_read failed\n", -- dv->devname); -- close(container_fd); -- tst->ss->free_super(tst); -- goto unlock; -- } -- sra->array.level = LEVEL_CONTAINER; -- /* Need to set data_offset and component_size */ -- tst->ss->getinfo_super(tst, &new_mdi, NULL); -- new_mdi.disk.major = disc.major; -- new_mdi.disk.minor = disc.minor; -- new_mdi.recovery_start = 0; -- /* Make sure fds are closed as they are O_EXCL which -- * would block add_disk */ -- tst->ss->free_super(tst); -- if (sysfs_add_disk(sra, &new_mdi, 0) != 0) { -- pr_err("add new device to external metadata failed for %s\n", dv->devname); -- close(container_fd); -- sysfs_free(sra); -- goto unlock; -- } -- ping_monitor(devnm); -- sysfs_free(sra); -- close(container_fd); - } else { - tst->ss->free_super(tst); - if (ioctl(fd, ADD_NEW_DISK, &disc)) { --- -2.40.1 - diff --git a/0024-mdmon-imsm-fix-metadata-corruption-when-managing-new.patch b/0024-mdmon-imsm-fix-metadata-corruption-when-managing-new.patch new file mode 100644 index 0000000..1d41259 --- /dev/null +++ b/0024-mdmon-imsm-fix-metadata-corruption-when-managing-new.patch @@ -0,0 +1,122 @@ +From 7d29b3823c18a24d6efbb502f08638788f97e04b Mon Sep 17 00:00:00 2001 +From: Junxiao Bi +Date: Tue, 18 Feb 2025 10:48:31 -0800 +Subject: [PATCH 24/37] mdmon: imsm: fix metadata corruption when managing new + array + +When manager thread detects new array, it will invoke manage_new(). +For imsm array, it will further invoke imsm_open_new(). Since +commit bbab0940fa75("imsm: write bad block log on metadata sync"), +it preallocates bad block log when opening the array, that requires +increasing the mpb buffer size. +For that, imsm_open_new() invokes function imsm_update_metadata_locally(), +which first uses imsm_prepare_update() to allocate a larger mpb buffer +and store it at "mpb->next_buf", and then invoke imsm_process_update() +to copy the content from current mpb buffer "mpb->buf" to "mpb->next_buf", +and then free the current mpb buffer and set the new buffer as current. + +There is a small race window, when monitor thread is syncing metadata, +it gets current buffer pointer in imsm_sync_metadata()->write_super_imsm(), +but before flushing the buffer to disk, manager thread does above switching +buffer which frees current buffer, then monitor thread will run into +use-after-free issue and could cause on-disk metadata corruption. +If system keeps running, further metadata update could fix the corruption, +because after switching buffer, the new buffer will contain good metadata, +but if panic/power cycle happens while disk metadata is corrupted, +the system will run into bootup failure if array is used as root, +otherwise the array can not be assembled after boot if not used as root. + +This issue will not happen for imsm array with only one member array, +because the memory array has not be opened yet, monitor thread will not +do any metadata updates. +This can happen for imsm array with at lease two member array, in the +following two scenarios: +1. Restarting mdmon process with at least two member array +This will happen during system boot up or user restart mdmon after mdadm +upgrade +2. Adding new member array to exist imsm array with at least one member +array. + +To fix this, delay the switching buffer operation to monitor thread. + +Fixes: bbab0940fa75 ("imsm: write bad block log on metadata sync") +Signed-off-by: Junxiao Bi +--- + managemon.c | 10 ++++++++-- + super-intel.c | 14 +++++++++++--- + 2 files changed, 19 insertions(+), 5 deletions(-) + +diff --git a/managemon.c b/managemon.c +index d7981328..74b64bfc 100644 +--- a/managemon.c ++++ b/managemon.c +@@ -721,11 +721,12 @@ static void manage_new(struct mdstat_ent *mdstat, + * the monitor. + */ + ++ struct metadata_update *update = NULL; + struct active_array *new = NULL; + struct mdinfo *mdi = NULL, *di; +- int i, inst; +- int failed = 0; + char buf[SYSFS_MAX_BUF_SIZE]; ++ int failed = 0; ++ int i, inst; + + /* check if array is ready to be monitored */ + if (!mdstat->active || !mdstat->level) +@@ -824,9 +825,14 @@ static void manage_new(struct mdstat_ent *mdstat, + /* if everything checks out tell the metadata handler we want to + * manage this instance + */ ++ container->update_tail = &update; + if (!aa_ready(new) || container->ss->open_new(container, new, inst) < 0) { ++ container->update_tail = NULL; + goto error; + } else { ++ if (update) ++ queue_metadata_update(update); ++ container->update_tail = NULL; + replace_array(container, victim, new); + if (failed) { + new->check_degraded = 1; +diff --git a/super-intel.c b/super-intel.c +index cab84198..4988eef1 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -8467,12 +8467,15 @@ static int imsm_count_failed(struct intel_super *super, struct imsm_dev *dev, + return failed; + } + ++static int imsm_prepare_update(struct supertype *st, ++ struct metadata_update *update); + static int imsm_open_new(struct supertype *c, struct active_array *a, + int inst) + { + struct intel_super *super = c->sb; + struct imsm_super *mpb = super->anchor; +- struct imsm_update_prealloc_bb_mem u; ++ struct imsm_update_prealloc_bb_mem *u; ++ struct metadata_update mu; + + if (inst >= mpb->num_raid_devs) { + pr_err("subarry index %d, out of range\n", inst); +@@ -8482,8 +8485,13 @@ static int imsm_open_new(struct supertype *c, struct active_array *a, + dprintf("imsm: open_new %d\n", inst); + a->info.container_member = inst; + +- u.type = update_prealloc_badblocks_mem; +- imsm_update_metadata_locally(c, &u, sizeof(u)); ++ u = xmalloc(sizeof(*u)); ++ u->type = update_prealloc_badblocks_mem; ++ mu.len = sizeof(*u); ++ mu.buf = (char *)u; ++ imsm_prepare_update(c, &mu); ++ if (c->update_tail) ++ append_metadata_update(c, u, sizeof(*u)); + + return 0; + } +-- +2.41.0 + diff --git a/0025-Regression-fix-156.patch b/0025-Regression-fix-156.patch new file mode 100644 index 0000000..dc803f8 --- /dev/null +++ b/0025-Regression-fix-156.patch @@ -0,0 +1,217 @@ +From c2fbf66ba0243f499f78ed43fa1207a9bd9361b5 Mon Sep 17 00:00:00 2001 +From: XiaoNi87 +Date: Tue, 18 Mar 2025 08:18:04 +0800 +Subject: [PATCH 25/37] Regression fix (#156) + +Signed-off-by: Xiao Ni +--- + .github/tools/run_mdadm_tests.sh | 2 +- + test | 22 +++++++++++++++++++--- + tests/05r6tor0.broken | 15 +++++++++++++++ + tests/07revert-inplace.broken | 8 ++++++++ + tests/10ddf-create.broken | 5 ----- + tests/10ddf-fail-two-spares.broken | 5 ----- + tests/20raid5journal.broken | 17 +++++++++++++++++ + tests/env-ddf-template | 3 +-- + tests/skiptests | 9 +++++++++ + util.c | 2 +- + 10 files changed, 71 insertions(+), 17 deletions(-) + create mode 100644 tests/05r6tor0.broken + create mode 100644 tests/07revert-inplace.broken + delete mode 100644 tests/10ddf-create.broken + delete mode 100644 tests/10ddf-fail-two-spares.broken + create mode 100644 tests/20raid5journal.broken + create mode 100644 tests/skiptests + +diff --git a/.github/tools/run_mdadm_tests.sh b/.github/tools/run_mdadm_tests.sh +index 456874b5..22d89a8c 100755 +--- a/.github/tools/run_mdadm_tests.sh ++++ b/.github/tools/run_mdadm_tests.sh +@@ -11,7 +11,7 @@ sudo ./test setup + + #sudo ./test --tests=00createnames + +-sudo ./test --skip-broken --no-error --disable-integrity --disable-multipath --disable-linear --keep-going ++sudo ./test --skip-broken --no-error --disable-integrity --disable-multipath --disable-linear --keep-going --skip-bigcase + + ret=$? + sudo ./test cleanup +diff --git a/test b/test +index 88e44f18..7fa68177 100755 +--- a/test ++++ b/test +@@ -26,6 +26,10 @@ savelogs=0 + exitonerror=1 + ctrl_c_error=0 + skipbroken=0 ++skipbigcase=0 ++skipfile="skiptests" ++skipcheckfile=$testdir/$skipfile ++checkscript="" + loop=1 + prefix='[0-9][0-9]' + +@@ -192,6 +196,7 @@ do_help() { + --loop=N Run tests N times (0 to run forever) + --skip-broken Skip tests that are known to be broken + --skip-always-broken Skip tests that are known to always fail ++ --skip-bigcase Skip tests that need time than 200 seconds + --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk + --disks= Provide a bunch of physical devices for test + --volgroup=name LVM volume group for LVM test +@@ -295,6 +300,9 @@ parse_args() { + --skip-always-broken ) + skipbroken=always + ;; ++ --skip-bigcase ) ++ skipbigcase=all ++ ;; + --disable-multipath ) + unset MULTIPATH + ;; +@@ -369,9 +377,17 @@ main() { + else + for script in $testdir/$prefix $testdir/$prefix*[^~] + do +- case $script in *.broken) ;; +- *) +- do_test $script ++ checkscript="${script##*/}" ++ case $script in ++ *.broken) ++ ;; ++ *) ++ if grep -q "$checkscript" "$skipcheckfile"; then ++ if [ "$skipbigcase" == "all" ]; then ++ continue ++ fi ++ fi ++ do_test $script + esac + done + fi +diff --git a/tests/05r6tor0.broken b/tests/05r6tor0.broken +new file mode 100644 +index 00000000..930a0941 +--- /dev/null ++++ b/tests/05r6tor0.broken +@@ -0,0 +1,15 @@ ++Sometimes ++ +++++ pgrep -f 'mdadm --grow --continue' ++++ [[ '' != '' ]] ++++ break ++++ echo 100 ++++ echo 500 ++++ sleep 2 ++++ check raid5 ++++ case $1 in ++++ grep -sq 'active raid5 ' /proc/mdstat ++++ die 'active raid5 not found' ++++ echo -e '\n\tERROR: active raid5 not found \n' ++ ++ ERROR: active raid5 not found +diff --git a/tests/07revert-inplace.broken b/tests/07revert-inplace.broken +new file mode 100644 +index 00000000..73d98a04 +--- /dev/null ++++ b/tests/07revert-inplace.broken +@@ -0,0 +1,8 @@ ++always fails ++ ++Fails with errors: ++ ++ /usr/sbin/mdadm -A /dev/md0 --update=revert-reshape /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4 --backup-file=/tmp/md-backup ++++ rv=1 ++++ case $* in ++++ cat /var/tmp/stderr ++mdadm: failed to RUN_ARRAY /dev/md0: Invalid argument +diff --git a/tests/10ddf-create.broken b/tests/10ddf-create.broken +deleted file mode 100644 +index 0f7d25e5..00000000 +--- a/tests/10ddf-create.broken ++++ /dev/null +@@ -1,5 +0,0 @@ +-Fails due to segmentation fault at assemble. +- +-Too much effort to diagnose this now, marking as broken to make CI clear. +- ++ /usr/sbin/mdadm -A /dev/md/ddf0 /dev/loop8 /dev/loop9 /dev/loop10 /dev/loop11 /dev/loop12 +- ./test: line 76: 101955 Segmentation fault (core dumped) $mdadm "$@" 2> $targetdir/stderr +diff --git a/tests/10ddf-fail-two-spares.broken b/tests/10ddf-fail-two-spares.broken +deleted file mode 100644 +index eeea56d9..00000000 +--- a/tests/10ddf-fail-two-spares.broken ++++ /dev/null +@@ -1,5 +0,0 @@ +-fails infrequently +- +-Fails roughly 1 in 3 with error: +- +- ERROR: /dev/md/vol1 should be optimal in meta data +diff --git a/tests/20raid5journal.broken b/tests/20raid5journal.broken +new file mode 100644 +index 00000000..c7b214af +--- /dev/null ++++ b/tests/20raid5journal.broken +@@ -0,0 +1,17 @@ ++always fail ++ ++++ /usr/sbin/mdadm -I /dev/loop4 ++++ rv=0 ++++ case $* in ++++ cat /var/tmp/stderr ++mdadm: /dev/loop4 attached to /dev/md/0_0, which has been started. ++++ return 0 ++++ check raid5 ++++ case $1 in ++++ grep -sq 'active raid5 ' /proc/mdstat ++++ die 'active raid5 not found' ++++ echo -e '\n\tERROR: active raid5 not found \n' ++ ++ ERROR: active raid5 not found ++ ++++ save_log fail +diff --git a/tests/env-ddf-template b/tests/env-ddf-template +index 4f4ad0f3..ebc0ebf3 100644 +--- a/tests/env-ddf-template ++++ b/tests/env-ddf-template +@@ -3,8 +3,7 @@ sha1_sum() { + } + + get_rootdev() { +- local part=$(grep ' / ' /proc/mounts | awk '{print $1}') +- local bd=/dev/$(lsblk -no PKNAME $part) ++ local bd=$(grep ' / ' /proc/mounts | awk '{print $1}') + [ -b $bd ] || exit 1 + echo $bd + } +diff --git a/tests/skiptests b/tests/skiptests +new file mode 100644 +index 00000000..fd0893f1 +--- /dev/null ++++ b/tests/skiptests +@@ -0,0 +1,9 @@ ++casename:seconds ++01raid6integ:1732 ++01replace:396 ++07layouts:836 ++11spare-migration:1140 ++12imsm-r0_2d-grow-r0_5d:218 ++13imsm-r0_r0_2d-grow-r0_r0_4d:218 ++13imsm-r0_r0_2d-grow-r0_r0_5d:246 ++19raid6check:268 +diff --git a/util.c b/util.c +index 8c45f0e1..9fe2d227 100644 +--- a/util.c ++++ b/util.c +@@ -2310,7 +2310,7 @@ mdadm_status_t continue_via_systemd(char *devnm, char *service_name, char *prefi + dprintf("Start %s service\n", service_name); + /* Simply return that service cannot be started */ + if (check_env("MDADM_NO_SYSTEMCTL")) +- return MDADM_STATUS_SUCCESS; ++ return MDADM_STATUS_ERROR; + + /* Fork in attempt to start services */ + switch (fork()) { +-- +2.41.0 + diff --git a/0025-mdadm-introduce-sysfs_get_container_devnm.patch b/0025-mdadm-introduce-sysfs_get_container_devnm.patch deleted file mode 100644 index acd0f84..0000000 --- a/0025-mdadm-introduce-sysfs_get_container_devnm.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 14a8657940be34a781222b4b715bd09eb80d1057 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:09 +0100 -Subject: [PATCH 25/41] mdadm: introduce sysfs_get_container_devnm() - -There at least two places where it is done directly, so replace them -with function. Print message about creating external array, add "/dev/" -prefix to refer directly to devnode. - -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 21 ++++++++++----------- - Manage.c | 14 ++++---------- - mdadm.h | 2 ++ - sysfs.c | 23 +++++++++++++++++++++++ - 4 files changed, 39 insertions(+), 21 deletions(-) - -diff --git a/Create.c b/Create.c -index 7e9170b6..0b776266 100644 ---- a/Create.c -+++ b/Create.c -@@ -1142,24 +1142,23 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - - if (did_default && c->verbose >= 0) { - if (is_subarray(info.text_version)) { -- char devnm[32]; -- char *ep; -+ char devnm[MD_NAME_MAX]; - struct mdinfo *mdi; - -- strncpy(devnm, info.text_version+1, 32); -- devnm[31] = 0; -- ep = strchr(devnm, '/'); -- if (ep) -- *ep = 0; -+ sysfs_get_container_devnm(&info, devnm); - - mdi = sysfs_read(-1, devnm, GET_VERSION); -+ if (!mdi) { -+ pr_err("Cannot open sysfs for container %s\n", devnm); -+ goto abort_locked; -+ } -+ -+ pr_info("Creating array inside %s container /dev/%s\n", mdi->text_version, -+ devnm); - -- pr_info("Creating array inside %s container %s\n", -- mdi?mdi->text_version:"managed", devnm); - sysfs_free(mdi); - } else -- pr_info("Defaulting to version %s metadata\n", -- info.text_version); -+ pr_info("Defaulting to version %s metadata\n", info.text_version); - } - - map_update(&map, fd2devnm(mdfd), info.text_version, -diff --git a/Manage.c b/Manage.c -index b3e216cb..969d0ea9 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -178,7 +178,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - struct map_ent *map = NULL; - struct mdinfo *mdi; - char devnm[32]; -- char container[32]; -+ char container[MD_NAME_MAX] = {0}; - int err; - int count; - char buf[SYSFS_MAX_BUF_SIZE]; -@@ -192,15 +192,9 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - * to stop is probably a bad idea. - */ - mdi = sysfs_read(fd, NULL, GET_LEVEL|GET_COMPONENT|GET_VERSION); -- if (mdi && is_subarray(mdi->text_version)) { -- char *sl; -- strncpy(container, mdi->text_version+1, sizeof(container)); -- container[sizeof(container)-1] = 0; -- sl = strchr(container, '/'); -- if (sl) -- *sl = 0; -- } else -- container[0] = 0; -+ if (mdi && is_subarray(mdi->text_version)) -+ sysfs_get_container_devnm(mdi, container); -+ - close(fd); - count = 5; - while (((fd = ((devname[0] == '/') -diff --git a/mdadm.h b/mdadm.h -index cbc586f5..39b86bd0 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -777,6 +777,8 @@ enum sysfs_read_flags { - - #define SYSFS_MAX_BUF_SIZE 64 - -+extern void sysfs_get_container_devnm(struct mdinfo *mdi, char *buf); -+ - /* If fd >= 0, get the array it is open on, - * else use devnm. - */ -diff --git a/sysfs.c b/sysfs.c -index f95ef701..230b842e 100644 ---- a/sysfs.c -+++ b/sysfs.c -@@ -74,6 +74,29 @@ void sysfs_free(struct mdinfo *sra) - } - } - -+/** -+ * sysfs_get_container_devnm() - extract container device name. -+ * @mdi: md_info describes member array, with GET_VERSION option. -+ * @buf: buf to fill, must be MD_NAME_MAX. -+ * -+ * External array version is in format {/,-}/ -+ * Extract container_devnm from it and safe it in @buf. -+ */ -+void sysfs_get_container_devnm(struct mdinfo *mdi, char *buf) -+{ -+ char *p; -+ -+ assert(is_subarray(mdi->text_version)); -+ -+ /* Skip first special sign */ -+ snprintf(buf, MD_NAME_MAX, "%s", mdi->text_version + 1); -+ -+ /* Remove array index */ -+ p = strchr(buf, '/'); -+ if (p) -+ *p = 0; -+} -+ - int sysfs_open(char *devnm, char *devname, char *attr) - { - char fname[MAX_SYSFS_PATH_LEN]; --- -2.40.1 - diff --git a/0026-mdadm.h-Introduce-custom-device-policies.patch b/0026-mdadm.h-Introduce-custom-device-policies.patch deleted file mode 100644 index ed4caee..0000000 --- a/0026-mdadm.h-Introduce-custom-device-policies.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 1fef0c6ff54c2710f75a239dd8a5e0ffb0068e86 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:10 +0100 -Subject: [PATCH 26/41] mdadm.h: Introduce custom device policies - -The approach proposed here is to test drive policies outside -validate_geometry() separately per every drive and add determined -policies to list. The implementation reuses dev_policy we have in -mdadm. - -This concept addresses following problems: -- test drives if they fit together to criteria required by metadata - handler, -- test all drives assigned to the container even if some of them are not - target of the request, mdmon is free to use any drive in the same - container, -- extensibility, new policies can be added to handler easy, -- fix issues related to imsm controller domain verifying. - -Add superswitch function. It is used in next patches. - -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 54 ++++++++++++++++++++++++++++++++++++------------------ - 1 file changed, 36 insertions(+), 18 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index 39b86bd0..889f4a0f 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -940,6 +940,23 @@ struct reshape { - unsigned long long new_size; /* New size of array in sectors */ - }; - -+/** -+ * struct dev_policy - Data structure for policy management. -+ * @next: pointer to next dev_policy. -+ * @name: policy name, category. -+ * @metadata: the metadata type it affects. -+ * @value: value of the policy. -+ * -+ * The functions to manipulate dev_policy lists do not free elements, so they must be statically -+ * allocated. @name and @metadata can be compared by address. -+ */ -+typedef struct dev_policy { -+ struct dev_policy *next; -+ char *name; -+ const char *metadata; -+ const char *value; -+} dev_policy_t; -+ - /* A superswitch provides entry point to a metadata handler. - * - * The superswitch primarily operates on some "metadata" that -@@ -1168,6 +1185,25 @@ extern struct superswitch { - char *subdev, unsigned long long *freesize, - int consistency_policy, int verbose); - -+ /** -+ * test_and_add_drive_policies() - test new and add custom policies from metadata handler. -+ * @pols: list of currently recorded policies. -+ * @disk_fd: file descriptor of the device to check. -+ * @verbose: verbose flag. -+ * -+ * Used by IMSM to verify all drives in container/array, against requirements not recored -+ * in superblock, like controller type for IMSM. It should check all drives even if -+ * they are not actually used, because mdmon or kernel are free to use any drive assigned to -+ * container automatically. -+ * -+ * Generating and comparison methods belong to metadata handler. It is not mandatory to be -+ * implemented. -+ * -+ * Return: MDADM_STATUS_SUCCESS is expected on success. -+ */ -+ mdadm_status_t (*test_and_add_drive_policies)(dev_policy_t **pols, int disk_fd, -+ const int verbose); -+ - /* Return a linked list of 'mdinfo' structures for all arrays - * in the container. For non-containers, it is like - * getinfo_super with an allocated mdinfo.*/ -@@ -1372,23 +1408,6 @@ extern int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep); - extern int must_be_container(int fd); - void wait_for(char *dev, int fd); - --/* -- * Data structures for policy management. -- * Each device can have a policy structure that lists -- * various name/value pairs each possibly with a metadata associated. -- * The policy list is sorted by name/value/metadata -- */ --struct dev_policy { -- struct dev_policy *next; -- char *name; /* None of these strings are allocated. They are -- * all just references to strings which are known -- * to exist elsewhere. -- * name and metadata can be compared by address equality. -- */ -- const char *metadata; -- const char *value; --}; -- - extern char pol_act[], pol_domain[], pol_metadata[], pol_auto[]; - - /* iterate over the sublist starting at list, having the same -@@ -1430,7 +1449,6 @@ extern struct dev_policy *disk_policy(struct mdinfo *disk); - extern struct dev_policy *devid_policy(int devid); - extern void dev_policy_free(struct dev_policy *p); - --//extern void pol_new(struct dev_policy **pol, char *name, char *val, char *metadata); - extern void pol_add(struct dev_policy **pol, char *name, char *val, char *metadata); - extern struct dev_policy *pol_find(struct dev_policy *pol, char *name); - --- -2.40.1 - diff --git a/0026-super1-Clear-extra-flags-when-initializing-metadata.patch b/0026-super1-Clear-extra-flags-when-initializing-metadata.patch new file mode 100644 index 0000000..07408dc --- /dev/null +++ b/0026-super1-Clear-extra-flags-when-initializing-metadata.patch @@ -0,0 +1,72 @@ +From 4e2e208c8d3e9ba0fae88136d7c4cd0292af73b0 Mon Sep 17 00:00:00 2001 +From: Wu Guanghao +Date: Tue, 11 Mar 2025 03:11:55 +0000 +Subject: [PATCH 26/37] super1: Clear extra flags when initializing metadata + +When adding a disk to a RAID1 array, the metadata is read from the +existing member disks for sync. However, only the bad_blocks flag are +copied, the bad_blocks records are not copied, so the bad_blocks +records are all zeros. The kernel function super_1_load() detects +bad_blocks flag and reads the bad_blocks record, then sets the bad +block using badblocks_set(). + +After the kernel commit 1726c7746783 (badblocks: improve badblocks_set() +for multiple ranges handling) if the length of a bad_blocks record is 0, +it will return a failure. Therefore the device addition will fail. + +So when adding a new disk, some flags cannot be sync and need to be clead. + +Signed-off-by: Wu Guanghao +--- + super1.c | 3 +++ + tests/05r1-add-badblocks | 24 ++++++++++++++++++++++++ + 2 files changed, 27 insertions(+) + create mode 100644 tests/05r1-add-badblocks + +diff --git a/super1.c b/super1.c +index fe3c4c64..c828b682 100644 +--- a/super1.c ++++ b/super1.c +@@ -1971,6 +1971,9 @@ static int write_init_super1(struct supertype *st) + long bm_offset; + bool raid0_need_layout = false; + ++ /* Clear extra flags */ ++ sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_BAD_BLOCKS | MD_FEATURE_REPLACEMENT); ++ + /* Since linux kernel v5.4, raid0 always has a layout */ + if (has_raid0_layout(sb) && get_linux_version() >= 5004000) + raid0_need_layout = true; +diff --git a/tests/05r1-add-badblocks b/tests/05r1-add-badblocks +new file mode 100644 +index 00000000..6192327a +--- /dev/null ++++ b/tests/05r1-add-badblocks +@@ -0,0 +1,24 @@ ++# ++# create a raid1 with a drive and set badblocks for the drive. ++# add a new drive does not cause an error. ++# ++ ++# create raid1 ++mdadm -CR $md0 -l1 -n2 -e1.0 $dev1 missing ++testdev $md0 1 $mdsize1a 64 ++sleep 3 ++ ++# set badblocks for the drive ++dev1_name=$(basename $dev1) ++echo "100 100" > /sys/block/md0/md/dev-$dev1_name/bad_blocks ++echo "write_error" > /sys/block/md0/md/dev-$dev1_name/state ++ ++# write badblocks to metadata ++dd if=/dev/zero of=$md0 bs=512 count=200 oflag=direct ++ ++# re-add and recovery ++mdadm $md0 -a $dev2 ++check recovery ++ ++mdadm -S $md0 ++ +-- +2.41.0 + diff --git a/0027-imsm-Fix-RAID0-to-RAID10-migration.patch b/0027-imsm-Fix-RAID0-to-RAID10-migration.patch new file mode 100644 index 0000000..26b5d6b --- /dev/null +++ b/0027-imsm-Fix-RAID0-to-RAID10-migration.patch @@ -0,0 +1,74 @@ +From 127e38b59cbdf717d1569bcdc75b8d823d8485f3 Mon Sep 17 00:00:00 2001 +From: Blazej Kucman +Date: Mon, 31 Mar 2025 12:46:52 +0200 +Subject: [PATCH 27/37] imsm: Fix RAID0 to RAID10 migration + +Support for RAID10 with +4 disks in IMSM introduced an inconsistency +between the VROC UEFI driver and Linux IMSM. VROC UEFI does not +support RAID10 with +4 disks, therefore appropriate protections were +added to the mdadm IMSM code that results in skipping processing of +such RAID in the UEFI phase. Unfortunately the case of migration +RAID0 2 disks to RAID10 4 disks was omitted, this case requires +maintaining compatibility with the VROC UEFI driver because it is +supported. + +For RAID10 +4 disk the MPB_ATTRIB_RAID10_EXT attribute is set in the +metadata, thanks to which the UEFI driver does not process such RAID. +In the series adding support, a new metadata raid level value +IMSM_T_RAID10 was also introduced. It is not recognized by VROC UEFI. + +The issue is caused by the fact that in the case of the mentioned +migration, IMSM_T_RAID10 is entered into the metadata but attribute +MPB_ATTRIB_RAID10_EXT is not entered, which causes an attempt to +process such RAID in the UEFI phase. This situation results in +the platform hang during booting in UEFI phase, this also results in +data loss after failed and interrupted RAID processing in VROC UEFI. + +The above situation is result of the update_imsm_raid_level() +function, for the mentioned migration function is executed on a map +with a not yet updated number of disks. + +The fix is to explicitly handle migration in the function mentioned +above to maintain compatibility with VROC UEFI driver. + +Steps to reproduce: +mdadm -C /dev/md/imsm0 -e imsm -n 2 /dev/nvme[1,2]n1 -R +mdadm -C /dev/md/vol -l 0 -n 2 /dev/nvme[1,2]n1 --assume-clean -R +mdadm -a /dev/md127 /dev/nvme3n1 +mdadm -a /dev/md127 /dev/nvme4n1 +mdadm -G /dev/md126 -l 10 +reboot + +Fixes: 27550b13297a ("imsm: add support for literal RAID 10") +Signed-off-by: Blazej Kucman +--- + super-intel.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/super-intel.c b/super-intel.c +index 4988eef1..b7b030a2 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -1327,6 +1327,19 @@ static void update_imsm_raid_level(struct imsm_map *map, int new_level) + return; + } + ++ /* ++ * RAID0 to RAID10 migration. ++ * Due to the compatibility with VROC UEFI must be maintained, this case must be handled ++ * separately, because the map does not have an updated number of disks. ++ */ ++ if (map->raid_level == IMSM_T_RAID0) { ++ if (map->num_members == 2) ++ map->raid_level = IMSM_T_RAID1; ++ else ++ map->raid_level = IMSM_T_RAID10; ++ return; ++ } ++ + if (map->num_members == 4) { + if (map->raid_level == IMSM_T_RAID10 || map->raid_level == IMSM_T_RAID1) + return; +-- +2.41.0 + diff --git a/0027-mdadm-test_and_add-device-policies-implementation.patch b/0027-mdadm-test_and_add-device-policies-implementation.patch deleted file mode 100644 index b7bc9ce..0000000 --- a/0027-mdadm-test_and_add-device-policies-implementation.patch +++ /dev/null @@ -1,144 +0,0 @@ -From 5a2e194cb31569880a26356b8594ddca6e3b3828 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:11 +0100 -Subject: [PATCH 27/41] mdadm: test_and_add device policies implementation - -Add support for three scenarios: -- obtaining array wide policies via fd, -- obtaining array wide policies via struct mdinfo, -- getting policies for particular drive from the request. - -Add proper functions and make them extern. These functions are used -in next patches. - -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 7 +++++ - policy.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 100 insertions(+) - -diff --git a/mdadm.h b/mdadm.h -index 889f4a0f..af2bc714 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1452,6 +1452,13 @@ extern void dev_policy_free(struct dev_policy *p); - extern void pol_add(struct dev_policy **pol, char *name, char *val, char *metadata); - extern struct dev_policy *pol_find(struct dev_policy *pol, char *name); - -+extern mdadm_status_t drive_test_and_add_policies(struct supertype *st, dev_policy_t **pols, -+ int fd, const int verbose); -+extern mdadm_status_t sysfs_test_and_add_drive_policies(struct supertype *st, dev_policy_t **pols, -+ struct mdinfo *mdi, const int verbose); -+extern mdadm_status_t mddev_test_and_add_drive_policies(struct supertype *st, dev_policy_t **pols, -+ int array_fd, const int verbose); -+ - enum policy_action { - act_default, - act_include, -diff --git a/policy.c b/policy.c -index eee9ef63..4b85f62d 100644 ---- a/policy.c -+++ b/policy.c -@@ -397,6 +397,99 @@ struct dev_policy *path_policy(char **paths, char *type) - return pol; - } - -+/** -+ * drive_test_and_add_policies() - get policies for drive and add them to pols. -+ * @st: supertype. -+ * @pols: pointer to pointer of first list entry, cannot be NULL, may point to NULL. -+ * @fd: device descriptor. -+ * @verbose: verbose flag. -+ * -+ * If supertype doesn't support this functionality return success. Use metadata handler to get -+ * policies. -+ */ -+mdadm_status_t drive_test_and_add_policies(struct supertype *st, dev_policy_t **pols, int fd, -+ const int verbose) -+{ -+ if (!st->ss->test_and_add_drive_policies) -+ return MDADM_STATUS_SUCCESS; -+ -+ if (st->ss->test_and_add_drive_policies(pols, fd, verbose) == MDADM_STATUS_SUCCESS) { -+ /* After successful call list cannot be empty */ -+ assert(*pols); -+ return MDADM_STATUS_SUCCESS; -+ } -+ -+ return MDADM_STATUS_ERROR; -+} -+ -+/** -+ * sysfs_test_and_add_policies() - get policies for mddev and add them to pols. -+ * @st: supertype. -+ * @pols: pointer to pointer of first list entry, cannot be NULL, may point to NULL. -+ * @mdi: mdinfo describes the MD array, must have GET_DISKS option. -+ * @verbose: verbose flag. -+ * -+ * If supertype doesn't support this functionality return success. To get policies, all disks -+ * connected to mddev are analyzed. -+ */ -+mdadm_status_t sysfs_test_and_add_drive_policies(struct supertype *st, dev_policy_t **pols, -+ struct mdinfo *mdi, const int verbose) -+{ -+ struct mdinfo *sd; -+ -+ if (!st->ss->test_and_add_drive_policies) -+ return MDADM_STATUS_SUCCESS; -+ -+ for (sd = mdi->devs; sd; sd = sd->next) { -+ char *devpath = map_dev(sd->disk.major, sd->disk.minor, 0); -+ int fd = dev_open(devpath, O_RDONLY); -+ int rv; -+ -+ if (!is_fd_valid(fd)) { -+ pr_err("Cannot open fd for %s\n", devpath); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ rv = drive_test_and_add_policies(st, pols, fd, verbose); -+ close(fd); -+ -+ if (rv) -+ return MDADM_STATUS_ERROR; -+ } -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ -+/** -+ * mddev_test_and_add_policies() - get policies for mddev and add them to pols. -+ * @st: supertype. -+ * @pols: pointer to pointer of first list entry, cannot be NULL, may point to NULL. -+ * @array_fd: MD device descriptor. -+ * @verbose: verbose flag. -+ * -+ * If supertype doesn't support this functionality return success. Use fd to extract disks. -+ */ -+mdadm_status_t mddev_test_and_add_drive_policies(struct supertype *st, dev_policy_t **pols, -+ int array_fd, const int verbose) -+{ -+ struct mdinfo *sra; -+ int ret; -+ -+ if (!st->ss->test_and_add_drive_policies) -+ return MDADM_STATUS_SUCCESS; -+ -+ sra = sysfs_read(array_fd, NULL, GET_DEVS); -+ if (!sra) { -+ pr_err("Cannot load sysfs for %s\n", fd2devnm(array_fd)); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ ret = sysfs_test_and_add_drive_policies(st, pols, sra, verbose); -+ -+ sysfs_free(sra); -+ return ret; -+} -+ - void pol_add(struct dev_policy **pol, - char *name, char *val, - char *metadata) --- -2.40.1 - diff --git a/0028-Allow-RAID0-to-be-created-with-v0.90-metadata-161.patch b/0028-Allow-RAID0-to-be-created-with-v0.90-metadata-161.patch new file mode 100644 index 0000000..65489a5 --- /dev/null +++ b/0028-Allow-RAID0-to-be-created-with-v0.90-metadata-161.patch @@ -0,0 +1,193 @@ +From 6ce7f21bb822fd0125f78434d9fbf6c3db524892 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Fri, 4 Apr 2025 11:56:04 +1100 +Subject: [PATCH 28/37] Allow RAID0 to be created with v0.90 metadata #161 + +It is not currently possible to create a RAID0 with 0.90 metadata. +This is because 0.90 cannot specify the layout of RAID0 (it is +traditionally ignored) and different kernels do different things with +RAID0 layouts. + +However it should be possible to use --layout=dangerous as that +acknowledges the risk. +It also should be possible to create a RAID0 with all devices the same +size because in that case all layouts are identical. + +The metadata handler can only check that all devices are the same size +quite late - in write_init_super(). By that time the default is +currently set - set to a value that super0 cannot handle. + +So this patch delays the setting of the default value and leave it for +the metadata handler (or for the Build handler). + +super1 selects ORIG in that case. +intel and ddf don't support non-uniform RAID0 so they don't need any +change. +super0 now checks the sizes of devices if the default RAID0 layout was +requested and rejects the request in they are not the same. + +validiate_geometry0 now allows "dangerous" layouts for raid0. + +Signed-off-by: NeilBrown +--- + Build.c | 4 ++++ + Create.c | 2 +- + maps.c | 2 +- + mdadm.h | 1 + + super0.c | 34 +++++++++++++++++++++++++++++++++- + super1.c | 4 ++++ + tests/00raid0 | 4 ++-- + 7 files changed, 46 insertions(+), 5 deletions(-) + +diff --git a/Build.c b/Build.c +index 70aab7a0..9eb85a13 100644 +--- a/Build.c ++++ b/Build.c +@@ -103,6 +103,10 @@ int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s, + s->chunk = 64; + array.chunk_size = s->chunk*1024; + array.layout = s->layout; ++ ++ if (array.level == 0 && array.layout == UnSet) ++ /* Raid0 leaves default to metadata handler. That is us. */ ++ array.layout = RAID0_ORIG_LAYOUT; + if (md_set_array_info(mdfd, &array)) { + pr_err("md_set_array_info() failed for %s: %s\n", chosen_name, strerror(errno)); + goto abort; +diff --git a/Create.c b/Create.c +index fd6c9215..2b181dbf 100644 +--- a/Create.c ++++ b/Create.c +@@ -77,7 +77,7 @@ int default_layout(struct supertype *st, int level, int verbose) + layout = 0; + break; + case 0: +- layout = RAID0_ORIG_LAYOUT; ++ /* Leave unset - metadata handlers choose default */ + break; + case 10: + layout = 0x102; /* near=2, far=1 */ +diff --git a/maps.c b/maps.c +index 17f8b54d..2181b4ac 100644 +--- a/maps.c ++++ b/maps.c +@@ -81,7 +81,7 @@ mapping_t r0layout[] = { + { "alternate", RAID0_ALT_MULTIZONE_LAYOUT}, + { "1", 1}, /* aka ORIG */ + { "2", 2}, /* aka ALT */ +- { "dangerous", 0}, ++ { "dangerous", RAID0_DANGEROUS_LAYOUT}, + { NULL, UnSet}, + }; + +diff --git a/mdadm.h b/mdadm.h +index e84c341c..0ea83ad3 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -2003,6 +2003,7 @@ static inline int xasprintf(char **strp, const char *fmt, ...) { + #endif + + enum r0layout { ++ RAID0_DANGEROUS_LAYOUT = 0, /* layout depends on kernel version */ + RAID0_ORIG_LAYOUT = 1, + RAID0_ALT_MULTIZONE_LAYOUT = 2, + }; +diff --git a/super0.c b/super0.c +index ff4905b9..4a462bdc 100644 +--- a/super0.c ++++ b/super0.c +@@ -837,6 +837,7 @@ struct devinfo { + int fd; + char *devname; + mdu_disk_info_t disk; ++ unsigned long long dev_size; + struct devinfo *next; + }; + +@@ -866,6 +867,10 @@ static int add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo, + di->devname = devname; + di->disk = *dinfo; + di->next = NULL; ++ ++ if (is_fd_valid(fd)) ++ get_dev_size(fd, NULL, &di->dev_size); ++ + *dip = di; + + return 0; +@@ -929,6 +934,33 @@ static int write_init_super0(struct supertype *st) + int rv = 0; + struct devinfo *di; + ++ if (sb->level == 0 && sb->layout == UnSet) { ++ /* Without requesting a dangerous (0) layout ++ * we can only allow this RAID0 if all devices are ++ * the same size ++ */ ++ unsigned long long chunks = 0; ++ unsigned long chunk_sectors = sb->chunk_size >> 9; ++ ++ for (di = st->info; di; di = di->next) { ++ unsigned long long this_chunks; ++ ++ this_chunks = st->ss->avail_size(st, di->dev_size, 0) / chunk_sectors; ++ ++ if (chunks == 0) { ++ chunks = this_chunks; ++ continue; ++ } ++ ++ if (this_chunks != chunks) { ++ pr_err("Need explicit layout=dangerous to create 0.90 raid0 on non-uniform sized devices\n"); ++ return 1; ++ } ++ } ++ /* looks safe */ ++ sb->layout = 0; ++ } ++ + for (di = st->info ; di && ! rv ; di = di->next) { + + if (di->disk.state & (1 << MD_DISK_FAULTY)) +@@ -1321,7 +1353,7 @@ static int validate_geometry0(struct supertype *st, int level, + if (*chunk == UnSet) + *chunk = DEFAULT_CHUNK; + +- if (level == 0 && layout != UnSet) { ++ if (level == 0 && layout != UnSet && layout != RAID0_DANGEROUS_LAYOUT) { + if (verbose) + pr_err("0.90 metadata does not support layouts for RAID0\n"); + return 0; +diff --git a/super1.c b/super1.c +index c828b682..fb93f462 100644 +--- a/super1.c ++++ b/super1.c +@@ -1677,6 +1677,10 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info, + sizeof(sb->set_name) - namelen); + } + ++ if (info->level == 0 && info->layout == UnSet) ++ /* Metadata chooses default layout for RAID0 */ ++ info->layout = RAID0_ORIG_LAYOUT; ++ + sb->ctime = __cpu_to_le64((unsigned long long)time(0)); + sb->level = __cpu_to_le32(info->level); + sb->layout = __cpu_to_le32(info->layout); +diff --git a/tests/00raid0 b/tests/00raid0 +index 6407c320..94abcd49 100644 +--- a/tests/00raid0 ++++ b/tests/00raid0 +@@ -6,8 +6,8 @@ check raid0 + testdev $md0 3 $mdsize2_l 512 + mdadm -S $md0 + +-# verify raid0 with layouts fail for 0.90 +-mdadm -CR $md0 -e0.90 -l0 -n4 $dev0 $dev1 $dev2 $dev3 ++# verify raid0 with explicit layouts fail for 0.90 ++mdadm -CR $md0 -e0.90 -l0 --layout=original -n4 $dev0 $dev1 $dev2 $dev3 + check opposite_result + + # now with no superblock +-- +2.41.0 + diff --git a/0028-Create-Use-device-policies.patch b/0028-Create-Use-device-policies.patch deleted file mode 100644 index e49fea9..0000000 --- a/0028-Create-Use-device-policies.patch +++ /dev/null @@ -1,124 +0,0 @@ -From f5a39b66f794322f30828389ddd488d17f578ad5 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:12 +0100 -Subject: [PATCH 28/41] Create: Use device policies - -Generate and compare policies, abort if policies do not match. -It is tested for both create modes, with container and disk list -specified directly. It is used if supertype supports it. - -For a case when disk list is specified, container may contain more -devices, so additional check on container is done to analyze all disks. - -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 31 +++++++++++++++++++++++++------ - 1 file changed, 25 insertions(+), 6 deletions(-) - -diff --git a/Create.c b/Create.c -index 0b776266..4397ff49 100644 ---- a/Create.c -+++ b/Create.c -@@ -497,6 +497,7 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - */ - int mdfd; - unsigned long long minsize = 0, maxsize = 0; -+ dev_policy_t *custom_pols = NULL; - char *mindisc = NULL; - char *maxdisc = NULL; - char *name = ident->name; -@@ -588,6 +589,9 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - first_missing = subdevs * 2; - second_missing = subdevs * 2; - insert_point = subdevs * 2; -+ -+ if (mddev_test_and_add_drive_policies(st, &custom_pols, fd, 1)) -+ exit(1); - } - } - if (fd >= 0) -@@ -739,7 +743,7 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - close(dfd); - exit(2); - } -- close(dfd); -+ - info.array.working_disks++; - if (dnum < s->raiddisks && dv->disposition != 'j') - info.array.active_disks++; -@@ -812,6 +816,11 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - } - } - -+ if (drive_test_and_add_policies(st, &custom_pols, dfd, 1)) -+ exit(1); -+ -+ close(dfd); -+ - if (dv->disposition == 'j') - goto skip_size_check; /* skip write journal for size check */ - -@@ -886,6 +895,7 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - close(fd); - } - } -+ - if (missing_disks == dnum && !have_container) { - pr_err("Subdevs can't be all missing\n"); - return 1; -@@ -1140,25 +1150,30 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - goto abort_locked; - } - -- if (did_default && c->verbose >= 0) { -+ if (did_default) { - if (is_subarray(info.text_version)) { - char devnm[MD_NAME_MAX]; - struct mdinfo *mdi; - - sysfs_get_container_devnm(&info, devnm); - -- mdi = sysfs_read(-1, devnm, GET_VERSION); -+ mdi = sysfs_read(-1, devnm, GET_VERSION | GET_DEVS); - if (!mdi) { - pr_err("Cannot open sysfs for container %s\n", devnm); - goto abort_locked; - } - -- pr_info("Creating array inside %s container /dev/%s\n", mdi->text_version, -- devnm); -+ if (sysfs_test_and_add_drive_policies(st, &custom_pols, mdi, 1)) -+ goto abort_locked; -+ -+ if (c->verbose >= 0) -+ pr_info("Creating array inside %s container /dev/%s\n", -+ mdi->text_version, devnm); - - sysfs_free(mdi); -- } else -+ } else if (c->verbose >= 0) { - pr_info("Defaulting to version %s metadata\n", info.text_version); -+ } - } - - map_update(&map, fd2devnm(mdfd), info.text_version, -@@ -1328,6 +1343,8 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - udev_unblock(); - close(mdfd); - sysfs_uevent(&info, "change"); -+ dev_policy_free(custom_pols); -+ - return 0; - - abort: -@@ -1339,5 +1356,7 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - - if (mdfd >= 0) - close(mdfd); -+ -+ dev_policy_free(custom_pols); - return 1; - } --- -2.40.1 - diff --git a/0029-Manage-check-device-policies-in-manage_add_external.patch b/0029-Manage-check-device-policies-in-manage_add_external.patch deleted file mode 100644 index 061f77c..0000000 --- a/0029-Manage-check-device-policies-in-manage_add_external.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 1251db34616bf4890d86664abc5186e9106e9073 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:13 +0100 -Subject: [PATCH 29/41] Manage: check device policies in manage_add_external() - -Only IMSM is going to use device policies so it is added to -manage_add_external(). Test policies before adding the drive to -container. - -The change blocks adding new device to the container which already -contains not matching devices - -Signed-off-by: Mariusz Tkaczyk ---- - Manage.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/Manage.c b/Manage.c -index 969d0ea9..96e5ee54 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -704,6 +704,7 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name - { - mdadm_status_t rv = MDADM_STATUS_ERROR; - char container_devpath[MD_NAME_MAX]; -+ struct dev_policy *pols = NULL; - struct mdinfo new_mdi; - struct mdinfo *sra = NULL; - int container_fd; -@@ -722,6 +723,9 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name - 0, 1)) - goto out; - -+ if (mddev_test_and_add_drive_policies(st, &pols, container_fd, 1)) -+ goto out; -+ - Kill(disk_name, NULL, 0, -1, 0); - - disk_fd = dev_open(disk_name, O_RDWR | O_EXCL | O_DIRECT); -@@ -730,6 +734,9 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name - goto out; - } - -+ if (drive_test_and_add_policies(st, &pols, disk_fd, 1)) -+ goto out; -+ - if (st->ss->add_to_super(st, disc, disk_fd, disk_name, INVALID_SECTORS)) - goto out; - -@@ -760,6 +767,7 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name - - out: - close(container_fd); -+ dev_policy_free(pols); - - if (sra) - sysfs_free(sra); --- -2.40.1 - diff --git a/0029-Update-tests.yml.patch b/0029-Update-tests.yml.patch new file mode 100644 index 0000000..e905aba --- /dev/null +++ b/0029-Update-tests.yml.patch @@ -0,0 +1,45 @@ +From b532421e747d75223c6f7a065fb643d2d318011c Mon Sep 17 00:00:00 2001 +From: Paul Luse +Date: Thu, 24 Apr 2025 07:30:10 -0700 +Subject: [PATCH 29/37] Update tests.yml + +Signed-off-by: Paul Luse +--- + .github/workflows/tests.yml | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index ce940108..6f8e2b8e 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -31,9 +31,15 @@ jobs: + - name: 'Prepare machine' + run: | + cd .. +- vagrant halt ++ vagrant snapshot restore clean_vm_v42 ++ echo "FYI vagrant restore command finished with exit code: $?" ++ sleep 2 + vagrant status + vagrant up ++ sleep 2 ++ vagrant ssh -c "sudo timedatectl set-timezone UTC && \ ++ sudo systemctl restart chronyd && sudo chronyc -a makestep && sleep 1" ++ echo "FYI vagrant time command finished with exit code: $?" + + - name: 'Run tests' + id: testing +@@ -69,9 +75,7 @@ jobs: + runs-on: self-hosted + needs: [upstream_tests] + steps: +- - name: Restore clean VM ++ - name: Halt VM + run: | + cd .. +- vagrant up +- vagrant ssh -c "sudo mdadm -Ss" + vagrant halt +-- +2.41.0 + diff --git a/0030-Monitor-Incremental-use-device-policies.patch b/0030-Monitor-Incremental-use-device-policies.patch deleted file mode 100644 index 753ee8f..0000000 --- a/0030-Monitor-Incremental-use-device-policies.patch +++ /dev/null @@ -1,142 +0,0 @@ -From 51a9f2fc5e982f3bcbf88fe1bf30c0bf55bfd49c Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:14 +0100 -Subject: [PATCH 30/41] Monitor, Incremental: use device policies - -spare_criteria is expanded to contain policies which will be generated -by handler's get_spare_criteria() function. It provides a way to -test device for metadata specific policies earlier than during -add_do_super(), when device is already removed from previous -array/container for Monitor. - -For Incremental, it ensures that all criteria are tested when trying -spare. It is not tested when device contains valid metadata. - -Signed-off-by: Mariusz Tkaczyk ---- - Incremental.c | 2 +- - Monitor.c | 3 ++- - mdadm.h | 5 +++-- - util.c | 13 +++++++++---- - 4 files changed, 15 insertions(+), 8 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index 66c2cc86..958ba9ba 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -865,7 +865,7 @@ mdadm_status_t incremental_external_test_spare_criteria(struct supertype *st, ch - goto out; - } - -- if (!disk_fd_matches_criteria(disk_fd, &sc)) { -+ if (!disk_fd_matches_criteria(dup, disk_fd, &sc)) { - if (verbose > 1) - pr_err("Disk does not match spare criteria for %s\n", container_devname); - goto out; -diff --git a/Monitor.c b/Monitor.c -index 6b4560ae..9b016bc3 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -1047,7 +1047,7 @@ static dev_t choose_spare(struct state *from, struct state *to, - test_partition_from_id(from->devid[d])) - continue; - -- if (devid_matches_criteria(from->devid[d], sc) == false) -+ if (devid_matches_criteria(to->metadata, from->devid[d], sc) == false) - continue; - - pol = devid_policy(from->devid[d]); -@@ -1195,6 +1195,7 @@ static void try_spare_migration(struct state *statelist) - } - } - domain_free(domlist); -+ dev_policy_free(sc.pols); - } - } - -diff --git a/mdadm.h b/mdadm.h -index af2bc714..cfa11391 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -433,6 +433,7 @@ struct spare_criteria { - bool criteria_set; - unsigned long long min_size; - unsigned int sector_size; -+ struct dev_policy *pols; - }; - - typedef enum mdadm_status { -@@ -1734,8 +1735,8 @@ extern int assemble_container_content(struct supertype *st, int mdfd, - #define INCR_ALREADY 4 - #define INCR_YES 8 - --extern bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc); --extern bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc); -+extern bool devid_matches_criteria(struct supertype *st, dev_t devid, struct spare_criteria *sc); -+extern bool disk_fd_matches_criteria(struct supertype *st, int disk_fd, struct spare_criteria *sc); - extern struct mdinfo *container_choose_spares(struct supertype *st, - struct spare_criteria *criteria, - struct domainlist *domlist, -diff --git a/util.c b/util.c -index 041e78cf..05ad3343 100644 ---- a/util.c -+++ b/util.c -@@ -2056,12 +2056,13 @@ unsigned int __invalid_size_argument_for_IOC = 0; - - /** - * disk_fd_matches_criteria() - check if device matches spare criteria. -+ * @st: supertype, not NULL. - * @disk_fd: file descriptor of the disk. - * @sc: criteria to test. - * - * Return: true if disk matches criteria, false otherwise. - */ --bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc) -+bool disk_fd_matches_criteria(struct supertype *st, int disk_fd, struct spare_criteria *sc) - { - unsigned int dev_sector_size = 0; - unsigned long long dev_size = 0; -@@ -2076,17 +2077,21 @@ bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc) - sc->sector_size != dev_sector_size) - return false; - -+ if (drive_test_and_add_policies(st, &sc->pols, disk_fd, 0)) -+ return false; -+ - return true; - } - - /** - * devid_matches_criteria() - check if device referenced by devid matches spare criteria. -+ * @st: supertype, not NULL. - * @devid: devid of the device to check. - * @sc: criteria to test. - * - * Return: true if disk matches criteria, false otherwise. - */ --bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc) -+bool devid_matches_criteria(struct supertype *st, dev_t devid, struct spare_criteria *sc) - { - char buf[NAME_MAX]; - bool ret; -@@ -2102,7 +2107,7 @@ bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc) - return false; - - /* Error code inherited */ -- ret = disk_fd_matches_criteria(fd, sc); -+ ret = disk_fd_matches_criteria(st, fd, sc); - - close(fd); - return ret; -@@ -2137,7 +2142,7 @@ struct mdinfo *container_choose_spares(struct supertype *st, - if (d->disk.state == 0) { - dev_t dev = makedev(d->disk.major,d->disk.minor); - -- found = devid_matches_criteria(dev, criteria); -+ found = devid_matches_criteria(st, dev, criteria); - - /* check if domain matches */ - if (found && domlist) { --- -2.40.1 - diff --git a/0030-Update-tests.yml.patch b/0030-Update-tests.yml.patch new file mode 100644 index 0000000..d545af7 --- /dev/null +++ b/0030-Update-tests.yml.patch @@ -0,0 +1,26 @@ +From 07bde560b71a2f6e36de5bc6f24e07e761c1c83b Mon Sep 17 00:00:00 2001 +From: Paul Luse +Date: Thu, 24 Apr 2025 08:38:29 -0700 +Subject: [PATCH 30/37] Update tests.yml + +Signed-off-by: Paul Luse +--- + .github/workflows/tests.yml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index 6f8e2b8e..b4c156c0 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -65,7 +65,7 @@ jobs: + if: ${{ steps.testing.outcome == 'failure' }} + run: | + cd .. +- sudo rm /home/ci/actions-runner/_work/mdadm/logs/*.log ++ sudo rm -rf /home/ci/actions-runner/_work/mdadm/logs/*.log + + - name: "Set failed" + if: ${{ steps.testing.outcome == 'failure' }} +-- +2.41.0 + diff --git a/0031-Update-tests.yml.patch b/0031-Update-tests.yml.patch new file mode 100644 index 0000000..e455753 --- /dev/null +++ b/0031-Update-tests.yml.patch @@ -0,0 +1,26 @@ +From affe2168b807ccd48f00dc9e021196a5e2e83870 Mon Sep 17 00:00:00 2001 +From: Paul Luse +Date: Thu, 24 Apr 2025 08:41:15 -0700 +Subject: [PATCH 31/37] Update tests.yml + +Signed-off-by: Paul Luse +--- + .github/workflows/tests.yml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index b4c156c0..9b361571 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -37,7 +37,7 @@ jobs: + vagrant status + vagrant up + sleep 2 +- vagrant ssh -c "sudo timedatectl set-timezone UTC && \ ++ vagrant ssh -c "uname -r && sudo timedatectl set-timezone UTC && \ + sudo systemctl restart chronyd && sudo chronyc -a makestep && sleep 1" + echo "FYI vagrant time command finished with exit code: $?" + +-- +2.41.0 + diff --git a/0031-imsm-test_and_add_device_policies-implementation.patch b/0031-imsm-test_and_add_device_policies-implementation.patch deleted file mode 100644 index 86161d4..0000000 --- a/0031-imsm-test_and_add_device_policies-implementation.patch +++ /dev/null @@ -1,187 +0,0 @@ -From e21aea08eb706939a38f7dc5cf9509a9afd45f8a Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:15 +0100 -Subject: [PATCH 31/41] imsm: test_and_add_device_policies() implementation - -This patch removes get_disk_controller_domain_imsm() in favour of -test_and_add_device_policies_imsm(). It is used by -create, add and mdmonitor. - -Signed-off-by: Mariusz Tkaczyk ---- - platform-intel.h | 1 - - super-intel.c | 123 ++++++++++++++++++++++++++++++++++------------- - 2 files changed, 90 insertions(+), 34 deletions(-) - -diff --git a/platform-intel.h b/platform-intel.h -index ce29d3da..3c2bc595 100644 ---- a/platform-intel.h -+++ b/platform-intel.h -@@ -262,7 +262,6 @@ 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); --const char *get_sys_dev_type(enum sys_dev_type); - 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 7ad391ac..77140455 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -11220,39 +11220,90 @@ abort: - return retval; - } - --static char disk_by_path[] = "/dev/disk/by-path/"; -- --static const char *imsm_get_disk_controller_domain(const char *path) --{ -- char disk_path[PATH_MAX]; -- char *drv=NULL; -- struct stat st; -- -- strncpy(disk_path, disk_by_path, PATH_MAX); -- strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1); -- if (stat(disk_path, &st) == 0) { -- struct sys_dev* hba; -- char *path; -- -- path = devt_to_devpath(st.st_rdev, 1, NULL); -- if (path == NULL) -- return "unknown"; -- hba = find_disk_attached_hba(-1, path); -- if (hba && hba->type == SYS_DEV_SAS) -- drv = "isci"; -- else if (hba && (hba->type == SYS_DEV_SATA || hba->type == SYS_DEV_SATA_VMD)) -- drv = "ahci"; -- else if (hba && hba->type == SYS_DEV_VMD) -- drv = "vmd"; -- else if (hba && hba->type == SYS_DEV_NVME) -- drv = "nvme"; -- else -- drv = "unknown"; -- dprintf("path: %s hba: %s attached: %s\n", -- path, (hba) ? hba->path : "NULL", drv); -- free(path); -+/** -+ * test_and_add_drive_controller_policy_imsm() - add disk controller to policies list. -+ * @type: Policy type to search on list. -+ * @pols: List of currently recorded policies. -+ * @disk_fd: File descriptor of the device to check. -+ * @hba: The hba disk is attached, could be NULL if verification is disabled. -+ * @verbose: verbose flag. -+ * -+ * IMSM cares about drive physical placement. If @hba is not set, it adds unknown policy. -+ * If there is no controller policy on pols we are free to add first one. If there is a policy then, -+ * new must be the same - no controller mixing allowed. -+ */ -+static mdadm_status_t -+test_and_add_drive_controller_policy_imsm(const char * const type, dev_policy_t **pols, int disk_fd, -+ struct sys_dev *hba, const int verbose) -+{ -+ const char *controller_policy = get_sys_dev_type(SYS_DEV_UNKNOWN); -+ struct dev_policy *pol = pol_find(*pols, (char *)type); -+ char devname[MAX_RAID_SERIAL_LEN]; -+ -+ if (hba) -+ controller_policy = get_sys_dev_type(hba->type); -+ -+ if (!pol) { -+ pol_add(pols, (char *)type, (char *)controller_policy, "imsm"); -+ return MDADM_STATUS_SUCCESS; - } -- return drv; -+ -+ if (strcmp(pol->value, controller_policy) == 0) -+ return MDADM_STATUS_SUCCESS; -+ -+ fd2devname(disk_fd, devname); -+ pr_vrb("Intel(R) raid controller \"%s\" found for %s, but \"%s\" was detected earlier\n", -+ controller_policy, devname, pol->value); -+ pr_vrb("Disks under different controllers cannot be used, aborting\n"); -+ -+ return MDADM_STATUS_ERROR; -+} -+ -+struct imsm_drive_policy { -+ char *type; -+ mdadm_status_t (*test_and_add_drive_policy)(const char * const type, -+ struct dev_policy **pols, int disk_fd, -+ struct sys_dev *hba, const int verbose); -+}; -+ -+struct imsm_drive_policy imsm_policies[] = { -+ {"controller", test_and_add_drive_controller_policy_imsm}, -+}; -+ -+mdadm_status_t test_and_add_drive_policies_imsm(struct dev_policy **pols, int disk_fd, -+ const int verbose) -+{ -+ struct imsm_drive_policy *imsm_pol; -+ struct sys_dev *hba = NULL; -+ char path[PATH_MAX]; -+ mdadm_status_t ret; -+ unsigned int i; -+ -+ /* If imsm platform verification is disabled, do not search for hba. */ -+ if (check_no_platform() != 1) { -+ if (!diskfd_to_devpath(disk_fd, 1, path)) { -+ pr_vrb("IMSM: Failed to retrieve device path by file descriptor.\n"); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ hba = find_disk_attached_hba(disk_fd, path); -+ if (!hba) { -+ pr_vrb("IMSM: Failed to find hba for %s\n", path); -+ return MDADM_STATUS_ERROR; -+ } -+ } -+ -+ for (i = 0; i < ARRAY_SIZE(imsm_policies); i++) { -+ imsm_pol = &imsm_policies[i]; -+ -+ ret = imsm_pol->test_and_add_drive_policy(imsm_pol->type, pols, disk_fd, hba, -+ verbose); -+ if (ret != MDADM_STATUS_SUCCESS) -+ /* Inherit error code */ -+ return ret; -+ } -+ -+ return MDADM_STATUS_SUCCESS; - } - - /** -@@ -11280,6 +11331,7 @@ mdadm_status_t get_spare_criteria_imsm(struct supertype *st, char *mddev_path, - - if (mddev_path) { - int fd = open(mddev_path, O_RDONLY); -+ mdadm_status_t rv; - - if (!is_fd_valid(fd)) - return MDADM_STATUS_ERROR; -@@ -11291,7 +11343,12 @@ mdadm_status_t get_spare_criteria_imsm(struct supertype *st, char *mddev_path, - } - free_superblock = true; - } -+ -+ rv = mddev_test_and_add_drive_policies(st, &c->pols, fd, 0); - close(fd); -+ -+ if (rv != MDADM_STATUS_SUCCESS) -+ goto out; - } - - super = st->sb; -@@ -13026,7 +13083,7 @@ struct superswitch super_imsm = { - .update_subarray = update_subarray_imsm, - .load_container = load_container_imsm, - .default_geometry = default_geometry_imsm, -- .get_disk_controller_domain = imsm_get_disk_controller_domain, -+ .test_and_add_drive_policies = test_and_add_drive_policies_imsm, - .reshape_super = imsm_reshape_super, - .manage_reshape = imsm_manage_reshape, - .recover_backup = recover_backup_imsm, --- -2.40.1 - diff --git a/0032-Update-tests.yml.patch b/0032-Update-tests.yml.patch new file mode 100644 index 0000000..fb0e546 --- /dev/null +++ b/0032-Update-tests.yml.patch @@ -0,0 +1,29 @@ +From 5fd2f5da6fe7995190627f8a7bd9f6ff90aad1d4 Mon Sep 17 00:00:00 2001 +From: Paul Luse +Date: Thu, 24 Apr 2025 09:03:32 -0700 +Subject: [PATCH 32/37] Update tests.yml + +Signed-off-by: Paul Luse +--- + .github/workflows/tests.yml | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index 9b361571..2556fccf 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -37,9 +37,8 @@ jobs: + vagrant status + vagrant up + sleep 2 +- vagrant ssh -c "uname -r && sudo timedatectl set-timezone UTC && \ +- sudo systemctl restart chronyd && sudo chronyc -a makestep && sleep 1" +- echo "FYI vagrant time command finished with exit code: $?" ++ vagrant ssh -c "uname -r" ++ echo "FYI vagrant uname command finished with exit code: $?" + + - name: 'Run tests' + id: testing +-- +2.41.0 + diff --git a/0032-mdadm-drop-get_disk_controller_domain.patch b/0032-mdadm-drop-get_disk_controller_domain.patch deleted file mode 100644 index be22fdf..0000000 --- a/0032-mdadm-drop-get_disk_controller_domain.patch +++ /dev/null @@ -1,75 +0,0 @@ -From e492d2ac143e7f02d6c262130d42a4422e8295d5 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:16 +0100 -Subject: [PATCH 32/41] mdadm: drop get_disk_controller_domain() - -This function is unused now. Drop it. -Controller for IMSM is a device policy and is separated from user defined -domains. - -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 15 --------------- - policy.c | 13 ------------- - 2 files changed, 28 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index cfa11391..3fedca48 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1286,21 +1286,6 @@ extern struct superswitch { - */ - struct mdinfo *(*activate_spare)(struct active_array *a, - struct metadata_update **updates); -- /* -- * Return statically allocated string that represents metadata specific -- * controller domain of the disk. The domain is used in disk domain -- * matching functions. Disks belong to the same domain if the they have -- * the same domain from mdadm.conf and belong the same metadata domain. -- * Returning NULL or not providing this handler means that metadata -- * does not distinguish the differences between disks that belong to -- * different controllers. They are in the domain specified by -- * configuration file (mdadm.conf). -- * In case when the metadata has the notion of domains based on disk -- * it shall return NULL for disks that do not belong to the controller -- * the supported domains. Such disks will form another domain and won't -- * be mixed with supported ones. -- */ -- const char *(*get_disk_controller_domain)(const char *path); - - /* for external backup area */ - int (*recover_backup)(struct supertype *st, struct mdinfo *info); -diff --git a/policy.c b/policy.c -index 4b85f62d..404f9b5d 100644 ---- a/policy.c -+++ b/policy.c -@@ -365,7 +365,6 @@ struct dev_policy *path_policy(char **paths, char *type) - { - struct pol_rule *rules; - struct dev_policy *pol = NULL; -- int i; - - rules = config_rules; - -@@ -380,18 +379,6 @@ struct dev_policy *path_policy(char **paths, char *type) - rules = rules->next; - } - -- /* Now add any metadata-specific internal knowledge -- * about this path -- */ -- for (i=0; paths && paths[0] && superlist[i]; i++) -- if (superlist[i]->get_disk_controller_domain) { -- const char *d = -- superlist[i]->get_disk_controller_domain( -- paths[0]); -- if (d) -- pol_new(&pol, pol_domain, d, superlist[i]->name); -- } -- - pol_sort(&pol); - pol_dedup(pol); - return pol; --- -2.40.1 - diff --git a/0033-Revert-policy.c-Avoid-to-take-spare-without-defined-.patch b/0033-Revert-policy.c-Avoid-to-take-spare-without-defined-.patch deleted file mode 100644 index b38a1da..0000000 --- a/0033-Revert-policy.c-Avoid-to-take-spare-without-defined-.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 933bb500b80cca6f4e9237382f7d8ac852978471 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 29 Feb 2024 12:52:17 +0100 -Subject: [PATCH 33/41] Revert "policy.c: Avoid to take spare without defined - domain by imsm" - -This reverts commit 3bf9495270d7 ("policy.c: Avoid to take spare without -defined domain by imsm"). - -IMSM does not require to be special now because it doesn't create disk -controller domain. - -Signed-off-by: Mariusz Tkaczyk ---- - policy.c | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/policy.c b/policy.c -index 404f9b5d..dfaafdc0 100644 ---- a/policy.c -+++ b/policy.c -@@ -759,7 +759,6 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol, - * 1: has domains, all match - */ - int found_any = -1; -- int has_one_domain = 1; - struct dev_policy *p; - - pol = pol_find(pol, pol_domain); -@@ -769,9 +768,6 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol, - dom = dom->next; - if (!dom || strcmp(dom->dom, p->value) != 0) - return 0; -- if (has_one_domain && metadata && strcmp(metadata, "imsm") == 0) -- found_any = -1; -- has_one_domain = 0; - } - return found_any; - } --- -2.40.1 - diff --git a/0033-This-is-a-test-for-CI-do-not-merge.patch b/0033-This-is-a-test-for-CI-do-not-merge.patch new file mode 100644 index 0000000..d6a10ce --- /dev/null +++ b/0033-This-is-a-test-for-CI-do-not-merge.patch @@ -0,0 +1,22 @@ +From 97ee409451a7191d3d2861b6718f79116f80b4ec Mon Sep 17 00:00:00 2001 +From: Paul E Luse +Date: Thu, 24 Apr 2025 18:22:54 +0200 +Subject: [PATCH 33/37] This is a test for CI, do not merge + +Signed-off-by: Paul E Luse +--- + README.md | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/README.md b/README.md +index 029e0ee2..426e3512 100644 +--- a/README.md ++++ b/README.md +@@ -1,3 +1,4 @@ ++test + **mdadm** is a utility used to create and manage **software RAID** devices implemented through + **Multiple devices driver (MD)** in kernel. It supports following RAID metadata formats: + +-- +2.41.0 + diff --git a/0034-Update-README.md.patch b/0034-Update-README.md.patch new file mode 100644 index 0000000..36b8d8f --- /dev/null +++ b/0034-Update-README.md.patch @@ -0,0 +1,24 @@ +From f5ff81d14fdd34f770120a057804d6067fd5035b Mon Sep 17 00:00:00 2001 +From: Paul Luse +Date: Thu, 24 Apr 2025 09:48:56 -0700 +Subject: [PATCH 34/37] Update README.md + +Needed to remove the word "test" as part of testing updated CI workflow. + +Signed-off-by: Paul Luse +--- + README.md | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/README.md b/README.md +index 426e3512..029e0ee2 100644 +--- a/README.md ++++ b/README.md +@@ -1,4 +1,3 @@ +-test + **mdadm** is a utility used to create and manage **software RAID** devices implemented through + **Multiple devices driver (MD)** in kernel. It supports following RAID metadata formats: + +-- +2.41.0 + diff --git a/0034-mdadm-remove-inventory-file.patch b/0034-mdadm-remove-inventory-file.patch deleted file mode 100644 index ee9bb97..0000000 --- a/0034-mdadm-remove-inventory-file.patch +++ /dev/null @@ -1,307 +0,0 @@ -From 9c63130e8974033969569fb9d0b373d1d1478cf7 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 6 Mar 2024 13:45:53 +0100 -Subject: [PATCH 34/41] mdadm: remove inventory file - -It is a file with repo content list. It is outdated already. -Remove it. - -Signed-off-by: Mariusz Tkaczyk ---- - inventory | 284 ------------------------------------------------------ - 1 file changed, 284 deletions(-) - delete mode 100755 inventory - -diff --git a/inventory b/inventory -deleted file mode 100755 -index c4801b49..00000000 ---- a/inventory -+++ /dev/null -@@ -1,284 +0,0 @@ -- --.gitignore --ANNOUNCE-3.0 --ANNOUNCE-3.0.1 --ANNOUNCE-3.0.2 --ANNOUNCE-3.0.3 --ANNOUNCE-3.1 --ANNOUNCE-3.1.1 --ANNOUNCE-3.1.2 --ANNOUNCE-3.1.3 --ANNOUNCE-3.1.4 --ANNOUNCE-3.1.5 --ANNOUNCE-3.2 --ANNOUNCE-3.2.1 --ANNOUNCE-3.2.2 --ANNOUNCE-3.2.3 --ANNOUNCE-3.2.4 --ANNOUNCE-3.2.5 --ANNOUNCE-3.2.6 --ANNOUNCE-3.3 --ANNOUNCE-3.3.1 --ANNOUNCE-3.3.2 --ANNOUNCE-3.3.3 --ANNOUNCE-3.3.4 --ANNOUNCE-3.4 --ANNOUNCE-4.0 --ANNOUNCE-4.1 --ANNOUNCE-4.2 --Assemble.c --Build.c --COPYING --ChangeLog --Create.c --Detail.c --Dump.c --Examine.c --Grow.c --INSTALL --Incremental.c --Kill.c --Makefile --Manage.c --Monitor.c --Query.c --README.initramfs --ReadMe.c --TODO --bitmap.c --bitmap.h --clustermd_tests/ --clustermd_tests/00r10_Create --clustermd_tests/00r1_Create --clustermd_tests/01r10_Grow_bitmap-switch --clustermd_tests/01r10_Grow_resize --clustermd_tests/01r1_Grow_add --clustermd_tests/01r1_Grow_bitmap-switch --clustermd_tests/01r1_Grow_resize --clustermd_tests/02r10_Manage_add --clustermd_tests/02r10_Manage_add-spare --clustermd_tests/02r10_Manage_re-add --clustermd_tests/02r1_Manage_add --clustermd_tests/02r1_Manage_add-spare --clustermd_tests/02r1_Manage_re-add --clustermd_tests/03r10_switch-recovery --clustermd_tests/03r10_switch-resync --clustermd_tests/03r1_switch-recovery --clustermd_tests/03r1_switch-resync --clustermd_tests/cluster_conf --clustermd_tests/func.sh --config.c --coverity-gcc-hack.h --crc32.c --crc32.h --crc32c.c --dlink.c --dlink.h --external-reshape-design.txt --inventory --lib.c --makedist --managemon.c --mapfile.c --maps.c --md.4 --md5.h --md_p.h --md_u.h --mdadm.8.in --mdadm.c --mdadm.conf-example --mdadm.conf.5 --mdadm.h --mdadm.spec --mdmon-design.txt --mdmon.8 --mdmon.c --mdmon.h --mdopen.c --mdstat.c --misc/ --misc/mdcheck --misc/syslog-events --mkinitramfs --monitor.c --msg.c --msg.h --part.h --platform-intel.c --platform-intel.h --policy.c --probe_roms.c --probe_roms.h --pwgr.c --raid5extend.c --raid6check.8 --raid6check.c --restripe.c --sg_io.c --sha1.c --sha1.h --super-ddf.c --super-gpt.c --super-intel.c --super-mbr.c --super0.c --super1.c --swap_super.c --sysfs.c --systemd/ --systemd/SUSE-mdadm_env.sh --systemd/mdadm-grow-continue@.service --systemd/mdadm-last-resort@.service --systemd/mdadm-last-resort@.timer --systemd/mdadm.shutdown --systemd/mdcheck_continue.service --systemd/mdcheck_continue.timer --systemd/mdcheck_start.service --systemd/mdcheck_start.timer --systemd/mdmon@.service --systemd/mdmonitor-oneshot.service --systemd/mdmonitor-oneshot.timer --systemd/mdmonitor.service --test --tests/ --tests/00linear --tests/00multipath --tests/00names --tests/00raid0 --tests/00raid1 --tests/00raid10 --tests/00raid4 --tests/00raid5 --tests/00raid6 --tests/00readonly --tests/01r1fail --tests/01r5fail --tests/01r5integ --tests/01raid6integ --tests/01replace --tests/02lineargrow --tests/02r1add --tests/02r1grow --tests/02r5grow --tests/02r6grow --tests/03assem-incr --tests/03r0assem --tests/03r5assem --tests/03r5assem-failed --tests/03r5assemV1 --tests/04r0update --tests/04r1update --tests/04r5swap --tests/04update-metadata --tests/04update-uuid --tests/05r1-add-internalbitmap --tests/05r1-add-internalbitmap-v1a --tests/05r1-add-internalbitmap-v1b --tests/05r1-add-internalbitmap-v1c --tests/05r1-bitmapfile --tests/05r1-failfast --tests/05r1-grow-external --tests/05r1-grow-internal --tests/05r1-grow-internal-1 --tests/05r1-internalbitmap --tests/05r1-internalbitmap-v1a --tests/05r1-internalbitmap-v1b --tests/05r1-internalbitmap-v1c --tests/05r1-n3-bitmapfile --tests/05r1-re-add --tests/05r1-re-add-nosuper --tests/05r1-remove-internalbitmap --tests/05r1-remove-internalbitmap-v1a --tests/05r1-remove-internalbitmap-v1b --tests/05r1-remove-internalbitmap-v1c --tests/05r5-bitmapfile --tests/05r5-internalbitmap --tests/05r6-bitmapfile --tests/05r6tor0 --tests/06name --tests/06sysfs --tests/06wrmostly --tests/07autoassemble --tests/07autodetect --tests/07changelevelintr --tests/07changelevels --tests/07layouts --tests/07reshape5intr --tests/07revert-grow --tests/07revert-inplace --tests/07revert-shrink --tests/07testreshape5 --tests/09imsm-assemble --tests/09imsm-create-fail-rebuild --tests/09imsm-overlap --tests/10ddf-assemble-missing --tests/10ddf-create --tests/10ddf-create-fail-rebuild --tests/10ddf-fail-create-race --tests/10ddf-fail-readd --tests/10ddf-fail-readd-readonly --tests/10ddf-fail-spare --tests/10ddf-fail-stop-readd --tests/10ddf-fail-twice --tests/10ddf-fail-two-spares --tests/10ddf-geometry --tests/10ddf-incremental-wrong-order --tests/10ddf-sudden-degraded --tests/11spare-migration --tests/12imsm-r0_2d-grow-r0_3d --tests/12imsm-r0_2d-grow-r0_4d --tests/12imsm-r0_2d-grow-r0_5d --tests/12imsm-r0_3d-grow-r0_4d --tests/12imsm-r5_3d-grow-r5_4d --tests/12imsm-r5_3d-grow-r5_5d --tests/13imsm-r0_r0_2d-grow-r0_r0_4d --tests/13imsm-r0_r0_2d-grow-r0_r0_5d --tests/13imsm-r0_r0_3d-grow-r0_r0_4d --tests/13imsm-r0_r5_3d-grow-r0_r5_4d --tests/13imsm-r0_r5_3d-grow-r0_r5_5d --tests/13imsm-r5_r0_3d-grow-r5_r0_4d --tests/13imsm-r5_r0_3d-grow-r5_r0_5d --tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d --tests/14imsm-r0_3d_no_spares-migrate-r5_3d --tests/14imsm-r0_r0_2d-takeover-r10_4d --tests/14imsm-r10_4d-grow-r10_5d --tests/14imsm-r10_r5_4d-takeover-r0_2d --tests/14imsm-r1_2d-grow-r1_3d --tests/14imsm-r1_2d-takeover-r0_2d --tests/14imsm-r5_3d-grow-r5_5d-no-spares --tests/14imsm-r5_3d-migrate-r4_3d --tests/15imsm-r0_3d_64k-migrate-r0_3d_256k --tests/15imsm-r5_3d_4k-migrate-r5_3d_256k --tests/15imsm-r5_3d_64k-migrate-r5_3d_256k --tests/15imsm-r5_6d_4k-migrate-r5_6d_256k --tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k --tests/16imsm-r0_3d-migrate-r5_4d --tests/16imsm-r0_5d-migrate-r5_6d --tests/16imsm-r5_3d-migrate-r0_3d --tests/16imsm-r5_5d-migrate-r0_5d --tests/18imsm-1d-takeover-r0_1d --tests/18imsm-1d-takeover-r1_2d --tests/18imsm-r0_2d-takeover-r10_4d --tests/18imsm-r10_4d-takeover-r0_2d --tests/18imsm-r1_2d-takeover-r0_1d --tests/19raid6auto-repair --tests/19raid6check --tests/19raid6repair --tests/19repair-does-not-destroy --tests/20raid5journal --tests/21raid5cache --tests/ToTest --tests/env-ddf-template --tests/env-imsm-template --tests/func.sh --tests/imsm-grow-template --tests/utils --udev-md-clustered-confirm-device.rules --udev-md-raid-arrays.rules --udev-md-raid-assembly.rules --udev-md-raid-creating.rules --udev-md-raid-safe-timeouts.rules --util.c --uuid.c --xmalloc.c --- -2.40.1 - diff --git a/0035-mdadm-Remove-klibc-and-uclibc-support.patch b/0035-mdadm-Remove-klibc-and-uclibc-support.patch new file mode 100644 index 0000000..7ebd8da --- /dev/null +++ b/0035-mdadm-Remove-klibc-and-uclibc-support.patch @@ -0,0 +1,183 @@ +From bd648e3bec3d883d2f4addea84ac1ac8790c75e9 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Fri, 7 Mar 2025 11:38:48 +0100 +Subject: [PATCH 35/37] mdadm: Remove klibc and uclibc support + +Klibc compilation is not working for at least 3 years because of +following error: +mdadm.h:1912:15: error: unknown type name 'sighandler_t' + +It will have a conflict with le/be_to_cpu() functions family provided by +asm/byteorder.h which will be included with raid/md_p.h. Therefore we +need to remove support for it. Also, remove uclibc because it is not actively +maintained. + +Remove klibc and uclibc targets from Makefile and special klibc code. +Targets can be removed safely because using CC is recommended. + +Signed-off-by: Mariusz Tkaczyk +--- + Makefile | 34 +++------------------------------- + README.md | 3 --- + mdadm.h | 37 +------------------------------------ + 3 files changed, 4 insertions(+), 70 deletions(-) + +diff --git a/Makefile b/Makefile +index bcd092de..387e4a56 100644 +--- a/Makefile ++++ b/Makefile +@@ -31,16 +31,6 @@ + # define "CXFLAGS" to give extra flags to CC. + # e.g. make CXFLAGS=-O to optimise + CXFLAGS ?=-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE +-TCC = tcc +-UCLIBC_GCC = $(shell for nm in i386-uclibc-linux-gcc i386-uclibc-gcc; do which $$nm > /dev/null && { echo $$nm ; exit; } ; done; echo false No uclibc found ) +-#DIET_GCC = diet gcc +-# sorry, but diet-libc doesn't know about posix_memalign, +-# so we cannot use it any more. +-DIET_GCC = gcc -DHAVE_STDINT_H +- +-KLIBC=/home/src/klibc/klibc-0.77 +- +-KLIBC_GCC = gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 + + ifdef COVERITY + COVERITY_FLAGS=-include coverity-gcc-hack.h +@@ -225,8 +215,6 @@ everything: all swap_super test_stripe raid6check \ + mdadm.Os mdadm.O2 man + everything-test: all swap_super test_stripe \ + mdadm.Os mdadm.O2 man +-# mdadm.uclibc doesn't work on x86-64 +-# mdadm.tcc doesn't work.. + + %.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(COVERITY_FLAGS) -o $@ -c $< +@@ -237,13 +225,6 @@ mdadm : $(OBJS) | check_rundir + mdadm.static : $(OBJS) $(STATICOBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS) $(LDLIBS) + +-mdadm.tcc : $(SRCS) $(INCL) +- $(TCC) -o mdadm.tcc $(SRCS) +- +-mdadm.klibc : $(SRCS) $(INCL) +- rm -f $(OBJS) +- $(CC) -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS) +- + mdadm.Os : $(SRCS) $(INCL) + $(CC) -o mdadm.Os $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -Os $(SRCS) $(LDLIBS) + +@@ -298,15 +279,6 @@ install : install-bin install-man install-udev + install-static : mdadm.static install-man + $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm + +-install-tcc : mdadm.tcc install-man +- $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm +- +-install-uclibc : mdadm.uclibc install-man +- $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm +- +-install-klibc : mdadm.klibc install-man +- $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm +- + install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8 + $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8 + $(INSTALL) -D -m 644 mdmon.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 +@@ -354,9 +326,9 @@ test: mdadm mdmon test_stripe swap_super raid6check + + clean : + rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \ +- mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \ +- .merge_file_* mdadm.Os mdadm.O2 mdmon.O2 swap_super init.cpio.gz \ +- mdadm.uclibc.static test_stripe raid6check raid6check.o mdmon mdadm.8 ++ mdadm.static *.orig *.porig *.rej *.alt merge_file_* \ ++ mdadm.Os mdadm.O2 mdmon.O2 swap_super init.cpio.gz \ ++ test_stripe raid6check raid6check.o mdmon mdadm.8 + rm -rf cov-int + + dist : clean +diff --git a/README.md b/README.md +index 029e0ee2..ba611ec5 100644 +--- a/README.md ++++ b/README.md +@@ -135,9 +135,6 @@ List of installation targets: + + The following targets are deprecated and should not be used: + - `install-static` +-- `install-tcc` +-- `install-uclibc` +-- `install-klibc` + + # License + +diff --git a/mdadm.h b/mdadm.h +index 0ea83ad3..592bd1ba 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -43,6 +43,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); + #include + #include + #include ++#include + #include + #include + #include +@@ -189,7 +190,6 @@ struct dlm_lksb { + ((x) & 0x00000000ff000000ULL) << 8 | \ + ((x) & 0x000000ff00000000ULL) >> 8) + +-#if !defined(__KLIBC__) + #if BYTE_ORDER == LITTLE_ENDIAN + #define __cpu_to_le16(_x) (unsigned int)(_x) + #define __cpu_to_le32(_x) (unsigned int)(_x) +@@ -221,7 +221,6 @@ struct dlm_lksb { + #else + # error "unknown endianness." + #endif +-#endif /* __KLIBC__ */ + + /* + * Partially stolen from include/linux/unaligned/packed_struct.h +@@ -1530,40 +1529,6 @@ extern void sysfsline(char *line); + struct stat64; + #endif + +-#define HAVE_NFTW we assume +-#define HAVE_FTW +- +-#ifdef __UCLIBC__ +-# include +-# ifndef __UCLIBC_HAS_LFS__ +-# define lseek64 lseek +-# endif +-# ifndef __UCLIBC_HAS_FTW__ +-# undef HAVE_FTW +-# undef HAVE_NFTW +-# endif +-#endif +- +-#ifdef __dietlibc__ +-# undef HAVE_NFTW +-#endif +- +-#if defined(__KLIBC__) +-# undef HAVE_NFTW +-# undef HAVE_FTW +-#endif +- +-#ifndef HAVE_NFTW +-# define FTW_PHYS 1 +-# ifndef HAVE_FTW +- struct FTW {}; +-# endif +-#endif +- +-#ifdef HAVE_FTW +-# include +-#endif +- + extern int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s); + + extern int Manage_ro(char *devname, int fd, int readonly); +-- +2.41.0 + diff --git a/0035-udev.c-Do-not-require-libudev.h-if-DNO_LIBUDEV.patch b/0035-udev.c-Do-not-require-libudev.h-if-DNO_LIBUDEV.patch deleted file mode 100644 index 084bbc4..0000000 --- a/0035-udev.c-Do-not-require-libudev.h-if-DNO_LIBUDEV.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 1750758c7ff526e3560433f6235e5cfa35cf646a Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 6 Mar 2024 15:50:55 +0100 -Subject: [PATCH 35/41] udev.c: Do not require libudev.h if DNO_LIBUDEV - -libudev may not be presented at all, do not require it. - -Reported-by: Boian Bonev -Signed-off-by: Mariusz Tkaczyk ---- - udev.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/udev.c b/udev.c -index bc4722b0..066e6ab1 100644 ---- a/udev.c -+++ b/udev.c -@@ -26,7 +26,10 @@ - #include - #include - #include -+ -+#ifndef NO_LIBUDEV - #include -+#endif - - static char *unblock_path; - --- -2.40.1 - diff --git a/0036-mdadm-include-asm-byteorder.h.patch b/0036-mdadm-include-asm-byteorder.h.patch new file mode 100644 index 0000000..9f9c3cd --- /dev/null +++ b/0036-mdadm-include-asm-byteorder.h.patch @@ -0,0 +1,96 @@ +From 696207860f408534651db89c5b40133f5903fa25 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Fri, 7 Mar 2025 12:10:58 +0100 +Subject: [PATCH 36/37] mdadm: include asm/byteorder.h + +It will be included by raid/md_p.h anyway. Include it directly and +remove custom functions. It is not a problem now. + +Signed-off-by: Mariusz Tkaczyk +--- + mdadm.h | 55 +------------------------------------------------------ + 1 file changed, 1 insertion(+), 54 deletions(-) + +diff --git a/mdadm.h b/mdadm.h +index 592bd1ba..7471cedc 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -34,6 +34,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); + #endif + + #include ++#include + #include + #include + #include +@@ -85,7 +86,6 @@ struct dlm_lksb { + #endif + + #include +-/*#include */ + #include + #include + #include +@@ -169,59 +169,6 @@ struct dlm_lksb { + #include "msg.h" + #include "mdadm_status.h" + +-#include +-/* Redhat don't like to #include , and +- * some time include isn't enough, +- * and there is no standard conversion function so... */ +-/* And dietlibc doesn't think byteswap is ok, so.. */ +-/* #include */ +-#define __mdadm_bswap_16(x) (((x) & 0x00ffU) << 8 | \ +- ((x) & 0xff00U) >> 8) +-#define __mdadm_bswap_32(x) (((x) & 0x000000ffU) << 24 | \ +- ((x) & 0xff000000U) >> 24 | \ +- ((x) & 0x0000ff00U) << 8 | \ +- ((x) & 0x00ff0000U) >> 8) +-#define __mdadm_bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \ +- ((x) & 0xff00000000000000ULL) >> 56 | \ +- ((x) & 0x000000000000ff00ULL) << 40 | \ +- ((x) & 0x00ff000000000000ULL) >> 40 | \ +- ((x) & 0x0000000000ff0000ULL) << 24 | \ +- ((x) & 0x0000ff0000000000ULL) >> 24 | \ +- ((x) & 0x00000000ff000000ULL) << 8 | \ +- ((x) & 0x000000ff00000000ULL) >> 8) +- +-#if BYTE_ORDER == LITTLE_ENDIAN +-#define __cpu_to_le16(_x) (unsigned int)(_x) +-#define __cpu_to_le32(_x) (unsigned int)(_x) +-#define __cpu_to_le64(_x) (unsigned long long)(_x) +-#define __le16_to_cpu(_x) (unsigned int)(_x) +-#define __le32_to_cpu(_x) (unsigned int)(_x) +-#define __le64_to_cpu(_x) (unsigned long long)(_x) +- +-#define __cpu_to_be16(_x) __mdadm_bswap_16(_x) +-#define __cpu_to_be32(_x) __mdadm_bswap_32(_x) +-#define __cpu_to_be64(_x) __mdadm_bswap_64(_x) +-#define __be16_to_cpu(_x) __mdadm_bswap_16(_x) +-#define __be32_to_cpu(_x) __mdadm_bswap_32(_x) +-#define __be64_to_cpu(_x) __mdadm_bswap_64(_x) +-#elif BYTE_ORDER == BIG_ENDIAN +-#define __cpu_to_le16(_x) __mdadm_bswap_16(_x) +-#define __cpu_to_le32(_x) __mdadm_bswap_32(_x) +-#define __cpu_to_le64(_x) __mdadm_bswap_64(_x) +-#define __le16_to_cpu(_x) __mdadm_bswap_16(_x) +-#define __le32_to_cpu(_x) __mdadm_bswap_32(_x) +-#define __le64_to_cpu(_x) __mdadm_bswap_64(_x) +- +-#define __cpu_to_be16(_x) (unsigned int)(_x) +-#define __cpu_to_be32(_x) (unsigned int)(_x) +-#define __cpu_to_be64(_x) (unsigned long long)(_x) +-#define __be16_to_cpu(_x) (unsigned int)(_x) +-#define __be32_to_cpu(_x) (unsigned int)(_x) +-#define __be64_to_cpu(_x) (unsigned long long)(_x) +-#else +-# error "unknown endianness." +-#endif +- + /* + * Partially stolen from include/linux/unaligned/packed_struct.h + */ +-- +2.41.0 + diff --git a/0036-util.c-add-limits.h-include-for-NAME_MAX-definition.patch b/0036-util.c-add-limits.h-include-for-NAME_MAX-definition.patch deleted file mode 100644 index c3c0ced..0000000 --- a/0036-util.c-add-limits.h-include-for-NAME_MAX-definition.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 8bda86099089b44129ef6206764f9de47a45f0db Mon Sep 17 00:00:00 2001 -From: Alexander Kanavin -Date: Tue, 12 Mar 2024 11:01:50 +0100 -Subject: [PATCH 36/41] util.c: add limits.h include for NAME_MAX definition - -Add limits.h include for NAME_MAX definition. - -Signed-off-by: Alexander Kanavin -Signed-off-by: Mariusz Tkaczyk ---- - util.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util.c b/util.c -index 05ad3343..49a9c6e2 100644 ---- a/util.c -+++ b/util.c -@@ -36,7 +36,7 @@ - #include - #include - #include -- -+#include - - /* - * following taken from linux/blkpg.h because they aren't --- -2.40.1 - diff --git a/0037-mdadm-set-swapuuid-in-all-handlers.patch b/0037-mdadm-set-swapuuid-in-all-handlers.patch deleted file mode 100644 index b8c77e8..0000000 --- a/0037-mdadm-set-swapuuid-in-all-handlers.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 1c8327950566449e206e613c11c8232032f26787 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 18 Mar 2024 16:19:29 +0100 -Subject: [PATCH 37/41] mdadm: set swapuuid in all handlers - -It is not set, so it should be 0 but it may vary on compilation -settings. Set it always to 0. - -metadata should care to set UUID and read in proper endianness so it -doesn't follow super1 concept of swapuuid to depend on endianness. - -It is not an attempt to fix endianness issues. - -Signed-off-by: Mariusz Tkaczyk ---- - super-ddf.c | 1 + - super-intel.c | 1 + - super0.c | 2 ++ - 3 files changed, 4 insertions(+) - -diff --git a/super-ddf.c b/super-ddf.c -index 7571e3b7..94ac5ff3 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -5162,6 +5162,7 @@ struct superswitch super_ddf = { - .default_geometry = default_geometry_ddf, - - .external = 1, -+ .swapuuid = 0, - - /* for mdmon */ - .open_new = ddf_open_new, -diff --git a/super-intel.c b/super-intel.c -index 77140455..e1754f29 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -13116,6 +13116,7 @@ struct superswitch super_imsm = { - .validate_ppl = validate_ppl_imsm, - - .external = 1, -+ .swapuuid = 0, - .name = "imsm", - - /* for mdmon */ -diff --git a/super0.c b/super0.c -index a7c5f813..9b8a1bd6 100644 ---- a/super0.c -+++ b/super0.c -@@ -1369,5 +1369,7 @@ struct superswitch super0 = { - .locate_bitmap = locate_bitmap0, - .write_bitmap = write_bitmap0, - .free_super = free_super0, -+ -+ .swapuuid = 0, - .name = "0.90", - }; --- -2.40.1 - diff --git a/0037-mdadm-use-kernel-raid-headers.patch b/0037-mdadm-use-kernel-raid-headers.patch new file mode 100644 index 0000000..82dd150 --- /dev/null +++ b/0037-mdadm-use-kernel-raid-headers.patch @@ -0,0 +1,346 @@ +From f5889f9a1b8753a1472dfef9d025da2bae395239 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Mon, 10 Mar 2025 11:16:28 +0100 +Subject: [PATCH 37/37] mdadm: use kernel raid headers + +For a years we redefined these headers in mdadm. We should reuse headers +exported by kernel to integrate driver and mdadm better. +Include them and remove mdadm owned headers. + +There are 3 defines not available in kernel headers, so define them +directly but put them in ifndef guard to make them transparent later. + +Use MD_FEATURE_CLUSTERED instead of MD_FEATURE_BITMAP_VERSIONED. The +value is same, kernel define has different name. + +Signed-off-by: Mariusz Tkaczyk +--- + Create.c | 2 - + Detail.c | 2 - + Examine.c | 2 - + Grow.c | 6 --- + Kill.c | 2 - + Manage.c | 2 - + Query.c | 2 - + mdadm.h | 16 ++++++- + mdmonitor.c | 2 - + super1.c | 126 ++-------------------------------------------------- + udev.c | 2 - + 11 files changed, 17 insertions(+), 147 deletions(-) + +diff --git a/Create.c b/Create.c +index 2b181dbf..de90b0b8 100644 +--- a/Create.c ++++ b/Create.c +@@ -23,8 +23,6 @@ + */ + + #include "mdadm.h" +-#include "md_u.h" +-#include "md_p.h" + #include "udev.h" + #include "xmalloc.h" + +diff --git a/Detail.c b/Detail.c +index b804a624..3802ef8f 100644 +--- a/Detail.c ++++ b/Detail.c +@@ -23,8 +23,6 @@ + */ + + #include "mdadm.h" +-#include "md_p.h" +-#include "md_u.h" + #include "xmalloc.h" + + #include +diff --git a/Examine.c b/Examine.c +index 036b7a56..9c8564be 100644 +--- a/Examine.c ++++ b/Examine.c +@@ -24,8 +24,6 @@ + + #include "dlink.h" + #include "mdadm.h" +-#include "md_u.h" +-#include "md_p.h" + #include "xmalloc.h" + + #if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN) +diff --git a/Grow.c b/Grow.c +index 53b0b387..30eaa3c6 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -30,12 +30,6 @@ + #include + #include + +-#if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN) +-#error no endian defined +-#endif +-#include "md_u.h" +-#include "md_p.h" +- + int restore_backup(struct supertype *st, + struct mdinfo *content, + int working_disks, +diff --git a/Kill.c b/Kill.c +index 43c9abed..9f05a1ac 100644 +--- a/Kill.c ++++ b/Kill.c +@@ -26,8 +26,6 @@ + */ + + #include "mdadm.h" +-#include "md_u.h" +-#include "md_p.h" + + int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl) + { +diff --git a/Manage.c b/Manage.c +index 034eb00c..22b1f52b 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -23,8 +23,6 @@ + */ + + #include "mdadm.h" +-#include "md_u.h" +-#include "md_p.h" + #include "udev.h" + #include "xmalloc.h" + +diff --git a/Query.c b/Query.c +index aedb4ce7..72f49a4e 100644 +--- a/Query.c ++++ b/Query.c +@@ -23,8 +23,6 @@ + */ + + #include "mdadm.h" +-#include "md_p.h" +-#include "md_u.h" + + int Query(char *dev) + { +diff --git a/mdadm.h b/mdadm.h +index 7471cedc..ce9c216b 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -163,8 +163,20 @@ struct dlm_lksb { + #define GROW_SERVICE "mdadm-grow-continue" + #endif /* GROW_SERVICE */ + +-#include "md_u.h" +-#include "md_p.h" ++#include ++#include ++ ++/* These defines might be missing in raid headers*/ ++#ifndef MD_SB_BLOCK_CONTAINER_RESHAPE ++#define MD_SB_BLOCK_CONTAINER_RESHAPE 3 ++#endif ++#ifndef MD_SB_BLOCK_VOLUME ++#define MD_SB_BLOCK_VOLUME 4 ++#endif ++#ifndef MD_DISK_REPLACEMENT ++#define MD_DISK_REPLACEMENT 17 ++#endif ++ + #include "bitmap.h" + #include "msg.h" + #include "mdadm_status.h" +diff --git a/mdmonitor.c b/mdmonitor.c +index d1cfbf94..d51617cd 100644 +--- a/mdmonitor.c ++++ b/mdmonitor.c +@@ -23,8 +23,6 @@ + */ + + #include "mdadm.h" +-#include "md_p.h" +-#include "md_u.h" + #include "udev.h" + #include "xmalloc.h" + +diff --git a/super1.c b/super1.c +index fb93f462..84d73573 100644 +--- a/super1.c ++++ b/super1.c +@@ -26,92 +26,6 @@ + #include "mdadm.h" + #include "xmalloc.h" + +-/* +- * The version-1 superblock : +- * All numeric fields are little-endian. +- * +- * total size: 256 bytes plus 2 per device. +- * 1K allows 384 devices. +- */ +-struct mdp_superblock_1 { +- /* constant array information - 128 bytes */ +- __u32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */ +- __u32 major_version; /* 1 */ +- __u32 feature_map; /* 0 for now */ +- __u32 pad0; /* always set to 0 when writing */ +- +- __u8 set_uuid[16]; /* user-space generated. */ +- char set_name[32]; /* set and interpreted by user-space */ +- +- __u64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ +- __u32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ +- __u32 layout; /* used for raid5, raid6, raid10, and raid0 */ +- __u64 size; /* used size of component devices, in 512byte sectors */ +- +- __u32 chunksize; /* in 512byte sectors */ +- __u32 raid_disks; +- union { +- __u32 bitmap_offset; /* sectors after start of superblock that bitmap starts +- * NOTE: signed, so bitmap can be before superblock +- * only meaningful of feature_map[0] is set. +- */ +- +- /* only meaningful when feature_map[MD_FEATURE_PPL] is set */ +- struct { +- __s16 offset; /* sectors from start of superblock that ppl starts */ +- __u16 size; /* ppl size in sectors */ +- } ppl; +- }; +- +- /* These are only valid with feature bit '4' */ +- __u32 new_level; /* new level we are reshaping to */ +- __u64 reshape_position; /* next address in array-space for reshape */ +- __u32 delta_disks; /* change in number of raid_disks */ +- __u32 new_layout; /* new layout */ +- __u32 new_chunk; /* new chunk size (sectors) */ +- __u32 new_offset; /* signed number to add to data_offset in new +- * layout. 0 == no-change. This can be +- * different on each device in the array. +- */ +- +- /* constant this-device information - 64 bytes */ +- __u64 data_offset; /* sector start of data, often 0 */ +- __u64 data_size; /* sectors in this device that can be used for data */ +- __u64 super_offset; /* sector start of this superblock */ +- union { +- __u64 recovery_offset;/* sectors before this offset (from data_offset) have been recovered */ +- __u64 journal_tail;/* journal tail of journal device (from data_offset) */ +- }; +- __u32 dev_number; /* permanent identifier of this device - not role in raid */ +- __u32 cnt_corrected_read; /* number of read errors that were corrected by re-writing */ +- __u8 device_uuid[16]; /* user-space setable, ignored by kernel */ +- __u8 devflags; /* per-device flags. Only one defined...*/ +-#define WriteMostly1 1 /* mask for writemostly flag in above */ +-#define FailFast1 2 /* Device should get FailFast requests */ +- /* bad block log. If there are any bad blocks the feature flag is set. +- * if offset and size are non-zero, that space is reserved and available. +- */ +- __u8 bblog_shift; /* shift from sectors to block size for badblock list */ +- __u16 bblog_size; /* number of sectors reserved for badblock list */ +- __u32 bblog_offset; /* sector offset from superblock to bblog, signed */ +- +- /* array state information - 64 bytes */ +- __u64 utime; /* 40 bits second, 24 bits microseconds */ +- __u64 events; /* incremented when superblock updated */ +- __u64 resync_offset; /* data before this offset (from data_offset) known to be in sync */ +- __u32 sb_csum; /* checksum upto dev_roles[max_dev] */ +- __u32 max_dev; /* size of dev_roles[] array to consider */ +- __u8 pad3[64-32]; /* set to 0 when writing */ +- +- /* device state information. Indexed by dev_number. +- * 2 bytes per device +- * Note there are no per-device state flags. State information is rolled +- * into the 'roles' value. If a device is spare or faulty, then it doesn't +- * have a meaningful role. +- */ +- __u16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */ +-}; +- + #define MAX_SB_SIZE 4096 + /* bitmap super size is 256, but we round up to a sector for alignment */ + #define BM_SUPER_SIZE 512 +@@ -126,40 +40,6 @@ struct misc_dev_info { + #define MULTIPLE_PPL_AREA_SIZE_SUPER1 (1024 * 1024) /* Size of the whole + * mutliple PPL area + */ +-/* feature_map bits */ +-#define MD_FEATURE_BITMAP_OFFSET 1 +-#define MD_FEATURE_RECOVERY_OFFSET 2 /* recovery_offset is present and +- * must be honoured +- */ +-#define MD_FEATURE_RESHAPE_ACTIVE 4 +-#define MD_FEATURE_BAD_BLOCKS 8 /* badblock list is not empty */ +-#define MD_FEATURE_REPLACEMENT 16 /* This device is replacing an +- * active device with same 'role'. +- * 'recovery_offset' is also set. +- */ +-#define MD_FEATURE_RESHAPE_BACKWARDS 32 /* Reshape doesn't change number +- * of devices, but is going +- * backwards anyway. +- */ +-#define MD_FEATURE_NEW_OFFSET 64 /* new_offset must be honoured */ +-#define MD_FEATURE_BITMAP_VERSIONED 256 /* bitmap version number checked properly */ +-#define MD_FEATURE_JOURNAL 512 /* support write journal */ +-#define MD_FEATURE_PPL 1024 /* support PPL */ +-#define MD_FEATURE_MUTLIPLE_PPLS 2048 /* support for multiple PPLs */ +-#define MD_FEATURE_RAID0_LAYOUT 4096 /* layout is meaningful in RAID0 */ +-#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \ +- |MD_FEATURE_RECOVERY_OFFSET \ +- |MD_FEATURE_RESHAPE_ACTIVE \ +- |MD_FEATURE_BAD_BLOCKS \ +- |MD_FEATURE_REPLACEMENT \ +- |MD_FEATURE_RESHAPE_BACKWARDS \ +- |MD_FEATURE_NEW_OFFSET \ +- |MD_FEATURE_BITMAP_VERSIONED \ +- |MD_FEATURE_JOURNAL \ +- |MD_FEATURE_PPL \ +- |MD_FEATURE_MULTIPLE_PPLS \ +- |MD_FEATURE_RAID0_LAYOUT \ +- ) + + static int role_from_sb(struct mdp_superblock_1 *sb) + { +@@ -319,7 +199,7 @@ static int awrite(struct align_fd *afd, void *buf, int len) + static inline unsigned int md_feature_any_ppl_on(__u32 feature_map) + { + return ((__cpu_to_le32(feature_map) & +- (MD_FEATURE_PPL | MD_FEATURE_MUTLIPLE_PPLS))); ++ (MD_FEATURE_PPL | MD_FEATURE_MULTIPLE_PPLS))); + } + + static inline unsigned int choose_ppl_space(int chunk) +@@ -1483,7 +1363,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info, + } + case UOPT_NO_PPL: + sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_PPL | +- MD_FEATURE_MUTLIPLE_PPLS); ++ MD_FEATURE_MULTIPLE_PPLS); + break; + case UOPT_DEVICESIZE: + if (__le64_to_cpu(sb->super_offset) >= +@@ -2650,7 +2530,7 @@ add_internal_bitmap1(struct supertype *st, + bms->nodes = __cpu_to_le32(st->nodes); + if (st->nodes) + sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map) | +- MD_FEATURE_BITMAP_VERSIONED); ++ MD_FEATURE_CLUSTERED); + if (st->cluster_name) { + len = sizeof(bms->cluster_name); + strncpy((char *)bms->cluster_name, st->cluster_name, len); +diff --git a/udev.c b/udev.c +index 88a99781..961ca970 100644 +--- a/udev.c ++++ b/udev.c +@@ -20,8 +20,6 @@ + + #include "mdadm.h" + #include "udev.h" +-#include "md_p.h" +-#include "md_u.h" + #include "xmalloc.h" + + #include +-- +2.41.0 + diff --git a/0038-mdadm-Fix-native-detail-export.patch b/0038-mdadm-Fix-native-detail-export.patch deleted file mode 100644 index 74d7084..0000000 --- a/0038-mdadm-Fix-native-detail-export.patch +++ /dev/null @@ -1,247 +0,0 @@ -From ba65d917d121dfb9876053e6f62dbd4ebf2e028c Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 18 Mar 2024 16:19:30 +0100 -Subject: [PATCH 38/41] mdadm: Fix native --detail --export - -Mentioned commit (see Fixes) causes that UUID is not swapped as expected -for native superblock. Fix this problem. - -For detail, we should avoid superblock calls, we can have information -about supertype from map, use that. - -Simplify fname_from_uuid() by removing dependencies to metadata -handler, it is not needed. Decision is taken at compile time, expect -super1 but this function is not used by super1. Add warning about that. -Remove separator, it is always ':'. - -Fixes: 60c19530dd7c ("Detail: remove duplicated code") -Signed-off-by: Mariusz Tkaczyk ---- - Detail.c | 26 +++++++++++++++++++++++++- - mdadm.h | 3 +-- - super-ddf.c | 10 +++++----- - super-intel.c | 16 ++++++++-------- - util.c | 24 +++++++++++++----------- - 5 files changed, 52 insertions(+), 27 deletions(-) - -diff --git a/Detail.c b/Detail.c -index f23ec16f..55a086d3 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -49,6 +49,30 @@ static int add_device(const char *dev, char ***p_devices, - return n_devices + 1; - } - -+/** -+ * detail_fname_from_uuid() - generate uuid string with special super1 handling. -+ * @mp: map entry to parse. -+ * @buf: buf to write. -+ * -+ * Hack to workaround an issue with super1 superblocks. It swapuuid set in order for assembly -+ * to work, but can't have it set if we want this printout to match all the other uuid printouts -+ * in super1.c, so we force swapuuid to 1 to make our printout match the rest of super1. -+ * -+ * Always convert uuid if host is big endian. -+ */ -+char *detail_fname_from_uuid(struct map_ent *mp, char *buf) -+{ -+#if __BYTE_ORDER == BIG_ENDIAN -+ bool swap = true; -+#else -+ bool swap = false; -+#endif -+ if (strncmp(mp->metadata, "1.", 2) == 0) -+ swap = true; -+ -+ return __fname_from_uuid(mp->uuid, swap, buf, ':'); -+} -+ - int Detail(char *dev, struct context *c) - { - /* -@@ -256,7 +280,7 @@ int Detail(char *dev, struct context *c) - mp = map_by_devnm(&map, fd2devnm(fd)); - - if (mp) { -- __fname_from_uuid(mp->uuid, 0, nbuf, ':'); -+ detail_fname_from_uuid(mp, nbuf); - printf("MD_UUID=%s\n", nbuf + 5); - if (mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) - printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN); -diff --git a/mdadm.h b/mdadm.h -index 3fedca48..a363708a 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1696,8 +1696,7 @@ extern const int uuid_zero[4]; - extern int same_uuid(int a[4], int b[4], int swapuuid); - extern void copy_uuid(void *a, int b[4], int swapuuid); - extern char *__fname_from_uuid(int id[4], int swap, char *buf, char sep); --extern char *fname_from_uuid(struct supertype *st, -- struct mdinfo *info, char *buf, char sep); -+extern char *fname_from_uuid(struct mdinfo *info, char *buf); - extern unsigned long calc_csum(void *super, int bytes); - extern int enough(int level, int raid_disks, int layout, int clean, - char *avail); -diff --git a/super-ddf.c b/super-ddf.c -index 94ac5ff3..21426c75 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -1617,7 +1617,7 @@ static void brief_examine_super_ddf(struct supertype *st, int verbose) - struct mdinfo info; - char nbuf[64]; - getinfo_super_ddf(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - - printf("ARRAY metadata=ddf UUID=%s\n", nbuf + 5); - } -@@ -1632,7 +1632,7 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose) - unsigned int i; - char nbuf[64]; - getinfo_super_ddf(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - - for (i = 0; i < be16_to_cpu(ddf->virt->max_vdes); i++) { - struct virtual_entry *ve = &ddf->virt->entries[i]; -@@ -1645,7 +1645,7 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose) - ddf->currentconf =&vcl; - vcl.vcnum = i; - uuid_from_super_ddf(st, info.uuid); -- fname_from_uuid(st, &info, nbuf1, ':'); -+ fname_from_uuid(&info, nbuf1); - _ddf_array_name(namebuf, ddf, i); - printf("ARRAY%s%s container=%s member=%d UUID=%s\n", - namebuf[0] == '\0' ? "" : " " DEV_MD_DIR, namebuf, -@@ -1658,7 +1658,7 @@ static void export_examine_super_ddf(struct supertype *st) - struct mdinfo info; - char nbuf[64]; - getinfo_super_ddf(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - printf("MD_METADATA=ddf\n"); - printf("MD_LEVEL=container\n"); - printf("MD_UUID=%s\n", nbuf+5); -@@ -1798,7 +1798,7 @@ static void brief_detail_super_ddf(struct supertype *st, char *subarray) - return; - else - uuid_of_ddf_subarray(ddf, vcnum, info.uuid); -- fname_from_uuid(st, &info, nbuf,':'); -+ fname_from_uuid(&info, nbuf); - printf(" UUID=%s", nbuf + 5); - } - -diff --git a/super-intel.c b/super-intel.c -index e1754f29..ff2590fe 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2217,7 +2217,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost) - else - printf("not supported\n"); - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - printf(" UUID : %s\n", nbuf + 5); - sum = __le32_to_cpu(mpb->check_sum); - printf(" Checksum : %08x %s\n", sum, -@@ -2242,7 +2242,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost) - - super->current_vol = i; - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - print_imsm_dev(super, dev, nbuf + 5, super->disks->index); - } - for (i = 0; i < mpb->num_disks; i++) { -@@ -2267,7 +2267,7 @@ static void brief_examine_super_imsm(struct supertype *st, int verbose) - char nbuf[64]; - - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - printf("ARRAY metadata=imsm UUID=%s\n", nbuf + 5); - } - -@@ -2284,13 +2284,13 @@ static void brief_examine_subarrays_imsm(struct supertype *st, int verbose) - return; - - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - for (i = 0; i < super->anchor->num_raid_devs; i++) { - struct imsm_dev *dev = get_imsm_dev(super, i); - - super->current_vol = i; - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf1, ':'); -+ fname_from_uuid(&info, nbuf1); - printf("ARRAY " DEV_MD_DIR "%.16s container=%s member=%d UUID=%s\n", - dev->volume, nbuf + 5, i, nbuf1 + 5); - } -@@ -2304,7 +2304,7 @@ static void export_examine_super_imsm(struct supertype *st) - char nbuf[64]; - - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - printf("MD_METADATA=imsm\n"); - printf("MD_LEVEL=container\n"); - printf("MD_UUID=%s\n", nbuf+5); -@@ -2324,7 +2324,7 @@ static void detail_super_imsm(struct supertype *st, char *homehost, - super->current_vol = strtoul(subarray, NULL, 10); - - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - printf("\n UUID : %s\n", nbuf + 5); - - super->current_vol = temp_vol; -@@ -2341,7 +2341,7 @@ static void brief_detail_super_imsm(struct supertype *st, char *subarray) - super->current_vol = strtoul(subarray, NULL, 10); - - getinfo_super_imsm(st, &info, NULL); -- fname_from_uuid(st, &info, nbuf, ':'); -+ fname_from_uuid(&info, nbuf); - printf(" UUID=%s", nbuf + 5); - - super->current_vol = temp_vol; -diff --git a/util.c b/util.c -index 49a9c6e2..03336d6f 100644 ---- a/util.c -+++ b/util.c -@@ -589,19 +589,21 @@ char *__fname_from_uuid(int id[4], int swap, char *buf, char sep) - - } - --char *fname_from_uuid(struct supertype *st, struct mdinfo *info, -- char *buf, char sep) --{ -- // dirty hack to work around an issue with super1 superblocks... -- // super1 superblocks need swapuuid set in order for assembly to -- // work, but can't have it set if we want this printout to match -- // all the other uuid printouts in super1.c, so we force swapuuid -- // to 1 to make our printout match the rest of super1 -+/** -+ * fname_from_uuid() - generate uuid string. Should not be used with super1. -+ * @info: info with uuid -+ * @buf: buf to fill. -+ * -+ * This routine should not be used with super1. See detail_fname_from_uuid() for details. It does -+ * not use superswitch swapuuid as it should be 0 but it has to do UUID conversion if host is big -+ * endian- left for backward compatibility. -+ */ -+char *fname_from_uuid(struct mdinfo *info, char *buf) -+{ - #if __BYTE_ORDER == BIG_ENDIAN -- return __fname_from_uuid(info->uuid, 1, buf, sep); -+ return __fname_from_uuid(info->uuid, true, buf, ':'); - #else -- return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 : -- st->ss->swapuuid, buf, sep); -+ return __fname_from_uuid(info->uuid, false, buf, ':'); - #endif - } - --- -2.40.1 - diff --git a/0039-sysfs-remove-vers-parameter-from-sysfs_set_array.patch b/0039-sysfs-remove-vers-parameter-from-sysfs_set_array.patch deleted file mode 100644 index c84146e..0000000 --- a/0039-sysfs-remove-vers-parameter-from-sysfs_set_array.patch +++ /dev/null @@ -1,87 +0,0 @@ -From de23e12a39cfc94575e1173293fe9e15337ee999 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 18 Mar 2024 16:53:31 +0100 -Subject: [PATCH 39/41] sysfs: remove vers parameter from sysfs_set_array - -9003 was passed directly to sysfs_set_array() since md_get_version() -always returned this value. md_get_version() was removed long ago. - -Remove dead version check from sysfs_set_array(). -Remove "vers" argument and fix function calls. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Assemble.c | 2 +- - mdadm.h | 2 +- - sysfs.c | 6 ++---- - util.c | 3 +-- - 4 files changed, 5 insertions(+), 8 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 9d042055..f6c5b99e 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1988,7 +1988,7 @@ int assemble_container_content(struct supertype *st, int mdfd, - * and ignoring special character on the first place. - */ - if (strcmp(sra->text_version + 1, content->text_version + 1) != 0) { -- if (sysfs_set_array(content, 9003) != 0) { -+ if (sysfs_set_array(content) != 0) { - sysfs_free(sra); - return 1; - } -diff --git a/mdadm.h b/mdadm.h -index a363708a..ae2106a2 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -811,7 +811,7 @@ extern int sysfs_attribute_available(struct mdinfo *sra, struct mdinfo *dev, - extern int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev, - char *name, char *val, int size); - extern int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms); --extern int sysfs_set_array(struct mdinfo *info, int vers); -+extern int sysfs_set_array(struct mdinfo *info); - extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume); - extern int sysfs_disk_to_scsi_id(int fd, __u32 *id); - extern int sysfs_unique_holder(char *devnm, long rdev); -diff --git a/sysfs.c b/sysfs.c -index 230b842e..4ded1672 100644 ---- a/sysfs.c -+++ b/sysfs.c -@@ -678,7 +678,7 @@ int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms) - return sysfs_set_str(sra, NULL, "safe_mode_delay", delay); - } - --int sysfs_set_array(struct mdinfo *info, int vers) -+int sysfs_set_array(struct mdinfo *info) - { - int rv = 0; - char ver[100]; -@@ -702,9 +702,7 @@ int sysfs_set_array(struct mdinfo *info, int vers) - if (strlen(buf) >= 9 && buf[9] == '-') - ver[9] = '-'; - -- if ((vers % 100) < 2 || -- sysfs_set_str(info, NULL, "metadata_version", -- ver) < 0) { -+ if (sysfs_set_str(info, NULL, "metadata_version", ver) < 0) { - pr_err("This kernel does not support external metadata.\n"); - return 1; - } -diff --git a/util.c b/util.c -index 03336d6f..9e837045 100644 ---- a/util.c -+++ b/util.c -@@ -1867,8 +1867,7 @@ int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info) - int rv; - - if (st->ss->external) -- return sysfs_set_array(info, 9003); -- -+ return sysfs_set_array(info); - memset(&inf, 0, sizeof(inf)); - inf.major_version = info->array.major_version; - inf.minor_version = info->array.minor_version; --- -2.40.1 - diff --git a/0040-mdadm-fix-grow-segfault-for-IMSM.patch b/0040-mdadm-fix-grow-segfault-for-IMSM.patch deleted file mode 100644 index 80df278..0000000 --- a/0040-mdadm-fix-grow-segfault-for-IMSM.patch +++ /dev/null @@ -1,55 +0,0 @@ -From ae996e81232b8ba991e763dfa15577a0af358358 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 18 Mar 2024 17:28:42 +0100 -Subject: [PATCH 40/41] mdadm: fix grow segfault for IMSM - -If sc is not initialized, there is possibility that sc.pols is not zeroed -and it causes segfault. - -Add missing initialization. -Add missing dev_policy_free() in two places. - -Fixes: f656201188d7 ("mdadm: drop get_required_spare_criteria()") -Signed-off-by: Mariusz Tkaczyk ---- - Incremental.c | 1 + - super-intel.c | 9 +++++++-- - 2 files changed, 8 insertions(+), 2 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index 958ba9ba..83db0712 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -874,6 +874,7 @@ mdadm_status_t incremental_external_test_spare_criteria(struct supertype *st, ch - rv = MDADM_STATUS_SUCCESS; - - out: -+ dev_policy_free(sc.pols); - dup->ss->free_super(dup); - free(dup); - -diff --git a/super-intel.c b/super-intel.c -index ff2590fe..70f3c4ef 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -11518,10 +11518,15 @@ static int imsm_reshape_is_allowed_on_container(struct supertype *st, - */ - static struct mdinfo *get_spares_for_grow(struct supertype *st) - { -- struct spare_criteria sc; -+ struct spare_criteria sc = {0}; -+ struct mdinfo *spares; - - get_spare_criteria_imsm(st, NULL, &sc); -- return container_choose_spares(st, &sc, NULL, NULL, NULL, 0); -+ spares = container_choose_spares(st, &sc, NULL, NULL, NULL, 0); -+ -+ dev_policy_free(sc.pols); -+ -+ return spares; - } - - /****************************************************************************** --- -2.40.1 - diff --git a/0041-Remove-all-if-zeros-pt.2.patch b/0041-Remove-all-if-zeros-pt.2.patch deleted file mode 100644 index 8fc44e8..0000000 --- a/0041-Remove-all-if-zeros-pt.2.patch +++ /dev/null @@ -1,85 +0,0 @@ -From da4d58b6d01ed8b0149b777eba7818861fde8c80 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Tue, 19 Mar 2024 11:15:29 +0100 -Subject: [PATCH 41/41] Remove all "if zeros" pt.2 - -Commit e15e8b00cbce ("Remove all "if zeros"") did not remove all "if 0" -code blocks. - -This commit is cleanup for that commit. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Build.c | 6 ------ - Grow.c | 13 +------------ - super1.c | 11 ----------- - 3 files changed, 1 insertion(+), 29 deletions(-) - -diff --git a/Build.c b/Build.c -index 1fbf8596..1be90e41 100644 ---- a/Build.c -+++ b/Build.c -@@ -156,12 +156,6 @@ int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s, - bitmap_fd = open(s->bitmap_file, O_RDWR); - if (bitmap_fd < 0) { - int major = BITMAP_MAJOR_HI; --#if 0 -- if (s->bitmap_chunk == UnSet) { -- pr_err("%s cannot be opened.\n", s->bitmap_file); -- goto abort; -- } --#endif - bitmapsize = s->size >> 9; /* FIXME wrong for RAID10 */ - if (CreateBitmap(s->bitmap_file, 1, NULL, - s->bitmap_chunk, c->delay, -diff --git a/Grow.c b/Grow.c -index c69a342d..074f1995 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -4413,19 +4413,8 @@ static void validate(int afd, int bfd, unsigned long long offset) - lseek64(afd, __le64_to_cpu(bsb2.arraystart)*512, 0); - if ((unsigned long long)read(afd, abuf, len) != len) - fail("read first from array failed"); -- if (memcmp(bbuf, abuf, len) != 0) { --#if 0 -- int i; -- printf("offset=%llu len=%llu\n", -- (unsigned long long)__le64_to_cpu(bsb2.arraystart)*512, len); -- for (i=0; imax_dev); i++) { -- int role = __le16_to_cpu(sb->dev_roles[i]); -- if (role == MD_DISK_ROLE_FAULTY) -- faulty++; -- } -- if (faulty) -- printf(" %d failed", faulty); --#endif - printf(" ('A' == active, '.' == missing, 'R' == replacing)"); - printf("\n"); - for (d = 0; d < __le32_to_cpu(sb->max_dev); d++) { --- -2.40.1 - diff --git a/0042-mdadm-Move-pr_vrb-define-to-mdadm.h.patch b/0042-mdadm-Move-pr_vrb-define-to-mdadm.h.patch deleted file mode 100644 index 0741be2..0000000 --- a/0042-mdadm-Move-pr_vrb-define-to-mdadm.h.patch +++ /dev/null @@ -1,44 +0,0 @@ -From cc75b0faaa016e54d569486c9a7abe6c39cb883a Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Mar 2024 12:51:15 +0100 -Subject: [PATCH 42/66] mdadm: Move pr_vrb define to mdadm.h - -Move pr_vrb define from super-intel.c to mdadm.h to make it widely -available. This change will be used in the next patches. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 2 ++ - super-intel.c | 2 -- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index ae2106a2..fbb161ba 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1911,6 +1911,8 @@ static inline int xasprintf(char **strp, const char *fmt, ...) { - - #define pr_info(fmt, args...) printf("%s: "fmt, Name, ##args) - -+#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); -diff --git a/super-intel.c b/super-intel.c -index 70f3c4ef..212387ec 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -393,8 +393,6 @@ struct md_list { - struct md_list *next; - }; - --#define pr_vrb(fmt, arg...) (void) (verbose && pr_err(fmt, ##arg)) -- - static __u8 migr_type(struct imsm_dev *dev) - { - if (dev->vol.migr_type == MIGR_VERIFY && --- -2.41.0 - diff --git a/0043-Add-reading-Opal-NVMe-encryption-information.patch b/0043-Add-reading-Opal-NVMe-encryption-information.patch deleted file mode 100644 index 140c620..0000000 --- a/0043-Add-reading-Opal-NVMe-encryption-information.patch +++ /dev/null @@ -1,463 +0,0 @@ -From cc48406887b3bc439e3462e8e4d20f992e81b87e Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Mar 2024 12:51:16 +0100 -Subject: [PATCH 43/66] Add reading Opal NVMe encryption information - -For NVMe devices with Opal support, encryption information, status and -ability are determined based on Opal Level 0 discovery response. Technical -documentation used is given in the implementation. - -Ability in general describes what type of encryption is supported, Status -describes in what state the disk with encryption support is. The current -patch includes only the implementation of reading encryption information, -functions will be used in one of the next patches. - -Motivation for adding this functionality is to block mixing of disks in -IMSM arrays with encryption enabled and disabled. The main goal is to not -allow stealing data by rebuilding array to not encrypted drive which can be -read elsewhere. - -Value ENA_OTHER from enum encryption_ability will be used in the next -patch. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk ---- - Makefile | 4 +- - drive_encryption.c | 362 +++++++++++++++++++++++++++++++++++++++++++++ - drive_encryption.h | 32 ++++ - 3 files changed, 396 insertions(+), 2 deletions(-) - create mode 100644 drive_encryption.c - create mode 100644 drive_encryption.h - -diff --git a/Makefile b/Makefile -index cbdba49a..7c221a89 100644 ---- a/Makefile -+++ b/Makefile -@@ -170,7 +170,7 @@ OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o uuid.o util.o maps.o lib.o u - 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 \ -- platform-intel.o probe_roms.o crc32c.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 - -@@ -183,7 +183,7 @@ MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o c - Kill.o sg_io.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 -+ platform-intel.o probe_roms.o crc32c.o drive_encryption.o - - MON_SRCS = $(patsubst %.o,%.c,$(MON_OBJS)) - -diff --git a/drive_encryption.c b/drive_encryption.c -new file mode 100644 -index 00000000..b44585a7 ---- /dev/null -+++ b/drive_encryption.c -@@ -0,0 +1,362 @@ -+// SPDX-License-Identifier: GPL-2.0-only -+/* -+ * Read encryption information for Opal and ATA devices. -+ * -+ * Copyright (C) 2024 Intel Corporation -+ * Author: Blazej Kucman -+ */ -+ -+#include "mdadm.h" -+ -+#include -+#include -+#include "drive_encryption.h" -+ -+/* -+ * Opal defines -+ * TCG Storage Opal SSC 2.01 chapter 3.3.3 -+ * NVM ExpressTM Revision 1.4c, chapter 5 -+ */ -+#define TCG_SECP_01 (0x01) -+#define TCG_SECP_00 (0x00) -+#define OPAL_DISCOVERY_COMID (0x0001) -+#define OPAL_LOCKING_FEATURE (0x0002) -+#define OPAL_IO_BUFFER_LEN 2048 -+#define OPAL_DISCOVERY_FEATURE_HEADER_LEN (4) -+ -+/* -+ * NVMe defines -+ * NVM ExpressTM Revision 1.4c, chapter 5 -+ */ -+#define NVME_SECURITY_RECV (0x82) -+#define NVME_IDENTIFY (0x06) -+#define NVME_IDENTIFY_RESPONSE_LEN 4096 -+#define NVME_OACS_BYTE_POSITION (256) -+#define NVME_IDENTIFY_CONTROLLER_DATA (1) -+ -+typedef enum drive_feature_support_status { -+ /* Drive feature is supported. */ -+ DRIVE_FEAT_SUP_ST = 0, -+ /* Drive feature is not supported. */ -+ DRIVE_FEAT_NOT_SUP_ST, -+ /* Drive feature support check failed. */ -+ DRIVE_FEAT_CHECK_FAILED_ST -+} drive_feat_sup_st; -+ -+/* TCG Storage Opal SSC 2.01 chapter 3.1.1.3 */ -+typedef struct opal_locking_feature { -+ /* feature header */ -+ __u16 feature_code; -+ __u8 reserved : 4; -+ __u8 version : 4; -+ __u8 description_length; -+ /* feature description */ -+ __u8 locking_supported : 1; -+ __u8 locking_enabled : 1; -+ __u8 locked : 1; -+ __u8 media_encryption : 1; -+ __u8 mbr_enabled : 1; -+ __u8 mbr_done : 1; -+ __u8 mbr_shadowing_not_supported : 1; -+ __u8 hw_reset_for_dor_supported : 1; -+ __u8 reserved1[11]; -+} __attribute__((__packed__)) opal_locking_feature_t; -+ -+/* TCG Storage Opal SSC 2.01 chapter 3.1.1.1 */ -+typedef struct opal_level0_header { -+ __u32 length; -+ __u32 version; -+ __u64 reserved; -+ __u8 vendor_specific[32]; -+} opal_level0_header_t; -+ -+/** -+ * NVM ExpressTM Revision 1.4c, Figure 249 -+ * Structure specifies only OACS filed, which is needed in the current use case. -+ */ -+typedef struct nvme_identify_ctrl { -+ __u8 reserved[255]; -+ __u16 oacs; -+ __u8 reserved2[3839]; -+} nvme_identify_ctrl_t; -+ -+/* SCSI Primary Commands - 4 (SPC-4), Table 512 */ -+typedef struct supported_security_protocols { -+ __u8 reserved[6]; -+ __u16 list_length; -+ __u8 list[504]; -+} supported_security_protocols_t; -+ -+/** -+ * get_opal_locking_feature_description() - get opal locking feature description. -+ * @response: response from Opal Discovery Level 0. -+ * -+ * Based on the documentation TCG Storage Opal SSC 2.01 chapter 3.1.1, -+ * a Locking feature is searched for in Opal Level 0 Discovery response. -+ * -+ * Return: if locking feature is found, pointer to struct %opal_locking_feature_t, NULL otherwise. -+ */ -+static opal_locking_feature_t *get_opal_locking_feature_description(__u8 *response) -+{ -+ opal_level0_header_t *response_header = (opal_level0_header_t *)response; -+ int features_length = __be32_to_cpu(response_header->length); -+ int current_position = sizeof(*response_header); -+ -+ while (current_position < features_length) { -+ opal_locking_feature_t *feature; -+ -+ feature = (opal_locking_feature_t *)(response + current_position); -+ -+ if (__be16_to_cpu(feature->feature_code) == OPAL_LOCKING_FEATURE) -+ return feature; -+ -+ current_position += feature->description_length + OPAL_DISCOVERY_FEATURE_HEADER_LEN; -+ } -+ -+ return NULL; -+} -+ -+/** -+ * nvme_security_recv_ioctl() - nvme security receive ioctl. -+ * @disk_fd: a disk file descriptor. -+ * @sec_protocol: security protocol. -+ * @comm_id: command id. -+ * @response_buffer: response buffer to fill out. -+ * @buf_size: response buffer size. -+ * @verbose: verbose flag. -+ * -+ * Based on the documentations TCG Storage Opal SSC 2.01 chapter 3.3.3 and -+ * NVM ExpressTM Revision 1.4c, chapter 5.25, -+ * read security receive command via ioctl(). -+ * On success, @response_buffer is completed. -+ * -+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise. -+ */ -+static mdadm_status_t -+nvme_security_recv_ioctl(int disk_fd, __u8 sec_protocol, __u16 comm_id, void *response_buffer, -+ size_t buf_size, const int verbose) -+{ -+ struct nvme_admin_cmd nvme_cmd = {0}; -+ int status; -+ -+ nvme_cmd.opcode = NVME_SECURITY_RECV; -+ nvme_cmd.cdw10 = sec_protocol << 24 | comm_id << 8; -+ nvme_cmd.cdw11 = buf_size; -+ nvme_cmd.data_len = buf_size; -+ nvme_cmd.addr = (__u64)response_buffer; -+ -+ status = ioctl(disk_fd, NVME_IOCTL_ADMIN_CMD, &nvme_cmd); -+ if (status != 0) { -+ pr_vrb("Failed to read NVMe security receive ioctl() for device /dev/%s, status: %d\n", -+ fd2kname(disk_fd), status); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ -+/** -+ * nvme_identify_ioctl() - NVMe identify ioctl. -+ * @disk_fd: a disk file descriptor. -+ * @response_buffer: response buffer to fill out. -+ * @buf_size: response buffer size. -+ * @verbose: verbose flag. -+ * -+ * Based on the documentations TCG Storage Opal SSC 2.01 chapter 3.3.3 and -+ * NVM ExpressTM Revision 1.4c, chapter 5.25, -+ * read NVMe identify via ioctl(). -+ * On success, @response_buffer will be completed. -+ * -+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise. -+ */ -+static mdadm_status_t -+nvme_identify_ioctl(int disk_fd, void *response_buffer, size_t buf_size, const int verbose) -+{ -+ struct nvme_admin_cmd nvme_cmd = {0}; -+ int status; -+ -+ nvme_cmd.opcode = NVME_IDENTIFY; -+ nvme_cmd.cdw10 = NVME_IDENTIFY_CONTROLLER_DATA; -+ nvme_cmd.data_len = buf_size; -+ nvme_cmd.addr = (__u64)response_buffer; -+ -+ status = ioctl(disk_fd, NVME_IOCTL_ADMIN_CMD, &nvme_cmd); -+ if (status != 0) { -+ pr_vrb("Failed to read NVMe identify ioctl() for device /dev/%s, status: %d\n", -+ fd2kname(disk_fd), status); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ -+/** -+ * is_sec_prot_01h_supported() - check if security protocol 01h supported. -+ * @security_protocols: struct with response from disk (NVMe, SATA) describing supported -+ * security protocols. -+ * -+ * Return: true if TCG_SECP_01 found, false otherwise. -+ */ -+static bool is_sec_prot_01h_supported(supported_security_protocols_t *security_protocols) -+{ -+ int list_length = be16toh(security_protocols->list_length); -+ int index; -+ -+ for (index = 0 ; index < list_length; index++) { -+ if (security_protocols->list[index] == TCG_SECP_01) -+ return true; -+ } -+ -+ return false; -+} -+ -+/** -+ * is_sec_prot_01h_supported_nvme() - check if security protocol 01h supported for given NVMe disk. -+ * @disk_fd: a disk file descriptor. -+ * @verbose: verbose flag. -+ * -+ * Return: %DRIVE_FEAT_SUP_ST if TCG_SECP_01 supported, %DRIVE_FEAT_NOT_SUP_ST if not supported, -+ * %DRIVE_FEAT_CHECK_FAILED_ST if failed to check. -+ */ -+static drive_feat_sup_st is_sec_prot_01h_supported_nvme(int disk_fd, const int verbose) -+{ -+ supported_security_protocols_t security_protocols = {0}; -+ -+ /* security_protocol: TCG_SECP_00, comm_id: not applicable */ -+ if (nvme_security_recv_ioctl(disk_fd, TCG_SECP_00, 0x0, &security_protocols, -+ sizeof(security_protocols), verbose)) -+ return DRIVE_FEAT_CHECK_FAILED_ST; -+ -+ if (is_sec_prot_01h_supported(&security_protocols)) -+ return DRIVE_FEAT_SUP_ST; -+ -+ return DRIVE_FEAT_NOT_SUP_ST; -+} -+ -+/** -+ * is_nvme_sec_send_recv_supported() - check if Security Send and Security Receive is supported. -+ * @disk_fd: a disk file descriptor. -+ * @verbose: verbose flag. -+ * -+ * Check if "Optional Admin Command Support" bit 0 is set in NVMe identify. -+ * Bit 0 set to 1 means controller supports the Security Send and Security Receive commands. -+ * -+ * Return: %DRIVE_FEAT_SUP_ST if security send/receive supported, -+ * %DRIVE_FEAT_NOT_SUP_ST if not supported, %DRIVE_FEAT_CHECK_FAILED_ST if check failed. -+ */ -+static drive_feat_sup_st is_nvme_sec_send_recv_supported(int disk_fd, const int verbose) -+{ -+ nvme_identify_ctrl_t nvme_identify = {0}; -+ int status = 0; -+ -+ status = nvme_identify_ioctl(disk_fd, &nvme_identify, sizeof(nvme_identify), verbose); -+ if (status) -+ return DRIVE_FEAT_CHECK_FAILED_ST; -+ -+ if ((__le16_to_cpu(nvme_identify.oacs) & 0x1) == 0x1) -+ return DRIVE_FEAT_SUP_ST; -+ -+ return DRIVE_FEAT_NOT_SUP_ST; -+} -+ -+/** -+ * get_opal_encryption_information() - get Opal encryption information. -+ * @buffer: buffer with Opal Level 0 Discovery response. -+ * @information: struct to fill out, describing encryption status of disk. -+ * -+ * If Locking feature frame is in response from Opal Level 0 discovery, &encryption_information_t -+ * structure is completed with status and ability otherwise the status is set to &None. -+ * For possible encryption statuses and abilities, -+ * please refer to enums &encryption_status and &encryption_ability. -+ * -+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise. -+ */ -+static mdadm_status_t get_opal_encryption_information(__u8 *buffer, -+ encryption_information_t *information) -+{ -+ opal_locking_feature_t *opal_locking_feature = -+ get_opal_locking_feature_description(buffer); -+ -+ if (!opal_locking_feature) -+ return MDADM_STATUS_ERROR; -+ -+ if (opal_locking_feature->locking_supported == 1) { -+ information->ability = ENC_ABILITY_SED; -+ -+ if (opal_locking_feature->locking_enabled == 0) -+ information->status = ENC_STATUS_UNENCRYPTED; -+ else if (opal_locking_feature->locked == 1) -+ information->status = ENC_STATUS_LOCKED; -+ else -+ information->status = ENC_STATUS_UNLOCKED; -+ } else { -+ information->ability = ENC_ABILITY_NONE; -+ information->status = ENC_STATUS_UNENCRYPTED; -+ } -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ -+/** -+ * get_nvme_opal_encryption_information() - get NVMe Opal encryption information. -+ * @disk_fd: a disk file descriptor. -+ * @information: struct to fill out, describing encryption status of disk. -+ * @verbose: verbose flag. -+ * -+ * In case the disk supports Opal Level 0 discovery, &encryption_information_t structure -+ * is completed with status and ability based on ioctl response, -+ * otherwise the ability is set to %ENC_ABILITY_NONE and &status to %ENC_STATUS_UNENCRYPTED. -+ * As the current use case does not need the knowledge of Opal support, if there is no support, -+ * %MDADM_STATUS_SUCCESS will be returned, with the values described above. -+ * For possible encryption statuses and abilities, -+ * please refer to enums &encryption_status and &encryption_ability. -+ * -+ * %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR otherwise. -+ */ -+mdadm_status_t -+get_nvme_opal_encryption_information(int disk_fd, encryption_information_t *information, -+ const int verbose) -+{ -+ __u8 buffer[OPAL_IO_BUFFER_LEN]; -+ int sec_send_recv_supported = 0; -+ int protocol_01h_supported = 0; -+ mdadm_status_t status; -+ -+ information->ability = ENC_ABILITY_NONE; -+ information->status = ENC_STATUS_UNENCRYPTED; -+ -+ sec_send_recv_supported = is_nvme_sec_send_recv_supported(disk_fd, verbose); -+ if (sec_send_recv_supported == DRIVE_FEAT_CHECK_FAILED_ST) -+ return MDADM_STATUS_ERROR; -+ -+ /* Opal not supported */ -+ if (sec_send_recv_supported == DRIVE_FEAT_NOT_SUP_ST) -+ return MDADM_STATUS_SUCCESS; -+ -+ /** -+ * sec_send_recv_supported determine that it should be possible to read -+ * supported sec protocols -+ */ -+ protocol_01h_supported = is_sec_prot_01h_supported_nvme(disk_fd, verbose); -+ if (protocol_01h_supported == DRIVE_FEAT_CHECK_FAILED_ST) -+ return MDADM_STATUS_ERROR; -+ -+ /* Opal not supported */ -+ if (sec_send_recv_supported == DRIVE_FEAT_SUP_ST && -+ protocol_01h_supported == DRIVE_FEAT_NOT_SUP_ST) -+ return MDADM_STATUS_SUCCESS; -+ -+ if (nvme_security_recv_ioctl(disk_fd, TCG_SECP_01, OPAL_DISCOVERY_COMID, (void *)&buffer, -+ OPAL_IO_BUFFER_LEN, verbose)) -+ return MDADM_STATUS_ERROR; -+ -+ status = get_opal_encryption_information((__u8 *)&buffer, information); -+ if (status) -+ pr_vrb("Locking feature description not found in Level 0 discovery response. Device /dev/%s.\n", -+ fd2kname(disk_fd)); -+ -+ if (information->ability == ENC_ABILITY_NONE) -+ assert(information->status == ENC_STATUS_UNENCRYPTED); -+ -+ return status; -+} -diff --git a/drive_encryption.h b/drive_encryption.h -new file mode 100644 -index 00000000..82c2c624 ---- /dev/null -+++ b/drive_encryption.h -@@ -0,0 +1,32 @@ -+/* SPDX-License-Identifier: GPL-2.0-only */ -+/* -+ * Read encryption information for Opal and ATA devices. -+ * -+ * Copyright (C) 2024 Intel Corporation -+ * Author: Blazej Kucman -+ */ -+ -+typedef enum encryption_status { -+ /* The drive is not currently encrypted. */ -+ ENC_STATUS_UNENCRYPTED = 0, -+ /* The drive is encrypted and the data is not accessible. */ -+ ENC_STATUS_LOCKED, -+ /* The drive is encrypted but the data is accessible in unencrypted form. */ -+ ENC_STATUS_UNLOCKED -+} encryption_status_t; -+ -+typedef enum encryption_ability { -+ ENC_ABILITY_NONE = 0, -+ ENC_ABILITY_OTHER, -+ /* Self encrypted drive */ -+ ENC_ABILITY_SED -+} encryption_ability_t; -+ -+typedef struct encryption_information { -+ encryption_ability_t ability; -+ encryption_status_t status; -+} encryption_information_t; -+ -+mdadm_status_t -+get_nvme_opal_encryption_information(int disk_fd, struct encryption_information *information, -+ const int verbose); --- -2.41.0 - diff --git a/0044-Add-reading-SATA-encryption-information.patch b/0044-Add-reading-SATA-encryption-information.patch deleted file mode 100644 index 607f6af..0000000 --- a/0044-Add-reading-SATA-encryption-information.patch +++ /dev/null @@ -1,459 +0,0 @@ -From df38df3052c3386c0fd076e0d534b4f688b5c8a4 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Mar 2024 12:51:17 +0100 -Subject: [PATCH 44/66] Add reading SATA encryption information - -Functionality reads information about SATA disk encryption. Technical -documentation used is given in the implementation. - -The implementation is able to recognized two encryption standards for SATA -drives, OPAL and ATA security. - -If the SATA drive supports OPAL, encryption status and ability are -determined based on Opal Level 0 discovery response, for ATA security, -based on ATA identify response. If SATA supports OPAL, ability is set to -"SED", for ATA security to "Other". - -SED(Self-Encrypting Drive) is commonly used to describe drive which using -OPAL or Enterprise standards developed by Trusted Computing Group. Ability -"Other" is used for ATA security because we rely only on information from -ATA identify which describe the overall state of encryption. - -It is allowed to mix disks with different encryption ability such as "SED" -and "Other" and it is not security gap. - -Motivation for adding this functionality is to block mixing of disks in -IMSM arrays with encryption enabled and disabled. The main goal is to not -allow stealing data by rebuilding array to not encrypted drive which can be -read elsewhere. - -For SATA Opal drives, libata allow_tmp parameter enabled is required, which -is necessary for Opal Security commands to work, therefore, if the -parameter is not enabled, SATA Opal disk cannot be used in case the -encryption will be checked by metadata. - -Implemented functions will be used in one of the next patches. In one of -the next patches, a flag will be added to enable disabling SATA Opal -encryption checking due to allow_tpm kernel setting dependency. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk ---- - drive_encryption.c | 318 +++++++++++++++++++++++++++++++++++++++++++++ - drive_encryption.h | 3 + - mdadm.h | 1 + - sysfs.c | 29 +++++ - 4 files changed, 351 insertions(+) - -diff --git a/drive_encryption.c b/drive_encryption.c -index b44585a7..d520f0c7 100644 ---- a/drive_encryption.c -+++ b/drive_encryption.c -@@ -10,8 +10,12 @@ - - #include - #include -+#include -+#include - #include "drive_encryption.h" - -+#define DEFAULT_SECTOR_SIZE (512) -+ - /* - * Opal defines - * TCG Storage Opal SSC 2.01 chapter 3.3.3 -@@ -34,6 +38,35 @@ - #define NVME_OACS_BYTE_POSITION (256) - #define NVME_IDENTIFY_CONTROLLER_DATA (1) - -+/* -+ * ATA defines -+ * ATA/ATAPI Command Set ATA8-ACS -+ * SCSI / ATA Translation - 3 (SAT-3) -+ * SCSI Primary Commands - 4 (SPC-4) -+ * AT Attachment-8 - ATA Serial Transport (ATA8-AST) -+ * ATA Command Pass-Through -+ */ -+#define ATA_IDENTIFY (0xec) -+#define ATA_TRUSTED_RECEIVE (0x5c) -+#define ATA_SECURITY_WORD_POSITION (128) -+#define HDIO_DRIVE_CMD (0x031f) -+#define ATA_TRUSTED_COMPUTING_POS (48) -+#define ATA_PASS_THROUGH_12 (0xa1) -+#define ATA_IDENTIFY_RESPONSE_LEN (512) -+#define ATA_PIO_DATA_IN (4) -+#define SG_CHECK_CONDITION (0x02) -+#define ATA_STATUS_RETURN_DESCRIPTOR (0x09) -+#define ATA_PT_INFORMATION_AVAILABLE_ASCQ (0x1d) -+#define ATA_PT_INFORMATION_AVAILABLE_ASC (0x00) -+#define ATA_INQUIRY_LENGTH (0x0c) -+#define SG_INTERFACE_ID 'S' -+#define SG_IO_TIMEOUT (60000) -+#define SG_SENSE_SIZE (32) -+#define SENSE_DATA_CURRENT_FIXED (0x70) -+#define SENSE_DATA_CURRENT_DESC (0x72) -+#define SENSE_CURRENT_RES_DESC_POS (8) -+#define SG_DRIVER_SENSE (0x08) -+ - typedef enum drive_feature_support_status { - /* Drive feature is supported. */ - DRIVE_FEAT_SUP_ST = 0, -@@ -87,6 +120,27 @@ typedef struct supported_security_protocols { - __u8 list[504]; - } supported_security_protocols_t; - -+/* ATA/ATAPI Command Set - 3 (ACS-3), Table 45 */ -+typedef struct ata_security_status { -+ __u16 security_supported : 1; -+ __u16 security_enabled : 1; -+ __u16 security_locked : 1; -+ __u16 security_frozen : 1; -+ __u16 security_count_expired : 1; -+ __u16 enhanced_security_erase_supported : 1; -+ __u16 reserved1 : 2; -+ __u16 security_level : 1; -+ __u16 reserved2 : 7; -+} __attribute__((__packed__)) ata_security_status_t; -+ -+/* ATA/ATAPI Command Set - 3 (ACS-3), Table 45 */ -+typedef struct ata_trusted_computing { -+ __u16 tc_feature :1; -+ __u16 reserved : 13; -+ __u16 var1 : 1; -+ __u16 var2 : 1; -+} __attribute__((__packed__)) ata_trusted_computing_t; -+ - /** - * get_opal_locking_feature_description() - get opal locking feature description. - * @response: response from Opal Discovery Level 0. -@@ -360,3 +414,267 @@ get_nvme_opal_encryption_information(int disk_fd, encryption_information_t *info - - return status; - } -+ -+/** -+ * ata_pass_through12_ioctl() - ata pass through12 ioctl. -+ * @disk_fd: a disk file descriptor. -+ * @ata_command: ata command. -+ * @sec_protocol: security protocol. -+ * @comm_id: additional command id. -+ * @response_buffer: response buffer to fill out. -+ * @buf_size: response buffer size. -+ * @verbose: verbose flag. -+ * -+ * Based on the documentations ATA Command Pass-Through, chapter 13.2.2 and -+ * ATA Translation - 3 (SAT-3), send read ata pass through 12 command via ioctl(). -+ * On success, @response_buffer will be completed. -+ * -+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR on fail. -+ */ -+static mdadm_status_t -+ata_pass_through12_ioctl(int disk_fd, __u8 ata_command, __u8 sec_protocol, __u16 comm_id, -+ void *response_buffer, size_t buf_size, const int verbose) -+{ -+ __u8 cdb[ATA_INQUIRY_LENGTH] = {0}; -+ __u8 sense[SG_SENSE_SIZE] = {0}; -+ __u8 *sense_desc = NULL; -+ sg_io_hdr_t sg = {0}; -+ -+ /* -+ * ATA Command Pass-Through, chapter 13.2.2 -+ * SCSI Primary Commands - 4 (SPC-4) -+ * ATA Translation - 3 (SAT-3) -+ */ -+ cdb[0] = ATA_PASS_THROUGH_12; -+ /* protocol, bits 1-4 */ -+ cdb[1] = ATA_PIO_DATA_IN << 1; -+ /* Bytes: CK_COND=1, T_DIR = 1, BYTE_BLOCK = 1, Length in Sector Count = 2 */ -+ cdb[2] = 0x2E; -+ cdb[3] = sec_protocol; -+ /* Sector count */ -+ cdb[4] = buf_size / DEFAULT_SECTOR_SIZE; -+ cdb[6] = (comm_id) & 0xFF; -+ cdb[7] = (comm_id >> 8) & 0xFF; -+ cdb[9] = ata_command; -+ -+ sg.interface_id = SG_INTERFACE_ID; -+ sg.cmd_len = sizeof(cdb); -+ sg.mx_sb_len = sizeof(sense); -+ sg.dxfer_direction = SG_DXFER_FROM_DEV; -+ sg.dxfer_len = buf_size; -+ sg.dxferp = response_buffer; -+ sg.cmdp = cdb; -+ sg.sbp = sense; -+ sg.timeout = SG_IO_TIMEOUT; -+ sg.usr_ptr = NULL; -+ -+ if (ioctl(disk_fd, SG_IO, &sg) < 0) { -+ pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s.\n", fd2kname(disk_fd)); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ if ((sg.status && sg.status != SG_CHECK_CONDITION) || sg.host_status || -+ (sg.driver_status && sg.driver_status != SG_DRIVER_SENSE)) { -+ pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s.\n", fd2kname(disk_fd)); -+ pr_vrb("SG_IO error: ATA_12 Status: %d Host Status: %d, Driver Status: %d\n", -+ sg.status, sg.host_status, sg.driver_status); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ /* verify expected sense response code */ -+ if (!(sense[0] == SENSE_DATA_CURRENT_DESC || sense[0] == SENSE_DATA_CURRENT_FIXED)) { -+ pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s.\n", fd2kname(disk_fd)); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ sense_desc = sense + SENSE_CURRENT_RES_DESC_POS; -+ /* verify sense data current response with descriptor format */ -+ if (sense[0] == SENSE_DATA_CURRENT_DESC && -+ !(sense_desc[0] == ATA_STATUS_RETURN_DESCRIPTOR && -+ sense_desc[1] == ATA_INQUIRY_LENGTH)) { -+ pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s. Sense data ASC: %d, ASCQ: %d.\n", -+ fd2kname(disk_fd), sense[2], sense[3]); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ /* verify sense data current response with fixed format */ -+ if (sense[0] == SENSE_DATA_CURRENT_FIXED && -+ !(sense[12] == ATA_PT_INFORMATION_AVAILABLE_ASC && -+ sense[13] == ATA_PT_INFORMATION_AVAILABLE_ASCQ)) { -+ pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s. Sense data ASC: %d, ASCQ: %d.\n", -+ fd2kname(disk_fd), sense[12], sense[13]); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ -+/** -+ * is_sec_prot_01h_supported_ata() - check if security protocol 01h supported for given SATA disk. -+ * @disk_fd: a disk file descriptor. -+ * @verbose: verbose flag. -+ * -+ * Return: %DRIVE_FEAT_SUP_ST if TCG_SECP_01 supported, %DRIVE_FEAT_NOT_SUP_ST if not supported, -+ * %DRIVE_FEAT_CHECK_FAILED_ST if failed. -+ */ -+static drive_feat_sup_st is_sec_prot_01h_supported_ata(int disk_fd, const int verbose) -+{ -+ supported_security_protocols_t security_protocols; -+ -+ mdadm_status_t result = ata_pass_through12_ioctl(disk_fd, ATA_TRUSTED_RECEIVE, TCG_SECP_00, -+ 0x0, &security_protocols, -+ sizeof(security_protocols), verbose); -+ if (result) -+ return DRIVE_FEAT_CHECK_FAILED_ST; -+ -+ if (is_sec_prot_01h_supported(&security_protocols)) -+ return DRIVE_FEAT_SUP_ST; -+ -+ return DRIVE_FEAT_NOT_SUP_ST; -+} -+ -+/** -+ * is_ata_trusted_computing_supported() - check if ata trusted computing supported. -+ * @buffer: buffer with ATA identify response, not NULL. -+ * -+ * Return: true if trusted computing bit set, false otherwise. -+ */ -+bool is_ata_trusted_computing_supported(__u16 *buffer) -+{ -+ /* Added due to warnings from the compiler about a possible uninitialized variable below. */ -+ assert(buffer); -+ -+ __u16 security_tc_frame = __le16_to_cpu(buffer[ATA_TRUSTED_COMPUTING_POS]); -+ ata_trusted_computing_t *security_tc = (ata_trusted_computing_t *)&security_tc_frame; -+ -+ if (security_tc->tc_feature == 1) -+ return true; -+ -+ return false; -+} -+ -+/** -+ * get_ata_standard_security_status() - get ATA disk encryption information from ATA identify. -+ * @buffer: buffer with response from ATA identify, not NULL. -+ * @information: struct to fill out, describing encryption status of disk. -+ * -+ * The function based on the Security status frame from ATA identify, -+ * completed encryption information. -+ * For possible encryption statuses and abilities, -+ * please refer to enums &encryption_status and &encryption_ability. -+ * -+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR on fail. -+ */ -+static mdadm_status_t get_ata_standard_security_status(__u16 *buffer, -+ struct encryption_information *information) -+{ -+ /* Added due to warnings from the compiler about a possible uninitialized variable below. */ -+ assert(buffer); -+ -+ __u16 security_status_frame = __le16_to_cpu(buffer[ATA_SECURITY_WORD_POSITION]); -+ ata_security_status_t *security_status = (ata_security_status_t *)&security_status_frame; -+ -+ if (!security_status->security_supported) { -+ information->ability = ENC_ABILITY_NONE; -+ information->status = ENC_STATUS_UNENCRYPTED; -+ -+ return MDADM_STATUS_SUCCESS; -+ } -+ -+ information->ability = ENC_ABILITY_OTHER; -+ -+ if (security_status->security_enabled == 0) -+ information->status = ENC_STATUS_UNENCRYPTED; -+ else if (security_status->security_locked == 1) -+ information->status = ENC_STATUS_LOCKED; -+ else -+ information->status = ENC_STATUS_UNLOCKED; -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ -+/** -+ * is_ata_opal() - check if SATA disk support Opal. -+ * @disk_fd: a disk file descriptor. -+ * @buffer: buffer with ATA identify response. -+ * @verbose: verbose flag. -+ * -+ * Return: %DRIVE_FEAT_SUP_ST if TCG_SECP_01 supported, %DRIVE_FEAT_NOT_SUP_ST if not supported, -+ * %DRIVE_FEAT_CHECK_FAILED_ST if failed to check. -+ */ -+static drive_feat_sup_st is_ata_opal(int disk_fd, __u16 *buffer_identify, const int verbose) -+{ -+ bool tc_status = is_ata_trusted_computing_supported(buffer_identify); -+ drive_feat_sup_st tcg_sec_prot_status; -+ -+ if (!tc_status) -+ return DRIVE_FEAT_NOT_SUP_ST; -+ -+ tcg_sec_prot_status = is_sec_prot_01h_supported_ata(disk_fd, verbose); -+ -+ if (tcg_sec_prot_status == DRIVE_FEAT_CHECK_FAILED_ST) { -+ pr_vrb("Failed to verify if security protocol 01h supported. Device /dev/%s.\n", -+ fd2kname(disk_fd)); -+ return DRIVE_FEAT_CHECK_FAILED_ST; -+ } -+ -+ if (tc_status && tcg_sec_prot_status == DRIVE_FEAT_SUP_ST) -+ return DRIVE_FEAT_SUP_ST; -+ -+ return DRIVE_FEAT_NOT_SUP_ST; -+} -+ -+/** -+ * get_ata_encryption_information() - get ATA disk encryption information. -+ * @disk_fd: a disk file descriptor. -+ * @information: struct to fill out, describing encryption status of disk. -+ * @verbose: verbose flag. -+ * -+ * The function reads information about encryption, if the disk supports Opal, -+ * the information is completed based on Opal Level 0 discovery, otherwise, -+ * based on ATA security status frame from ATA identification response. -+ * For possible encryption statuses and abilities, -+ * please refer to enums &encryption_status and &encryption_ability. -+ * -+ * Based on the documentations ATA/ATAPI Command Set ATA8-ACS and -+ * AT Attachment-8 - ATA Serial Transport (ATA8-AST). -+ * -+ * Return: %MDADM_STATUS_SUCCESS on success, %MDADM_STATUS_ERROR on fail. -+ */ -+mdadm_status_t -+get_ata_encryption_information(int disk_fd, struct encryption_information *information, -+ const int verbose) -+{ -+ __u8 buffer_opal_level0_discovery[OPAL_IO_BUFFER_LEN] = {0}; -+ __u16 buffer_identify[ATA_IDENTIFY_RESPONSE_LEN] = {0}; -+ drive_feat_sup_st ata_opal_status; -+ mdadm_status_t status; -+ -+ /* Get disk ATA identification */ -+ status = ata_pass_through12_ioctl(disk_fd, ATA_IDENTIFY, 0x0, 0x0, buffer_identify, -+ sizeof(buffer_identify), verbose); -+ if (status == MDADM_STATUS_ERROR) -+ return MDADM_STATUS_ERROR; -+ -+ if (is_ata_trusted_computing_supported(buffer_identify) && -+ !sysfs_is_libata_allow_tpm_enabled(verbose)) { -+ pr_vrb("For SATA with Trusted Computing support, required libata.tpm_enabled=1.\n"); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ ata_opal_status = is_ata_opal(disk_fd, buffer_identify, verbose); -+ if (ata_opal_status == DRIVE_FEAT_CHECK_FAILED_ST) -+ return MDADM_STATUS_ERROR; -+ -+ if (ata_opal_status == DRIVE_FEAT_NOT_SUP_ST) -+ return get_ata_standard_security_status(buffer_identify, information); -+ -+ /* SATA Opal */ -+ status = ata_pass_through12_ioctl(disk_fd, ATA_TRUSTED_RECEIVE, TCG_SECP_01, -+ OPAL_DISCOVERY_COMID, buffer_opal_level0_discovery, -+ OPAL_IO_BUFFER_LEN, verbose); -+ if (status != MDADM_STATUS_SUCCESS) -+ return MDADM_STATUS_ERROR; -+ -+ return get_opal_encryption_information(buffer_opal_level0_discovery, information); -+} -diff --git a/drive_encryption.h b/drive_encryption.h -index 82c2c624..77c7f10f 100644 ---- a/drive_encryption.h -+++ b/drive_encryption.h -@@ -30,3 +30,6 @@ typedef struct encryption_information { - mdadm_status_t - get_nvme_opal_encryption_information(int disk_fd, struct encryption_information *information, - const int verbose); -+mdadm_status_t -+get_ata_encryption_information(int disk_fd, struct encryption_information *information, -+ const int verbose); -diff --git a/mdadm.h b/mdadm.h -index fbb161ba..52a66b9a 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -853,6 +853,7 @@ extern int restore_stripes(int *dest, unsigned long long *offsets, - int source, unsigned long long read_offset, - unsigned long long start, unsigned long long length, - char *src_buf); -+extern bool sysfs_is_libata_allow_tpm_enabled(const int verbose); - - #ifndef Sendmail - #define Sendmail "/usr/lib/sendmail -t" -diff --git a/sysfs.c b/sysfs.c -index 4ded1672..20fe1e9e 100644 ---- a/sysfs.c -+++ b/sysfs.c -@@ -1121,3 +1121,32 @@ void sysfsline(char *line) - sr->next = sysfs_rules; - sysfs_rules = sr; - } -+ -+/** -+ * sysfs_is_libata_allow_tpm_enabled() - check if libata allow_tmp is enabled. -+ * @verbose: verbose flag. -+ * -+ * Check if libata allow_tmp flag is set, this is required for SATA Opal Security commands to work. -+ * -+ * Return: true if allow_tpm enable, false otherwise. -+ */ -+bool sysfs_is_libata_allow_tpm_enabled(const int verbose) -+{ -+ const char *path = "/sys/module/libata/parameters/allow_tpm"; -+ const char *expected_value = "1"; -+ int fd = open(path, O_RDONLY); -+ char buf[3]; -+ -+ if (!is_fd_valid(fd)) { -+ pr_vrb("Failed open file descriptor to %s. Cannot check libata allow_tpm param.\n", -+ path); -+ return false; -+ } -+ -+ sysfs_fd_get_str(fd, buf, sizeof(buf)); -+ close(fd); -+ -+ if (strncmp(buf, expected_value, 1) == 0) -+ return true; -+ return false; -+} --- -2.41.0 - diff --git a/0045-Add-key-ENCRYPTION_NO_VERIFY-to-conf.patch b/0045-Add-key-ENCRYPTION_NO_VERIFY-to-conf.patch deleted file mode 100644 index d9009c4..0000000 --- a/0045-Add-key-ENCRYPTION_NO_VERIFY-to-conf.patch +++ /dev/null @@ -1,163 +0,0 @@ -From 336e13fc5ef43bc5b4633a9dadac5f7208e6c241 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Mar 2024 12:51:18 +0100 -Subject: [PATCH 45/66] Add key ENCRYPTION_NO_VERIFY to conf - -Add ENCRYPTION_NO_VERIFY config key and allow to disable checking -encryption status for given type of drives. - -The key is introduced because of SATA Opal disks for which TPM commands -must be enabled in libata kernel module, (libata.allow_tpm=1), otherwise -it is impossible to verify encryption status. TPM commands are disabled by -default. - -Currently the key only supports the "sata_opal" value, if necessary, -the functionality is ready to support more types of disks. This -functionality will be used in the next patches. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk ---- - config.c | 25 ++++++++++++++++++++++++- - drive_encryption.c | 16 ++++++++++++---- - mdadm.conf.5.in | 13 +++++++++++++ - mdadm.h | 1 + - 4 files changed, 50 insertions(+), 5 deletions(-) - -diff --git a/config.c b/config.c -index 44f7dd2f..b46d71cb 100644 ---- a/config.c -+++ b/config.c -@@ -81,7 +81,7 @@ char DefaultAltConfDir[] = CONFFILE2 ".d"; - - enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev, - Homehost, HomeCluster, AutoMode, Policy, PartPolicy, Sysfs, -- MonitorDelay, LTEnd }; -+ MonitorDelay, EncryptionNoVerify, LTEnd }; - char *keywords[] = { - [Devices] = "devices", - [Array] = "array", -@@ -96,6 +96,7 @@ char *keywords[] = { - [PartPolicy]="part-policy", - [Sysfs] = "sysfs", - [MonitorDelay] = "monitordelay", -+ [EncryptionNoVerify] = "ENCRYPTION_NO_VERIFY", - [LTEnd] = NULL - }; - -@@ -729,6 +730,19 @@ void monitordelayline(char *line) - } - } - -+static bool sata_opal_encryption_no_verify; -+void encryption_no_verify_line(char *line) -+{ -+ char *word; -+ -+ for (word = dl_next(line); word != line; word = dl_next(word)) { -+ if (strcasecmp(word, "sata_opal") == 0) -+ sata_opal_encryption_no_verify = true; -+ else -+ pr_err("unrecognised word on ENCRYPTION_NO_VERIFY line: %s\n", word); -+ } -+} -+ - char auto_yes[] = "yes"; - char auto_no[] = "no"; - char auto_homehost[] = "homehost"; -@@ -913,6 +927,9 @@ void conf_file(FILE *f) - case MonitorDelay: - monitordelayline(line); - break; -+ case EncryptionNoVerify: -+ encryption_no_verify_line(line); -+ break; - default: - pr_err("Unknown keyword %s\n", line); - } -@@ -1075,6 +1092,12 @@ int conf_get_monitor_delay(void) - return monitor_delay; - } - -+bool conf_get_sata_opal_encryption_no_verify(void) -+{ -+ load_conffile(); -+ return sata_opal_encryption_no_verify; -+} -+ - struct createinfo *conf_get_create_info(void) - { - load_conffile(); -diff --git a/drive_encryption.c b/drive_encryption.c -index d520f0c7..6b2bd358 100644 ---- a/drive_encryption.c -+++ b/drive_encryption.c -@@ -656,10 +656,18 @@ get_ata_encryption_information(int disk_fd, struct encryption_information *infor - if (status == MDADM_STATUS_ERROR) - return MDADM_STATUS_ERROR; - -- if (is_ata_trusted_computing_supported(buffer_identify) && -- !sysfs_is_libata_allow_tpm_enabled(verbose)) { -- pr_vrb("For SATA with Trusted Computing support, required libata.tpm_enabled=1.\n"); -- return MDADM_STATUS_ERROR; -+ /* Possible OPAL support, further checks require tpm_enabled.*/ -+ if (is_ata_trusted_computing_supported(buffer_identify)) { -+ /* OPAL SATA encryption checking disabled. */ -+ if (conf_get_sata_opal_encryption_no_verify()) -+ return MDADM_STATUS_SUCCESS; -+ -+ if (!sysfs_is_libata_allow_tpm_enabled(verbose)) { -+ pr_vrb("Detected SATA drive /dev/%s with Trusted Computing support.\n", -+ fd2kname(disk_fd)); -+ pr_vrb("Cannot verify encryption state. Requires libata.tpm_enabled=1.\n"); -+ return MDADM_STATUS_ERROR; -+ } - } - - ata_opal_status = is_ata_opal(disk_fd, buffer_identify, verbose); -diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in -index 787e51e9..afb0a296 100644 ---- a/mdadm.conf.5.in -+++ b/mdadm.conf.5.in -@@ -636,6 +636,17 @@ If multiple - .B MINITORDELAY - lines are provided, only first non-zero value is considered. - -+.TP -+.B ENCRYPTION_NO_VERIFY -+The -+.B ENCRYPTION_NO_VERIFY -+disables encryption verification for devices with particular encryption support detected. -+Currently, only verification of SATA OPAL encryption can be disabled. -+It does not disable ATA security encryption verification. -+Available parameter -+.I "sata_opal". -+ -+ - .SH FILES - - .SS {CONFFILE} -@@ -744,6 +755,8 @@ SYSFS uuid=bead5eb6:31c17a27:da120ba2:7dfda40d group_thread_cnt=4 - sync_speed_max=1000000 - .br - MONITORDELAY 60 -+.br -+ENCRYPTION_NO_VERIFY sata_opal - - .SH SEE ALSO - .BR mdadm (8), -diff --git a/mdadm.h b/mdadm.h -index 52a66b9a..2640b396 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1673,6 +1673,7 @@ extern char *conf_get_program(void); - extern char *conf_get_homehost(int *require_homehostp); - extern char *conf_get_homecluster(void); - extern int conf_get_monitor_delay(void); -+extern bool conf_get_sata_opal_encryption_no_verify(void); - extern char *conf_line(FILE *file); - extern char *conf_word(FILE *file, int allow_key); - extern void print_quoted(char *str); --- -2.41.0 - diff --git a/0046-imsm-print-disk-encryption-information.patch b/0046-imsm-print-disk-encryption-information.patch deleted file mode 100644 index 0208e72..0000000 --- a/0046-imsm-print-disk-encryption-information.patch +++ /dev/null @@ -1,217 +0,0 @@ -From bf62ed5d9642aa60abf4ac2d1d89f173bd66ae48 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Mar 2024 12:51:19 +0100 -Subject: [PATCH 46/66] imsm: print disk encryption information - -Print SATA/NVMe disk encryption information in --detail-platform. -Encryption Ability and Status will be printed for each disk. - -There is one exception, Opal SATA drives encryption is not checked when -ENCRYPTION_NO_VERIFY key with "sata_opal" value is set in conf, for this -reason such drives are treated as without encryption support. - -To test this feature, drives SATA/NVMe with Opal support or SATA drives -with encryption support have to be used. - -Example outputs of --detail-platform: - -Non Opal, encryption enabled, SATA drive: -Port0 : /dev/sdc (CVPR050600G3120LGN) - Encryption(Ability|Status): Other|Unlocked - -NVMe drive without Opal support: -NVMe under VMD : /dev/nvme2n1 (PHLF737302GB1P0GGN) - Encryption(Ability|Status): None|Unencrypted - -Unencrypted SATA drive with OPAL support: - -- default allow_tpm, we will get an error from mdadm: - Port6 : /dev/sdi (CVTS4246015V180IGN) -mdadm: Detected SATA drive /dev/sdi with Trusted Computing support. -mdadm: Cannot verify encryption state. Requires libata.tpm_enabled=1. -mdadm: Failed to get drive encrytpion information. - -- default "allow_tpm" and config entry "ENCRYPTION_NO_VERIFY sata_opal": -Port6 : /dev/sdi (CVTS4246015V180IGN) - Encryption(Ability|Status): None|Unencrypted - -- added "libata.allow_tpm=1" to boot parameters(requires reboot), -the status will be read correctly: -Port6 : /dev/sdi (CVTS4246015V180IGN) - Encryption(Ability|Status): SED|Unencrypted - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk ---- - drive_encryption.c | 36 ++++++++++++++++++++++++++++++++++++ - drive_encryption.h | 2 ++ - mdadm.conf.5.in | 3 +++ - super-intel.c | 42 ++++++++++++++++++++++++++++++++++++++---- - 4 files changed, 79 insertions(+), 4 deletions(-) - -diff --git a/drive_encryption.c b/drive_encryption.c -index 6b2bd358..27da9621 100644 ---- a/drive_encryption.c -+++ b/drive_encryption.c -@@ -141,6 +141,42 @@ typedef struct ata_trusted_computing { - __u16 var2 : 1; - } __attribute__((__packed__)) ata_trusted_computing_t; - -+mapping_t encryption_ability_map[] = { -+ { "None", ENC_ABILITY_NONE }, -+ { "Other", ENC_ABILITY_OTHER }, -+ { "SED", ENC_ABILITY_SED }, -+ { NULL, UnSet } -+}; -+ -+mapping_t encryption_status_map[] = { -+ { "Unencrypted", ENC_STATUS_UNENCRYPTED }, -+ { "Locked", ENC_STATUS_LOCKED }, -+ { "Unlocked", ENC_STATUS_UNLOCKED }, -+ { NULL, UnSet } -+}; -+ -+/** -+ * get_encryption_ability_string() - get encryption ability name string. -+ * @ability: encryption ability enum. -+ * -+ * Return: encryption ability string. -+ */ -+const char *get_encryption_ability_string(enum encryption_ability ability) -+{ -+ return map_num_s(encryption_ability_map, ability); -+} -+ -+/** -+ * get_encryption_status_string() - get encryption status name string. -+ * @ability: encryption status enum. -+ * -+ * Return: encryption status string. -+ */ -+const char *get_encryption_status_string(enum encryption_status status) -+{ -+ return map_num_s(encryption_status_map, status); -+} -+ - /** - * get_opal_locking_feature_description() - get opal locking feature description. - * @response: response from Opal Discovery Level 0. -diff --git a/drive_encryption.h b/drive_encryption.h -index 77c7f10f..0cb8ff1b 100644 ---- a/drive_encryption.h -+++ b/drive_encryption.h -@@ -33,3 +33,5 @@ get_nvme_opal_encryption_information(int disk_fd, struct encryption_information - mdadm_status_t - get_ata_encryption_information(int disk_fd, struct encryption_information *information, - const int verbose); -+const char *get_encryption_ability_string(enum encryption_ability ability); -+const char *get_encryption_status_string(enum encryption_status status); -diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in -index afb0a296..14302a91 100644 ---- a/mdadm.conf.5.in -+++ b/mdadm.conf.5.in -@@ -643,6 +643,9 @@ The - disables encryption verification for devices with particular encryption support detected. - Currently, only verification of SATA OPAL encryption can be disabled. - It does not disable ATA security encryption verification. -+Currently effective only for -+.I IMSM -+metadata. - Available parameter - .I "sata_opal". - -diff --git a/super-intel.c b/super-intel.c -index 212387ec..fbd1c11f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include "drive_encryption.h" - - /* MPB == Metadata Parameter Block */ - #define MPB_SIGNATURE "Intel Raid ISM Cfg Sig. " -@@ -2349,12 +2350,41 @@ static int imsm_read_serial(int fd, char *devname, __u8 *serial, - size_t serial_buf_len); - static void fd2devname(int fd, char *name); - --static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_base, int verbose) -+void print_encryption_information(int disk_fd, enum sys_dev_type hba_type) -+{ -+ struct encryption_information information = {0}; -+ mdadm_status_t status = MDADM_STATUS_SUCCESS; -+ const char *indent = " "; -+ -+ switch (hba_type) { -+ case SYS_DEV_VMD: -+ case SYS_DEV_NVME: -+ status = get_nvme_opal_encryption_information(disk_fd, &information, 1); -+ break; -+ case SYS_DEV_SATA: -+ case SYS_DEV_SATA_VMD: -+ status = get_ata_encryption_information(disk_fd, &information, 1); -+ break; -+ default: -+ return; -+ } -+ -+ if (status) { -+ pr_err("Failed to get drive encryption information.\n"); -+ return; -+ } -+ -+ printf("%sEncryption(Ability|Status): %s|%s\n", indent, -+ get_encryption_ability_string(information.ability), -+ get_encryption_status_string(information.status)); -+} -+ -+static int ahci_enumerate_ports(struct sys_dev *hba, int port_count, int host_base, int verbose) - { - /* dump an unsorted list of devices attached to AHCI Intel storage - * controller, as well as non-connected ports - */ -- int hba_len = strlen(hba_path) + 1; -+ int hba_len = strlen(hba->path) + 1; - struct dirent *ent; - DIR *dir; - char *path = NULL; -@@ -2390,7 +2420,7 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b - path = devt_to_devpath(makedev(major, minor), 1, NULL); - if (!path) - continue; -- if (!path_attached_to_hba(path, hba_path)) { -+ if (!path_attached_to_hba(path, hba->path)) { - free(path); - path = NULL; - continue; -@@ -2493,6 +2523,8 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b - printf(" (%s)\n", buf); - else - printf(" ()\n"); -+ -+ print_encryption_information(fd, hba->type); - close(fd); - } - free(path); -@@ -2557,6 +2589,8 @@ static int print_nvme_info(struct sys_dev *hba) - else - printf("()\n"); - -+ print_encryption_information(fd, hba->type); -+ - skip: - close_fd(&fd); - } -@@ -2812,7 +2846,7 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle - hba->path, get_sys_dev_type(hba->type)); - if (hba->type == SYS_DEV_SATA || hba->type == SYS_DEV_SATA_VMD) { - host_base = ahci_get_port_count(hba->path, &port_count); -- if (ahci_enumerate_ports(hba->path, port_count, host_base, verbose)) { -+ if (ahci_enumerate_ports(hba, port_count, host_base, verbose)) { - if (verbose > 0) - pr_err("failed to enumerate ports on %s controller at %s.\n", - get_sys_dev_type(hba->type), hba->pci_id); --- -2.41.0 - diff --git a/0047-imsm-drive-encryption-policy-implementation.patch b/0047-imsm-drive-encryption-policy-implementation.patch deleted file mode 100644 index c4b9d0a..0000000 --- a/0047-imsm-drive-encryption-policy-implementation.patch +++ /dev/null @@ -1,114 +0,0 @@ -From acb8f13be88c224eb1e01f72c1e1fda955bc80ba Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Mar 2024 12:51:20 +0100 -Subject: [PATCH 47/66] imsm: drive encryption policy implementation - -IMSM cares about drive encryption state. It is not allowed to mix disks -with different encryption state within one md device. This policy will -verify that attempt to use disks with different encryption states will -fail. Verification is performed for devices NVMe/SATA Opal and SATA. - -There is one exception, Opal SATA drives encryption is not checked when -ENCRYPTION_NO_VERIFY key with "sata_opal" value is set in conf, for this -reason such drives are treated as without encryption support. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 73 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index fbd1c11f..1faab607 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -11291,6 +11291,78 @@ test_and_add_drive_controller_policy_imsm(const char * const type, dev_policy_t - return MDADM_STATUS_ERROR; - } - -+/** -+ * test_and_add_drive_encryption_policy_imsm() - add disk encryption to policies list. -+ * @type: policy type to search in the list. -+ * @pols: list of currently recorded policies. -+ * @disk_fd: file descriptor of the device to check. -+ * @hba: The hba to which the drive is attached, could be NULL if verification is disabled. -+ * @verbose: verbose flag. -+ * -+ * IMSM cares about drive encryption state. It is not allowed to mix disks with different -+ * encryption state within one md device. -+ * If there is no encryption policy on pols we are free to add first one. -+ * If there is a policy then, new must be the same. -+ */ -+static mdadm_status_t -+test_and_add_drive_encryption_policy_imsm(const char * const type, dev_policy_t **pols, int disk_fd, -+ struct sys_dev *hba, const int verbose) -+{ -+ struct dev_policy *expected_policy = pol_find(*pols, (char *)type); -+ struct encryption_information information = {0}; -+ char *encryption_state = "Unknown"; -+ int status = MDADM_STATUS_SUCCESS; -+ bool encryption_checked = true; -+ char devname[PATH_MAX]; -+ -+ if (!hba) -+ goto check_policy; -+ -+ switch (hba->type) { -+ case SYS_DEV_NVME: -+ case SYS_DEV_VMD: -+ status = get_nvme_opal_encryption_information(disk_fd, &information, verbose); -+ break; -+ case SYS_DEV_SATA: -+ case SYS_DEV_SATA_VMD: -+ status = get_ata_encryption_information(disk_fd, &information, verbose); -+ break; -+ default: -+ encryption_checked = false; -+ } -+ -+ if (status) { -+ fd2devname(disk_fd, devname); -+ pr_vrb("Failed to read encryption information of device %s\n", devname); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ if (encryption_checked) { -+ if (information.status == ENC_STATUS_LOCKED) { -+ fd2devname(disk_fd, devname); -+ pr_vrb("Device %s is in Locked state, cannot use. Aborting.\n", devname); -+ return MDADM_STATUS_ERROR; -+ } -+ encryption_state = (char *)get_encryption_status_string(information.status); -+ } -+ -+check_policy: -+ if (expected_policy) { -+ if (strcmp(expected_policy->value, encryption_state) == 0) -+ return MDADM_STATUS_SUCCESS; -+ -+ fd2devname(disk_fd, devname); -+ pr_vrb("Encryption status \"%s\" detected for disk %s, but \"%s\" status was detected eariler.\n", -+ encryption_state, devname, expected_policy->value); -+ pr_vrb("Disks with different encryption status cannot be used.\n"); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ pol_add(pols, (char *)type, encryption_state, "imsm"); -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ - struct imsm_drive_policy { - char *type; - mdadm_status_t (*test_and_add_drive_policy)(const char * const type, -@@ -11300,6 +11372,7 @@ struct imsm_drive_policy { - - struct imsm_drive_policy imsm_policies[] = { - {"controller", test_and_add_drive_controller_policy_imsm}, -+ {"encryption", test_and_add_drive_encryption_policy_imsm} - }; - - mdadm_status_t test_and_add_drive_policies_imsm(struct dev_policy **pols, int disk_fd, --- -2.41.0 - diff --git a/0048-mdadm-add-CHANGELOG.md.patch b/0048-mdadm-add-CHANGELOG.md.patch deleted file mode 100644 index 4923820..0000000 --- a/0048-mdadm-add-CHANGELOG.md.patch +++ /dev/null @@ -1,2010 +0,0 @@ -From 275e5d2fe316202cce5cb1319a83c3cd8fb22dd3 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 26 Mar 2024 13:21:10 +0100 -Subject: [PATCH 48/66] mdadm: add CHANGELOG.md - -Bring changelog back to life. Remove ANNOUCEs. It will use markdown -format, to have one style. All releases are migrated to new -changelog. It was a exercise I have taken, to familiarize with the -mdadm history. - -Signed-off-by: Mariusz Tkaczyk ---- - ANNOUNCE-3.0 | 98 ------------- - ANNOUNCE-3.0.1 | 22 --- - ANNOUNCE-3.0.2 | 21 --- - ANNOUNCE-3.0.3 | 29 ---- - ANNOUNCE-3.1 | 33 ----- - ANNOUNCE-3.1.1 | 39 ------ - ANNOUNCE-3.1.2 | 46 ------- - ANNOUNCE-3.1.3 | 46 ------- - ANNOUNCE-3.1.4 | 37 ----- - ANNOUNCE-3.1.5 | 42 ------ - ANNOUNCE-3.2 | 77 ----------- - ANNOUNCE-3.2.1 | 75 ---------- - ANNOUNCE-3.2.2 | 36 ----- - ANNOUNCE-3.2.3 | 24 ---- - ANNOUNCE-3.2.4 | 144 ------------------- - ANNOUNCE-3.2.5 | 31 ----- - ANNOUNCE-3.2.6 | 57 -------- - ANNOUNCE-3.3 | 63 --------- - ANNOUNCE-3.3.1 | 23 ---- - ANNOUNCE-3.3.2 | 16 --- - ANNOUNCE-3.3.3 | 18 --- - ANNOUNCE-3.3.4 | 37 ----- - ANNOUNCE-3.4 | 24 ---- - ANNOUNCE-4.0 | 22 --- - ANNOUNCE-4.1 | 16 --- - ANNOUNCE-4.2 | 19 --- - CHANGELOG.md | 368 +++++++++++++++++++++++++++++++++++++++++++++++++ - ChangeLog | 306 ---------------------------------------- - 28 files changed, 368 insertions(+), 1401 deletions(-) - delete mode 100644 ANNOUNCE-3.0 - delete mode 100644 ANNOUNCE-3.0.1 - delete mode 100644 ANNOUNCE-3.0.2 - delete mode 100644 ANNOUNCE-3.0.3 - delete mode 100644 ANNOUNCE-3.1 - delete mode 100644 ANNOUNCE-3.1.1 - delete mode 100644 ANNOUNCE-3.1.2 - delete mode 100644 ANNOUNCE-3.1.3 - delete mode 100644 ANNOUNCE-3.1.4 - delete mode 100644 ANNOUNCE-3.1.5 - delete mode 100644 ANNOUNCE-3.2 - delete mode 100644 ANNOUNCE-3.2.1 - delete mode 100644 ANNOUNCE-3.2.2 - delete mode 100644 ANNOUNCE-3.2.3 - delete mode 100644 ANNOUNCE-3.2.4 - delete mode 100644 ANNOUNCE-3.2.5 - delete mode 100644 ANNOUNCE-3.2.6 - delete mode 100644 ANNOUNCE-3.3 - delete mode 100644 ANNOUNCE-3.3.1 - delete mode 100644 ANNOUNCE-3.3.2 - delete mode 100644 ANNOUNCE-3.3.3 - delete mode 100644 ANNOUNCE-3.3.4 - delete mode 100644 ANNOUNCE-3.4 - delete mode 100644 ANNOUNCE-4.0 - delete mode 100644 ANNOUNCE-4.1 - delete mode 100644 ANNOUNCE-4.2 - create mode 100644 CHANGELOG.md - delete mode 100644 ChangeLog - -diff --git a/ANNOUNCE-3.0 b/ANNOUNCE-3.0 -deleted file mode 100644 -index f2d4f847..00000000 ---- a/ANNOUNCE-3.0 -+++ /dev/null -@@ -1,98 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.0 - A tool for managing Soft RAID under Linux -- --I am pleased to (finally) announce the availability of -- mdadm version 3.0 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- -- --This is a major new version and as such should be treated with some --caution. However it has seen substantial testing and is considerred --to be ready for wide use. -- -- --The significant change which justifies the new major version number is --that mdadm can now handle metadata updates entirely in userspace. --This allows mdadm to support metadata formats that the kernel knows --nothing about. -- --Currently two such metadata formats are supported: -- - DDF - The SNIA standard format -- - Intel Matrix - The metadata used by recent Intel ICH controlers. -- --Also the approach to device names has changed significantly. -- --If udev is installed on the system, mdadm will not create any devices --in /dev. Rather it allows udev to manage those devices. For this to work --as expected, the included udev rules file should be installed. -- --If udev is not installed, mdadm will still create devices and symlinks --as required, and will also remove them when the array is stopped. -- --mdadm now requires all devices which do not have a standard name (mdX --or md_dX) to live in the directory /dev/md/. Names in this directory --will always be created as symlinks back to the standard name in /dev. -- --The man pages contain some information about the new externally managed --metadata. However see below for a more condensed overview. -- --Externally managed metadata introduces the concept of a 'container'. --A container is a collection of (normally) physical devices which have --a common set of metadata. A container is assembled as an md array, but --is left 'inactive'. -- --A container can contain one or more data arrays. These are composed from --slices (partitions?) of various devices in the container. -- --For example, a 5 devices DDF set can container a RAID1 using the first --half of two devices, a RAID0 using the first half of the remain 3 devices, --and a RAID5 over thte second half of all 5 devices. -- --A container can be created with -- -- mdadm --create /dev/md0 -e ddf -n5 /dev/sd[abcde] -- --or "-e imsm" to use the Intel Matrix Storage Manager. -- --An array can be created within a container either by giving the --container name and the only member: -- -- mdadm -C /dev/md1 --level raid1 -n 2 /dev/md0 -- --or by listing the component devices -- -- mdadm -C /dev/md2 --level raid0 -n 3 /dev/sd[cde] -- --To assemble a container, it is easiest just to pass each device in turn to --mdadm -I -- -- for i in /dev/sd[abcde] -- do mdadm -I $i -- done -- --This will assemble the container and the components. -- --Alternately the container can be assembled explicitly -- -- mdadm -A /dev/md0 /dev/sd[abcde] -- --Then the components can all be assembled with -- -- mdadm -I /dev/md0 -- --For each container, mdadm will start a program called "mdmon" which will --monitor the array and effect any metadata updates needed. The array is --initially assembled readonly. It is up to "mdmon" to mark the metadata --as 'dirty' and which the array to 'read-write'. -- --The version 0.90 and 1.x metadata formats supported by previous --versions for mdadm are still supported and the kernel still performs --the same updates it use to. The new 'mdmon' approach is only used for --newly introduced metadata types. -- --NeilBrown 2nd June 2009 -diff --git a/ANNOUNCE-3.0.1 b/ANNOUNCE-3.0.1 -deleted file mode 100644 -index 91b44284..00000000 ---- a/ANNOUNCE-3.0.1 -+++ /dev/null -@@ -1,22 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.0.1 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.0.1 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- -- --This contains only minor bug fixes over 3.0. If you are using --3.0, you could consider upgrading. -- --The brief change log is: -- - Fix various segfaults -- - Fixed for --examine with containers -- - Lots of other little fixes. -- --NeilBrown 25th September 2009 -diff --git a/ANNOUNCE-3.0.2 b/ANNOUNCE-3.0.2 -deleted file mode 100644 -index 93643d17..00000000 ---- a/ANNOUNCE-3.0.2 -+++ /dev/null -@@ -1,21 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.0.2 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.0.2 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- -- --This just contains one bugfix over 3.0.1 - I was obviously a bit hasty --in releasing that one. -- --The brief change log is: -- - Fix crash when hosthost is not set, as often happens in -- early boot. -- --NeilBrown 25th September 2009 -diff --git a/ANNOUNCE-3.0.3 b/ANNOUNCE-3.0.3 -deleted file mode 100644 -index d6117a1d..00000000 ---- a/ANNOUNCE-3.0.3 -+++ /dev/null -@@ -1,29 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.0.3 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.0.3 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- -- --This contains a collection of bug fixes and minor enhancements over --3.0.1. -- --The brief change log is: -- - Improvements for creating arrays giving just a name, like 'foo', -- rather than the full '/dev/md/foo'. -- - Improvements for assembling member arrays of containers. -- - Improvements to test suite -- - Add option to change increment for RebuildNN messages reported -- by "mdadm --monitor" -- - Improvements to mdmon 'hand-over' from initrd to final root. -- - Handle merging of devices that have left an IMSM array and are -- being re-incorporated. -- - Add missing space in "--detail --brief" output. -- --NeilBrown 22nd October 2009 -diff --git a/ANNOUNCE-3.1 b/ANNOUNCE-3.1 -deleted file mode 100644 -index 343b85da..00000000 ---- a/ANNOUNCE-3.1 -+++ /dev/null -@@ -1,33 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.1 - A tool for managing Soft RAID under Linux -- --Hot on the heals of 3.0.3 I am pleased to announce the availability of -- mdadm version 3.1 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- -- --It contains significant feature enhancements over 3.0.x -- --The brief change log is: -- - Support --grow to change the layout of RAID4/5/6 -- - Support --grow to change the chunksize of raid 4/5/6 -- - Support --grow to change level from RAID1 -> RAID5 -> RAID6 and -- back. -- - Support --grow to reduce the number of devices in RAID4/5/6. -- - Support restart of these grow options which assembling an array -- which is partially grown. -- - Assorted tests of this code, and of different RAID6 layouts. -- --Note that a 2.6.31 or later is needed to have access to these. --Reducing devices in a RAID4/5/6 requires 2.6.32. --Changing RAID5 to RAID1 requires 2.6.33. -- --You should only upgrade if you need to use, or which to test, these --features. -- --NeilBrown 22nd October 2009 -diff --git a/ANNOUNCE-3.1.1 b/ANNOUNCE-3.1.1 -deleted file mode 100644 -index 9e480dc0..00000000 ---- a/ANNOUNCE-3.1.1 -+++ /dev/null -@@ -1,39 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.1.1 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.1.1 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- --This is a bugfix release over 3.1, which was withdrawn due to serious --bugs. So it might be best to ignore 3.1 and say that this is a significant --feature release over 3.0.x -- --Significant changes are: -- - RAID level conversion between RAID1, RAID5, and RAID6 are -- possible were the kernel supports it (2.6.32 at least) -- - online chunksize and layout changing for RAID5 and RAID6 -- where the kernel supports it. -- - reduce the number of devices in a RAID4/5/6 array. -- -- - The default metadata is not v1.1. This metadata is stored at the -- start of the device so is safer in many ways but could interfere with -- boot loaded. The old default (0.90) is still available and fully -- supported. -- -- - The default chunksize is now 512K rather than 64K. This seems more -- appropriate for modern devices. -- -- - The default bitmap chunksize for internal bitmaps is now at least -- 64Meg as fine grained bitmaps tend to impact performance more for -- little extra gain. -- --This release is believed to be stable and you should feel free to --upgrade to 3.1.1. -- --NeilBrown 19th November 2009 -diff --git a/ANNOUNCE-3.1.2 b/ANNOUNCE-3.1.2 -deleted file mode 100644 -index 321b8bef..00000000 ---- a/ANNOUNCE-3.1.2 -+++ /dev/null -@@ -1,46 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.1.2 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.1.2 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- --This is a bugfix/stability release over 3.1.1. -- --Significant changes are: -- - The default metadata has change again (sorry about that). -- It is now v1.2 and will hopefully stay that way. It turned -- out there with boot-block issues with v1.1 which make it -- unsuitable for a default, though in many cases it is still -- suitable to use. -- - Stopping a container is not permitted when members are still -- active -- - Add 'homehost' to the valid words for the "AUTO" config file -- line. When followed by "-all", this causes mdadm to -- auto-assemble any array belonging to this host, but not -- auto-assemble anything else. -- - Fix some bugs with "--grow --chunksize=" for changing chunksize. -- - VAR_RUN can be easily changed at compile time just like ALT_RUN. -- This gives distros more flexability in how to manage the -- pid and sock files that mdmon needs. -- - Various mdmon fixes -- - Alway make bitmap 4K-aligned if at all possible. -- - If mdadm.conf lists arrays which have inter-dependencies, -- the previously had to be listed in the "right" order. Now -- any order should work. -- - Fix --force assembly of v1.x arrays which are in the process -- of recovering. -- - Add section on 'scrubbing' to 'md' man page. -- - Various command-line-option parsing improvements. -- - ... and lots of other bug fixes. -- -- --This release is believed to be stable and you should feel free to --upgrade to 3.1.2 -- --NeilBrown 10th March 2010 -diff --git a/ANNOUNCE-3.1.3 b/ANNOUNCE-3.1.3 -deleted file mode 100644 -index 95b2b6c1..00000000 ---- a/ANNOUNCE-3.1.3 -+++ /dev/null -@@ -1,46 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.1.3 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.1.3 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- --This is a bugfix/stability release over 3.1.2 -- --Significant changes are: -- - mapfile now lives in a fixed location which default to -- /dev/.mdadm/map but can be changed at compile time. This -- location is choses and most distros provide it during early -- boot and preserve it through. As long a /dev exists and is -- writable, /dev/.mdadm will be created. -- Other files file communication with mdmon live here too. -- This fixes a bug reported by Debian and Gentoo users where -- udev would spin in early-boot. -- - IMSM and DDF metadata will not be recognised on partitions -- as they should only be used on whole-disks. -- - Various overflows causes by 2G drives have been addressed. -- - A subarray of an IMSM contain can now be killed with -- --kill-subarray. Also subarrays can be renamed with -- --update-subarray -- - -If (or --incremental --fail) can be used from udev to -- fail and remove from all arrays a device which has been -- unplugged from the system. i.e. hot-unplug-support. -- - "mdadm /dev/mdX --re-add missing" will look for any device -- that looks like it should be a member of /dev/mdX but isn't -- and will automatically --re-add it -- - Now compile with -Wextra to get extra warnings. -- - Lots of minor bug fixes, documentation improvements, etcc -- --This release is believed to be stable and you should feel free to --upgrade to 3.1.3 -- --It is expected that the next release will be 3.2 with a number of new --features. 3.1.4 will only happen if important bugs show up before 3.2 --is stable. -- --NeilBrown 6th August 2010 -diff --git a/ANNOUNCE-3.1.4 b/ANNOUNCE-3.1.4 -deleted file mode 100644 -index c157a36a..00000000 ---- a/ANNOUNCE-3.1.4 -+++ /dev/null -@@ -1,37 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.1.4 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.1.4 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- --This is a bugfix/stability release over 3.1.3. --3.1.3 had a couple of embarrasing regressions and a couple of other --issues surfaces which had easy fixes so I decided to make a 3.1.4 --release after all. -- --Two fixes related to configs that aren't using udev: -- - Don't remove md devices which 'standard' names on --stop -- - Allow dev_open to work on read-only /dev --And fixed regressions: -- - Allow --incremental to add spares to an array -- - Accept --no-degraded as a deprecated option rather than -- throwing an error -- - Return correct success status when --incrmental assembling -- a container which does not yet have enough devices. -- - Don't link mdadm with pthreads, only mdmon needs it. -- - Fix compiler warning due to bad use of snprintf -- - Fix spare migration -- --This release is believed to be stable and you should feel free to --upgrade to 3.1.4 -- --It is expected that the next release will be 3.2 with a number of new --features. -- --NeilBrown 31st August 2010 -diff --git a/ANNOUNCE-3.1.5 b/ANNOUNCE-3.1.5 -deleted file mode 100644 -index baa1f921..00000000 ---- a/ANNOUNCE-3.1.5 -+++ /dev/null -@@ -1,42 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.1.5 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.1.5 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git?p=mdadm -- --This is a bugfix/stability release over 3.1.4. It contains all the --important bugfixes found while working on 3.2 and 3.2.1. It will be --the last 3.1.x release - 3.2.1 is expected to be released in a few days. -- --Changes include: -- - Fixes for v1.x metadata on big-endian machines. -- - man page improvements -- - Improve '--detail --export' when run on partitions of an md array. -- - Fix regression with removing 'failed' or 'detached' devices. -- - Fixes for "--assemble --force" in various unusual cases. -- - Allow '-Y' to mean --export. This was documented but not implemented. -- - Various fixed for handling 'ddf' metadata. This is now more reliable -- but could benefit from more interoperability testing. -- - Correctly list subarrays of a container in "--detail" output. -- - Improve checks on whether the requested number of devices is supported -- by the metadata - both for --create and --grow. -- - Don't remove partitions from a device that is being included in an -- array until we are fully committed to including it. -- - Allow "--assemble --update=no-bitmap" so an array with a corrupt -- bitmap can still be assembled. -- - Don't allow --add to succeed if it looks like a "--re-add" is probably -- wanted, but cannot succeed. This avoids inadvertently turning -- devices into spares when an array is failed. -- --This release is believed to be stable and you should feel free to --upgrade to 3.1.5 -- -- --NeilBrown 23rd March 2011 -- -diff --git a/ANNOUNCE-3.2 b/ANNOUNCE-3.2 -deleted file mode 100644 -index 9e282bc6..00000000 ---- a/ANNOUNCE-3.2 -+++ /dev/null -@@ -1,77 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.2 - A tool for managing Soft RAID under Linux (DEVEL ONLY) -- --I am pleased to announce the availability of -- mdadm version 3.2 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm devel-3.2 -- http://neil.brown.name/git?p=mdadm -- --This is a "Developers only" release. Please don't consider using it --or making it available to others without reading the following. -- -- --By far the most significant change in this release related to the --management of reshaping arrays. This code has been substantially --re-written so that it can work with 'externally managed metadata' - --Intel's IMSM in particular. We now support level migration and --OnLine Capacity Expansion on these arrays. -- --However, while the code largely works it has not been tested --exhaustively so there are likely to be problems. As the reshape code --for native metadata arrays was changed as part of this rewrite these --problems could also result in regressions for reshape of native --metadata. -- --It is partly to encourage greater testing that this release is being --made. Any reports of problem - particular reproducible recipes for --triggering the problems - will be gratefully received. -- --It is hopped that a "3.2.1" release will be available in early March --which will be a bugfix release over this and can be considered --suitable for general use. -- --Other changes of note: -- -- - Policy framework. -- Various policy statements can be made in the mdadm.conf to guide -- the behaviour of mdadm, particular with regards to how new devices -- are treated by "mdadm -I". -- Depending on the 'action' associated with a device (identified by -- its 'path') such need devices can be automatically re-added to and -- existing array that they previously fell out off, or automatically -- added as a spare if they appear to contain no data. -- -- - mdadm now has a limited understanding of partition tables. This -- allows the policy framework to make decisions about partitioned -- devices as well. -- -- - --incremental --remove can be told what --path the device was on, -- and this info will be recorded so that another device appearing at -- the same physical location can be preferentially added to the same -- array (provides the spare-same-slot action policy applied to the -- path). -- -- - A new flags "--invalid-backup" flag is available in --assemble -- mode. This can be used to re-assemble an array which was stopping -- in the middle of a reshape, and for which the 'backup file' is no -- longer available or is corrupted. The array may have some -- corruption in it at the point where reshape was up to, but at least -- the rest of the array will become available. -- -- -- - Various internal restructuring - more is needed. -- -- --Any feed back and bug reports are always welcomed at: -- linux-raid@vger.kernel.org -- --And please: don't use this in production - particularly not the ----grow functionality. -- --NeilBrown 1st February 2011 -- -- -diff --git a/ANNOUNCE-3.2.1 b/ANNOUNCE-3.2.1 -deleted file mode 100644 -index 0e7826ca..00000000 ---- a/ANNOUNCE-3.2.1 -+++ /dev/null -@@ -1,75 +0,0 @@ -- -- --I am pleased to announce the availability of -- mdadm version 3.2.1 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git/mdadm -- --Many of the changes in this release are of internal interest only, --restructuring and refactoring code and so forth. -- --Most of the bugs found and fixed during development for 3.2.1 have been --back-ported for the recently-release 3.1.5 so this release primarily --provides a few new features over 3.1.5. -- --They include: -- - policy framework -- Policy can be expressed for moving spare devices between arrays, and -- for how to handle hot-plugged devices. This policy can be different -- for devices plugged in to different controllers etc. -- This, for example, allows a configuration where when a device is plugged -- in it is immediately included in an md array as a hot spare and -- possibly starts recovery immediately if an array is degraded. -- -- - some understanding of mbr and gpt paritition tables -- This is primarly to support the new hot-plug support. If a -- device is plugged in and policy suggests it should have a partition table, -- the partition table will be copied from a suitably similar device, and -- then the partitions will hot-plug and can then be added to md arrays. -- -- - "--incremental --remove" can remember where a device was removed from -- so if a device gets plugged back in the same place, special policy applies -- to it, allowing it to be included in an array even if a general hotplug -- will not be included. -- -- - enhanced reshape options, including growing a RAID0 by converting to RAID4, -- restriping, and converting back. Also convertions between RAID0 and -- RAID10 and between RAID1 and RAID10 are possible (with a suitably recent -- kernel). -- -- - spare migration for IMSM arrays. -- Spare migration can now work across 'containers' using non-native metadata -- and specifically Intel's IMSM arrays support spare migrations. -- -- - OLCE and level migration for Intel IMSM arrays. -- OnLine Capacity Expansion and level migration (e.g. RAID0 -> RAID5) is -- supported for Intel Matrix Storage Manager arrays. -- This support is currently 'experimental' for technical reasons. It can -- be enabled with "export MDADM_EXPERIMENTAL=1" -- -- - avoid including wayward devices -- If you split a RAID1, mount the two halves as two separate degraded RAID1s, -- and then later bring the two back together, it is possible that the md -- metadata won't properly show that one must over-ride the other. -- mdadm now does extra checking to detect this possibilty and avoid -- potentially corrupting data. -- -- - remove any possible confusion between similar options. -- e.g. --brief and --bitmap were mapped to 'b' and mdadm wouldn't -- notice if one was used where the other was expected. -- -- - allow K,M,G suffixes on chunk sizes -- -- --While mdadm-3.2.1 is considered to be reasonably stable, you should --only use it if you want to try out the new features, or if you --generally like to be on the bleeding edge. If the new features are not --important to you, then 3.1.5 is probably the appropriate version to be using --until 3.2.2 comes out. -- --NeilBrown 28th March 2011 -diff --git a/ANNOUNCE-3.2.2 b/ANNOUNCE-3.2.2 -deleted file mode 100644 -index b70d18b9..00000000 ---- a/ANNOUNCE-3.2.2 -+++ /dev/null -@@ -1,36 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.2.2 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.2.2 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git/mdadm -- --This release is largely a stablising release for the 3.2 series. --Many of the changes just fix bugs introduces in 3.2 or 3.2.1. -- --There are some new features. They are: -- - reshaping IMSM (Intel metadata) arrays is no longer 'experimental', -- it should work properly and be largely compatible with IMSM drivers in -- other platforms. -- - --assume-clean can be used with --grow --size to avoid resyncing the -- new part of the array. This is only support with very new kernels. -- - RAID0 arrays can have chunksize which is not a power of 2. This has been -- supported in the kernel for a while but is only now supprted by -- mdadm. -- -- - A new tool 'raid6check' is available which can check a RAID6 array, -- or part of it, and report which device is most inconsistent with the -- others if any stripe is inconsistent. This is still under development -- and does not have a man page yet. If anyone tries it out and has any -- questions or experience to report, they would be most welcome on -- linux-raid@vger.kernel.org. -- --Future releases in the 3.2 series will only be made if bugfixes are needed. --The next release to add features is expected to be 3.3. -- --NeilBrown 17th June 2011 -diff --git a/ANNOUNCE-3.2.3 b/ANNOUNCE-3.2.3 -deleted file mode 100644 -index 8a8dba46..00000000 ---- a/ANNOUNCE-3.2.3 -+++ /dev/null -@@ -1,24 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.2.3 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.2.3 -- --It is available at the usual places: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://neil.brown.name/mdadm -- http://neil.brown.name/git/mdadm -- --This release is largely a bugfix release for the 3.2 series with many --minor fixes with little or no impact. -- --The largest single area of change is support for reshape of Intel --IMSM arrays (OnLine Capacity Explansion and Level Migtration). --Among other fixes, this now has a better chance of surviving if a --device fails during reshape. -- --Upgrading is recommended - particularly if you use mdadm for IMSM --arrays - but not essential. -- --NeilBrown 23rd December 2011 -diff --git a/ANNOUNCE-3.2.4 b/ANNOUNCE-3.2.4 -deleted file mode 100644 -index e3216786..00000000 ---- a/ANNOUNCE-3.2.4 -+++ /dev/null -@@ -1,144 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.2.4 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.2.4 -- --It is available at the usual places, now including github: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://neil.brown.name/git/mdadm -- --This release is largely a bugfix release for the 3.2 series with many --minor fixes with little or no impact. -- --"--oneline" log of changes is below. Some notable ones are: -- -- - --offroot argument to improve interactions between mdmon and initrd -- - --prefer argument to select which /dev names to display in some -- circumstances. -- - relax restructions on when "--add" will be allowed -- - Fix bug with adding write-intent-bitmap to active array -- - Now defaults to "/run/mdadm" for storing run-time files. -- --Upgrading is encouraged. -- --The next mdadm release is expected to be 3.3 with a number of new --features. -- --NeilBrown 9th May 2012 -- --77b3ac8 monitor: make return from read_and_act more symbolic. --68226a8 monitor: ensure we retry soon when 'remove' fails. --8453f8d fix: Monitor sometimes crashes --90fa1a2 Work around gcc-4.7's strict aliasing checks --0c4304c fix: container creation with --incremental used. --5d1c7cd FIX: External metadata sometimes is not updated --3c20f98 FIX: mdmon check in reshape_container() can cause a problem --59ab9f5 FIX: Typo error in fprint command --9587c37 imsm: load_super_imsm_all function refactoring --ec50f7b imsm: load_imsm_super_all supports loading metadata from the device list --ca9de18 imsm: validate the number of imsm volumes per controller --30602f5 imsm: display fd in error trace when when store_imsm_mpb failes --eb155f6 mdmon: Use getopt_long() to parse command line options --08ca2ad Add --offroot argument to mdadm --da82751 Add --offroot argument to mdmon --a0963a8 Spawn mdmon with --offroot if mdadm was launched with --offroot --f878b24 imsm: fix, the second array need to have the whole available space on devices --d597705 getinfo_super1: Use MaxSector in place of sb->size --6ef8905 super1: make aread/awrite always use an aligned buffer. --de5a472 Remove avail_disks arg from 'enough'. --da8fe5a Assemble: fix --force assemble during reshape. --b10c663 config: fix handing of 'homehost' in AUTO line. --92d49ec FIX: NULL pointer to strdup() can be passed --d2bde6d imsm: FIX: No new missing disks are allowed during general migration --111e9fd FIX: Array is not run when expansion disks are added --bf5cf7c imsm: FIX: imsm_get_allowed_degradation() doesn't count degradation for raid1 --50927b1 Fix: Sometimes mdmon throws core dump during reshape --78340e2 Flush mdmon before next reshape step during container operation --e174219 imsm: FIX: Chunk size migration problem --f93346e FIX: use md position to reshape restart --6a75c8c imsm: FIX: use md position to reshape restart --51d83f5 imsm: FIX: Clear migration record when migration switches to next volume. --e1dd332 FIX: restart reshape when reshape process is stopped just between 2 reshapes --1ca90aa FIX: Do not try to (continue) reshape using inactive array --9f1b0f0 config: conf_match should ignore devname when not set. --d669228 Use posix_memalign() for memory used to write bitmaps --178950e FIX: Changes in '0' case for reshape position verification --9200d41 avoid double-free upon "old buggy kernel" sysfs_read failure --4011421 Print error message if failing to write super for 1.x metadata --0011874 Use MDMON_DIR for pid files created in Monitor.c --56d1885 Assemble: don't use O_EXCL until we have checked device content. --b720636 Assemble: support assembling of a RAID0 being reshaped. --c69ffac Manage: allow --re-add to failed array. --52f07f5 Reset bad flag on map update --911cead super1: support superblocks up to 4K. --ad6db3c Create: reduce the verbosity of 'default_layout'. --b2bfdfa super1.c don't keep recalculating bitmap pointer --4122675 Define and use SUPER1_SIZE for allocations --1afa930 init_super1() memset full buffer allocated for superblock --2de0b8a match_metadata_desc1(): Use calloc instead of malloc+memset --3c0bcd4 Use 4K buffer alignment for superblock allocations --308340a Use struct align_fd to cache fd's block size for aligned reads/writes --65ed615 match_metadata_desc0(): Use calloc instead of malloc+memset --de89706 Generalize ROUND_UP() macro and introduce matching ROUND_UP_PTR() --0a2f189 super1.c: use ROUND_UP/ROUND_UP_PTR --654a381 super-intel.c: Use ROUND_UP() instead of manually coding it --42d5dfd __write_init_super_ddf(): Use posix_memalign() instead of static aligned buffer --d4633e0 Examine: fix array size calculation for RAID10. --e62b778 Assemble: improve verbose logging when including old devices. --0073a6e Remove possible crash during RAID6 -> RAID5 reshape. --69fe207 Incremental: fix adding devices with --incremental --bcbb311 Manage: replace 'return 1' with 'goto abort'. --9f58469 Manage: freeze recovery while adding multiple devices. --ae6c05a Create: round off size for RAID1 arrays. --5ca3a90 Grow: print useful error when converting RAID1->RAID5 will fail. --c07d640 Fix tests/05r1-re-add-nosupper --2d762ad Fix the new ROUND_UP macro. --fd324b0 sysfs: fixed sysfs_freeze_array array to work properly with Manage_subdevs. --5551b11 imsm: avoid overflows for disks over 1TB --97f81ee clear hi bits if not used after loading metadata from disk --e03640b simplify calculating array_blocks --29cd082 show 2TB volumes/disks support in --detail-platform --2cc699a check volume size in validate_geometry_imsm_orom --9126b9a check that no disk over 2TB is used to create container when no support --027c374 imsm: set 2tb disk attribute for spare --3556c2f Fix typo: wan -> want --15632a9 parse_size: distinguish between 0 and error. --fbdef49 Bitmap_offset is a signed number --508a7f1 super1: leave more space in front of data by default. --40110b9 Fix two typos in fprintf messages --342460c mdadm man page: fix typo --0e7f69a imsm: display maximum volumes per controller and array --36fd8cc imsm: FIX: Update function imsm_num_data_members() for Raid1/10 --7abc987 imsm: FIX: Add volume size expand support to imsm_analyze_change() --f3871fd imsm: Add new metadata update for volume size expansion --54397ed imsm: Execute size change for external metatdata --016e00f FIX: Support metadata changes rollback --fbf3d20 imsm: FIX: Support metadata changes rollback --44f6f18 FIX: Extend size of raid0 array --7e7e9a4 FIX: Respect metadata size limitations --65a9798 FIX: Detect error and rollback metadata --13bcac9 imsm: Add function imsm_get_free_size() --b130333 imsm: Support setting max size for size change operation --c41e00b imsm: FIX: Component size alignment check --58d26a2 FIX: Size change is possible as standalone change only --4aecb54 FIX: Assembled second array is in read only state during reshape --ae2416e FIX: resolve make everything compilation error --480f356 Raid limit of 1024 when scanning for devices. --c2ecf5f Add --prefer option for --detail and --monitor --0a99975 Relax restrictions on when --add is permitted. --7ce0570 imsm: fix: rebuild does not continue after reboot --b51702b fix: correct extending size of raid0 array --34a1395 Fix sign extension of bitmap_offset in super1.c --012a864 Introduce sysfs_set_num_signed() and use it to set bitmap/offset --5d7b407 imsm: fix: thunderdome may drop 2tb attribute --5ffdc2d Update test for "is udev active". --96fd06e Adjust to new standard of /run --974e039 test: don't worry too much about array size. --b0a658f Grow: failing the set the per-device size is not an error. --36614e9 super-intel.c: Don't try to close negative fd --562aa10 super-intel.c: Fix resource leak from opendir() -- -diff --git a/ANNOUNCE-3.2.5 b/ANNOUNCE-3.2.5 -deleted file mode 100644 -index 396da12a..00000000 ---- a/ANNOUNCE-3.2.5 -+++ /dev/null -@@ -1,31 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.2.5 - A tool for managing Soft RAID under Linux -- --I am somewhat disappointed to have to announce the availability of -- mdadm version 3.2.5 -- --It is available at the usual places, now including github: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://neil.brown.name/git/mdadm -- --This release primarily fixes a serious regression in 3.2.4. --This regression does *not* cause any risk to data. It simply --means that adding a device with "--add" would sometime fail --when it should not. -- --The fix also includes a couple of minor fixes such as making --the "--layout=preserve" option to "--grow" work again. -- --A reminder that the default location for runtime files is now --"/run/mdadm". If you compile this for a distro that does not --have "/run", you will need to compile with an alternate setting for --MAP_DIR. e.g. -- make MAP_DIR=/var/run/mdadm --or -- make MAP_DIR=/dev/.mdadm -- --NeilBrown 18th May 2012 -- -diff --git a/ANNOUNCE-3.2.6 b/ANNOUNCE-3.2.6 -deleted file mode 100644 -index f5cfd492..00000000 ---- a/ANNOUNCE-3.2.6 -+++ /dev/null -@@ -1,57 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.2.6 - A tool for managing Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.2.6 -- --It is available at the usual places, now including github: -- countrycode=xx. -- http://www.${countrycode}kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://neil.brown.name/git/mdadm -- --This is a stablity release which adds a number of bugfixs to 3.2.5. --There are no real stand-out fixes, just lots of little bits and pieces. -- --Below is the "git log --oneline --reverse" list of changes since --3.2.5. -- --NeilBrown 25th October 2012 -- --b7e05d2 udev-rules: prevent systemd from mount devices before they are ready. --0d478e2 mdadm: Fix Segmentation fault. --42f0ca1 imsm: fix: correct checking volume's degradation --fcf2195 Monitor: fix inconsistencies in values for ->percent --5f862fb Monitor: Report NewArray when an array the disappeared, reappears. --6f51b1c Monitor: fix reporting for Fail vs FailSpare etc. --68ad53b mdmon: fix arg parsing. --517f135 Assemble: don't leak memory with fdlist. --090900c udev-rules: prevent systemd from mount devices before they are ready. --446e000 sha1.h: remove ansidecl.h header inclusion --ec894f5 Manage: zero metadata before adding to 'external' array. --3a84db5 ddf: allow a non-spare to be used to recovery a missing device. --c5d61ca ddf: hack to fix container recognition. --23084aa mdmon: fix arg processing for -a --c4e96a3 mdmon: allow --takeover when original was started with --offroot --80841df find_free_devnum: avoid auto-using names in /etc/mdadm.conf --c5c56d6 mapfile: fix mapfile rebuild for containers --aec89f6 fix segfaults in Detail() --2117ad1 Fix 'enough' function for RAID10. --0bc300d Use --offroot flag when assembling md arrays via --incrmental --ac78f24 Grow: make warning about old metadata more explicit. --14026ab Replace sha1.h with slightly older version. --6f6809f Add zlib license to crc32.c --5267ba0 Handles spaces in array names better. --c51f288 imsm: allow --assume-clean to work. --acf7076 Grow: allow --grow --continue to work for native metadata. --335d2a6 Grow: fix a couple of typos with --assume-clean usage --9ff1427 Fix open_container --3713633 mdadm: super0: do not override uuid with homehost --31bff58 Trivial bugfix and spelling fixes. --e1e539f Detail: don't report a faulty device as 'spare' or 'rebuilding'. --22a6461 super0: allow creation of array on 2TB+ devices. --a5d47a2 Create new md devices consistently --eb48676 Monitor: don't complain about non-monitorable arrays in mdadm.conf --ecdf2d7 Query: don't be confused by partition tables. --f7b75c1 Query: allow member of non-0.90 arrays to be better reported. -diff --git a/ANNOUNCE-3.3 b/ANNOUNCE-3.3 -deleted file mode 100644 -index f770aa13..00000000 ---- a/ANNOUNCE-3.3 -+++ /dev/null -@@ -1,63 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.3 - A tools for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.3 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://git.neil.brown.name/git/mdadm -- --This is a major new release so don't be too surprised if there are a --few issues. If I hear about them they will be fixed in 3.3.1. --git log reports nearly 500 changes since 3.2.6 so I won't list them --all. -- --Some highlights are: -- --- Some array reshapes can proceed without needing backup file. -- This is done by changing the 'data_offset' so we never need to write -- any data back over where it was before. If there is no "head space" -- or "tail space" to allow data_offset to change, the old mechanism -- with a backup file can still be used. --- RAID10 arrays can be reshaped to change the number of devices, -- change the chunk size, or change the layout between 'near' -- and 'offset'. -- This will always change data_offset, and will fail if there is no -- room for data_offset to be moved. --- "--assemble --update=metadata" can convert a 0.90 array to a 1.0 array. --- bad-block-logs are supported (but not heavily tested yet) --- "--assemble --update=revert-reshape" can be used to undo a reshape -- that has just been started but isn't really wanted. This is very -- new and while it passes basic tests it cannot be guaranteed. --- improved locking between --incremental and --assemble --- uses systemd to run "mdmon" if systemd is configured to do that. --- kernel names of md devices can be non-numeric. e.g. "md_home" rather than -- "md0". This will probably confuse lots of other tools, so you need to -- echo CREATE names=yes >> /etc/mdadm.conf -- or the feature will not be used. (you also need a reasonably new kernel). --- "--stop" can be given a kernel name instead of a device name. i.e -- mdadm --stop md4 -- will work even if /dev/md4 doesn't exist. --- "--detail --export" has some information about the devices in the array --- --dump and --restore can be used to backup and restore the metadata on an -- array. --- Hot-replace is supported with -- mdadm /dev/mdX --replace /dev/foo -- and -- mdadm /dev/mdX --replace /dev/foo --with /dev/bar --- Config file can be a directory in which case all "*.conf" files are -- read in lexical order. -- Default is to read /etc/mdadm.conf and then /etc/mdadm.conf.d -- Thus -- echo CREATE name=yes > /etc/mdadm.conf.d/names.conf -- will also enable the use of named md devices. -- --- Lots of improvements to DDF support including adding support for -- RAID10 (thanks Martin Wilck). -- --and lots of bugfixes and other little changes. -- --NeilBrown 3rd September 2013 -diff --git a/ANNOUNCE-3.3.1 b/ANNOUNCE-3.3.1 -deleted file mode 100644 -index 7d5e666e..00000000 ---- a/ANNOUNCE-3.3.1 -+++ /dev/null -@@ -1,23 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.3.1 - A tool for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.3.1 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://git.neil.brown.name/git/mdadm.git -- --The main changes are: -- - lots of work on "DDF" support. Hopefully it will be more stable -- now. Bug reports are always welcome. -- - improved interactions with 'systemd'. Where possible, background -- tasks are run from systemd (if it is present) rather then forking -- disassociationg from the session. This is important because udev -- doesn't really let you disassociate. -- --though there are a number of other little bug fixes too. -- --NeilBrown 5th June 2014 -diff --git a/ANNOUNCE-3.3.2 b/ANNOUNCE-3.3.2 -deleted file mode 100644 -index 6b549611..00000000 ---- a/ANNOUNCE-3.3.2 -+++ /dev/null -@@ -1,16 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.3.2 - A tool for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.3.2 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://git.neil.brown.name/git/mdadm.git -- --Changes since 3.3.1 are mostly little bugfixes and some man-page --updates. -- --NeilBrown 21st August 2014 -diff --git a/ANNOUNCE-3.3.3 b/ANNOUNCE-3.3.3 -deleted file mode 100644 -index ac1b2173..00000000 ---- a/ANNOUNCE-3.3.3 -+++ /dev/null -@@ -1,18 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.3.3 - A tool for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.3.3 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://git.neil.brown.name/git/mdadm.git -- --The 100 changes since 3.3.3 are mostly little bugfixes and some improvements --to the selftests. --raid6check now handle all RAID6 layouts including DDF correctly. --See git log for the rest. -- --NeilBrown 24th July 2015 -diff --git a/ANNOUNCE-3.3.4 b/ANNOUNCE-3.3.4 -deleted file mode 100644 -index 52b94562..00000000 ---- a/ANNOUNCE-3.3.4 -+++ /dev/null -@@ -1,37 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.3.4 - A tool for managing md Soft RAID under Linux -- --I am somewhat disappointed to have to announce the availability of -- mdadm version 3.3.4 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://git.neil.brown.name/git/mdadm.git -- --In mdadm-3.3 a change was made to how IMSM (Intel Matrix Storage --Manager) metadata was handled. Previously an IMSM array would only --be assembled if it was attached to an IMSM controller. -- --In 3.3 this was relaxed as there are circumstances where the --controller is not properly detected. Unfortunately this has negative --consequences which have only just come to light. -- --If you have an IMSM RAID1 configured and then disable RAID in the --BIOS, the metadata will remain on the devices. If you then install --some other OS on one device and then install Linux on the other, Linux --might eventually start noticing the IMSM metadata (depending a bit on whether --mdadm is included in the initramfs) and might start up the RAID1. This could --copy one device over the other, thus trashing one of the installations. -- --Not good. -- --So with this release IMSM arrays will only be assembled if attached to --an IMSM controller, or if "--force" is given to --assemble, or if the --environment variable IMSM_NO_PLATFORM is set (used primarily for --testing). -- --I strongly recommend upgrading to 3.3.4 if you are using 3.3 or later. -- --NeilBrown 3rd August 2015. -diff --git a/ANNOUNCE-3.4 b/ANNOUNCE-3.4 -deleted file mode 100644 -index 2689732d..00000000 ---- a/ANNOUNCE-3.4 -+++ /dev/null -@@ -1,24 +0,0 @@ --Subject: ANNOUNCE: mdadm 3.4 - A tool for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 3.4 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://github.com/neilbrown/mdadm -- git://neil.brown.name/mdadm -- http://git.neil.brown.name/git/mdadm -- --The new second-level version number reflects significant new --functionality, particular support for journalled RAID5/6 and clustered --RAID1. This new support is probably still buggy. Please report bugs. -- --There are also a number of fixes for Intel's IMSM metadata support, --and an assortment of minor bug fixes. -- --I plan for this to be the last release of mdadm that I provide as I am --retiring from MD and mdadm maintenance. Jes Sorensen has volunteered --to oversee mdadm for the next while. Thanks Jes! -- --NeilBrown 28th January 2016 -diff --git a/ANNOUNCE-4.0 b/ANNOUNCE-4.0 -deleted file mode 100644 -index f79c5408..00000000 ---- a/ANNOUNCE-4.0 -+++ /dev/null -@@ -1,22 +0,0 @@ --Subject: ANNOUNCE: mdadm 4.0 - A tool for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 4.0 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://git.kernel.org/pub/scm/utils/mdadm/mdadm.git -- http://git.kernel.org/cgit/utils/mdadm/ -- --The update in major version number primarily indicates this is a --release by it's new maintainer. In addition it contains a large number --of fixes in particular for IMSM RAID and clustered RAID support. In --addition this release includes support for IMSM 4k sector drives, --failfast and better documentation for journaled RAID. -- --This is my first release of mdadm. Please thank Neil Brown for his --previous work as maintainer and blame me for all the bugs I caused --since taking over. -- --Jes Sorensen, 2017-01-09 -diff --git a/ANNOUNCE-4.1 b/ANNOUNCE-4.1 -deleted file mode 100644 -index a273b9a0..00000000 ---- a/ANNOUNCE-4.1 -+++ /dev/null -@@ -1,16 +0,0 @@ --Subject: ANNOUNCE: mdadm 4.1 - A tool for managing md Soft RAID under Linux -- --I am pleased to announce the availability of -- mdadm version 4.1 -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://git.kernel.org/pub/scm/utils/mdadm/mdadm.git -- http://git.kernel.org/cgit/utils/mdadm/ -- --The update constitutes more than one year of enhancements and bug fixes --including for IMSM RAID, Partial Parity Log, clustered RAID support, --improved testing, and gcc-8 support. -- --Jes Sorensen, 2018-10-01 -diff --git a/ANNOUNCE-4.2 b/ANNOUNCE-4.2 -deleted file mode 100644 -index 8b22d09f..00000000 ---- a/ANNOUNCE-4.2 -+++ /dev/null -@@ -1,19 +0,0 @@ --Subject: ANNOUNCE: mdadm 4.2 - A tool for managing md Soft RAID under Linux -- --I am pleased to finally announce the availability of mdadm-4.2. --get 4.2 out the door soon. -- --It is available at the usual places: -- http://www.kernel.org/pub/linux/utils/raid/mdadm/ --and via git at -- git://git.kernel.org/pub/scm/utils/mdadm/mdadm.git -- http://git.kernel.org/cgit/utils/mdadm/ -- --The release includes more than two years of development and bugfixes, --so it is difficult to remember everything. Highlights include --enhancements and bug fixes including for IMSM RAID, Partial Parity --Log, clustered RAID support, improved testing, and gcc-9 support. -- --Thank you everyone who contributed to this release! -- --Jes Sorensen, 2021-12-30 -diff --git a/CHANGELOG.md b/CHANGELOG.md -new file mode 100644 -index 00000000..c1997ba7 ---- /dev/null -+++ b/CHANGELOG.md -@@ -0,0 +1,368 @@ -+# Release [mdadm-4.3](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-4.3) -+ -+Features: -+- **IMSM_NO_PLATFORM** boot parameter support from Neil Brown. -+- **--write-zeros** option support by Logan Gunthorpe. -+- **IMSM** monetization by VMD register from Mateusz Grzonka. -+- RST SATA under VMD support from Kevin Friedberg. -+- Strong name rules from Mariusz Tkaczyk. -+ -+Fixes: -+- Unify failed raid behavior from Coly Li. -+- Rework of **--update** options from Mateusz Kusiak. -+- **mdmon-initrd** service from Neil Brown. -+- **IMSM** expand functionality rework from Mariusz Tkaczyk. -+- Mdmonitor improvements from Mateusz Grzonka. -+- Failed state verification from Mateusz Kusiak and Kinga Tanska. -+ -+# Release [mdadm-4.2](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-4.2) -+ -+The release includes more than two years of development and bugfixes, so it is difficult to -+remember everything. Highlights include enhancements and bug fixes including for **IMSM** RAID, -+Partial Parity Log, clustered RAID support, improved testing, and gcc-9 support. -+ -+# Release [mdadm-4.1](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-4.1) -+ -+The update constitutes more than one year of enhancements and bug fixes including for **IMSM** -+RAID, Partial Parity Log, clustered RAID support, improved testing, and gcc-8 support. -+ -+# Release [mdadm-4.0](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-4.0) -+ -+The update in major version number primarily indicates this is a release by it's new maintainer. -+In addition it contains a large number of fixes in particular for IMSM RAID and clustered RAID -+support. In addition, this release includes support for IMSM 4k sector drives, failfast and better -+documentation for journaled RAID. -+ -+This is my first release of mdadm. Please thank Neil Brown for his previous work as maintainer and -+blame me for all the bugs I caused since taking over. -+ -+# Release [mdadm-3.4](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.4) -+ -+- Support for journalled RAID5/6 and clustered RAID1. This new support is probably still buggy. -+ Please report bugs. -+ -+- There are also a number of fixes for **IMSM** support and an assortment of minor bug fixes. -+ -+- I plan for this to be the last release of mdadm that I provide as I am retiring from MD and mdadm -+ maintenance. Jes Sorensen has volunteered to oversee mdadm for the next while. Thanks Jes! -+ -+# Release [mdadm-3.3.4](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.3.4) -+ -+**I strongly recommend upgrading to 3.3.4 if you are using 3.3 or later with IMSM.** -+ -+- **IMSM** metadata assemble fixes. -+ -+ In mdadm-3.3 a change was made to how **IMSM** metadata was handled. Previously an **IMSM** array -+ would only be assembled if it was attached to an **IMSM** controller. In 3.3 this was relaxed as -+ there are circumstances where the controller is not properly detected. Unfortunately, this has -+ negative consequences which have only just come to light. -+ -+ If you have an IMSM RAID1 configured and then disable RAID in the BIOS, the metadata will remain -+ on the devices. If you then install some other OS on one device and then install Linux on the -+ other, Linux might eventually start noticing the IMSM metadata (depending a bit on whether -+ mdadm is included in the initramfs) and might start up the RAID1. This could copy one device over -+ the other, thus trashing one of the installations. -+ -+ So, with this release IMSM arrays will only be assembled if attached to an **IMSM** controller, -+ or if **--force** is given to **--assemble**, or if the environment variable -+ **IMSM_NO_PLATFORM=1** is set (used primarily for testing). -+ -+# Release [mdadm-3.3.3](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.3.3) -+ -+- The 100 changes since 3.3.3 are mostly little bugfixes and some improvements to the self-tests. -+- raid6check now handle all RAID6 layouts including **DDF** correctly. See git log for the rest. -+ -+# Release [mdadm-3.3.2](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.3.2) -+ -+- Little bugfixes and some man-page updates. -+ -+# Release [mdadm-3.3.1](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.3.1) -+ -+- lots of work on **DDF** support. -+- Improved interactions with **systemd**. Where possible, background tasks are run from systemd -+ rather than forking. -+- Number of other little bug fixes too. -+ -+# Release [mdadm-3.3](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.3) -+ -+- Some array reshapes can proceed without needing backup file. This is done by changing the -+ data_offset* so we never need to write any data back over where it was before. If there is no -+ 'head space' or 'tail space' to allow *data_offset* to change, the old mechanism with a backup -+ file can still be used. -+ -+- RAID10 arrays can be reshaped to change the number of devices, change the chunk size, or change -+ the layout between *near* and *offset*. -+ This will always change *data_offset*, and will fail if there is no room for *data_offset* to be -+ moved. -+ -+- **--assemble --update=metadata** can convert a **0.90** array to a **1.0** array. -+ -+- **bad-block-logs** are supported (but not heavily tested yet). -+ -+- **--assemble --update=revert-reshape** can be used to undo a reshape that has just been started -+ but isn't really wanted. This is very new and while it passes basic tests it cannot be -+ guaranteed. -+ -+- improved locking between **--incremental** and **--assemble**. -+ -+- uses systemd to run **mdmon** if systemd is configured to do that. -+- kernel names of md devices can be non-numeric. e.g. "md_home" rather than -+ "md0". This will probably confuse lots of other tools, so you need to -+ **echo CREATE names=yes >> /etc/mdadm.conf** or the feature will not be used (you also need a -+ reasonably new kernel). -+ -+- **--stop** can be given a kernel name instead of a device name. i.e. **mdadm --stop md4** will -+ work even if /dev/md4 doesn't exist. -+ -+- **--detail --export** has some information about the devices in the array. -+- **--dump** and **--restore** can be used to backup and restore the metadata on an array. -+- Hot-replace is supported with **mdadm /dev/mdX --replace /dev/foo** and -+ **mdadm /dev/mdX --replace /dev/foo --with /dev/bar**. -+ -+- Config file can be a directory in which case all "*.conf" files are read in lexical order. -+ Default is to read **/etc/mdadm.conf** and then **/etc/mdadm.conf.d**. Thus -+ **echo CREATE name=yes > /etc/mdadm.conf.d/names.conf** will also enable the use of named md -+ devices. -+ -+- Lots of improvements to **DDF** support including adding support for RAID10 (thanks Martin Wilck). -+ -+# Release [mdadm-3.2.6](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2.6) -+ -+- There are no real stand-out fixes, just lots of little bits and pieces. -+ -+# Release [mdadm-3.2.5](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2.5) -+ -+- This release primarily fixes a serious regression in 3.2.4. This regression does *not* cause -+ any risk to data. It simply means that adding a device with **--add** would sometime fail -+ when it should not. -+- The fix also includes a couple of minor fixes such as making the **--layout=preserve** option to -+ **--grow** work again. -+ -+# Release [mdadm-3.2.4](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2.4) -+ -+ - **--offroot** argument to improve interactions between mdmon and initrd. -+ - **--prefer** argument to select which */dev* names to display in some circumstances. -+ - relax restrictions on when **--add** will be allowed. -+ - Fix bug with adding write-intent-bitmap to active array. -+ - Now defaults to */run/mdadm* for storing run-time files. -+ -+# Release [mdadm-3.2.3](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2.3) -+ -+- The largest single area of change is support for reshape of Intel IMSM arrays (OnLine Capacity -+ Expansion and Level Migration). -+- Among other fixes, this now has a better chance of surviving if a device fails during reshape. -+ -+# Release [mdadm-3.2.2](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2.2) -+ -+- reshaping IMSM (Intel metadata) arrays is no longer 'experimental', it should work properly and be -+ largely compatible with IMSM drivers in other platforms. -+- **--assume-clean** can be used with **--grow --size** to avoid resyncing the new part of the -+ array. This is only support with very new kernels. -+- RAID0 arrays can have chunksize which is not a power of 2. This has been supported in the kernel -+ for a while but is only now supported by mdadm. -+ -+- A new tool **raid6check** is available, which can check a RAID6 array, or part of it and report -+ which device is most inconsistent with the others if any stripe is inconsistent. This is still -+ under development and does not have a man page yet. If anyone tries it out and has any questions -+ or experience to report, they would be most welcome on linux-raid@vger.kernel.org. -+ -+# Release [mdadm-3.2.1](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2.1) -+ -+- Policy framework -+ -+ Policy can be expressed for moving spare devices between arrays, and for how to handle hot-plugged -+ devices. This policy can be different for devices plugged in to different controllers etc. This, -+ for example, allows a configuration where when a device is plugged in it is immediately included -+ in an md array as a hot spare and possibly starts recovery immediately if an array is degraded. -+ -+- Some understanding of mbr and gpt paritition tables. This is primarily to support the new -+ hot-plug support. If a device is plugged in and policy suggests it should have a partition table, -+ the partition table will be copied from a suitably similar device, and then the partitions will -+ hot-plug and can then be added to md arrays. -+ -+- **--incremental --remove** can remember where a device was removed from so if a device gets -+ plugged back in the same place, special policy applies to it, allowing it to be included in an -+ array even if a general hotplug will not be included. -+ -+- Enhanced reshape options, including growing a RAID0 by converting to RAID4, restriping, and -+ converting back. Also convertions between RAID0 and RAID10 and between RAID1 and RAID10 are -+ possible (with a suitably recent kernel). -+ -+- Spare migration for IMSM arrays. Spare migration can now work across 'containers' using -+ non-native metadata and specifically Intel's IMSM arrays support spare migrations. -+ -+- OLCE and level migration for Intel IMSM arrays. OnLine Capacity Expansion and level migration -+ (e.g. RAID0 -> RAID5) is supported for Intel Matrix Storage Manager arrays. This support is -+ currently *experimental* for technical reasons. It can be enabled with -+ **export MDADM_EXPERIMENTAL=1**. -+ -+- avoid including wayward devices. -+ -+ If you split a RAID1, mount the two halves as two separate degraded RAID1s, and then later bring -+ the two back together, it is possible that the md metadata won't properly show that one must -+ over-ride the other. Mdadm now does extra checking to detect this possibility and avoid -+ potentially corrupting data. -+ -+- Remove any possible confusion between similar options. e.g. **--brief** and **--bitmap** were -+ mapped to 'b' and mdadm wouldn't notice if one was used where the other was expected. -+ -+- Allow K,M,G suffixes on chunk sizes. -+ -+# Release [mdadm-3.2](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.2) -+ -+- By far the most significant change in this release related to the management of reshaping arrays. -+ This code has been substantially re-written so that it can work with **externally managed -+ metadata** -Intel's IMSM in particular. We now support level migration and OnLine Capacity -+ Expansion on these arrays. -+ -+- Various policy statements can be made in the *mdadm.conf* to guide the behavior of mdadm, -+ particular with regards to how new devices are treated by **--incremental**. Depending on the -+ *action* associated with a device (identified by its *path*) such need devices can be -+ automatically re-added to and existing array that they previously fell out off, or automatically -+ added as a spare if they appear to contain no data. -+ -+- mdadm now has a limited understanding of partition tables. This allows the policy framework to -+ make decisions about partitioned devices as well. -+ -+- **--incremental --remove** can be told what **--path** the device was on, and this info will be -+ recorded so that another device appearing at the same physical location can be preferentially -+ added to the same array (provides the spare-same-slot action policy applied to the path). -+ -+- A new flags **--invalid-backup** flag is available in **--assemble** mode. This can be used to -+ re-assemble an array which was stopping in the middle of a reshape, and for which the -+ *backup file* is no longer available or is corrupted. The array may have some corruption in it -+ at the point where reshape was up to, but at least the rest of the array will become available. -+ -+- Policy framework. -+- Various internal restructuring - more is needed. -+ -+# Release [mdadm-3.1.5](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.1.5) -+ -+- Fixes for **v1.x** metadata on big-endian machines. -+- man page improvements. -+- Improve **--detail --export** when run on partitions of an md array. -+- Fix regression with removing *failed* or *detached* devices. -+- Fixes for **--assemble --force** in various unusual cases. -+- Allow **-Y** to mean **--export**. This was documented but not implemented. -+- Various fixes for handling **ddf** metadata. This is now more reliable but could benefit from -+ more interoperability testing. -+- Correctly list subarrays of a container in **--detail** output. -+- Improve checks on whether the requested number of devices is supported by the metadata, both for -+ **--create** and **--grow**. -+- Don't remove partitions from a device that is being included in an array until we are fully -+ committed to including it. -+- Allow **--assemble --update=no-bitmap** so an array with a corrupt bitmap can still be assembled. -+- Don't allow **--add** to succeed if it looks like a **--re-add** is probably wanted, but cannot -+ succeed. This avoids inadvertently turning devices into spares when an array is failed. -+ -+# Release [mdadm-3.1.4](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.1.4) -+ -+Two fixes related to configs that aren't using udev: -+- Don't remove md devices which 'standard' names on **--stop**. -+- Allow dev_open to work on read-only */dev*. -+ -+And fixed regressions: -+- Allow **--incremental** to add spares to an array. -+- Accept **--no-degraded** as a deprecated option rather than throwing an error. -+- Return correct success status when **--incremental** assembling a container which does not yet -+ have enough devices. -+- Don't link mdadm with pthreads, only mdmon needs it. -+- Fix compiler warning due to bad use of snprintf. -+ -+# Release [mdadm-3.1.3](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.1.3) -+ -+- mapfile now lives in a fixed location which default to */dev/.mdadm/map*, but can be changed at -+ compile time. This location is chosen and most distros provide it during early boot and preserve -+ it through. As long a */dev* exists and is writable, */dev/.mdadm* will be created. Other files -+ communication with mdmon live here too. This fixes a bug reported by Debian and Gentoo users where -+ udev would spin in early-boot. -+ -+- IMSM and DDF metadata will not be recognized on partitions as they should only be used on -+ whole-disks. -+ -+- Various overflows causes by 2G drives have been addressed. -+ -+- A subarray of an IMSM contain can now be killed with **--kill-subarray**. Also, subarrays can be -+ renamed with **--update-subarray --update=name**. -+ -+- **-If** (or **--incremental --fail**) can be used from udev to fail and remove from all arrays -+ a device which has been unplugged from the system i.e. hot-unplug-support. -+ -+- **/dev/mdX --re-add missing** will look for any device that looks like it should be a member of -+ */dev/mdX* but isn't and will automatically **--re-add** it. -+ -+- Now compile with *-Wextra* to get extra warnings. -+- Lots of minor bug fixes, documentation improvements, etc. -+ -+# Release [mdadm-3.1.2](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.1.2) -+ -+- The default metadata has change again (sorry about that). It is now **v1.2** and will hopefully -+ stay that way. It turned out there with boot-block issues with **v1.1** which make it unsuitable -+ for a default, though in many cases it is still suitable to use. -+ -+- Add *homehost* to the valid words for the **AUTO** config file line. When followed by *-all*, -+ this causes mdadm to auto-assemble any array belonging to this host, but not auto-assemble -+ anything else. -+ -+- VAR_RUN can be easily changed at compile time just like ALT_RUN. This gives distros more -+ flexibility in how to manage the pid and sock files that mdmon needs. -+ -+- If mdadm.conf lists arrays which have inter-dependencies, the previously had to be listed in the -+ "right" order. Now, any order should work. -+ -+- Fix some bugs with **--grow --chunksize=**. -+- Stopping a container is not permitted when members are still active. -+- Various mdmon fixes. -+- Alway make bitmap 4K-aligned if at all possible. -+- Fix **--force** assembly of **v1.x** arrays which are in the process of recovering. -+- Add section on 'scrubbing' to 'md' man page. -+- Various command-line-option parsing improvements. -+- ... and lots of other bug fixes. -+ -+# Release [mdadm-3.1.1](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.1.1) -+ -+- Multiple fixes for new **--grow** levels including fixes for serious data corruption -+ problems. -+- Change default metadata to **v1.1**. -+- Change default chunk size to 512K. -+- Change default bitmap chunk size to 64MB. -+- When **--re-add** is used, don't fall back to **--add** as this can destroy data. -+ -+# Release [mdadm-3.1](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.1) -+ -+- Support **--grow** to change the layout of RAID 4/5/6. -+- Support **--grow** to change the chunk size of RAID 4/5/6. -+- Support **--grow** to change level from RAID1 -> RAID5 -> RAID6 and back. -+- Support **--grow** to reduce the number of devices in RAID 4/5/6. -+- Support restart of these grow options which assembling an array which is partially grown. -+- Assorted tests of this code, and of different RAID6 layouts. -+ -+# Release [mdadm-3.0.3](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.0.3) -+ -+- Improvements for creating arrays giving just a name, like *foo*, rather than the full -+ */dev/md/foo*. -+- Improvements for assembling member arrays of containers. -+- Improvements to test suite. -+- Add option to change increment for *RebuildNN* messages reported by **--monitor**. -+- Improvements to **mdmon** hand-over from initrd to final root. -+- Handle merging of devices that have left an IMSM array and are being re-incorporated. -+- Add missing space in **--detail --brief** output. -+ -+# Release [mdadm-3.0.2](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.0.2) -+ -+- Fix crash when **homehost** is not set, as often happens in early boot. -+ -+# Release [mdadm-3.0.1](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.0.1) -+ -+- Fix various segfaults. -+- Fixed for **--examine** with containers. -+- Lots of other little fixes. -+ -+# Release [mdadm-3.0](https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/log/?h=mdadm-3.0) -+ -+- Support for **externally managed metadata**, specifically DDF and IMSM. -+- Depend on udev to create entries in */dev*, rather than creating them ourselves. -+- Remove **--auto-update-home-hosts**. -+- New config file line **auto**. -+- New *ignore* and *any* options for **homehost**. -+- Numerous bug fixes and minor enhancements. -diff --git a/ChangeLog b/ChangeLog -deleted file mode 100644 -index a3bf7007..00000000 ---- a/ChangeLog -+++ /dev/null -@@ -1,306 +0,0 @@ --Please see git logs for detailed change log. --This file just contains highlight. -- --Changes Prior to release 3.3 --- Some array reshapes can proceed without needing backup file. -- This is done by changing the 'data_offset' so we never need to write -- any data back over where it was before. If there is no "head space" -- or "tail space" to allow data_offset to change, the old mechanism -- with a backup file can still be used. --- RAID10 arrays can be reshaped to change the number of devices, -- change the chunk size, or change the layout between 'near' -- and 'offset'. -- This will always change data_offset, and will fail if there is no -- room for data_offset to be moved. --- "--assemble --update=metadata" can convert a 0.90 array to a 1.0 array. --- bad-block-logs are supported (but not heavily tested yet) --- "--assemble --update=revert-reshape" can be used to undo a reshape -- that has just been started but isn't really wanted. This is very -- new and while it passes basic tests it cannot be guaranteed. --- improved locking between --incremental and --assemble --- uses systemd to run "mdmon" if systemd is configured to do that. --- kernel names of md devices can be non-numeric. e.g. "md_home" rather than -- "md0". This will probably confuse lots of other tools, so you need to -- echo CREATE names=yes >> /etc/mdadm.conf -- or the feature will not be used. (you also need a reasonably new kernel). --- "--stop" can be given a kernel name instead of a device name. i.e -- mdadm --stop md4 -- will work even if /dev/md4 doesn't exist. --- "--detail --export" has some information about the devices in the array --- --dump and --restore can be used to backup and restore the metadata on an -- array. --- Hot-replace is supported with -- mdadm /dev/mdX --replace /dev/foo -- and -- mdadm /dev/mdX --replace /dev/foo --with /dev/bar --- Config file can be a directory in which case all "*.conf" files are -- read in lexical order. -- Default is to read /etc/mdadm.conf and then /etc/mdadm.conf.d -- Thus -- echo CREATE name=yes > /etc/mdadm.conf.d/names.conf -- will also enable the use of named md devices. -- --- Lots of improvements to DDF support including adding support for -- RAID10 (thanks Martin Wilck). -- --Changes Prior to release 3.2.6 -- - There are no real stand-out fixes, just lots of little bits and pieces. -- --Changes Prior to release 3.2.5 -- - This release primarily fixes a serious regression in 3.2.4. -- This regression does *not* cause any risk to data. It simply -- means that adding a device with "--add" would sometime fail -- when it should not. -- -- - The fix also includes a couple of minor fixes such as making -- the "--layout=preserve" option to "--grow" work again. -- -- --Changes Prior to release 3.2.4 --"--oneline" log of changes is below. Some notable ones are: -- -- - --offroot argument to improve interactions between mdmon and initrd -- - --prefer argument to select which /dev names to display in some -- circumstances. -- - relax restructions on when "--add" will be allowed -- - Fix bug with adding write-intent-bitmap to active array -- - Now defaults to "/run/mdadm" for storing run-time files. -- --Changes Prior to release 3.2.3 -- - The largest single area of change is support for reshape of Intel -- IMSM arrays (OnLine Capacity Explansion and Level Migration). -- - Among other fixes, this now has a better chance of surviving if a -- device fails during reshape. -- --Changes Prior to release 3.2.2 -- - reshaping IMSM (Intel metadata) arrays is no longer 'experimental', -- it should work properly and be largely compatible with IMSM drivers in -- other platforms. -- - --assume-clean can be used with --grow --size to avoid resyncing the -- new part of the array. This is only support with very new kernels. -- - RAID0 arrays can have chunksize which is not a power of 2. This has been -- supported in the kernel for a while but is only now supprted by -- mdadm. -- -- - A new tool 'raid6check' is available which can check a RAID6 array, -- or part of it, and report which device is most inconsistent with the -- others if any stripe is inconsistent. This is still under development -- and does not have a man page yet. If anyone tries it out and has any -- questions or experience to report, they would be most welcome on -- linux-raid@vger.kernel.org. -- --Changes Prior to release 3.2.1 -- - policy framework -- Policy can be expressed for moving spare devices between arrays, and -- for how to handle hot-plugged devices. This policy can be different -- for devices plugged in to different controllers etc. -- This, for example, allows a configuration where when a device is plugged -- in it is immediately included in an md array as a hot spare and -- possibly starts recovery immediately if an array is degraded. -- -- - some understanding of mbr and gpt paritition tables -- This is primarly to support the new hot-plug support. If a -- device is plugged in and policy suggests it should have a partition table, -- the partition table will be copied from a suitably similar device, and -- then the partitions will hot-plug and can then be added to md arrays. -- -- - "--incremental --remove" can remember where a device was removed from -- so if a device gets plugged back in the same place, special policy applies -- to it, allowing it to be included in an array even if a general hotplug -- will not be included. -- -- - enhanced reshape options, including growing a RAID0 by converting to RAID4, -- restriping, and converting back. Also convertions between RAID0 and -- RAID10 and between RAID1 and RAID10 are possible (with a suitably recent -- kernel). -- -- - spare migration for IMSM arrays. -- Spare migration can now work across 'containers' using non-native metadata -- and specifically Intel's IMSM arrays support spare migrations. -- -- - OLCE and level migration for Intel IMSM arrays. -- OnLine Capacity Expansion and level migration (e.g. RAID0 -> RAID5) is -- supported for Intel Matrix Storage Manager arrays. -- This support is currently 'experimental' for technical reasons. It can -- be enabled with "export MDADM_EXPERIMENTAL=1" -- -- - avoid including wayward devices -- If you split a RAID1, mount the two halves as two separate degraded RAID1s, -- and then later bring the two back together, it is possible that the md -- metadata won't properly show that one must over-ride the other. -- mdadm now does extra checking to detect this possibilty and avoid -- potentially corrupting data. -- -- - remove any possible confusion between similar options. -- e.g. --brief and --bitmap were mapped to 'b' and mdadm wouldn't -- notice if one was used where the other was expected. -- -- - allow K,M,G suffixes on chunk sizes -- --Changes Prior to release 3.2 -- - By far the most significant change in this release related to the -- management of reshaping arrays. This code has been substantially -- re-written so that it can work with 'externally managed metadata' - -- Intel's IMSM in particular. We now support level migration and -- OnLine Capacity Expansion on these arrays. -- - Policy framework. -- Various policy statements can be made in the mdadm.conf to guide -- the behaviour of mdadm, particular with regards to how new devices -- are treated by "mdadm -I". -- Depending on the 'action' associated with a device (identified by -- its 'path') such need devices can be automatically re-added to and -- existing array that they previously fell out off, or automatically -- added as a spare if they appear to contain no data. -- -- - mdadm now has a limited understanding of partition tables. This -- allows the policy framework to make decisions about partitioned -- devices as well. -- -- - --incremental --remove can be told what --path the device was on, -- and this info will be recorded so that another device appearing at -- the same physical location can be preferentially added to the same -- array (provides the spare-same-slot action policy applied to the -- path). -- -- - A new flags "--invalid-backup" flag is available in --assemble -- mode. This can be used to re-assemble an array which was stopping -- in the middle of a reshape, and for which the 'backup file' is no -- longer available or is corrupted. The array may have some -- corruption in it at the point where reshape was up to, but at least -- the rest of the array will become available. -- -- -- - Various internal restructuring - more is needed. -- --Changes Prior to release 3.1.5 -- - Fixes for v1.x metadata on big-endian machines. -- - man page improvements -- - Improve '--detail --export' when run on partitions of an md array. -- - Fix regression with removing 'failed' or 'detached' devices. -- - Fixes for "--assemble --force" in various unusual cases. -- - Allow '-Y' to mean --export. This was documented but not implemented. -- - Various fixed for handling 'ddf' metadata. This is now more reliable -- but could benefit from more interoperability testing. -- - Correctly list subarrays of a container in "--detail" output. -- - Improve checks on whether the requested number of devices is supported -- by the metadata - both for --create and --grow. -- - Don't remove partitions from a device that is being included in an -- array until we are fully committed to including it. -- - Allow "--assemble --update=no-bitmap" so an array with a corrupt -- bitmap can still be assembled. -- - Don't allow --add to succeed if it looks like a "--re-add" is probably -- wanted, but cannot succeed. This avoids inadvertently turning -- devices into spares when an array is failed. -- --Changes Prior to release 3.1.4 -- Two fixes related to configs that aren't using udev: -- - Don't remove md devices which 'standard' names on --stop -- - Allow dev_open to work on read-only /dev -- And fixed regressions: -- - Allow --incremental to add spares to an array -- - Accept --no-degraded as a deprecated option rather than -- throwing an error -- - Return correct success status when --incrmental assembling -- a container which does not yet have enough devices. -- - Don't link mdadm with pthreads, only mdmon needs it. -- - Fix compiler warning due to bad use of snprintf -- --Changes Prior to release 3.1.3 -- - mapfile now lives in a fixed location which default to -- /dev/.mdadm/map but can be changed at compile time. This -- location is choses and most distros provide it during early -- boot and preserve it through. As long a /dev exists and is -- writable, /dev/.mdadm will be created. -- Other files file communication with mdmon live here too. -- This fixes a bug reported by Debian and Gentoo users where -- udev would spin in early-boot. -- - IMSM and DDF metadata will not be recognised on partitions -- as they should only be used on whole-disks. -- - Various overflows causes by 2G drives have been addressed. -- - A subarray of an IMSM contain can now be killed with -- --kill-subarray. Also subarrays can be renamed with -- --update-subarray -- - -If (or --incremental --fail) can be used from udev to -- fail and remove from all arrays a device which has been -- unplugged from the system. i.e. hot-unplug-support. -- - "mdadm /dev/mdX --re-add missing" will look for any device -- that looks like it should be a member of /dev/mdX but isn't -- and will automatically --re-add it -- - Now compile with -Wextra to get extra warnings. -- - Lots of minor bug fixes, documentation improvements, etcc -- --Changes Prior to release 3.1.2 -- - The default metadata has change again (sorry about that). -- It is now v1.2 and will hopefully stay that way. It turned -- out there with boot-block issues with v1.1 which make it -- unsuitable for a default, though in many cases it is still -- suitable to use. -- - Stopping a container is not permitted when members are still -- active -- - Add 'homehost' to the valid words for the "AUTO" config file -- line. When followed by "-all", this causes mdadm to -- auto-assemble any array belonging to this host, but not -- auto-assemble anything else. -- - Fix some bugs with "--grow --chunksize=" for changing chunksize. -- - VAR_RUN can be easily changed at compile time just like ALT_RUN. -- This gives distros more flexability in how to manage the -- pid and sock files that mdmon needs. -- - Various mdmon fixes -- - Alway make bitmap 4K-aligned if at all possible. -- - If mdadm.conf lists arrays which have inter-dependencies, -- the previously had to be listed in the "right" order. Now -- any order should work. -- - Fix --force assembly of v1.x arrays which are in the process -- of recovering. -- - Add section on 'scrubbing' to 'md' man page. -- - Various command-line-option parsing improvements. -- - ... and lots of other bug fixes. -- --Changes Prior to release 3.1.1 -- - Multiple fixes for new --grow levels including fixes for -- serious data corruption problems. -- - Change default metadata to v1.1 -- - Change default chunk size to 512K -- - Change default bitmap chunk size to 64Meg -- - When --re-add is used, don't fall back to -- --add if --re-add fails as this can destroy data. -- --Changes Prior to release 3.1 -- - Support --grow to change the layout of RAID4/5/6 -- - Support --grow to change the chunksize of raid 4/5/6 -- - Support --grow to change level from RAID1 -> RAID5 -> RAID6 and -- back. -- - Support --grow to reduce the number of devices in RAID4/5/6. -- - Support restart of these grow options which assembling an array -- which is partially grown. -- - Assorted tests of this code, and of different RAID6 layouts. -- --Changes Prior to release 3.0.3 -- - Improvements for creating arrays giving just a name, like 'foo', -- rather than the full '/dev/md/foo'. -- - Improvements for assembling member arrays of containers. -- - Improvements to test suite -- - Add option to change increment for RebuildNN messages reported -- by "mdadm --monitor" -- - Improvements to mdmon 'hand-over' from initrd to final root. -- - Handle merging of devices that have left an IMSM array and are -- being re-incorporated. -- - Add missing space in "--detail --brief" output. -- --Changes Prior to release 3.0.2 -- - Fix crash when hosthost is not set, as often happens in -- early boot. -- --Changes Prior to release 3.0.1 -- - Fix various segfaults -- - Fixed for --examine with containers -- - Lots of other little fixes. -- --Changes Prior to release 3.0 -- - Support for externally managed metadata, specifically DDF and IMSM. -- - Depend on udev to create entries in /dev, rather than creating them -- ourselves. -- - remove --auto-update-home-hosts -- - new config file line "auto" -- - new "" and "any" options for "homehost" -- - numerous bug fixes and minor enhancements. --- -2.41.0 - diff --git a/0049-mdadm-Add-MAINTAINERS.md.patch b/0049-mdadm-Add-MAINTAINERS.md.patch deleted file mode 100644 index c5ff1f5..0000000 --- a/0049-mdadm-Add-MAINTAINERS.md.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 21d6c5d96a5a467b5877ba1d38106b3746005bcc Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 26 Mar 2024 13:21:11 +0100 -Subject: [PATCH 49/66] mdadm: Add MAINTAINERS.md - -Describe rules maintainer should follow. - -Signed-off-by: Mariusz Tkaczyk ---- - MAINTAINERS.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 44 insertions(+) - create mode 100644 MAINTAINERS.md - -diff --git a/MAINTAINERS.md b/MAINTAINERS.md -new file mode 100644 -index 00000000..9c79ba87 ---- /dev/null -+++ b/MAINTAINERS.md -@@ -0,0 +1,44 @@ -+# Maintainer tools -+ -+Useful tools used in daily routines: -+- [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. -+ -+- 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**. -+ -+- [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 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. -+ -+- Update CHANGELOG.md. -+- Write "ANNOUNCE" mail to linux-raid@kernel.org to notify community. --- -2.41.0 - diff --git a/0050-mdadm-Add-README.md.patch b/0050-mdadm-Add-README.md.patch deleted file mode 100644 index 18a5340..0000000 --- a/0050-mdadm-Add-README.md.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 256edaef3d43a112356762aaea4a48f021f45aec Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 26 Mar 2024 13:21:12 +0100 -Subject: [PATCH 50/66] mdadm: Add README.md - -Describe supported metadata types, add step-by-step patch sending -instruction, mention minimally supported kernel version and licensing. - -Signed-off-by: Mariusz Tkaczyk ---- - README.md | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 83 insertions(+) - create mode 100644 README.md - -diff --git a/README.md b/README.md -new file mode 100644 -index 00000000..64f2ecec ---- /dev/null -+++ b/README.md -@@ -0,0 +1,83 @@ -+**mdadm** is a utility used to create and manage **software RAID** devices implemented through -+**Multiple devices driver (MD)** in kernel. It supports following RAID metadata formats: -+ -+* [Linux native RAID](https://raid.wiki.kernel.org/index.php/RAID_superblock_formats): -+ -+ Known as **native** or **native RAID**. First and default metadata format. Metadata management -+ is implemented in **MD driver**. -+ -+* Matrix Storage Manager Support (no reference, metadata format documentation is proprietary). -+ -+ Known as **IMSM**. Metadata format developed and maintained by **Intel®** as a part of **VROC** -+ solution. There are some functional differences between **native** and **imsm**. The most -+ important difference is that the metadata is managed from userspace. -+ -+ **CAUTION:** **imsm** is compatible with **Intel RST**, however it is not officially supported. -+ You are using it on your own risk. -+ -+* [Common RAID DDF Specification Revision](https://www.snia.org/sites/default/files/SNIA_DDF_Technical_Position_v2.0.pdf) -+ -+ **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). -+ -+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**. -+ -+## Sending patches step-by-step -+ -+To maximize change of patches being taken, follow this instruction when submitting: -+ -+1. Create possibly logically separated commits and generate patches: -+ -+ Use ``git format-patch --cover-letter --signoff -v `` to create patches: -+ * ``--cover-letter`` can be skipped if it is only one patch; -+ * ``--signoff`` adds sign-off tag; -+ * ``-v `` indicates review revision number, sender should increment it before resending. -+ -+2. Check style of every patch with kernel -+ [checkpatch](https://docs.kernel.org/dev-tools/checkpatch.html) script: -+ -+ 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 `` 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. -+ -+3. Send patches using ``git send-mail --to=linux-raid@vger.kernel.org (...)`` -+ -+# Maintainers -+ -+It is good practice to add **mdadm maintainers** to recipients for patches: -+ -+- Jes Sorensen ; -+- Mariusz Tkaczyk ; -+ -+Adding **MD maintainers** could be reasonable, especially if patches may affect MD driver: -+ -+- Song Liu ; -+- Yu Kuai ; -+ -+# 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 -+workarounds and fixes for legacy issues. -+ -+# License -+ -+It is released under the terms of the **GNU General Public License version 2** as published -+by the **Free Software Foundation**. --- -2.41.0 - diff --git a/0051-Create.c-fix-uclibc-build.patch b/0051-Create.c-fix-uclibc-build.patch deleted file mode 100644 index 96c9c4d..0000000 --- a/0051-Create.c-fix-uclibc-build.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 52bead95d2957437c691891fcdc49bd6afccdd49 Mon Sep 17 00:00:00 2001 -From: Fabrice Fontaine -Date: Fri, 12 Apr 2024 18:45:13 +0200 -Subject: [PATCH 51/66] Create.c: fix uclibc build - -Define FALLOC_FL_ZERO_RANGE if needed as FALLOC_FL_ZERO_RANGE is only -defined for aarch64 on uclibc-ng resulting in the following or1k build -failure since commit 577fd10486d8d1472a6b559066f344ac30a3a391: - -Create.c: In function 'write_zeroes_fork': -Create.c:155:35: error: 'FALLOC_FL_ZERO_RANGE' undeclared (first use in this function) - 155 | if (fallocate(fd, FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE, - | ^~~~~~~~~~~~~~~~~~~~ - -Fixes: - - http://autobuild.buildroot.org/results/0e04bcdb591ca5642053e1f7e31384f06581e989 - -Signed-off-by: Fabrice Fontaine -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/Create.c b/Create.c -index 4397ff49..d94253b1 100644 ---- a/Create.c -+++ b/Create.c -@@ -32,6 +32,10 @@ - #include - #include - -+#ifndef FALLOC_FL_ZERO_RANGE -+#define FALLOC_FL_ZERO_RANGE 16 -+#endif -+ - static int round_size_and_verify(unsigned long long *size, int chunk) - { - if (*size == 0) --- -2.41.0 - diff --git a/0052-mdadm-pass-struct-context-for-external-reshapes.patch b/0052-mdadm-pass-struct-context-for-external-reshapes.patch deleted file mode 100644 index 7c92cdc..0000000 --- a/0052-mdadm-pass-struct-context-for-external-reshapes.patch +++ /dev/null @@ -1,309 +0,0 @@ -From bdc2c56998abf76141294b04facf20217cfd1911 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:13 +0200 -Subject: [PATCH 52/66] mdadm: pass struct context for external reshapes - -This patch alters mutiple functions calls so the context is passed to -external reshape functions. - -There are two main reasons behind it: -- reduces number of arguments passed and unifies them, -- imsm code will make use of context in incoming patches. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Assemble.c | 7 ++---- - Grow.c | 68 +++++++++++++++++++++------------------------------ - mdadm.c | 2 +- - mdadm.h | 11 +++------ - super-intel.c | 6 ++--- - 5 files changed, 37 insertions(+), 57 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index f6c5b99e..f5e9ab1f 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1197,9 +1197,7 @@ static int start_array(int mdfd, - rv = sysfs_set_str(content, NULL, - "array_state", "readonly"); - if (rv == 0) -- rv = Grow_continue(mdfd, st, content, -- c->backup_file, 0, -- c->freeze_reshape); -+ rv = Grow_continue(mdfd, st, content, 0, c); - } else if (c->readonly && - sysfs_attribute_available(content, NULL, - "array_state")) { -@@ -2180,8 +2178,7 @@ int assemble_container_content(struct supertype *st, int mdfd, - st->update_tail = &st->updates; - } - -- err = Grow_continue(mdfd, st, content, c->backup_file, -- 0, c->freeze_reshape); -+ err = Grow_continue(mdfd, st, content, 0, c); - } else switch(content->array.level) { - case LEVEL_LINEAR: - case LEVEL_MULTIPATH: -diff --git a/Grow.c b/Grow.c -index 074f1995..f477b438 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -864,8 +864,7 @@ static void wait_reshape(struct mdinfo *sra) - - static int reshape_super(struct supertype *st, unsigned long long size, - int level, int layout, int chunksize, int raid_disks, -- int delta_disks, char *backup_file, char *dev, -- int direction, int verbose) -+ int delta_disks, char *dev, int direction, struct context *c) - { - /* nothing extra to check in the native case */ - if (!st->ss->external) -@@ -876,9 +875,8 @@ static int reshape_super(struct supertype *st, unsigned long long size, - return 1; - } - -- return st->ss->reshape_super(st, size, level, layout, chunksize, -- raid_disks, delta_disks, backup_file, dev, -- direction, verbose); -+ return st->ss->reshape_super(st, size, level, layout, chunksize, raid_disks, -+ delta_disks, dev, direction, c); - } - - static void sync_metadata(struct supertype *st) -@@ -1764,9 +1762,8 @@ static int reshape_container(char *container, char *devname, - int mdfd, - struct supertype *st, - struct mdinfo *info, -- int force, -- char *backup_file, int verbose, -- int forked, int restart, int freeze_reshape); -+ struct context *c, -+ int forked, int restart); - - /** - * prepare_external_reshape() - prepares update on external metadata if supported. -@@ -2004,9 +2001,8 @@ int Grow_reshape(char *devname, int fd, - goto release; - } - -- if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet, NULL, -- devname, APPLY_METADATA_CHANGES, -- c->verbose > 0)) { -+ if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet, -+ devname, APPLY_METADATA_CHANGES, c)) { - rv = 1; - goto release; - } -@@ -2124,10 +2120,8 @@ size_change_error: - int err = errno; - - /* restore metadata */ -- if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0, -- UnSet, NULL, devname, -- ROLLBACK_METADATA_CHANGES, -- c->verbose) == 0) -+ if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0, UnSet, -+ devname, ROLLBACK_METADATA_CHANGES, c) == 0) - sync_metadata(st); - pr_err("Cannot set device size for %s: %s\n", - devname, strerror(err)); -@@ -2338,8 +2332,7 @@ size_change_error: - */ - close_fd(&fd); - rv = reshape_container(container, devname, -1, st, &info, -- c->force, c->backup_file, c->verbose, -- 0, 0, 0); -+ c, 0, 0); - frozen = 0; - } else { - /* get spare devices from external metadata -@@ -2356,13 +2349,13 @@ size_change_error: - } - - /* Impose these changes on a single array. First -- * check that the metadata is OK with the change. */ -+ * check that the metadata is OK with the change. -+ */ - - if (reshape_super(st, 0, info.new_level, - info.new_layout, info.new_chunk, - info.array.raid_disks, info.delta_disks, -- c->backup_file, devname, -- APPLY_METADATA_CHANGES, c->verbose)) { -+ devname, APPLY_METADATA_CHANGES, c)) { - rv = 1; - goto release; - } -@@ -3668,9 +3661,8 @@ int reshape_container(char *container, char *devname, - int mdfd, - struct supertype *st, - struct mdinfo *info, -- int force, -- char *backup_file, int verbose, -- int forked, int restart, int freeze_reshape) -+ struct context *c, -+ int forked, int restart) - { - struct mdinfo *cc = NULL; - int rv = restart; -@@ -3683,8 +3675,7 @@ int reshape_container(char *container, char *devname, - reshape_super(st, 0, info->new_level, - info->new_layout, info->new_chunk, - info->array.raid_disks, info->delta_disks, -- backup_file, devname, APPLY_METADATA_CHANGES, -- verbose)) { -+ devname, APPLY_METADATA_CHANGES, c)) { - unfreeze(st); - return 1; - } -@@ -3695,7 +3686,7 @@ int reshape_container(char *container, char *devname, - */ - ping_monitor(container); - -- if (!forked && !freeze_reshape) -+ if (!forked && !c->freeze_reshape) - if (continue_via_systemd(container, GROW_SERVICE, NULL)) - return 0; - -@@ -3705,7 +3696,7 @@ int reshape_container(char *container, char *devname, - unfreeze(st); - return 1; - default: /* parent */ -- if (!freeze_reshape) -+ if (!c->freeze_reshape) - printf("%s: multi-array reshape continues in background\n", Name); - return 0; - case 0: /* child */ -@@ -3802,12 +3793,12 @@ int reshape_container(char *container, char *devname, - flush_mdmon(container); - - rv = reshape_array(container, fd, adev, st, -- content, force, NULL, INVALID_SECTORS, -- backup_file, verbose, 1, restart, -- freeze_reshape); -+ content, c->force, NULL, INVALID_SECTORS, -+ c->backup_file, c->verbose, 1, restart, -+ c->freeze_reshape); - close(fd); - -- if (freeze_reshape) { -+ if (c->freeze_reshape) { - sysfs_free(cc); - exit(0); - } -@@ -4970,8 +4961,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, - return 1; - } - --int Grow_continue_command(char *devname, int fd, -- char *backup_file, int verbose) -+int Grow_continue_command(char *devname, int fd, struct context *c) - { - int ret_val = 0; - struct supertype *st = NULL; -@@ -5157,7 +5147,7 @@ int Grow_continue_command(char *devname, int fd, - - /* continue reshape - */ -- ret_val = Grow_continue(fd, st, content, backup_file, 1, 0); -+ ret_val = Grow_continue(fd, st, content, 1, c); - - Grow_continue_command_exit: - if (cfd > -1) -@@ -5171,7 +5161,7 @@ Grow_continue_command_exit: - } - - int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info, -- char *backup_file, int forked, int freeze_reshape) -+ int forked, struct context *c) - { - int ret_val = 2; - -@@ -5187,14 +5177,12 @@ int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info, - st->ss->load_container(st, cfd, st->container_devnm); - close(cfd); - ret_val = reshape_container(st->container_devnm, NULL, mdfd, -- st, info, 0, backup_file, 0, -- forked, 1 | info->reshape_active, -- freeze_reshape); -+ st, info, c, forked, 1 | info->reshape_active); - } else - ret_val = reshape_array(NULL, mdfd, "array", st, info, 1, -- NULL, INVALID_SECTORS, backup_file, -+ NULL, INVALID_SECTORS, c->backup_file, - 0, forked, 1 | info->reshape_active, -- freeze_reshape); -+ c->freeze_reshape); - - return ret_val; - } -diff --git a/mdadm.c b/mdadm.c -index 3f191288..d18619db 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -1636,7 +1636,7 @@ int main(int argc, char *argv[]) - c.delay = DEFAULT_BITMAP_DELAY; - rv = Grow_addbitmap(ident.devname, mdfd, &c, &s); - } else if (grow_continue) -- rv = Grow_continue_command(ident.devname, mdfd, c.backup_file, c.verbose); -+ rv = Grow_continue_command(ident.devname, mdfd, &c); - else if (s.size > 0 || s.raiddisks || s.layout_str || - s.chunk != 0 || s.level != UnSet || - s.data_offset != INVALID_SECTORS) { -diff --git a/mdadm.h b/mdadm.h -index 2640b396..0ade4beb 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1235,9 +1235,8 @@ extern struct superswitch { - int (*reshape_super)(struct supertype *st, - unsigned long long size, int level, - int layout, int chunksize, int raid_disks, -- int delta_disks, char *backup, char *dev, -- int direction, -- int verbose); /* optional */ -+ int delta_disks, char *dev, int direction, -+ struct context *c); - int (*manage_reshape)( /* optional */ - int afd, struct mdinfo *sra, struct reshape *reshape, - struct supertype *st, unsigned long blocks, -@@ -1541,8 +1540,7 @@ extern int Grow_reshape(char *devname, int fd, - extern int Grow_restart(struct supertype *st, struct mdinfo *info, - int *fdlist, int cnt, char *backup_file, int verbose); - extern int Grow_continue(int mdfd, struct supertype *st, -- struct mdinfo *info, char *backup_file, -- int forked, int freeze_reshape); -+ struct mdinfo *info, int forked, struct context *c); - extern int Grow_consistency_policy(char *devname, int fd, - struct context *c, struct shape *s); - -@@ -1552,8 +1550,7 @@ extern int restore_backup(struct supertype *st, - int spares, - char **backup_filep, - int verbose); --extern int Grow_continue_command(char *devname, int fd, -- char *backup_file, int verbose); -+extern int Grow_continue_command(char *devname, int fd, struct context *c); - - extern int Assemble(struct supertype *st, char *mddev, - struct mddev_ident *ident, -diff --git a/super-intel.c b/super-intel.c -index 1faab607..417da267 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -12153,10 +12153,8 @@ exit: - } - - static int imsm_reshape_super(struct supertype *st, unsigned long long size, -- int level, -- int layout, int chunksize, int raid_disks, -- int delta_disks, char *backup, char *dev, -- int direction, int verbose) -+ int level, int layout, int chunksize, int raid_disks, -+ int delta_disks, char *dev, int direction, struct context *c) - { - int ret_val = 1; - struct geo_params geo; --- -2.41.0 - diff --git a/0053-mdadm-use-struct-context-in-reshape_super.patch b/0053-mdadm-use-struct-context-in-reshape_super.patch deleted file mode 100644 index ebe0810..0000000 --- a/0053-mdadm-use-struct-context-in-reshape_super.patch +++ /dev/null @@ -1,296 +0,0 @@ -From 0acda7053df653022e46fa3b7caf1f4d4ba31a66 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:14 +0200 -Subject: [PATCH 53/66] mdadm: use struct context in reshape_super() - -reshape_super() takes too many arguments. Change passing params in -favor of single struct. - -Add devname pointer and change direction members to struct shape -and use it for reshape_super(). - -Create reshape_array_size() and reshape_array_non_size() to handle -reshape_super() calls. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 93 +++++++++++++++++++++++++++++++++++++-------------- - mdadm.h | 18 +++++----- - super-intel.c | 43 +++++++++++++++--------- - 3 files changed, 105 insertions(+), 49 deletions(-) - -diff --git a/Grow.c b/Grow.c -index f477b438..87ed9214 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -862,9 +862,7 @@ static void wait_reshape(struct mdinfo *sra) - close(fd); - } - --static int reshape_super(struct supertype *st, unsigned long long size, -- int level, int layout, int chunksize, int raid_disks, -- int delta_disks, char *dev, int direction, struct context *c) -+static int reshape_super(struct supertype *st, struct shape *shape, struct context *c) - { - /* nothing extra to check in the native case */ - if (!st->ss->external) -@@ -875,8 +873,65 @@ static int reshape_super(struct supertype *st, unsigned long long size, - return 1; - } - -- return st->ss->reshape_super(st, size, level, layout, chunksize, raid_disks, -- delta_disks, dev, direction, c); -+ return st->ss->reshape_super(st, shape, c); -+} -+ -+/** -+ * reshape_super_size() - Reshape array, size only. -+ * -+ * @st: supertype. -+ * @devname: device name. -+ * @size: component size. -+ * @dir metadata changes direction -+ * Returns: 0 on success, 1 otherwise. -+ * -+ * This function is solely used to change size of the volume. -+ * Setting size is not valid for container. -+ * Size is only change that can be rolled back, thus the @dir param. -+ */ -+static int reshape_super_size(struct supertype *st, char *devname, -+ unsigned long long size, change_dir_t direction, -+ struct context *c) -+{ -+ struct shape shape = {0}; -+ -+ shape.level = UnSet; -+ shape.layout = UnSet; -+ shape.delta_disks = UnSet; -+ shape.dev = devname; -+ shape.size = size; -+ shape.direction = direction; -+ -+ return reshape_super(st, &shape, c); -+} -+ -+/** -+ * reshape_super_non_size() - Reshape array, non size changes. -+ * -+ * @st: supertype. -+ * @devname: device name. -+ * @info: superblock info. -+ * Returns: 0 on success, 1 otherwise. -+ * -+ * This function is used for any external array changes but size. -+ * It handles both volumes and containers. -+ * For changes other than size, rollback is not possible. -+ */ -+static int reshape_super_non_size(struct supertype *st, char *devname, -+ struct mdinfo *info, struct context *c) -+{ -+ struct shape shape = {0}; -+ /* Size already set to zero, not updating size */ -+ shape.level = info->new_level; -+ shape.layout = info->new_layout; -+ shape.chunk = info->new_chunk; -+ shape.raiddisks = info->array.raid_disks; -+ shape.delta_disks = info->delta_disks; -+ shape.dev = devname; -+ /* Rollback not possible for non size changes */ -+ shape.direction = APPLY_METADATA_CHANGES; -+ -+ return reshape_super(st, &shape, c); - } - - static void sync_metadata(struct supertype *st) -@@ -1979,9 +2034,8 @@ int Grow_reshape(char *devname, int fd, - } - - /* ========= set size =============== */ -- if (s->size > 0 && -- (s->size == MAX_SIZE || s->size != (unsigned)array.size)) { -- unsigned long long orig_size = get_component_size(fd)/2; -+ if (s->size > 0 && (s->size == MAX_SIZE || s->size != (unsigned)array.size)) { -+ unsigned long long orig_size = get_component_size(fd) / 2; - unsigned long long min_csize; - struct mdinfo *mdi; - int raid0_takeover = 0; -@@ -2001,8 +2055,7 @@ int Grow_reshape(char *devname, int fd, - goto release; - } - -- if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet, -- devname, APPLY_METADATA_CHANGES, c)) { -+ if (reshape_super_size(st, devname, s->size, APPLY_METADATA_CHANGES, c)) { - rv = 1; - goto release; - } -@@ -2120,8 +2173,8 @@ size_change_error: - int err = errno; - - /* restore metadata */ -- if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0, UnSet, -- devname, ROLLBACK_METADATA_CHANGES, c) == 0) -+ if (reshape_super_size(st, devname, orig_size, -+ ROLLBACK_METADATA_CHANGES, c) == 0) - sync_metadata(st); - pr_err("Cannot set device size for %s: %s\n", - devname, strerror(err)); -@@ -2351,11 +2404,7 @@ size_change_error: - /* Impose these changes on a single array. First - * check that the metadata is OK with the change. - */ -- -- if (reshape_super(st, 0, info.new_level, -- info.new_layout, info.new_chunk, -- info.array.raid_disks, info.delta_disks, -- devname, APPLY_METADATA_CHANGES, c)) { -+ if (reshape_super_non_size(st, devname, &info, c)) { - rv = 1; - goto release; - } -@@ -3668,14 +3717,8 @@ int reshape_container(char *container, char *devname, - int rv = restart; - char last_devnm[32] = ""; - -- /* component_size is not meaningful for a container, -- * so pass '0' meaning 'no change' -- */ -- if (!restart && -- reshape_super(st, 0, info->new_level, -- info->new_layout, info->new_chunk, -- info->array.raid_disks, info->delta_disks, -- devname, APPLY_METADATA_CHANGES, c)) { -+ /* component_size is not meaningful for a container */ -+ if (!restart && reshape_super_non_size(st, devname, info, c)) { - unfreeze(st); - return 1; - } -diff --git a/mdadm.h b/mdadm.h -index 0ade4beb..2ff3e463 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -594,6 +594,11 @@ enum flag_mode { - FlagDefault, FlagSet, FlagClear, - }; - -+typedef enum { -+ ROLLBACK_METADATA_CHANGES, -+ APPLY_METADATA_CHANGES -+} change_dir_t; -+ - /* structures read from config file */ - /* List of mddevice names and identifiers - * Identifiers can be: -@@ -667,7 +672,9 @@ struct context { - }; - - struct shape { -+ char *dev; - int raiddisks; -+ int delta_disks; - int sparedisks; - int journaldisks; - int level; -@@ -682,6 +689,7 @@ struct shape { - unsigned long long size; - unsigned long long data_offset; - int consistency_policy; -+ change_dir_t direction; - }; - - /* List of device names - wildcards expanded */ -@@ -1229,14 +1237,8 @@ extern struct superswitch { - * initialized to indicate if reshape is being performed at the - * container or subarray level - */ --#define APPLY_METADATA_CHANGES 1 --#define ROLLBACK_METADATA_CHANGES 0 -- -- int (*reshape_super)(struct supertype *st, -- unsigned long long size, int level, -- int layout, int chunksize, int raid_disks, -- int delta_disks, char *dev, int direction, -- struct context *c); -+ -+ int (*reshape_super)(struct supertype *st, struct shape *shape, struct context *c); - int (*manage_reshape)( /* optional */ - int afd, struct mdinfo *sra, struct reshape *reshape, - struct supertype *st, unsigned long blocks, -diff --git a/super-intel.c b/super-intel.c -index 417da267..1a8a7b12 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -12152,26 +12152,37 @@ exit: - return ret_val; - } - --static int imsm_reshape_super(struct supertype *st, unsigned long long size, -- int level, int layout, int chunksize, int raid_disks, -- int delta_disks, char *dev, int direction, struct context *c) -+/** -+ * shape_to_geo() - fill geo_params from shape. -+ * -+ * @shape: array details. -+ * @geo: new geometry params. -+ * Returns: 0 on success, 1 otherwise. -+ */ -+static void shape_to_geo(struct shape *shape, struct geo_params *geo) -+{ -+ assert(shape); -+ assert(geo); -+ -+ geo->dev_name = shape->dev; -+ geo->size = shape->size; -+ geo->level = shape->level; -+ geo->layout = shape->layout; -+ geo->chunksize = shape->chunk; -+ geo->raid_disks = shape->raiddisks; -+} -+ -+static int imsm_reshape_super(struct supertype *st, struct shape *shape, struct context *c) - { - int ret_val = 1; -- struct geo_params geo; -+ struct geo_params geo = {0}; - - dprintf("(enter)\n"); - -- memset(&geo, 0, sizeof(struct geo_params)); -- -- geo.dev_name = dev; -+ shape_to_geo(shape, &geo); - strcpy(geo.devnm, st->devnm); -- geo.size = size; -- geo.level = level; -- geo.layout = layout; -- geo.chunksize = chunksize; -- geo.raid_disks = raid_disks; -- if (delta_disks != UnSet) -- geo.raid_disks += delta_disks; -+ if (shape->delta_disks != UnSet) -+ geo.raid_disks += shape->delta_disks; - - dprintf("for level : %i\n", geo.level); - dprintf("for raid_disks : %i\n", geo.raid_disks); -@@ -12182,7 +12193,7 @@ static int imsm_reshape_super(struct supertype *st, unsigned long long size, - int old_raid_disks = 0; - - if (imsm_reshape_is_allowed_on_container( -- st, &geo, &old_raid_disks, direction)) { -+ st, &geo, &old_raid_disks, shape->direction)) { - struct imsm_update_reshape *u = NULL; - int len; - -@@ -12236,7 +12247,7 @@ static int imsm_reshape_super(struct supertype *st, unsigned long long size, - goto exit_imsm_reshape_super; - } - super->current_vol = dev->index; -- change = imsm_analyze_change(st, &geo, direction); -+ change = imsm_analyze_change(st, &geo, shape->direction); - switch (change) { - case CH_TAKEOVER: - ret_val = imsm_takeover(st, &geo); --- -2.41.0 - diff --git a/0054-imsm-add-support-for-literal-RAID-10.patch b/0054-imsm-add-support-for-literal-RAID-10.patch deleted file mode 100644 index f611b7c..0000000 --- a/0054-imsm-add-support-for-literal-RAID-10.patch +++ /dev/null @@ -1,184 +0,0 @@ -From 27550b13297adbdefe42fe4eb785b7fde1c0ed91 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:15 +0200 -Subject: [PATCH 54/66] imsm: add support for literal RAID 10 - -As for now, IMSM supports only 4 drive RAID 1+0. This patch is first in -series to add support for literal RAID 10 (with more than 4 drives) to -imsm. - -Allow setting RAID 10 as raid level for imsm arrays. - -Add update_imsm_raid_level() to handle raid level updates. Set RAID10 as -default level for imsm R0 to R10 migrations. Replace magic numbers with -defined values for RAID level checks/assigns. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 67 ++++++++++++++++++++++++++++++++++++--------------- - 1 file changed, 48 insertions(+), 19 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 1a8a7b12..a7efc8df 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -166,7 +166,8 @@ struct imsm_map { - __u8 raid_level; - #define IMSM_T_RAID0 0 - #define IMSM_T_RAID1 1 --#define IMSM_T_RAID5 5 /* since metadata version 1.2.02 ? */ -+#define IMSM_T_RAID5 5 -+#define IMSM_T_RAID10 10 - __u8 num_members; /* number of member disks */ - __u8 num_domains; /* number of parity domains */ - __u8 failed_disk_num; /* valid only when state is degraded */ -@@ -1259,14 +1260,42 @@ static int get_imsm_disk_slot(struct imsm_map *map, const unsigned int idx) - - return IMSM_STATUS_ERROR; - } -+/** -+ * update_imsm_raid_level() - update raid level appropriately in &imsm_map. -+ * @map: &imsm_map pointer. -+ * @new_level: MD style level. -+ * -+ * For backward compatibility reasons we need to differentiate RAID10. -+ * In the past IMSM RAID10 was presented as RAID1. -+ * Keep compatibility unless it is not explicitly updated by UEFI driver. -+ * -+ * Routine needs num_members to be set and (optionally) raid_level. -+ */ -+static void update_imsm_raid_level(struct imsm_map *map, int new_level) -+{ -+ if (new_level != IMSM_T_RAID10) { -+ map->raid_level = new_level; -+ return; -+ } -+ -+ if (map->num_members == 4) { -+ if (map->raid_level == IMSM_T_RAID10 || map->raid_level == IMSM_T_RAID1) -+ return; -+ -+ map->raid_level = IMSM_T_RAID1; -+ return; -+ } -+ -+ map->raid_level = IMSM_T_RAID10; -+} - - static int get_imsm_raid_level(struct imsm_map *map) - { -- if (map->raid_level == 1) { -+ if (map->raid_level == IMSM_T_RAID1) { - if (map->num_members == 2) -- return 1; -+ return IMSM_T_RAID1; - else -- return 10; -+ return IMSM_T_RAID10; - } - - return map->raid_level; -@@ -5678,7 +5707,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - set_pba_of_lba0(map, super->create_offset); - map->blocks_per_strip = __cpu_to_le16(info_to_blocks_per_strip(info)); - map->failed_disk_num = ~0; -- if (info->level > 0) -+ if (info->level > IMSM_T_RAID0) - map->map_state = (info->state ? IMSM_T_STATE_NORMAL - : IMSM_T_STATE_UNINITIALIZED); - else -@@ -5686,16 +5715,15 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - IMSM_T_STATE_NORMAL; - map->ddf = 1; - -- if (info->level == 1 && info->raid_disks > 2) { -+ if (info->level == IMSM_T_RAID1 && info->raid_disks > 2) { - free(dev); - free(dv); -- pr_err("imsm does not support more than 2 disksin a raid1 volume\n"); -+ pr_err("imsm does not support more than 2 disks in a raid1 volume\n"); - return 0; - } -+ map->num_members = info->raid_disks; - -- map->raid_level = info->level; -- if (info->level == 10) -- map->raid_level = 1; -+ update_imsm_raid_level(map, info->level); - set_num_domains(map); - - size_per_member += NUM_BLOCKS_DIRTY_STRIPE_REGION; -@@ -5703,7 +5731,6 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - size_per_member / - BLOCKS_PER_KB)); - -- map->num_members = info->raid_disks; - update_num_data_stripes(map, array_blocks); - for (i = 0; i < map->num_members; i++) { - /* initialized in add_to_super */ -@@ -8275,7 +8302,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - info_d->data_offset = pba_of_lba0(map); - info_d->component_size = calc_component_size(map, dev); - -- if (map->raid_level == 5) { -+ if (map->raid_level == IMSM_T_RAID5) { - info_d->ppl_sector = this->ppl_sector; - info_d->ppl_size = this->ppl_size; - if (this->consistency_policy == CONSISTENCY_POLICY_PPL && -@@ -9533,7 +9560,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration * - } - - to_state = map->map_state; -- if ((u->new_level == 5) && (map->raid_level == 0)) { -+ if ((u->new_level == IMSM_T_RAID5) && (map->raid_level == IMSM_T_RAID0)) { - map->num_members++; - /* this should not happen */ - if (u->new_disks[0] < 0) { -@@ -9544,11 +9571,13 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration * - to_state = IMSM_T_STATE_NORMAL; - } - migrate(new_dev, super, to_state, MIGR_GEN_MIGR); -+ - if (u->new_level > -1) -- map->raid_level = u->new_level; -+ update_imsm_raid_level(map, u->new_level); -+ - migr_map = get_imsm_map(new_dev, MAP_1); -- if ((u->new_level == 5) && -- (migr_map->raid_level == 0)) { -+ if ((u->new_level == IMSM_T_RAID5) && -+ (migr_map->raid_level == IMSM_T_RAID0)) { - int ord = map->num_members - 1; - migr_map->num_members--; - if (u->new_disks[0] < 0) -@@ -9584,7 +9613,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration * - - /* add disk - */ -- if (u->new_level != 5 || migr_map->raid_level != 0 || -+ if (u->new_level != IMSM_T_RAID5 || migr_map->raid_level != IMSM_T_RAID0 || - migr_map->raid_level == map->raid_level) - goto skip_disk_add; - -@@ -9963,7 +9992,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u, - /* update map */ - map->num_members /= map->num_domains; - map->map_state = IMSM_T_STATE_NORMAL; -- map->raid_level = 0; -+ update_imsm_raid_level(map, IMSM_T_RAID0); - set_num_domains(map); - update_num_data_stripes(map, imsm_dev_size(dev)); - map->failed_disk_num = -1; -@@ -10007,7 +10036,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u, - map = get_imsm_map(dev_new, MAP_0); - - map->map_state = IMSM_T_STATE_DEGRADED; -- map->raid_level = 1; -+ update_imsm_raid_level(map, IMSM_T_RAID10); - set_num_domains(map); - map->num_members = map->num_members * map->num_domains; - update_num_data_stripes(map, imsm_dev_size(dev)); --- -2.41.0 - diff --git a/0055-imsm-refactor-RAID-level-handling.patch b/0055-imsm-refactor-RAID-level-handling.patch deleted file mode 100644 index 8b1689a..0000000 --- a/0055-imsm-refactor-RAID-level-handling.patch +++ /dev/null @@ -1,345 +0,0 @@ -From 191e6ddb1388236c5c54baf5020a87c996be941f Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:16 +0200 -Subject: [PATCH 55/66] imsm: refactor RAID level handling - -Add imsm_level_ops struct for better handling and unifying raid level -support. Add helper methods and move "orom_has_raid[...]" methods from -header to source file. - -RAID 1e is not supported under Linux, remove RAID 1e associated code. - -Refactor imsm_analyze_change() and is_raid_level_supported(). -Remove hardcoded check for 4 drives and make devNumChange a multiplier -for RAID 10. - -Refactor printing supported raid levels. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - platform-intel.c | 57 ++++++++++++++++++++++++ - platform-intel.h | 32 ++++++-------- - super-intel.c | 111 ++++++++++++++++++++++++++++------------------- - 3 files changed, 138 insertions(+), 62 deletions(-) - -diff --git a/platform-intel.c b/platform-intel.c -index ac282bc5..40e8fb82 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -32,6 +32,63 @@ - - #define NVME_SUBSYS_PATH "/sys/devices/virtual/nvme-subsystem/" - -+static bool imsm_orom_has_raid0(const struct imsm_orom *orom) -+{ -+ return imsm_rlc_has_bit(orom, IMSM_OROM_RLC_RAID0); -+} -+ -+static bool imsm_orom_has_raid1(const struct imsm_orom *orom) -+{ -+ return imsm_rlc_has_bit(orom, IMSM_OROM_RLC_RAID1); -+} -+ -+static bool imsm_orom_has_raid10(const struct imsm_orom *orom) -+{ -+ return imsm_rlc_has_bit(orom, IMSM_OROM_RLC_RAID10); -+} -+ -+static bool imsm_orom_has_raid5(const struct imsm_orom *orom) -+{ -+ return imsm_rlc_has_bit(orom, IMSM_OROM_RLC_RAID5); -+} -+ -+/* IMSM platforms do not define how many disks are allowed for each level, -+ * but there are some global limitations we need to follow. -+ */ -+static bool imsm_orom_support_raid_disks_count_raid0(const int raid_disks) -+{ -+ return true; -+} -+ -+static bool imsm_orom_support_raid_disks_count_raid1(const int raid_disks) -+{ -+ if (raid_disks == 2) -+ return true; -+ return false; -+} -+ -+static bool imsm_orom_support_raid_disks_count_raid5(const int raid_disks) -+{ -+ if (raid_disks > 2) -+ return true; -+ return false; -+} -+ -+static bool imsm_orom_support_raid_disks_count_raid10(const int raid_disks) -+{ -+ if (raid_disks == 4) -+ return true; -+ return false; -+} -+ -+struct imsm_level_ops imsm_level_ops[] = { -+ {0, imsm_orom_has_raid0, imsm_orom_support_raid_disks_count_raid0, "raid0"}, -+ {1, imsm_orom_has_raid1, imsm_orom_support_raid_disks_count_raid1, "raid1"}, -+ {5, imsm_orom_has_raid5, imsm_orom_support_raid_disks_count_raid5, "raid5"}, -+ {10, imsm_orom_has_raid10, imsm_orom_support_raid_disks_count_raid10, "raid10"}, -+ {-1, NULL, NULL, NULL} -+}; -+ - static int devpath_to_ll(const char *dev_path, const char *entry, - unsigned long long *val); - -diff --git a/platform-intel.h b/platform-intel.h -index 3c2bc595..dcc5aaa7 100644 ---- a/platform-intel.h -+++ b/platform-intel.h -@@ -109,25 +109,21 @@ struct imsm_orom { - #define IMSM_OROM_CAPABILITIES_TPV (1 << 10) - } __attribute__((packed)); - --static inline int imsm_orom_has_raid0(const struct imsm_orom *orom) --{ -- return !!(orom->rlc & IMSM_OROM_RLC_RAID0); --} --static inline int imsm_orom_has_raid1(const struct imsm_orom *orom) --{ -- return !!(orom->rlc & IMSM_OROM_RLC_RAID1); --} --static inline int imsm_orom_has_raid1e(const struct imsm_orom *orom) --{ -- return !!(orom->rlc & IMSM_OROM_RLC_RAID1E); --} --static inline int imsm_orom_has_raid10(const struct imsm_orom *orom) --{ -- return !!(orom->rlc & IMSM_OROM_RLC_RAID10); --} --static inline int imsm_orom_has_raid5(const struct imsm_orom *orom) -+/* IMSM metadata requirements for each level */ -+struct imsm_level_ops { -+ int level; -+ bool (*is_level_supported)(const struct imsm_orom *); -+ bool (*is_raiddisks_count_supported)(const int); -+ char *name; -+}; -+ -+extern struct imsm_level_ops imsm_level_ops[]; -+ -+static inline bool imsm_rlc_has_bit(const struct imsm_orom *orom, const unsigned short bit) - { -- return !!(orom->rlc & IMSM_OROM_RLC_RAID5); -+ if (orom->rlc & bit) -+ return true; -+ return false; - } - - /** -diff --git a/super-intel.c b/super-intel.c -index a7efc8df..da17265d 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2681,6 +2681,15 @@ static int ahci_get_port_count(const char *hba_path, int *port_count) - return host_base; - } - -+static void print_imsm_level_capability(const struct imsm_orom *orom) -+{ -+ int idx; -+ -+ for (idx = 0; imsm_level_ops[idx].name; idx++) -+ if (imsm_level_ops[idx].is_level_supported(orom)) -+ printf("%s ", imsm_level_ops[idx].name); -+} -+ - static void print_imsm_capability(const struct imsm_orom *orom) - { - printf(" Platform : Intel(R) "); -@@ -2699,12 +2708,11 @@ static void print_imsm_capability(const struct imsm_orom *orom) - printf(" Version : %d.%d.%d.%d\n", orom->major_ver, - orom->minor_ver, orom->hotfix_ver, orom->build); - } -- printf(" RAID Levels :%s%s%s%s%s\n", -- imsm_orom_has_raid0(orom) ? " raid0" : "", -- imsm_orom_has_raid1(orom) ? " raid1" : "", -- imsm_orom_has_raid1e(orom) ? " raid1e" : "", -- imsm_orom_has_raid10(orom) ? " raid10" : "", -- imsm_orom_has_raid5(orom) ? " raid5" : ""); -+ -+ printf(" RAID Levels : "); -+ print_imsm_level_capability(orom); -+ printf("\n"); -+ - printf(" Chunk Sizes :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", - imsm_orom_has_chunk(orom, 2) ? " 2k" : "", - imsm_orom_has_chunk(orom, 4) ? " 4k" : "", -@@ -2739,12 +2747,11 @@ static void print_imsm_capability_export(const struct imsm_orom *orom) - if (orom->major_ver || orom->minor_ver || orom->hotfix_ver || orom->build) - printf("IMSM_VERSION=%d.%d.%d.%d\n", orom->major_ver, orom->minor_ver, - orom->hotfix_ver, orom->build); -- printf("IMSM_SUPPORTED_RAID_LEVELS=%s%s%s%s%s\n", -- imsm_orom_has_raid0(orom) ? "raid0 " : "", -- imsm_orom_has_raid1(orom) ? "raid1 " : "", -- imsm_orom_has_raid1e(orom) ? "raid1e " : "", -- imsm_orom_has_raid5(orom) ? "raid10 " : "", -- imsm_orom_has_raid10(orom) ? "raid5 " : ""); -+ -+ printf("IMSM_SUPPORTED_RAID_LEVELS="); -+ print_imsm_level_capability(orom); -+ printf("\n"); -+ - printf("IMSM_SUPPORTED_CHUNK_SIZES=%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", - imsm_orom_has_chunk(orom, 2) ? "2k " : "", - imsm_orom_has_chunk(orom, 4) ? "4k " : "", -@@ -6992,26 +6999,41 @@ static unsigned long long merge_extents(struct intel_super *super, const bool ex - return free_size - reservation_size; - } - --static int is_raid_level_supported(const struct imsm_orom *orom, int level, int raiddisks) -+/** -+ * is_raid_level_supported() - check if this count of drives and level is supported by platform. -+ * @orom: hardware properties, could be NULL. -+ * @level: requested raid level. -+ * @raiddisks: requested disk count. -+ * -+ * IMSM UEFI/OROM does not provide information about supported count of raid disks -+ * for particular level. That is why it is hardcoded. -+ * It is recommended to not allow of usage other levels than supported, -+ * IMSM code is not tested against different level implementations. -+ * -+ * Return: true if supported, false otherwise. -+ */ -+static bool is_raid_level_supported(const struct imsm_orom *orom, int level, int raiddisks) - { -- if (level < 0 || level == 6 || level == 4) -- return 0; -+ int idx; - -- /* if we have an orom prevent invalid raid levels */ -- if (orom) -- switch (level) { -- case 0: return imsm_orom_has_raid0(orom); -- case 1: -- if (raiddisks > 2) -- return imsm_orom_has_raid1e(orom); -- return imsm_orom_has_raid1(orom) && raiddisks == 2; -- case 10: return imsm_orom_has_raid10(orom) && raiddisks == 4; -- case 5: return imsm_orom_has_raid5(orom) && raiddisks > 2; -- } -- else -- return 1; /* not on an Intel RAID platform so anything goes */ -+ for (idx = 0; imsm_level_ops[idx].name; idx++) { -+ if (imsm_level_ops[idx].level == level) -+ break; -+ } - -- return 0; -+ if (!imsm_level_ops[idx].name) -+ return false; -+ -+ if (!imsm_level_ops[idx].is_raiddisks_count_supported(raiddisks)) -+ return false; -+ -+ if (!orom) -+ return true; -+ -+ if (imsm_level_ops[idx].is_level_supported(orom)) -+ return true; -+ -+ return false; - } - - static int -@@ -11962,18 +11984,17 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - int change = -1; - int check_devs = 0; - int chunk; -- /* number of added/removed disks in operation result */ -- int devNumChange = 0; - /* imsm compatible layout value for array geometry verification */ - int imsm_layout = -1; -+ int raid_disks = geo->raid_disks; - imsm_status_t rv; - - getinfo_super_imsm_volume(st, &info, NULL); -- if (geo->level != info.array.level && geo->level >= 0 && -+ if (geo->level != info.array.level && geo->level >= IMSM_T_RAID0 && - geo->level != UnSet) { - switch (info.array.level) { -- case 0: -- if (geo->level == 5) { -+ case IMSM_T_RAID0: -+ if (geo->level == IMSM_T_RAID5) { - change = CH_MIGRATION; - if (geo->layout != ALGORITHM_LEFT_ASYMMETRIC) { - pr_err("Error. Requested Layout not supported (left-asymmetric layout is supported only)!\n"); -@@ -11982,20 +12003,20 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - } - imsm_layout = geo->layout; - check_devs = 1; -- devNumChange = 1; /* parity disk added */ -- } else if (geo->level == 10) { -+ raid_disks += 1; /* parity disk added */ -+ } else if (geo->level == IMSM_T_RAID10) { - change = CH_TAKEOVER; - check_devs = 1; -- devNumChange = 2; /* two mirrors added */ -+ raid_disks *= 2; /* mirrors added */ - imsm_layout = 0x102; /* imsm supported layout */ - } - break; -- case 1: -- case 10: -+ case IMSM_T_RAID1: -+ case IMSM_T_RAID10: - if (geo->level == 0) { - change = CH_TAKEOVER; - check_devs = 1; -- devNumChange = -(geo->raid_disks/2); -+ raid_disks /= 2; - imsm_layout = 0; /* imsm raid0 layout */ - } - break; -@@ -12011,10 +12032,10 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - if (geo->layout != info.array.layout && - (geo->layout != UnSet && geo->layout != -1)) { - change = CH_MIGRATION; -- if (info.array.layout == 0 && info.array.level == 5 && -+ if (info.array.layout == 0 && info.array.level == IMSM_T_RAID5 && - geo->layout == 5) { - /* reshape 5 -> 4 */ -- } else if (info.array.layout == 5 && info.array.level == 5 && -+ } else if (info.array.layout == 5 && info.array.level == IMSM_T_RAID5 && - geo->layout == 0) { - /* reshape 4 -> 5 */ - geo->layout = 0; -@@ -12033,7 +12054,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - - if (geo->chunksize > 0 && geo->chunksize != UnSet && - geo->chunksize != info.array.chunk_size) { -- if (info.array.level == 10) { -+ if (info.array.level == IMSM_T_RAID10) { - pr_err("Error. Chunk size change for RAID 10 is not supported.\n"); - change = -1; - goto analyse_change_exit; -@@ -12058,14 +12079,16 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - rv = imsm_analyze_expand(st, geo, &info, direction); - if (rv != IMSM_STATUS_OK) - goto analyse_change_exit; -+ raid_disks = geo->raid_disks; - change = CH_ARRAY_SIZE; - } - - chunk = geo->chunksize / 1024; -+ - if (!validate_geometry_imsm(st, - geo->level, - imsm_layout, -- geo->raid_disks + devNumChange, -+ raid_disks, - &chunk, - geo->size, INVALID_SECTORS, - 0, 0, info.consistency_policy, 1)) --- -2.41.0 - diff --git a/0056-imsm-bump-minimal-version.patch b/0056-imsm-bump-minimal-version.patch deleted file mode 100644 index fe78a92..0000000 --- a/0056-imsm-bump-minimal-version.patch +++ /dev/null @@ -1,180 +0,0 @@ -From ec7e873ba6643a9e5e74311b00ede66a3d2e36c9 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:17 +0200 -Subject: [PATCH 56/66] imsm: bump minimal version - -IMSM version 1.3 (called ATTRIBS) brought attributes used to define array -properties which require support in driver. The goal of this change was -to avoid changing version when adding new features. - -For some reasons migration has never been completed and currently (after -10 years of implementing) IMSM can use older versions. - -It is right time to finally switch it. There is no point in using old -versions, use 1.3.00 as minimal one. - -Define JD_VERSION used by Windows driver. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 87 ++++++++++++++++++++++----------------------------- - 1 file changed, 38 insertions(+), 49 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index da17265d..4b168add 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -32,14 +32,19 @@ - /* MPB == Metadata Parameter Block */ - #define MPB_SIGNATURE "Intel Raid ISM Cfg Sig. " - #define MPB_SIG_LEN (strlen(MPB_SIGNATURE)) --#define MPB_VERSION_RAID0 "1.0.00" --#define MPB_VERSION_RAID1 "1.1.00" --#define MPB_VERSION_MANY_VOLUMES_PER_ARRAY "1.2.00" --#define MPB_VERSION_3OR4_DISK_ARRAY "1.2.01" --#define MPB_VERSION_RAID5 "1.2.02" --#define MPB_VERSION_5OR6_DISK_ARRAY "1.2.04" --#define MPB_VERSION_CNG "1.2.06" -+ -+/* Legacy IMSM versions: -+ * MPB_VERSION_RAID0 1.0.00 -+ * MPB_VERSION_RAID1 1.1.00 -+ * MPB_VERSION_MANY_VOLUMES_PER_ARRAY 1.2.00 -+ * MPB_VERSION_3OR4_DISK_ARRAY 1.2.01 -+ * MPB_VERSION_RAID5 1.2.02 -+ * MPB_VERSION_5OR6_DISK_ARRAY 1.2.04 -+ * MPB_VERSION_CNG 1.2.06 -+ */ -+ - #define MPB_VERSION_ATTRIBS "1.3.00" -+#define MPB_VERSION_ATTRIBS_JD "2.0.00" - #define MAX_SIGNATURE_LENGTH 32 - #define MAX_RAID_SERIAL_LEN 16 - -@@ -5512,51 +5517,46 @@ static unsigned long long info_to_blocks_per_member(mdu_array_info_t *info, - return (size * 2) & ~(info_to_blocks_per_strip(info) - 1); - } - -+static void imsm_write_signature(struct imsm_super *mpb) -+{ -+ /* It is safer to eventually truncate version rather than left it not NULL ended */ -+ snprintf((char *) mpb->sig, MAX_SIGNATURE_LENGTH, MPB_SIGNATURE MPB_VERSION_ATTRIBS); -+} -+ - static void imsm_update_version_info(struct intel_super *super) - { - /* update the version and attributes */ - struct imsm_super *mpb = super->anchor; -- char *version; - struct imsm_dev *dev; - struct imsm_map *map; - int i; - -+ mpb->attributes |= MPB_ATTRIB_CHECKSUM_VERIFY; -+ - for (i = 0; i < mpb->num_raid_devs; i++) { - dev = get_imsm_dev(super, i); - map = get_imsm_map(dev, MAP_0); -+ - if (__le32_to_cpu(dev->size_high) > 0) - mpb->attributes |= MPB_ATTRIB_2TB; - -- /* FIXME detect when an array spans a port multiplier */ -- #if 0 -- mpb->attributes |= MPB_ATTRIB_PM; -- #endif -- -- if (mpb->num_raid_devs > 1 || -- mpb->attributes != MPB_ATTRIB_CHECKSUM_VERIFY) { -- version = MPB_VERSION_ATTRIBS; -- switch (get_imsm_raid_level(map)) { -- case 0: mpb->attributes |= MPB_ATTRIB_RAID0; break; -- case 1: mpb->attributes |= MPB_ATTRIB_RAID1; break; -- case 10: mpb->attributes |= MPB_ATTRIB_RAID10; break; -- case 5: mpb->attributes |= MPB_ATTRIB_RAID5; break; -- } -- } else { -- if (map->num_members >= 5) -- version = MPB_VERSION_5OR6_DISK_ARRAY; -- else if (dev->status == DEV_CLONE_N_GO) -- version = MPB_VERSION_CNG; -- else if (get_imsm_raid_level(map) == 5) -- version = MPB_VERSION_RAID5; -- else if (map->num_members >= 3) -- version = MPB_VERSION_3OR4_DISK_ARRAY; -- else if (get_imsm_raid_level(map) == 1) -- version = MPB_VERSION_RAID1; -- else -- version = MPB_VERSION_RAID0; -+ switch (get_imsm_raid_level(map)) { -+ case IMSM_T_RAID0: -+ mpb->attributes |= MPB_ATTRIB_RAID0; -+ break; -+ case IMSM_T_RAID1: -+ mpb->attributes |= MPB_ATTRIB_RAID1; -+ break; -+ case IMSM_T_RAID5: -+ mpb->attributes |= MPB_ATTRIB_RAID5; -+ break; -+ case IMSM_T_RAID10: -+ mpb->attributes |= MPB_ATTRIB_RAID10; -+ break; - } -- strcpy(((char *) mpb->sig) + strlen(MPB_SIGNATURE), version); - } -+ -+ imsm_write_signature(mpb); - } - - /** -@@ -5785,7 +5785,6 @@ static int init_super_imsm(struct supertype *st, mdu_array_info_t *info, - struct intel_super *super; - struct imsm_super *mpb; - size_t mpb_size; -- char *version; - - if (data_offset != INVALID_SECTORS) { - pr_err("data-offset not supported by imsm\n"); -@@ -5828,13 +5827,7 @@ static int init_super_imsm(struct supertype *st, mdu_array_info_t *info, - return 0; - } - -- mpb->attributes = MPB_ATTRIB_CHECKSUM_VERIFY; -- -- version = (char *) mpb->sig; -- strcpy(version, MPB_SIGNATURE); -- version += strlen(MPB_SIGNATURE); -- strcpy(version, MPB_VERSION_RAID0); -- -+ imsm_update_version_info(super); - return 1; - } - -@@ -6208,7 +6201,6 @@ static union { - - static int write_super_imsm_spare(struct intel_super *super, struct dl *d) - { -- struct imsm_super *mpb = super->anchor; - struct imsm_super *spare = &spare_record.anchor; - __u32 sum; - -@@ -6217,14 +6209,11 @@ static int write_super_imsm_spare(struct intel_super *super, struct dl *d) - - spare->mpb_size = __cpu_to_le32(sizeof(struct imsm_super)); - spare->generation_num = __cpu_to_le32(1UL); -- spare->attributes = MPB_ATTRIB_CHECKSUM_VERIFY; - spare->num_disks = 1; - spare->num_raid_devs = 0; -- spare->cache_size = mpb->cache_size; - spare->pwr_cycle_count = __cpu_to_le32(1); - -- snprintf((char *) spare->sig, MAX_SIGNATURE_LENGTH, -- MPB_SIGNATURE MPB_VERSION_RAID0); -+ imsm_write_signature(spare); - - spare->disk[0] = d->disk; - if (__le32_to_cpu(d->disk.total_blocks_hi) > 0) --- -2.41.0 - diff --git a/0057-imsm-define-RAID_10-attribute.patch b/0057-imsm-define-RAID_10-attribute.patch deleted file mode 100644 index edb1c8e..0000000 --- a/0057-imsm-define-RAID_10-attribute.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 610fc2ee6fc09e828b14e8fa221b3f4f70fc7b2b Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:18 +0200 -Subject: [PATCH 57/66] imsm: define RAID_10 attribute - -Add MPB_ATTRIB_RAID10_EXT attribute to support RAID 10 -with more than 4 drives. - -Allow more than 4 drives in imsm_orom_support_raid_disks_raid10(). - -This is one of last patches for introducing R10D4+ to imsm. -Only small adjustments in reshape behaviours are needed. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - platform-intel.c | 3 ++- - super-intel.c | 5 +++++ - 2 files changed, 7 insertions(+), 1 deletion(-) - -diff --git a/platform-intel.c b/platform-intel.c -index 40e8fb82..15a9fa5a 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -76,7 +76,8 @@ static bool imsm_orom_support_raid_disks_count_raid5(const int raid_disks) - - static bool imsm_orom_support_raid_disks_count_raid10(const int raid_disks) - { -- if (raid_disks == 4) -+ /* raid_disks count must be higher than 4 and even */ -+ if (raid_disks >= 4 && (raid_disks & 1) == 0) - return true; - return false; - } -diff --git a/super-intel.c b/super-intel.c -index 4b168add..2d309316 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -62,6 +62,8 @@ - #define MPB_ATTRIB_RAIDCNG __cpu_to_le32(0x00000020) - /* supports expanded stripe sizes of 256K, 512K and 1MB */ - #define MPB_ATTRIB_EXP_STRIPE_SIZE __cpu_to_le32(0x00000040) -+/* supports RAID10 with more than 4 drives */ -+#define MPB_ATTRIB_RAID10_EXT __cpu_to_le32(0x00000080) - - /* The OROM Support RST Caching of Volumes */ - #define MPB_ATTRIB_NVM __cpu_to_le32(0x02000000) -@@ -89,6 +91,7 @@ - MPB_ATTRIB_RAID10 | \ - MPB_ATTRIB_RAID5 | \ - MPB_ATTRIB_EXP_STRIPE_SIZE | \ -+ MPB_ATTRIB_RAID10_EXT | \ - MPB_ATTRIB_BBM) - - /* Define attributes that are unused but not harmful */ -@@ -5552,6 +5555,8 @@ static void imsm_update_version_info(struct intel_super *super) - break; - case IMSM_T_RAID10: - mpb->attributes |= MPB_ATTRIB_RAID10; -+ if (map->num_members > 4) -+ mpb->attributes |= MPB_ATTRIB_RAID10_EXT; - break; - } - } --- -2.41.0 - diff --git a/0058-imsm-simplify-imsm_check_attributes.patch b/0058-imsm-simplify-imsm_check_attributes.patch deleted file mode 100644 index 8c1754c..0000000 --- a/0058-imsm-simplify-imsm_check_attributes.patch +++ /dev/null @@ -1,153 +0,0 @@ -From e0e56f4b2ed514f5049eb96b4ff8f7fdf30a4c49 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:19 +0200 -Subject: [PATCH 58/66] imsm: simplify imsm_check_attributes() - -imsm_check_attributes() is too complex for that it really does. - -Remove repeating code and simplify the function. -Fix function calls. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 106 ++++++++------------------------------------------ - 1 file changed, 16 insertions(+), 90 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 2d309316..d60915e8 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2135,91 +2135,18 @@ void convert_from_4k(struct intel_super *super) - mpb->check_sum = __gen_imsm_checksum(mpb); - } - --/******************************************************************************* -- * function: imsm_check_attributes -- * Description: Function checks if features represented by attributes flags -- * are supported by mdadm. -- * Parameters: -- * attributes - Attributes read from metadata -- * Returns: -- * 0 - passed attributes contains unsupported features flags -- * 1 - all features are supported -- ******************************************************************************/ --static int imsm_check_attributes(__u32 attributes) -+/** -+ * imsm_check_attributes() - Check if features represented by attributes flags are supported. -+ * -+ * @attributes: attributes read from metadata. -+ * Returns: true if all features are supported, false otherwise. -+ */ -+static bool imsm_check_attributes(__u32 attributes) - { -- int ret_val = 1; -- __u32 not_supported = MPB_ATTRIB_SUPPORTED^0xffffffff; -- -- not_supported &= ~MPB_ATTRIB_IGNORED; -- -- not_supported &= attributes; -- if (not_supported) { -- pr_err("(IMSM): Unsupported attributes : %x\n", -- (unsigned)__le32_to_cpu(not_supported)); -- if (not_supported & MPB_ATTRIB_CHECKSUM_VERIFY) { -- dprintf("\t\tMPB_ATTRIB_CHECKSUM_VERIFY \n"); -- not_supported ^= MPB_ATTRIB_CHECKSUM_VERIFY; -- } -- if (not_supported & MPB_ATTRIB_2TB) { -- dprintf("\t\tMPB_ATTRIB_2TB\n"); -- not_supported ^= MPB_ATTRIB_2TB; -- } -- if (not_supported & MPB_ATTRIB_RAID0) { -- dprintf("\t\tMPB_ATTRIB_RAID0\n"); -- not_supported ^= MPB_ATTRIB_RAID0; -- } -- if (not_supported & MPB_ATTRIB_RAID1) { -- dprintf("\t\tMPB_ATTRIB_RAID1\n"); -- not_supported ^= MPB_ATTRIB_RAID1; -- } -- if (not_supported & MPB_ATTRIB_RAID10) { -- dprintf("\t\tMPB_ATTRIB_RAID10\n"); -- not_supported ^= MPB_ATTRIB_RAID10; -- } -- if (not_supported & MPB_ATTRIB_RAID1E) { -- dprintf("\t\tMPB_ATTRIB_RAID1E\n"); -- not_supported ^= MPB_ATTRIB_RAID1E; -- } -- if (not_supported & MPB_ATTRIB_RAID5) { -- dprintf("\t\tMPB_ATTRIB_RAID5\n"); -- not_supported ^= MPB_ATTRIB_RAID5; -- } -- if (not_supported & MPB_ATTRIB_RAIDCNG) { -- dprintf("\t\tMPB_ATTRIB_RAIDCNG\n"); -- not_supported ^= MPB_ATTRIB_RAIDCNG; -- } -- if (not_supported & MPB_ATTRIB_BBM) { -- dprintf("\t\tMPB_ATTRIB_BBM\n"); -- not_supported ^= MPB_ATTRIB_BBM; -- } -- if (not_supported & MPB_ATTRIB_CHECKSUM_VERIFY) { -- dprintf("\t\tMPB_ATTRIB_CHECKSUM_VERIFY (== MPB_ATTRIB_LEGACY)\n"); -- not_supported ^= MPB_ATTRIB_CHECKSUM_VERIFY; -- } -- if (not_supported & MPB_ATTRIB_EXP_STRIPE_SIZE) { -- dprintf("\t\tMPB_ATTRIB_EXP_STRIP_SIZE\n"); -- not_supported ^= MPB_ATTRIB_EXP_STRIPE_SIZE; -- } -- if (not_supported & MPB_ATTRIB_2TB_DISK) { -- dprintf("\t\tMPB_ATTRIB_2TB_DISK\n"); -- not_supported ^= MPB_ATTRIB_2TB_DISK; -- } -- if (not_supported & MPB_ATTRIB_NEVER_USE2) { -- dprintf("\t\tMPB_ATTRIB_NEVER_USE2\n"); -- not_supported ^= MPB_ATTRIB_NEVER_USE2; -- } -- if (not_supported & MPB_ATTRIB_NEVER_USE) { -- dprintf("\t\tMPB_ATTRIB_NEVER_USE\n"); -- not_supported ^= MPB_ATTRIB_NEVER_USE; -- } -- -- if (not_supported) -- dprintf("(IMSM): Unknown attributes : %x\n", not_supported); -- -- ret_val = 0; -- } -+ if ((attributes & (MPB_ATTRIB_SUPPORTED | MPB_ATTRIB_IGNORED)) == attributes) -+ return true; - -- return ret_val; -+ return false; - } - - static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *map); -@@ -2247,11 +2174,10 @@ static void examine_super_imsm(struct supertype *st, char *homehost) - creation_time = __le64_to_cpu(mpb->creation_time); - printf(" Creation Time : %.24s\n", - creation_time ? ctime(&creation_time) : "Unknown"); -- printf(" Attributes : "); -- if (imsm_check_attributes(mpb->attributes)) -- printf("All supported\n"); -- else -- printf("not supported\n"); -+ -+ printf(" Attributes : %08x (%s)\n", mpb->attributes, -+ imsm_check_attributes(mpb->attributes) ? "supported" : "not supported"); -+ - getinfo_super_imsm(st, &info, NULL); - fname_from_uuid(&info, nbuf); - printf(" UUID : %s\n", nbuf + 5); -@@ -8182,9 +8108,9 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - int current_vol = super->current_vol; - - /* do not assemble arrays when not all attributes are supported */ -- if (imsm_check_attributes(mpb->attributes) == 0) { -+ if (imsm_check_attributes(mpb->attributes) == false) { - sb_errors = 1; -- pr_err("Unsupported attributes in IMSM metadata.Arrays activation is blocked.\n"); -+ pr_err("Unsupported attributes in IMSM metadata. Arrays activation is blocked.\n"); - } - - /* count spare devices, not used in maps --- -2.41.0 - diff --git a/0059-imsm-support-RAID-10-with-more-than-4-drives.patch b/0059-imsm-support-RAID-10-with-more-than-4-drives.patch deleted file mode 100644 index 6d6d245..0000000 --- a/0059-imsm-support-RAID-10-with-more-than-4-drives.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 44463edeb303a464c4a44fcea184b267aeb53302 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Mon, 29 Apr 2024 15:07:20 +0200 -Subject: [PATCH 59/66] imsm: support RAID 10 with more than 4 drives - -VROC UEFI driver does not support RAID 10 with more than 4 drives. -Add user prompts if such layout is being created and for R0->R10 -reshapes. - -Refactor ask() function: -- simplify the code, -- remove dialog reattempts, -- do no pass '?' sign on function calls, -- highlight default option on output. - -This patch completes adding support for R10D4+ to IMSM. - -Signed-off-by: Mateusz Kusiak -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 9 ++++++++- - super-intel.c | 14 ++++++++++++-- - util.c | 39 +++++++++++++++++++++++++-------------- - 3 files changed, 45 insertions(+), 17 deletions(-) - -diff --git a/Create.c b/Create.c -index d94253b1..d033eb68 100644 ---- a/Create.c -+++ b/Create.c -@@ -965,6 +965,13 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - return 1; - } - -+ if (st->ss == &super_imsm && s->level == 10 && s->raiddisks > 4) { -+ /* Print no matter runstop was specifed */ -+ pr_err("Warning! VROC UEFI driver does not support RAID10 in requested layout.\n"); -+ pr_err("Array won't be suitable as boot device.\n"); -+ warn = 1; -+ } -+ - if (!have_container && s->level > 0 && ((maxsize-s->size)*100 > maxsize)) { - if (c->runstop != 1 || c->verbose >= 0) - pr_err("largest drive (%s) exceeds size (%lluK) by more than 1%%\n", -@@ -984,7 +991,7 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - - if (warn) { - if (c->runstop!= 1) { -- if (!ask("Continue creating array? ")) { -+ if (!ask("Continue creating array")) { - pr_err("create aborted.\n"); - return 1; - } -diff --git a/super-intel.c b/super-intel.c -index d60915e8..2b8b6fda 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -523,6 +523,7 @@ enum imsm_reshape_type { - CH_TAKEOVER, - CH_MIGRATION, - CH_ARRAY_SIZE, -+ CH_ABORT - }; - - /* definition of messages passed to imsm_process_update */ -@@ -11898,7 +11899,7 @@ success: - ****************************************************************************/ - enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - struct geo_params *geo, -- int direction) -+ int direction, struct context *c) - { - struct mdinfo info; - int change = -1; -@@ -11925,6 +11926,14 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - check_devs = 1; - raid_disks += 1; /* parity disk added */ - } else if (geo->level == IMSM_T_RAID10) { -+ if (geo->level == IMSM_T_RAID10 && geo->raid_disks > 2 && -+ !c->force) { -+ pr_err("Warning! VROC UEFI driver does not support RAID10 in requested layout.\n"); -+ pr_err("Array won't be suitable as boot device.\n"); -+ pr_err("Note: You can omit this check with \"--force\"\n"); -+ if (ask("Do you want to continue") < 1) -+ return CH_ABORT; -+ } - change = CH_TAKEOVER; - check_devs = 1; - raid_disks *= 2; /* mirrors added */ -@@ -12219,7 +12228,7 @@ static int imsm_reshape_super(struct supertype *st, struct shape *shape, struct - goto exit_imsm_reshape_super; - } - super->current_vol = dev->index; -- change = imsm_analyze_change(st, &geo, shape->direction); -+ change = imsm_analyze_change(st, &geo, shape->direction, c); - switch (change) { - case CH_TAKEOVER: - ret_val = imsm_takeover(st, &geo); -@@ -12262,6 +12271,7 @@ static int imsm_reshape_super(struct supertype *st, struct shape *shape, struct - free(u); - } - break; -+ case CH_ABORT: - default: - ret_val = 1; - } -diff --git a/util.c b/util.c -index 9e837045..4fbf11c4 100644 ---- a/util.c -+++ b/util.c -@@ -725,23 +725,33 @@ int stat_is_blkdev(char *devname, dev_t *rdev) - return 1; - } - -+/** -+ * ask() - prompt user for "yes/no" dialog. -+ * @mesg: message to be printed, without '?' sign. -+ * Returns: 1 if 'Y/y', 0 otherwise. -+ * -+ * The default value is 'N/n', thus the caps on "N" on prompt. -+ */ - int ask(char *mesg) - { -- char *add = ""; -- int i; -- for (i = 0; i < 5; i++) { -- char buf[100]; -- fprintf(stderr, "%s%s", mesg, add); -- fflush(stderr); -- if (fgets(buf, 100, stdin)==NULL) -- return 0; -- if (buf[0]=='y' || buf[0]=='Y') -- return 1; -- if (buf[0]=='n' || buf[0]=='N') -- return 0; -- add = "(y/n) "; -+ char buf[3] = {0}; -+ -+ fprintf(stderr, "%s [y/N]? ", mesg); -+ fflush(stderr); -+ if (fgets(buf, 3, stdin) == NULL) -+ return 0; -+ if (strlen(buf) == 1) { -+ pr_err("assuming no.\n"); -+ return 0; - } -- pr_err("assuming 'no'\n"); -+ if (buf[1] != '\n') -+ goto bad_option; -+ if (toupper(buf[0]) == 'Y') -+ return 1; -+ if (toupper(buf[0]) == 'N') -+ return 0; -+bad_option: -+ pr_err("bad option.\n"); - return 0; - } - -@@ -1868,6 +1878,7 @@ int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info) - - if (st->ss->external) - return sysfs_set_array(info); -+ - memset(&inf, 0, sizeof(inf)); - inf.major_version = info->array.major_version; - inf.minor_version = info->array.minor_version; --- -2.41.0 - diff --git a/0060-tests-01r5fail-enhance.patch b/0060-tests-01r5fail-enhance.patch deleted file mode 100644 index 32c06d6..0000000 --- a/0060-tests-01r5fail-enhance.patch +++ /dev/null @@ -1,41 +0,0 @@ -From d399c494c6364a6b6d0f965c08443fdc79d1e248 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Thu, 18 Apr 2024 18:23:19 +0800 -Subject: [PATCH 60/66] tests/01r5fail enhance - -After removing dev0, the recovery starts because it already has a spare -disk. It's good to check recovery. But it's not right to check recovery -after adding dev3. Because the recovery may finish. It depends on the -recovery performance of the testing machine. If the recovery finishes, -it will fail. But dev3 is only added as a spare disk, we can't expect -there is a recovery happens. - -So remove the codes about adding dev3. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/01r5fail | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/tests/01r5fail b/tests/01r5fail -index 873dba58..c210d6e7 100644 ---- a/tests/01r5fail -+++ b/tests/01r5fail -@@ -17,11 +17,7 @@ check wait - mdadm $md0 --fail $dev0 - mdadm $md0 --remove $dev3 $dev0 - check recovery --check state _UUU -- --mdadm $md0 -a $dev3 --check recovery - check wait - check state UUUU - --mdadm -S $md0 -\ No newline at end of file -+mdadm -S $md0 --- -2.41.0 - diff --git a/0061-tests-01r5integ.broken.patch b/0061-tests-01r5integ.broken.patch deleted file mode 100644 index c662238..0000000 --- a/0061-tests-01r5integ.broken.patch +++ /dev/null @@ -1,32 +0,0 @@ -From a20cb3872c02241e4f0f7cc26933a43bac7d1cbb Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Thu, 18 Apr 2024 18:23:20 +0800 -Subject: [PATCH 61/66] tests/01r5integ.broken - -01r5integ can be run successfully 152 times without error with -kernel 6.9.0-rc4 and mdadm - v4.3-51-g52bead95. So remove this -one broken case. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/01r5integ.broken | 7 ------- - 1 file changed, 7 deletions(-) - delete mode 100644 tests/01r5integ.broken - -diff --git a/tests/01r5integ.broken b/tests/01r5integ.broken -deleted file mode 100644 -index 20737637..00000000 ---- a/tests/01r5integ.broken -+++ /dev/null -@@ -1,7 +0,0 @@ --fails rarely -- --Fails about 1 in every 30 runs with a sha mismatch error: -- -- c49ab26e1b01def7874af9b8a6d6d0c29fdfafe6 /dev/md0 does not match -- 15dc2f73262f811ada53c65e505ceec9cf025cb9 /dev/md0 with /dev/loop3 -- missing --- -2.41.0 - diff --git a/0062-tests-01raid6integ.broken-can-be-removed.patch b/0062-tests-01raid6integ.broken-can-be-removed.patch deleted file mode 100644 index 9becf86..0000000 --- a/0062-tests-01raid6integ.broken-can-be-removed.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 896948b14ad26f15590269dce50ac4896284dc29 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Thu, 18 Apr 2024 18:23:21 +0800 -Subject: [PATCH 62/66] tests/01raid6integ.broken can be removed - -01raid6integ can be run successfully with kernel 6.9.0-rc3. -So remove 01raid6integ.broken. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/01raid6integ.broken | 7 ------- - 1 file changed, 7 deletions(-) - delete mode 100644 tests/01raid6integ.broken - -diff --git a/tests/01raid6integ.broken b/tests/01raid6integ.broken -deleted file mode 100644 -index 1df735f0..00000000 ---- a/tests/01raid6integ.broken -+++ /dev/null -@@ -1,7 +0,0 @@ --fails infrequently -- --Fails about 1 in 5 with a sha mismatch: -- -- 8286c2bc045ae2cfe9f8b7ae3a898fa25db6926f /dev/md0 does not match -- a083a0738b58caab37fd568b91b177035ded37df /dev/md0 with /dev/loop2 and -- /dev/loop3 missing --- -2.41.0 - diff --git a/0063-Makefile-Move-pie-to-LDFLAGS.patch b/0063-Makefile-Move-pie-to-LDFLAGS.patch deleted file mode 100644 index 7065fe7..0000000 --- a/0063-Makefile-Move-pie-to-LDFLAGS.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 893a55831e5abbcd15b171db66fa1f389fb61506 Mon Sep 17 00:00:00 2001 -From: Fabrice Fontaine -Date: Tue, 7 May 2024 19:32:16 +0200 -Subject: [PATCH 63/66] Makefile: Move -pie to LDFLAGS - -Move -pie from LDLIBS to LDFLAGS and make LDFLAGS configurable to allow -the user to drop it by setting their own LDFLAGS (e.g. PIE could be -enabled or disabled by the buildsystem such as buildroot). - -Suggested-by: Mariusz Tkaczyk -Signed-off-by: Fabrice Fontaine -Signed-off-by: Mariusz Tkaczyk ---- - Makefile | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Makefile b/Makefile -index 7c221a89..adac7905 100644 ---- a/Makefile -+++ b/Makefile -@@ -132,12 +132,12 @@ CFLAGS += -DUSE_PTHREADS - MON_LDFLAGS += -pthread - endif - --LDFLAGS = -Wl,-z,now,-z,noexecstack -+LDFLAGS ?= -pie -Wl,-z,now,-z,noexecstack - - # If you want a static binary, you might uncomment these - # LDFLAGS += -static - # STRIP = -s --LDLIBS = -ldl -pie -+LDLIBS = -ldl - - # To explicitly disable libudev, set -DNO_LIBUDEV in CXFLAGS - ifeq (, $(findstring -DNO_LIBUDEV, $(CXFLAGS))) --- -2.41.0 - diff --git a/0064-tests-23rdev-lifetime-fix-a-typo.patch b/0064-tests-23rdev-lifetime-fix-a-typo.patch deleted file mode 100644 index 5c1b196..0000000 --- a/0064-tests-23rdev-lifetime-fix-a-typo.patch +++ /dev/null @@ -1,30 +0,0 @@ -From a0174749426f49a04f11ae0e728cb0a681bfa465 Mon Sep 17 00:00:00 2001 -From: Yu Kuai -Date: Thu, 9 May 2024 09:10:59 +0800 -Subject: [PATCH 64/66] tests/23rdev-lifetime: fix a typo - -"pill" was wrong, while it should be "kill", test will still pass while -test thread will not be cleaned up. - -Signed-off-by: Yu Kuai -Signed-off-by: Mariusz Tkaczyk ---- - tests/23rdev-lifetime | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/23rdev-lifetime b/tests/23rdev-lifetime -index 1750b0db..03b61de4 100644 ---- a/tests/23rdev-lifetime -+++ b/tests/23rdev-lifetime -@@ -4,7 +4,7 @@ pid="" - runtime=2 - - clean_up_test() { -- pill -9 $pid -+ kill -9 $pid - echo clear > /sys/block/md0/md/array_state - } - --- -2.41.0 - diff --git a/0065-util.c-change-devnm-to-const-in-mdmon-functions.patch b/0065-util.c-change-devnm-to-const-in-mdmon-functions.patch deleted file mode 100644 index 6de3318..0000000 --- a/0065-util.c-change-devnm-to-const-in-mdmon-functions.patch +++ /dev/null @@ -1,55 +0,0 @@ -From b0f4e8e30f38d83f7e3f53d01d72d4cb3b4d42d7 Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Tue, 7 May 2024 05:38:55 +0200 -Subject: [PATCH 65/66] util.c: change devnm to const in mdmon functions - -Devnm shall not be changed inside mdmon_running() -and mdmon_pid() functions, change this parameter to const. - -Signed-off-by: Kinga Stefaniuk -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 4 ++-- - util.c | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index 2ff3e463..1ba541fc 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1768,8 +1768,8 @@ extern int is_subarray_active(char *subarray, char *devname); - extern int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet); - extern struct superswitch *version_to_superswitch(char *vers); - --extern int mdmon_running(char *devnm); --extern int mdmon_pid(char *devnm); -+extern int mdmon_running(const char *devnm); -+extern int mdmon_pid(const char *devnm); - extern int check_env(char *name); - extern __u32 random32(void); - extern void random_uuid(__u8 *buf); -diff --git a/util.c b/util.c -index 4fbf11c4..e2b490e1 100644 ---- a/util.c -+++ b/util.c -@@ -1902,7 +1902,7 @@ unsigned long long min_recovery_start(struct mdinfo *array) - return recovery_start; - } - --int mdmon_pid(char *devnm) -+int mdmon_pid(const char *devnm) - { - char path[100]; - char pid[10]; -@@ -1922,7 +1922,7 @@ int mdmon_pid(char *devnm) - return atoi(pid); - } - --int mdmon_running(char *devnm) -+int mdmon_running(const char *devnm) - { - int pid = mdmon_pid(devnm); - if (pid <= 0) --- -2.41.0 - diff --git a/0066-Wait-for-mdmon-when-it-is-stared-via-systemd.patch b/0066-Wait-for-mdmon-when-it-is-stared-via-systemd.patch deleted file mode 100644 index 6cd30b2..0000000 --- a/0066-Wait-for-mdmon-when-it-is-stared-via-systemd.patch +++ /dev/null @@ -1,121 +0,0 @@ -From aa1cc5815d2b14a8b47add18cfaa8264e19c10ce Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Tue, 7 May 2024 05:38:56 +0200 -Subject: [PATCH 66/66] Wait for mdmon when it is stared via systemd - -When mdmon is being started it may need few seconds to start. -For now, we didn't wait for it. Introduce wait_for_mdmon() -function, which waits up to 5 seconds for mdmon to start completely. - -Signed-off-by: Kinga Stefaniuk -Signed-off-by: Mariusz Tkaczyk ---- - Assemble.c | 4 ++-- - Grow.c | 7 ++++--- - mdadm.h | 2 ++ - util.c | 29 +++++++++++++++++++++++++++++ - 4 files changed, 37 insertions(+), 5 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index f5e9ab1f..83dced19 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -2173,8 +2173,8 @@ int assemble_container_content(struct supertype *st, int mdfd, - if (!mdmon_running(st->container_devnm)) - start_mdmon(st->container_devnm); - ping_monitor(st->container_devnm); -- if (mdmon_running(st->container_devnm) && -- st->update_tail == NULL) -+ if (wait_for_mdmon(st->container_devnm) == MDADM_STATUS_SUCCESS && -+ !st->update_tail) - st->update_tail = &st->updates; - } - -diff --git a/Grow.c b/Grow.c -index 87ed9214..1923c27c 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -2134,7 +2134,7 @@ int Grow_reshape(char *devname, int fd, - if (!mdmon_running(st->container_devnm)) - start_mdmon(st->container_devnm); - ping_monitor(container); -- if (mdmon_running(st->container_devnm) == false) { -+ if (wait_for_mdmon(st->container_devnm) != MDADM_STATUS_SUCCESS) { - pr_err("No mdmon found. Grow cannot continue.\n"); - goto release; - } -@@ -3218,7 +3218,8 @@ static int reshape_array(char *container, int fd, char *devname, - if (!mdmon_running(container)) - start_mdmon(container); - ping_monitor(container); -- if (mdmon_running(container) && st->update_tail == NULL) -+ if (wait_for_mdmon(container) == MDADM_STATUS_SUCCESS && -+ !st->update_tail) - st->update_tail = &st->updates; - } - } -@@ -5173,7 +5174,7 @@ int Grow_continue_command(char *devname, int fd, struct context *c) - start_mdmon(container); - ping_monitor(container); - -- if (mdmon_running(container) == false) { -+ if (wait_for_mdmon(container) != MDADM_STATUS_SUCCESS) { - pr_err("No mdmon found. Grow cannot continue.\n"); - ret_val = 1; - goto Grow_continue_command_exit; -diff --git a/mdadm.h b/mdadm.h -index 1ba541fc..b71d7b32 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1770,6 +1770,8 @@ extern struct superswitch *version_to_superswitch(char *vers); - - extern int mdmon_running(const char *devnm); - extern int mdmon_pid(const char *devnm); -+extern mdadm_status_t wait_for_mdmon(const char *devnm); -+ - extern int check_env(char *name); - extern __u32 random32(void); - extern void random_uuid(__u8 *buf); -diff --git a/util.c b/util.c -index e2b490e1..bf79742f 100644 ---- a/util.c -+++ b/util.c -@@ -1932,6 +1932,35 @@ int mdmon_running(const char *devnm) - return 0; - } - -+/* -+ * wait_for_mdmon() - Waits for mdmon within specified time. -+ * @devnm: Device for which mdmon should start. -+ * -+ * Function waits for mdmon to start. It may need few seconds -+ * to start, we set timeout to 5, it should be sufficient. -+ * Do not wait if mdmon has been started. -+ * -+ * Return: MDADM_STATUS_SUCCESS if mdmon is running, error code otherwise. -+ */ -+mdadm_status_t wait_for_mdmon(const char *devnm) -+{ -+ const time_t mdmon_timeout = 5; -+ time_t start_time = time(0); -+ -+ if (mdmon_running(devnm)) -+ return MDADM_STATUS_SUCCESS; -+ -+ pr_info("Waiting for mdmon to start\n"); -+ while (time(0) - start_time < mdmon_timeout) { -+ sleep_for(0, MSEC_TO_NSEC(200), true); -+ if (mdmon_running(devnm)) -+ return MDADM_STATUS_SUCCESS; -+ }; -+ -+ pr_err("Timeout waiting for mdmon\n"); -+ return MDADM_STATUS_ERROR; -+} -+ - int start_mdmon(char *devnm) - { - int i; --- -2.41.0 - diff --git a/0067-mdadm-Change-main-repository-to-Github.patch b/0067-mdadm-Change-main-repository-to-Github.patch deleted file mode 100644 index ae729f5..0000000 --- a/0067-mdadm-Change-main-repository-to-Github.patch +++ /dev/null @@ -1,193 +0,0 @@ -From 3f90be087fa62c0c7ed76c2ac26752f0ac3a89e7 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 `` to create patches: -- * ``--cover-letter`` can be skipped if it is only one patch; -- * ``--signoff`` adds sign-off tag; -- * ``-v `` 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 `` 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 (...)`` -+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 ; - - Mariusz Tkaczyk ; - --Adding **MD maintainers** could be reasonable, especially if patches may affect MD driver: -- --- Song Liu ; --- Yu Kuai ; -- --# 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 - diff --git a/0069-mdadm-Fix-compilation-for-32-bit-arch.patch b/0069-mdadm-Fix-compilation-for-32-bit-arch.patch deleted file mode 100644 index 4a8ed71..0000000 --- a/0069-mdadm-Fix-compilation-for-32-bit-arch.patch +++ /dev/null @@ -1,62 +0,0 @@ -From c5879860eac64ddd7bec4ba50c9adbfebcbf1d2e Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 15 May 2024 13:26:28 +0200 -Subject: [PATCH 1/1] mdadm: Fix compilation for 32-bit arch -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Casting void pointer to __u64 works for 64-bit arch but fails to compile -on 32-bit arch like i686. - -Fail on i686 platform: -drive_encryption.c: In function ‘nvme_security_recv_ioctl’: -drive_encryption.c:236:25: error: cast from pointer to integer of -different size [-Werror=pointer-to-int-cast] - 236 | nvme_cmd.addr = (__u64)response_buffer; - | ^ -drive_encryption.c: In function ‘nvme_identify_ioctl’: -drive_encryption.c:271:25: error: cast from pointer to integer of -different size [-Werror=pointer-to-int-cast] - 271 | nvme_cmd.addr = (__u64)response_buffer; - | ^ -cc1: all warnings being treated as errors -make: *** [Makefile:211: drive_encryption.o] Error 1 - -This change adds cast void pointer to uintptr_t first to ensure that -proper pointer size is used for casting from pointer type. Then is safe to -cast it to __u64 because it is tracked as u_int, regardless it is 32-bit -or 64-bit arch. - -Reported-by: Xiao Ni -Fixes: cc48406887b3 ("Add reading Opal NVMe encryption information") -Signed-off-by: Blazej Kucman ---- - drive_encryption.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drive_encryption.c b/drive_encryption.c -index 27da9621..a4ad799f 100644 ---- a/drive_encryption.c -+++ b/drive_encryption.c -@@ -233,7 +233,7 @@ nvme_security_recv_ioctl(int disk_fd, __u8 sec_protocol, __u16 comm_id, void *re - nvme_cmd.cdw10 = sec_protocol << 24 | comm_id << 8; - nvme_cmd.cdw11 = buf_size; - nvme_cmd.data_len = buf_size; -- nvme_cmd.addr = (__u64)response_buffer; -+ nvme_cmd.addr = (__u64)(uintptr_t)response_buffer; - - status = ioctl(disk_fd, NVME_IOCTL_ADMIN_CMD, &nvme_cmd); - if (status != 0) { -@@ -268,7 +268,7 @@ nvme_identify_ioctl(int disk_fd, void *response_buffer, size_t buf_size, const i - nvme_cmd.opcode = NVME_IDENTIFY; - nvme_cmd.cdw10 = NVME_IDENTIFY_CONTROLLER_DATA; - nvme_cmd.data_len = buf_size; -- nvme_cmd.addr = (__u64)response_buffer; -+ nvme_cmd.addr = (__u64)(uintptr_t)response_buffer; - - status = ioctl(disk_fd, NVME_IOCTL_ADMIN_CMD, &nvme_cmd); - if (status != 0) { --- -2.41.0 - diff --git a/0070-add-checking-of-return-status-on-fstat-calls.patch b/0070-add-checking-of-return-status-on-fstat-calls.patch deleted file mode 100644 index e81baeb..0000000 --- a/0070-add-checking-of-return-status-on-fstat-calls.patch +++ /dev/null @@ -1,267 +0,0 @@ -From 95673c7d83c8ac7f2aeb91a34ead2971ba30e96e Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Mon, 20 May 2024 09:36:50 -0400 -Subject: [PATCH 070/157] add checking of return status on fstat calls - -There are a few places we don't check the return status when -calling fstat for success. Clean up the calls by adding a -check before continuing. - -Signed-off-by: Nigel Croxon ---- - Assemble.c | 41 +++++++++++++++++++++++------------------ - Dump.c | 11 +++++++++-- - Grow.c | 12 ++++++++---- - config.c | 3 ++- - mdstat.c | 3 ++- - super-ddf.c | 8 ++++++-- - super-intel.c | 8 ++++++-- - 7 files changed, 56 insertions(+), 30 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 83dced19..58dc2c5e 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -652,7 +652,9 @@ static int load_devices(struct devs *devices, char *devmap, - /* prepare useful information in info structures */ - struct stat stb2; - int err; -- fstat(mdfd, &stb2); -+ -+ if (fstat(mdfd, &stb2) != 0) -+ goto error; - - if (c->update == UOPT_UUID && !ident->uuid_set) - random_uuid((__u8 *)ident->uuid); -@@ -675,13 +677,10 @@ static int load_devices(struct devs *devices, char *devmap, - devname); - if (dfd >= 0) - close(dfd); -- close(mdfd); -- free(devices); -- free(devmap); - tst->ss->free_super(tst); - free(tst); - *stp = st; -- return -1; -+ goto error; - } - tst->ss->getinfo_super(tst, content, devmap + devcnt * content->array.raid_disks); - -@@ -715,12 +714,9 @@ static int load_devices(struct devs *devices, char *devmap, - map_num(update_options, c->update), tst->ss->name); - tst->ss->free_super(tst); - free(tst); -- close(mdfd); - close(dfd); -- free(devices); -- free(devmap); - *stp = st; -- return -1; -+ goto error; - } - if (c->update == UOPT_UUID && - !ident->uuid_set) { -@@ -751,18 +747,23 @@ static int load_devices(struct devs *devices, char *devmap, - devname); - if (dfd >= 0) - close(dfd); -- close(mdfd); -- free(devices); -- free(devmap); - tst->ss->free_super(tst); - free(tst); - *stp = st; -- return -1; -+ goto error; - } - tst->ss->getinfo_super(tst, content, devmap + devcnt * content->array.raid_disks); - } - -- fstat(dfd, &stb); -+ if (fstat(dfd, &stb) != 0) { -+ close(dfd); -+ free(devices); -+ free(devmap); -+ tst->ss->free_super(tst); -+ free(tst); -+ *stp = st; -+ return -1; -+ } - close(dfd); - - if (c->verbose > 0) -@@ -842,12 +843,9 @@ static int load_devices(struct devs *devices, char *devmap, - inargv ? "the list" : - "the\n DEVICE list in mdadm.conf" - ); -- close(mdfd); -- free(devices); -- free(devmap); - free(best); - *stp = st; -- return -1; -+ goto error; - } - if (best[i] == -1 || (devices[best[i]].i.events - < devices[devcnt].i.events)) -@@ -863,6 +861,13 @@ static int load_devices(struct devs *devices, char *devmap, - *bestp = best; - *stp = st; - return devcnt; -+ -+error: -+ close(mdfd); -+ free(devices); -+ free(devmap); -+ return -1; -+ - } - - static int force_array(struct mdinfo *content, -diff --git a/Dump.c b/Dump.c -index 736bcb60..81b94940 100644 ---- a/Dump.c -+++ b/Dump.c -@@ -37,6 +37,7 @@ int Dump_metadata(char *dev, char *dir, struct context *c, - unsigned long long size; - DIR *dirp; - struct dirent *de; -+ int ret = 0; - - if (stat(dir, &stb) != 0 || - (S_IFMT & stb.st_mode) != S_IFDIR) { -@@ -112,9 +113,15 @@ int Dump_metadata(char *dev, char *dir, struct context *c, - } - if (c->verbose >= 0) - printf("%s saved as %s.\n", dev, fname); -- fstat(fd, &dstb); -- close(fd); -+ - close(fl); -+ ret = fstat(fd, &dstb); -+ close(fd); -+ if (ret) { -+ unlink(fname); -+ free(fname); -+ return 1; -+ } - if ((dstb.st_mode & S_IFMT) != S_IFBLK) { - /* Not a block device, so cannot create links */ - free(fname); -diff --git a/Grow.c b/Grow.c -index 1923c27c..963792d0 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -1223,13 +1223,14 @@ int reshape_open_backup_file(char *backup_file, - * way this will not notice, but it is better than - * nothing. - */ -- fstat(*fdlist, &stb); -+ if (fstat(*fdlist, &stb) != 0) -+ goto error; - dev = stb.st_dev; -- fstat(fd, &stb); -+ if (fstat(fd, &stb) != 0) -+ goto error; - if (stb.st_rdev == dev) { - pr_err("backup file must NOT be on the array being reshaped.\n"); -- close(*fdlist); -- return 0; -+ goto error; - } - - memset(buf, 0, 512); -@@ -1255,6 +1256,9 @@ int reshape_open_backup_file(char *backup_file, - } - - return 1; -+error: -+ close(*fdlist); -+ return 0; - } - - unsigned long compute_backup_blocks(int nchunk, int ochunk, -diff --git a/config.c b/config.c -index b46d71cb..612e700d 100644 ---- a/config.c -+++ b/config.c -@@ -949,7 +949,8 @@ void conf_file_or_dir(FILE *f) - struct dirent *dp; - struct fname *list = NULL; - -- fstat(fileno(f), &st); -+ if (fstat(fileno(f), &st) != 0) -+ return; - if (S_ISREG(st.st_mode)) - conf_file(f); - else if (!S_ISDIR(st.st_mode)) -diff --git a/mdstat.c b/mdstat.c -index 2fd792c5..e233f094 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -348,7 +348,8 @@ void mdstat_wait_fd(int fd, const sigset_t *sigmask) - - if (fd >= 0) { - struct stat stb; -- fstat(fd, &stb); -+ if (fstat(fd, &stb) != 0) -+ return; - if ((stb.st_mode & S_IFMT) == S_IFREG) - /* Must be a /proc or /sys fd, so expect - * POLLPRI -diff --git a/super-ddf.c b/super-ddf.c -index 21426c75..311001c1 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -1053,7 +1053,10 @@ static int load_ddf_local(int fd, struct ddf_super *super, - 0); - dl->devname = devname ? xstrdup(devname) : NULL; - -- fstat(fd, &stb); -+ if (fstat(fd, &stb) != 0) { -+ free(dl); -+ return 1; -+ } - dl->major = major(stb.st_rdev); - dl->minor = minor(stb.st_rdev); - dl->next = super->dlist; -@@ -2786,7 +2789,8 @@ static int add_to_super_ddf(struct supertype *st, - /* This is device numbered dk->number. We need to create - * a phys_disk entry and a more detailed disk_data entry. - */ -- fstat(fd, &stb); -+ if (fstat(fd, &stb) != 0) -+ return 1; - n = find_unused_pde(ddf); - if (n == DDF_NOTFOUND) { - pr_err("No free slot in array, cannot add disk\n"); -diff --git a/super-intel.c b/super-intel.c -index 2b8b6fda..4d257371 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -4239,7 +4239,10 @@ load_imsm_disk(int fd, struct intel_super *super, char *devname, int keep_fd) - - dl = xcalloc(1, sizeof(*dl)); - -- fstat(fd, &stb); -+ if (fstat(fd, &stb) != 0) { -+ free(dl); -+ return 1; -+ } - dl->major = major(stb.st_rdev); - dl->minor = minor(stb.st_rdev); - dl->next = super->disks; -@@ -5981,7 +5984,8 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - if (super->current_vol >= 0) - return add_to_super_imsm_volume(st, dk, fd, devname); - -- fstat(fd, &stb); -+ if (fstat(fd, &stb) != 0) -+ return 1; - dd = xcalloc(sizeof(*dd), 1); - dd->major = major(stb.st_rdev); - dd->minor = minor(stb.st_rdev); --- -2.41.0 - diff --git a/0071-super-intel-fix-typo-in-error-msg.patch b/0071-super-intel-fix-typo-in-error-msg.patch deleted file mode 100644 index bb683d1..0000000 --- a/0071-super-intel-fix-typo-in-error-msg.patch +++ /dev/null @@ -1,28 +0,0 @@ -From c7790592bb7d050a990a9accb50de8f584879169 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 22 May 2024 11:13:17 +0200 -Subject: [PATCH 071/157] super-intel: fix typo in error msg - -Fix typo in encryption policy error msg. - -Signed-off-by: Blazej Kucman ---- - super-intel.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index 4d257371..95856322 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -11328,7 +11328,7 @@ check_policy: - return MDADM_STATUS_SUCCESS; - - fd2devname(disk_fd, devname); -- pr_vrb("Encryption status \"%s\" detected for disk %s, but \"%s\" status was detected eariler.\n", -+ pr_vrb("Encryption status \"%s\" detected for disk %s, but \"%s\" status was detected earlier.\n", - encryption_state, devname, expected_policy->value); - pr_vrb("Disks with different encryption status cannot be used.\n"); - return MDADM_STATUS_ERROR; --- -2.41.0 - diff --git a/0072-mdadm-super-intel-remove-dead-code.patch b/0072-mdadm-super-intel-remove-dead-code.patch deleted file mode 100644 index c25564b..0000000 --- a/0072-mdadm-super-intel-remove-dead-code.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 49145d4f574b21a6c0612ce691f255732cb91832 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Wed, 22 May 2024 16:05:25 -0400 -Subject: [PATCH 072/157] mdadm: super-intel remove dead code - -Execution cannot reach this statement: "while (devlist) { dv = de...". -Local variable "err" is assigned only once, to a constant value, -making it effectively constant throughout its scope. -Remove dead code. - -Signed-off-by: Nigel Croxon ---- - super-intel.c | 9 --------- - 1 file changed, 9 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 95856322..d1b737c7 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7046,7 +7046,6 @@ get_devices(const char *hba_path) - struct md_list *dv; - struct dirent *ent; - DIR *dir; -- int err = 0; - - #if DEBUG_LOOP - devlist = get_loop_devices(); -@@ -7088,14 +7087,6 @@ get_devices(const char *hba_path) - dv->next = devlist; - devlist = dv; - } -- if (err) { -- while(devlist) { -- dv = devlist; -- devlist = devlist->next; -- free(dv->devname); -- free(dv); -- } -- } - closedir(dir); - return devlist; - } --- -2.41.0 - diff --git a/0073-mdadm-super-intel-fix-bad-shift.patch b/0073-mdadm-super-intel-fix-bad-shift.patch deleted file mode 100644 index f032dd4..0000000 --- a/0073-mdadm-super-intel-fix-bad-shift.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 5c30864146412fcdfdcfddcdd94c5c449d9ddbed Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Wed, 22 May 2024 16:53:22 -0400 -Subject: [PATCH 073/157] mdadm: super-intel fix bad shift - -In the expression "1 << i", left shifting by more than 31 bits has undefined behavior. -The shift amount, "i", is as much as 63. The operand has type "int" (32 bits) and will -be shifted as an "int". The fix is to change to a 64 bit int. - -Signed-off-by: Nigel Croxon ---- - super-intel.c | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index d1b737c7..0287a618 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2343,7 +2343,8 @@ void print_encryption_information(int disk_fd, enum sys_dev_type hba_type) - get_encryption_status_string(information.status)); - } - --static int ahci_enumerate_ports(struct sys_dev *hba, int port_count, int host_base, int verbose) -+static int ahci_enumerate_ports(struct sys_dev *hba, unsigned long port_count, int host_base, -+ int verbose) - { - /* dump an unsorted list of devices attached to AHCI Intel storage - * controller, as well as non-connected ports -@@ -2357,7 +2358,7 @@ static int ahci_enumerate_ports(struct sys_dev *hba, int port_count, int host_ba - - if (port_count > (int)sizeof(port_mask) * 8) { - if (verbose > 0) -- pr_err("port_count %d out of range\n", port_count); -+ pr_err("port_count %ld out of range\n", port_count); - return 2; - } - -@@ -2499,11 +2500,11 @@ static int ahci_enumerate_ports(struct sys_dev *hba, int port_count, int host_ba - if (dir) - closedir(dir); - if (err == 0) { -- int i; -+ unsigned long i; - - for (i = 0; i < port_count; i++) -- if (port_mask & (1 << i)) -- printf(" Port%d : - no device attached -\n", i); -+ if (port_mask & (1L << i)) -+ printf(" Port%ld : - no device attached -\n", i); - } - - return err; --- -2.41.0 - diff --git a/0074-mdadm-deprecate-bitmap-custom-file.patch b/0074-mdadm-deprecate-bitmap-custom-file.patch deleted file mode 100644 index 5a2a0b2..0000000 --- a/0074-mdadm-deprecate-bitmap-custom-file.patch +++ /dev/null @@ -1,438 +0,0 @@ -From 50b100768a115526f5029113af957658ef76b383 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 29 Mar 2024 15:21:54 +0100 -Subject: [PATCH 074/157] mdadm: deprecate bitmap custom file - -This option has been deprecated in kernel by Christoph in commit -0ae1c9d38426 ("md: deprecate bitmap file support"). Do the same in -mdadm. - -With this change, user must acknowledge it, it is not -skippable. The implementation of custom bitmap file looks like it's -abandoned. It cannot be done by Incremental so it is not respected by -any udev based system and it seems to not be recorded by metadata. -User must assemble such volume manually. - -Tests for bitmap custom file are removed because now they will not -pass because interaction with user is mandatory. - -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.8.in | 34 +++++++++---------- - mdadm.c | 70 +++++++++++++++++++++++++++------------- - tests/05r1-bitmapfile | 49 ---------------------------- - tests/05r1-grow-external | 33 ------------------- - tests/05r1-n3-bitmapfile | 53 ------------------------------ - tests/05r5-bitmapfile | 49 ---------------------------- - tests/05r6-bitmapfile | 49 ---------------------------- - 7 files changed, 62 insertions(+), 275 deletions(-) - delete mode 100644 tests/05r1-bitmapfile - delete mode 100644 tests/05r1-grow-external - delete mode 100644 tests/05r1-n3-bitmapfile - delete mode 100644 tests/05r5-bitmapfile - delete mode 100644 tests/05r6-bitmapfile - -diff --git a/mdadm.8.in b/mdadm.8.in -index 9ba66825..aa0c5403 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -727,29 +727,25 @@ same as - - .TP - .BR \-b ", " \-\-bitmap= --Specify a file to store a write-intent bitmap in. The file should not --exist unless --.B \-\-force --is also given. The same file should be provided --when assembling the array. If the word --.B "internal" --is given, then the bitmap is stored with the metadata on the array, --and so is replicated on all devices. If the word --.B "none" --is given with --.B \-\-grow --mode, then any bitmap that is present is removed. If the word --.B "clustered" --is given, the array is created for a clustered environment. One bitmap --is created for each node as defined by the -+Specify how to store a write-intent bitmap. Following values are supported: -+ -+.B internal -+- the bitmap is stored with the metadata on the array and so is replicated on all devices. -+ -+.B clustered -+- the array is created for a clustered environment. One bitmap is created for each node as defined -+by the - .B \-\-nodes - parameter and are stored internally. - --To help catch typing errors, the filename must contain at least one --slash ('/') if it is a real file (not 'internal' or 'none'). -+.B none -+- create array with no bitmap or remove any present bitmap (grow mode). - --Note: external bitmaps are only known to work on ext2 and ext3. --Storing bitmap files on other filesystems may result in serious problems. -+Setting bitmap for file is deprecated and should not be used. The file should not exist unless -+.B \-\-force -+is also given. The same file should be provided when assembling the array. The file name must -+contain at least one slash ('/'). Bitmap files are only known to work on ext2 and ext3. Storing -+bitmap files on other filesystems may result in serious problems. - - When creating an array on devices which are 100G or larger, - .I mdadm -diff --git a/mdadm.c b/mdadm.c -index d18619db..0b99fad4 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -29,6 +29,51 @@ - #include "md_p.h" - #include - -+/** -+ * set_bitmap_value() - set bitmap value. -+ * @s: Shape. -+ * @c: Context. -+ * @val: value to set. -+ * -+ * Validate and set bitmap. Context is needed for setting nodes for clustered bitmap. -+ */ -+static mdadm_status_t set_bitmap_value(struct shape *s, struct context *c, char *val) -+{ -+ if (s->bitmap_file) { -+ pr_err("--bitmap cannot be set twice. Second value: \"%s\".\n", val); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ if (strcmp(val, "internal") == 0 || strcmp(optarg, STR_COMMON_NONE) == 0) { -+ s->bitmap_file = val; -+ return MDADM_STATUS_SUCCESS; -+ } -+ -+ if (strcmp(val, "clustered") == 0) { -+ s->bitmap_file = val; -+ /* Set the default number of cluster nodes -+ * to 4 if not already set by user -+ */ -+ if (c->nodes < 1) -+ c->nodes = 4; -+ return MDADM_STATUS_SUCCESS; -+ } -+ -+ if (strchr(val, '/')) { -+ pr_info("Custom write-intent bitmap file option is deprecated.\n"); -+ if (ask("Do you want to continue? (y/n)")) { -+ s->bitmap_file = val; -+ return MDADM_STATUS_SUCCESS; -+ } -+ -+ return MDADM_STATUS_ERROR; -+ } -+ -+ pr_err("--bitmap value must contain a '/' or be 'internal', 'clustered' or 'none'\n"); -+ pr_err("Current value is \"%s\"", val); -+ return MDADM_STATUS_ERROR; -+} -+ - static int scan_assemble(struct supertype *ss, - struct context *c, - struct mddev_ident *ident); -@@ -1094,30 +1139,9 @@ int main(int argc, char *argv[]) - case O(CREATE,Bitmap): /* here we create the bitmap */ - case O(GROW,'b'): - case O(GROW,Bitmap): -- if (s.bitmap_file) { -- pr_err("bitmap cannot be set twice. Second value: %s.\n", optarg); -+ if (set_bitmap_value(&s, &c, optarg)) - exit(2); -- } -- if (strcmp(optarg, "internal") == 0 || -- strcmp(optarg, STR_COMMON_NONE) == 0 || -- strchr(optarg, '/') != NULL) { -- s.bitmap_file = optarg; -- continue; -- } -- if (strcmp(optarg, "clustered") == 0) { -- s.bitmap_file = optarg; -- /* Set the default number of cluster nodes -- * to 4 if not already set by user -- */ -- if (c.nodes < 1) -- c.nodes = 4; -- continue; -- } -- /* probable typo */ -- pr_err("bitmap file must contain a '/', or be 'internal', or be 'clustered', or 'none'\n" -- " not '%s'\n", optarg); -- exit(2); -- -+ continue; - case O(GROW,BitmapChunk): - case O(BUILD,BitmapChunk): - case O(CREATE,BitmapChunk): /* bitmap chunksize */ -diff --git a/tests/05r1-bitmapfile b/tests/05r1-bitmapfile -deleted file mode 100644 -index f384f0ea..00000000 ---- a/tests/05r1-bitmapfile -+++ /dev/null -@@ -1,49 +0,0 @@ -- --# --# create a raid1 with a bitmap file --# --bmf=$targetdir/bitmap --rm -f $bmf --mdadm --create --run $md0 --level=1 -n2 --delay=1 --bitmap $bmf $dev1 $dev2 --check wait --testdev $md0 1 $mdsize1a 64 --mdadm -S $md0 -- --mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 --testdev $md0 1 $mdsize1a 64 --dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --sleep 4 --dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -- exit 1 --fi --mdadm $md0 -f $dev1 --testdev $md0 1 $mdsize1a 64 --sleep 4 --dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -- exit 2 --fi -- --mdadm -S $md0 -- --mdadm --assemble -R $md0 --bitmap=$bmf $dev2 --dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --mdadm --zero $dev1 # force --add, not --re-add --mdadm $md0 --add $dev1 --#it is too fast# check recovery -- --check wait --sleep 4 --dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -- exit 1 --fi -- --mdadm -S $md0 -diff --git a/tests/05r1-grow-external b/tests/05r1-grow-external -deleted file mode 100644 -index 69da3e90..00000000 ---- a/tests/05r1-grow-external -+++ /dev/null -@@ -1,33 +0,0 @@ -- --# --# create a raid1 array, add an external bitmap --# --mdadm --create --run $md0 -l 1 -n 2 $dev1 $dev2 --check wait --testdev $md0 1 $mdsize1a 64 -- --bmf=$targetdir/bm --rm -f $bmf --#mdadm -E $dev1 --mdadm --grow $md0 --bitmap=$bmf --delay=1 || { mdadm -X $bmf ; exit 1; } --dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --sleep 4 --dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --testdev $md0 1 $mdsize1a 64 --dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --sleep 4 --dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --#echo $dirty1 $dirty2 $dirty3 $dirty4 --if [ $dirty2 -ne 0 -o $dirty4 -ne 0 -o $dirty3 -lt 400 ] --then -- echo bad dirty counts -- exit 1 --fi -- --# now to remove the bitmap --check bitmap --mdadm --grow $md0 --bitmap=none --check nobitmap --mdadm -S $md0 -diff --git a/tests/05r1-n3-bitmapfile b/tests/05r1-n3-bitmapfile -deleted file mode 100644 -index f1c3f1ee..00000000 ---- a/tests/05r1-n3-bitmapfile -+++ /dev/null -@@ -1,53 +0,0 @@ -- --# --# create a raid1 with 3 devices and a bitmap file --# make sure resync does right thing. --# --# --bmf=$targetdir/bitmap --rm -f $bmf --mdadm --create -e0.90 --run $md0 --level=1 -n3 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3 --check wait --testdev $md0 1 $mdsize0 64 --mdadm -S $md0 -- --mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 --testdev $md0 1 $mdsize0 64 --dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --sleep 4 --dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -- exit 1 --fi --mdadm $md0 -f $dev2 --testdev $md0 1 $mdsize0 64 --sleep 4 --dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -- exit 2 --fi -- --mdadm -S $md0 -- --mdadm --assemble -R $md0 --bitmap=$bmf $dev1 $dev3 --check nosync --mdadm --zero-superblock $dev2 --mdadm $md0 --add $dev2 --check recovery -- --dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --check wait --sleep 4 --dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -- exit 1 --fi -- --mdadm -S $md0 --exit 0 -diff --git a/tests/05r5-bitmapfile b/tests/05r5-bitmapfile -deleted file mode 100644 -index 6d173d88..00000000 ---- a/tests/05r5-bitmapfile -+++ /dev/null -@@ -1,49 +0,0 @@ -- --# --# create a raid1 with a bitmap file --# --bmf=$targetdir/bitmap --rm -f $bmf --mdadm --create --run $md0 --level=5 -n3 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3 --check wait --testdev $md0 2 $mdsize1 512 --mdadm -S $md0 -- --mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 --testdev $md0 2 $mdsize1 512 --dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --sleep 4 --dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -- exit 1 --fi --mdadm $md0 -f $dev1 --testdev $md0 2 $mdsize1 512 --sleep 4 --dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -- exit 2 --fi -- --mdadm -S $md0 -- --mdadm --assemble -R $md0 --bitmap=$bmf $dev2 $dev3 --mdadm --zero $dev1 # force add, not re-add --mdadm $md0 --add $dev1 --check recovery -- --dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --check wait --sleep 4 --dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -- exit 1 --fi -- --mdadm -S $md0 -diff --git a/tests/05r6-bitmapfile b/tests/05r6-bitmapfile -deleted file mode 100644 -index d11896db..00000000 ---- a/tests/05r6-bitmapfile -+++ /dev/null -@@ -1,49 +0,0 @@ -- --# --# create a raid1 with a bitmap file --# --bmf=$targetdir/bitmap --rm -f $bmf --mdadm --create --run $md0 --level=6 -n4 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3 $dev4 --check wait --testdev $md0 2 $mdsize1 512 --mdadm -S $md0 -- --mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 $dev4 --testdev $md0 2 $mdsize1 512 --dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --sleep 4 --dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -- exit 1 --fi --mdadm $md0 -f $dev3 --testdev $md0 2 $mdsize1 512 --sleep 4 --dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -- exit 2 --fi -- --mdadm -S $md0 -- --mdadm --assemble -R $md0 --bitmap=$bmf $dev1 $dev2 $dev4 --mdadm --zero $dev3 # force --add, not --re-add --mdadm $md0 --add $dev3 --check recovery -- --dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --check wait --sleep 4 --dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -- --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -- exit 1 --fi -- --mdadm -S $md0 --- -2.41.0 - diff --git a/0075-Makefile-fix-make-s-detection.patch b/0075-Makefile-fix-make-s-detection.patch deleted file mode 100644 index ab5076a..0000000 --- a/0075-Makefile-fix-make-s-detection.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 906922ee321d64e2ce8458147e67d4892696fb58 Mon Sep 17 00:00:00 2001 -From: Valery Ushakov -Date: Wed, 22 May 2024 17:07:38 +0300 -Subject: [PATCH 075/157] Makefile: fix make -s detection - -Only check the first word of MAKEFLAGS for 's', that's where all the -single letter options are collected. - -MAKEFLAGS contains _all_ make flags, so if any command line argument -contains a letter 's', the silent test will be false positive. Think -e.g. make 'DESTDIR=.../aports/main/mdadm/pkg/mdadm' install ---- - Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index adac7905..446710bd 100644 ---- a/Makefile -+++ b/Makefile -@@ -157,7 +157,7 @@ ifndef UDEVDIR - UDEVDIR = /lib/udev - endif - --ifeq (,$(findstring s,$(MAKEFLAGS))) -+ifeq (,$(findstring s,$(firstword -$(MAKEFLAGS)))) - ECHO=echo - else - ECHO=: --- -2.41.0 - diff --git a/0076-Change-some-error-messages-to-info-level.patch b/0076-Change-some-error-messages-to-info-level.patch deleted file mode 100644 index 76442a9..0000000 --- a/0076-Change-some-error-messages-to-info-level.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 13a0e92a3ed70c52246a0f0572dee61203994327 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:38 +0800 -Subject: [PATCH 076/157] Change some error messages to info level - -These logs are not error logs. Change them to info level. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - Assemble.c | 16 ++++++---------- - Manage.c | 2 +- - util.c | 4 ++-- - 3 files changed, 9 insertions(+), 13 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 58dc2c5e..0e6da593 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1214,23 +1214,19 @@ static int start_array(int mdfd, - if (rv == 0) { - sysfs_rules_apply(mddev, content); - if (c->verbose >= 0) { -- pr_err("%s has been started with %d drive%s", -+ pr_info("%s has been started with %d drive%s", - mddev, okcnt, okcnt==1?"":"s"); - if (okcnt < (unsigned)content->array.raid_disks) -- fprintf(stderr, " (out of %d)", -- content->array.raid_disks); -+ printf(" (out of %d)", content->array.raid_disks); - if (rebuilding_cnt) -- fprintf(stderr, "%s %d rebuilding", -- sparecnt?",":" and", -+ printf("%s %d rebuilding", sparecnt?",":" and", - rebuilding_cnt); - if (sparecnt) -- fprintf(stderr, " and %d spare%s", -- sparecnt, -+ printf(" and %d spare%s", sparecnt, - sparecnt == 1 ? "" : "s"); - if (content->journal_clean) -- fprintf(stderr, " and %d journal", -- journalcnt); -- fprintf(stderr, ".\n"); -+ printf(" and %d journal", journalcnt); -+ printf(".\n"); - } - if (content->reshape_active && - is_level456(content->array.level)) { -diff --git a/Manage.c b/Manage.c -index 96e5ee54..5db72b77 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -463,7 +463,7 @@ done: - } - - if (verbose >= 0) -- pr_err("stopped %s\n", devname); -+ pr_info("stopped %s\n", devname); - map_lock(&map); - map_remove(&map, devnm); - map_unlock(&map); -diff --git a/util.c b/util.c -index bf79742f..48c97545 100644 ---- a/util.c -+++ b/util.c -@@ -633,9 +633,9 @@ int check_ext2(int fd, char *name) - bsize = sb[24]|(sb[25]|(sb[26]|sb[27]<<8)<<8)<<8; - size = sb[4]|(sb[5]|(sb[6]|sb[7]<<8)<<8)<<8; - size <<= bsize; -- pr_err("%s appears to contain an ext2fs file system\n", -+ pr_info("%s appears to contain an ext2fs file system\n", - name); -- cont_err("size=%lluK mtime=%s", size, ctime(&mtime)); -+ pr_info("size=%lluK mtime=%s", size, ctime(&mtime)); - return 1; - } - --- -2.41.0 - diff --git a/0077-mdadm-Start-update_opt-from-0.patch b/0077-mdadm-Start-update_opt-from-0.patch deleted file mode 100644 index 5578a24..0000000 --- a/0077-mdadm-Start-update_opt-from-0.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 296398299391b10650bdd79d986b115588e60590 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:39 +0800 -Subject: [PATCH 077/157] mdadm: Start update_opt from 0 - -Before f2e8393bd722 ('Manage&Incremental: code refactor, string to enum'), it uses -NULL to represent it doesn't need to update. So init UOPT_UNDEFINED to 0. This -problem is found by test case 05r6tor0. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index b71d7b32..40818941 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -535,7 +535,8 @@ enum special_options { - }; - - enum update_opt { -- UOPT_NAME = 1, -+ UOPT_UNDEFINED = 0, -+ UOPT_NAME, - UOPT_PPL, - UOPT_NO_PPL, - UOPT_BITMAP, -@@ -575,7 +576,6 @@ enum update_opt { - UOPT_SPEC_FAILFAST, - UOPT_SPEC_NOFAILFAST, - UOPT_SPEC_REVERT_RESHAPE_NOBACKUP, -- UOPT_UNDEFINED - }; - extern void fprint_update_options(FILE *outf, enum update_opt update_mode); - --- -2.41.0 - diff --git a/0078-Don-t-control-reshape-speed-in-daemon.patch b/0078-Don-t-control-reshape-speed-in-daemon.patch deleted file mode 100644 index 3b4ed28..0000000 --- a/0078-Don-t-control-reshape-speed-in-daemon.patch +++ /dev/null @@ -1,49 +0,0 @@ -From f79f7189aa25b9da51736f2c578a51c2c4fe7706 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:40 +0800 -Subject: [PATCH 078/157] Don't control reshape speed in daemon - -It tries to set the max sync speed in reshape. This should be done by -administrators by control interfaces /proc/sys/dev/raid/speed_limit_max/min. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 7 ------- - 1 file changed, 7 deletions(-) - -diff --git a/Grow.c b/Grow.c -index 963792d0..b135930d 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -4488,7 +4488,6 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape, - */ - char *buf; - int degraded = -1; -- unsigned long long speed; - unsigned long long suspend_point, array_size; - unsigned long long backup_point, wait_point; - unsigned long long reshape_completed; -@@ -4544,10 +4543,6 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape, - if (posix_memalign((void**)&buf, 4096, disks * chunk)) - /* Don't start the 'reshape' */ - return 0; -- if (reshape->before.data_disks == reshape->after.data_disks) { -- sysfs_get_ll(sra, NULL, "sync_speed_min", &speed); -- sysfs_set_num(sra, NULL, "sync_speed_min", 200000); -- } - - if (increasing) { - array_size = sra->component_size * reshape->after.data_disks; -@@ -4680,8 +4675,6 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape, - sysfs_set_num(sra, NULL, "suspend_lo", 0); - sysfs_set_num(sra, NULL, "sync_min", 0); - -- if (reshape->before.data_disks == reshape->after.data_disks) -- sysfs_set_num(sra, NULL, "sync_speed_min", speed); - free(buf); - return done; - } --- -2.41.0 - diff --git a/0079-mdadm-tests-test-enhance.patch b/0079-mdadm-tests-test-enhance.patch deleted file mode 100644 index ed4263c..0000000 --- a/0079-mdadm-tests-test-enhance.patch +++ /dev/null @@ -1,119 +0,0 @@ -From 6e8af9475cf0ac22f7ac167040dbf92fbfdd97ab Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:41 +0800 -Subject: [PATCH 079/157] mdadm/tests: test enhance - -There are two changes. -First, if md module is not loaded, it gives error when reading -speed_limit_max. So read the value after loading md module which -is done in do_setup - -Second, sometimes the test reports error sync action doesn't -happen. But dmesg shows sync action is done. So limit the sync -speed before test. It doesn't affect the test run time. Because -check wait sets the max speed before waiting sync action. And -recording speed_limit_max/min in do_setup. - -Fixes: 4c12714d1ca0 ('test: run tests on system level mdadm') -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 10 +++++----- - tests/func.sh | 26 +++++++++++++++++++++++--- - 2 files changed, 28 insertions(+), 8 deletions(-) - -diff --git a/test b/test -index 338c2db4..ff403293 100755 ---- a/test -+++ b/test -@@ -6,7 +6,10 @@ targetdir="/var/tmp" - logdir="$targetdir" - config=/tmp/mdadm.conf - testdir=$PWD/tests --system_speed_limit=`cat /proc/sys/dev/raid/speed_limit_max` -+system_speed_limit_max=0 -+system_speed_limit_min=0 -+test_speed_limit_min=100 -+test_speed_limit_max=500 - devlist= - - savelogs=0 -@@ -39,10 +42,6 @@ ctrl_c() { - ctrl_c_error=1 - } - --restore_system_speed_limit() { -- echo $system_speed_limit > /proc/sys/dev/raid/speed_limit_max --} -- - mdadm() { - rm -f $targetdir/stderr - case $* in -@@ -103,6 +102,7 @@ do_test() { - do_clean - # source script in a subshell, so it has access to our - # namespace, but cannot change it. -+ control_system_speed_limit - echo -ne "$_script... " - if ( set -ex ; . $_script ) &> $targetdir/log - then -diff --git a/tests/func.sh b/tests/func.sh -index b474442b..221cff15 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -136,6 +136,23 @@ check_env() { - fi - } - -+record_system_speed_limit() { -+ system_speed_limit_max=`cat /proc/sys/dev/raid/speed_limit_max` -+ system_speed_limit_min=`cat /proc/sys/dev/raid/speed_limit_min` -+} -+ -+# To avoid sync action finishes before checking it, it needs to limit -+# the sync speed -+control_system_speed_limit() { -+ echo $test_speed_limit_min > /proc/sys/dev/raid/speed_limit_min -+ echo $test_speed_limit_max > /proc/sys/dev/raid/speed_limit_max -+} -+ -+restore_system_speed_limit() { -+ echo $system_speed_limit_min > /proc/sys/dev/raid/speed_limit_max -+ echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max -+} -+ - do_setup() { - trap cleanup 0 1 3 15 - trap ctrl_c 2 -@@ -214,6 +231,7 @@ do_setup() { - ulimit -c unlimited - [ -f /proc/mdstat ] || modprobe md_mod - echo 0 > /sys/module/md_mod/parameters/start_ro -+ record_system_speed_limit - } - - # check various things -@@ -265,15 +283,17 @@ check() { - fi - ;; - wait ) -- p=`cat /proc/sys/dev/raid/speed_limit_max` -- echo 2000000 > /proc/sys/dev/raid/speed_limit_max -+ min=`cat /proc/sys/dev/raid/speed_limit_min` -+ max=`cat /proc/sys/dev/raid/speed_limit_max` -+ echo 200000 > /proc/sys/dev/raid/speed_limit_max - sleep 0.1 - while grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat || - grep -v idle > /dev/null /sys/block/md*/md/sync_action - do - sleep 0.5 - done -- echo $p > /proc/sys/dev/raid/speed_limit_max -+ echo $min > /proc/sys/dev/raid/speed_limit_min -+ echo $max > /proc/sys/dev/raid/speed_limit_max - ;; - state ) - grep -sq "blocks.*\[$2\]\$" /proc/mdstat || --- -2.41.0 - diff --git a/0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch b/0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch deleted file mode 100644 index 0d443c0..0000000 --- a/0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 73ba062ef93d0a57360a2d5200bc7a8f8781e7b6 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:42 +0800 -Subject: [PATCH 080/157] mdadm/tests: test don't fail when systemd reports - error - -Sometimes systemd reports error in dmesg and test fails. Add -a condition to avoid this failure. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test b/test -index ff403293..3da53f87 100755 ---- a/test -+++ b/test -@@ -109,7 +109,7 @@ do_test() { - if [ -f "${_script}.inject_error" ]; then - echo "dmesg checking is skipped because test inject error" - else -- dmesg | grep -iq "error\|call trace\|segfault" && -+ dmesg | grep -iq "error\|call trace\|segfault" | grep -v "systemd" && - die "dmesg prints errors when testing $_basename!" - fi - echo "succeeded" --- -2.41.0 - diff --git a/0081-mdadm-tests-names_template-enhance.patch b/0081-mdadm-tests-names_template-enhance.patch deleted file mode 100644 index 71bc49e..0000000 --- a/0081-mdadm-tests-names_template-enhance.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 41706a91568472d10153bf4ada3c3f0d93ef327a Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:43 +0800 -Subject: [PATCH 081/157] mdadm/tests: names_template enhance - -For super1, if the length of hostname is >= 32, it doesn't add hostname -in metadata name. Fix this problem by checking the length of hostname. -Because other cases may use need to check this, so do the check in -do_setup. - -And this patch adds a check if link /dev/md/name exists. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 5 +++++ - tests/func.sh | 13 +++++++++++++ - tests/templates/names_template | 14 ++++++++++++-- - 3 files changed, 30 insertions(+), 2 deletions(-) - -diff --git a/test b/test -index 3da53f87..814ce199 100755 ---- a/test -+++ b/test -@@ -11,6 +11,11 @@ system_speed_limit_min=0 - test_speed_limit_min=100 - test_speed_limit_max=500 - devlist= -+# If super1 metadata name doesn't have the same hostname with machine, -+# it's treated as foreign. -+# For example, /dev/md0 is created, stops it, then assemble it, the -+# device node will be /dev/md127 (127 is choosed by mdadm autumatically) -+is_foreign="no" - - savelogs=0 - exitonerror=1 -diff --git a/tests/func.sh b/tests/func.sh -index 221cff15..cfe83e55 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -153,6 +153,18 @@ restore_system_speed_limit() { - echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max - } - -+is_raid_foreign() { -+ -+ # If the length of hostname is >= 32, super1 doesn't use -+ # hostname in metadata -+ hostname=$(hostname) -+ if [ `expr length $(hostname)` -lt 32 ]; then -+ is_foreign="no" -+ else -+ is_foreign="yes" -+ fi -+} -+ - do_setup() { - trap cleanup 0 1 3 15 - trap ctrl_c 2 -@@ -232,6 +244,7 @@ do_setup() { - [ -f /proc/mdstat ] || modprobe md_mod - echo 0 > /sys/module/md_mod/parameters/start_ro - record_system_speed_limit -+ is_raid_foreign - } - - # check various things -diff --git a/tests/templates/names_template b/tests/templates/names_template -index 1b6cd14b..88ad5b8c 100644 ---- a/tests/templates/names_template -+++ b/tests/templates/names_template -@@ -30,6 +30,7 @@ function names_verify() { - local DEVNODE_NAME="$1" - local WANTED_LINK="$2" - local WANTED_NAME="$3" -+ local EXPECTED="" - - local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)" - if [[ "$?" != "0" ]]; then -@@ -38,7 +39,12 @@ function names_verify() { - fi - - if [[ "$WANTED_LINK" != "empty" ]]; then -- local EXPECTED="MD_DEVNAME=$WANTED_LINK" -+ EXPECTED="MD_DEVNAME=$WANTED_LINK" -+ -+ if [ ! -b /dev/md/$WANTED_LINK ]; then -+ echo "/dev/md/$WANTED_LINK doesn't exit" -+ exit 1 -+ fi - fi - - if [[ "$RES" != "$EXPECTED" ]]; then -@@ -52,7 +58,11 @@ function names_verify() { - exit 1 - fi - -- local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" -+ if [ $is_foreign == "no" ]; then -+ EXPECTED="MD_NAME=$(hostname):$WANTED_NAME" -+ else -+ EXPECTED="MD_NAME=$WANTED_NAME" -+ fi - if [[ "$RES" != "$EXPECTED" ]]; then - echo "$RES doesn't match $EXPECTED." - exit 1 --- -2.41.0 - diff --git a/0082-mdadm-tests-03assem-incr-enhance.patch b/0082-mdadm-tests-03assem-incr-enhance.patch deleted file mode 100644 index 4c0cb2c..0000000 --- a/0082-mdadm-tests-03assem-incr-enhance.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 23f45965a0abe3506885c8e8005ee79473a66422 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:44 +0800 -Subject: [PATCH 082/157] mdadm/tests: 03assem-incr enhance - -It fails when hostname lenght > 32. Because the super1 metadata name -doesn't include hostname when hostname length > 32. Then mdadm thinks -the array is a foreign array if no device link is specified when -assembling the array. It chooses a minor number from 127. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 3 +++ - tests/03assem-incr | 20 +++++++++++++------- - 2 files changed, 16 insertions(+), 7 deletions(-) - -diff --git a/test b/test -index 814ce199..1fce6be2 100755 ---- a/test -+++ b/test -@@ -33,6 +33,9 @@ LVM_VOLGROUP=mdtest - md0=/dev/md0 - md1=/dev/md1 - md2=/dev/md2 -+# if user doesn't specify minor number, mdadm chooses minor number -+# automatically from 127. -+md127=/dev/md127 - mdp0=/dev/md_d0 - mdp1=/dev/md_d1 - -diff --git a/tests/03assem-incr b/tests/03assem-incr -index 38880a7f..21215a34 100644 ---- a/tests/03assem-incr -+++ b/tests/03assem-incr -@@ -9,15 +9,21 @@ set -x -e - levels=(raid0 raid1 raid5) - - if [ "$LINEAR" == "yes" ]; then -- levels+=( linear ) -+ levels+=( linear ) - fi - - for l in ${levels[@]} - do -- mdadm -CR $md0 -l $l -n5 $dev0 $dev1 $dev2 $dev3 $dev4 --assume-clean -- mdadm -S md0 -- mdadm -I $dev1 -- mdadm -I $dev3 -- mdadm -A /dev/md0 $dev0 $dev1 $dev2 $dev3 $dev4 -- mdadm -S /dev/md0 -+ mdadm -CR $md0 -l $l -n5 $dev0 $dev1 $dev2 $dev3 $dev4 --assume-clean -+ mdadm -S $md0 -+ mdadm -I $dev1 -+ mdadm -I $dev3 -+ mdadm -A $md0 $dev0 $dev1 $dev2 $dev3 $dev4 -+ # If one array is foreign (metadata name doesn't have the machine's -+ # hostname), mdadm chooses a minor number automatically from 127 -+ if [ $is_foreign == "no" ]; then -+ mdadm -S $md0 -+ else -+ mdadm -S $md127 -+ fi - done --- -2.41.0 - diff --git a/0083-mdadm-tests-03r0assem-enhance.patch b/0083-mdadm-tests-03r0assem-enhance.patch deleted file mode 100644 index 6552599..0000000 --- a/0083-mdadm-tests-03r0assem-enhance.patch +++ /dev/null @@ -1,38 +0,0 @@ -From f136d9a8b7d8fdfd7539b96707bc9a03528754aa Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:45 +0800 -Subject: [PATCH 083/157] mdadm/tests 03r0assem enhance - -dcc22ae74a864 ('super1: remove support for name= in config') already -removes name= support. So remove related test codes in 03r0assem. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/03r0assem | 10 ---------- - 1 file changed, 10 deletions(-) - -diff --git a/tests/03r0assem b/tests/03r0assem -index f7c29e8c..4bf8b9e8 100644 ---- a/tests/03r0assem -+++ b/tests/03r0assem -@@ -33,16 +33,6 @@ mdadm -As -c $conf $md2 - $tst - mdadm -S $md2 - --{ -- echo DEVICE $devlist -- echo array $md2 name=2 --} > $conf -- --mdadm -As -c $conf $md2 --$tst --mdadm -S $md2 -- -- - { - echo DEVICE $devlist - echo array $md2 devices=$dev0,$dev1,$dev2 --- -2.41.0 - diff --git a/0084-mdadm-tests-remove-03r5assem-failed.patch b/0084-mdadm-tests-remove-03r5assem-failed.patch deleted file mode 100644 index 9086c99..0000000 --- a/0084-mdadm-tests-remove-03r5assem-failed.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 5c1133ba8d026d65362953f25178fbf974b78ce9 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:46 +0800 -Subject: [PATCH 084/157] mdadm/tests: remove 03r5assem-failed - -03r5assem can run successfully with kernel 6.9.0-rc4 - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/03r5assem-failed | 12 ------------ - 1 file changed, 12 deletions(-) - delete mode 100644 tests/03r5assem-failed - -diff --git a/tests/03r5assem-failed b/tests/03r5assem-failed -deleted file mode 100644 -index d38241df..00000000 ---- a/tests/03r5assem-failed -+++ /dev/null -@@ -1,12 +0,0 @@ -- --# Create an array, fail one device while array is active, stop array, --# then re-assemble listing the failed device first. -- --mdadm -CR $md1 -l5 -n4 $dev0 $dev1 $dev2 $dev3 --check wait -- --echo 2000 > /sys/block/md1/md/safe_mode_delay --mkfs $md1 --mdadm $md1 -f $dev0 --mdadm -S $md1 --mdadm -A $md1 $dev0 $dev1 $dev2 $dev3 || exit 1 --- -2.41.0 - diff --git a/0085-mdadm-tests-03r5assemV1.patch b/0085-mdadm-tests-03r5assemV1.patch deleted file mode 100644 index 36eeb14..0000000 --- a/0085-mdadm-tests-03r5assemV1.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 6077e9248acda8c70df58fabc8de23195c19a0cf Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:47 +0800 -Subject: [PATCH 085/157] mdadm/tests: 03r5assemV1 - -dcc22ae74a864 ('super1: remove support for name= in config') already -removes name= support. So remove related test codes in 03r5assemV1. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/03r5assemV1 | 17 ----------------- - 1 file changed, 17 deletions(-) - -diff --git a/tests/03r5assemV1 b/tests/03r5assemV1 -index bca0c583..6026011e 100644 ---- a/tests/03r5assemV1 -+++ b/tests/03r5assemV1 -@@ -31,14 +31,6 @@ conf=$targetdir/mdadm.conf - mdadm -As -c $conf $md1 - eval $tst - --{ -- echo DEVICE $devlist -- echo array $md1 name=one --} > $conf -- --mdadm -As -c $conf --eval $tst -- - { - echo DEVICE $devlist - echo array $md1 devices=$dev0,$dev1,$dev2,$dev3,$dev4 -@@ -88,15 +80,6 @@ mdadm -As -c $conf $md1 - check state U_U - eval $tst - --{ -- echo DEVICE $devlist -- echo array $md1 name=one --} > $conf -- --mdadm -As -c $conf --check state U_U --eval $tst -- - { - echo DEVICE $devlist - echo array $md1 devices=$dev0,$dev1,$dev2 --- -2.41.0 - diff --git a/0086-mdadm-tests-remove-04r5swap.broken.patch b/0086-mdadm-tests-remove-04r5swap.broken.patch deleted file mode 100644 index 7af555c..0000000 --- a/0086-mdadm-tests-remove-04r5swap.broken.patch +++ /dev/null @@ -1,30 +0,0 @@ -From b9b8eaef49e075ce68846abb7cf0ca47c1ba9f2f Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:48 +0800 -Subject: [PATCH 086/157] mdadm/tests: remove 04r5swap.broken - -04r5swap can run successfully with kernel 6.9.0-rc4 - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/04r5swap.broken | 7 ------- - 1 file changed, 7 deletions(-) - delete mode 100644 tests/04r5swap.broken - -diff --git a/tests/04r5swap.broken b/tests/04r5swap.broken -deleted file mode 100644 -index e38987db..00000000 ---- a/tests/04r5swap.broken -+++ /dev/null -@@ -1,7 +0,0 @@ --always fails -- --Fails with errors: -- -- mdadm: /dev/loop0 has no superblock - assembly aborted -- -- ERROR: no recovery happening --- -2.41.0 - diff --git a/0087-tests-04update-metadata-skip-linear.patch b/0087-tests-04update-metadata-skip-linear.patch deleted file mode 100644 index d6aee4a..0000000 --- a/0087-tests-04update-metadata-skip-linear.patch +++ /dev/null @@ -1,116 +0,0 @@ -From 9808f110c5aea5454e9f56b2b660612a57adb347 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:49 +0800 -Subject: [PATCH 087/157] tests/04update-metadata skip linear - -Add one check that if kernel doesn't support linear/multipath, it can -skip linear/multipath testing. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 3 +++ - tests/04update-metadata | 35 ++++++++++++++++++++--------------- - tests/func.sh | 2 ++ - 3 files changed, 25 insertions(+), 15 deletions(-) - -diff --git a/test b/test -index 1fce6be2..f09994e7 100755 ---- a/test -+++ b/test -@@ -17,6 +17,9 @@ devlist= - # device node will be /dev/md127 (127 is choosed by mdadm autumatically) - is_foreign="no" - -+skipping_linear="no" -+skipping_multipath="no" -+ - savelogs=0 - exitonerror=1 - ctrl_c_error=0 -diff --git a/tests/04update-metadata b/tests/04update-metadata -index 2b72a303..c748770c 100644 ---- a/tests/04update-metadata -+++ b/tests/04update-metadata -@@ -8,24 +8,29 @@ set -xe - - dlist="$dev0 $dev1 $dev2 $dev3" - --for ls in linear/4 raid1/1 raid5/3 raid6/2 -+if [ $skipping_linear == "yes" ]; then -+ level_list="raid1/1 raid5/3 raid6/2" -+else -+ level_list="linear/4 raid1/1 raid5/3 raid6/2" -+fi -+for ls in $level_list - do -- s=${ls#*/} l=${ls%/*} -- if [[ $l == 'raid1' ]]; then -- mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 $dlist -- else -- mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist -- fi -- testdev $md0 $s 19904 64 -- mdadm -S $md0 -- mdadm -A $md0 --update=metadata $dlist -- testdev $md0 $s 19904 64 check -- mdadm -S $md0 -+ s=${ls#*/} l=${ls%/*} -+ if [[ $l == 'raid1' ]]; then -+ mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 $dlist -+ else -+ mdadm -CR --assume-clean -e 0.90 $md0 --level $l -n 4 -c 64 $dlist -+ fi -+ testdev $md0 $s 19904 64 -+ mdadm -S $md0 -+ mdadm -A $md0 --update=metadata $dlist -+ testdev $md0 $s 19904 64 check -+ mdadm -S $md0 - done - - if mdadm -A $md0 --update=metadata $dlist - then echo >&2 should fail with v1.0 metadata -- exit 1 -+ exit 1 - fi - - mdadm -CR -e 0.90 $md0 --level=6 -n4 -c32 $dlist -@@ -33,7 +38,7 @@ mdadm -S $md0 - - if mdadm -A $md0 --update=metadata $dlist - then echo >&2 should fail during resync -- exit 1 -+ exit 1 - fi - mdadm -A $md0 $dlist - mdadm --wait $md0 || true -@@ -48,5 +53,5 @@ mdadm -S $md0 - - if mdadm -A $md0 --update=metadata $dlist - then echo >&2 should fail when bitmap present -- exit 1 -+ exit 1 - fi -diff --git a/tests/func.sh b/tests/func.sh -index cfe83e55..db55542d 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -125,6 +125,7 @@ check_env() { - MULTIPATH="yes" - if [ "$MULTIPATH" != "yes" ]; then - echo "test: skipping tests for multipath, which is removed in upstream 6.8+ kernels" -+ skipping_multipath="yes" - fi - - # Check whether to run linear tests -@@ -133,6 +134,7 @@ check_env() { - LINEAR="yes" - if [ "$LINEAR" != "yes" ]; then - echo "test: skipping tests for linear, which is removed in upstream 6.8+ kernels" -+ skipping_linear="yes" - fi - } - --- -2.41.0 - diff --git a/0088-mdadm-tests-05r5-internalbitmap.patch b/0088-mdadm-tests-05r5-internalbitmap.patch deleted file mode 100644 index a01bb9a..0000000 --- a/0088-mdadm-tests-05r5-internalbitmap.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 7664a3851476cfcda931d35f495d03f51707bac9 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:50 +0800 -Subject: [PATCH 088/157] mdadm/tests: 05r5-internalbitmap - -It's not right to compare bitmap bits with a number after io comes. -Because maybe those bits are already flused. Remove the related -tests. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/05r5-internalbitmap | 21 +++++++++------------ - 1 file changed, 9 insertions(+), 12 deletions(-) - -diff --git a/tests/05r5-internalbitmap b/tests/05r5-internalbitmap -index 13dc5921..1a64482f 100644 ---- a/tests/05r5-internalbitmap -+++ b/tests/05r5-internalbitmap -@@ -9,21 +9,20 @@ mdadm -S $md0 - - mdadm --assemble $md0 $dev1 $dev2 $dev3 - testdev $md0 2 $mdsize1 512 --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -+if [ $dirty1 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty1" - exit 1 - fi - mdadm $md0 -f $dev1 - testdev $md0 2 $mdsize1 512 - sleep 4 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+if [ $dirty2 -lt 400 ] - then -- echo >&2 "ERROR dirty count $dirty3 is too small" -+ echo >&2 "ERROR dirty count $dirty2 is too small" - exit 2 - fi - -@@ -33,14 +32,12 @@ mdadm --assemble -R $md0 $dev2 $dev3 - mdadm --zero $dev1 # force --add, not --re-add - mdadm $md0 --add $dev1 - check recovery -- --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - check wait - sleep 4 --dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -+if [ $dirty3 -ne 0 ] -+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty3" - exit 1 - fi - --- -2.41.0 - diff --git a/0089-mdadm-tests-06name-enhance.patch b/0089-mdadm-tests-06name-enhance.patch deleted file mode 100644 index 8b3b6d2..0000000 --- a/0089-mdadm-tests-06name-enhance.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 6e7d850a57d40e18d525d0739a4f4226f6057d91 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:52 +0800 -Subject: [PATCH 089/157] mdadm/tests: 06name enhance - -It needs to check hostname in metadata name if one array is -local. Add the check in this case. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/06name | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) - -diff --git a/tests/06name b/tests/06name -index 86eaab69..c3213f6c 100644 ---- a/tests/06name -+++ b/tests/06name -@@ -3,8 +3,14 @@ set -x - # create an array with a name - - mdadm -CR $md0 -l0 -n2 --metadata=1 --name="Fred" $dev0 $dev1 --mdadm -E $dev0 | grep 'Name : Fred' > /dev/null || exit 1 --mdadm -D $md0 | grep 'Name : Fred' > /dev/null || exit 1 -+ -+if [ $is_foreign == "no" ]; then -+ mdadm -E $dev0 | grep "Name : $(hostname):Fred" > /dev/null || exit 1 -+ mdadm -D $md0 | grep "Name : $(hostname):Fred" > /dev/null || exit 1 -+else -+ mdadm -E $dev0 | grep "Name : Fred" > /dev/null || exit 1 -+ mdadm -D $md0 | grep "Name : Fred" > /dev/null || exit 1 -+fi - mdadm -S $md0 - - mdadm -A $md0 --name="Fred" $devlist --- -2.41.0 - diff --git a/0090-mdadm-tests-07autoassemble.patch b/0090-mdadm-tests-07autoassemble.patch deleted file mode 100644 index f36f95d..0000000 --- a/0090-mdadm-tests-07autoassemble.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 63e99a49cc02cbe4d1777b477719078897fc8308 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:53 +0800 -Subject: [PATCH 090/157] mdadm/tests: 07autoassemble - -This test is used to test stacked array auto assemble. - -There are two different cases depends on if array is foreign or not. -If the array is foreign, the stacked array (md0 is on md1 and md2) -can't be assembled with name md0. Because udev rule will run when md1 -and md2 are assembled and mdadm -I doesn't specify homehost. So it -will treat stacked array (md0) as foreign array and choose md127 as -the device node name (/dev/md127) - -Add the case that stacked array is local. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 2 ++ - tests/07autoassemble | 37 +++++++++++++++++++++++++++++++++++-- - tests/07autoassemble.broken | 8 -------- - 3 files changed, 37 insertions(+), 10 deletions(-) - delete mode 100644 tests/07autoassemble.broken - -diff --git a/test b/test -index f09994e7..4a88de58 100755 ---- a/test -+++ b/test -@@ -39,6 +39,8 @@ md2=/dev/md2 - # if user doesn't specify minor number, mdadm chooses minor number - # automatically from 127. - md127=/dev/md127 -+md126=/dev/md126 -+md125=/dev/md125 - mdp0=/dev/md_d0 - mdp1=/dev/md_d1 - -diff --git a/tests/07autoassemble b/tests/07autoassemble -index e689be7c..9dc78149 100644 ---- a/tests/07autoassemble -+++ b/tests/07autoassemble -@@ -10,7 +10,14 @@ mdadm -Ss - mdadm -As -c /dev/null --homehost=testing -vvv - testdev $md1 1 $mdsize1a 64 - testdev $md2 1 $mdsize1a 64 --testdev $md0 2 $mdsize11a 512 -+# md1 and md2 will be incremental assemble by udev rule. And -+# the testing machines' hostname is not testing. The md0 will -+# be considered as a foreign array. It can use 0 as metadata -+# name. md127 will be used -+testdev $md127 2 $mdsize11a 512 -+mdadm --stop $md127 -+mdadm --zero-superblock $md1 -+mdadm --zero-superblock $md2 - mdadm -Ss - - mdadm --zero-superblock $dev0 $dev1 $dev2 $dev3 -@@ -20,5 +27,31 @@ mdadm -CR $md0 -l0 -n2 $md1 $dev2 --homehost=testing - mdadm -Ss - mdadm -As -c /dev/null --homehost=testing -vvv - testdev $md1 1 $mdsize1a 64 --testdev $md0 1 $[mdsize1a+mdsize11a] 512 -+testdev $md127 1 $[mdsize1a+mdsize11a] 512 -+mdadm --stop $md127 -+mdadm --zero-superblock $md1 -+mdadm -Ss -+ -+# Don't specify homehost when creating raid and use the test -+# machine's homehost. For super1.2, if homehost name's length -+# is > 32, it doesn't use homehost name in metadata name and -+# the array will be treated as foreign array -+mdadm --zero-superblock $dev0 $dev1 $dev2 $dev3 -+mdadm -CR $md1 -l1 -n2 $dev0 $dev1 -+mdadm -CR $md2 -l1 -n2 $dev2 $dev3 -+mdadm -CR $md0 -l0 -n2 $md1 $md2 -+mdadm -Ss -+mdadm -As -c /dev/null -+if [ $is_foreign == "yes" ]; then -+ # md127 is md1 -+ testdev $md127 1 $mdsize1a 64 -+ # md126 is md0, udev rule incremental assemble it -+ testdev $md126 2 $mdsize11a 512 -+ # md125 is md2 -+ testdev $md125 1 $mdsize1a 64 -+else -+ testdev $md1 1 $mdsize1a 64 -+ testdev $md2 1 $mdsize1a 64 -+ testdev $md0 2 $mdsize11a 512 -+fi - mdadm -Ss -diff --git a/tests/07autoassemble.broken b/tests/07autoassemble.broken -deleted file mode 100644 -index 8be09407..00000000 ---- a/tests/07autoassemble.broken -+++ /dev/null -@@ -1,8 +0,0 @@ --always fails -- --Prints lots of messages, but the array doesn't assemble. Error --possibly related to: -- -- mdadm: /dev/md/1 is busy - skipping -- mdadm: no recogniseable superblock on /dev/md/testing:0 -- mdadm: /dev/md/2 is busy - skipping --- -2.41.0 - diff --git a/0091-mdadm-tests-07autodetect.broken-can-be-removed.patch b/0091-mdadm-tests-07autodetect.broken-can-be-removed.patch deleted file mode 100644 index 89df7b2..0000000 --- a/0091-mdadm-tests-07autodetect.broken-can-be-removed.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 1d0c61f4baa49bc218687017ccb2e3a664351390 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:54 +0800 -Subject: [PATCH 091/157] mdadm/tests: 07autodetect.broken can be removed - -07autodetect can run successfully without error in kernel 6.9.0-rc5. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/07autodetect.broken | 5 ----- - 1 file changed, 5 deletions(-) - delete mode 100644 tests/07autodetect.broken - -diff --git a/tests/07autodetect.broken b/tests/07autodetect.broken -deleted file mode 100644 -index 294954a1..00000000 ---- a/tests/07autodetect.broken -+++ /dev/null -@@ -1,5 +0,0 @@ --always fails -- --Fails with error: -- -- ERROR: no resync happening --- -2.41.0 - diff --git a/0092-mdadm-tests-07changelevelintr.patch b/0092-mdadm-tests-07changelevelintr.patch deleted file mode 100644 index a1f0f24..0000000 --- a/0092-mdadm-tests-07changelevelintr.patch +++ /dev/null @@ -1,73 +0,0 @@ -From cd3b2350bef136b20c81190371fb0b60d62a0365 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:55 +0800 -Subject: [PATCH 092/157] mdadm/tests: 07changelevelintr - -It needs to specify a 2 powered array size when updating array size. -If not, it can't change chunksize. - -And sometimes it reports error reshape doesn't happen. In fact the -reshape has finished. It doesn't need to wait before checking -reshape action. Because check function waits itself. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/07changelevelintr | 9 +++++---- - tests/07changelevelintr.broken | 9 --------- - 2 files changed, 5 insertions(+), 13 deletions(-) - delete mode 100644 tests/07changelevelintr.broken - -diff --git a/tests/07changelevelintr b/tests/07changelevelintr -index 18c63092..d921f2b2 100644 ---- a/tests/07changelevelintr -+++ b/tests/07changelevelintr -@@ -27,11 +27,9 @@ checkgeo() { - } - - restart() { -- sleep 0.5 - check reshape - mdadm -S $md0 - mdadm -A $md0 $devs --backup-file=$bu -- sleep 0.5 - check reshape - } - -@@ -49,13 +47,16 @@ mdadm -G $md0 --layout rs --backup-file=$bu - restart - checkgeo md0 raid5 5 $[128*1024] 3 - --mdadm -G $md0 --array-size 58368 -+# It needs to shrink array size first. Choose a value that -+# is power of 2 for array size. If not, it can't change -+# chunk size. -+mdadm -G $md0 --array-size 51200 - mdadm -G $md0 --raid-disks 4 -c 64 --backup-file=$bu - restart - checkgeo md0 raid5 4 $[64*1024] 3 - - devs="$dev0 $dev1 $dev2 $dev3" --mdadm -G $md0 --array-size 19456 -+mdadm -G $md0 --array-size 18432 - mdadm -G $md0 -n 2 -c 256 --backup-file=$bu - restart - checkgeo md0 raid5 2 $[256*1024] 3 -diff --git a/tests/07changelevelintr.broken b/tests/07changelevelintr.broken -deleted file mode 100644 -index 284b4906..00000000 ---- a/tests/07changelevelintr.broken -+++ /dev/null -@@ -1,9 +0,0 @@ --always fails -- --Fails with errors: -- -- mdadm: this change will reduce the size of the array. -- use --grow --array-size first to truncate array. -- e.g. mdadm --grow /dev/md0 --array-size 56832 -- -- ERROR: no reshape happening --- -2.41.0 - diff --git a/0093-mdadm-tests-disable-selinux.patch b/0093-mdadm-tests-disable-selinux.patch deleted file mode 100644 index e00b325..0000000 --- a/0093-mdadm-tests-disable-selinux.patch +++ /dev/null @@ -1,68 +0,0 @@ -From b914aa25ee1fe3e0bd97f58bdf2bfdd185992a79 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 22 May 2024 16:50:56 +0800 -Subject: [PATCH 093/157] mdadm/tests: disable selinux - -Sometimes systemd service fails because selinux. Disable selinux -during testing now. We can enable it in future when having a better -method. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - test | 3 +++ - tests/func.sh | 10 ++++++++++ - 2 files changed, 13 insertions(+) - -diff --git a/test b/test -index 4a88de58..47f53ad7 100755 ---- a/test -+++ b/test -@@ -16,6 +16,8 @@ devlist= - # For example, /dev/md0 is created, stops it, then assemble it, the - # device node will be /dev/md127 (127 is choosed by mdadm autumatically) - is_foreign="no" -+#disable selinux -+sys_selinux="Permissive" - - skipping_linear="no" - skipping_multipath="no" -@@ -351,6 +353,7 @@ main() { - fi - done - -+ restore_selinux - exit 0 - } - -diff --git a/tests/func.sh b/tests/func.sh -index db55542d..b2e4d122 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -167,6 +167,15 @@ is_raid_foreign() { - fi - } - -+record_selinux() { -+ sys_selinux=`getenforce` -+ setenforce Permissive -+} -+ -+restore_selinux() { -+ setenforce $sys_selinux -+} -+ - do_setup() { - trap cleanup 0 1 3 15 - trap ctrl_c 2 -@@ -247,6 +256,7 @@ do_setup() { - echo 0 > /sys/module/md_mod/parameters/start_ro - record_system_speed_limit - is_raid_foreign -+ record_selinux - } - - # check various things --- -2.41.0 - diff --git a/0094-mdadm-platform-intel-buffer-overflow-detected.patch b/0094-mdadm-platform-intel-buffer-overflow-detected.patch deleted file mode 100644 index 7cf6d1d..0000000 --- a/0094-mdadm-platform-intel-buffer-overflow-detected.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 827e1870f320545796d907f50af594e901399417 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 28 May 2024 16:44:39 +0800 -Subject: [PATCH 094/157] mdadm/platform-intel: buffer overflow detected - -mdadm -CR /dev/md0 -l1 -n2 /dev/nvme0n1 /dev/nvme2n1 -*** buffer overflow detected ***: terminated -Aborted (core dumped) - -It doesn't happen 100% and it depends on the building environment. -It can be fixed by replacing sprintf with snprintf. - -Fixes: d835518b6b53 ('imsm: nvme multipath support') -Reported-by: Guang Wu -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - platform-intel.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/platform-intel.c b/platform-intel.c -index 15a9fa5a..d6a53533 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -907,14 +907,14 @@ char *get_nvme_multipath_dev_hw_path(const char *dev_path) - return NULL; - - for (ent = readdir(dir); ent; ent = readdir(dir)) { -- char buf[strlen(dev_path) + strlen(ent->d_name) + 1]; -+ char buf[PATH_MAX]; - - /* Check if dir is a controller, ignore namespaces*/ - if (!(strncmp(ent->d_name, "nvme", 4) == 0) || - (strrchr(ent->d_name, 'n') != &ent->d_name[0])) - continue; - -- sprintf(buf, "%s/%s", dev_path, ent->d_name); -+ snprintf(buf, PATH_MAX, "%s/%s", dev_path, ent->d_name); - rp = realpath(buf, NULL); - break; - } --- -2.41.0 - diff --git a/0095-mdadm-tests-bitmap-cases-enhance.patch b/0095-mdadm-tests-bitmap-cases-enhance.patch deleted file mode 100644 index 56b36b0..0000000 --- a/0095-mdadm-tests-bitmap-cases-enhance.patch +++ /dev/null @@ -1,279 +0,0 @@ -From c006602b313e2f6062b51aad37d93dccd29649de Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 28 May 2024 21:51:47 +0800 -Subject: [PATCH 095/157] mdadm/tests: bitmap cases enhance - -It fails because bitmap dirty number is smaller than 400 sometimes. It's not -good to compare bitmap dirty bits with a number. It depends on the test -machine, it can flush soon before checking the number. So remove related codes. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/05r1-grow-internal | 11 ++++------- - tests/05r1-grow-internal-1 | 12 ++++-------- - tests/05r1-internalbitmap | 22 ++++++++++------------ - tests/05r1-internalbitmap-v1a | 22 ++++++++++------------ - tests/05r1-internalbitmap-v1b | 23 ++++++++++------------- - tests/05r1-internalbitmap-v1c | 22 ++++++++++------------ - 6 files changed, 48 insertions(+), 64 deletions(-) - -diff --git a/tests/05r1-grow-internal b/tests/05r1-grow-internal -index 24b3aece..f7fff989 100644 ---- a/tests/05r1-grow-internal -+++ b/tests/05r1-grow-internal -@@ -8,18 +8,15 @@ testdev $md0 1 $mdsize1a 64 - - #mdadm -E $dev1 - mdadm --grow $md0 --bitmap=internal --bitmap-chunk=4 --delay=1 || { mdadm -X $dev2 ; exit 1; } --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - - testdev $md0 1 $mdsize1a 64 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --#echo $dirty1 $dirty2 $dirty3 $dirty4 --if [ $dirty2 -ne 0 -o $dirty4 -ne 0 -o $dirty3 -lt 400 ] --then -+if [ $dirty1 -ne 0 -o $dirty2 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: dirty1 $dirty1, dirty2 $dirty2" - echo bad dirty counts - exit 1 - fi -diff --git a/tests/05r1-grow-internal-1 b/tests/05r1-grow-internal-1 -index 2f0d8237..f0f8349f 100644 ---- a/tests/05r1-grow-internal-1 -+++ b/tests/05r1-grow-internal-1 -@@ -8,19 +8,15 @@ testdev $md0 1 $mdsize1b 64 - - #mdadm -E $dev1 - mdadm --grow $md0 --bitmap=internal --bitmap-chunk=4 --delay=1 --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - - testdev $md0 1 $mdsize1b 64 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --#echo $dirty1 $dirty2 $dirty3 $dirty4 --if [ $dirty2 -ne 0 -o $dirty4 -ne 0 -o $dirty3 -lt 400 ] --then -- echo bad dirty counts -+if [ $dirty1 -ne 0 -o $dirty2 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: dirty1 $dirty1, dirty2 $dirty2" - exit 1 - fi - -diff --git a/tests/05r1-internalbitmap b/tests/05r1-internalbitmap -index dd7232a7..f1a2843e 100644 ---- a/tests/05r1-internalbitmap -+++ b/tests/05r1-internalbitmap -@@ -9,21 +9,20 @@ mdadm -S $md0 - - mdadm --assemble $md0 $dev1 $dev2 - testdev $md0 1 $mdsize0 64 --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -+if [ $dirty1 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty1" - exit 1 - fi - mdadm $md0 -f $dev1 - testdev $md0 1 $mdsize0 64 - sleep 4 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -+total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+if [ $dirty2 -ne $total ] -+then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" - exit 2 - fi - -@@ -34,13 +33,12 @@ mdadm --zero-superblock $dev1 - mdadm $md0 --add $dev1 - check recovery - --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - check wait - sleep 4 --dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -+if [ $dirty3 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty3" - exit 1 - fi - -diff --git a/tests/05r1-internalbitmap-v1a b/tests/05r1-internalbitmap-v1a -index 3ddc082f..cf3f3972 100644 ---- a/tests/05r1-internalbitmap-v1a -+++ b/tests/05r1-internalbitmap-v1a -@@ -10,21 +10,20 @@ mdadm -S $md0 - - mdadm --assemble $md0 $dev1 $dev2 - testdev $md0 1 $mdsize1b 64 --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -+if [ $dirty1 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty1" - exit 1 - fi - mdadm $md0 -f $dev1 - testdev $md0 1 $mdsize1b 64 - sleep 4 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -+total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+if [ $dirty2 -ne $total ] -+then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" - exit 2 - fi - -@@ -35,13 +34,12 @@ mdadm --assemble -R $md0 $dev2 - mdadm $md0 --add $dev1 - check recovery - --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - check wait - sleep 4 --dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -+if [ $dirty3 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty3" - exit 1 - fi - -diff --git a/tests/05r1-internalbitmap-v1b b/tests/05r1-internalbitmap-v1b -index 40f7abea..4952887e 100644 ---- a/tests/05r1-internalbitmap-v1b -+++ b/tests/05r1-internalbitmap-v1b -@@ -11,21 +11,20 @@ mdadm -S $md0 - mdadm --assemble $md0 $dev1 $dev2 - check bitmap - testdev $md0 1 $mdsize11 64 --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -+if [ $dirty1 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty1" - exit 1 - fi - mdadm $md0 -f $dev1 - testdev $md0 1 $mdsize11 64 - sleep 4 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -+total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+if [ $dirty2 -ne $total ] -+then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" - exit 2 - fi - -@@ -35,14 +34,12 @@ mdadm --zero-superblock $dev1 - mdadm --assemble -R $md0 $dev2 - mdadm $md0 --add $dev1 - check recovery -- --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - check wait - sleep 4 --dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -+if [ $dirty3 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty3" - exit 1 - fi - -diff --git a/tests/05r1-internalbitmap-v1c b/tests/05r1-internalbitmap-v1c -index 2eaea59b..e1e4472f 100644 ---- a/tests/05r1-internalbitmap-v1c -+++ b/tests/05r1-internalbitmap-v1c -@@ -10,21 +10,20 @@ mdadm -S $md0 - - mdadm --assemble $md0 $dev1 $dev2 - testdev $md0 1 $mdsize12 64 --dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - sleep 4 --dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ] --then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2" -+if [ $dirty1 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty1" - exit 1 - fi - mdadm $md0 -f $dev1 - testdev $md0 1 $mdsize12 64 - sleep 4 --dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` --if [ $dirty3 -lt 400 ] --then -- echo >&2 "ERROR dirty count $dirty3 is too small" -+total=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) bits.*/\1/p'` -+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+if [ $dirty2 -ne $total ] -+then echo >&2 "ERROR bad 'dirty' counts: total $total, dirty2 $dirty2" - exit 2 - fi - -@@ -35,13 +34,12 @@ mdadm --assemble -R $md0 $dev2 - mdadm $md0 --add $dev1 - check recovery - --dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - check wait - sleep 4 --dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` -+dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'` - --if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ] --then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5" -+if [ $dirty3 -ne 0 ] -+then echo >&2 "ERROR bad 'dirty' counts: $dirty3" - exit 1 - fi - --- -2.41.0 - diff --git a/0096-mdadm-tests-04update-uuid.patch b/0096-mdadm-tests-04update-uuid.patch deleted file mode 100644 index d3bf9ed..0000000 --- a/0096-mdadm-tests-04update-uuid.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 19cde79fda386329f69ead15ca6ae26527fab707 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 28 May 2024 21:51:48 +0800 -Subject: [PATCH 096/157] mdadm/tests: 04update-uuid - -Patch 50b100768a11('mdadm: deprecate bitmap custom file') needs to confirm when -creating raid device with bitmap file. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/04update-uuid | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tests/04update-uuid b/tests/04update-uuid -index a4409e78..25314ab5 100644 ---- a/tests/04update-uuid -+++ b/tests/04update-uuid -@@ -25,7 +25,7 @@ mdadm -S /dev/md0 - - # now if we have a bitmap, that needs updating too. - rm -f $targetdir/bitmap --mdadm -CR --assume-clean -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 -+yes | mdadm -CR --assume-clean -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 - mdadm -S /dev/md0 - mdadm -A /dev/md0 -b $targetdir/bitmap --update=uuid --uuid=0123456789abcdef:fedcba9876543210 $dev0 $dev1 $dev2 - no_errors -@@ -41,7 +41,7 @@ mdadm -S /dev/md0 - - # and bitmap for version1 - rm -f $targetdir/bitmap --mdadm -CR --assume-clean -e1.1 -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 -+yes | mdadm -CR --assume-clean -e1.1 -b $targetdir/bitmap $md0 -l5 -n3 $dev0 $dev1 $dev2 - mdadm -S /dev/md0 - mdadm -A /dev/md0 -b $targetdir/bitmap --update=uuid --uuid=0123456789abcdef:fedcba9876543210 $dev0 $dev1 $dev2 - no_errors --- -2.41.0 - diff --git a/0097-mdadm-tests-05r1-re-add-nosuper.patch b/0097-mdadm-tests-05r1-re-add-nosuper.patch deleted file mode 100644 index 55ffbd8..0000000 --- a/0097-mdadm-tests-05r1-re-add-nosuper.patch +++ /dev/null @@ -1,30 +0,0 @@ -From c36477fac2e485fd294e5cb48d411b548c654f30 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 28 May 2024 21:51:49 +0800 -Subject: [PATCH 097/157] mdadm/tests: 05r1-re-add-nosuper - -Patch 50b100768a11('mdadm: deprecate bitmap custom file') needs to confirm when -creating raid device with bitmap file. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/05r1-re-add-nosuper | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/05r1-re-add-nosuper b/tests/05r1-re-add-nosuper -index 058d602d..7d41fd7b 100644 ---- a/tests/05r1-re-add-nosuper -+++ b/tests/05r1-re-add-nosuper -@@ -6,7 +6,7 @@ - # - bmf=$targetdir/bitmap2 - rm -f $bmf --mdadm -B $md0 -l1 -n2 -b$bmf -d1 $dev1 $dev2 -+yes | mdadm -B $md0 -l1 -n2 -b$bmf -d1 $dev1 $dev2 - check resync - check wait - testdev $md0 1 $size 1 --- -2.41.0 - diff --git a/0098-mdadm-tests-remove-strace-test.patch b/0098-mdadm-tests-remove-strace-test.patch deleted file mode 100644 index 964b06d..0000000 --- a/0098-mdadm-tests-remove-strace-test.patch +++ /dev/null @@ -1,44 +0,0 @@ -From c5a4fe7874f94b3f172027043f9a94b037f4d4dd Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 28 May 2024 21:51:50 +0800 -Subject: [PATCH 098/157] mdadm/tests: remove strace test - -Some tests will fail if the test env doesn't have strace -commands. So remove the dependency. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/07revert-grow | 2 +- - tests/07revert-inplace | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tests/07revert-grow b/tests/07revert-grow -index c8c4e855..333483dc 100644 ---- a/tests/07revert-grow -+++ b/tests/07revert-grow -@@ -43,7 +43,7 @@ testdev $md0 2 $mdsize1 512 - mdadm -G $md0 -n 5 - sleep 3 - mdadm -S $md0 --strace -o /tmp/str ./mdadm -A $md0 --update=revert-reshape $devlist4 -+mdadm -A $md0 --update=revert-reshape $devlist4 - check wait - check raid10 - testdev $md0 2 $mdsize1 512 -diff --git a/tests/07revert-inplace b/tests/07revert-inplace -index a73eb977..776324ac 100644 ---- a/tests/07revert-inplace -+++ b/tests/07revert-inplace -@@ -37,7 +37,7 @@ testdev $md0 3 $mdsize1 64 - mdadm -G $md0 -c 32 - sleep 2 - mdadm -S $md0 --strace -o /tmp/str ./mdadm -A $md0 --update=revert-reshape $devlist5 -+mdadm -A $md0 --update=revert-reshape $devlist5 - check wait - check raid10 - testdev $md0 3 $mdsize1 64 --- -2.41.0 - diff --git a/0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch b/0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch deleted file mode 100644 index 0a458da..0000000 --- a/0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 9dbd11e091f84eb0bf9d717283774816c4c4453d Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 21 May 2024 16:26:33 +0200 -Subject: [PATCH 099/157] mdadm.h: provide basename if GLIBC is not avialable - -If GNU basename is not avilable, define it. It is safer to use that -rather than include libgen.h with XPG basename() definition. - -Fixes:#12 - -Signed-off-by: Mariusz Tkaczyk ---- - mdadm.h | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/mdadm.h b/mdadm.h -index 40818941..e9f764a2 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -223,6 +223,14 @@ struct dlm_lksb { - struct __una_u16 { __u16 x; } __attribute__ ((packed)); - struct __una_u32 { __u32 x; } __attribute__ ((packed)); - -+/* -+ * Ensure GNU basename behavior on GLIBC less systems. -+ */ -+#ifndef __GLIBC__ -+#define basename(path) \ -+ (strrchr((path), '/') ? strrchr((path),'/') + 1 : (path)) -+#endif -+ - static inline __u16 __get_unaligned16(const void *p) - { - const struct __una_u16 *ptr = (const struct __una_u16 *)p; --- -2.41.0 - diff --git a/0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch b/0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch deleted file mode 100644 index 1ab7f08..0000000 --- a/0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 46f19270265fe54cda1c728cb156b755273b4ab6 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 23 May 2024 12:06:36 +0200 -Subject: [PATCH 100/157] imsm: fix first volume autolayout with - IMSM_NO_PLATFORM - -Autolayout_imsm() is not executed if IMSM_NO_PLATFORM=1 is set. -This causes that first volume cannot be created. Disk for new volume are -never configured. - -Fix it by making autolayout_imsm() independent from super->orom because -NULL there means that IMSM_NO_PLATFORM=1 is set. There are not platform -restrictions to create volume, we just analyze drives. It is safe. - -Fixes: 6d4d9ab295de ("imsm: use same slot across container") -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 0287a618..29652196 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7706,9 +7706,11 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - char *dev, unsigned long long *freesize, - int consistency_policy, int verbose) - { -- int fd, cfd; -+ struct intel_super *super = st->sb; - struct mdinfo *sra; - int is_member = 0; -+ imsm_status_t rv; -+ int fd, cfd; - - /* load capability - * if given unused devices create a container -@@ -7733,11 +7735,10 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - } - - if (!dev) { -- struct intel_super *super = st->sb; -- - /* - * Autolayout mode, st->sb must be set. - */ -+ - if (!super) { - pr_vrb("superblock must be set for autolayout, aborting\n"); - return 0; -@@ -7749,20 +7750,19 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - return 0; - - if (super->orom && freesize) { -- imsm_status_t rv; -- int count = count_volumes(super->hba, super->orom->dpa, -- verbose); -+ int count = count_volumes(super->hba, super->orom->dpa, verbose); -+ - if (super->orom->vphba <= count) { - pr_vrb("platform does not support more than %d raid volumes.\n", - super->orom->vphba); - return 0; - } -+ } - -- rv = autolayout_imsm(super, raiddisks, size, *chunk, -- freesize); -+ rv = autolayout_imsm(super, raiddisks, size, *chunk, freesize); - if (rv != IMSM_STATUS_OK) - return 0; -- } -+ - return 1; - } - if (st->sb) { --- -2.41.0 - diff --git a/0101-imsm-make-freesize-required-to-volume-autolayout.patch b/0101-imsm-make-freesize-required-to-volume-autolayout.patch deleted file mode 100644 index ddd148e..0000000 --- a/0101-imsm-make-freesize-required-to-volume-autolayout.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 4f3efc34644d06f55fc650e4aa6b5a6ec22cea5f Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Tue, 11 Jun 2024 07:58:49 +0200 -Subject: [PATCH 101/157] imsm: make freesize required to volume autolayout - -Autolayout_imsm() shall be executed when IMSM_NO_PLATFORM=1 is set. -It was fixed by listed commit, checking super->orom was removed, but -also checking freesize. Freesize is not set for operations on RAID -volume with no size update, that's why it is not required to have -this value and always run autolayout_imsm(). -Fix it by making autolayout_imsm() dependent on freesize. - -Fixes: 46f192 ("imsm: fix first volume autolayout with IMSM_NO_PLATFORM") - -Signed-off-by: Kinga Stefaniuk ---- - super-intel.c | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 29652196..ef3f5da1 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7749,7 +7749,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - verbose)) - return 0; - -- if (super->orom && freesize) { -+ if (super->orom) { - int count = count_volumes(super->hba, super->orom->dpa, verbose); - - if (super->orom->vphba <= count) { -@@ -7759,9 +7759,11 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - } - } - -- rv = autolayout_imsm(super, raiddisks, size, *chunk, freesize); -- if (rv != IMSM_STATUS_OK) -- return 0; -+ if (freesize) { -+ rv = autolayout_imsm(super, raiddisks, size, *chunk, freesize); -+ if (rv != IMSM_STATUS_OK) -+ return 0; -+ } - - return 1; - } --- -2.41.0 - diff --git a/0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch b/0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch deleted file mode 100644 index 3b8048a..0000000 --- a/0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 1a5c0e60308651a20d25ff52511230a20d830330 Mon Sep 17 00:00:00 2001 -From: Logan Gunthorpe -Date: Tue, 4 Jun 2024 10:38:36 -0600 -Subject: [PATCH 102/157] mdadm: Fix hang race condition in - wait_for_zero_forks() - -Running a create operation with --write-zeros can randomly hang -forever waiting for child processes. This happens roughly on in -ten runs with when running with small (20MB) loop devices. - -The bug is caused by the fact that signals can be coallesced into -one if they are not read by signalfd quick enough. So if two children -finish at exactly the same time, only one SIGCHLD will be received -by the parent. - -To fix this, wait on all processes with WNOHANG every time a SIGCHLD -is received and exit when all processes have been waited on. - -Reported-by: Xiao Ni -Signed-off-by: Logan Gunthorpe -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 28 +++++++++++++++------------- - 1 file changed, 15 insertions(+), 13 deletions(-) - -diff --git a/Create.c b/Create.c -index d033eb68..4f992a22 100644 ---- a/Create.c -+++ b/Create.c -@@ -178,6 +178,7 @@ static int wait_for_zero_forks(int *zero_pids, int count) - bool interrupted = false; - sigset_t sigset; - ssize_t s; -+ pid_t pid; - - for (i = 0; i < count; i++) - if (zero_pids[i]) -@@ -196,7 +197,7 @@ static int wait_for_zero_forks(int *zero_pids, int count) - return 1; - } - -- while (1) { -+ while (wait_count) { - s = read(sfd, &fdsi, sizeof(fdsi)); - if (s != sizeof(fdsi)) { - pr_err("Invalid signalfd read: %s\n", strerror(errno)); -@@ -209,23 +210,24 @@ static int wait_for_zero_forks(int *zero_pids, int count) - pr_info("Interrupting zeroing processes, please wait...\n"); - interrupted = true; - } else if (fdsi.ssi_signo == SIGCHLD) { -- if (!--wait_count) -- break; -+ for (i = 0; i < count; i++) { -+ if (!zero_pids[i]) -+ continue; -+ -+ pid = waitpid(zero_pids[i], &wstatus, WNOHANG); -+ if (pid <= 0) -+ continue; -+ -+ zero_pids[i] = 0; -+ if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus)) -+ ret = 1; -+ wait_count--; -+ } - } - } - - close(sfd); - -- for (i = 0; i < count; i++) { -- if (!zero_pids[i]) -- continue; -- -- waitpid(zero_pids[i], &wstatus, 0); -- zero_pids[i] = 0; -- if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus)) -- ret = 1; -- } -- - if (interrupted) { - pr_err("zeroing interrupted!\n"); - return 1; --- -2.41.0 - diff --git a/0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch b/0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch deleted file mode 100644 index d2fe3f0..0000000 --- a/0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 539ad6e6f9a067646a018d77582af0babf8e125e Mon Sep 17 00:00:00 2001 -From: Logan Gunthorpe -Date: Tue, 4 Jun 2024 10:38:37 -0600 -Subject: [PATCH 103/157] mdadm: Block SIGCHLD processes before starting - children - -There is a small race condition noticed during code review, but -never actully hit in practice, with the write_zero feature. - -If a write zeros fork finishes quickly before wait_for_zero_forks() -gets called, then the SIGCHLD will be delivered before the signalfd -is setup. - -While this is only theoretical, fix this by blocking the SIGCHLD -signal before forking any children. - -Signed-off-by: Logan Gunthorpe -Signed-off-by: Mariusz Tkaczyk ---- - Create.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Create.c b/Create.c -index 4f992a22..bd4875e4 100644 ---- a/Create.c -+++ b/Create.c -@@ -401,6 +401,7 @@ static int add_disks(int mdfd, struct mdinfo *info, struct shape *s, - */ - sigemptyset(&sigset); - sigaddset(&sigset, SIGINT); -+ sigaddset(&sigset, SIGCHLD); - sigprocmask(SIG_BLOCK, &sigset, &orig_sigset); - memset(zero_pids, 0, sizeof(zero_pids)); - --- -2.41.0 - diff --git a/0104-test-pass-flags-to-services.patch b/0104-test-pass-flags-to-services.patch deleted file mode 100644 index ad7606e..0000000 --- a/0104-test-pass-flags-to-services.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 29aa21d94bc7ff10f3f7ef0b7f490f3903f5c6fd Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -Date: Fri, 15 Mar 2024 16:03:09 -0400 -Subject: [PATCH 104/157] test: pass flags to services - -Commit 4c12714d1ca0 ("test: run tests on system level mdadm") removed -MDADM_NO_SYSTEMCTL flag from test suite. This causes imsm tests to fail -as mdadm no longer triggers mdmon and flags exists only within session. - -Use systemd set/unset-environment to pass necessary flags. - -Introduce colors to grab users attention to warnings and key messages. - -Make test suite setup systemd environment. -Add setup/clean_systemd_env() functions. -Warn user about altering systemd environment. - -Add colors to success/fail messages and warnings. - -Signed-off-by: Mateusz Kusiak ---- - test | 8 +++----- - tests/func.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++- - 2 files changed, 48 insertions(+), 6 deletions(-) - -diff --git a/test b/test -index 47f53ad7..3a05bc9b 100755 ---- a/test -+++ b/test -@@ -127,7 +127,7 @@ do_test() { - dmesg | grep -iq "error\|call trace\|segfault" | grep -v "systemd" && - die "dmesg prints errors when testing $_basename!" - fi -- echo "succeeded" -+ succeed "succeeded\n" - _fail=0 - else - save_log fail -@@ -315,10 +315,8 @@ parse_args() { - } - - print_warning() { -- cat <<-EOF -- Warning! Tests are performed on system level mdadm! -- If you want to test local build, you need to install it first! -- EOF -+ warn "Warning! Tests are performed on system level mdadm!\n" -+ echo "If you want to test local build, you need to install it first!" - } - - main() { -diff --git a/tests/func.sh b/tests/func.sh -index b2e4d122..8c142c76 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -23,6 +23,28 @@ mdsize12=19988 - # ddf needs bigger devices as 32Meg is reserved! - ddfsize=65536 - -+# Systemd flags -+devname_as_serial_flag="IMSM_DEVNAME_AS_SERIAL=1" -+no_platform_flag="IMSM_NO_PLATFORM=1" -+ -+# Common colors -+COLOR_FAIL='\033[0;31m' #RED -+COLOR_WARN='\033[1;33m' #YELLOW -+COLOR_SUCCESS='\033[0;32m' #GREEN -+COLOR_NONE='\033[0m' -+ -+fail() { -+ printf "${COLOR_FAIL}$1${COLOR_NONE}" -+} -+ -+warn() { -+ printf "${COLOR_WARN}$1${COLOR_NONE}" -+} -+ -+succeed() { -+ printf "${COLOR_SUCCESS}$1${COLOR_NONE}" -+} -+ - # $1 is optional parameter, it shows why to save log - save_log() { - status=$1 -@@ -36,7 +58,8 @@ save_log() { - cat /proc/mdstat >> $logdir/$logfile - array=($(mdadm -Ds | cut -d' ' -f2)) - [ "$1" == "fail" ] && -- echo "FAILED - see $logdir/$_basename.log and $logdir/$logfile for details" -+ fail "FAILED" -+ echo " - see $logdir/$_basename.log and $logdir/$logfile for details\n" - if [ $DEVTYPE == 'lvm' ] - then - # not supported lvm type yet -@@ -86,6 +109,7 @@ cleanup() { - $mdadm --zero ${disks[@]} &> /dev/null - ;; - esac -+ clean_systemd_env - } - - do_clean() -@@ -176,11 +200,31 @@ restore_selinux() { - setenforce $sys_selinux - } - -+setup_systemd_env() { -+ warn "Warning! Test suite will set up systemd environment!\n" -+ echo "Use \"systemctl show-environment\" to show systemd environment variables" -+ for env_var in $devname_as_serial_flag $no_platform_flag -+ do -+ systemctl set-environment $env_var -+ echo "Added $env_var" to systemd environment, use \ -+ \"systemctl unset-environment $env_var\" to remove it. -+ done -+} -+ -+clean_systemd_env() { -+ for env_var in $devname_as_serial_flag $no_platform_flag -+ do -+ systemctl unset-environment $env_var -+ echo "Removed $env_var from systemd environment." -+ done -+} -+ - do_setup() { - trap cleanup 0 1 3 15 - trap ctrl_c 2 - - check_env -+ setup_systemd_env - [ -d $logdir ] || mkdir -p $logdir - - devlist= --- -2.41.0 - diff --git a/0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch b/0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch deleted file mode 100644 index 488f9b8..0000000 --- a/0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 66a54b266f6c579e5f37b6253820903a55c3346c Mon Sep 17 00:00:00 2001 -From: Shminderjit Singh -Date: Tue, 4 Jun 2024 07:46:03 +0000 -Subject: [PATCH 105/157] mdadm: Fix socket connection failure when mdmon runs - in foreground mode. - -While creating an IMSM RAID, mdadm will wait for the mdmon main process -to finish if mdmon runs in forking mode. This is because with -"Type=forking" in the mdmon service unit file, "systemctl start service" -will block until the main process of mdmon exits. At that moment, mdmon -has already created the socket, so the subsequent socket connect from -mdadm will succeed. - -However, when mdmon runs in foreground mode (without "Type=forking" in -the service unit file), "systemctl start service" will return once the -mdmon process starts. This causes mdadm and mdmon to run in parallel, -which may lead to a socket connection failure since mdmon has not yet -initialized the socket when mdadm tries to connect. If the next -instruction/command is to access this device and try to write to it, a -permission error will occur since mdmon has not yet set the array to RW -mode. - -Signed-off-by: Shminderjit Singh ---- - msg.c | 20 +++++++++++++++++++- - 1 file changed, 19 insertions(+), 1 deletion(-) - -diff --git a/msg.c b/msg.c -index ba0e25be..d17f679d 100644 ---- a/msg.c -+++ b/msg.c -@@ -151,6 +151,7 @@ int connect_monitor(char *devname) - struct sockaddr_un addr; - int pos; - char *c; -+ int rv, retry_count = 0; - - pos = sprintf(path, "%s/", MDMON_DIR); - if (is_subarray(devname)) { -@@ -170,7 +171,24 @@ int connect_monitor(char *devname) - - addr.sun_family = PF_LOCAL; - strcpy(addr.sun_path, path); -- if (connect(sfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { -+ -+ /* In foreground mode, when mdadm is trying to connect to control -+ * socket it is possible that the mdmon has not created it yet. -+ * Give some time to mdmon to create socket. -+ */ -+ for (retry_count = 0; retry_count < 10; retry_count++) { -+ rv = connect(sfd, (struct sockaddr*)&addr, sizeof(addr)); -+ -+ if (rv < 0) { -+ sleep_for(0, MSEC_TO_NSEC(200), true); -+ continue; -+ } -+ break; -+ } -+ -+ if (rv < 0) { -+ pr_err("Failed to connect to control socket. (%s!!)\n", -+ strerror(errno)); - close(sfd); - return -1; - } --- -2.41.0 - diff --git a/0106-Makefile-Do-not-call-gcc-directly.patch b/0106-Makefile-Do-not-call-gcc-directly.patch deleted file mode 100644 index 2708598..0000000 --- a/0106-Makefile-Do-not-call-gcc-directly.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 027b2d37a8cd56973d117107acc25a64cfe0a92f Mon Sep 17 00:00:00 2001 -From: Gwendal Grignou -Date: Wed, 15 May 2024 14:30:59 -0700 -Subject: [PATCH 106/157] Makefile: Do not call gcc directly - -When mdadm is compiled with clang, direct gcc will fail. -Make sure to use $(CC) variable instead. - -Note that Clang does not support --help=warnings, ---print-diagnostic-options should be used instead. -So with Clang, the compilation will go through, but the -extra warning flags will never be added. - -Signed-off-by: Gwendal Grignou ---- - Makefile | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/Makefile b/Makefile -index 446710bd..3fe0a053 100644 ---- a/Makefile -+++ b/Makefile -@@ -56,21 +56,21 @@ CWFLAGS += -Wp -O3 - endif - - ifeq ($(origin FALLTHROUGH), undefined) -- FALLTHROUGH := $(shell gcc -Q --help=warnings 2>&1 | grep "implicit-fallthrough" | wc -l) -+ FALLTHROUGH := $(shell $(CC) -Q --help=warnings 2>&1 | grep "implicit-fallthrough" | wc -l) - ifneq "$(FALLTHROUGH)" "0" - CWFLAGS += -Wimplicit-fallthrough=0 - endif - endif - - ifeq ($(origin FORMATOVERFLOW), undefined) -- FORMATOVERFLOW := $(shell gcc -Q --help=warnings 2>&1 | grep "format-overflow" | wc -l) -+ FORMATOVERFLOW := $(shell $(CC) -Q --help=warnings 2>&1 | grep "format-overflow" | wc -l) - ifneq "$(FORMATOVERFLOW)" "0" - CWFLAGS += -Wformat-overflow - endif - endif - - ifeq ($(origin STRINGOPOVERFLOW), undefined) -- STRINGOPOVERFLOW := $(shell gcc -Q --help=warnings 2>&1 | grep "stringop-overflow" | wc -l) -+ STRINGOPOVERFLOW := $(shell $(CC) -Q --help=warnings 2>&1 | grep "stringop-overflow" | wc -l) - ifneq "$(STRINGOPOVERFLOW)" "0" - CWFLAGS += -Wstringop-overflow - endif --- -2.41.0 - diff --git a/0107-mdadm-tests-judge-foreign-array-in-test-cases.patch b/0107-mdadm-tests-judge-foreign-array-in-test-cases.patch deleted file mode 100644 index dc7f5be..0000000 --- a/0107-mdadm-tests-judge-foreign-array-in-test-cases.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 23aef35113553cb97ef2e7b01c760d5449592e14 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 14 Jun 2024 10:45:01 +0800 -Subject: [PATCH 107/157] mdadm/tests: judge foreign array in test cases - -It needs to use array name when judging if one array is foreign or not. -So calling is_raid_foreign in test cases which need it. - -Fixes: 41706a915684 ('mdadm/tests: names_template enhance') -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - tests/03assem-incr | 2 ++ - tests/06name | 2 ++ - tests/07autoassemble | 3 +++ - tests/func.sh | 9 +++++---- - tests/templates/names_template | 2 ++ - 5 files changed, 14 insertions(+), 4 deletions(-) - -diff --git a/tests/03assem-incr b/tests/03assem-incr -index 21215a34..56afbf2c 100644 ---- a/tests/03assem-incr -+++ b/tests/03assem-incr -@@ -12,6 +12,8 @@ if [ "$LINEAR" == "yes" ]; then - levels+=( linear ) - fi - -+is_raid_foreign $md0 -+ - for l in ${levels[@]} - do - mdadm -CR $md0 -l $l -n5 $dev0 $dev1 $dev2 $dev3 $dev4 --assume-clean -diff --git a/tests/06name b/tests/06name -index c3213f6c..9ec3437b 100644 ---- a/tests/06name -+++ b/tests/06name -@@ -2,6 +2,8 @@ set -x - - # create an array with a name - -+is_raid_foreign $md0 -+ - mdadm -CR $md0 -l0 -n2 --metadata=1 --name="Fred" $dev0 $dev1 - - if [ $is_foreign == "no" ]; then -diff --git a/tests/07autoassemble b/tests/07autoassemble -index 9dc78149..b6630e17 100644 ---- a/tests/07autoassemble -+++ b/tests/07autoassemble -@@ -2,6 +2,9 @@ - # create two raid1s, build a raid0 on top, then - # tear it down and get auto-assemble to rebuild it. - -+#the length of md0/md1/md2 is same. So use md0 here. -+is_raid_foreign $md0 -+ - mdadm -CR $md1 -l1 -n2 $dev0 $dev1 --homehost=testing - mdadm -CR $md2 -l1 -n2 $dev2 $dev3 --homehost=testing - mdadm -CR $md0 -l0 -n2 $md1 $md2 --homehost=testing -diff --git a/tests/func.sh b/tests/func.sh -index 8c142c76..e7ccc4fc 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -181,10 +181,12 @@ restore_system_speed_limit() { - - is_raid_foreign() { - -- # If the length of hostname is >= 32, super1 doesn't use -- # hostname in metadata -+ name=$1 -+ # super1 uses this formula strlen(homehost)+1+strlen(name) < 32 -+ # to decide if an array is foreign or local. It adds homehost if -+ # one array is local - hostname=$(hostname) -- if [ `expr length $(hostname)` -lt 32 ]; then -+ if [ `expr length "$(hostname)$name"` -lt 31 ]; then - is_foreign="no" - else - is_foreign="yes" -@@ -299,7 +301,6 @@ do_setup() { - [ -f /proc/mdstat ] || modprobe md_mod - echo 0 > /sys/module/md_mod/parameters/start_ro - record_system_speed_limit -- is_raid_foreign - record_selinux - } - -diff --git a/tests/templates/names_template b/tests/templates/names_template -index 88ad5b8c..c94245ea 100644 ---- a/tests/templates/names_template -+++ b/tests/templates/names_template -@@ -4,6 +4,8 @@ function names_create() { - local NAME=$2 - local NEG_TEST=$3 - -+ is_raid_foreign $DEVNAME -+ - if [[ -z "$NAME" ]]; then - mdadm -CR "$DEVNAME" -l0 -n 1 $dev0 --force - else --- -2.41.0 - diff --git a/0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch b/0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch deleted file mode 100644 index 2bc632a..0000000 --- a/0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch +++ /dev/null @@ -1,58 +0,0 @@ -From f98340f1b830d950978abba752b2b9b004528faf Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 20 Jun 2024 15:22:50 +0200 -Subject: [PATCH 108/157] Revert "mdadm: Fix socket connection failure when - mdmon runs in foreground mode." - -This reverts commit 66a54b266f6c579e5f37b6253820903a55c3346c. - -connect_monitor() is called from ping_monitor() but this function is often -used as advice, without verification that mdmon is really working. This -produces hangs in many scenarios. - -Signed-off-by: Mariusz Tkaczyk ---- - msg.c | 20 +------------------- - 1 file changed, 1 insertion(+), 19 deletions(-) - -diff --git a/msg.c b/msg.c -index d17f679d..f0772b3f 100644 ---- a/msg.c -+++ b/msg.c -@@ -151,7 +151,6 @@ int connect_monitor(char *devname) - struct sockaddr_un addr; - int pos; - char *c; -- int rv, retry_count = 0; - - pos = sprintf(path, "%s/", MDMON_DIR); - if (is_subarray(devname)) { -@@ -171,24 +170,7 @@ int connect_monitor(char *devname) - - addr.sun_family = PF_LOCAL; - strcpy(addr.sun_path, path); -- -- /* In foreground mode, when mdadm is trying to connect to control -- * socket it is possible that the mdmon has not created it yet. -- * Give some time to mdmon to create socket. -- */ -- for (retry_count = 0; retry_count < 10; retry_count++) { -- rv = connect(sfd, (struct sockaddr*)&addr, sizeof(addr)); -- -- if (rv < 0) { -- sleep_for(0, MSEC_TO_NSEC(200), true); -- continue; -- } -- break; -- } -- -- if (rv < 0) { -- pr_err("Failed to connect to control socket. (%s!!)\n", -- strerror(errno)); -+ if (connect(sfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - close(sfd); - return -1; - } --- -2.41.0 - diff --git a/0109-mdadm-Assemble.c-fix-coverity-issues.patch b/0109-mdadm-Assemble.c-fix-coverity-issues.patch deleted file mode 100644 index 6e9bcf1..0000000 --- a/0109-mdadm-Assemble.c-fix-coverity-issues.patch +++ /dev/null @@ -1,149 +0,0 @@ -From 3e6358e9aa0618f6a7de3a58e545caaada03739f Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Tue, 25 Jun 2024 07:57:28 -0400 -Subject: [PATCH 109/157] mdadm: Assemble.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Event dereference: Dereferencing "pre_exist", which is known to be "NULL". -* Event parameter_hidden: Declaration hides parameter "c". -* Event leaked_storage: Variable "pre_exist" going out of scope leaks the - storage it points to. -* Event leaked_storage: Variable "avail" going out of scope leaks the - storage it points to. - -Signed-off-by: Nigel Croxon ---- - Assemble.c | 30 ++++++++++++++++++++++++------ - 1 file changed, 24 insertions(+), 6 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 0e6da593..77f2b50e 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -567,6 +567,9 @@ static int select_devices(struct mddev_dev *devlist, - tmpdev->used = 1; - content = *contentp; - -+ if (!st) -+ return -1; -+ - if (!st->sb) { - /* we need sb from one of the spares */ - int dfd = dev_open(tmpdev->devname, O_RDONLY); -@@ -815,12 +818,12 @@ static int load_devices(struct devs *devices, char *devmap, - if (i >= bestcnt) { - int newbestcnt = i+10; - int *newbest = xmalloc(sizeof(int)*newbestcnt); -- int c; -- for (c=0; c < newbestcnt; c++) -- if (c < bestcnt) -- newbest[c] = best[c]; -+ int cc; -+ for (cc = 0; cc < newbestcnt; cc++) -+ if (cc < bestcnt) -+ newbest[cc] = best[cc]; - else -- newbest[c] = -1; -+ newbest[cc] = -1; - if (best)free(best); - best = newbest; - bestcnt = newbestcnt; -@@ -1493,8 +1496,11 @@ try_again: - mp = map_by_uuid(&map, content->uuid); - if (mp) { - struct mdinfo *dv; -- /* array already exists. */ - pre_exist = sysfs_read(-1, mp->devnm, GET_LEVEL|GET_DEVS); -+ if (!pre_exist) -+ goto out; -+ -+ /* array already exists. */ - if (pre_exist->array.level != UnSet) { - pr_err("Found some drive for an array that is already active: %s\n", - mp->path); -@@ -1606,6 +1612,7 @@ try_again: - err = assemble_container_content(st, mdfd, content, c, - chosen_name, NULL); - close(mdfd); -+ sysfs_free(pre_exist); - return err; - } - -@@ -1745,23 +1752,27 @@ try_again: - : (O_RDONLY|O_EXCL)))< 0) { - pr_err("Cannot open %s: %s\n", - devices[j].devname, strerror(errno)); -+ free(avail); - goto out; - } - if (st->ss->load_super(st,fd, NULL)) { - close(fd); - pr_err("RAID superblock has disappeared from %s\n", - devices[j].devname); -+ free(avail); - goto out; - } - close(fd); - } - if (st->sb == NULL) { - pr_err("No suitable drives found for %s\n", mddev); -+ free(avail); - goto out; - } - st->ss->getinfo_super(st, content, NULL); - if (sysfs_init(content, mdfd, NULL)) { - pr_err("Unable to initialize sysfs\n"); -+ free(avail); - goto out; - } - -@@ -1824,12 +1835,14 @@ try_again: - if (fd < 0) { - pr_err("Could not open %s for write - cannot Assemble array.\n", - devices[chosen_drive].devname); -+ free(avail); - goto out; - } - if (st->ss->store_super(st, fd)) { - close(fd); - pr_err("Could not re-write superblock on %s\n", - devices[chosen_drive].devname); -+ free(avail); - goto out; - } - if (c->verbose >= 0) -@@ -1888,6 +1901,7 @@ try_again: - pr_err("Failed to restore critical section for reshape, sorry.\n"); - if (c->backup_file == NULL) - cont_err("Possibly you needed to specify the --backup-file\n"); -+ free(avail); - goto out; - } - } -@@ -1916,6 +1930,7 @@ try_again: - if (rv == 1 && !pre_exist) - ioctl(mdfd, STOP_ARRAY, NULL); - free(devices); -+ free(avail); - out: - map_unlock(&map); - if (rv == 0) { -@@ -1951,11 +1966,14 @@ out: - close(mdfd); - - free(best); -+ sysfs_free(pre_exist); -+ - /* '2' means 'OK, but not started yet' */ - if (rv == -1) { - free(devices); - return 1; - } -+ close(mdfd); - return rv == 2 ? 0 : rv; - } - --- -2.41.0 - diff --git a/0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch b/0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch deleted file mode 100644 index cbb4bff..0000000 --- a/0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 3cbe13403ec0c78374343dcd889609aefe791f9b Mon Sep 17 00:00:00 2001 -From: Shminderjit Singh -Date: Mon, 24 Jun 2024 08:58:51 +0000 -Subject: [PATCH 111/157] mdadm: Fix socket connection failure when mdmon runs - in foreground mode. - -While creating an IMSM RAID, mdadm will wait for the mdmon main process -to finish if mdmon runs in forking mode. This is because with -"Type=forking" in the mdmon service unit file, "systemctl start service" -will block until the main process of mdmon exits. At that moment, mdmon -has already created the socket, so the subsequent socket connect from -mdadm will succeed. - -However, when mdmon runs in foreground mode (without "Type=forking" in -the service unit file), "systemctl start service" will return once the -mdmon process starts. This causes mdadm and mdmon to run in parallel, -which may lead to a socket connection failure since mdmon has not yet -initialized the socket when mdadm tries to connect. If the next -instruction/command is to access this device and try to write to it, a -permission error will occur since mdmon has not yet set the array to RW -mode. - -Signed-off-by: Shminderjit Singh ---- - Create.c | 6 ++++-- - mdadm.h | 1 + - util.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 50 insertions(+), 2 deletions(-) - -diff --git a/Create.c b/Create.c -index bd4875e4..479c2715 100644 ---- a/Create.c -+++ b/Create.c -@@ -1344,9 +1344,11 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - if (c->verbose >= 0) - pr_info("array %s started.\n", chosen_name); - if (st->ss->external && st->container_devnm[0]) { -- if (need_mdmon) -+ if (need_mdmon) { - start_mdmon(st->container_devnm); -- -+ if (wait_for_mdmon_control_socket(st->container_devnm) != MDADM_STATUS_SUCCESS) -+ goto abort; -+ } - ping_monitor(st->container_devnm); - close(container_fd); - } -diff --git a/mdadm.h b/mdadm.h -index e9f764a2..27009154 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1776,6 +1776,7 @@ extern int is_subarray_active(char *subarray, char *devname); - extern int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet); - extern struct superswitch *version_to_superswitch(char *vers); - -+extern mdadm_status_t wait_for_mdmon_control_socket(const char *container_devnm); - extern int mdmon_running(const char *devnm); - extern int mdmon_pid(const char *devnm); - extern mdadm_status_t wait_for_mdmon(const char *devnm); -diff --git a/util.c b/util.c -index 48c97545..908f8430 100644 ---- a/util.c -+++ b/util.c -@@ -1932,6 +1932,51 @@ int mdmon_running(const char *devnm) - return 0; - } - -+/* -+ * wait_for_mdmon_control_socket() - Waits for mdmon control socket -+ * to be created within specified time. -+ * @container_devnm: Device for which mdmon control socket should start. -+ * -+ * In foreground mode, when mdadm is trying to connect to control -+ * socket it is possible that the mdmon has not created it yet. -+ * Give some time to mdmon to create socket. Timeout set to 2 sec. -+ * -+ * Return: MDADM_STATUS_SUCCESS if connect succeed, otherwise return -+ * error code. -+ */ -+mdadm_status_t wait_for_mdmon_control_socket(const char *container_devnm) -+{ -+ enum mdadm_status status = MDADM_STATUS_SUCCESS; -+ int sfd, rv, retry_count = 0; -+ struct sockaddr_un addr; -+ char path[PATH_MAX]; -+ -+ snprintf(path, PATH_MAX, "%s/%s.sock", MDMON_DIR, container_devnm); -+ sfd = socket(PF_LOCAL, SOCK_STREAM, 0); -+ if (!is_fd_valid(sfd)) -+ return MDADM_STATUS_ERROR; -+ -+ addr.sun_family = PF_LOCAL; -+ strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); -+ addr.sun_path[sizeof(addr.sun_path) - 1] = '\0'; -+ -+ for (retry_count = 0; retry_count < 10; retry_count++) { -+ rv = connect(sfd, (struct sockaddr*)&addr, sizeof(addr)); -+ if (rv < 0) { -+ sleep_for(0, MSEC_TO_NSEC(200), true); -+ continue; -+ } -+ break; -+ } -+ -+ if (rv < 0) { -+ pr_err("Failed to connect to control socket.\n"); -+ status = MDADM_STATUS_ERROR; -+ } -+ close(sfd); -+ return status; -+} -+ - /* - * wait_for_mdmon() - Waits for mdmon within specified time. - * @devnm: Device for which mdmon should start. --- -2.41.0 - diff --git a/0113-config.c-Fix-memory-leak-in-load_containers.patch b/0113-config.c-Fix-memory-leak-in-load_containers.patch deleted file mode 100644 index 204ecf0..0000000 --- a/0113-config.c-Fix-memory-leak-in-load_containers.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 44457789fd67168c37932060f9a991f0c611e5a2 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -Date: Fri, 28 Jun 2024 12:32:16 +0200 -Subject: [PATCH 113/157] config.c: Fix memory leak in load_containers() - -Fix memory leak in load_containers() in config.c reported by SAST -analysis. - -Signed-off-by: Anna Sztukowska ---- - config.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/config.c b/config.c -index 612e700d..cd2379bd 100644 ---- a/config.c -+++ b/config.c -@@ -379,6 +379,7 @@ struct mddev_dev *load_containers(void) - map = NULL; - } - free_mdstat(mdstat); -+ map_free(map); - - return rv; - } --- -2.41.0 - diff --git a/0114-mdadm-Build.c-fix-coverity-issues.patch b/0114-mdadm-Build.c-fix-coverity-issues.patch deleted file mode 100644 index 7dc51ce..0000000 --- a/0114-mdadm-Build.c-fix-coverity-issues.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0244bac0a828e69aef36404437cac4ff148eaea0 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Tue, 2 Jul 2024 09:49:13 -0400 -Subject: [PATCH 114/157] mdadm: Build.c fix coverity issues - -Event leaked_handle: Handle variable "bitmap_fd" going out of -scope leaks the handle. - -Signed-off-by: Nigel Croxon ---- - Build.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/Build.c b/Build.c -index 1be90e41..052b1bc2 100644 ---- a/Build.c -+++ b/Build.c -@@ -168,13 +168,13 @@ int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s, - goto abort; - } - } -- if (bitmap_fd >= 0) { -- if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) { -- pr_err("Cannot set bitmap file for %s: %s\n", chosen_name, -- strerror(errno)); -- goto abort; -- } -+ if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) { -+ pr_err("Cannot set bitmap file for %s: %s\n", chosen_name, -+ strerror(errno)); -+ close(bitmap_fd); -+ goto abort; - } -+ close(bitmap_fd); - } - if (ioctl(mdfd, RUN_ARRAY, ¶m)) { - pr_err("RUN_ARRAY failed: %s\n", strerror(errno)); --- -2.41.0 - diff --git a/0115-mdadm-Create.c-fix-coverity-issues.patch b/0115-mdadm-Create.c-fix-coverity-issues.patch deleted file mode 100644 index 5d26f4b..0000000 --- a/0115-mdadm-Create.c-fix-coverity-issues.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 7c524aa83c4463c15a13f6f47a27a18ab4de9eef Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Fri, 5 Jul 2024 08:45:32 -0400 -Subject: [PATCH 115/157] mdadm: Create.c fix coverity issues - -* Event negative_returns: "fd" is passed to a parameter that cannot be negative. Which -is set to -1 to start. - -* Event open_fn: Returning handle opened by "open_dev_excl". -* Event var_assign: Assigning: "container_fd" = handle returned from -"open_dev_excl(st->container_devnm)" -* Event leaked_handle: Handle variable "container_fd" going out of scope leaks the handle - -Signed-off-by: Nigel Croxon ---- - Create.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/Create.c b/Create.c -index 479c2715..7fde1c16 100644 ---- a/Create.c -+++ b/Create.c -@@ -297,7 +297,7 @@ static int add_disk_to_super(int mdfd, struct shape *s, struct context *c, - if (st->ss->add_to_super(st, &info->disk, fd, dv->devname, - dv->data_offset)) { - ioctl(mdfd, STOP_ARRAY, NULL); -- close(fd); -+ close_fd(&fd); - return 1; - } - st->ss->getinfo_super(st, info, NULL); -@@ -1370,8 +1370,8 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs, - map_remove(&map, fd2devnm(mdfd)); - map_unlock(&map); - -- if (mdfd >= 0) -- close(mdfd); -+ close_fd(&mdfd); -+ close_fd(&container_fd); - - dev_policy_free(custom_pols); - return 1; --- -2.41.0 - diff --git a/0116-mdadm-super-ddf.c-fix-coverity-issues.patch b/0116-mdadm-super-ddf.c-fix-coverity-issues.patch deleted file mode 100644 index 9517bca..0000000 --- a/0116-mdadm-super-ddf.c-fix-coverity-issues.patch +++ /dev/null @@ -1,473 +0,0 @@ -From 96b8035a09b6449ea99f2eb91f9ba4f6912e5bd6 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Tue, 2 Jul 2024 10:11:26 -0400 -Subject: [PATCH 116/157] mdadm: super-ddf.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Calling "lseek64" without checking return value. This library function may -fail and return an error code. -* Overrunning array "anchor->pad2" of 3 bytes by passing it to a function -which accesses it at byte offset 398 using argument "399UL". -* Event leaked_storage: Variable "sra" going out of scope leaks the storage -it points to. -* Event leaked_storage: Variable "super" going out of scope leaks the storage -it points to. -* Event leaked_handle: Handle variable "dfd" going out of scope leaks the -handle. -* Event leaked_storage: Variable "dl1" going out of scope leaks the storage -it points to -* Event leaked_handle: Handle variable "cfd" going out of scope leaks the -handle. -* Variable "avail" going out of scope leaks the storage it points to. -* Passing unterminated string "super->anchor.revision" to "fprintf", which -expects a null-terminated string. -* You might overrun the 32-character fixed-size string "st->container_devnm" -by copying the return value of "fd2devnm" without checking the length. -* Event fixed_size_dest: You might overrun the 33-character fixed-size string -"dev->name" by copying "(*d).devname" without checking the length. -* Event uninit_use_in_call: Using uninitialized value "info.array.raid_disks" -when calling "getinfo_super_ddf" - -V2: clean up validate_geometry_ddf() routine with Mariusz Tkaczyk recommendations. -V3: clean up spaces with Blazej Kucman recommendations. -V4: clean up recommended by Mariusz Tkaczyk. -V5: clean up recommended by Mariusz Tkaczyk. - -Signed-off-by: Nigel Croxon ---- - super-ddf.c | 172 +++++++++++++++++++++++++++++++++++----------------- - 1 file changed, 115 insertions(+), 57 deletions(-) - -diff --git a/super-ddf.c b/super-ddf.c -index 311001c1..d870102d 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -809,7 +809,7 @@ static int load_ddf_header(int fd, unsigned long long lba, - if (lba >= size-1) - return 0; - -- if (lseek64(fd, lba<<9, 0) < 0) -+ if (lseek64(fd, lba << 9, 0) == -1L) - return 0; - - if (read(fd, hdr, 512) != 512) -@@ -828,8 +828,7 @@ static int load_ddf_header(int fd, unsigned long long lba, - !be64_eq(anchor->primary_lba, hdr->primary_lba) || - !be64_eq(anchor->secondary_lba, hdr->secondary_lba) || - hdr->type != type || -- memcmp(anchor->pad2, hdr->pad2, 512 - -- offsetof(struct ddf_header, pad2)) != 0) { -+ memcmp(anchor->pad2, hdr->pad2, sizeof(anchor->pad2)) != 0) { - pr_err("header mismatch\n"); - return 0; - } -@@ -863,7 +862,7 @@ static void *load_section(int fd, struct ddf_super *super, void *buf, - else - offset += be64_to_cpu(super->active->secondary_lba); - -- if ((unsigned long long)lseek64(fd, offset<<9, 0) != (offset<<9)) { -+ if ((unsigned long long)lseek64(fd, offset << 9, 0) != (offset << 9)) { - if (dofree) - free(buf); - return NULL; -@@ -882,7 +881,7 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname) - - get_dev_size(fd, NULL, &dsize); - -- if (lseek64(fd, dsize-512, 0) < 0) { -+ if (lseek64(fd, dsize - 512, 0) == -1L) { - if (devname) - pr_err("Cannot seek to anchor block on %s: %s\n", - devname, strerror(errno)); -@@ -909,8 +908,7 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname) - if (memcmp(super->anchor.revision, DDF_REVISION_0, 8) != 0 && - memcmp(super->anchor.revision, DDF_REVISION_2, 8) != 0) { - if (devname) -- pr_err("can only support super revision %.8s and earlier, not %.8s on %s\n", -- DDF_REVISION_2, super->anchor.revision,devname); -+ pr_err("The DDF revision on %s\n is not supported", devname); - return 2; - } - super->active = NULL; -@@ -1610,6 +1608,7 @@ static unsigned int get_vd_num_of_subarray(struct supertype *st) - return DDF_NOTFOUND; - } - -+ sysfs_free(sra); - return vcnum; - } - -@@ -1617,11 +1616,11 @@ static void brief_examine_super_ddf(struct supertype *st, int verbose) - { - /* We just write a generic DDF ARRAY entry - */ -- struct mdinfo info; -+ struct mdinfo info = {0}; - char nbuf[64]; -+ - getinfo_super_ddf(st, &info, NULL); - fname_from_uuid(&info, nbuf); -- - printf("ARRAY metadata=ddf UUID=%s\n", nbuf + 5); - } - -@@ -1631,9 +1630,10 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose) - * by uuid and member by unit number and uuid. - */ - struct ddf_super *ddf = st->sb; -- struct mdinfo info; -+ struct mdinfo info = {0}; - unsigned int i; - char nbuf[64]; -+ - getinfo_super_ddf(st, &info, NULL); - fname_from_uuid(&info, nbuf); - -@@ -1658,8 +1658,9 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose) - - static void export_examine_super_ddf(struct supertype *st) - { -- struct mdinfo info; -+ struct mdinfo info = {0}; - char nbuf[64]; -+ - getinfo_super_ddf(st, &info, NULL); - fname_from_uuid(&info, nbuf); - printf("MD_METADATA=ddf\n"); -@@ -1692,10 +1693,12 @@ static int copy_metadata_ddf(struct supertype *st, int from, int to) - if (!get_dev_size(from, NULL, &dsize)) - goto err; - -- if (lseek64(from, dsize-512, 0) < 0) -+ if (lseek64(from, dsize - 512, 0) == -1L) - goto err; -+ - if (read(from, buf, 512) != 512) - goto err; -+ - ddf = buf; - if (!be32_eq(ddf->magic, DDF_HEADER_MAGIC) || - !be32_eq(calc_crc(ddf, 512), ddf->crc) || -@@ -1711,9 +1714,9 @@ static int copy_metadata_ddf(struct supertype *st, int from, int to) - - bytes = dsize - offset; - -- if (lseek64(from, offset, 0) < 0 || -- lseek64(to, offset, 0) < 0) -+ if (lseek64(from, offset, 0) == -1L || lseek64(to, offset, 0) == -1L) - goto err; -+ - while (written < bytes) { - int n = bytes - written; - if (n > 4096) -@@ -1795,6 +1798,7 @@ static void brief_detail_super_ddf(struct supertype *st, char *subarray) - char nbuf[64]; - struct ddf_super *ddf = st->sb; - unsigned int vcnum = get_vd_num_of_subarray(st); -+ - if (vcnum == DDF_CONTAINER) - uuid_from_super_ddf(st, info.uuid); - else if (vcnum == DDF_NOTFOUND) -@@ -2971,7 +2975,9 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type) - header->openflag = 1; - header->crc = calc_crc(header, 512); - -- lseek64(fd, sector<<9, 0); -+ if (lseek64(fd, sector << 9, 0) == -1L) -+ goto out; -+ - if (write(fd, header, 512) < 0) - goto out; - -@@ -2982,6 +2988,7 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type) - ddf->phys->crc = calc_crc(ddf->phys, ddf->pdsize); - if (write(fd, ddf->phys, ddf->pdsize) < 0) - goto out; -+ - ddf->virt->crc = calc_crc(ddf->virt, ddf->vdsize); - if (write(fd, ddf->virt, ddf->vdsize) < 0) - goto out; -@@ -3035,7 +3042,9 @@ out: - header->openflag = 0; - header->crc = calc_crc(header, 512); - -- lseek64(fd, sector<<9, 0); -+ if (lseek64(fd, sector << 9, 0) == -1L) -+ return 0; -+ - if (write(fd, header, 512) < 0) - ret = 0; - -@@ -3088,7 +3097,9 @@ static int _write_super_to_disk(struct ddf_super *ddf, struct dl *d) - if (!__write_ddf_structure(d, ddf, DDF_HEADER_SECONDARY)) - return 0; - -- lseek64(fd, (size-1)*512, SEEK_SET); -+ if (lseek64(fd, (size - 1) * 512, SEEK_SET) == -1L) -+ return 0; -+ - if (write(fd, &ddf->anchor, 512) < 0) - return 0; - -@@ -3299,9 +3310,10 @@ static int validate_geometry_ddf(struct supertype *st, - char *dev, unsigned long long *freesize, - int consistency_policy, int verbose) - { -- int fd; -- struct mdinfo *sra; -+ struct mdinfo *sra = NULL; -+ int ret = 1; - int cfd; -+ int fd; - - /* ddf potentially supports lots of things, but it depends on - * what devices are offered (and maybe kernel version?) -@@ -3369,7 +3381,7 @@ static int validate_geometry_ddf(struct supertype *st, - * Later we should check for a BVD and make an SVD. - */ - fd = open(dev, O_RDONLY|O_EXCL, 0); -- if (fd >= 0) { -+ if (is_fd_valid(fd)) { - close(fd); - /* Just a bare device, no good to us */ - if (verbose) -@@ -3377,44 +3389,58 @@ static int validate_geometry_ddf(struct supertype *st, - dev); - return 0; - } -+ - if (errno != EBUSY || (fd = open(dev, O_RDONLY, 0)) < 0) { - if (verbose) - pr_err("ddf: Cannot open %s: %s\n", - dev, strerror(errno)); - return 0; - } -+ - /* Well, it is in use by someone, maybe a 'ddf' container. */ - cfd = open_container(fd); -- if (cfd < 0) { -- close(fd); -+ close(fd); -+ -+ if (!is_fd_valid(cfd)) { - if (verbose) -- pr_err("ddf: Cannot use %s: %s\n", -- dev, strerror(EBUSY)); -+ pr_err("ddf: Cannot use %s\n", dev); - return 0; - } -+ - sra = sysfs_read(cfd, NULL, GET_VERSION); -- close(fd); -- if (sra && sra->array.major_version == -1 && -- strcmp(sra->text_version, "ddf") == 0) { -+ if (!sra) { -+ pr_err("Cannot read sysfs for /dev/%s\n", fd2kname(cfd)); -+ goto error; -+ } -+ -+ if (sra->array.major_version == -1 && strcmp(sra->text_version, "ddf") == 0) { - /* This is a member of a ddf container. Load the container - * and try to create a bvd - */ -- struct ddf_super *ddf; -+ struct ddf_super *ddf = NULL; -+ - if (load_super_ddf_all(st, cfd, (void **)&ddf, NULL) == 0) { - st->sb = ddf; -- strcpy(st->container_devnm, fd2devnm(cfd)); -+ snprintf(st->container_devnm, sizeof(st->container_devnm), -+ "%s", fd2kname(cfd)); - close(cfd); -- return validate_geometry_ddf_bvd(st, level, layout, -- raiddisks, chunk, size, -- data_offset, -- dev, freesize, -- verbose); -+ free(sra); -+ -+ return validate_geometry_ddf_bvd(st, level, layout, raiddisks, -+ chunk, size, data_offset, dev, -+ freesize, verbose); - } -- close(cfd); -- } else /* device may belong to a different container */ -- return 0; -+ free(ddf); -+ } - -- return 1; -+ /* device may belong to a different container */ -+ ret = 0; -+ -+error: -+ free(sra); -+ close(cfd); -+ -+ return ret; - } - - static int validate_geometry_ddf_bvd(struct supertype *st, -@@ -3483,35 +3509,42 @@ static int validate_geometry_ddf_bvd(struct supertype *st, - static int load_super_ddf_all(struct supertype *st, int fd, - void **sbp, char *devname) - { -- struct mdinfo *sra; -- struct ddf_super *super; - struct mdinfo *sd, *best = NULL; -+ struct ddf_super *super = NULL; -+ struct mdinfo *sra; - int bestseq = 0; -- int seq; -+ int ret = 1; - char nm[20]; -+ int seq; - int dfd; - - sra = sysfs_read(fd, NULL, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE); - if (!sra) - return 1; -- if (sra->array.major_version != -1 || -- sra->array.minor_version != -2 || -+ if (sra->array.major_version != -1 || sra->array.minor_version != -2 || - strcmp(sra->text_version, "ddf") != 0) -- return 1; -+ goto out; - - if (posix_memalign((void**)&super, 512, sizeof(*super)) != 0) -- return 1; -+ goto out; -+ - memset(super, 0, sizeof(*super)); - - /* first, try each device, and choose the best ddf */ - for (sd = sra->devs ; sd ; sd = sd->next) { - int rv; -+ - sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor); -+ - dfd = dev_open(nm, O_RDONLY); -- if (dfd < 0) -- return 2; -+ if (!is_fd_valid(dfd)) { -+ ret = 2; -+ goto out; -+ } -+ - rv = load_ddf_headers(dfd, super, NULL); - close(dfd); -+ - if (rv == 0) { - seq = be32_to_cpu(super->active->seq); - if (super->active->openflag) -@@ -3523,28 +3556,39 @@ static int load_super_ddf_all(struct supertype *st, int fd, - } - } - if (!best) -- return 1; -+ goto out; -+ - /* OK, load this ddf */ - sprintf(nm, "%d:%d", best->disk.major, best->disk.minor); -+ - dfd = dev_open(nm, O_RDONLY); - if (dfd < 0) -- return 1; -+ goto out; -+ - load_ddf_headers(dfd, super, NULL); - load_ddf_global(dfd, super, NULL); - close(dfd); -+ - /* Now we need the device-local bits */ - for (sd = sra->devs ; sd ; sd = sd->next) { - int rv; - - sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor); -+ - dfd = dev_open(nm, O_RDWR); -- if (dfd < 0) -- return 2; -+ if (dfd < 0) { -+ ret = 2; -+ goto out; -+ } -+ - rv = load_ddf_headers(dfd, super, NULL); - if (rv == 0) - rv = load_ddf_local(dfd, super, NULL, 1); -- if (rv) -- return 1; -+ -+ if (rv) { -+ close(dfd); -+ goto out; -+ } - } - - *sbp = super; -@@ -3553,8 +3597,16 @@ static int load_super_ddf_all(struct supertype *st, int fd, - st->minor_version = 0; - st->max_devs = 512; - } -- strcpy(st->container_devnm, fd2devnm(fd)); -- return 0; -+ -+ snprintf(st->container_devnm, sizeof(st->container_devnm), "%s", fd2devnm(fd)); -+ ret = 0; -+ -+out: -+ if (sra) -+ free(sra); -+ if (super && ret != 0) -+ free(super); -+ return ret; - } - - static int load_container_ddf(struct supertype *st, int fd, -@@ -3791,7 +3843,7 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray - be64_to_cpu(LBA_OFFSET(ddf, bvd)[iphys]); - dev->component_size = be64_to_cpu(bvd->blocks); - if (d->devname) -- strcpy(dev->name, d->devname); -+ snprintf(dev->name, sizeof(dev->name), "%s", d->devname); - } - } - return rest; -@@ -3840,11 +3892,15 @@ static int store_super_ddf(struct supertype *st, int fd) - return 1; - memset(buf, 0, 512); - -- lseek64(fd, dsize-512, 0); -+ if (lseek64(fd, dsize - 512, 0) == -1L) { -+ free(buf); -+ return 1; -+ } - rc = write(fd, buf, 512); - free(buf); - if (rc < 0) - return 1; -+ - return 0; - } - -@@ -3959,6 +4015,7 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst, - if (posix_memalign((void **)&dl1->spare, 512, - first->conf_rec_len*512) != 0) { - pr_err("could not allocate spare info buf\n"); -+ free(dl1); - return 3; - } - memcpy(dl1->spare, dl2->spare, first->conf_rec_len*512); -@@ -4180,6 +4237,7 @@ static int get_bvd_state(const struct ddf_super *ddf, - state = DDF_state_part_optimal; - break; - } -+ free(avail); - return state; - } - --- -2.41.0 - diff --git a/0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch b/0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch deleted file mode 100644 index 0458285..0000000 --- a/0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch +++ /dev/null @@ -1,102 +0,0 @@ -From cdce3219a52938fc35f93b5f17561f2ca7175e37 Mon Sep 17 00:00:00 2001 -From: Heming Zhao -Date: Tue, 9 Jul 2024 20:04:51 +0800 -Subject: [PATCH 117/157] mdadm/clustermd_tests: add some APIs in func.sh to - support running the tests without errors - -clustermd_tests/func.sh lacks some APIs to run, this patch makes -clustermd_tests runnable from the test suite. - -Signed-off-by: Heming Zhao -Signed-off-by: Mariusz Tkaczyk ---- - clustermd_tests/func.sh | 60 +++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 60 insertions(+) - -diff --git a/clustermd_tests/func.sh b/clustermd_tests/func.sh -index 801d6043..e659c0ba 100644 ---- a/clustermd_tests/func.sh -+++ b/clustermd_tests/func.sh -@@ -1,5 +1,22 @@ - #!/bin/bash - -+COLOR_FAIL='\033[0;31m' #RED -+COLOR_WARN='\033[1;33m' #YELLOW -+COLOR_SUCCESS='\033[0;32m' #GREEN -+COLOR_NONE='\033[0m' -+ -+fail() { -+ printf "${COLOR_FAIL}$1${COLOR_NONE}" -+} -+ -+warn() { -+ printf "${COLOR_WARN}$1${COLOR_NONE}" -+} -+ -+succeed() { -+ printf "${COLOR_SUCCESS}$1${COLOR_NONE}" -+} -+ - check_ssh() - { - NODE1="$(grep '^NODE1' $CLUSTER_CONF | cut -d'=' -f2)" -@@ -151,6 +168,33 @@ stop_md() - fi - } - -+record_system_speed_limit() { -+ system_speed_limit_max=`cat /proc/sys/dev/raid/speed_limit_max` -+ system_speed_limit_min=`cat /proc/sys/dev/raid/speed_limit_min` -+} -+ -+# To avoid sync action finishes before checking it, it needs to limit -+# the sync speed -+control_system_speed_limit() { -+ echo $test_speed_limit_min > /proc/sys/dev/raid/speed_limit_min -+ echo $test_speed_limit_max > /proc/sys/dev/raid/speed_limit_max -+} -+ -+restore_system_speed_limit() { -+ echo $system_speed_limit_min > /proc/sys/dev/raid/speed_limit_max -+ echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max -+} -+ -+record_selinux() { -+ # empty -+ return 0 -+} -+ -+restore_selinux() { -+ # empty -+ return 0 -+} -+ - # $1/optional, it shows why to save log - save_log() - { -@@ -240,6 +284,22 @@ check() - die "$ip: check '$2' failed." - done - ;; -+ recovery-remote ) -+ cnt=5 -+ for ip in ${NODES[@]} -+ do -+ while ! ssh $ip "grep -sqE 'recovery|REMOTE' /proc/mdstat" -+ do -+ if [ "$cnt" -gt '0' ] -+ then -+ sleep 0.2 -+ cnt=$[cnt-1] -+ else -+ die "$ip: no '$2' happening!" -+ fi -+ done -+ done -+ ;; - PENDING | recovery | resync | reshape ) - cnt=5 - for ip in ${NODES[@]} --- -2.41.0 - diff --git a/0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch b/0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch deleted file mode 100644 index 1f8e409..0000000 --- a/0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch +++ /dev/null @@ -1,81 +0,0 @@ -From bde21cc929d4864bd4b9f459f46ce63dd8c793ca Mon Sep 17 00:00:00 2001 -From: Heming Zhao -Date: Tue, 9 Jul 2024 20:04:52 +0800 -Subject: [PATCH 118/157] mdadm/clustermd_tests: adjust test cases to support - md module changes - -Since kernel commit db5e653d7c9f ("md: delay choosing sync action to -md_start_sync()") delays the start of the sync action, clustermd -array sync/resync jobs can happen on any leg of the array. This -commit adjusts the test cases to follow the new kernel layer behavior. - -Signed-off-by: Heming Zhao -Signed-off-by: Mariusz Tkaczyk ---- - clustermd_tests/02r10_Manage_re-add | 3 ++- - clustermd_tests/02r1_Manage_re-add | 1 + - clustermd_tests/03r10_switch-recovery | 4 ++-- - clustermd_tests/03r1_switch-recovery | 4 ++-- - 4 files changed, 7 insertions(+), 5 deletions(-) - -diff --git a/clustermd_tests/02r10_Manage_re-add b/clustermd_tests/02r10_Manage_re-add -index 2288a008..d8764667 100644 ---- a/clustermd_tests/02r10_Manage_re-add -+++ b/clustermd_tests/02r10_Manage_re-add -@@ -9,7 +9,8 @@ check all state UU - check all dmesg - mdadm --manage $md0 --fail $dev0 --remove $dev0 - mdadm --manage $md0 --re-add $dev0 --check $NODE1 recovery -+#non-clustered array also doesn't do sync job -+#check $NODE1 recovery - check all wait - check all state UU - check all dmesg -diff --git a/clustermd_tests/02r1_Manage_re-add b/clustermd_tests/02r1_Manage_re-add -index d0d13e53..811df87b 100644 ---- a/clustermd_tests/02r1_Manage_re-add -+++ b/clustermd_tests/02r1_Manage_re-add -@@ -9,6 +9,7 @@ check all state UU - check all dmesg - mdadm --manage $md0 --fail $dev0 --remove $dev0 - mdadm --manage $md0 --re-add $dev0 -+check all wait - check all state UU - check all dmesg - stop_md all $md0 -diff --git a/clustermd_tests/03r10_switch-recovery b/clustermd_tests/03r10_switch-recovery -index 867388d0..7d0b8812 100644 ---- a/clustermd_tests/03r10_switch-recovery -+++ b/clustermd_tests/03r10_switch-recovery -@@ -10,9 +10,9 @@ check all state UU - check all dmesg - mdadm --manage $md0 --fail $dev0 - sleep 0.2 --check $NODE1 recovery -+check $NODE1 recovery-remote - stop_md $NODE1 $md0 --check $NODE2 recovery -+check $NODE2 recovery-remote - check $NODE2 wait - check $NODE2 state UU - check all dmesg -diff --git a/clustermd_tests/03r1_switch-recovery b/clustermd_tests/03r1_switch-recovery -index a1a7cbe7..d8483c45 100644 ---- a/clustermd_tests/03r1_switch-recovery -+++ b/clustermd_tests/03r1_switch-recovery -@@ -10,9 +10,9 @@ check all state UU - check all dmesg - mdadm --manage $md0 --fail $dev0 - sleep 0.3 --check $NODE1 recovery -+check $NODE1 recovery-remote - stop_md $NODE1 $md0 --check $NODE2 recovery -+check $NODE2 recovery-remote - check $NODE2 wait - check $NODE2 state UU - check all dmesg --- -2.41.0 - diff --git a/0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch b/0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch deleted file mode 100644 index a239400..0000000 --- a/0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 48c365376ce7763fd9a9e7735b1e9ec5d0ff1631 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -Date: Wed, 3 Jul 2024 14:11:58 +0200 -Subject: [PATCH 119/157] mapfile.c: Fix STRING_OVERFLOW issue - -Fix STRING_OVERFLOW issue found by SAST analysis in map_add() and -map_update() in mapfile.c. - -Signed-off-by: Anna Sztukowska ---- - mapfile.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/mapfile.c b/mapfile.c -index f1f3ee2c..ea9837ac 100644 ---- a/mapfile.c -+++ b/mapfile.c -@@ -165,8 +165,8 @@ void map_add(struct map_ent **melp, - { - struct map_ent *me = xmalloc(sizeof(*me)); - -- strcpy(me->devnm, devnm); -- strcpy(me->metadata, metadata); -+ snprintf(me->devnm, sizeof(me->devnm), "%s", devnm); -+ snprintf(me->metadata, sizeof(me->metadata), "%s", metadata); - memcpy(me->uuid, uuid, 16); - me->path = path ? xstrdup(path) : NULL; - me->next = *melp; -@@ -227,7 +227,7 @@ int map_update(struct map_ent **mpp, char *devnm, char *metadata, - - for (mp = map ; mp ; mp=mp->next) - if (strcmp(mp->devnm, devnm) == 0) { -- strcpy(mp->metadata, metadata); -+ snprintf(mp->metadata, sizeof(mp->metadata), "%s", metadata); - memcpy(mp->uuid, uuid, 16); - free(mp->path); - mp->path = path ? xstrdup(path) : NULL; --- -2.41.0 - diff --git a/0120-mdadm-Manage.c-fix-coverity-issues.patch b/0120-mdadm-Manage.c-fix-coverity-issues.patch deleted file mode 100644 index 382544d..0000000 --- a/0120-mdadm-Manage.c-fix-coverity-issues.patch +++ /dev/null @@ -1,484 +0,0 @@ -From 1b4b73fd535a6487075e98f620454ff2e13b5240 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Wed, 10 Jul 2024 08:55:08 -0400 -Subject: [PATCH 120/157] mdadm: Manage.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Event parameter_hidden: declaration hides parameter "dv". -* Event leaked_storage: Variable "mdi" going out of scope leaks the storage -it points to. -* Event overwrite_var: Overwriting "mdi" in "mdi = mdi->devs" leaks the -storage that "mdi" points to. -* Event leaked_handle: Handle variable "lfd" going out of scope leaks -the handle. -* Event leaked_handle: Returning without closing handle "fd" leaks it. -* Event fixed_size_dest: You might overrun the 32-character fixed-sizei -string "devnm" by copying the return value of "fd2devnm" without -checking the length. -* Event fixed_size_dest: You might overrun the 32-character fixed-size -string "nm" by copying "nmp" without checking the length. -* Event fixed_size_dest: You might overrun the 32-character fixed-size -string "devnm" by copying the return value of "fd2devnm" without -checking the length. -* Event assigned_value: Assigning value "-1" to "tfd" here, but that -stored value is overwritten before it can be used. - -Signed-off-by: Nigel Croxon ---- - Manage.c | 149 ++++++++++++++++++++++++++----------------------------- - 1 file changed, 71 insertions(+), 78 deletions(-) - -diff --git a/Manage.c b/Manage.c -index 5db72b77..aa5e80b2 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -56,7 +56,7 @@ int Manage_ro(char *devname, int fd, int readonly) - vers[9] = '-'; - sysfs_set_str(mdi, NULL, "metadata_version", vers); - -- close(fd); -+ close_fd(&fd); - rv = sysfs_set_str(mdi, NULL, "array_state", "readonly"); - - if (rv < 0) { -@@ -165,7 +165,7 @@ int Manage_run(char *devname, int fd, struct context *c) - pr_err("Cannot find %s in sysfs!!\n", devname); - return 1; - } -- strcpy(nm, nmp); -+ snprintf(nm, sizeof(nm), "%s", nmp); - return IncrementalScan(c, nm); - } - -@@ -187,7 +187,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - if (will_retry && verbose == 0) - verbose = -1; - -- strcpy(devnm, fd2devnm(fd)); -+ snprintf(devnm, sizeof(devnm), "%s", fd2devnm(fd)); - /* Get EXCL access first. If this fails, then attempting - * to stop is probably a bad idea. - */ -@@ -195,7 +195,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - if (mdi && is_subarray(mdi->text_version)) - sysfs_get_container_devnm(mdi, container); - -- close(fd); -+ close_fd(&fd); - count = 5; - while (((fd = ((devname[0] == '/') - ?open(devname, O_RDONLY|O_EXCL) -@@ -206,14 +206,12 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - * is a container, so we might be racing with mdmon, so - * retry for a bit. - */ -- if (fd >= 0) -- close(fd); -+ close_fd(&fd); - flush_mdmon(container); - count--; - } - if (fd < 0 || strcmp(fd2devnm(fd), devnm) != 0) { -- if (fd >= 0) -- close(fd); -+ close_fd(&fd); - if (verbose >= 0) - pr_err("Cannot get exclusive access to %s:Perhaps a running process, mounted filesystem or active volume group?\n", - devname); -@@ -228,7 +226,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - is_subarray(mdi->text_version)) { - int err; - /* This is mdmon managed. */ -- close(fd); -+ close_fd(&fd); - - /* As we had an O_EXCL open, any use of the device - * which blocks STOP_ARRAY is probably a transient use, -@@ -430,8 +428,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - break; - sysfs_wait(scfd, &delay); - } -- if (scfd >= 0) -- close(scfd); -+ close_fd(&scfd); - - } - done: -@@ -469,6 +466,7 @@ done: - map_unlock(&map); - out: - sysfs_free(mdi); -+ close_fd(&fd); - - return rv; - } -@@ -664,7 +662,7 @@ int attempt_re_add(int fd, int tfd, struct mddev_dev *dv, - devname, verbose, 0, NULL); - if (rv == 0) - rv = dev_st->ss->store_super(dev_st, tfd); -- close(tfd); -+ close_fd(&tfd); - if (rv != 0) { - pr_err("failed to update superblock during re-add\n"); - return -1; -@@ -766,15 +764,15 @@ mdadm_status_t manage_add_external(struct supertype *st, int fd, char *disk_name - rv = MDADM_STATUS_SUCCESS; - - out: -- close(container_fd); -+ close_fd(&container_fd); - dev_policy_free(pols); - - if (sra) - sysfs_free(sra); - -- if (rv != MDADM_STATUS_SUCCESS && is_fd_valid(disk_fd)) -+ if (rv != MDADM_STATUS_SUCCESS) - /* Metadata handler records this descriptor, so release it only on failure. */ -- close(disk_fd); -+ close_fd(&disk_fd); - - if (st->sb) - st->ss->free_super(st); -@@ -845,10 +843,10 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, - continue; - if (tst->ss->load_super(tst, dfd, - NULL)) { -- close(dfd); -+ close_fd(&dfd); - continue; - } -- close(dfd); -+ close_fd(&dfd); - break; - } - /* FIXME this is a bad test to be using */ -@@ -1100,7 +1098,8 @@ int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv, - */ - int ret; - char devnm[32]; -- strcpy(devnm, fd2devnm(fd)); -+ -+ snprintf(devnm, sizeof(devnm), "%s", fd2devnm(fd)); - lfd = open_dev_excl(devnm); - if (lfd < 0) { - pr_err("Cannot get exclusive access to container - odd\n"); -@@ -1134,13 +1133,13 @@ int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv, - if (ret == 0) { - pr_err("%s is not a member, cannot remove.\n", - dv->devname); -- close(lfd); -+ close_fd(&lfd); - return -1; - } - if (ret >= 2) { - pr_err("%s is still in use, cannot remove.\n", - dv->devname); -- close(lfd); -+ close_fd(&lfd); - return -1; - } - } -@@ -1157,26 +1156,27 @@ int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv, - /* Old kernels rejected this if no personality - * is registered */ - struct mdinfo *sra = sysfs_read(fd, NULL, GET_DEVS); -- struct mdinfo *dv = NULL; -- if (sra) -- dv = sra->devs; -- for ( ; dv ; dv=dv->next) -- if (dv->disk.major == (int)major(rdev) && -- dv->disk.minor == (int)minor(rdev)) -- break; -- if (dv) -- err = sysfs_set_str(sra, dv, -- "state", "remove"); -- else -+ struct mdinfo *dev = NULL; -+ -+ if (!sra) { - err = -1; -- sysfs_free(sra); -+ } else { -+ for (dev = sra->devs; dev ; dev = dev->next) -+ if (dev->disk.major == (int)major(rdev) && -+ dev->disk.minor == (int)minor(rdev)) -+ break; -+ -+ if (dev) -+ err = sysfs_set_str(sra, dev, -+ "state", "remove"); -+ sysfs_free(sra); -+ } - } - } - if (err) { - pr_err("hot remove failed for %s: %s\n", dv->devname, - strerror(errno)); -- if (lfd >= 0) -- close(lfd); -+ close_fd(&lfd); - return -1; - } - if (tst->ss->external) { -@@ -1190,13 +1190,13 @@ int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv, - - if (!devnm) { - pr_err("unable to get container name\n"); -+ close_fd(&lfd); - return -1; - } - - ping_manager(devnm); - } -- if (lfd >= 0) -- close(lfd); -+ close_fd(&lfd); - if (verbose >= 0) - pr_err("hot removed %s from %s\n", - dv->devname, devname); -@@ -1218,7 +1218,7 @@ int Manage_replace(struct supertype *tst, int fd, struct mddev_dev *dv, - if (!mdi || !mdi->devs) { - pr_err("Cannot find status of %s to enable replacement - strange\n", - devname); -- return -1; -+ goto abort; - } - for (di = mdi->devs; di; di = di->next) - if (di->disk.major == (int)major(rdev) && -@@ -1229,16 +1229,14 @@ int Manage_replace(struct supertype *tst, int fd, struct mddev_dev *dv, - if (di->disk.raid_disk < 0) { - pr_err("%s is not active and so cannot be replaced.\n", - dv->devname); -- sysfs_free(mdi); -- return -1; -+ goto abort; - } - rv = sysfs_set_str(mdi, di, - "state", "want_replacement"); - if (rv) { -- sysfs_free(mdi); - pr_err("Failed to request replacement for %s\n", - dv->devname); -- return -1; -+ goto abort; - } - if (verbose >= 0) - pr_err("Marked %s (device %d in %s) for replacement\n", -@@ -1252,11 +1250,13 @@ int Manage_replace(struct supertype *tst, int fd, struct mddev_dev *dv, - dv->disposition = 'w'; - dv->used = di->disk.raid_disk; - } -+ sysfs_free(mdi); - return 1; - } -- sysfs_free(mdi); - pr_err("%s not found in %s so cannot --replace it\n", - dv->devname, devname); -+abort: -+ sysfs_free(mdi); - return -1; - } - -@@ -1269,7 +1269,7 @@ int Manage_with(struct supertype *tst, int fd, struct mddev_dev *dv, - if (!mdi || !mdi->devs) { - pr_err("Cannot find status of %s to enable replacement - strange\n", - devname); -- return -1; -+ goto abort; - } - for (di = mdi->devs; di; di = di->next) - if (di->disk.major == (int)major(rdev) && -@@ -1280,31 +1280,30 @@ int Manage_with(struct supertype *tst, int fd, struct mddev_dev *dv, - if (di->disk.state & (1<devname); -- sysfs_free(mdi); -- return -1; -+ goto abort; - } - if (di->disk.raid_disk >= 0) { - pr_err("%s is active and cannot be a replacement\n", - dv->devname); -- sysfs_free(mdi); -- return -1; -+ goto abort; - } - rv = sysfs_set_num(mdi, di, - "slot", dv->used); - if (rv) { -- sysfs_free(mdi); - pr_err("Failed to set %s as preferred replacement.\n", - dv->devname); -- return -1; -+ goto abort; - } - if (verbose >= 0) - pr_err("Marked %s in %s as replacement for device %d\n", - dv->devname, devname, dv->used); -+ sysfs_free(mdi); - return 1; - } -- sysfs_free(mdi); - pr_err("%s not found in %s so cannot make it preferred replacement\n", - dv->devname, devname); -+abort: -+ sysfs_free(mdi); - return -1; - } - -@@ -1324,6 +1323,7 @@ bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const - { - dev_t devid = devnm2devid(devname + 5); - struct mdinfo *mdi = sysfs_read(fd, NULL, GET_DEVS | GET_DISKS | GET_STATE); -+ struct mdinfo *disk; - - if (!mdi) { - if (verbose) -@@ -1333,14 +1333,14 @@ bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const - - char *avail = xcalloc(array->raid_disks, sizeof(char)); - -- for (mdi = mdi->devs; mdi; mdi = mdi->next) { -- if (mdi->disk.raid_disk < 0) -+ for (disk = mdi->devs; disk; disk = mdi->next) { -+ if (disk->disk.raid_disk < 0) - continue; -- if (!(mdi->disk.state & (1 << MD_DISK_SYNC))) -+ if (!(disk->disk.state & (1 << MD_DISK_SYNC))) - continue; -- if (makedev(mdi->disk.major, mdi->disk.minor) == devid) -+ if (makedev(disk->disk.major, disk->disk.minor) == devid) - continue; -- avail[mdi->disk.raid_disk] = 1; -+ avail[disk->disk.raid_disk] = 1; - } - sysfs_free(mdi); - -@@ -1550,7 +1550,7 @@ int Manage_subdevs(char *devname, int fd, - rdev = makedev(mj,mn); - found = 1; - } -- close(sysfd); -+ close_fd(&sysfd); - sysfd = -1; - } - if (!found) { -@@ -1572,7 +1572,7 @@ int Manage_subdevs(char *devname, int fd, - tfd = dev_open(dv->devname, O_RDONLY); - if (tfd >= 0) { - fstat_is_blkdev(tfd, dv->devname, &rdev); -- close(tfd); -+ close_fd(&tfd); - } else { - int open_err = errno; - if (!stat_is_blkdev(dv->devname, &rdev)) { -@@ -1635,7 +1635,7 @@ int Manage_subdevs(char *devname, int fd, - * need non-exclusive access to add it, so - * do that now. - */ -- close(tfd); -+ close_fd(&tfd); - tfd = dev_open(dv->devname, O_RDONLY); - } - if (tfd < 0) { -@@ -1654,8 +1654,7 @@ int Manage_subdevs(char *devname, int fd, - rv = Manage_add(fd, tfd, dv, tst, &array, - force, verbose, devname, update, - rdev, array_size, raid_slot); -- close(tfd); -- tfd = -1; -+ close_fd(&tfd); - if (rv < 0) - goto abort; - if (rv > 0) -@@ -1672,7 +1671,7 @@ int Manage_subdevs(char *devname, int fd, - rdev, verbose, force, - devname); - if (sysfd >= 0) -- close(sysfd); -+ close_fd(&sysfd); - sysfd = -1; - if (rv < 0) - goto abort; -@@ -1684,8 +1683,7 @@ int Manage_subdevs(char *devname, int fd, - if (!is_remove_safe(&array, fd, dv->devname, verbose)) { - pr_err("Cannot remove %s from %s, array will be failed.\n", - dv->devname, devname); -- if (sysfd >= 0) -- close(sysfd); -+ close_fd(&sysfd); - goto abort; - } - case 'I': /* incremental fail */ -@@ -1696,13 +1694,10 @@ int Manage_subdevs(char *devname, int fd, - busy = 1; - pr_err("set device faulty failed for %s: %s\n", - dv->devname, strerror(errno)); -- if (sysfd >= 0) -- close(sysfd); -+ close_fd(&sysfd); - goto abort; - } -- if (sysfd >= 0) -- close(sysfd); -- sysfd = -1; -+ close_fd(&sysfd); - count++; - if (verbose >= 0) - pr_err("set %s faulty in %s\n", -@@ -1762,7 +1757,7 @@ int autodetect(void) - if (fd >= 0) { - if (ioctl(fd, RAID_AUTORUN, 0) == 0) - rv = 0; -- close(fd); -+ close_fd(&fd); - } - return rv; - } -@@ -1825,7 +1820,7 @@ free_super: - if (info) - free(info); - st->ss->free_super(st); -- close(fd); -+ close_fd(&fd); - - return rv; - } -@@ -1843,10 +1838,8 @@ int move_spare(char *from_devname, char *to_devname, dev_t devid) - int fd2 = open(from_devname, O_RDONLY); - - if (fd1 < 0 || fd2 < 0) { -- if (fd1 >= 0) -- close(fd1); -- if (fd2 >= 0) -- close(fd2); -+ close_fd(&fd1); -+ close_fd(&fd2); - return 0; - } - -@@ -1865,15 +1858,15 @@ int move_spare(char *from_devname, char *to_devname, dev_t devid) - /* make sure manager is aware of changes */ - ping_manager(to_devname); - ping_manager(from_devname); -- close(fd1); -- close(fd2); -+ close_fd(&fd1); -+ close_fd(&fd2); - return 1; - } - else - Manage_subdevs(from_devname, fd2, &devlist, - -1, 0, UOPT_UNDEFINED, 0); - } -- close(fd1); -- close(fd2); -+ close_fd(&fd1); -+ close_fd(&fd2); - return 0; - } --- -2.41.0 - diff --git a/0121-Manage-fix-is_remove_safe.patch b/0121-Manage-fix-is_remove_safe.patch deleted file mode 100644 index d66c542..0000000 --- a/0121-Manage-fix-is_remove_safe.patch +++ /dev/null @@ -1,29 +0,0 @@ -From ec72668a9768ad01b409b68f31f3ca7ffeeaab4e Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 16 Jul 2024 15:37:34 +0200 -Subject: [PATCH 121/157] Manage: fix is_remove_safe() - -Fix for to make --set-faulty working. - -Fixes: 1b4b73fd535a ("mdadm: Manage.c fix coverity issues") -Signed-off-by: Mariusz Tkaczyk ---- - Manage.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Manage.c b/Manage.c -index aa5e80b2..f0304e1e 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -1333,7 +1333,7 @@ bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const - - char *avail = xcalloc(array->raid_disks, sizeof(char)); - -- for (disk = mdi->devs; disk; disk = mdi->next) { -+ for (disk = mdi->devs; disk; disk = disk->next) { - if (disk->disk.raid_disk < 0) - continue; - if (!(disk->disk.state & (1 << MD_DISK_SYNC))) --- -2.41.0 - diff --git a/0122-imsm-add-indent-for-encryption-details.patch b/0122-imsm-add-indent-for-encryption-details.patch deleted file mode 100644 index 22e783b..0000000 --- a/0122-imsm-add-indent-for-encryption-details.patch +++ /dev/null @@ -1,28 +0,0 @@ -From f8274feea5c63300e893109840943513df924da2 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 15 Jul 2024 12:21:19 +0200 -Subject: [PATCH 122/157] imsm: add indent for encryption details - -Improve readability of the output. - -Signed-off-by: Mariusz Tkaczyk ---- - super-intel.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index ef3f5da1..713bfccf 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2318,7 +2318,7 @@ void print_encryption_information(int disk_fd, enum sys_dev_type hba_type) - { - struct encryption_information information = {0}; - mdadm_status_t status = MDADM_STATUS_SUCCESS; -- const char *indent = " "; -+ const char *indent = " "; - - switch (hba_type) { - case SYS_DEV_VMD: --- -2.41.0 - diff --git a/0123-mdadm-Monitor.c-fix-coverity-issues.patch b/0123-mdadm-Monitor.c-fix-coverity-issues.patch deleted file mode 100644 index da0ac6b..0000000 --- a/0123-mdadm-Monitor.c-fix-coverity-issues.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 5cb6df3f190feccc8b3e82da2b01a0e01e612a25 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Mon, 15 Jul 2024 10:13:46 -0400 -Subject: [PATCH 123/157] mdadm: Monitor.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Event check_return: Calling "fcntl(fd, 2, 1)" without checking -return value. This library function may fail and return an error code. - -* Dereferencing "sl", which is known to be "NULL". - -* Event fixed_size_dest: You might overrun the 32-character fixed-size -string "devnm" by copying "tmp" without checking the length. - -Signed-off-by: Nigel Croxon ---- - Monitor.c | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index 9b016bc3..26c53e13 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -782,7 +782,9 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, - if (!is_container && !md_array_active(fd)) - goto disappeared; - -- fcntl(fd, F_SETFD, FD_CLOEXEC); -+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) -+ goto out; -+ - if (md_get_array_info(fd, &array) < 0) - goto disappeared; - -@@ -997,7 +999,8 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist) - snprintf(st->parent_devnm, MD_NAME_MAX, - "%s", mse->metadata_version + 10); - sl = strchr(st->parent_devnm, '/'); -- *sl = 0; -+ if (sl) -+ *sl = 0; - } else - st->parent_devnm[0] = 0; - *statelist = st; -@@ -1261,7 +1264,7 @@ int Wait(char *dev) - return 2; - } - -- strcpy(devnm, tmp); -+ snprintf(devnm, sizeof(devnm), "%s", tmp); - - while(1) { - struct mdstat_ent *ms = mdstat_read(1, 0); -@@ -1332,7 +1335,8 @@ int WaitClean(char *dev, int verbose) - return 1; - } - -- strcpy(devnm, fd2devnm(fd)); -+ snprintf(devnm, sizeof(devnm), "%s", fd2devnm(fd)); -+ - mdi = sysfs_read(fd, devnm, GET_VERSION|GET_LEVEL|GET_SAFEMODE); - if (!mdi) { - if (verbose) --- -2.41.0 - diff --git a/0124-mdadm-Query.c-fix-coverity-issues.patch b/0124-mdadm-Query.c-fix-coverity-issues.patch deleted file mode 100644 index 57b7079..0000000 --- a/0124-mdadm-Query.c-fix-coverity-issues.patch +++ /dev/null @@ -1,42 +0,0 @@ -From bcc3ab1728da61e5519e1f01597c8da0c5bc769b Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Tue, 16 Jul 2024 07:19:34 -0400 -Subject: [PATCH 124/157] mdadm: Query.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Event leaked_storage: Variable "sra" going out of scope leaks the -storage it points to. - -* Event uninit_use_in_call: Using uninitialized value "larray_size" when -calling "human_size_brief". - -Signed-off-by: Nigel Croxon ---- - Query.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/Query.c b/Query.c -index adcd231e..aedb4ce7 100644 ---- a/Query.c -+++ b/Query.c -@@ -39,7 +39,7 @@ int Query(char *dev) - struct mdinfo info; - struct mdinfo *sra; - struct supertype *st = NULL; -- unsigned long long larray_size; -+ unsigned long long larray_size = 0; - struct stat stb; - char *mddev; - mdu_disk_info_t disc; -@@ -136,5 +136,7 @@ int Query(char *dev) - if (st->ss == &super0) - put_md_name(mddev); - } -+ free(sra); -+ - return 0; - } --- -2.41.0 - diff --git a/0125-mdadm-lib.c-fix-coverity-issues.patch b/0125-mdadm-lib.c-fix-coverity-issues.patch deleted file mode 100644 index a31b904..0000000 --- a/0125-mdadm-lib.c-fix-coverity-issues.patch +++ /dev/null @@ -1,43 +0,0 @@ -From da7aecdf25371e1476da4ec56e9ec5ddf13af5da Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Tue, 16 Jul 2024 07:20:10 -0400 -Subject: [PATCH 125/157] mdadm: lib.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 "devnm" by copying "cp + 1" without checking the length. - -* Event fixed_size_dest: You might overrun the 32-character fixed-size -string "devnm" by copying "cp" without checking the length. - -Signed-off-by: Nigel Croxon ---- - lib.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib.c b/lib.c -index 2b09293c..13d4e4f1 100644 ---- a/lib.c -+++ b/lib.c -@@ -109,7 +109,7 @@ char *devid2kname(dev_t devid) - link[n] = 0; - cp = strrchr(link, '/'); - if (cp) { -- strcpy(devnm, cp + 1); -+ snprintf(devnm, sizeof(devnm), "%s", cp + 1); - return devnm; - } - } -@@ -159,7 +159,7 @@ char *devid2devnm(dev_t devid) - ep = strchr(cp, '/'); - if (ep) - *ep = 0; -- strcpy(devnm, cp); -+ snprintf(devnm, sizeof(devnm), "%s", cp); - return devnm; - } - } --- -2.41.0 - diff --git a/0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch b/0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch deleted file mode 100644 index 1fa0e52..0000000 --- a/0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch +++ /dev/null @@ -1,158 +0,0 @@ -From 998544c198c156db027a6e4f1b201910b138041e Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 15 Jul 2024 12:29:24 +0200 -Subject: [PATCH 126/157] mdadm: do not allow leading dot in MD device name - -Do not allow to use '.' on first place for named MD device. -Having leading dot might be confusing, MD device cannot be hidden. -It also removes possibility to create md device with name '.'. - -Additionally, code optimalizations are done. - -Signed-off-by: Mariusz Tkaczyk ---- - config.c | 75 +++++++++++++++++++++++++++++++------------------------- - 1 file changed, 41 insertions(+), 34 deletions(-) - -diff --git a/config.c b/config.c -index cd2379bd..6ea905f3 100644 ---- a/config.c -+++ b/config.c -@@ -188,8 +188,36 @@ inline void ident_init(struct mddev_ident *ident) - ident->uuid_set = 0; - } - -+/** ident_check_name() - helper function to verify name. -+ * @name: name to check. -+ * @prop_name: the name of the property it is validated against, used for logging. -+ * @cmdline: context dependent actions. -+ * -+ * @name must follow name's criteria, be POSIX compatible and does not have leading dot. -+ */ -+static mdadm_status_t ident_check_name(const char *name, const char *prop_name, const bool cmdline) -+{ -+ if (!is_string_lq(name, MD_NAME_MAX + 1)) { -+ ident_log(prop_name, name, "Too long or empty", cmdline); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ if (*name == '.') { -+ /* MD device should not be considered as hidden. */ -+ ident_log(prop_name, name, "Leading dot forbidden", cmdline); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ if (!is_name_posix_compatible(name)) { -+ ident_log(prop_name, name, "Not POSIX compatible", cmdline); -+ return MDADM_STATUS_ERROR; -+ } -+ -+ return MDADM_STATUS_SUCCESS; -+} -+ - /** -- * _ident_set_devname()- verify devname and set it in &mddev_ident. -+ * _ident_set_devname() - verify devname and set it in &mddev_ident. - * @ident: pointer to &mddev_ident. - * @devname: devname to be set. - * @cmdline: context dependent actions. If set, ignore keyword is not allowed. -@@ -202,8 +230,7 @@ inline void ident_init(struct mddev_ident *ident) - * /dev/md/{name} - * {name} - * -- * {name} must follow name's criteria and be POSIX compatible. -- * If criteria passed, duplicate memory and set devname in @ident. -+ * If verification passed, duplicate memory and set devname in @ident. - * - * Return: %MDADM_STATUS_SUCCESS or %MDADM_STATUS_ERROR. - */ -@@ -216,6 +243,7 @@ mdadm_status_t _ident_set_devname(struct mddev_ident *ident, const char *devname - static const char named_dev_pref[] = DEV_NUM_PREF "_"; - static const int named_dev_pref_size = sizeof(named_dev_pref) - 1; - const char *prop_name = "devname"; -+ mdadm_status_t ret; - const char *name; - - if (ident->devname) { -@@ -242,53 +270,40 @@ 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); -- return MDADM_STATUS_ERROR; -- } -- -- if (is_string_lq(name, MD_NAME_MAX + 1) == false) { -- ident_log(prop_name, devname, "Invalid length", cmdline); -- return MDADM_STATUS_ERROR; -- } -+ ret = ident_check_name(name, prop_name, cmdline); -+ if (ret) -+ return ret; - pass: - ident->devname = xstrdup(devname); - return MDADM_STATUS_SUCCESS; - } - - /** -- * _ident_set_name()- set name in &mddev_ident. -+ * _ident_set_name() - set name in &mddev_ident. - * @ident: pointer to &mddev_ident. - * @name: name to be set. -- * @cmdline: context dependent actions. - * - * If criteria passed, set name in @ident. - * Note: name is not used by config file, it for cmdline only. - * - * Return: %MDADM_STATUS_SUCCESS or %MDADM_STATUS_ERROR. - */ --static mdadm_status_t _ident_set_name(struct mddev_ident *ident, const char *name, -- const bool cmdline) -+mdadm_status_t ident_set_name(struct mddev_ident *ident, const char *name) - { - assert(name); - assert(ident); - - const char *prop_name = "name"; -+ mdadm_status_t ret; - - if (ident->name[0]) { -- ident_log(prop_name, name, "Already defined", cmdline); -+ ident_log(prop_name, name, "Already defined", true); - return MDADM_STATUS_ERROR; - } - -- if (is_string_lq(name, MD_NAME_MAX + 1) == false) { -- ident_log(prop_name, name, "Too long or empty", cmdline); -- return MDADM_STATUS_ERROR; -- } -- -- if (is_name_posix_compatible(name) == false) { -- ident_log(prop_name, name, "Not POSIX compatible", cmdline); -- return MDADM_STATUS_ERROR; -- } -+ ret = ident_check_name(name, prop_name, true); -+ if (ret) -+ return ret; - - snprintf(ident->name, MD_NAME_MAX + 1, "%s", name); - return MDADM_STATUS_SUCCESS; -@@ -302,14 +317,6 @@ mdadm_status_t ident_set_devname(struct mddev_ident *ident, const char *name) - return _ident_set_devname(ident, name, true); - } - --/** -- * ident_set_name()- exported, for cmdline. -- */ --mdadm_status_t ident_set_name(struct mddev_ident *ident, const char *name) --{ -- return _ident_set_name(ident, name, true); --} -- - struct conf_dev { - struct conf_dev *next; - char *name; --- -2.41.0 - diff --git a/0128-Detail-fix-detail-export-for-uuid_zero.patch b/0128-Detail-fix-detail-export-for-uuid_zero.patch deleted file mode 100644 index 3c3ae7f..0000000 --- a/0128-Detail-fix-detail-export-for-uuid_zero.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 5be749ce416852e7acbb2415be380be358859612 Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Tue, 23 Jul 2024 15:38:41 +0200 -Subject: [PATCH 128/157] Detail: fix --detail --export for uuid_zero - -Mentioned commit (see Fixes) causes that devices with UUID -equal to uuid_zero was not recognized properly. For few devices -the first one was taken always, and the same information was -printed. It caused regression, when few containers were created, -symlinks were generated only for the first one. - -Add checking if uuid is uuid_zero and, if yes, use devname to -differentiate devices. - -Fixes: 60c19530dd7c ("Detail: remove duplicated code") -Signed-off-by: Kinga Stefaniuk ---- - Detail.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index 55a086d3..f8b9e847 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -274,7 +274,7 @@ int Detail(char *dev, struct context *c) - array.minor_version); - } - -- if (info) -+ if (info && memcmp(info->uuid, uuid_zero, sizeof(int[4])) != 0) - mp = map_by_uuid(&map, info->uuid); - if (!mp) - mp = map_by_devnm(&map, fd2devnm(fd)); --- -2.41.0 - diff --git a/0129-drive_encryption-Fix-ata-passthrough12-verify.patch b/0129-drive_encryption-Fix-ata-passthrough12-verify.patch deleted file mode 100644 index 1427a93..0000000 --- a/0129-drive_encryption-Fix-ata-passthrough12-verify.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 2bb4efb504d0991eaba755242d3e70facb5d994b Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Tue, 23 Jul 2024 12:45:10 +0200 -Subject: [PATCH 129/157] drive_encryption: Fix ata passthrough12 verify - -Based on documentation SCSI Primary Commands - 4 (SPC-4) only first 7 bits -of first byte in sense data are used to store response code. The current -verification uses all 8 bits for comparison of response code. - -Incorrect verification may make impossible to use SATA disks with IMSM, -because IMSM requires verification of the encryption state before use. - -There was issue in kernel libata [1]. This issue hides bug in mdadm because -last bit was not set. - -Example output with affected mdadm: - - Port3 : /dev/sde (BTPR212503EK120LGN) -mdadm: Failed ata passthrough12 ioctl. Device: /dev/sde. -mdadm: Failed to get drive encryption information - -The fix is use the first 7 bits of Byte 0, to compare with the expected -values. - -[1] https://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git/commit/?id=38dab832c3f4 - -Fixes: df38df3052c3 ("Add reading SATA encryption information") -Signed-off-by: Blazej Kucman ---- - drive_encryption.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/drive_encryption.c b/drive_encryption.c -index a4ad799f..63bdab1a 100644 ---- a/drive_encryption.c -+++ b/drive_encryption.c -@@ -65,6 +65,7 @@ - #define SENSE_DATA_CURRENT_FIXED (0x70) - #define SENSE_DATA_CURRENT_DESC (0x72) - #define SENSE_CURRENT_RES_DESC_POS (8) -+#define SENSE_RESPONSE_CODE_MASK (0x7f) - #define SG_DRIVER_SENSE (0x08) - - typedef enum drive_feature_support_status { -@@ -473,6 +474,7 @@ ata_pass_through12_ioctl(int disk_fd, __u8 ata_command, __u8 sec_protocol, __u1 - { - __u8 cdb[ATA_INQUIRY_LENGTH] = {0}; - __u8 sense[SG_SENSE_SIZE] = {0}; -+ __u8 sense_response_code; - __u8 *sense_desc = NULL; - sg_io_hdr_t sg = {0}; - -@@ -517,15 +519,17 @@ ata_pass_through12_ioctl(int disk_fd, __u8 ata_command, __u8 sec_protocol, __u1 - return MDADM_STATUS_ERROR; - } - -+ sense_response_code = sense[0] & SENSE_RESPONSE_CODE_MASK; - /* verify expected sense response code */ -- if (!(sense[0] == SENSE_DATA_CURRENT_DESC || sense[0] == SENSE_DATA_CURRENT_FIXED)) { -+ if (!(sense_response_code == SENSE_DATA_CURRENT_DESC || -+ sense_response_code == SENSE_DATA_CURRENT_FIXED)) { - pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s.\n", fd2kname(disk_fd)); - return MDADM_STATUS_ERROR; - } - - sense_desc = sense + SENSE_CURRENT_RES_DESC_POS; - /* verify sense data current response with descriptor format */ -- if (sense[0] == SENSE_DATA_CURRENT_DESC && -+ if (sense_response_code == SENSE_DATA_CURRENT_DESC && - !(sense_desc[0] == ATA_STATUS_RETURN_DESCRIPTOR && - sense_desc[1] == ATA_INQUIRY_LENGTH)) { - pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s. Sense data ASC: %d, ASCQ: %d.\n", -@@ -534,7 +538,7 @@ ata_pass_through12_ioctl(int disk_fd, __u8 ata_command, __u8 sec_protocol, __u1 - } - - /* verify sense data current response with fixed format */ -- if (sense[0] == SENSE_DATA_CURRENT_FIXED && -+ if (sense_response_code == SENSE_DATA_CURRENT_FIXED && - !(sense[12] == ATA_PT_INFORMATION_AVAILABLE_ASC && - sense[13] == ATA_PT_INFORMATION_AVAILABLE_ASCQ)) { - pr_vrb("Failed ata passthrough12 ioctl. Device: /dev/%s. Sense data ASC: %d, ASCQ: %d.\n", --- -2.41.0 - diff --git a/0130-super0-use-define-for-char-array-in-examine_super0.patch b/0130-super0-use-define-for-char-array-in-examine_super0.patch deleted file mode 100644 index 639a401..0000000 --- a/0130-super0-use-define-for-char-array-in-examine_super0.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0af8c9ebf50b68ad5f80efad7e94688235544a3d Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Thu, 4 Jul 2024 14:53:35 +0200 -Subject: [PATCH 130/157] super0: use define for char array in examine_super0 - -Using nb with 11 length may cause format-truncation errors, -because it was possible to use snprintf with 12 length input -and write it to 11 length output. Added new define and use it -to avoid this error. - -Signed-off-by: Kinga Stefaniuk ---- - mdadm.h | 3 +++ - super0.c | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/mdadm.h b/mdadm.h -index 27009154..22d5e8f4 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -2021,6 +2021,9 @@ enum r0layout { - #define PATH_MAX 4096 - #endif - -+/* The max string length necessary for decimal conversion, cannot be longer than count of bits */ -+#define INT_2_DEC_STR_MAX (sizeof(int) * 8) -+ - #define RESYNC_NONE -1 - #define RESYNC_DELAYED -2 - #define RESYNC_PENDING -3 -diff --git a/super0.c b/super0.c -index 9b8a1bd6..9b4e187e 100644 ---- a/super0.c -+++ b/super0.c -@@ -229,7 +229,7 @@ static void examine_super0(struct supertype *st, char *homehost) - d++) { - mdp_disk_t *dp; - char *dv; -- char nb[11]; -+ char nb[INT_2_DEC_STR_MAX]; - int wonly, failfast; - if (d>=0) dp = &sb->disks[d]; - else dp = &sb->this_disk; --- -2.41.0 - diff --git a/0131-Makefile-add-more-compiler-flags.patch b/0131-Makefile-add-more-compiler-flags.patch deleted file mode 100644 index 81157ab..0000000 --- a/0131-Makefile-add-more-compiler-flags.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 93c5215677a71e9772f68a449533cb3c97d2b869 Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Thu, 4 Jul 2024 15:01:06 +0200 -Subject: [PATCH 131/157] Makefile: add more compiler flags - -It is essential to avoid vulnerabilities in code as much -as possible using safe compilation flags. It is easier if -they are added to the Makefile and applied during compilation. -Add new gcc flags and make them configurable, because they -may not be supported for some compilers. -Set FORTIFY_SOURCE with the highest supported value for platform. - -Signed-off-by: Kinga Stefaniuk ---- - Makefile | 23 ++++++++++++++++++++++- - 1 file changed, 22 insertions(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index 3fe0a053..a914b178 100644 ---- a/Makefile -+++ b/Makefile -@@ -30,7 +30,7 @@ - - # define "CXFLAGS" to give extra flags to CC. - # e.g. make CXFLAGS=-O to optimise --CXFLAGS ?=-O2 -D_FORTIFY_SOURCE=2 -+CXFLAGS ?=-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE - TCC = tcc - UCLIBC_GCC = $(shell for nm in i386-uclibc-linux-gcc i386-uclibc-gcc; do which $$nm > /dev/null && { echo $$nm ; exit; } ; done; echo false No uclibc found ) - #DIET_GCC = diet gcc -@@ -76,6 +76,27 @@ ifeq ($(origin STRINGOPOVERFLOW), undefined) - endif - endif - -+ifeq ($(origin NOSTRICTOVERFLOW), undefined) -+ NOSTRICTOVERFLOW := $(shell $(CC) -Q --help=warning 2>&1 | grep "strict-overflow" | wc -l) -+ ifneq "$(NOSTRICTOVERFLOW)" "0" -+ CWFLAGS += -fno-strict-overflow -+ endif -+endif -+ -+ifeq ($(origin NODELETENULLPOINTER), undefined) -+ NODELETENULLPOINTER := $(shell $(CC) -Q --help=optimizers 2>&1 | grep "delete-null-pointer-checks" | wc -l) -+ ifneq "$(NODELETENULLPOINTER)" "0" -+ CWFLAGS += -fno-delete-null-pointer-checks -+ endif -+endif -+ -+ifeq ($(origin WRAPV), undefined) -+ WRAPV := $(shell $(CC) -Q --help=optimizers 2>&1 | grep "wrapv" | wc -l) -+ ifneq "$(WRAPV)" "0" -+ CWFLAGS += -fwrapv -+ endif -+endif -+ - ifdef DEBIAN - CPPFLAGS += -DDEBIAN - endif --- -2.41.0 - diff --git a/0133-mdstat-Rework-mdstat-external-arrays-handling.patch b/0133-mdstat-Rework-mdstat-external-arrays-handling.patch deleted file mode 100644 index c87f869..0000000 --- a/0133-mdstat-Rework-mdstat-external-arrays-handling.patch +++ /dev/null @@ -1,575 +0,0 @@ -From 4b3644ab4ce6df8c7f64c189c12b66627ff3e027 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 5 Jul 2024 10:49:27 +0200 -Subject: [PATCH 133/157] mdstat: Rework mdstat external arrays handling - -To avoid repeating mdstat_read() in IncrementalRemove(), new function -mdstat_find_by_member_name() has been proposed. With that, -IncrementalRemove() handles own copy of mdstat content and there is no -need to repeat reading for external stop. - -Additionally, It proposed few helper to avoid repeating -mdstat_ent->metadata_version checks across code. - -Signed-off-by: Mariusz Tkaczyk ---- - Assemble.c | 9 ++-- - Incremental.c | 37 +++++++++------ - Manage.c | 6 +-- - Monitor.c | 18 +++---- - config.c | 49 ++++++++++--------- - mapfile.c | 12 ++--- - mdadm.h | 6 ++- - mdmon.c | 4 +- - mdmon.h | 2 +- - mdstat.c | 129 ++++++++++++++++++++++++++++++++++++-------------- - super-intel.c | 9 ++-- - util.c | 10 ---- - 12 files changed, 167 insertions(+), 124 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 77f2b50e..a2bb7b64 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -114,14 +114,11 @@ static int is_member_busy(char *metadata_version) - int busy = 0; - - for (ent = mdstat; ent; ent = ent->next) { -- if (ent->metadata_version == NULL) -- continue; -- if (strncmp(ent->metadata_version, "external:", 9) != 0) -- continue; -- if (!is_subarray(&ent->metadata_version[9])) -+ if (!is_mdstat_ent_subarray(ent)) - continue; -+ - /* Skip first char - it can be '/' or '-' */ -- if (strcmp(&ent->metadata_version[10], metadata_version+1) == 0) { -+ if (strcmp(&ent->metadata_version[10], metadata_version + 1) == 0) { - busy = 1; - break; - } -diff --git a/Incremental.c b/Incremental.c -index 83db0712..abc7721b 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -1686,12 +1686,13 @@ static void remove_from_member_array(struct mdstat_ent *memb, - */ - int IncrementalRemove(char *devname, char *id_path, int verbose) - { -- int mdfd; -- int rv = 0; -- struct mdstat_ent *ent; -+ struct mdstat_ent *ent = NULL; -+ char buf[SYSFS_MAX_BUF_SIZE]; -+ struct mdstat_ent *mdstat; - struct mddev_dev devlist; - struct mdinfo mdi; -- char buf[SYSFS_MAX_BUF_SIZE]; -+ int rv = 1; -+ int mdfd; - - if (!id_path) - dprintf("incremental removal without --path lacks the possibility to re-add new device in this port\n"); -@@ -1700,16 +1701,25 @@ int IncrementalRemove(char *devname, char *id_path, int verbose) - pr_err("incremental removal requires a kernel device name, not a file: %s\n", devname); - return 1; - } -- ent = mdstat_by_component(devname); -+ -+ mdstat = mdstat_read(0, 0); -+ if (!mdstat) { -+ pr_err("Cannot read /proc/mdstat file, aborting\n"); -+ return 1; -+ } -+ -+ ent = mdstat_find_by_member_name(mdstat, devname); - if (!ent) { - if (verbose >= 0) - pr_err("%s does not appear to be a component of any array\n", devname); -- return 1; -+ goto out; - } -+ - if (sysfs_init(&mdi, -1, ent->devnm)) { - pr_err("unable to initialize sysfs for: %s\n", devname); -- return 1; -+ goto out; - } -+ - mdfd = open_dev_excl(ent->devnm); - if (is_fd_valid(mdfd)) { - close_fd(&mdfd); -@@ -1725,8 +1735,7 @@ int IncrementalRemove(char *devname, char *id_path, int verbose) - if (mdfd < 0) { - if (verbose >= 0) - pr_err("Cannot open array %s!!\n", ent->devnm); -- free_mdstat(ent); -- return 1; -+ goto out; - } - - if (id_path) { -@@ -1741,16 +1750,13 @@ int IncrementalRemove(char *devname, char *id_path, int verbose) - devlist.devname = devname; - devlist.disposition = 'I'; - /* for a container, we must fail each member array */ -- if (ent->metadata_version && -- strncmp(ent->metadata_version, "external:", 9) == 0) { -- struct mdstat_ent *mdstat = mdstat_read(0, 0); -+ if (is_mdstat_ent_external(ent)) { - struct mdstat_ent *memb; - for (memb = mdstat ; memb ; memb = memb->next) { - if (is_container_member(memb, ent->devnm)) - remove_from_member_array(memb, - &devlist, verbose); - } -- free_mdstat(mdstat); - } else { - /* - * This 'I' incremental remove is a try-best effort, -@@ -1765,7 +1771,8 @@ int IncrementalRemove(char *devname, char *id_path, int verbose) - rv = Manage_subdevs(ent->devnm, mdfd, &devlist, - verbose, 0, UOPT_UNDEFINED, 0); - -- close(mdfd); -- free_mdstat(ent); -+ close_fd(&mdfd); -+out: -+ free_mdstat(mdstat); - return rv; - } -diff --git a/Manage.c b/Manage.c -index f0304e1e..241de055 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -276,10 +276,8 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) - */ - mds = mdstat_read(0, 0); - for (m = mds; m; m = m->next) -- if (m->metadata_version && -- strncmp(m->metadata_version, "external:", 9)==0 && -- metadata_container_matches(m->metadata_version+9, -- devnm)) { -+ if (is_mdstat_ent_external(m) && -+ metadata_container_matches(m->metadata_version + 9, devnm)) { - if (verbose >= 0) - pr_err("Cannot stop container %s: member %s still active\n", - devname, m->devnm); -diff --git a/Monitor.c b/Monitor.c -index 26c53e13..cf14fbb3 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -879,9 +879,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, - } - last_disk = i; - -- if (mse->metadata_version && -- strncmp(mse->metadata_version, "external:", 9) == 0 && -- is_subarray(mse->metadata_version+9)) { -+ if (is_mdstat_ent_subarray(mse)) { - char *sl; - snprintf(st->parent_devnm, MD_NAME_MAX, "%s", mse->metadata_version + 10); - sl = strchr(st->parent_devnm, '/'); -@@ -991,13 +989,12 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist) - snprintf(st->devnm, MD_NAME_MAX, "%s", mse->devnm); - st->percent = RESYNC_UNKNOWN; - st->expected_spares = -1; -- if (mse->metadata_version && -- strncmp(mse->metadata_version, -- "external:", 9) == 0 && -- is_subarray(mse->metadata_version+9)) { -+ -+ if (is_mdstat_ent_subarray(mse)) { - char *sl; -- snprintf(st->parent_devnm, MD_NAME_MAX, -- "%s", mse->metadata_version + 10); -+ -+ snprintf(st->parent_devnm, MD_NAME_MAX, "%s", -+ mse->metadata_version + 10); - sl = strchr(st->parent_devnm, '/'); - if (sl) - *sl = 0; -@@ -1297,8 +1294,7 @@ int Wait(char *dev) - } - } - if (!e || e->percent == RESYNC_NONE) { -- if (e && e->metadata_version && -- strncmp(e->metadata_version, "external:", 9) == 0) { -+ if (e && is_mdstat_ent_external(e)) { - if (is_subarray(&e->metadata_version[9])) - ping_monitor(&e->metadata_version[9]); - else -diff --git a/config.c b/config.c -index 6ea905f3..5411a480 100644 ---- a/config.c -+++ b/config.c -@@ -360,35 +360,38 @@ struct mddev_dev *load_partitions(void) - struct mddev_dev *load_containers(void) - { - struct mdstat_ent *mdstat = mdstat_read(0, 0); -+ struct mddev_dev *dev_list = NULL; -+ struct map_ent *map_list = NULL; - struct mdstat_ent *ent; -- struct mddev_dev *d; -- struct mddev_dev *rv = NULL; -- struct map_ent *map = NULL, *me; - -- if (!mdstat) -- return NULL; -+ for (ent = mdstat; ent; ent = ent->next) { -+ struct mddev_dev *d; -+ struct map_ent *map; - -- for (ent = mdstat; ent; ent = ent->next) -- if (ent->metadata_version && -- strncmp(ent->metadata_version, "external:", 9) == 0 && -- !is_subarray(&ent->metadata_version[9])) { -- d = xcalloc(1, sizeof(*d)); -- me = map_by_devnm(&map, ent->devnm); -- if (me) -- d->devname = xstrdup(me->path); -- else if (asprintf(&d->devname, "/dev/%s", ent->devnm) < 0) { -- free(d); -- continue; -- } -- d->next = rv; -- rv = d; -- map_free(map); -- map = NULL; -+ if (!is_mdstat_ent_external(ent)) -+ continue; -+ -+ if (is_mdstat_ent_subarray(ent)) -+ continue; -+ -+ d = xcalloc(1, sizeof(*d)); -+ -+ map = map_by_devnm(&map_list, ent->devnm); -+ if (map) { -+ d->devname = xstrdup(map->path); -+ } else if (asprintf(&d->devname, "/dev/%s", ent->devnm) < 0) { -+ free(d); -+ continue; - } -+ -+ d->next = dev_list; -+ dev_list = d; -+ } -+ - free_mdstat(mdstat); -- map_free(map); -+ map_free(map_list); - -- return rv; -+ return dev_list; - } - - struct createinfo createinfo = { -diff --git a/mapfile.c b/mapfile.c -index ea9837ac..632cf5e8 100644 ---- a/mapfile.c -+++ b/mapfile.c -@@ -339,18 +339,14 @@ struct map_ent *map_by_name(struct map_ent **map, char *name) - */ - static char *get_member_info(struct mdstat_ent *ent) - { -+ char *subarray; - -- if (ent->metadata_version == NULL || -- strncmp(ent->metadata_version, "external:", 9) != 0) -+ if (!is_mdstat_ent_subarray(ent)) - return NULL; - -- if (is_subarray(&ent->metadata_version[9])) { -- char *subarray; -+ subarray = strrchr(ent->metadata_version, '/'); - -- subarray = strrchr(ent->metadata_version, '/'); -- return subarray + 1; -- } -- return NULL; -+ return subarray + 1; - } - - void RebuildMap(void) -diff --git a/mdadm.h b/mdadm.h -index 22d5e8f4..5c3a9836 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -743,8 +743,12 @@ extern int mdstat_wait(int seconds); - extern void mdstat_wait_fd(int fd, const sigset_t *sigmask); - extern int mddev_busy(char *devnm); - extern struct mdstat_ent *mdstat_by_component(char *name); -+extern struct mdstat_ent *mdstat_find_by_member_name(struct mdstat_ent *mdstat, char *member_devnm); - extern struct mdstat_ent *mdstat_by_subdev(char *subdev, char *container); - -+extern bool is_mdstat_ent_external(struct mdstat_ent *ent); -+extern bool is_mdstat_ent_subarray(struct mdstat_ent *ent); -+ - struct map_ent { - struct map_ent *next; - char devnm[32]; -@@ -1771,7 +1775,7 @@ extern int is_mddev(char *dev); - extern int open_container(int fd); - extern int metadata_container_matches(char *metadata, char *devnm); - extern int metadata_subdev_matches(char *metadata, char *devnm); --extern int is_container_member(struct mdstat_ent *ent, char *devname); -+extern bool is_container_member(struct mdstat_ent *ent, char *devname); - extern int is_subarray_active(char *subarray, char *devname); - extern int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet); - extern struct superswitch *version_to_superswitch(char *vers); -diff --git a/mdmon.c b/mdmon.c -index 5fdb5cdb..95e350f4 100644 ---- a/mdmon.c -+++ b/mdmon.c -@@ -394,9 +394,7 @@ int main(int argc, char *argv[]) - /* launch an mdmon instance for each container found */ - mdstat = mdstat_read(0, 0); - for (e = mdstat; e; e = e->next) { -- if (e->metadata_version && -- strncmp(e->metadata_version, "external:", 9) == 0 && -- !is_subarray(&e->metadata_version[9])) { -+ if (is_mdstat_ent_external(e) && !is_mdstat_ent_subarray(e)) { - /* update cmdline so this mdmon instance can be - * distinguished from others in a call to ps(1) - */ -diff --git a/mdmon.h b/mdmon.h -index b3d72ac3..110cbef2 100644 ---- a/mdmon.h -+++ b/mdmon.h -@@ -78,7 +78,7 @@ void do_manager(struct supertype *container); - extern int sigterm; - - int read_dev_state(int fd); --int is_container_member(struct mdstat_ent *mdstat, char *container); -+bool is_container_member(struct mdstat_ent *mdstat, char *container); - - struct mdstat_ent *mdstat_read(int hold, int start); - -diff --git a/mdstat.c b/mdstat.c -index e233f094..cbbace3d 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -110,6 +110,28 @@ static int add_member_devname(struct dev_member **m, char *name) - return 1; - } - -+/* Detach element from the list, it may modify list_head */ -+static void mdstat_ent_list_detach_element(struct mdstat_ent **list_head, struct mdstat_ent *el) -+{ -+ struct mdstat_ent *ent = *list_head; -+ -+ if (ent == el) { -+ *list_head = ent->next; -+ } else { -+ while (ent) { -+ if (ent->next == el) { -+ ent->next = el->next; -+ break; -+ } -+ } -+ -+ ent = ent->next; -+ } -+ -+ assert(ent); -+ ent->next = NULL; -+} -+ - void free_mdstat(struct mdstat_ent *ms) - { - while (ms) { -@@ -124,6 +146,32 @@ void free_mdstat(struct mdstat_ent *ms) - } - } - -+bool is_mdstat_ent_external(struct mdstat_ent *ent) -+{ -+ if (!ent->metadata_version) -+ return false; -+ -+ if (strncmp(ent->metadata_version, "external:", 9) == 0) -+ return true; -+ return false; -+} -+ -+bool is_mdstat_ent_subarray(struct mdstat_ent *ent) -+{ -+ if (is_mdstat_ent_external(ent) && is_subarray(ent->metadata_version + 9)) -+ return true; -+ return false; -+} -+ -+bool is_container_member(struct mdstat_ent *mdstat, char *container) -+{ -+ if (is_mdstat_ent_external(mdstat) && -+ metadata_container_matches(mdstat->metadata_version + 9, container)) -+ return true; -+ -+ return false; -+} -+ - static int mdstat_fd = -1; - struct mdstat_ent *mdstat_read(int hold, int start) - { -@@ -382,61 +430,70 @@ int mddev_busy(char *devnm) - return me != NULL; - } - --struct mdstat_ent *mdstat_by_component(char *name) -+/** -+ * mdstat_find_by_member_devnm()- Return first array or external container with member device. -+ * @mdstat: Preloaded mdstat to iterate over. -+ * @member_devnm: devnm of the device to find. -+ * -+ * External subarrays are skipped. -+ */ -+struct mdstat_ent *mdstat_find_by_member_name(struct mdstat_ent *mdstat, char *member_devnm) - { -- struct mdstat_ent *mdstat = mdstat_read(0, 0); -+ struct mdstat_ent *ent; - -- while (mdstat) { -- struct dev_member *m; -- struct mdstat_ent *ent; -- if (mdstat->metadata_version && -- strncmp(mdstat->metadata_version, "external:", 9) == 0 && -- is_subarray(mdstat->metadata_version+9)) -- /* don't return subarrays, only containers */ -- ; -- else for (m = mdstat->members; m; m = m->next) { -- if (strcmp(m->name, name) == 0) { -- free_mdstat(mdstat->next); -- mdstat->next = NULL; -- return mdstat; -- } -- } -- ent = mdstat; -- mdstat = mdstat->next; -- ent->next = NULL; -- free_mdstat(ent); -+ for (ent = mdstat; ent; ent = ent->next) { -+ struct dev_member *member; -+ -+ if (is_mdstat_ent_subarray(ent)) -+ continue; -+ -+ for (member = ent->members; member; member = member->next) -+ if (strcmp(member->name, member_devnm) == 0) -+ return ent; - } -+ - return NULL; - } - -+ -+struct mdstat_ent *mdstat_by_component(char *name) -+{ -+ struct mdstat_ent *mdstat = mdstat_read(0, 0); -+ struct mdstat_ent *ent = mdstat_find_by_member_name(mdstat, name); -+ -+ if (ent) -+ mdstat_ent_list_detach_element(&mdstat, ent); -+ -+ free_mdstat(mdstat); -+ -+ return ent; -+} -+ - struct mdstat_ent *mdstat_by_subdev(char *subdev, char *container) - { - struct mdstat_ent *mdstat = mdstat_read(0, 0); - struct mdstat_ent *ent = NULL; - -- while (mdstat) { -+ for (ent = mdstat; ent; ent = ent->next) { - /* metadata version must match: - * external:[/-]%s/%s - * where first %s is 'container' and second %s is 'subdev' - */ -- if (ent) -- free_mdstat(ent); -- ent = mdstat; -- mdstat = mdstat->next; -- ent->next = NULL; - -- if (ent->metadata_version == NULL || -- strncmp(ent->metadata_version, "external:", 9) != 0) -+ if (!is_mdstat_ent_external(ent)) - continue; - -- if (!metadata_container_matches(ent->metadata_version+9, -- container) || -- !metadata_subdev_matches(ent->metadata_version+9, -- subdev)) -+ if (!metadata_container_matches(ent->metadata_version + 9, container)) -+ continue; -+ if (!metadata_subdev_matches(ent->metadata_version + 9, subdev)) - continue; - -- free_mdstat(mdstat); -- return ent; -+ break; - } -- return NULL; -+ -+ if (ent) -+ mdstat_ent_list_detach_element(&mdstat, ent); -+ -+ free_mdstat(mdstat); -+ return ent; - } -diff --git a/super-intel.c b/super-intel.c -index 713bfccf..c215b910 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -6974,13 +6974,11 @@ active_arrays_by_format(char *name, char* hba, struct md_list **devlist, - int found; - - for (memb = mdstat ; memb ; memb = memb->next) { -- if (memb->metadata_version && -- (strncmp(memb->metadata_version, "external:", 9) == 0) && -- (strcmp(&memb->metadata_version[9], name) == 0) && -- !is_subarray(memb->metadata_version+9) && -- memb->members) { -+ if (is_mdstat_ent_external(memb) && !is_subarray(memb->metadata_version + 9) && -+ strcmp(&memb->metadata_version[9], name) == 0 && memb->members) { - struct dev_member *dev = memb->members; - int fd = -1; -+ - while (dev && !is_fd_valid(fd)) { - char *path = xmalloc(strlen(dev->name) + strlen("/dev/") + 1); - num = snprintf(path, PATH_MAX, "%s%s", "/dev/", dev->name); -@@ -6998,7 +6996,6 @@ active_arrays_by_format(char *name, char* hba, struct md_list **devlist, - struct mdstat_ent *vol; - for (vol = mdstat ; vol ; vol = vol->next) { - if (vol->active > 0 && -- vol->metadata_version && - is_container_member(vol, memb->devnm)) { - found++; - count++; -diff --git a/util.c b/util.c -index 908f8430..83d42833 100644 ---- a/util.c -+++ b/util.c -@@ -1671,16 +1671,6 @@ int metadata_subdev_matches(char *metadata, char *devnm) - return 0; - } - --int is_container_member(struct mdstat_ent *mdstat, char *container) --{ -- if (mdstat->metadata_version == NULL || -- strncmp(mdstat->metadata_version, "external:", 9) != 0 || -- !metadata_container_matches(mdstat->metadata_version+9, container)) -- return 0; -- -- return 1; --} -- - int is_subarray_active(char *subarray, char *container) - { - struct mdstat_ent *mdstat = mdstat_read(0, 0); --- -2.41.0 - diff --git a/0134-mdadm-managemon.c-fix-coverity-issues.patch b/0134-mdadm-managemon.c-fix-coverity-issues.patch deleted file mode 100644 index daa2b66..0000000 --- a/0134-mdadm-managemon.c-fix-coverity-issues.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 2a4c40766d654dcbf5911d1b7b63bbbe8b2c0128 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Wed, 24 Jul 2024 09:04:08 -0400 -Subject: [PATCH 134/157] mdadm: managemon.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Event check_return: Calling "fcntl(fd, 4, fl)" without checking -return value. This library function may fail and return an error code. - -* Event check_after_deref: Null-checking "new" suggests that it may -be null, but it has already been dereferenced on all paths leading -to the check. - -Signed-off-by: Nigel Croxon ---- - managemon.c | 15 ++++++++++----- - 1 file changed, 10 insertions(+), 5 deletions(-) - -diff --git a/managemon.c b/managemon.c -index 358459e7..add6a79e 100644 ---- a/managemon.c -+++ b/managemon.c -@@ -776,10 +776,8 @@ static void manage_new(struct mdstat_ent *mdstat, - - error: - pr_err("failed to monitor %s\n", mdstat->metadata_version); -- if (new) { -- new->container = NULL; -- free_aa(new); -- } -+ new->container = NULL; -+ free_aa(new); - if (mdi) - sysfs_free(mdi); - } -@@ -870,8 +868,15 @@ void read_sock(struct supertype *container) - return; - - fl = fcntl(fd, F_GETFL, 0); -+ if (fl < 0) { -+ close_fd(&fd); -+ return; -+ } - fl |= O_NONBLOCK; -- fcntl(fd, F_SETFL, fl); -+ if (fcntl(fd, F_SETFL, fl) < 0) { -+ close_fd(&fd); -+ return; -+ } - - do { - msg.buf = NULL; --- -2.41.0 - diff --git a/0135-mdadm-msg.c-fix-coverity-issues.patch b/0135-mdadm-msg.c-fix-coverity-issues.patch deleted file mode 100644 index b34933f..0000000 --- a/0135-mdadm-msg.c-fix-coverity-issues.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 87f96c870399cd029933a9742ba72e85e3251c3e Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Wed, 24 Jul 2024 09:20:28 -0400 -Subject: [PATCH 135/157] mdadm: msg.c fix coverity issues - -Fixing the following coding errors the coverity tools found: - -* Event check_return: Calling "fcntl(sfd, 4, fl)" without -checking return value. This library function may fail and -return an error code. - -Signed-off-by: Nigel Croxon ---- - msg.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/msg.c b/msg.c -index f0772b3f..b6da91d3 100644 ---- a/msg.c -+++ b/msg.c -@@ -176,8 +176,15 @@ int connect_monitor(char *devname) - } - - fl = fcntl(sfd, F_GETFL, 0); -+ if (fl < 0) { -+ close(sfd); -+ return -1; -+ } - fl |= O_NONBLOCK; -- fcntl(sfd, F_SETFL, fl); -+ if (fcntl(sfd, F_SETFL, fl) < 0) { -+ close(sfd); -+ return -1; -+ } - - return sfd; - } --- -2.41.0 - diff --git a/0136-imsm-refactor-chunk-size-print.patch b/0136-imsm-refactor-chunk-size-print.patch deleted file mode 100644 index 292994d..0000000 --- a/0136-imsm-refactor-chunk-size-print.patch +++ /dev/null @@ -1,150 +0,0 @@ -From a944180a7e6a7d6d4cd08f6afcb83e58986c35f9 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 24 Jul 2024 22:17:42 +0200 -Subject: [PATCH 136/157] imsm: refactor chunk size print - -- add imsm_chunk_ops struct for better code readability, -- move chunk size mapping to string into array, -- add function to print supported chunk sizes by IMSM controller. - -Signed-off-by: Blazej Kucman ---- - super-intel.c | 92 +++++++++++++++++++++++++++------------------------ - 1 file changed, 49 insertions(+), 43 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index c215b910..ab9b5d3f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -647,6 +647,31 @@ static const char *_sys_dev_type[] = { - [SYS_DEV_SATA_VMD] = "SATA VMD" - }; - -+struct imsm_chunk_ops { -+ uint chunk; -+ char *chunk_str; -+}; -+ -+static const struct imsm_chunk_ops imsm_chunk_ops[] = { -+ {IMSM_OROM_SSS_2kB, "2k"}, -+ {IMSM_OROM_SSS_4kB, "4k"}, -+ {IMSM_OROM_SSS_8kB, "8k"}, -+ {IMSM_OROM_SSS_16kB, "16k"}, -+ {IMSM_OROM_SSS_32kB, "32k"}, -+ {IMSM_OROM_SSS_64kB, "64k"}, -+ {IMSM_OROM_SSS_128kB, "128k"}, -+ {IMSM_OROM_SSS_256kB, "256k"}, -+ {IMSM_OROM_SSS_512kB, "512k"}, -+ {IMSM_OROM_SSS_1MB, "1M"}, -+ {IMSM_OROM_SSS_2MB, "2M"}, -+ {IMSM_OROM_SSS_4MB, "4M"}, -+ {IMSM_OROM_SSS_8MB, "8M"}, -+ {IMSM_OROM_SSS_16MB, "16M"}, -+ {IMSM_OROM_SSS_32MB, "32M"}, -+ {IMSM_OROM_SSS_64MB, "64M"}, -+ {0, NULL} -+}; -+ - static int no_platform = -1; - - static int check_no_platform(void) -@@ -2626,6 +2651,16 @@ static void print_imsm_level_capability(const struct imsm_orom *orom) - printf("%s ", imsm_level_ops[idx].name); - } - -+static void print_imsm_chunk_size_capability(const struct imsm_orom *orom) -+{ -+ int idx; -+ -+ for (idx = 0; imsm_chunk_ops[idx].chunk_str; idx++) -+ if (imsm_chunk_ops[idx].chunk & orom->sss) -+ printf("%s ", imsm_chunk_ops[idx].chunk_str); -+} -+ -+ - static void print_imsm_capability(const struct imsm_orom *orom) - { - printf(" Platform : Intel(R) "); -@@ -2638,41 +2673,25 @@ static void print_imsm_capability(const struct imsm_orom *orom) - 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); -+ printf(" Version : %d.%d\n", orom->major_ver, orom->minor_ver); - else -- printf(" Version : %d.%d.%d.%d\n", orom->major_ver, -- orom->minor_ver, orom->hotfix_ver, orom->build); -+ printf(" Version : %d.%d.%d.%d\n", orom->major_ver, orom->minor_ver, -+ orom->hotfix_ver, orom->build); - } - - printf(" RAID Levels : "); - print_imsm_level_capability(orom); - printf("\n"); - -- printf(" Chunk Sizes :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", -- imsm_orom_has_chunk(orom, 2) ? " 2k" : "", -- imsm_orom_has_chunk(orom, 4) ? " 4k" : "", -- imsm_orom_has_chunk(orom, 8) ? " 8k" : "", -- imsm_orom_has_chunk(orom, 16) ? " 16k" : "", -- imsm_orom_has_chunk(orom, 32) ? " 32k" : "", -- imsm_orom_has_chunk(orom, 64) ? " 64k" : "", -- imsm_orom_has_chunk(orom, 128) ? " 128k" : "", -- imsm_orom_has_chunk(orom, 256) ? " 256k" : "", -- imsm_orom_has_chunk(orom, 512) ? " 512k" : "", -- imsm_orom_has_chunk(orom, 1024*1) ? " 1M" : "", -- imsm_orom_has_chunk(orom, 1024*2) ? " 2M" : "", -- imsm_orom_has_chunk(orom, 1024*4) ? " 4M" : "", -- imsm_orom_has_chunk(orom, 1024*8) ? " 8M" : "", -- imsm_orom_has_chunk(orom, 1024*16) ? " 16M" : "", -- imsm_orom_has_chunk(orom, 1024*32) ? " 32M" : "", -- imsm_orom_has_chunk(orom, 1024*64) ? " 64M" : ""); -- printf(" 2TB volumes :%s supported\n", -- (orom->attr & IMSM_OROM_ATTR_2TB)?"":" not"); -+ printf(" Chunk Sizes : "); -+ print_imsm_chunk_size_capability(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"); -+ (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, -+ printf(" Max Volumes : %d per array, %d per %s\n", orom->vpa, orom->vphba, - imsm_orom_is_nvme(orom) ? "platform" : "controller"); - return; - } -@@ -2688,23 +2707,10 @@ static void print_imsm_capability_export(const struct imsm_orom *orom) - print_imsm_level_capability(orom); - printf("\n"); - -- printf("IMSM_SUPPORTED_CHUNK_SIZES=%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", -- imsm_orom_has_chunk(orom, 2) ? "2k " : "", -- imsm_orom_has_chunk(orom, 4) ? "4k " : "", -- imsm_orom_has_chunk(orom, 8) ? "8k " : "", -- imsm_orom_has_chunk(orom, 16) ? "16k " : "", -- imsm_orom_has_chunk(orom, 32) ? "32k " : "", -- imsm_orom_has_chunk(orom, 64) ? "64k " : "", -- imsm_orom_has_chunk(orom, 128) ? "128k " : "", -- imsm_orom_has_chunk(orom, 256) ? "256k " : "", -- imsm_orom_has_chunk(orom, 512) ? "512k " : "", -- imsm_orom_has_chunk(orom, 1024*1) ? "1M " : "", -- imsm_orom_has_chunk(orom, 1024*2) ? "2M " : "", -- imsm_orom_has_chunk(orom, 1024*4) ? "4M " : "", -- imsm_orom_has_chunk(orom, 1024*8) ? "8M " : "", -- imsm_orom_has_chunk(orom, 1024*16) ? "16M " : "", -- imsm_orom_has_chunk(orom, 1024*32) ? "32M " : "", -- imsm_orom_has_chunk(orom, 1024*64) ? "64M " : ""); -+ printf("IMSM_SUPPORTED_CHUNK_SIZES="); -+ print_imsm_chunk_size_capability(orom); -+ printf("\n"); -+ - printf("IMSM_2TB_VOLUMES=%s\n",(orom->attr & IMSM_OROM_ATTR_2TB) ? "yes" : "no"); - printf("IMSM_2TB_DISKS=%s\n",(orom->attr & IMSM_OROM_ATTR_2TB_DISK) ? "yes" : "no"); - printf("IMSM_MAX_DISKS=%d\n",orom->tds); --- -2.41.0 - diff --git a/0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch b/0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch deleted file mode 100644 index 2992b16..0000000 --- a/0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch +++ /dev/null @@ -1,109 +0,0 @@ -From e0373b734db511cdfec248ff6d769270ec8fd492 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:03 +0800 -Subject: [PATCH 137/157] mdadm/Grow: fix coverity issue CHECKED_RETURN - -It needs to check return value when functions have return value. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 43 ++++++++++++++++++++++++++++++++++++------- - 1 file changed, 36 insertions(+), 7 deletions(-) - -diff --git a/Grow.c b/Grow.c -index b135930d..7ae967bd 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -3261,7 +3261,12 @@ static int reshape_array(char *container, int fd, char *devname, - /* This is a spare that wants to - * be part of the array. - */ -- add_disk(fd, st, info2, d); -+ if (add_disk(fd, st, info2, d) < 0) { -+ pr_err("Can not add disk %s\n", -+ d->sys_name); -+ free(info2); -+ goto release; -+ } - } - } - sysfs_free(info2); -@@ -4413,7 +4418,10 @@ static void validate(int afd, int bfd, unsigned long long offset) - */ - if (afd < 0) - return; -- lseek64(bfd, offset - 4096, 0); -+ if (lseek64(bfd, offset - 4096, 0) < 0) { -+ pr_err("lseek64 fails %d:%s\n", errno, strerror(errno)); -+ return; -+ } - if (read(bfd, &bsb2, 512) != 512) - fail("cannot read bsb"); - if (bsb2.sb_csum != bsb_csum((char*)&bsb2, -@@ -4444,12 +4452,19 @@ static void validate(int afd, int bfd, unsigned long long offset) - } - } - -- lseek64(bfd, offset, 0); -+ if (lseek64(bfd, offset, 0) < 0) { -+ pr_err("lseek64 fails %d:%s\n", errno, strerror(errno)); -+ goto out; -+ } - if ((unsigned long long)read(bfd, bbuf, len) != len) { - //printf("len %llu\n", len); - fail("read first backup failed"); - } -- lseek64(afd, __le64_to_cpu(bsb2.arraystart)*512, 0); -+ -+ if (lseek64(afd, __le64_to_cpu(bsb2.arraystart)*512, 0) < 0) { -+ pr_err("lseek64 fails %d:%s\n", errno, strerror(errno)); -+ goto out; -+ } - if ((unsigned long long)read(afd, abuf, len) != len) - fail("read first from array failed"); - if (memcmp(bbuf, abuf, len) != 0) -@@ -4466,15 +4481,25 @@ static void validate(int afd, int bfd, unsigned long long offset) - bbuf = xmalloc(abuflen); - } - -- lseek64(bfd, offset+__le64_to_cpu(bsb2.devstart2)*512, 0); -+ if (lseek64(bfd, offset+__le64_to_cpu(bsb2.devstart2)*512, 0) < 0) { -+ pr_err("lseek64 fails %d:%s\n", errno, strerror(errno)); -+ goto out; -+ } - if ((unsigned long long)read(bfd, bbuf, len) != len) - fail("read second backup failed"); -- lseek64(afd, __le64_to_cpu(bsb2.arraystart2)*512, 0); -+ if (lseek64(afd, __le64_to_cpu(bsb2.arraystart2)*512, 0) < 0) { -+ pr_err("lseek64 fails %d:%s\n", errno, strerror(errno)); -+ goto out; -+ } - if ((unsigned long long)read(afd, abuf, len) != len) - fail("read second from array failed"); - if (memcmp(bbuf, abuf, len) != 0) - fail("data2 compare failed"); - } -+out: -+ free(abuf); -+ free(bbuf); -+ return; - } - - int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape, -@@ -5033,7 +5058,11 @@ int Grow_continue_command(char *devname, int fd, struct context *c) - goto Grow_continue_command_exit; - } - content = &array; -- sysfs_init(content, fd, NULL); -+ if (sysfs_init(content, fd, NULL) < 0) { -+ pr_err("sysfs_init fails\n"); -+ ret_val = 1; -+ goto Grow_continue_command_exit; -+ } - /* Need to load a superblock. - * FIXME we should really get what we need from - * sysfs --- -2.41.0 - diff --git a/0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch b/0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch deleted file mode 100644 index a43344e..0000000 --- a/0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 54c09eaa8bc057dfd88ae20d259f88457f67fd1c Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:04 +0800 -Subject: [PATCH 138/157] mdadm/Grow: fix coverity issue RESOURCE_LEAK - -Fix some resource leak problems. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 42 +++++++++++++++++++++++++++++++----------- - 1 file changed, 31 insertions(+), 11 deletions(-) - -diff --git a/Grow.c b/Grow.c -index 7ae967bd..907a6e1b 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -530,8 +530,10 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) - pr_err("Cannot add bitmap while array is resyncing or reshaping etc.\n"); - pr_err("Cannot set bitmap file for %s: %s\n", - devname, strerror(err)); -+ close_fd(&bitmap_fd); - return 1; - } -+ close_fd(&bitmap_fd); - } - - return 0; -@@ -3083,6 +3085,7 @@ static int reshape_array(char *container, int fd, char *devname, - int done; - struct mdinfo *sra = NULL; - char buf[SYSFS_MAX_BUF_SIZE]; -+ bool located_backup = false; - - /* when reshaping a RAID0, the component_size might be zero. - * So try to fix that up. -@@ -3165,8 +3168,10 @@ static int reshape_array(char *container, int fd, char *devname, - goto release; - } - -- if (!backup_file) -+ if (!backup_file) { - backup_file = locate_backup(sra->sys_name); -+ located_backup = true; -+ } - - goto started; - } -@@ -3612,15 +3617,13 @@ started: - mdstat_wait(30 - (delayed-1) * 25); - } while (delayed); - mdstat_close(); -- if (check_env("MDADM_GROW_VERIFY")) -- fd = open(devname, O_RDONLY | O_DIRECT); -- else -- fd = -1; - mlockall(MCL_FUTURE); - - if (signal_s(SIGTERM, catch_term) == SIG_ERR) - goto release; - -+ if (check_env("MDADM_GROW_VERIFY")) -+ fd = open(devname, O_RDONLY | O_DIRECT); - if (st->ss->external) { - /* metadata handler takes it from here */ - done = st->ss->manage_reshape( -@@ -3632,6 +3635,7 @@ started: - fd, sra, &reshape, st, blocks, fdlist, offsets, - d - odisks, fdlist + odisks, offsets + odisks); - -+ close_fd(&fd); - free(fdlist); - free(offsets); - -@@ -3701,6 +3705,8 @@ out: - exit(0); - - release: -+ if (located_backup) -+ free(backup_file); - free(fdlist); - free(offsets); - if (orig_level != UnSet && sra) { -@@ -3839,6 +3845,7 @@ int reshape_container(char *container, char *devname, - pr_err("Unable to initialize sysfs for %s\n", - mdstat->devnm); - rv = 1; -+ close_fd(&fd); - break; - } - -@@ -4717,6 +4724,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, - unsigned long long *offsets; - unsigned long long nstripe, ostripe; - int ndata, odata; -+ int fd, backup_fd = -1; - - odata = info->array.raid_disks - info->delta_disks - 1; - if (info->array.level == 6) -@@ -4732,9 +4740,18 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, - * been used - */ - old_disks = cnt; -+ -+ if (backup_file) { -+ backup_fd = open(backup_file, O_RDONLY); -+ if (!is_fd_valid(backup_fd)) { -+ pr_err("Can't open backup file %s : %s\n", -+ backup_file, strerror(errno)); -+ return -EINVAL; -+ } -+ } -+ - for (i=old_disks-(backup_file?1:0); iss->store_super(st, fdlist[j]); - st->ss->free_super(st); - } -+ close_fd(&backup_fd); - return 0; - } -+ -+ close_fd(&backup_fd); -+ - /* Didn't find any backup data, try to see if any - * was needed. - */ --- -2.41.0 - diff --git a/0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch b/0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch deleted file mode 100644 index d5bf8e3..0000000 --- a/0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 13c1f4a56b3bedbf802d66e86afd787e318e25fb Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:05 +0800 -Subject: [PATCH 139/157] mdadm/Grow: fix coverity issue STRING_OVERFLOW - -Fix string overflow problems in Grow.c - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - Grow.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Grow.c b/Grow.c -index 907a6e1b..a5f9027d 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -1694,7 +1694,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re) - /* Current RAID6 layout has a RAID5 - * equivalent - good - */ -- strcat(strcpy(layout, ls), "-6"); -+ snprintf(layout, 40, "%s-6", ls); - l = map_name(r6layout, layout); - if (l == UnSet) - return "Cannot find RAID6 layout to convert to"; --- -2.41.0 - diff --git a/0140-mdadm-Incremental-fix-coverity-issues.patch b/0140-mdadm-Incremental-fix-coverity-issues.patch deleted file mode 100644 index b308af6..0000000 --- a/0140-mdadm-Incremental-fix-coverity-issues.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 17c99bab3e2e3606961d7ecec62c29921b5d6660 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:06 +0800 -Subject: [PATCH 140/157] mdadm/Incremental: fix coverity issues. - -There are two issues PW.PARAMETER_HIDDEN (declaration hides -parameter 'devname') and INTEGER_OVERFLOW. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - Incremental.c | 20 ++++++++++---------- - 1 file changed, 10 insertions(+), 10 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index abc7721b..fc4e68ff 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -770,7 +770,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra, - replcnt++; - st->ss->free_super(st); - } -- if (max_journal_events >= max_events - 1) -+ if (max_events > 0 && max_journal_events >= max_events - 1) - bestinfo->journal_clean = 1; - - if (!avail) -@@ -1113,7 +1113,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - int fd = -1; - struct mdinfo info; - struct supertype *st2 = NULL; -- char *devname = NULL; -+ char *dev_path_name = NULL; - unsigned long long devsectors; - char *pathlist[2]; - -@@ -1142,14 +1142,14 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - domain_free(domlist); - domlist = NULL; - -- if (asprintf(&devname, "/dev/disk/by-path/%s", de->d_name) != 1) { -- devname = NULL; -+ if (asprintf(&dev_path_name, "/dev/disk/by-path/%s", de->d_name) != 1) { -+ dev_path_name = NULL; - goto next; - } -- fd = open(devname, O_RDONLY); -+ fd = open(dev_path_name, O_RDONLY); - if (fd < 0) - goto next; -- if (get_dev_size(fd, devname, &devsectors) == 0) -+ if (get_dev_size(fd, dev_path_name, &devsectors) == 0) - goto next; - devsectors >>= 9; - -@@ -1188,8 +1188,8 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - if (chosen == NULL || chosen_size < info.component_size) { - chosen_size = info.component_size; - free(chosen); -- chosen = devname; -- devname = NULL; -+ chosen = dev_path_name; -+ dev_path_name = NULL; - if (chosen_st) { - chosen_st->ss->free_super(chosen_st); - free(chosen_st); -@@ -1199,7 +1199,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - } - - next: -- free(devname); -+ free(dev_path_name); - domain_free(domlist); - dev_policy_free(pol2); - if (st2) -@@ -1246,7 +1246,7 @@ static int is_bare(int dfd) - - /* OK, first 4K appear blank, try the end. */ - get_dev_size(dfd, NULL, &size); -- if (lseek(dfd, size-4096, SEEK_SET) < 0 || -+ if ((size >= 4096 && lseek(dfd, size-4096, SEEK_SET) < 0) || - read(dfd, buf, 4096) != 4096) - return 0; - --- -2.41.0 - diff --git a/0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch b/0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch deleted file mode 100644 index efc7c9d..0000000 --- a/0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch +++ /dev/null @@ -1,46 +0,0 @@ -From f9949a04355f0fca29c6bc02ead8425e76daa573 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:07 +0800 -Subject: [PATCH 141/157] mdadm/mdmon: fix coverity issue CHECKED_RETURN - -It needs to check return values when functions have return value. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - mdmon.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/mdmon.c b/mdmon.c -index 95e350f4..cae63841 100644 ---- a/mdmon.c -+++ b/mdmon.c -@@ -198,8 +198,12 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock) - /* Wait for monitor to exit by reading from the socket, after - * clearing the non-blocking flag */ - fl = fcntl(sock, F_GETFL, 0); -+ if (fl < 0) -+ return; -+ - fl &= ~O_NONBLOCK; -- fcntl(sock, F_SETFL, fl); -+ if (fcntl(sock, F_SETFL, fl) < 0) -+ return; - n = read(sock, buf, 100); - - /* If there is I/O going on it might took some time to get to -@@ -249,7 +253,10 @@ static int make_control_sock(char *devname) - listen(sfd, 10); - fl = fcntl(sfd, F_GETFL, 0); - fl |= O_NONBLOCK; -- fcntl(sfd, F_SETFL, fl); -+ if (fcntl(sfd, F_SETFL, fl) < 0) { -+ close_fd(&sfd); -+ return -1; -+ } - return sfd; - } - --- -2.41.0 - diff --git a/0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch b/0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch deleted file mode 100644 index 38ae3d5..0000000 --- a/0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch +++ /dev/null @@ -1,49 +0,0 @@ -From e7623d5ae4724c72e873e8af17f2ed6bfdc54427 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:08 +0800 -Subject: [PATCH 142/157] mdadm/mdmon: fix coverity issue RESOURCE_LEAK - -Fix resource leak problem in mdmon.c - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - mdmon.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/mdmon.c b/mdmon.c -index cae63841..6e28b56e 100644 ---- a/mdmon.c -+++ b/mdmon.c -@@ -456,22 +456,25 @@ static int mdmon(char *devnm, int must_fork, int takeover) - if (must_fork) { - if (pipe(pfd) != 0) { - pr_err("failed to create pipe\n"); -+ close_fd(&mdfd); - return 1; - } - switch(fork()) { - case -1: - pr_err("failed to fork: %s\n", strerror(errno)); -+ close_fd(&mdfd); - return 1; - case 0: /* child */ -- close(pfd[0]); -+ close_fd(&pfd[0]); - break; - default: /* parent */ -- close(pfd[1]); -+ close_fd(&pfd[1]); - if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) { - wait(&status); - status = WEXITSTATUS(status); - } -- close(pfd[0]); -+ close_fd(&pfd[0]); -+ close_fd(&mdfd); - return status; - } - } else --- -2.41.0 - diff --git a/0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch b/0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch deleted file mode 100644 index 5786c84..0000000 --- a/0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch +++ /dev/null @@ -1,33 +0,0 @@ -From f34040081c36ff92180674b89c39ddc7bdd47288 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:09 +0800 -Subject: [PATCH 143/157] mdadm/mdopen: fix coverity issue CHECKED_RETURN - -It needs to check return values when functions return value. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - mdopen.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/mdopen.c b/mdopen.c -index eaa59b59..c9fda131 100644 ---- a/mdopen.c -+++ b/mdopen.c -@@ -406,7 +406,11 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, - perror("chown"); - if (chmod(devname, ci->mode)) - perror("chmod"); -- stat(devname, &stb); -+ if (stat(devname, &stb) < 0) { -+ pr_err("failed to stat %s\n", -+ devname); -+ return -1; -+ } - add_dev(devname, &stb, 0, NULL); - } - if (use_mdp == 1) --- -2.41.0 - diff --git a/0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch b/0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch deleted file mode 100644 index 7e3e410..0000000 --- a/0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch +++ /dev/null @@ -1,29 +0,0 @@ -From debf421db02c85f176b5eda2e8dcc9d17d89623c Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:10 +0800 -Subject: [PATCH 144/157] mdadm/mdopen: fix coverity issue STRING_OVERFLOW - -Fix string overflow problems in mdopen.c - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - mdopen.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/mdopen.c b/mdopen.c -index c9fda131..e49defb6 100644 ---- a/mdopen.c -+++ b/mdopen.c -@@ -376,7 +376,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, - - sprintf(devname, "/dev/%s", devnm); - -- if (dev && dev[0] == '/') -+ if (dev && dev[0] == '/' && strlen(dev) < 400) - strcpy(chosen, dev); - else if (cname[0] == 0) - strcpy(chosen, devname); --- -2.41.0 - diff --git a/0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch b/0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch deleted file mode 100644 index fd7f863..0000000 --- a/0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 6984814b6fd879efae178acb057c1025aa4c64e8 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:11 +0800 -Subject: [PATCH 145/157] mdadm/mdstat: fix coverity issue CHECKED_RETURN - -It needs to check return values when functions return value. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - mdstat.c | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/mdstat.c b/mdstat.c -index cbbace3d..a971a957 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -194,8 +194,11 @@ struct mdstat_ent *mdstat_read(int hold, int start) - f = fopen("/proc/mdstat", "r"); - if (f == NULL) - return NULL; -- else -- fcntl(fileno(f), F_SETFD, FD_CLOEXEC); -+ -+ if (fcntl(fileno(f), F_SETFD, FD_CLOEXEC) < 0) { -+ fclose(f); -+ return NULL; -+ } - - all = NULL; - end = &all; -@@ -329,7 +332,10 @@ struct mdstat_ent *mdstat_read(int hold, int start) - } - if (hold && mdstat_fd == -1) { - mdstat_fd = dup(fileno(f)); -- fcntl(mdstat_fd, F_SETFD, FD_CLOEXEC); -+ if (fcntl(mdstat_fd, F_SETFD, FD_CLOEXEC) < 0) { -+ fclose(f); -+ return NULL; -+ } - } - fclose(f); - --- -2.41.0 - diff --git a/0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch b/0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch deleted file mode 100644 index b10b123..0000000 --- a/0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch +++ /dev/null @@ -1,56 +0,0 @@ -From e055d9236a7d0dca2a311e8bb8013018dc571d6a Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:12 +0800 -Subject: [PATCH 146/157] mdadm/super0: fix coverity issue CHECKED_RETURN and - EVALUATION_ORDER - -Fix coverity problems in super0. It needs to check return value when -functions return value. And fix EVALUATION_ORDER problems in super0.c - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - super0.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/super0.c b/super0.c -index 9b4e187e..c428e2a6 100644 ---- a/super0.c -+++ b/super0.c -@@ -83,6 +83,9 @@ static void examine_super0(struct supertype *st, char *homehost) - int d; - int delta_extra = 0; - char *c; -+ unsigned long expected_csum = 0; -+ -+ expected_csum = calc_sb0_csum(sb); - - printf(" Magic : %08x\n", sb->md_magic); - printf(" Version : %d.%02d.%02d\n", -@@ -187,11 +190,11 @@ static void examine_super0(struct supertype *st, char *homehost) - printf("Working Devices : %d\n", sb->working_disks); - printf(" Failed Devices : %d\n", sb->failed_disks); - printf(" Spare Devices : %d\n", sb->spare_disks); -- if (calc_sb0_csum(sb) == sb->sb_csum) -+ if (expected_csum == sb->sb_csum) - printf(" Checksum : %x - correct\n", sb->sb_csum); - else - printf(" Checksum : %x - expected %lx\n", -- sb->sb_csum, calc_sb0_csum(sb)); -+ sb->sb_csum, expected_csum); - printf(" Events : %llu\n", - ((unsigned long long)sb->events_hi << 32) + sb->events_lo); - printf("\n"); -@@ -1212,7 +1215,8 @@ static int locate_bitmap0(struct supertype *st, int fd, int node_num) - - offset += MD_SB_BYTES; - -- lseek64(fd, offset, 0); -+ if (lseek64(fd, offset, 0) < 0) -+ return -1; - return 0; - } - --- -2.41.0 - diff --git a/0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch b/0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch deleted file mode 100644 index e99adc0..0000000 --- a/0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch +++ /dev/null @@ -1,67 +0,0 @@ -From eb9834599c8c9764bb3e711b6f291b10797eff27 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:13 +0800 -Subject: [PATCH 147/157] mdadm/super1: fix coverity issue CHECKED_RETURN - -It needs to check return value when functions return value. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - super1.c | 20 ++++++++++++++++---- - 1 file changed, 16 insertions(+), 4 deletions(-) - -diff --git a/super1.c b/super1.c -index 81d29a65..4e4c7bfd 100644 ---- a/super1.c -+++ b/super1.c -@@ -260,7 +260,10 @@ static int aread(struct align_fd *afd, void *buf, int len) - n = read(afd->fd, b, iosize); - if (n <= 0) - return n; -- lseek(afd->fd, len - n, 1); -+ if (lseek(afd->fd, len - n, 1) < 0) { -+ pr_err("lseek fails\n"); -+ return -1; -+ } - if (n > len) - n = len; - memcpy(buf, b, n); -@@ -294,14 +297,20 @@ static int awrite(struct align_fd *afd, void *buf, int len) - n = read(afd->fd, b, iosize); - if (n <= 0) - return n; -- lseek(afd->fd, -n, 1); -+ if (lseek(afd->fd, -n, 1) < 0) { -+ pr_err("lseek fails\n"); -+ return -1; -+ } - } - - memcpy(b, buf, len); - n = write(afd->fd, b, iosize); - if (n <= 0) - return n; -- lseek(afd->fd, len - n, 1); -+ if (lseek(afd->fd, len - n, 1) < 0) { -+ pr_err("lseek fails\n"); -+ return -1; -+ } - return len; - } - -@@ -2667,7 +2676,10 @@ static int locate_bitmap1(struct supertype *st, int fd, int node_num) - } - if (mustfree) - free(sb); -- lseek64(fd, offset<<9, 0); -+ if (lseek64(fd, offset<<9, 0) < 0) { -+ pr_err("lseek fails\n"); -+ ret = -1; -+ } - return ret; - } - --- -2.41.0 - diff --git a/0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch b/0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch deleted file mode 100644 index 4d8df9f..0000000 --- a/0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 7904dc1c576a742c601c40dab4d0a6e562c4d00c Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:14 +0800 -Subject: [PATCH 148/157] mdadm/super1: fix coverity issue DEADCODE - -optimal_space is at most 2046. So space can't be larger than UINT16_MAX. - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - super1.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/super1.c b/super1.c -index 4e4c7bfd..24bc1026 100644 ---- a/super1.c -+++ b/super1.c -@@ -1466,8 +1466,6 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - __le32_to_cpu(sb->chunksize)); - if (space > optimal_space) - space = optimal_space; -- if (space > UINT16_MAX) -- space = UINT16_MAX; - } - - sb->ppl.offset = __cpu_to_le16(offset); --- -2.41.0 - diff --git a/0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch b/0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch deleted file mode 100644 index a8834ea..0000000 --- a/0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 38f712dba339bb9bd6a73cc7219d217871e7f27a Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:15 +0800 -Subject: [PATCH 149/157] mdadm/super1: fix coverity issue EVALUATION_ORDER - -Fix evaluation order problems in super1.c - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - super1.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/super1.c b/super1.c -index 24bc1026..243eeb1a 100644 ---- a/super1.c -+++ b/super1.c -@@ -340,6 +340,9 @@ static void examine_super1(struct supertype *st, char *homehost) - unsigned long long sb_offset; - struct mdinfo info; - int inconsistent = 0; -+ unsigned int expected_csum = 0; -+ -+ expected_csum = calc_sb_1_csum(sb); - - printf(" Magic : %08x\n", __le32_to_cpu(sb->magic)); - printf(" Version : 1"); -@@ -507,13 +510,13 @@ static void examine_super1(struct supertype *st, char *homehost) - printf("\n"); - } - -- if (calc_sb_1_csum(sb) == sb->sb_csum) -+ if (expected_csum == sb->sb_csum) - printf(" Checksum : %x - correct\n", - __le32_to_cpu(sb->sb_csum)); - else - printf(" Checksum : %x - expected %x\n", - __le32_to_cpu(sb->sb_csum), -- __le32_to_cpu(calc_sb_1_csum(sb))); -+ __le32_to_cpu(expected_csum)); - printf(" Events : %llu\n", - (unsigned long long)__le64_to_cpu(sb->events)); - printf("\n"); --- -2.41.0 - diff --git a/0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch b/0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch deleted file mode 100644 index e86d4b7..0000000 --- a/0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch +++ /dev/null @@ -1,41 +0,0 @@ -From ae2308ddf38b8f24a2b5e8e14e31153dfe608239 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 26 Jul 2024 15:14:16 +0800 -Subject: [PATCH 150/157] mdadm/super1: fix coverity issue RESOURCE_LEAK - -Fix resource leak problems in super1.c - -Signed-off-by: Xiao Ni -Signed-off-by: Mariusz Tkaczyk ---- - super1.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/super1.c b/super1.c -index 243eeb1a..9c9c7dd1 100644 ---- a/super1.c -+++ b/super1.c -@@ -923,10 +923,12 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname) - offset <<= 9; - if (lseek64(fd, offset, 0) < 0) { - pr_err("Cannot seek to bad-blocks list\n"); -+ free(bbl); - return 1; - } - if (read(fd, bbl, size) != size) { - pr_err("Cannot read bad-blocks list\n"); -+ free(bbl); - return 1; - } - /* 64bits per entry. 10 bits is block-count, 54 bits is block -@@ -947,6 +949,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname) - - printf("%20llu for %d sectors\n", sector, count); - } -+ free(bbl); - return 0; - } - --- -2.41.0 - diff --git a/0151-policy.c-Fix-check_return-issue-in-Write_rules.patch b/0151-policy.c-Fix-check_return-issue-in-Write_rules.patch deleted file mode 100644 index 25a5f46..0000000 --- a/0151-policy.c-Fix-check_return-issue-in-Write_rules.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 44c2a293260952fbb14db23d1ad07e6066641e0a Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -Date: Thu, 11 Jul 2024 14:31:57 +0200 -Subject: [PATCH 151/157] policy.c: Fix check_return issue in Write_rules() - -Refactor Write_rules() in policy.c to eliminate check_return issue found -by SAST analysis. Create udev rules file directly using rule_name -instead of creating temporary file and renaming it. - -Signed-off-by: Anna Sztukowska ---- - policy.c | 25 +++++++++---------------- - 1 file changed, 9 insertions(+), 16 deletions(-) - -diff --git a/policy.c b/policy.c -index dfaafdc0..4d4b248d 100644 ---- a/policy.c -+++ b/policy.c -@@ -969,19 +969,13 @@ int generate_entries(int fd) - */ - int Write_rules(char *rule_name) - { -- int fd; -- char udev_rule_file[PATH_MAX]; -+ int fd = fileno(stdout); - -- if (rule_name) { -- strncpy(udev_rule_file, rule_name, sizeof(udev_rule_file) - 6); -- udev_rule_file[sizeof(udev_rule_file) - 6] = '\0'; -- strcat(udev_rule_file, ".temp"); -- fd = creat(udev_rule_file, -- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); -- if (fd == -1) -- return 1; -- } else -- fd = 1; -+ if (rule_name) -+ fd = creat(rule_name, 0644); -+ -+ if (!is_fd_valid(fd)) -+ return 1; - - /* write static invocation */ - if (write(fd, udev_template_start, sizeof(udev_template_start) - 1) != -@@ -993,15 +987,14 @@ int Write_rules(char *rule_name) - goto abort; - - fsync(fd); -- if (rule_name) { -+ if (rule_name) - close(fd); -- rename(udev_rule_file, rule_name); -- } -+ - return 0; - abort: - if (rule_name) { - close(fd); -- unlink(udev_rule_file); -+ unlink(rule_name); - } - return 1; - } --- -2.41.0 - diff --git a/0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch b/0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch deleted file mode 100644 index b91cd90..0000000 --- a/0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 483ff037f1036f5f604e085cf76097a87e2be348 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -Date: Wed, 24 Jul 2024 11:46:57 +0200 -Subject: [PATCH 152/157] super-gpt.c: Fix check_return issue in load_gpt() - -Fix check_return issue in load_gpt() reported by SAST analysis in -super-gpt.c. - -Signed-off-by: Anna Sztukowska ---- - super-gpt.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/super-gpt.c b/super-gpt.c -index a1e9aa9d..ec3cf53f 100644 ---- a/super-gpt.c -+++ b/super-gpt.c -@@ -105,7 +105,8 @@ static int load_gpt(struct supertype *st, int fd, char *devname) - return 1; - } - /* Set offset to second block (GPT header) */ -- lseek(fd, sector_size, SEEK_SET); -+ if (lseek(fd, sector_size, SEEK_SET) == -1L) -+ goto no_read; - /* Seem to have GPT, load the header */ - gpt_head = (struct GPT*)(super+1); - if (read(fd, gpt_head, sizeof(*gpt_head)) != sizeof(*gpt_head)) -@@ -118,7 +119,8 @@ static int load_gpt(struct supertype *st, int fd, char *devname) - to_read = __le32_to_cpu(gpt_head->part_cnt) * sizeof(struct GPT_part_entry); - to_read = ((to_read+511)/512) * 512; - /* Set offset to third block (GPT entries) */ -- lseek(fd, sector_size*2, SEEK_SET); -+ if (lseek(fd, sector_size * 2, SEEK_SET) == -1L) -+ goto no_read; - if (read(fd, gpt_head+1, to_read) != to_read) - goto no_read; - --- -2.41.0 - diff --git a/0153-super-intel-fix-compilation-error.patch b/0153-super-intel-fix-compilation-error.patch deleted file mode 100644 index dc0cfe3..0000000 --- a/0153-super-intel-fix-compilation-error.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 734de8b02022bf3b7a5f2111f5314a87ddebcc83 Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Tue, 6 Aug 2024 11:14:02 +0200 -Subject: [PATCH 153/157] super-intel: fix compilation error -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Fix compilation error: - -super-intel.c: In function ‘end_migration’: -super-intel.c:4360:29: error: writing 2 bytes into a region - of size 0 [-Werror=stringop-overflow=] - 4360 | dev->vol.migr_state = 0; - | ~~~~~~~~~~~~~~~~~~~~^~~ -cc1: note: destination object is likely at address zero -cc1: all warnings being treated as errors -make: *** [Makefile:232: super-intel.o] Error 1 - -reported, when GCC 14 is used. Return when dev is NULL, to avoid it. - -Signed-off-by: Kinga Stefaniuk ---- - super-intel.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index ab9b5d3f..f6745e10 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -4330,6 +4330,12 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super, - static void end_migration(struct imsm_dev *dev, struct intel_super *super, - __u8 map_state) - { -+ /* To avoid compilation error, saying dev can't be NULL when -+ * migr_state is assigned. -+ */ -+ if (dev == NULL) -+ return; -+ - struct imsm_map *map = get_imsm_map(dev, MAP_0); - struct imsm_map *prev = get_imsm_map(dev, dev->vol.migr_state == 0 ? - MAP_0 : MAP_1); --- -2.41.0 - diff --git a/0154-super-intel-add-define-for-migr_state.patch b/0154-super-intel-add-define-for-migr_state.patch deleted file mode 100644 index fd3b049..0000000 --- a/0154-super-intel-add-define-for-migr_state.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 125217e0903ab0eb574d20c698c49b04e3b1a99c Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Wed, 31 Jul 2024 15:06:42 +0200 -Subject: [PATCH 154/157] super-intel: add define for migr_state - -Represent migr_state with the define, which helps in code readability. -Add new values for Normal and Migration states. - -Signed-off-by: Kinga Stefaniuk ---- - super-intel.c | 16 +++++++++------- - 1 file changed, 9 insertions(+), 7 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index f6745e10..354c292a 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -194,6 +194,8 @@ ASSERT_SIZE(imsm_map, 52) - struct imsm_vol { - __u32 curr_migr_unit_lo; - __u32 checkpoint_id; /* id to access curr_migr_unit */ -+#define MIGR_STATE_NORMAL 0 -+#define MIGR_STATE_MIGRATING 1 - __u8 migr_state; /* Normal or Migrating */ - #define MIGR_INIT 0 - #define MIGR_REBUILD 1 -@@ -4303,7 +4305,7 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super, - struct imsm_map *dest; - struct imsm_map *src = get_imsm_map(dev, MAP_0); - -- dev->vol.migr_state = 1; -+ dev->vol.migr_state = MIGR_STATE_MIGRATING; - set_migr_type(dev, migr_type); - set_vol_curr_migr_unit(dev, 0); - dest = get_imsm_map(dev, MAP_1); -@@ -4337,7 +4339,7 @@ static void end_migration(struct imsm_dev *dev, struct intel_super *super, - return; - - struct imsm_map *map = get_imsm_map(dev, MAP_0); -- struct imsm_map *prev = get_imsm_map(dev, dev->vol.migr_state == 0 ? -+ struct imsm_map *prev = get_imsm_map(dev, dev->vol.migr_state == MIGR_STATE_NORMAL ? - MAP_0 : MAP_1); - int i, j; - -@@ -4369,7 +4371,7 @@ static void end_migration(struct imsm_dev *dev, struct intel_super *super, - map_state = imsm_check_degraded(super, dev, failed, MAP_0); - } - -- dev->vol.migr_state = 0; -+ dev->vol.migr_state = MIGR_STATE_NORMAL; - set_migr_type(dev, 0); - set_vol_curr_migr_unit(dev, 0); - map->map_state = map_state; -@@ -4449,7 +4451,7 @@ int check_mpb_migr_compatibility(struct intel_super *super) - for (i = 0; i < super->anchor->num_raid_devs; i++) { - struct imsm_dev *dev_iter = __get_imsm_dev(super->anchor, i); - -- if (dev_iter->vol.migr_state == 1 && -+ if (dev_iter->vol.migr_state == MIGR_STATE_MIGRATING && - dev_iter->vol.migr_type == MIGR_GEN_MIGR) { - /* This device is migrating */ - map0 = get_imsm_map(dev_iter, MAP_0); -@@ -5654,7 +5656,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - set_imsm_dev_size(dev, array_blocks); - dev->status = (DEV_READ_COALESCING | DEV_WRITE_COALESCING); - vol = &dev->vol; -- vol->migr_state = 0; -+ vol->migr_state = MIGR_STATE_NORMAL; - set_migr_type(dev, MIGR_INIT); - vol->dirty = !info->state; - set_vol_curr_migr_unit(dev, 0); -@@ -8631,7 +8633,7 @@ static void imsm_progress_container_reshape(struct intel_super *super) - copy_map_size = sizeof_imsm_map(map); - prev_num_members = map->num_members; - map->num_members = prev_disks; -- dev->vol.migr_state = 1; -+ dev->vol.migr_state = MIGR_STATE_MIGRATING; - set_vol_curr_migr_unit(dev, 0); - set_migr_type(dev, MIGR_GEN_MIGR); - for (i = prev_num_members; -@@ -9863,7 +9865,7 @@ static int apply_reshape_container_disks_update(struct imsm_update_reshape *u, - dprintf("imsm: modifying subdev: %i\n", - id->index); - devices_to_reshape--; -- newdev->vol.migr_state = 1; -+ newdev->vol.migr_state = MIGR_STATE_MIGRATING; - set_vol_curr_migr_unit(newdev, 0); - set_migr_type(newdev, MIGR_GEN_MIGR); - newmap->num_members = u->new_raid_disks; --- -2.41.0 - diff --git a/0156-Grow_reshape-set-only-component_size-for-size-grow.patch b/0156-Grow_reshape-set-only-component_size-for-size-grow.patch deleted file mode 100644 index 575e984..0000000 --- a/0156-Grow_reshape-set-only-component_size-for-size-grow.patch +++ /dev/null @@ -1,52 +0,0 @@ -From c653054b322a03e8912ac05accc87b6a1ba8daab Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -Date: Fri, 26 Apr 2024 08:33:00 +0200 -Subject: [PATCH 156/157] Grow_reshape: set only component_size for size grow - -Component_size couldn't be set using ioctl when new drive size is big -(e.g. 5TB). Command value is bigger than 32 bits and error is reported -- it is known ioctl limitation. Remove updating array properties using -ioctl, use sysfs instead. Sysfs was introduced in 3.10, so now it is old -enough to be safely used. Array_size in sysfs should be set for every -size change for external metadata, when grow is performed without -errors. - -Signed-off-by: Kinga Stefaniuk ---- - Grow.c | 19 +++++++------------ - 1 file changed, 7 insertions(+), 12 deletions(-) - -diff --git a/Grow.c b/Grow.c -index a5f9027d..5810b128 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -2149,19 +2149,14 @@ int Grow_reshape(char *devname, int fd, - if (s->size == MAX_SIZE) - s->size = 0; - array.size = s->size; -- if (s->size & ~INT32_MAX) { -- /* got truncated to 32bit, write to -- * component_size instead -- */ -- rv = sysfs_set_num(sra, NULL, "component_size", s->size); -- } else { -- rv = md_set_array_info(fd, &array); -+ rv = sysfs_set_num(sra, NULL, "component_size", s->size); - -- /* manage array size when it is managed externally -- */ -- if ((rv == 0) && st->ss->external) -- rv = set_array_size(st, sra, sra->text_version); -- } -+ /* -+ * For native metadata, md/array_size is updated by kernel, -+ * for external management update it here. -+ */ -+ if (st->ss->external && rv == MDADM_STATUS_SUCCESS) -+ rv = set_array_size(st, sra, sra->text_version); - - if (raid0_takeover) { - /* do not recync non-existing parity, --- -2.41.0 - diff --git a/0157-mdstat-fix-list-detach-issues.patch b/0157-mdstat-fix-list-detach-issues.patch deleted file mode 100644 index e4c3618..0000000 --- a/0157-mdstat-fix-list-detach-issues.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 4b041873ff5556882bc6f17ac3de00c72eebcc4f Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 6 Aug 2024 16:11:18 +0200 -Subject: [PATCH 157/157] mdstat: fix list detach issues - -Move ent = ent->next; to while. It was outside the loop so if there -are more than 2 elements and we are looking for 3rd element it causes -infinite loop.. - -Fix el->next zeroing. It causes segfault in mdstat_free(). Theses -issues were not visible in my testing because I had only 2 MD devices. - -Fixes: 4b3644ab4ce6 ("mdstat: Rework mdstat external arrays handling") -Signed-off-by: Mariusz Tkaczyk ---- - mdstat.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/mdstat.c b/mdstat.c -index a971a957..29e78362 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -123,13 +123,15 @@ static void mdstat_ent_list_detach_element(struct mdstat_ent **list_head, struct - ent->next = el->next; - break; - } -+ -+ ent = ent->next; - } - -- ent = ent->next; - } - -+ /* Guard if not found or list is empty - not allowed */ - assert(ent); -- ent->next = NULL; -+ el->next = NULL; - } - - void free_mdstat(struct mdstat_ent *ms) --- -2.41.0 - diff --git a/0158-md.4-replace-wrong-word.patch b/0158-md.4-replace-wrong-word.patch deleted file mode 100644 index c510a3f..0000000 --- a/0158-md.4-replace-wrong-word.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 1f49ecbf3d2ab8003d37eb1c0454c5cfbe335ee5 Mon Sep 17 00:00:00 2001 -From: Nicolas Roeser -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 ---- - 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 - diff --git a/0159-mdadm-util.c-fix-coverity-issues.patch b/0159-mdadm-util.c-fix-coverity-issues.patch deleted file mode 100644 index b2bc66a..0000000 --- a/0159-mdadm-util.c-fix-coverity-issues.patch +++ /dev/null @@ -1,134 +0,0 @@ -From ea076e7c4bc8b3122ad9d7131098c4b85902a299 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -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 ---- - 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, §or_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 - diff --git a/0160-mdadm-sysfs.c-fix-coverity-issues.patch b/0160-mdadm-sysfs.c-fix-coverity-issues.patch deleted file mode 100644 index 03f3d39..0000000 --- a/0160-mdadm-sysfs.c-fix-coverity-issues.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 18eaf6c5206a37ad059c930d1ee2dbc9b7297513 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -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 ---- - 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 - diff --git a/0161-imsm-add-read-OROM-form-ACPI-UEFI-tables.patch b/0161-imsm-add-read-OROM-form-ACPI-UEFI-tables.patch deleted file mode 100644 index 586fa4c..0000000 --- a/0161-imsm-add-read-OROM-form-ACPI-UEFI-tables.patch +++ /dev/null @@ -1,405 +0,0 @@ -From 91845dab52c3f9ab56710338c0c38e9c1473df1d Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -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 ---- - 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 - diff --git a/0162-imsm-get-bus-from-VMD-driver-directory.patch b/0162-imsm-get-bus-from-VMD-driver-directory.patch deleted file mode 100644 index 3f34550..0000000 --- a/0162-imsm-get-bus-from-VMD-driver-directory.patch +++ /dev/null @@ -1,146 +0,0 @@ -From 6e793aeace463d7687656f7ac6968300ba106228 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0163-platform-intel-refactor-path_attached_to_hba.patch b/0163-platform-intel-refactor-path_attached_to_hba.patch deleted file mode 100644 index 038c16c..0000000 --- a/0163-platform-intel-refactor-path_attached_to_hba.patch +++ /dev/null @@ -1,129 +0,0 @@ -From a6392b419f38a0144a03df90371d6890540a55cf Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -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 ---- - 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 - diff --git a/0164-mdadm-Change-displaying-of-devices-in-detail.patch b/0164-mdadm-Change-displaying-of-devices-in-detail.patch deleted file mode 100644 index 02ba8d3..0000000 --- a/0164-mdadm-Change-displaying-of-devices-in-detail.patch +++ /dev/null @@ -1,44 +0,0 @@ -From bd5511c792ecc73de8897fbd8713e8c6eaf3e835 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - diff --git a/0165-imsm-Remove-warning-and-refactor-add_to_super_imsm-c.patch b/0165-imsm-Remove-warning-and-refactor-add_to_super_imsm-c.patch deleted file mode 100644 index 6501c61..0000000 --- a/0165-imsm-Remove-warning-and-refactor-add_to_super_imsm-c.patch +++ /dev/null @@ -1,196 +0,0 @@ -From 734e7db4dfc502044d2a3dacfab67aeab0081cf9 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0166-imsm-add-IMSM_OROM_CAPABILITIES_TPV-to-nvme-orom.patch b/0166-imsm-add-IMSM_OROM_CAPABILITIES_TPV-to-nvme-orom.patch deleted file mode 100644 index 3545f0b..0000000 --- a/0166-imsm-add-IMSM_OROM_CAPABILITIES_TPV-to-nvme-orom.patch +++ /dev/null @@ -1,192 +0,0 @@ -From b1d38b512aa3162b5089fbf6b02357ed5fdf5760 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0167-mdadm-Increase-number-limit-in-md-device-name-to-102.patch b/0167-mdadm-Increase-number-limit-in-md-device-name-to-102.patch deleted file mode 100644 index 9be51ba..0000000 --- a/0167-mdadm-Increase-number-limit-in-md-device-name-to-102.patch +++ /dev/null @@ -1,33 +0,0 @@ -From f786072a3e2928766a9b4f1b7d3372a601c259ea Mon Sep 17 00:00:00 2001 -From: Shminderjit Singh -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 ---- - 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 - diff --git a/0168-imsm-save-checkpoint-prior-to-exit.patch b/0168-imsm-save-checkpoint-prior-to-exit.patch deleted file mode 100644 index 01791e4..0000000 --- a/0168-imsm-save-checkpoint-prior-to-exit.patch +++ /dev/null @@ -1,44 +0,0 @@ -From dd0d193ad8722140e240c95a4fd1e214077dd719 Mon Sep 17 00:00:00 2001 -From: Mateusz Kusiak -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 ---- - 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 - diff --git a/0169-Examine.c-Fix-memory-leaks-in-Examine.patch b/0169-Examine.c-Fix-memory-leaks-in-Examine.patch deleted file mode 100644 index 826f343..0000000 --- a/0169-Examine.c-Fix-memory-leaks-in-Examine.patch +++ /dev/null @@ -1,116 +0,0 @@ -From da26064bfe4457d5037f3a1f1bb83a54225c6375 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - diff --git a/0170-dlink.h-Fix-checkpatch-warnings-for-function-args.patch b/0170-dlink.h-Fix-checkpatch-warnings-for-function-args.patch deleted file mode 100644 index 13038b1..0000000 --- a/0170-dlink.h-Fix-checkpatch-warnings-for-function-args.patch +++ /dev/null @@ -1,39 +0,0 @@ -From be1b4ff0957b287b2d8494967a7f0a1e3401dd8a Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - diff --git a/0171-Incremental-support-devnode-in-IncrementalRemove.patch b/0171-Incremental-support-devnode-in-IncrementalRemove.patch deleted file mode 100644 index c31cfb8..0000000 --- a/0171-Incremental-support-devnode-in-IncrementalRemove.patch +++ /dev/null @@ -1,151 +0,0 @@ -From 9b8933bb6dbfcae1bd5a2f933c87684de99412de Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 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 - diff --git a/0172-Detail.c-Fix-divide_by_zero-issue.patch b/0172-Detail.c-Fix-divide_by_zero-issue.patch deleted file mode 100644 index 59d92d8..0000000 --- a/0172-Detail.c-Fix-divide_by_zero-issue.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 7b65dd6d71dfff35847440e19d309990dfcb29d3 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - diff --git a/0173-mdadm-Add-compilation-process-to-README.md.patch b/0173-mdadm-Add-compilation-process-to-README.md.patch deleted file mode 100644 index cfb5064..0000000 --- a/0173-mdadm-Add-compilation-process-to-README.md.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 983e9226fb02a91692c2c55a19b5cd06d8ddd005 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - diff --git a/0174-mdadm-Grow-Update-new-level-when-starting-reshape.patch b/0174-mdadm-Grow-Update-new-level-when-starting-reshape.patch deleted file mode 100644 index 0541434..0000000 --- a/0174-mdadm-Grow-Update-new-level-when-starting-reshape.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 21212f6ad7c634f5f114f342ca84fe8c42a13f40 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0175-mdadm-Grow-Update-reshape_progress-to-need_back-afte.patch b/0175-mdadm-Grow-Update-reshape_progress-to-need_back-afte.patch deleted file mode 100644 index dc5a889..0000000 --- a/0175-mdadm-Grow-Update-reshape_progress-to-need_back-afte.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 568259859cafeefbf54354c19405cf2292da4b4a Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0176-mdadm-Grow-Can-t-open-raid-when-running-grow-continu.patch b/0176-mdadm-Grow-Can-t-open-raid-when-running-grow-continu.patch deleted file mode 100644 index ebe0d4a..0000000 --- a/0176-mdadm-Grow-Can-t-open-raid-when-running-grow-continu.patch +++ /dev/null @@ -1,38 +0,0 @@ -From cd94b9adf7d53457d86cdc39b983b18713f24032 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0177-mdadm-Grow-sleep-a-while-after-removing-disk-in-impo.patch b/0177-mdadm-Grow-sleep-a-while-after-removing-disk-in-impo.patch deleted file mode 100644 index 7e60aca..0000000 --- a/0177-mdadm-Grow-sleep-a-while-after-removing-disk-in-impo.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 166e5e2fc4b634df100ccc0010035f925bb2ad63 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0178-mdadm-tests-wait-until-level-changes.patch b/0178-mdadm-tests-wait-until-level-changes.patch deleted file mode 100644 index 3437de6..0000000 --- a/0178-mdadm-tests-wait-until-level-changes.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 098337f31de3f0683cd99727104c81db81fda9cd Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0179-mdadm-tests-07changelevels-fix.patch b/0179-mdadm-tests-07changelevels-fix.patch deleted file mode 100644 index 68805a4..0000000 --- a/0179-mdadm-tests-07changelevels-fix.patch +++ /dev/null @@ -1,179 +0,0 @@ -From f5b2dddd258084836634e169c84400e82825996c Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0180-mdadm-tests-Remove-07reshape5intr.broken.patch b/0180-mdadm-tests-Remove-07reshape5intr.broken.patch deleted file mode 100644 index 901ac9f..0000000 --- a/0180-mdadm-tests-Remove-07reshape5intr.broken.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 01f5aefd830d6ad5357de4d6f5ce139b415a62b9 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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: -- -- __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 - diff --git a/0181-mdadm-tests-07testreshape5-fix.patch b/0181-mdadm-tests-07testreshape5-fix.patch deleted file mode 100644 index fb4e2c4..0000000 --- a/0181-mdadm-tests-07testreshape5-fix.patch +++ /dev/null @@ -1,48 +0,0 @@ -From fe3e4809476ab4e2e0e905e36f6bb1a45c16a2c3 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0182-mdadm-tests-remove-09imsm-assemble.broken.patch b/0182-mdadm-tests-remove-09imsm-assemble.broken.patch deleted file mode 100644 index 1ded516..0000000 --- a/0182-mdadm-tests-remove-09imsm-assemble.broken.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 5cafbc8b3a7f352be80c5dc22d59d26b06f57680 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0183-mdadm-Manage-record-errno.patch b/0183-mdadm-Manage-record-errno.patch deleted file mode 100644 index f37f629..0000000 --- a/0183-mdadm-Manage-record-errno.patch +++ /dev/null @@ -1,56 +0,0 @@ -From e3c3cfb64b8ec8b616e2eefbc69fbc3de29b64b6 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0184-Remove-INSTALL-and-dev-null.patch b/0184-Remove-INSTALL-and-dev-null.patch deleted file mode 100644 index 551bd64..0000000 --- a/0184-Remove-INSTALL-and-dev-null.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 2c2a9d63d07102e54608ad7691072ebbed0f8be8 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0186-Incremental-Rename-IncrementalRemove.patch b/0186-Incremental-Rename-IncrementalRemove.patch deleted file mode 100644 index 0aa8bef..0000000 --- a/0186-Incremental-Rename-IncrementalRemove.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 60923d5cae78447902e9ec10c44504e0588cf447 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0187-sysfs-add-function-for-writing-to-sysfs-fd.patch b/0187-sysfs-add-function-for-writing-to-sysfs-fd.patch deleted file mode 100644 index 7740007..0000000 --- a/0187-sysfs-add-function-for-writing-to-sysfs-fd.patch +++ /dev/null @@ -1,315 +0,0 @@ -From d95edceb362a6b647ec454c2a83add11c4ed4e64 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0188-Mdmonitor-Fix-startup-with-missing-directory.patch b/0188-Mdmonitor-Fix-startup-with-missing-directory.patch deleted file mode 100644 index 4cc9e5e..0000000 --- a/0188-Mdmonitor-Fix-startup-with-missing-directory.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 344690313ae4e66f760b14afafda663ec750dfe0 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - diff --git a/0189-mdadm-add-xmalloc.h.patch b/0189-mdadm-add-xmalloc.h.patch deleted file mode 100644 index c0b8ca1..0000000 --- a/0189-mdadm-add-xmalloc.h.patch +++ /dev/null @@ -1,590 +0,0 @@ -From ee3a6cab09c8acaf6706b3710f5652e9be43b57e Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - - 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 - #include - #include -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 - #include - -diff --git a/Examine.c b/Examine.c -index fe162167..036b7a56 100644 ---- a/Examine.c -+++ b/Examine.c -@@ -22,14 +22,16 @@ - * Email: - */ - --#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 - #include - #include -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 - #include - #include -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 - - 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 - #include - #include -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 - #include - #include -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 - #include - -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 - #include - -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 - #include - -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 - - /** -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 - - 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 - #include - -diff --git a/msg.c b/msg.c -index b6da91d3..0cc7fc5d 100644 ---- a/msg.c -+++ b/msg.c -@@ -30,6 +30,7 @@ - #include - #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 - #include - #include -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 - #include - #include -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 - - /* 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 - #include - -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 - #include - #include -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 - #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 - #include --#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 - #include - #include -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 - #include - #include -diff --git a/xmalloc.c b/xmalloc.c -index 8b3f78a6..dac30eb6 100644 ---- a/xmalloc.c -+++ b/xmalloc.c -@@ -21,64 +21,57 @@ - * Email: - */ - --#include "mdadm.h" --/*#include --#include --#include --#include --#include --#include --#include --*/ -+#include "xmalloc.h" -+ -+#include -+#include -+#include -+#include -+ -+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 -+ -+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 - diff --git a/0190-md.man-update-refference-to-raid5-ppl.rst.patch b/0190-md.man-update-refference-to-raid5-ppl.rst.patch deleted file mode 100644 index 613570a..0000000 --- a/0190-md.man-update-refference-to-raid5-ppl.rst.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 4157e8da40ce976883c5b6e51e2352732e709b52 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0191-util-fix-sys_hot_remove_disk.patch b/0191-util-fix-sys_hot_remove_disk.patch deleted file mode 100644 index 70c389e..0000000 --- a/0191-util-fix-sys_hot_remove_disk.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 6f227de0a17369d3d6667591241c49140d5239b2 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0192-Rename-Monitor.c-to-mdmonitor.c.patch b/0192-Rename-Monitor.c-to-mdmonitor.c.patch deleted file mode 100644 index 1d4a5fd..0000000 --- a/0192-Rename-Monitor.c-to-mdmonitor.c.patch +++ /dev/null @@ -1,35 +0,0 @@ -From da826501c708b49a6e03394cf56f070160ea59d9 Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -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 ---- - 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 - diff --git a/0193-super-intel-move-scsi_get_serial-from-sg_io.patch b/0193-super-intel-move-scsi_get_serial-from-sg_io.patch deleted file mode 100644 index 5adf215..0000000 --- a/0193-super-intel-move-scsi_get_serial-from-sg_io.patch +++ /dev/null @@ -1,178 +0,0 @@ -From bafa5ccfa56d776d431f766c765178eda0a4900d Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -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 ---- - 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 --#include --#include --#include -- --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 --#include - #include - #include --#include "drive_encryption.h" -+#include -+#include -+#include -+#include -+#include - - /* 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 - diff --git a/0194-mdmonitor-Abandon-custom-configuration-files.patch b/0194-mdmonitor-Abandon-custom-configuration-files.patch deleted file mode 100644 index 4b598fb..0000000 --- a/0194-mdmonitor-Abandon-custom-configuration-files.patch +++ /dev/null @@ -1,120 +0,0 @@ -From a7a5e676a7eb2ac97acd31b13f75515e9573f891 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0195-mdadm.man-elaborate-more-about-mdmonitor.service.patch b/0195-mdadm.man-elaborate-more-about-mdmonitor.service.patch deleted file mode 100644 index 157cff4..0000000 --- a/0195-mdadm.man-elaborate-more-about-mdmonitor.service.patch +++ /dev/null @@ -1,131 +0,0 @@ -From 70f3a1bcb0ff3b740f986b5819931b93c8bed24d Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -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 ---- - 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 - diff --git a/0196-mdadm-Add-mdadm_status.h.patch b/0196-mdadm-Add-mdadm_status.h.patch deleted file mode 100644 index 6b5c0e2..0000000 --- a/0196-mdadm-Add-mdadm_status.h.patch +++ /dev/null @@ -1,85 +0,0 @@ -From f2f938b0b2755bb2c558eef87f5767beb2ff2ca1 Mon Sep 17 00:00:00 2001 -From: Anna Sztukowska -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 ---- - 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 - /* Redhat don't like to #include , 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 - #include -@@ -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 - diff --git a/0197-mdadm.conf.man-Explain-udev-rule.patch b/0197-mdadm.conf.man-Explain-udev-rule.patch deleted file mode 100644 index 2fd711e..0000000 --- a/0197-mdadm.conf.man-Explain-udev-rule.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 13378ba880c251aa65dac12a5d366230cb7ea039 Mon Sep 17 00:00:00 2001 -From: Andre Paiusco -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 ---- - 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\= -+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 - diff --git a/0198-mdadm.man-Add-udev-rules-flag.patch b/0198-mdadm.man-Add-udev-rules-flag.patch deleted file mode 100644 index a4ba75e..0000000 --- a/0198-mdadm.man-Add-udev-rules-flag.patch +++ /dev/null @@ -1,37 +0,0 @@ -From cb4acfa372a8d66703706ef54f985bd588d8bb99 Mon Sep 17 00:00:00 2001 -From: Andre Paiusco -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 ---- - 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 - diff --git a/0199-util-use-only-dev-directory-in-open_dev.patch b/0199-util-use-only-dev-directory-in-open_dev.patch deleted file mode 100644 index e2c3d53..0000000 --- a/0199-util-use-only-dev-directory-in-open_dev.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0d29e12553cd9f51c1d4428ea373cdb8c62fbcf2 Mon Sep 17 00:00:00 2001 -From: Kinga Stefaniuk -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 ---- - 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 - diff --git a/0200-mdadm-Manage-Clear-superblock-if-adding-new-device-f.patch b/0200-mdadm-Manage-Clear-superblock-if-adding-new-device-f.patch deleted file mode 100644 index 033987b..0000000 --- a/0200-mdadm-Manage-Clear-superblock-if-adding-new-device-f.patch +++ /dev/null @@ -1,47 +0,0 @@ -From c6ca5b31e18f92490e639de0e5eae88985628633 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0201-mdadm-Grow-Check-new_level-interface-rather-than-ker.patch b/0201-mdadm-Grow-Check-new_level-interface-rather-than-ker.patch deleted file mode 100644 index f0a9152..0000000 --- a/0201-mdadm-Grow-Check-new_level-interface-rather-than-ker.patch +++ /dev/null @@ -1,31 +0,0 @@ -From b278b2fc172bb8d50f607adef4d515af1f52d913 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -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 -Signed-off-by: Mariusz Tkaczyk ---- - 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 - diff --git a/0202-platform-intel-fix-buffer-overflow.patch b/0202-platform-intel-fix-buffer-overflow.patch deleted file mode 100644 index e9719b9..0000000 --- a/0202-platform-intel-fix-buffer-overflow.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 7f960c3bd050e76f8bf0a8a0c8fbdcbaa565fc78 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 22 Nov 2024 11:01:04 +0100 -Subject: [PATCH 1/1] platform-intel: fix buffer overflow - -mdadm -C /dev/md/imsm0 -e imsm -n 2 /dev/nvme5n1 /dev/nvme4n1 -R -mdadm -C /dev/md/r0d2 -l 0 -n 2 /dev/nvme5n1 /dev/nvme4n1 -R -*** buffer overflow detected ***: terminated -Aborted (core dumped) - -Issue is related to D_FORTIFY_SOURCE=3 flag and depends on environment, -especially compiler version. In function active_arrays_by_format length of -path buffer is calculated dynamically based on parameters, while PATH_MAX -is used in snprintf, this is my lead to buffer overflow. - -It is fixed by change dynamic length calculation, to use define PATH_MAX -for path length. - -Signed-off-by: Blazej Kucman ---- - super-intel.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 87026f5a0e80..9c464945d09c 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7055,7 +7055,8 @@ active_arrays_by_format(char *name, char* hba, struct md_list **devlist, - int fd = -1; - - while (dev && !is_fd_valid(fd)) { -- char *path = xmalloc(strlen(dev->name) + strlen("/dev/") + 1); -+ char path[PATH_MAX]; -+ - num = snprintf(path, PATH_MAX, "%s%s", "/dev/", dev->name); - if (num > 0) - fd = open(path, O_RDONLY, 0); -@@ -7063,7 +7064,6 @@ active_arrays_by_format(char *name, char* hba, struct md_list **devlist, - pr_vrb("Cannot open %s: %s\n", - dev->name, strerror(errno)); - } -- free(path); - dev = dev->next; - } - found = 0; --- -2.32.0 (Apple Git-132) - diff --git a/0203-imsm-fix-tpv-drvies-check-in-add_to_super.patch b/0203-imsm-fix-tpv-drvies-check-in-add_to_super.patch deleted file mode 100644 index fe96c49..0000000 --- a/0203-imsm-fix-tpv-drvies-check-in-add_to_super.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 8032700b7a44df2dd54af478940938958c08dcf0 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 20 Nov 2024 16:50:25 +0100 -Subject: [PATCH 1/1] imsm: fix tpv drvies check in add_to_super - -Before the mentioned patch, the check to verify if IMSM on current -platform supports a use of TPV (other than Intel) disk, was only performed -for non-Intel disks, after it is performed for all. This change causes -inability to use any disk when platform does not support TPV drives, -attempt results in the following error. - -mdadm: Platform configuration does not support non-Intel NVMe drives. - Please refer to Intel(R) RSTe/VROC user guide. - -This change restores the check if the disk is non-Intel. - -Fixes: 734e7db4dfc5 ("imsm: Remove warning and refactor add_to_super_imsm code") -Signed-off-by: Blazej Kucman ---- - super-intel.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index 9c464945d09c..7e3c5f2b7047 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -6121,7 +6121,8 @@ 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->orom && !imsm_orom_has_tpv_support(super->orom)) { -+ if (super->orom && devpath_to_vendor(pci_dev_path) != 0x8086 && -+ !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.32.0 (Apple Git-132) - diff --git a/mdadm-2.5.2-static.patch b/mdadm-2.5.2-static.patch index 188b478..44f38e6 100644 --- a/mdadm-2.5.2-static.patch +++ b/mdadm-2.5.2-static.patch @@ -1,23 +1,11 @@ ---- 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 @@ +--- mdadm/Makefile.orig 2025-04-30 05:17:02.238426018 -0400 ++++ mdadm/Makefile 2025-04-30 05:17:15.299183058 -0400 +@@ -277,7 +277,7 @@ install : install-bin install-man install-udev - + install-static : mdadm.static install-man - $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm + $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm.static - - install-tcc : mdadm.tcc install-man -- $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm -+ $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm.tcc - - install-uclibc : mdadm.uclibc install-man -- $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm -+ $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm.uclibc - - install-klibc : mdadm.klibc install-man -- $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm -+ $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm.klibc - + install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8 diff --git a/mdadm-fix-building-errors.patch b/mdadm-fix-building-errors.patch new file mode 100644 index 0000000..03025ad --- /dev/null +++ b/mdadm-fix-building-errors.patch @@ -0,0 +1,64 @@ +From 46940fbca6df3ddffa71541e459a277d79584fc0 Mon Sep 17 00:00:00 2001 +From: Xiao Ni +Date: Wed, 30 Apr 2025 06:47:08 -0400 +Subject: [PATCH 1/1] mdadm: fix building errors + +This is a rhel-only patch and this patch will be sent to upstream. + +Signed-off-by: Xiao Ni +--- + super-ddf.c | 9 +++++---- + super-intel.c | 2 +- + 2 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/super-ddf.c b/super-ddf.c +index 6e7db924..285d3b8b 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -1606,9 +1606,9 @@ static void examine_vd(int n, struct ddf_super *sb, char *guid) + map_num(ddf_sec_level, vc->srl) ?: "-unknown-"); + } + printf(" Device Size[%d] : %llu\n", n, +- be64_to_cpu(vc->blocks)/2); ++ (unsigned long long)(be64_to_cpu(vc->blocks)/2)); + printf(" Array Size[%d] : %llu\n", n, +- be64_to_cpu(vc->array_blocks)/2); ++ (unsigned long long)(be64_to_cpu(vc->array_blocks)/2)); + } + } + +@@ -1665,7 +1665,7 @@ static void examine_pds(struct ddf_super *sb) + printf(" %3d %08x ", i, + be32_to_cpu(pd->refnum)); + printf("%8lluK ", +- be64_to_cpu(pd->config_size)>>1); ++ (unsigned long long)be64_to_cpu(pd->config_size)>>1); + for (dl = sb->dlist; dl ; dl = dl->next) { + if (be32_eq(dl->disk.refnum, pd->refnum)) { + char *dv = map_dev(dl->major, dl->minor, 0); +@@ -2901,7 +2901,8 @@ static unsigned int find_unused_pde(const struct ddf_super *ddf) + static void _set_config_size(struct phys_disk_entry *pde, const struct dl *dl) + { + __u64 cfs, t; +- cfs = min(dl->size - 32*1024*2ULL, be64_to_cpu(dl->primary_lba)); ++ cfs = min((unsigned long long)dl->size - 32*1024*2ULL, ++ (unsigned long long)be64_to_cpu(dl->primary_lba)); + t = be64_to_cpu(dl->secondary_lba); + if (t != ~(__u64)0) + cfs = min(cfs, t); +diff --git a/super-intel.c b/super-intel.c +index b7b030a2..caa583d8 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -2325,7 +2325,7 @@ static void export_examine_super_imsm(struct supertype *st) + printf("MD_LEVEL=container\n"); + printf("MD_UUID=%s\n", nbuf+5); + printf("MD_DEVICES=%u\n", mpb->num_disks); +- printf("MD_CREATION_TIME=%llu\n", __le64_to_cpu(mpb->creation_time)); ++ printf("MD_CREATION_TIME=%llu\n", (unsigned long long)__le64_to_cpu(mpb->creation_time)); + } + + static void detail_super_imsm(struct supertype *st, char *homehost, +-- +2.41.0 + diff --git a/mdadm.spec b/mdadm.spec index 7f677e7..ae4dd7b 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,15 +1,15 @@ %bcond abrt %{undefined rhel} Name: mdadm -Version: 4.3 +Version: 4.4 # extraversion is used to define rhel internal version -%define extraversion 5 +%define extraversion 1 Release: %{extraversion}%{?dist} Summary: The mdadm program controls Linux md devices (software RAID arrays) -URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ +URL: https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git License: GPLv2+ -Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}%{?subversion:-%{subversion}}.tar.xz +Source: https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/snapshot/%{name}-%{version}%{?subversion:-%{subversion}}.tar.gz Source1: raid-check Source2: mdadm-raid-check-sysconfig Source3: mdmonitor.service @@ -21,204 +21,46 @@ Source8: mdcheck Source9: md-auto-readd.rule Source10: md-auto-readd.sh -Patch000: 0001-Remove-hardcoded-checkpoint-interval-checking.patch -Patch001: 0002-monitor-refactor-checkpoint-update.patch -Patch002: 0003-Super-intel-Fix-first-checkpoint-restart.patch -Patch003: 0004-Grow-Move-update_tail-assign-to-Grow_reshape.patch -Patch004: 0005-Add-understanding-output-section-in-man.patch -Patch005: 0006-Create-add_disk_to_super-fix-resource-leak.patch -Patch006: 0007-mdadm-signal_s-init-variables.patch -Patch007: 0008-Monitor-open-file-before-check-in-check_one_sharer.patch -Patch008: 0009-Grow-remove-dead-condition-in-Grow_reshape.patch -Patch009: 0010-super1-check-fd-before-passing-to-get_dev_size-in-ad.patch -Patch010: 0011-mdmon-refactor-md-device-name-check-in-main.patch -Patch011: 0012-test-run-tests-on-system-level-mdadm.patch -Patch012: 0013-Monitor-Allow-no-PID-in-check_one_sharer.patch -Patch013: 0014-super-intel-respect-IMSM_DEVNAME_AS_SERIAL-flag.patch -Patch014: 0015-mdadm-remove-TODO.patch -Patch015: 0016-mdadm-remove-makedist.patch -Patch016: 0017-mdadm-remove-mdadm.spec.patch -Patch017: 0018-mdadm-remove-mkinitramfs-stuff.patch -Patch018: 0019-mdadm-move-documentation-to-folder.patch -Patch019: 0020-Detail-remove-duplicated-code.patch -Patch020: 0021-mdadm-Add-functions-for-spare-criteria-verification.patch -Patch021: 0022-mdadm-drop-get_required_spare_criteria.patch -Patch022: 0023-Manage-fix-check-after-dereference-issue.patch -Patch023: 0024-Manage-implement-manage_add_external.patch -Patch024: 0025-mdadm-introduce-sysfs_get_container_devnm.patch -Patch025: 0026-mdadm.h-Introduce-custom-device-policies.patch -Patch026: 0027-mdadm-test_and_add-device-policies-implementation.patch -Patch027: 0028-Create-Use-device-policies.patch -Patch028: 0029-Manage-check-device-policies-in-manage_add_external.patch -Patch029: 0030-Monitor-Incremental-use-device-policies.patch -Patch030: 0031-imsm-test_and_add_device_policies-implementation.patch -Patch031: 0032-mdadm-drop-get_disk_controller_domain.patch -Patch032: 0033-Revert-policy.c-Avoid-to-take-spare-without-defined-.patch -Patch033: 0034-mdadm-remove-inventory-file.patch -Patch034: 0035-udev.c-Do-not-require-libudev.h-if-DNO_LIBUDEV.patch -Patch035: 0036-util.c-add-limits.h-include-for-NAME_MAX-definition.patch -Patch036: 0037-mdadm-set-swapuuid-in-all-handlers.patch -Patch037: 0038-mdadm-Fix-native-detail-export.patch -Patch038: 0039-sysfs-remove-vers-parameter-from-sysfs_set_array.patch -Patch039: 0040-mdadm-fix-grow-segfault-for-IMSM.patch -Patch040: 0041-Remove-all-if-zeros-pt.2.patch -Patch041: 0042-mdadm-Move-pr_vrb-define-to-mdadm.h.patch -Patch042: 0043-Add-reading-Opal-NVMe-encryption-information.patch -Patch043: 0044-Add-reading-SATA-encryption-information.patch -Patch044: 0045-Add-key-ENCRYPTION_NO_VERIFY-to-conf.patch -Patch045: 0046-imsm-print-disk-encryption-information.patch -Patch046: 0047-imsm-drive-encryption-policy-implementation.patch -Patch047: 0048-mdadm-add-CHANGELOG.md.patch -Patch048: 0049-mdadm-Add-MAINTAINERS.md.patch -Patch049: 0050-mdadm-Add-README.md.patch -Patch050: 0051-Create.c-fix-uclibc-build.patch -Patch051: 0052-mdadm-pass-struct-context-for-external-reshapes.patch -Patch052: 0053-mdadm-use-struct-context-in-reshape_super.patch -Patch053: 0054-imsm-add-support-for-literal-RAID-10.patch -Patch054: 0055-imsm-refactor-RAID-level-handling.patch -Patch055: 0056-imsm-bump-minimal-version.patch -Patch056: 0057-imsm-define-RAID_10-attribute.patch -Patch057: 0058-imsm-simplify-imsm_check_attributes.patch -Patch058: 0059-imsm-support-RAID-10-with-more-than-4-drives.patch -Patch059: 0060-tests-01r5fail-enhance.patch -Patch060: 0061-tests-01r5integ.broken.patch -Patch061: 0062-tests-01raid6integ.broken-can-be-removed.patch -Patch062: 0063-Makefile-Move-pie-to-LDFLAGS.patch -Patch063: 0064-tests-23rdev-lifetime-fix-a-typo.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 -Patch066: 0067-mdadm-Change-main-repository-to-Github.patch -Patch067: 0069-mdadm-Fix-compilation-for-32-bit-arch.patch -Patch068: 0070-add-checking-of-return-status-on-fstat-calls.patch -Patch069: 0071-super-intel-fix-typo-in-error-msg.patch -Patch070: 0072-mdadm-super-intel-remove-dead-code.patch -Patch071: 0073-mdadm-super-intel-fix-bad-shift.patch -Patch072: 0074-mdadm-deprecate-bitmap-custom-file.patch -Patch073: 0075-Makefile-fix-make-s-detection.patch -Patch074: 0076-Change-some-error-messages-to-info-level.patch -Patch075: 0077-mdadm-Start-update_opt-from-0.patch -Patch076: 0078-Don-t-control-reshape-speed-in-daemon.patch -Patch077: 0079-mdadm-tests-test-enhance.patch -Patch078: 0080-mdadm-tests-test-don-t-fail-when-systemd-reports-err.patch -Patch079: 0081-mdadm-tests-names_template-enhance.patch -Patch080: 0082-mdadm-tests-03assem-incr-enhance.patch -Patch081: 0083-mdadm-tests-03r0assem-enhance.patch -Patch082: 0084-mdadm-tests-remove-03r5assem-failed.patch -Patch083: 0085-mdadm-tests-03r5assemV1.patch -Patch084: 0086-mdadm-tests-remove-04r5swap.broken.patch -Patch085: 0087-tests-04update-metadata-skip-linear.patch -Patch086: 0088-mdadm-tests-05r5-internalbitmap.patch -Patch087: 0089-mdadm-tests-06name-enhance.patch -Patch088: 0090-mdadm-tests-07autoassemble.patch -Patch089: 0091-mdadm-tests-07autodetect.broken-can-be-removed.patch -Patch090: 0092-mdadm-tests-07changelevelintr.patch -Patch091: 0093-mdadm-tests-disable-selinux.patch -Patch092: 0094-mdadm-platform-intel-buffer-overflow-detected.patch -Patch093: 0095-mdadm-tests-bitmap-cases-enhance.patch -Patch094: 0096-mdadm-tests-04update-uuid.patch -Patch095: 0097-mdadm-tests-05r1-re-add-nosuper.patch -Patch096: 0098-mdadm-tests-remove-strace-test.patch -Patch097: 0099-mdadm.h-provide-basename-if-GLIBC-is-not-avialable.patch -Patch098: 0100-imsm-fix-first-volume-autolayout-with-IMSM_NO_PLATFO.patch -Patch099: 0101-imsm-make-freesize-required-to-volume-autolayout.patch -Patch100: 0102-mdadm-Fix-hang-race-condition-in-wait_for_zero_forks.patch -Patch101: 0103-mdadm-Block-SIGCHLD-processes-before-starting-childr.patch -Patch102: 0104-test-pass-flags-to-services.patch -Patch103: 0105-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch -Patch104: 0106-Makefile-Do-not-call-gcc-directly.patch -Patch105: 0107-mdadm-tests-judge-foreign-array-in-test-cases.patch -Patch106: 0108-Revert-mdadm-Fix-socket-connection-failure-when-mdmo.patch -Patch107: 0109-mdadm-Assemble.c-fix-coverity-issues.patch -Patch108: 0111-mdadm-Fix-socket-connection-failure-when-mdmon-runs-.patch -Patch109: 0113-config.c-Fix-memory-leak-in-load_containers.patch -Patch110: 0114-mdadm-Build.c-fix-coverity-issues.patch -Patch111: 0115-mdadm-Create.c-fix-coverity-issues.patch -Patch112: 0116-mdadm-super-ddf.c-fix-coverity-issues.patch -Patch113: 0117-mdadm-clustermd_tests-add-some-APIs-in-func.sh-to-su.patch -Patch114: 0118-mdadm-clustermd_tests-adjust-test-cases-to-support-m.patch -Patch115: 0119-mapfile.c-Fix-STRING_OVERFLOW-issue.patch -Patch116: 0120-mdadm-Manage.c-fix-coverity-issues.patch -Patch117: 0121-Manage-fix-is_remove_safe.patch -Patch118: 0122-imsm-add-indent-for-encryption-details.patch -Patch119: 0123-mdadm-Monitor.c-fix-coverity-issues.patch -Patch120: 0124-mdadm-Query.c-fix-coverity-issues.patch -Patch121: 0125-mdadm-lib.c-fix-coverity-issues.patch -Patch122: 0126-mdadm-do-not-allow-leading-dot-in-MD-device-name.patch -Patch123: 0128-Detail-fix-detail-export-for-uuid_zero.patch -Patch124: 0129-drive_encryption-Fix-ata-passthrough12-verify.patch -Patch125: 0130-super0-use-define-for-char-array-in-examine_super0.patch -Patch126: 0131-Makefile-add-more-compiler-flags.patch -Patch127: 0133-mdstat-Rework-mdstat-external-arrays-handling.patch -Patch128: 0134-mdadm-managemon.c-fix-coverity-issues.patch -Patch129: 0135-mdadm-msg.c-fix-coverity-issues.patch -Patch130: 0136-imsm-refactor-chunk-size-print.patch -Patch131: 0137-mdadm-Grow-fix-coverity-issue-CHECKED_RETURN.patch -Patch132: 0138-mdadm-Grow-fix-coverity-issue-RESOURCE_LEAK.patch -Patch133: 0139-mdadm-Grow-fix-coverity-issue-STRING_OVERFLOW.patch -Patch134: 0140-mdadm-Incremental-fix-coverity-issues.patch -Patch135: 0141-mdadm-mdmon-fix-coverity-issue-CHECKED_RETURN.patch -Patch136: 0142-mdadm-mdmon-fix-coverity-issue-RESOURCE_LEAK.patch -Patch137: 0143-mdadm-mdopen-fix-coverity-issue-CHECKED_RETURN.patch -Patch138: 0144-mdadm-mdopen-fix-coverity-issue-STRING_OVERFLOW.patch -Patch139: 0145-mdadm-mdstat-fix-coverity-issue-CHECKED_RETURN.patch -Patch140: 0146-mdadm-super0-fix-coverity-issue-CHECKED_RETURN-and-E.patch -Patch141: 0147-mdadm-super1-fix-coverity-issue-CHECKED_RETURN.patch -Patch142: 0148-mdadm-super1-fix-coverity-issue-DEADCODE.patch -Patch143: 0149-mdadm-super1-fix-coverity-issue-EVALUATION_ORDER.patch -Patch144: 0150-mdadm-super1-fix-coverity-issue-RESOURCE_LEAK.patch -Patch145: 0151-policy.c-Fix-check_return-issue-in-Write_rules.patch -Patch146: 0152-super-gpt.c-Fix-check_return-issue-in-load_gpt.patch -Patch147: 0153-super-intel-fix-compilation-error.patch -Patch148: 0154-super-intel-add-define-for-migr_state.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 -Patch194: 0202-platform-intel-fix-buffer-overflow.patch -Patch195: 0203-imsm-fix-tpv-drvies-check-in-add_to_super.patch +Patch000: 0001-Coverity-fixes-resources-leaks.patch +Patch001: 0002-Incremental-Document-workaround.patch +Patch002: 0003-sysfs-functions-for-writing-md-memb-state.patch +Patch003: 0004-Incremental-Simplify-remove-logic.patch +Patch004: 0005-checkpatch.conf-ignore-NEW_TYPEDEFS.patch +Patch005: 0006-mdadm-add-MAINTAINERS-file.patch +Patch006: 0007-mdadm.man-Remove-external-bitmap.patch +Patch007: 0008-Remove-freeze-reshape-logic.patch +Patch008: 0009-Detail-Export-reshape-status.patch +Patch009: 0010-mdadm-Do-not-start-reshape-before-switchroot.patch +Patch010: 0011-Better-error-messages-for-broken-reshape.patch +Patch011: 0012-Refactor-continue_via_systemd.patch +Patch012: 0013-mdadm-raid6check-add-xmalloc.h-to-raid6check.c.patch +Patch013: 0014-mdopen-add-sbin-path-to-env-PATH-when-call-system-mo.patch +Patch014: 0015-udev-persist-properties-of-MD-devices-after-switch_r.patch +Patch015: 0016-mdadm-fix-grow-with-add-for-linear.patch +Patch016: 0017-platform-intel-Disable-legacy-option-ROM-scan-on-UEF.patch +Patch017: 0018-super-ddf-Prevent-crash-when-handling-DDF-metadata.patch +Patch018: 0019-super-ddf-optimize-DDF-header-search-for-widely-used.patch +Patch019: 0020-bitmap.h-clear-__KERNEL__-based-headers.patch +Patch020: 0021-bitmap.h-Minor-fixes.patch +Patch021: 0022-Move-release-steps-to-documentation.patch +Patch022: 0023-Rework-MAINTAINERS-file.patch +Patch023: 0024-mdmon-imsm-fix-metadata-corruption-when-managing-new.patch +Patch024: 0025-Regression-fix-156.patch +Patch025: 0026-super1-Clear-extra-flags-when-initializing-metadata.patch +Patch026: 0027-imsm-Fix-RAID0-to-RAID10-migration.patch +Patch027: 0028-Allow-RAID0-to-be-created-with-v0.90-metadata-161.patch +Patch028: 0029-Update-tests.yml.patch +Patch029: 0030-Update-tests.yml.patch +Patch030: 0031-Update-tests.yml.patch +Patch031: 0032-Update-tests.yml.patch +Patch032: 0033-This-is-a-test-for-CI-do-not-merge.patch +Patch033: 0034-Update-README.md.patch +Patch034: 0035-mdadm-Remove-klibc-and-uclibc-support.patch +Patch035: 0036-mdadm-include-asm-byteorder.h.patch +Patch036: 0037-mdadm-use-kernel-raid-headers.patch # Fedora customization patches +Patch196: mdadm-fix-building-errors.patch Patch197: mdadm-udev.patch Patch198: mdadm-2.5.2-static.patch @@ -300,6 +142,10 @@ install -m644 %{SOURCE5} %{buildroot}/etc/libreport/events.d /usr/share/mdadm/mdcheck %changelog +* Wed Apr 30 2025 Xiao Ni - 4.4-1 +- Update to mdadm 4.4 and latest upstream +- Resolves: RHEL-86676, RHEL-72803, RHEL-88793, RHEL-88791 + * Tue Dec 3 2024 Xiao Ni - 4.3-5 - Two create command problems - Resolves: RHEL-69286, RHEL-68654 diff --git a/sources b/sources index 3b91d12..4010aa3 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (mdadm-4.3.tar.xz) = e44977f2f80d2471cb313803a60c92dafe8282ac06bbbfd41ae90ca493c64a3da94db924538788d045fd7f0667333912dabedb0b070f9abf5c0540b32e0fa08f +SHA512 (mdadm-4.4.tar.gz) = 08682b27f41a230f188d3b61e22e95ff8808b36c8fc2cba1dff443d39a72b35ba2eaf29ed64c7e5583c177fe6b71df983ec9a80a4128d8f07d58b7435d4700f6