From a98bc811ce7fc9f06de4a15c2d1060f0e36085f087902db07cb638a1534b2d84 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 3 Nov 2022 23:28:28 +0000 Subject: [PATCH] Accepting request 1033139 from home:colyli:branches:Base:System Update mdadm package to latest mdadm since mdadm-4.2 (jsc#PED-1009) OBS-URL: https://build.opensuse.org/request/show/1033139 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=210 --- ..._DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch | 43 -- 0001-Unify-error-message.patch | 50 ++ 0002-Document-PART-POLICY-lines.patch | 82 --- 0002-mdadm-Fix-double-free.patch | 36 + ...-r0-grow-size-error-message-and-upda.patch | 86 +++ ...-support-devices-with-multiple-paths.patch | 339 ---------- ...dd-systemd-unit-files-to-run-mdcheck.patch | 140 ---- 0004-udev-adapt-rules-to-systemd-v247.patch | 70 ++ ...em-timer-to-run-oneshot-periodically.patch | 85 --- ...ce-error-prone-signal-with-sigaction.patch | 255 ++++++++ ...data-correctly-while-raid10-double-d.patch | 88 --- ...-Respect-config-file-location-in-man.patch | 126 ++++ ...ILFAST-and-WRITEMOSTLY-flags-when-fi.patch | 48 -- 0007-mdadm-Update-ReadMe.patch | 50 ++ ...id-overflow-in-compute_backup_blocks.patch | 39 -- ...fig-man-regarding-default-files-and-.patch | 205 ++++++ 0009-Grow-report-correct-new-chunk-size.patch | 35 - 0009-mdadm-Update-config-manual.patch | 47 ++ 0010-Create-Build-use-default_layout.patch | 156 +++++ ...y.c-prevent-NULL-pointer-referencing.patch | 34 - 0011-mdadm-add-map_num_s.patch | 385 +++++++++++ ...mdmon-Stop-parsing-duplicate-options.patch | 125 ++++ 0012-policy.c-Fix-for-compiler-error.patch | 38 -- 0013-Grow-block-n-on-external-volumes.patch | 44 ++ ...covery-when-drive-with-rebuild-fails.patch | 98 --- ...x-possible-memory-and-resource-leaks.patch | 93 +++ 0014-imsm-fix-reshape-for-2TB-drives.patch | 327 --------- 0015-Fix-spelling-typos.patch | 106 --- 0015-Mdmonitor-Fix-segfault.patch | 101 +++ ...skip-first-character-when-calling-xs.patch | 49 -- 0016-Mdmonitor-Improve-logging-method.patch | 64 ++ ...LL-ptr-dereferences-and-memory-leaks.patch | 76 +++ ...x-reshape-for-decreasing-data-offset.patch | 75 --- ...ibility-for-get_imsm_dev-to-return-N.patch | 304 +++++++++ ...dadm-fix-coredump-of-mdadm-monitor-r.patch | 87 +++ ...-one-test-case-for-failfast-of-raid1.patch | 104 --- ...mpt-to-manage-new-arrays-when-termin.patch | 53 -- ...util-replace-ioctl-use-with-function.patch | 33 + ...tore-commit-45a87c2f31335-to-fix-clu.patch | 19 +- ...revious-mdmon-to-exit-during-takeove.patch | 62 -- ...rting-array-with-initial-reshape-che.patch | 56 -- ...-imsm-introduce-get_disk_slot_in_dev.patch | 124 ++++ 0023-add-missing-units-to-examine.patch | 64 -- ...-imsm-use-same-slot-across-container.patch | 254 +++++++ ...block-changing-slots-during-creation.patch | 124 ++++ ...are-activation-for-old-matrix-arrays.patch | 121 ---- 0025-Create-Block-rounding-size-to-max.patch | 99 --- ...ck-update-ppl-for-non-raid456-levels.patch | 180 +++++ ...m-Fix-array-size-mismatch-after-grow.patch | 33 + ...les-to-create-by-partuuid-for-md-dev.patch | 35 - ...-dead-code-in-imsm_fix_size_mismatch.patch | 37 ++ ...array-state-when-disk-fails-during-m.patch | 114 ---- ...-probe_roms-to-scan-more-than-6-roms.patch | 216 ------ ...ame-as-char-array-instead-of-pointer.patch | 43 ++ ...tor-use-snprintf-to-fill-device-name.patch | 136 ++++ ...-Fix-issue-with-abs-being-irrelevant.patch | 43 -- ...uild-static-build-with-everything-an.patch | 45 ++ ...ed-unaligned-get-put-_unaligned-16-3.patch | 61 -- ...anup-validate_geometry_ddf_container.patch | 144 ++++ ...intel-Use-put_unaligned-in-split_ull.patch | 43 -- ...nter-dereference-in-validate_geometr.patch | 52 ++ ...lt-sysfs-attributes-after-assemblati.patch | 349 ---------- ...se-after-close-bug-by-closing-after-.patch | 88 +++ ...-include-sysmacros.h-unconditionally.patch | 39 -- ...ices-to-avoid-component-devices-deta.patch | 161 ----- ...gfault-when-calling-NULL-get_bad_blo.patch | 39 ++ ...Fix-mdadm-r-remove-option-regression.patch | 81 +++ ...ices-option-for-calling-mdadm-detail.patch | 45 -- 0036-imsm-close-removed-drive-fd.patch | 49 -- ...-Fix-optional-write-behind-parameter.patch | 45 ++ ...place-obsolete-usleep-with-nanosleep.patch | 319 +++++++++ ...e-returned-by-snprintf-against-error.patch | 50 -- ...new-array-state-broken-for-raid0-lin.patch | 167 ----- 0038-mdadm-remove-symlink-option.patch | 179 +++++ ...dadm-force-a-uuid-swap-on-big-endian.patch | 45 -- ...adm-move-data_offset-to-struct-shape.patch | 235 +++++++ ...en-md-device-for-CREATE-and-ASSEMBLE.patch | 165 +++++ ...he-descriptions-for-bitmap-sysfs-nod.patch | 103 --- ...it-Grow_reshape-into-helper-function.patch | 233 +++++++ 0041-Init-devlist-as-an-array.patch | 40 -- ...f-device-is-container-before-schedul.patch | 39 ++ ...eck-recovery-after-re-add-when-no-I-.patch | 36 - 0043-super1-report-truncated-device.patch | 115 ++++ ...allow-for-udev-attribute-reading-bug.patch | 52 -- 0044-imsm-save-current_vol-number.patch | 45 -- ...typos-punctuation-and-grammar-in-man.patch | 619 ++++++++++++++++++ 0045-Manage-Block-unsafe-member-failing.patch | 94 +++ ...-allow-to-specify-second-volume-size.patch | 55 -- 0046-Monitor-Fix-statelist-memory-leaks.patch | 115 ++++ ...heck_start-is-enabled-enable-mdcheck.patch | 47 -- ...ort-for-Intel-Alderlake-RST-on-VMD-p.patch | 64 ++ ...entation-entries-to-systemd-services.patch | 113 ++++ 0049-ReadMe-fix-command-line-help.patch | 34 + ...container-level-checking-with-inline.patch | 259 ++++++++ ...heck-use-to-pass-variable-to-mdcheck.patch | 54 -- 0051-Mdmonitor-Omit-non-md-devices.patch | 61 ++ ...m_env.sh-handle-MDADM_CHECK_DURATION.patch | 31 - ...-t-mark-structs-packed-unnecessarily.patch | 126 ---- ...e-legacy-code-for-md-driver-prior-to.patch | 57 -- 0054-Remove-last-traces-of-HOT_ADD_DISK.patch | 46 -- 0055-Fix-up-a-few-formatting-issues.patch | 56 -- 0056-Remove-unused-code.patch | 31 - ...rn-correct-uuid-for-volume-in-detail.patch | 181 ----- ...way-of-printing-nvme-drives-in-detai.patch | 213 ------ ...Create-add-support-for-RAID0-layouts.patch | 345 ---------- ...semble-add-support-for-RAID0-layouts.patch | 153 ----- ...CROSS_COMPILE-when-CC-is-the-default.patch | 40 -- 0062-Change-warning-message.patch | 44 -- ...can-t-start-succesfully-because-of-s.patch | 50 -- 0064-imsm-Update-grow-manual.patch | 48 -- 0065-Add-support-for-Tebibytes.patch | 197 ------ ...-working_disks-according-to-metadata.patch | 70 -- ...-information-for-raid0-growing-opera.patch | 58 -- 0068-Remove-the-legacy-whitespace.patch | 64 -- ...ubarray-id-to-kill_subarray-function.patch | 95 --- ...m-Remove-dump-restore-implementation.patch | 96 --- ...check_one_sharer-for-checking-duplic.patch | 112 ---- ...dding-sync-status-for-cluster-device.patch | 88 --- 0073-imsm-Correct-minimal-device-size.patch | 36 - ...ect-bitmap-info-for-cluster-raid-dev.patch | 34 - ...-Array-Creation-Time-field-in-metada.patch | 70 -- ...rray-and-Volume-ID-in-examine-output.patch | 42 -- 0077-udev-Ignore-change-event-for-imsm.patch | 39 -- ...anage-imsm-Write-metadata-before-add.patch | 168 ----- ...rror-message-if-mdadm-fails-assembli.patch | 61 -- 0080-clean-up-meaning-of-small-typo.patch | 33 - 0081-Assemble.c-respect-force-flag.patch | 99 --- 0082-mdcheck-Log-when-done.patch | 49 -- 0083-Makefile-add-EXTRAVERSION-support.patch | 53 -- ...uuid.c-split-uuid-stuffs-from-util.c.patch | 288 -------- ...r-0-character-when-using-strncpy-to-.patch | 38 -- ...oring-return-value-of-read-and-lseek.patch | 53 -- ...g-existing-links-while-manual-assemb.patch | 36 - ...-device-error-rather-than-underflow-.patch | 80 --- 0089-Use-more-secure-HTTPS-URLs.patch | 127 ---- 0090-Update-link-to-Intel-page-for-IMSM.patch | 32 - ...nt-md-s-fd-from-being-occupied-durin.patch | 68 -- ...s-number-when-updating-cluster-nodes.patch | 40 -- ...e-path-to-in-kernel-tree-documentati.patch | 35 - 0094-manual-update-examine-badblocks.patch | 38 -- ...ect-raid-level-when-the-array-is-ina.patch | 71 -- ...e-bitmap-for-raid5-with-journal-disk.patch | 33 - ...nitor-refresh-mdstat-fd-after-select.patch | 74 --- ...nitor-stop-notifing-about-containers.patch | 82 --- 0099-mdmonitor-set-small-delay-once.patch | 107 --- ...Monitor-instance-running-before-fork.patch | 107 --- ...w-RAID0-layout-setting-to-be-removed.patch | 140 ---- ...x-segfault-during-IMSM-raid-creation.patch | 37 -- ...ate.c-close-mdfd-and-generate-uevent.patch | 41 -- ...m_data_stripes-according-to-dev_size.patch | 167 ----- ...move-redundant-calls-to-imsm_get_map.patch | 39 -- ...e-default-modes-when-creating-a-file.patch | 59 -- ...imit-support-to-first-NVMe-namespace.patch | 99 --- 0108-mdadm-Unify-forks-behaviour.patch | 358 ---------- ...ow-correct-state-for-clustered-array.patch | 201 ------ ...Make-target-to-install-binaries-only.patch | 47 -- ...dev-start-grow-service-automatically.patch | 41 -- ...emove-redundant-spare-movement-logic.patch | 115 ---- ...om-a-wrong-metadata-file-when-restor.patch | 52 -- ...-super1-fix-Floating-point-exception.patch | 41 -- ...seless-sync-when-bitmap-switches-fro.patch | 57 -- 0116-imsm-nvme-multipath-support.patch | 232 ------- ...be-careful-of-corrupt-dev_roles-list.patch | 166 ----- ...ves-line-from-details-for-external-m.patch | 38 -- ...spares-with-other-arrays-during-RAID.patch | 168 ----- ...embly.rules-skip-if-DM_UDEV_DISABLE_.patch | 34 - ...sm-support-for-third-Sata-controller.patch | 125 ---- ...nstall-mdadm_env.sh-to-usr-lib-mdadm.patch | 1 + ...e-Intel-Alderlake-RSTe-configuration.patch | 24 +- mdadm-4.1.tar.xz | 3 - mdadm-4.2.tar.xz | 3 + mdadm.changes | 279 ++++++++ mdadm.spec | 238 ++----- 173 files changed, 6818 insertions(+), 10696 deletions(-) delete mode 100644 0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch create mode 100644 0001-Unify-error-message.patch delete mode 100644 0002-Document-PART-POLICY-lines.patch create mode 100644 0002-mdadm-Fix-double-free.patch create mode 100644 0003-Grow_reshape-Add-r0-grow-size-error-message-and-upda.patch delete mode 100644 0003-policy-support-devices-with-multiple-paths.patch delete mode 100644 0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch create mode 100644 0004-udev-adapt-rules-to-systemd-v247.patch delete mode 100644 0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch create mode 100644 0005-Replace-error-prone-signal-with-sigaction.patch delete mode 100644 0006-imsm-update-metadata-correctly-while-raid10-double-d.patch create mode 100644 0006-mdadm-Respect-config-file-location-in-man.patch delete mode 100644 0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch create mode 100644 0007-mdadm-Update-ReadMe.patch delete mode 100644 0008-Grow-avoid-overflow-in-compute_backup_blocks.patch create mode 100644 0008-mdadm-Update-config-man-regarding-default-files-and-.patch delete mode 100644 0009-Grow-report-correct-new-chunk-size.patch create mode 100644 0009-mdadm-Update-config-manual.patch create mode 100644 0010-Create-Build-use-default_layout.patch delete mode 100644 0010-policy.c-prevent-NULL-pointer-referencing.patch create mode 100644 0011-mdadm-add-map_num_s.patch create mode 100644 0012-mdmon-Stop-parsing-duplicate-options.patch delete mode 100644 0012-policy.c-Fix-for-compiler-error.patch create mode 100644 0013-Grow-block-n-on-external-volumes.patch delete mode 100644 0013-imsm-finish-recovery-when-drive-with-rebuild-fails.patch create mode 100644 0014-Incremental-Fix-possible-memory-and-resource-leaks.patch delete mode 100644 0014-imsm-fix-reshape-for-2TB-drives.patch delete mode 100644 0015-Fix-spelling-typos.patch create mode 100644 0015-Mdmonitor-Fix-segfault.patch delete mode 100644 0016-Detail.c-do-not-skip-first-character-when-calling-xs.patch create mode 100644 0016-Mdmonitor-Improve-logging-method.patch create mode 100644 0017-Fix-possible-NULL-ptr-dereferences-and-memory-leaks.patch delete mode 100644 0018-Fix-reshape-for-decreasing-data-offset.patch create mode 100644 0018-imsm-Remove-possibility-for-get_imsm_dev-to-return-N.patch create mode 100644 0019-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch delete mode 100644 0019-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch delete mode 100644 0020-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch create mode 100644 0020-util-replace-ioctl-use-with-function.patch rename 1004-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch => 0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch (90%) delete mode 100644 0021-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch delete mode 100644 0022-Assemble-Fix-starting-array-with-initial-reshape-che.patch create mode 100644 0022-imsm-introduce-get_disk_slot_in_dev.patch delete mode 100644 0023-add-missing-units-to-examine.patch create mode 100644 0023-imsm-use-same-slot-across-container.patch create mode 100644 0024-imsm-block-changing-slots-during-creation.patch delete mode 100644 0024-imsm-fix-spare-activation-for-old-matrix-arrays.patch delete mode 100644 0025-Create-Block-rounding-size-to-max.patch create mode 100644 0025-mdadm-block-update-ppl-for-non-raid456-levels.patch create mode 100644 0026-mdadm-Fix-array-size-mismatch-after-grow.patch delete mode 100644 0026-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch create mode 100644 0027-mdadm-Remove-dead-code-in-imsm_fix_size_mismatch.patch delete mode 100644 0027-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch delete mode 100644 0028-Enable-probe_roms-to-scan-more-than-6-roms.patch create mode 100644 0028-Monitor-use-devname-as-char-array-instead-of-pointer.patch create mode 100644 0029-Monitor-use-snprintf-to-fill-device-name.patch delete mode 100644 0029-super-intel-Fix-issue-with-abs-being-irrelevant.patch create mode 100644 0030-Makefile-Don-t-build-static-build-with-everything-an.patch delete mode 100644 0030-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch create mode 100644 0031-DDF-Cleanup-validate_geometry_ddf_container.patch delete mode 100644 0031-super-intel-Use-put_unaligned-in-split_ull.patch create mode 100644 0032-DDF-Fix-NULL-pointer-dereference-in-validate_geometr.patch delete mode 100644 0032-mdadm-load-default-sysfs-attributes-after-assemblati.patch create mode 100644 0033-mdadm-Grow-Fix-use-after-close-bug-by-closing-after-.patch delete mode 100644 0033-mdadm.h-include-sysmacros.h-unconditionally.patch delete mode 100644 0034-mdadm-add-no-devices-to-avoid-component-devices-deta.patch create mode 100644 0034-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch create mode 100644 0035-mdadm-Fix-mdadm-r-remove-option-regression.patch delete mode 100644 0035-udev-add-no-devices-option-for-calling-mdadm-detail.patch delete mode 100644 0036-imsm-close-removed-drive-fd.patch create mode 100644 0036-mdadm-Fix-optional-write-behind-parameter.patch create mode 100644 0037-mdadm-Replace-obsolete-usleep-with-nanosleep.patch delete mode 100644 0037-mdadm-check-value-returned-by-snprintf-against-error.patch delete mode 100644 0038-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch create mode 100644 0038-mdadm-remove-symlink-option.patch delete mode 100644 0039-mdadm-force-a-uuid-swap-on-big-endian.patch create mode 100644 0039-mdadm-move-data_offset-to-struct-shape.patch create mode 100644 0040-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch delete mode 100644 0040-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch create mode 100644 0041-Grow-Split-Grow_reshape-into-helper-function.patch delete mode 100644 0041-Init-devlist-as-an-array.patch create mode 100644 0042-Assemble-check-if-device-is-container-before-schedul.patch delete mode 100644 0042-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch create mode 100644 0043-super1-report-truncated-device.patch delete mode 100644 0043-udev-allow-for-udev-attribute-reading-bug.patch delete mode 100644 0044-imsm-save-current_vol-number.patch create mode 100644 0044-mdadm-Correct-typos-punctuation-and-grammar-in-man.patch create mode 100644 0045-Manage-Block-unsafe-member-failing.patch delete mode 100644 0045-imsm-allow-to-specify-second-volume-size.patch create mode 100644 0046-Monitor-Fix-statelist-memory-leaks.patch delete mode 100644 0046-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch create mode 100644 0047-mdadm-added-support-for-Intel-Alderlake-RST-on-VMD-p.patch create mode 100644 0048-mdadm-Add-Documentation-entries-to-systemd-services.patch create mode 100644 0049-ReadMe-fix-command-line-help.patch create mode 100644 0050-mdadm-replace-container-level-checking-with-inline.patch delete mode 100644 0050-mdcheck-use-to-pass-variable-to-mdcheck.patch create mode 100644 0051-Mdmonitor-Omit-non-md-devices.patch delete mode 100644 0051-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch delete mode 100644 0052-super-intel-don-t-mark-structs-packed-unnecessarily.patch delete mode 100644 0053-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch delete mode 100644 0054-Remove-last-traces-of-HOT_ADD_DISK.patch delete mode 100644 0055-Fix-up-a-few-formatting-issues.patch delete mode 100644 0056-Remove-unused-code.patch delete mode 100644 0057-imsm-return-correct-uuid-for-volume-in-detail.patch delete mode 100644 0058-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch delete mode 100644 0059-Create-add-support-for-RAID0-layouts.patch delete mode 100644 0060-Assemble-add-support-for-RAID0-layouts.patch delete mode 100644 0061-Respect-CROSS_COMPILE-when-CC-is-the-default.patch delete mode 100644 0062-Change-warning-message.patch delete mode 100644 0063-mdcheck-service-can-t-start-succesfully-because-of-s.patch delete mode 100644 0064-imsm-Update-grow-manual.patch delete mode 100644 0065-Add-support-for-Tebibytes.patch delete mode 100644 0066-imsm-fill-working_disks-according-to-metadata.patch delete mode 100644 0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch delete mode 100644 0068-Remove-the-legacy-whitespace.patch delete mode 100644 0069-imsm-pass-subarray-id-to-kill_subarray-function.patch delete mode 100644 0070-imsm-Remove-dump-restore-implementation.patch delete mode 100644 0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch delete mode 100644 0072-Detail-adding-sync-status-for-cluster-device.patch delete mode 100644 0073-imsm-Correct-minimal-device-size.patch delete mode 100644 0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch delete mode 100644 0075-imsm-support-the-Array-Creation-Time-field-in-metada.patch delete mode 100644 0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch delete mode 100644 0077-udev-Ignore-change-event-for-imsm.patch delete mode 100644 0078-Manage-imsm-Write-metadata-before-add.patch delete mode 100644 0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch delete mode 100644 0080-clean-up-meaning-of-small-typo.patch delete mode 100644 0081-Assemble.c-respect-force-flag.patch delete mode 100644 0082-mdcheck-Log-when-done.patch delete mode 100644 0083-Makefile-add-EXTRAVERSION-support.patch delete mode 100644 0084-uuid.c-split-uuid-stuffs-from-util.c.patch delete mode 100644 0085-Include-count-for-0-character-when-using-strncpy-to-.patch delete mode 100644 0086-restripe-fix-ignoring-return-value-of-read-and-lseek.patch delete mode 100644 0087-Block-overwriting-existing-links-while-manual-assemb.patch delete mode 100644 0088-Detect-too-small-device-error-rather-than-underflow-.patch delete mode 100644 0089-Use-more-secure-HTTPS-URLs.patch delete mode 100644 0090-Update-link-to-Intel-page-for-IMSM.patch delete mode 100644 0091-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch delete mode 100644 0092-Specify-nodes-number-when-updating-cluster-nodes.patch delete mode 100644 0093-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch delete mode 100644 0094-manual-update-examine-badblocks.patch delete mode 100644 0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch delete mode 100644 0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch delete mode 100644 0097-Monitor-refresh-mdstat-fd-after-select.patch delete mode 100644 0098-Monitor-stop-notifing-about-containers.patch delete mode 100644 0099-mdmonitor-set-small-delay-once.patch delete mode 100644 0100-Check-if-other-Monitor-instance-running-before-fork.patch delete mode 100644 0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch delete mode 100644 0102-Detail-fix-segfault-during-IMSM-raid-creation.patch delete mode 100644 0103-Create.c-close-mdfd-and-generate-uevent.patch delete mode 100644 0104-imsm-update-num_data_stripes-according-to-dev_size.patch delete mode 100644 0105-imsm-remove-redundant-calls-to-imsm_get_map.patch delete mode 100644 0106-Monitor-don-t-use-default-modes-when-creating-a-file.patch delete mode 100644 0107-imsm-limit-support-to-first-NVMe-namespace.patch delete mode 100644 0108-mdadm-Unify-forks-behaviour.patch delete mode 100644 0109-mdadm-Detail-show-correct-state-for-clustered-array.patch delete mode 100644 0110-Make-target-to-install-binaries-only.patch delete mode 100644 0111-udev-start-grow-service-automatically.patch delete mode 100644 0112-Incremental-Remove-redundant-spare-movement-logic.patch delete mode 100644 0113-Dump-get-stat-from-a-wrong-metadata-file-when-restor.patch delete mode 100644 0114-super1-fix-Floating-point-exception.patch delete mode 100644 0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch delete mode 100644 0116-imsm-nvme-multipath-support.patch delete mode 100644 0117-Grow-be-careful-of-corrupt-dev_roles-list.patch delete mode 100644 0118-Remove-Spare-drives-line-from-details-for-external-m.patch delete mode 100644 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch delete mode 100644 0120-udev-md-raid-assembly.rules-skip-if-DM_UDEV_DISABLE_.patch delete mode 100644 0121-imsm-support-for-third-Sata-controller.patch rename 0000-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch => 1004-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch (96%) delete mode 100644 mdadm-4.1.tar.xz create mode 100644 mdadm-4.2.tar.xz diff --git a/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch b/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch deleted file mode 100644 index 923d9b2..0000000 --- a/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0833f9c3dbaaee202b92ea956f9e2decc7b9593a Mon Sep 17 00:00:00 2001 -From: Gioh Kim -Date: Tue, 6 Nov 2018 15:27:42 +0100 -Subject: [PATCH] Assemble: keep MD_DISK_FAILFAST and MD_DISK_WRITEMOSTLY flag -Git-commit: 0833f9c3dbaaee202b92ea956f9e2decc7b9593a -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Before updating superblock of slave disks, desired_state value -is set for the target state of the slave disks. But it forgets -to check MD_DISK_FAILFAST and MD_DISK_WRITEMOSTLY flags. Then -start_arrays() calls ADD_NEW_DISK ioctl-call and pass the state -without MD_DISK_FAILFAST and MD_DISK_WRITEMOSTLY. - -Currenlty it does not generate any problem because kernel does not -care MD_DISK_FAILFAST or MD_DISK_WRITEMOSTLY flags. - -Reviewed-by: NeilBrown -Signed-off-by: Gioh Kim -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Assemble.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Assemble.c b/Assemble.c -index a79466c..f39c9e1 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1704,6 +1704,9 @@ try_again: - else - desired_state = (1< +Date: Tue, 15 Mar 2022 09:30:30 +0100 +Subject: [PATCH 01/61] Unify error message. +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Provide the same error message for the same error that can occur in Grow.c and super-intel.c. + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Grow.c | 4 ++-- + super-intel.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Grow.c b/Grow.c +index 9c6fc95..9a94720 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -1001,8 +1001,8 @@ int remove_disks_for_takeover(struct supertype *st, + rv = 1; + sysfs_free(arrays); + if (rv) { +- pr_err("Error. Cannot perform operation on /dev/%s\n", st->devnm); +- pr_err("For this operation it MUST be single array in container\n"); ++ pr_err("Error. Cannot perform operation on %s- for this operation " ++ "it MUST be single array in container\n", st->devnm); + return rv; + } + } +diff --git a/super-intel.c b/super-intel.c +index d5fad10..5ffa763 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -11683,8 +11683,8 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, + struct imsm_super *mpb = super->anchor; + + if (mpb->num_raid_devs > 1) { +- pr_err("Error. Cannot perform operation on %s- for this operation it MUST be single array in container\n", +- geo->dev_name); ++ pr_err("Error. Cannot perform operation on %s- for this operation " ++ "it MUST be single array in container\n", geo->dev_name); + change = -1; + } + } +-- +2.35.3 + diff --git a/0002-Document-PART-POLICY-lines.patch b/0002-Document-PART-POLICY-lines.patch deleted file mode 100644 index 4e15437..0000000 --- a/0002-Document-PART-POLICY-lines.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 6b6112842030309c297a521918d1a2e982426fa3 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Fri, 9 Nov 2018 17:12:33 +1100 -Subject: [PATCH 1/5] Document PART-POLICY lines -Git-commit: 6b6112842030309c297a521918d1a2e982426fa3 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -PART-POLICY has been accepted in mdadm.conf since the same -time that POLICY was accepted, but it was never documented. -So add the missing documentation. - -Also fix a bug which would have stopped it from working if -anyone had ever tried to use it. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdadm.conf.5 | 24 +++++++++++++++++++++++- - policy.c | 2 +- - 2 files changed, 24 insertions(+), 2 deletions(-) - -diff --git a/mdadm.conf.5 b/mdadm.conf.5 -index 18512cb0ec7e..47c962ab2071 100644 ---- a/mdadm.conf.5 -+++ b/mdadm.conf.5 -@@ -501,7 +501,7 @@ To update hot plug configuration it is necessary to execute - .B mdadm \-\-udev\-rules - command after changing the config file - --Key words used in the -+Keywords used in the - .I POLICY - line and supported values are: - -@@ -565,6 +565,28 @@ be automatically added to that array (or it's container) - as above and the disk will become a spare in remaining cases - .RE - -+.TP -+.B PART-POLICY -+This is similar to -+.B POLICY -+and accepts the same keyword assignments. It allows a consistent set -+of policies to applied to each of the partitions of a device. -+ -+A -+.B PART-POLICY -+line should set -+.I type=disk -+and identify the path to one or more disk devices. Each partition on -+these disks will be treated according to the -+.I action= -+setting from this line. If a -+.I domain -+is set in the line, then the domain associated with each patition will -+be based on the domain, but with -+.RB \(dq -part N\(dq -+appended, when N is the partition number for the partition that was -+found. -+ - .SH EXAMPLE - DEVICE /dev/sd[bcdjkl]1 - .br -diff --git a/policy.c b/policy.c -index c0d18a7eca5b..258f39317951 100644 ---- a/policy.c -+++ b/policy.c -@@ -300,7 +300,7 @@ static int path_has_part(char *path, char **part) - l--; - if (l < 5 || strncmp(path+l-5, "-part", 5) != 0) - return 0; -- *part = path+l-4; -+ *part = path+l-5; - return 1; - } - --- -2.14.0.rc0.dirty - diff --git a/0002-mdadm-Fix-double-free.patch b/0002-mdadm-Fix-double-free.patch new file mode 100644 index 0000000..b5471a1 --- /dev/null +++ b/0002-mdadm-Fix-double-free.patch @@ -0,0 +1,36 @@ +From 5ce5a15f0bf007e850e15259bba4f53736605fb2 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 25 Mar 2022 12:48:59 +0100 +Subject: [PATCH 02/61] mdadm: Fix double free +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +If there was a size mismatch after creation it would get fixed on grow +in imsm_fix_size_mismatch(), but due to double free "double free or corruption (fasttop)" +error occurs and grow cannot proceed. + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super-intel.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/super-intel.c b/super-intel.c +index 5ffa763..6ff336e 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -11783,9 +11783,8 @@ static int imsm_fix_size_mismatch(struct supertype *st, int subarray_index) + st->update_tail = &st->updates; + } else { + imsm_sync_metadata(st); ++ free(update); + } +- +- free(update); + } + ret_val = 0; + exit: +-- +2.35.3 + diff --git a/0003-Grow_reshape-Add-r0-grow-size-error-message-and-upda.patch b/0003-Grow_reshape-Add-r0-grow-size-error-message-and-upda.patch new file mode 100644 index 0000000..d83114c --- /dev/null +++ b/0003-Grow_reshape-Add-r0-grow-size-error-message-and-upda.patch @@ -0,0 +1,86 @@ +From fea026b4849182fc8413014c81456e7215af28d9 Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Wed, 23 Mar 2022 15:05:19 +0100 +Subject: [PATCH 03/61] Grow_reshape: Add r0 grow size error message and update + man +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Grow size on r0 is not supported for imsm and native metadata. +Add proper error message. +Update man for proper use of --size. +Signed-off-by: Mateusz Kusiak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Grow.c | 6 ++++++ + mdadm.8.in | 19 ++++++++++++------- + 2 files changed, 18 insertions(+), 7 deletions(-) + +diff --git a/Grow.c b/Grow.c +index 9a94720..aa72490 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -1998,6 +1998,12 @@ int Grow_reshape(char *devname, int fd, + goto release; + } + ++ if (array.level == 0) { ++ pr_err("Component size change is not supported for RAID0\n"); ++ rv = 1; ++ goto release; ++ } ++ + if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet, NULL, + devname, APPLY_METADATA_CHANGES, + c->verbose > 0)) { +diff --git a/mdadm.8.in b/mdadm.8.in +index be902db..e2a4242 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -459,7 +459,8 @@ number of spare devices. + + .TP + .BR \-z ", " \-\-size= +-Amount (in Kilobytes) of space to use from each drive in RAID levels 1/4/5/6. ++Amount (in Kilobytes) of space to use from each drive in RAID levels 1/4/5/6/10 ++and for RAID 0 on external metadata. + This must be a multiple of the chunk size, and must leave about 128Kb + of space at the end of the drive for the RAID superblock. + If this is not specified +@@ -478,10 +479,19 @@ To guard against this it can be useful to set the initial size + slightly smaller than the smaller device with the aim that it will + still be larger than any replacement. + ++This option can be used with ++.B \-\-create ++for determining initial size of an array. For external metadata, ++it can be used on a volume, but not on a container itself. ++Setting initial size of ++.B RAID 0 ++array is only valid for external metadata. ++ + This value can be set with + .B \-\-grow +-for RAID level 1/4/5/6 though ++for RAID level 1/4/5/6/10 though + DDF arrays may not be able to support this. ++RAID 0 array size cannot be changed. + If the array was created with a size smaller than the currently + active drives, the extra space can be accessed using + .BR \-\-grow . +@@ -501,11 +511,6 @@ problems the array can be made bigger again with no loss with another + .B "\-\-grow \-\-size=" + command. + +-This value cannot be used when creating a +-.B CONTAINER +-such as with DDF and IMSM metadata, though it perfectly valid when +-creating an array inside a container. +- + .TP + .BR \-Z ", " \-\-array\-size= + This is only meaningful with +-- +2.35.3 + diff --git a/0003-policy-support-devices-with-multiple-paths.patch b/0003-policy-support-devices-with-multiple-paths.patch deleted file mode 100644 index fbf4f86..0000000 --- a/0003-policy-support-devices-with-multiple-paths.patch +++ /dev/null @@ -1,339 +0,0 @@ -From cd72f9d114da206baa01fd56ff2d8ffcc08f3239 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Fri, 9 Nov 2018 17:12:33 +1100 -Subject: [PATCH 2/5] policy: support devices with multiple paths. -Git-commit: cd72f9d114da206baa01fd56ff2d8ffcc08f3239 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -As new releases of Linux some time change the name of -a path, some distros keep "legacy" names as well. This -is useful, but confuses mdadm which assumes each device has -precisely one path. - -So change this assumption: allow a disk to have several -paths, and allow any to match when looking for a policy -which matches a disk. - -Reported-and-tested-by: Mariusz Tkaczyk -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Incremental.c | 5 +- - mdadm.h | 2 +- - policy.c | 163 ++++++++++++++++++++++++++++++++-------------------------- - 3 files changed, 95 insertions(+), 75 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index a4ff7d4bd22d..d4d3c353560d 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -1080,6 +1080,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - struct supertype *st2 = NULL; - char *devname = NULL; - unsigned long long devsectors; -+ char *pathlist[2]; - - if (de->d_ino == 0 || de->d_name[0] == '.' || - (de->d_type != DT_LNK && de->d_type != DT_UNKNOWN)) -@@ -1094,7 +1095,9 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol, - /* This is a partition - skip it */ - goto next; - -- pol2 = path_policy(de->d_name, type_disk); -+ pathlist[0] = de->d_name; -+ pathlist[1] = NULL; -+ pol2 = path_policy(pathlist, type_disk); - - domain_merge(&domlist, pol2, st ? st->ss->name : NULL); - if (domain_test(domlist, pol, st ? st->ss->name : NULL) != 1) -diff --git a/mdadm.h b/mdadm.h -index 387e681aa4ed..705bd9b53b3a 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1247,7 +1247,7 @@ extern void policyline(char *line, char *type); - extern void policy_add(char *type, ...); - extern void policy_free(void); - --extern struct dev_policy *path_policy(char *path, char *type); -+extern struct dev_policy *path_policy(char **paths, char *type); - 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); -diff --git a/policy.c b/policy.c -index 258f39317951..fa67d5594c04 100644 ---- a/policy.c -+++ b/policy.c -@@ -189,15 +189,17 @@ struct dev_policy *pol_find(struct dev_policy *pol, char *name) - return pol; - } - --static char *disk_path(struct mdinfo *disk) -+static char **disk_paths(struct mdinfo *disk) - { - struct stat stb; - int prefix_len; - DIR *by_path; - char symlink[PATH_MAX] = "/dev/disk/by-path/"; -- char nm[PATH_MAX]; -+ char **paths; -+ int cnt = 0; - struct dirent *ent; -- int rv; -+ -+ paths = xmalloc(sizeof(*paths) * (cnt+1)); - - by_path = opendir(symlink); - if (by_path) { -@@ -214,22 +216,13 @@ static char *disk_path(struct mdinfo *disk) - continue; - if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor)) - continue; -- closedir(by_path); -- return xstrdup(ent->d_name); -+ paths[cnt++] = xstrdup(ent->d_name); -+ paths = xrealloc(paths, sizeof(*paths) * (cnt+1)); - } - closedir(by_path); - } -- /* A NULL path isn't really acceptable - use the devname.. */ -- sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor); -- rv = readlink(symlink, nm, sizeof(nm)-1); -- if (rv > 0) { -- char *dname; -- nm[rv] = 0; -- dname = strrchr(nm, '/'); -- if (dname) -- return xstrdup(dname + 1); -- } -- return xstrdup("unknown"); -+ paths[cnt] = NULL; -+ return paths; - } - - char type_part[] = "part"; -@@ -246,18 +239,53 @@ static char *disk_type(struct mdinfo *disk) - return type_disk; - } - --static int pol_match(struct rule *rule, char *path, char *type) -+static int path_has_part(char *path, char **part) -+{ -+ /* check if path ends with "-partNN" and -+ * if it does, place a pointer to "-pathNN" -+ * in 'part'. -+ */ -+ int l; -+ if (!path) -+ return 0; -+ l = strlen(path); -+ while (l > 1 && isdigit(path[l-1])) -+ l--; -+ if (l < 5 || strncmp(path+l-5, "-part", 5) != 0) -+ return 0; -+ *part = path+l-5; -+ return 1; -+} -+ -+static int pol_match(struct rule *rule, char **paths, char *type, char **part) - { -- /* check if this rule matches on path and type */ -+ /* Check if this rule matches on any path and type. -+ * If 'part' is not NULL, then 'path' must end in -partN, which -+ * we ignore for matching, and return in *part on success. -+ */ - int pathok = 0; /* 0 == no path, 1 == match, -1 == no match yet */ - int typeok = 0; - -- while (rule) { -+ for (; rule; rule = rule->next) { - if (rule->name == rule_path) { -+ char *p; -+ int i; - if (pathok == 0) - pathok = -1; -- if (path && fnmatch(rule->value, path, 0) == 0) -- pathok = 1; -+ if (!paths) -+ continue; -+ for (i = 0; paths[i]; i++) { -+ if (part) { -+ if (!path_has_part(paths[i], &p)) -+ continue; -+ *p = '\0'; -+ *part = p+1; -+ } -+ if (fnmatch(rule->value, paths[i], 0) == 0) -+ pathok = 1; -+ if (part) -+ *p = '-'; -+ } - } - if (rule->name == rule_type) { - if (typeok == 0) -@@ -265,7 +293,6 @@ static int pol_match(struct rule *rule, char *path, char *type) - if (type && strcmp(rule->value, type) == 0) - typeok = 1; - } -- rule = rule->next; - } - return pathok >= 0 && typeok >= 0; - } -@@ -286,24 +313,6 @@ static void pol_merge(struct dev_policy **pol, struct rule *rule) - pol_new(pol, r->name, r->value, metadata); - } - --static int path_has_part(char *path, char **part) --{ -- /* check if path ends with "-partNN" and -- * if it does, place a pointer to "-pathNN" -- * in 'part'. -- */ -- int l; -- if (!path) -- return 0; -- l = strlen(path); -- while (l > 1 && isdigit(path[l-1])) -- l--; -- if (l < 5 || strncmp(path+l-5, "-part", 5) != 0) -- return 0; -- *part = path+l-5; -- return 1; --} -- - static void pol_merge_part(struct dev_policy **pol, struct rule *rule, char *part) - { - /* copy any name assignments from rule into pol, appending -@@ -352,7 +361,7 @@ static int config_rules_has_path = 0; - * path_policy() gathers policy information for the - * disk described in the given a 'path' and a 'type'. - */ --struct dev_policy *path_policy(char *path, char *type) -+struct dev_policy *path_policy(char **paths, char *type) - { - struct pol_rule *rules; - struct dev_policy *pol = NULL; -@@ -361,27 +370,24 @@ struct dev_policy *path_policy(char *path, char *type) - rules = config_rules; - - while (rules) { -- char *part; -+ char *part = NULL; - if (rules->type == rule_policy) -- if (pol_match(rules->rule, path, type)) -+ if (pol_match(rules->rule, paths, type, NULL)) - pol_merge(&pol, rules->rule); - if (rules->type == rule_part && strcmp(type, type_part) == 0) -- if (path_has_part(path, &part)) { -- *part = 0; -- if (pol_match(rules->rule, path, type_disk)) -- pol_merge_part(&pol, rules->rule, part+1); -- *part = '-'; -- } -+ if (pol_match(rules->rule, paths, type_disk, &part)) -+ pol_merge_part(&pol, rules->rule, part); - rules = rules->next; - } - - /* Now add any metadata-specific internal knowledge - * about this path - */ -- for (i=0; path && superlist[i]; i++) -+ for (i=0; paths[0] && superlist[i]; i++) - if (superlist[i]->get_disk_controller_domain) { - const char *d = -- superlist[i]->get_disk_controller_domain(path); -+ superlist[i]->get_disk_controller_domain( -+ paths[0]); - if (d) - pol_new(&pol, pol_domain, d, superlist[i]->name); - } -@@ -400,22 +406,34 @@ void pol_add(struct dev_policy **pol, - pol_dedup(*pol); - } - -+static void free_paths(char **paths) -+{ -+ int i; -+ -+ if (!paths) -+ return; -+ -+ for (i = 0; paths[i]; i++) -+ free(paths[i]); -+ free(paths); -+} -+ - /* - * disk_policy() gathers policy information for the - * disk described in the given mdinfo (disk.{major,minor}). - */ - struct dev_policy *disk_policy(struct mdinfo *disk) - { -- char *path = NULL; -+ char **paths = NULL; - char *type = disk_type(disk); - struct dev_policy *pol = NULL; - - if (config_rules_has_path) -- path = disk_path(disk); -+ paths = disk_paths(disk); - -- pol = path_policy(path, type); -+ pol = path_policy(paths, type); - -- free(path); -+ free_paths(paths); - return pol; - } - -@@ -756,27 +774,26 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array) - { - char path[PATH_MAX]; - FILE *f = NULL; -- char *id_path = disk_path(disk); -- int rv; -+ char **id_paths = disk_paths(disk); -+ int i; -+ int rv = 0; - -- if (!id_path) -- return 0; -+ for (i = 0; id_paths[i]; i++) { -+ snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_paths[i]); -+ f = fopen(path, "r"); -+ if (!f) -+ continue; - -- snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path); -- f = fopen(path, "r"); -- if (!f) { -- free(id_path); -- return 0; -+ rv = fscanf(f, " %s %x:%x:%x:%x\n", -+ array->metadata, -+ array->uuid, -+ array->uuid+1, -+ array->uuid+2, -+ array->uuid+3); -+ fclose(f); -+ break; - } -- -- rv = fscanf(f, " %s %x:%x:%x:%x\n", -- array->metadata, -- array->uuid, -- array->uuid+1, -- array->uuid+2, -- array->uuid+3); -- fclose(f); -- free(id_path); -+ free_paths(id_paths); - return rv == 5; - } - --- -2.14.0.rc0.dirty - diff --git a/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch b/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch deleted file mode 100644 index 69e62e2..0000000 --- a/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 4199d3c629c14866505923d19fa50017ee92d2e1 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Wed, 5 Dec 2018 16:35:00 +1100 -Subject: [PATCH 3/5] mdcheck: add systemd unit files to run mdcheck. -Git-commit: 4199d3c629c14866505923d19fa50017ee92d2e1 -Patch-mainline: mdadm-4.1+ -References: bsc#1115407 - -Having the mdcheck script is not use if is never run. -This patch adds systemd unit files so that it can easily -be run on the first Sunday of each month for 6 hours, -then on every subsequent morning until the check is -finished. - -The units still need to be enabled with - systemctl enable mdcheck_start.timer - -The timer will only actually be started when an array -which might need it becomes active. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - Makefile | 5 ++++- - systemd/mdcheck_continue.service | 18 ++++++++++++++++++ - systemd/mdcheck_continue.timer | 13 +++++++++++++ - systemd/mdcheck_start.service | 17 +++++++++++++++++ - systemd/mdcheck_start.timer | 15 +++++++++++++++ - 5 files changed, 67 insertions(+), 1 deletion(-) - create mode 100644 systemd/mdcheck_continue.service - create mode 100644 systemd/mdcheck_continue.timer - create mode 100644 systemd/mdcheck_start.service - create mode 100644 systemd/mdcheck_start.timer - -diff --git a/Makefile b/Makefile -index 2767ac68396d..afb62cc6e3a6 100644 ---- a/Makefile -+++ b/Makefile -@@ -276,7 +276,10 @@ install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid - - install-systemd: systemd/mdmon@.service - @for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \ -- mdadm-last-resort@.service mdadm-grow-continue@.service; \ -+ mdadm-last-resort@.service mdadm-grow-continue@.service \ -+ mdcheck_start.timer mdcheck_start.service \ -+ mdcheck_continue.timer mdcheck_continue.service \ -+ ; \ - do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \ - $(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \ - $(INSTALL) -D -m 644 .install.tmp.2 $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \ -diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service -new file mode 100644 -index 000000000000..592c60798f82 ---- /dev/null -+++ b/systemd/mdcheck_continue.service -@@ -0,0 +1,18 @@ -+# This file is part of mdadm. -+# -+# mdadm is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+[Unit] -+Description=MD array scrubbing - continuation -+ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_* -+ -+[Service] -+Type=oneshot -+Environment= MDADM_CHECK_DURATION='"6 hours"' -+EnvironmentFile=-/run/sysconfig/mdadm -+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh -+ExecStart=/usr/share/mdadm/mdcheck --continue --duration $MDADM_CHECK_DURATION -+ -diff --git a/systemd/mdcheck_continue.timer b/systemd/mdcheck_continue.timer -new file mode 100644 -index 000000000000..3ccfd7858a3f ---- /dev/null -+++ b/systemd/mdcheck_continue.timer -@@ -0,0 +1,13 @@ -+# This file is part of mdadm. -+# -+# mdadm is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+[Unit] -+Description=MD array scrubbing - continuation -+ -+[Timer] -+OnCalendar= 1:05:00 -+ -diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service -new file mode 100644 -index 000000000000..812141bb5c9a ---- /dev/null -+++ b/systemd/mdcheck_start.service -@@ -0,0 +1,17 @@ -+# This file is part of mdadm. -+# -+# mdadm is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+[Unit] -+Description=MD array scrubbing -+Wants=mdcheck_continue.timer -+ -+[Service] -+Type=oneshot -+Environment= MDADM_CHECK_DURATION='"6 hours"' -+EnvironmentFile=-/run/sysconfig/mdadm -+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh -+ExecStart=/usr/share/mdadm/mdcheck --duration $MDADM_CHECK_DURATION -diff --git a/systemd/mdcheck_start.timer b/systemd/mdcheck_start.timer -new file mode 100644 -index 000000000000..64807362d649 ---- /dev/null -+++ b/systemd/mdcheck_start.timer -@@ -0,0 +1,15 @@ -+# This file is part of mdadm. -+# -+# mdadm is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+[Unit] -+Description=MD array scrubbing -+ -+[Timer] -+OnCalendar=Sun *-*-1..7 1:00:00 -+ -+[Install] -+WantedBy= mdmonitor.service --- -2.14.0.rc0.dirty - diff --git a/0004-udev-adapt-rules-to-systemd-v247.patch b/0004-udev-adapt-rules-to-systemd-v247.patch new file mode 100644 index 0000000..d98b756 --- /dev/null +++ b/0004-udev-adapt-rules-to-systemd-v247.patch @@ -0,0 +1,70 @@ +From cf9a109209aad285372b67306d54118af6fc522b Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Fri, 14 Jan 2022 16:44:33 +0100 +Subject: [PATCH 04/61] udev: adapt rules to systemd v247 +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +New events have been added in kernel 4.14 ("bind" and "unbind"). +Systemd maintainer suggests to modify "add|change" branches. +This patches implements their suggestions. There is no issue yet because +new event types are not used in md. + +Please see systemd announcement for details[1]. + +[1] https://lists.freedesktop.org/archives/systemd-devel/2020-November/045646.html + +Signed-off-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + udev-md-raid-arrays.rules | 2 +- + udev-md-raid-assembly.rules | 5 +++-- + udev-md-raid-safe-timeouts.rules | 2 +- + 3 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules +index 13c9076..2967ace 100644 +--- a/udev-md-raid-arrays.rules ++++ b/udev-md-raid-arrays.rules +@@ -3,7 +3,7 @@ + SUBSYSTEM!="block", GOTO="md_end" + + # handle md arrays +-ACTION!="add|change", GOTO="md_end" ++ACTION=="remove", GOTO="md_end" + KERNEL!="md*", GOTO="md_end" + + # partitions have no md/{array_state,metadata_version}, but should not +diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules +index d668cdd..39b4344 100644 +--- a/udev-md-raid-assembly.rules ++++ b/udev-md-raid-assembly.rules +@@ -30,8 +30,9 @@ LABEL="md_inc" + + # remember you can limit what gets auto/incrementally assembled by + # mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' +-ACTION=="add|change", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot $env{DEVLINKS}" +-ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer" ++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" + +diff --git a/udev-md-raid-safe-timeouts.rules b/udev-md-raid-safe-timeouts.rules +index 12bdcaa..2e185ce 100644 +--- a/udev-md-raid-safe-timeouts.rules ++++ b/udev-md-raid-safe-timeouts.rules +@@ -50,7 +50,7 @@ ENV{DEVTYPE}!="partition", GOTO="md_timeouts_end" + + IMPORT{program}="/sbin/mdadm --examine --export $devnode" + +-ACTION=="add|change", \ ++ACTION!="remove", \ + ENV{ID_FS_TYPE}=="linux_raid_member", \ + ENV{MD_LEVEL}=="raid[1-9]*", \ + TEST=="/sys/block/$parent/device/timeout", \ +-- +2.35.3 + diff --git a/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch b/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch deleted file mode 100644 index 87e7bc6..0000000 --- a/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 7cd7e91ab3de5aa75dc963cb08b0618c1885cf0d Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Wed, 5 Dec 2018 16:35:00 +1100 -Subject: [PATCH 4/5] Monitor: add system timer to run --oneshot periodically -Git-commit: 7cd7e91ab3de5aa75dc963cb08b0618c1885cf0d -Patch-mainline: mdadm-4.1+ -References: bsc#1115407 - -"mdadm --monitor --oneshot" can be used to get a warning -if there are any degraded arrays. It can be helpful to get -this warning periodically while the condition persists. - -This patch add a systemd service and timer which can -be enabled with - systemctl enable mdmonitor-oneshot.service - -and will then provide daily warnings. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - Makefile | 1 + - systemd/mdmonitor-oneshot.service | 15 +++++++++++++++ - systemd/mdmonitor-oneshot.timer | 15 +++++++++++++++ - 3 files changed, 31 insertions(+) - create mode 100644 systemd/mdmonitor-oneshot.service - create mode 100644 systemd/mdmonitor-oneshot.timer - -diff --git a/Makefile b/Makefile -index afb62cc6e3a6..dfe00b0a0be8 100644 ---- a/Makefile -+++ b/Makefile -@@ -279,6 +279,7 @@ install-systemd: systemd/mdmon@.service - mdadm-last-resort@.service mdadm-grow-continue@.service \ - mdcheck_start.timer mdcheck_start.service \ - mdcheck_continue.timer mdcheck_continue.service \ -+ mdmonitor-oneshot.timer mdmonitor-oneshot.service \ - ; \ - do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \ - $(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \ -diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service -new file mode 100644 -index 000000000000..fd469b12cc78 ---- /dev/null -+++ b/systemd/mdmonitor-oneshot.service -@@ -0,0 +1,15 @@ -+# This file is part of mdadm. -+# -+# mdadm is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+[Unit] -+Description=Reminder for degraded MD arrays -+ -+[Service] -+Environment= MDADM_MONITOR_ARGS=--scan -+EnvironmentFile=-/run/sysconfig/mdadm -+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh -+ExecStart=BINDIR/mdadm --monitor --oneshot $MDADM_MONITOR_ARGS -diff --git a/systemd/mdmonitor-oneshot.timer b/systemd/mdmonitor-oneshot.timer -new file mode 100644 -index 000000000000..cb54bdaa8897 ---- /dev/null -+++ b/systemd/mdmonitor-oneshot.timer -@@ -0,0 +1,15 @@ -+# This file is part of mdadm. -+# -+# mdadm is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+[Unit] -+Description=Reminder for degraded MD arrays -+ -+[Timer] -+OnCalendar= 2:00:00 -+ -+[Install] -+WantedBy= mdmonitor.service --- -2.14.0.rc0.dirty - diff --git a/0005-Replace-error-prone-signal-with-sigaction.patch b/0005-Replace-error-prone-signal-with-sigaction.patch new file mode 100644 index 0000000..a60128a --- /dev/null +++ b/0005-Replace-error-prone-signal-with-sigaction.patch @@ -0,0 +1,255 @@ +From 83a379cfbd283b387919fe05d44eb4c49e155ad6 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Mon, 21 Feb 2022 13:05:20 +0100 +Subject: [PATCH 05/61] Replace error prone signal() with sigaction() +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Up to this date signal() was used which implementation could vary [1]. +Sigaction() call is preferred. This commit introduces replacement +from signal() to sigaction() by the use of signal_s() wrapper. +Also remove redundant signal.h header includes. + +[1] https://man7.org/linux/man-pages/man2/signal.2.html + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Grow.c | 4 ++-- + Monitor.c | 5 +++-- + managemon.c | 1 - + mdadm.h | 22 ++++++++++++++++++++++ + mdmon.c | 1 - + monitor.c | 1 - + probe_roms.c | 6 +++--- + raid6check.c | 25 +++++++++++++++---------- + util.c | 1 - + 9 files changed, 45 insertions(+), 21 deletions(-) + +diff --git a/Grow.c b/Grow.c +index aa72490..18c5719 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -26,7 +26,6 @@ + #include + #include + #include +-#include + #include + + #if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN) +@@ -3566,7 +3565,8 @@ started: + fd = -1; + mlockall(MCL_FUTURE); + +- signal(SIGTERM, catch_term); ++ if (signal_s(SIGTERM, catch_term) == SIG_ERR) ++ goto release; + + if (st->ss->external) { + /* metadata handler takes it from here */ +diff --git a/Monitor.c b/Monitor.c +index 30c031a..c0ab541 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -26,7 +26,6 @@ + #include "md_p.h" + #include "md_u.h" + #include +-#include + #include + #include + #ifndef NO_LIBUDEV +@@ -435,8 +434,10 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info) + if (mp) { + FILE *mdstat; + char hname[256]; ++ + gethostname(hname, sizeof(hname)); +- signal(SIGPIPE, SIG_IGN); ++ signal_s(SIGPIPE, SIG_IGN); ++ + if (info->mailfrom) + fprintf(mp, "From: %s\n", info->mailfrom); + else +diff --git a/managemon.c b/managemon.c +index bb7334c..0e9bdf0 100644 +--- a/managemon.c ++++ b/managemon.c +@@ -106,7 +106,6 @@ + #include "mdmon.h" + #include + #include +-#include + + static void close_aa(struct active_array *aa) + { +diff --git a/mdadm.h b/mdadm.h +index c7268a7..26e7e5c 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -46,6 +46,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); + #include + #include + #include ++#include + /* Newer glibc requires sys/sysmacros.h directly for makedev() */ + #include + #ifdef __dietlibc__ +@@ -1729,6 +1730,27 @@ static inline char *to_subarray(struct mdstat_ent *ent, char *container) + return &ent->metadata_version[10+strlen(container)+1]; + } + ++/** ++ * signal_s() - Wrapper for sigaction() with signal()-like interface. ++ * @sig: The signal to set the signal handler to. ++ * @handler: The signal handler. ++ * ++ * Return: previous handler or SIG_ERR on failure. ++ */ ++static inline sighandler_t signal_s(int sig, sighandler_t handler) ++{ ++ struct sigaction new_act; ++ struct sigaction old_act; ++ ++ new_act.sa_handler = handler; ++ new_act.sa_flags = 0; ++ ++ if (sigaction(sig, &new_act, &old_act) == 0) ++ return old_act.sa_handler; ++ ++ return SIG_ERR; ++} ++ + #ifdef DEBUG + #define dprintf(fmt, arg...) \ + fprintf(stderr, "%s: %s: "fmt, Name, __func__, ##arg) +diff --git a/mdmon.c b/mdmon.c +index c71e62c..5570574 100644 +--- a/mdmon.c ++++ b/mdmon.c +@@ -56,7 +56,6 @@ + #include + #include + #include +-#include + #include + #ifdef USE_PTHREADS + #include +diff --git a/monitor.c b/monitor.c +index e0d3be6..b877e59 100644 +--- a/monitor.c ++++ b/monitor.c +@@ -22,7 +22,6 @@ + #include "mdmon.h" + #include + #include +-#include + + static char *array_states[] = { + "clear", "inactive", "suspended", "readonly", "read-auto", +diff --git a/probe_roms.c b/probe_roms.c +index 7ea04c7..94c80c2 100644 +--- a/probe_roms.c ++++ b/probe_roms.c +@@ -22,7 +22,6 @@ + #include "probe_roms.h" + #include "mdadm.h" + #include +-#include + #include + #include + #include +@@ -69,7 +68,8 @@ static int probe_address16(const __u16 *ptr, __u16 *val) + + void probe_roms_exit(void) + { +- signal(SIGBUS, SIG_DFL); ++ signal_s(SIGBUS, SIG_DFL); ++ + if (rom_fd >= 0) { + close(rom_fd); + rom_fd = -1; +@@ -98,7 +98,7 @@ int probe_roms_init(unsigned long align) + if (roms_init()) + return -1; + +- if (signal(SIGBUS, sigbus) == SIG_ERR) ++ if (signal_s(SIGBUS, sigbus) == SIG_ERR) + rc = -1; + if (rc == 0) { + fd = open("/dev/mem", O_RDONLY); +diff --git a/raid6check.c b/raid6check.c +index a8e6005..9947776 100644 +--- a/raid6check.c ++++ b/raid6check.c +@@ -24,7 +24,6 @@ + + #include "mdadm.h" + #include +-#include + #include + + #define CHECK_PAGE_BITS (12) +@@ -130,30 +129,36 @@ void raid6_stats(int *disk, int *results, int raid_disks, int chunk_size) + } + + int lock_stripe(struct mdinfo *info, unsigned long long start, +- int chunk_size, int data_disks, sighandler_t *sig) { ++ int chunk_size, int data_disks, sighandler_t *sig) ++{ + int rv; ++ ++ sig[0] = signal_s(SIGTERM, SIG_IGN); ++ sig[1] = signal_s(SIGINT, SIG_IGN); ++ sig[2] = signal_s(SIGQUIT, SIG_IGN); ++ ++ if (sig[0] == SIG_ERR || sig[1] == SIG_ERR || sig[2] == SIG_ERR) ++ return 1; ++ + if(mlockall(MCL_CURRENT | MCL_FUTURE) != 0) { + return 2; + } + +- sig[0] = signal(SIGTERM, SIG_IGN); +- sig[1] = signal(SIGINT, SIG_IGN); +- sig[2] = signal(SIGQUIT, SIG_IGN); +- + rv = sysfs_set_num(info, NULL, "suspend_lo", start * chunk_size * data_disks); + rv |= sysfs_set_num(info, NULL, "suspend_hi", (start + 1) * chunk_size * data_disks); + return rv * 256; + } + +-int unlock_all_stripes(struct mdinfo *info, sighandler_t *sig) { ++int unlock_all_stripes(struct mdinfo *info, sighandler_t *sig) ++{ + int rv; + rv = sysfs_set_num(info, NULL, "suspend_lo", 0x7FFFFFFFFFFFFFFFULL); + rv |= sysfs_set_num(info, NULL, "suspend_hi", 0); + rv |= sysfs_set_num(info, NULL, "suspend_lo", 0); + +- signal(SIGQUIT, sig[2]); +- signal(SIGINT, sig[1]); +- signal(SIGTERM, sig[0]); ++ signal_s(SIGQUIT, sig[2]); ++ signal_s(SIGINT, sig[1]); ++ signal_s(SIGTERM, sig[0]); + + if(munlockall() != 0) + return 3; +diff --git a/util.c b/util.c +index 3d05d07..cc94f96 100644 +--- a/util.c ++++ b/util.c +@@ -35,7 +35,6 @@ + #include + #include + #include +-#include + #include + + +-- +2.35.3 + diff --git a/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch b/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch deleted file mode 100644 index e391d8b..0000000 --- a/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch +++ /dev/null @@ -1,88 +0,0 @@ -From d7a1fda2769ba272d89de6caeab35d52b73a9c3c Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 17 Oct 2018 12:11:41 +0200 -Subject: [PATCH 5/5] imsm: update metadata correctly while raid10 double - degradation -Git-commit: d7a1fda2769ba272d89de6caeab35d52b73a9c3c -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Mdmon calls end_migration() when map state changes from normal to -degraded. It is not valid because in raid 10 double degradation case -mdmon breaks checkpointing but array is still rebuilding. -In this case mdmon has to mark map as degraded and continues marking -recovery checkpoint in metadata. Migration can be finished only if newly -failed device is a rebuilding device. - -Add catching double degraded to degraded transition. Migration is -finished but map state doesn't change, array is still degraded. - -Update failed_disk_num correctly. If double degradation -happens rebuild will start on the lowest slot, but this variable points -to the first failed slot. If second fail happens while rebuild this -variable shouldn't be updated until rebuild is not finished. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 25 +++++++++++++++++++------ - 1 file changed, 19 insertions(+), 6 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 6438987b778c..d2035ccd8270 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -8136,7 +8136,8 @@ static int mark_failure(struct intel_super *super, - set_imsm_ord_tbl_ent(map2, slot2, - idx | IMSM_ORD_REBUILD); - } -- if (map->failed_disk_num == 0xff) -+ if (map->failed_disk_num == 0xff || -+ (!is_rebuilding(dev) && map->failed_disk_num > slot)) - map->failed_disk_num = slot; - - clear_disk_badblocks(super->bbm_log, ord_to_idx(ord)); -@@ -8558,13 +8559,25 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - break; - } - if (is_rebuilding(dev)) { -- dprintf_cont("while rebuilding."); -+ dprintf_cont("while rebuilding "); - if (map->map_state != map_state) { -- dprintf_cont(" Map state change"); -- end_migration(dev, super, map_state); -+ dprintf_cont("map state change "); -+ if (n == map->failed_disk_num) { -+ dprintf_cont("end migration"); -+ end_migration(dev, super, map_state); -+ } else { -+ dprintf_cont("raid10 double degradation, map state change"); -+ map->map_state = map_state; -+ } - super->updates_pending++; -- } else if (!rebuild_done) { -+ } else if (!rebuild_done) - break; -+ else if (n == map->failed_disk_num) { -+ /* r10 double degraded to degraded transition */ -+ dprintf_cont("raid10 double degradation end migration"); -+ end_migration(dev, super, map_state); -+ a->last_checkpoint = 0; -+ super->updates_pending++; - } - - /* check if recovery is really finished */ -@@ -8575,7 +8588,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - } - if (recovery_not_finished) { - dprintf_cont("\n"); -- dprintf("Rebuild has not finished yet, state not changed"); -+ dprintf_cont("Rebuild has not finished yet, map state changes only if raid10 double degradation happens"); - if (a->last_checkpoint < mdi->recovery_start) { - a->last_checkpoint = - mdi->recovery_start; --- -2.14.0.rc0.dirty - diff --git a/0006-mdadm-Respect-config-file-location-in-man.patch b/0006-mdadm-Respect-config-file-location-in-man.patch new file mode 100644 index 0000000..2b476d6 --- /dev/null +++ b/0006-mdadm-Respect-config-file-location-in-man.patch @@ -0,0 +1,126 @@ +From e9dd5644843e2013a7dd1a8a5da2b9fa35837416 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 18 Mar 2022 09:26:04 +0100 +Subject: [PATCH 06/61] mdadm: Respect config file location in man +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Default config file location could differ depending on OS (e.g. Debian family). +This patch takes default config file into consideration when creating mdadm.man +file as well as mdadm.conf.man. + +Rename mdadm.conf.5 to mdadm.conf.5.in. Now mdadm.conf.5 is generated automatically. + +Signed-off-by: Lukasz Florczak +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + .gitignore | 1 + + Makefile | 7 ++++++- + mdadm.8.in | 16 ++++++++-------- + mdadm.conf.5 => mdadm.conf.5.in | 2 +- + 4 files changed, 16 insertions(+), 10 deletions(-) + rename mdadm.conf.5 => mdadm.conf.5.in (99%) + +diff --git a/.gitignore b/.gitignore +index 217fe76..8d791c6 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -3,6 +3,7 @@ + /*-stamp + /mdadm + /mdadm.8 ++/mdadm.conf.5 + /mdadm.udeb + /mdassemble + /mdmon +diff --git a/Makefile b/Makefile +index 2a51d81..bf12603 100644 +--- a/Makefile ++++ b/Makefile +@@ -227,7 +227,12 @@ raid6check : raid6check.o mdadm.h $(CHECK_OBJS) + + mdadm.8 : mdadm.8.in + sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' \ +- -e 's,{MAP_PATH},$(MAP_PATH),g' mdadm.8.in > mdadm.8 ++ -e 's,{MAP_PATH},$(MAP_PATH),g' -e 's,{CONFFILE},$(CONFFILE),g' \ ++ -e 's,{CONFFILE2},$(CONFFILE2),g' mdadm.8.in > mdadm.8 ++ ++mdadm.conf.5 : mdadm.conf.5.in ++ sed -e 's,{CONFFILE},$(CONFFILE),g' \ ++ -e 's,{CONFFILE2},$(CONFFILE2),g' mdadm.conf.5.in > mdadm.conf.5 + + mdadm.man : mdadm.8 + man -l mdadm.8 > mdadm.man +diff --git a/mdadm.8.in b/mdadm.8.in +index e2a4242..8b21ffd 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -267,13 +267,13 @@ the exact meaning of this option in different contexts. + .TP + .BR \-c ", " \-\-config= + Specify the config file or directory. Default is to use +-.B /etc/mdadm.conf ++.B {CONFFILE} + and +-.BR /etc/mdadm.conf.d , ++.BR {CONFFILE}.d , + or if those are missing then +-.B /etc/mdadm/mdadm.conf ++.B {CONFFILE2} + and +-.BR /etc/mdadm/mdadm.conf.d . ++.BR {CONFFILE2}.d . + If the config file given is + .B "partitions" + then nothing will be read, but +@@ -2014,9 +2014,9 @@ The config file is only used if explicitly named with + or requested with (a possibly implicit) + .BR \-\-scan . + In the later case, +-.B /etc/mdadm.conf ++.B {CONFFILE} + or +-.B /etc/mdadm/mdadm.conf ++.B {CONFFILE2} + is used. + + If +@@ -3344,7 +3344,7 @@ uses this to find arrays when + is given in Misc mode, and to monitor array reconstruction + on Monitor mode. + +-.SS /etc/mdadm.conf ++.SS {CONFFILE} (or {CONFFILE2}) + + The config file lists which devices may be scanned to see if + they contain MD super block, and gives identifying information +@@ -3352,7 +3352,7 @@ they contain MD super block, and gives identifying information + .BR mdadm.conf (5) + for more details. + +-.SS /etc/mdadm.conf.d ++.SS {CONFFILE}.d (or {CONFFILE2}.d) + + A directory containing configuration files which are read in lexical + order. +diff --git a/mdadm.conf.5 b/mdadm.conf.5.in +similarity index 99% +rename from mdadm.conf.5 +rename to mdadm.conf.5.in +index 74a21c5..83edd00 100644 +--- a/mdadm.conf.5 ++++ b/mdadm.conf.5.in +@@ -8,7 +8,7 @@ + .SH NAME + mdadm.conf \- configuration for management of Software RAID with mdadm + .SH SYNOPSIS +-/etc/mdadm.conf ++{CONFFILE} + .SH DESCRIPTION + .PP + .I mdadm +-- +2.35.3 + diff --git a/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch b/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch deleted file mode 100644 index 11e76ce..0000000 --- a/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 563ac108659980b3d1e226fe416254a86656235f Mon Sep 17 00:00:00 2001 -From: Gioh Kim -Date: Tue, 6 Nov 2018 16:20:17 +0100 -Subject: [PATCH] Assemble: mask FAILFAST and WRITEMOSTLY flags when finding - the most recent device -Git-commit: 563ac108659980b3d1e226fe416254a86656235f -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -If devices[].i.disk.state has MD_DISK_FAILFAST or MD_DISK_WRITEMOSTLY -flag, it cannot be the most recent device. Both flags should be masked -before checking the state. - -Reviewed-by: NeilBrown -Signed-off-by: Gioh Kim -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Assemble.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/Assemble.c b/Assemble.c -index f39c9e1..9f75c68 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -578,6 +578,7 @@ static int load_devices(struct devs *devices, char *devmap, - struct supertype *tst; - int i; - int dfd; -+ int disk_state; - - if (tmpdev->used != 1) - continue; -@@ -711,7 +712,9 @@ static int load_devices(struct devs *devices, char *devmap, - devices[devcnt].i.disk.major = major(stb.st_rdev); - devices[devcnt].i.disk.minor = minor(stb.st_rdev); - -- if (devices[devcnt].i.disk.state == 6) { -+ disk_state = devices[devcnt].i.disk.state & ~((1< devices[most_recent].i.events) { --- -2.25.0 - diff --git a/0007-mdadm-Update-ReadMe.patch b/0007-mdadm-Update-ReadMe.patch new file mode 100644 index 0000000..ded0df7 --- /dev/null +++ b/0007-mdadm-Update-ReadMe.patch @@ -0,0 +1,50 @@ +From c23400377bb3d8e98e810cd92dba478dac1dff82 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 18 Mar 2022 09:26:05 +0100 +Subject: [PATCH 07/61] mdadm: Update ReadMe +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Instead of hardcoded config file path give reference to config manual. + +Add missing monitordelay and homecluster parameters. + +Signed-off-by: Lukasz Florczak +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + ReadMe.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/ReadMe.c b/ReadMe.c +index 8139976..8f873c4 100644 +--- a/ReadMe.c ++++ b/ReadMe.c +@@ -613,7 +613,6 @@ char Help_incr[] = + ; + + char Help_config[] = +-"The /etc/mdadm.conf config file:\n\n" + " The config file contains, apart from blank lines and comment lines that\n" + " start with a hash(#), array lines, device lines, and various\n" + " configuration lines.\n" +@@ -636,10 +635,12 @@ char Help_config[] = + " than a device must match all of them to be considered.\n" + "\n" + " Other configuration lines include:\n" +-" mailaddr, mailfrom, program used for --monitor mode\n" +-" create, auto used when creating device names in /dev\n" +-" homehost, policy, part-policy used to guide policy in various\n" +-" situations\n" ++" mailaddr, mailfrom, program, monitordelay used for --monitor mode\n" ++" create, auto used when creating device names in /dev\n" ++" homehost, homecluster, policy, part-policy used to guide policy in various\n" ++" situations\n" ++"\n" ++"For more details see mdadm.conf(5).\n" + "\n" + ; + +-- +2.35.3 + diff --git a/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch b/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch deleted file mode 100644 index dfba67d..0000000 --- a/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 085df42259cba7863cd6ebe5cd0d8492ac5b869e Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 6 Dec 2018 10:35:41 +1100 -Subject: [PATCH] Grow: avoid overflow in compute_backup_blocks() -Git-commit: 085df42259cba7863cd6ebe5cd0d8492ac5b869e -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -With a chunk size of 16Meg and data drive count of 8, -this calculate can easily overflow the 'int' type that -is used for the multiplications. -So force it to use "long" instead. - -Reported-and-tested-by: Ed Spiridonov -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Grow.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Grow.c b/Grow.c -index 4436a4d6bd4c..76f82c075e38 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -1196,7 +1196,8 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk, - /* Find GCD */ - a = GCD(a, b); - /* LCM == product / GCD */ -- blocks = (ochunk/512) * (nchunk/512) * odata * ndata / a; -+ blocks = (unsigned long)(ochunk/512) * (unsigned long)(nchunk/512) * -+ odata * ndata / a; - - return blocks; - } --- -2.14.0.rc0.dirty - diff --git a/0008-mdadm-Update-config-man-regarding-default-files-and-.patch b/0008-mdadm-Update-config-man-regarding-default-files-and-.patch new file mode 100644 index 0000000..b1e8ae5 --- /dev/null +++ b/0008-mdadm-Update-config-man-regarding-default-files-and-.patch @@ -0,0 +1,205 @@ +From 24e075c659d0a8718aabefe5af4c97195a188af7 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 18 Mar 2022 09:26:06 +0100 +Subject: [PATCH 08/61] mdadm: Update config man regarding default files and + multi-keyword behavior +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Simplify default and alternative config file and directory location references +from mdadm(8) as references to mdadm.conf(5). Add FILE section in config man +and explain order and conditions in which default and alternative config files +and directories are used. + +Update config man behavior regarding parsing order when multiple keywords/config +files are involved. + +Signed-off-by: Lukasz Florczak +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + mdadm.8.in | 30 +++++++++-------------- + mdadm.conf.5.in | 65 ++++++++++++++++++++++++++++++++++++++++++++----- + 2 files changed, 71 insertions(+), 24 deletions(-) + +diff --git a/mdadm.8.in b/mdadm.8.in +index 8b21ffd..0be02e4 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -266,14 +266,11 @@ the exact meaning of this option in different contexts. + + .TP + .BR \-c ", " \-\-config= +-Specify the config file or directory. Default is to use +-.B {CONFFILE} +-and +-.BR {CONFFILE}.d , +-or if those are missing then +-.B {CONFFILE2} +-and +-.BR {CONFFILE2}.d . ++Specify the config file or directory. If not specified, default config file ++and default conf.d directory will be used. See ++.BR mdadm.conf (5) ++for more details. ++ + If the config file given is + .B "partitions" + then nothing will be read, but +@@ -2013,11 +2010,9 @@ The config file is only used if explicitly named with + .B \-\-config + or requested with (a possibly implicit) + .BR \-\-scan . +-In the later case, +-.B {CONFFILE} +-or +-.B {CONFFILE2} +-is used. ++In the later case, default config file is used. See ++.BR mdadm.conf (5) ++for more details. + + If + .B \-\-scan +@@ -3346,16 +3341,15 @@ on Monitor mode. + + .SS {CONFFILE} (or {CONFFILE2}) + +-The config file lists which devices may be scanned to see if +-they contain MD super block, and gives identifying information +-(e.g. UUID) about known MD arrays. See ++Default config file. See + .BR mdadm.conf (5) + for more details. + + .SS {CONFFILE}.d (or {CONFFILE2}.d) + +-A directory containing configuration files which are read in lexical +-order. ++Default directory containing configuration files. See ++.BR mdadm.conf (5) ++for more details. + + .SS {MAP_PATH} + When +diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in +index 83edd00..dd331a6 100644 +--- a/mdadm.conf.5.in ++++ b/mdadm.conf.5.in +@@ -88,7 +88,8 @@ but only the major and minor device numbers. It scans + .I /dev + to find the name that matches the numbers. + +-If no DEVICE line is present, then "DEVICE partitions containers" is assumed. ++If no DEVICE line is present in any config file, ++then "DEVICE partitions containers" is assumed. + + For example: + .IP +@@ -272,6 +273,10 @@ catenated with spaces to form the address. + Note that this value cannot be set via the + .I mdadm + commandline. It is only settable via the config file. ++There should only be one ++.B MAILADDR ++line and it should have only one address. Any subsequent addresses ++are silently ignored. + + .TP + .B PROGRAM +@@ -286,7 +291,8 @@ device. + + There should only be one + .B program +-line and it should be give only one program. ++line and it should be given only one program. Any subsequent programs ++are silently ignored. + + + .TP +@@ -295,7 +301,14 @@ The + .B create + line gives default values to be used when creating arrays, new members + of arrays, and device entries for arrays. +-These include: ++ ++There should only be one ++.B create ++line. Any subsequent lines will override the previous settings. ++ ++Keywords used in the ++.I CREATE ++line and supported values are: + + .RS 4 + .TP +@@ -475,8 +488,8 @@ The known metadata types are + + .B AUTO + should be given at most once. Subsequent lines are silently ignored. +-Thus an earlier config file in a config directory will over-ride +-the setting in a later config file. ++Thus a later config file in a config directory will not overwrite ++the setting in an earlier config file. + + .TP + .B POLICY +@@ -594,6 +607,7 @@ The + line lists custom values of MD device's sysfs attributes which will be + stored in sysfs after the array is assembled. Multiple lines are allowed and each + line has to contain the uuid or the name of the device to which it relates. ++Lines are applied in reverse order. + .RS 4 + .TP + .B uuid= +@@ -621,7 +635,46 @@ is running in + .B \-\-monitor + mode. + .B \-d/\-\-delay +-command line argument takes precedence over the config file ++command line argument takes precedence over the config file. ++ ++If multiple ++.B MINITORDELAY ++lines are provided, only first non-zero value is considered. ++ ++.SH FILES ++ ++.SS {CONFFILE} ++ ++The default config file location, used when ++.I mdadm ++is running without --config option. ++ ++.SS {CONFFILE}.d ++ ++The default directory with config files. Used when ++.I mdadm ++is running without --config option, after successful reading of the ++.B {CONFFILE} ++default config file. Files in that directory ++are read in lexical order. ++ ++ ++.SS {CONFFILE2} ++ ++Alternative config file that is read, when ++.I mdadm ++is running without --config option and the ++.B {CONFFILE} ++default config file was not opened successfully. ++ ++.SS {CONFFILE2}.d ++ ++The alternative directory with config files. Used when ++.I mdadm ++is runninng without --config option, after reading the ++.B {CONFFILE2} ++alternative config file whether it was successful or not. Files in ++that directory are read in lexical order. + + .SH EXAMPLE + DEVICE /dev/sd[bcdjkl]1 +-- +2.35.3 + diff --git a/0009-Grow-report-correct-new-chunk-size.patch b/0009-Grow-report-correct-new-chunk-size.patch deleted file mode 100644 index 171d1b1..0000000 --- a/0009-Grow-report-correct-new-chunk-size.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 76d505dec6c9f92564553596fc8350324be82463 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 6 Dec 2018 10:36:28 +1100 -Subject: [PATCH] Grow: report correct new chunk size. -Git-commit: 76d505dec6c9f92564553596fc8350324be82463 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -When using "--grow --chunk=" to change chunk -size, the old chunksize is reported instead of the new. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Grow.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Grow.c b/Grow.c -index 76f82c075e38..363b209d14a3 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -3286,7 +3286,7 @@ static int reshape_array(char *container, int fd, char *devname, - goto release; - } else if (verbose >= 0) - printf("chunk size for %s set to %d\n", -- devname, array.chunk_size); -+ devname, info->new_chunk); - } - unfreeze(st); - return 0; --- -2.14.0.rc0.dirty - diff --git a/0009-mdadm-Update-config-manual.patch b/0009-mdadm-Update-config-manual.patch new file mode 100644 index 0000000..abb1236 --- /dev/null +++ b/0009-mdadm-Update-config-manual.patch @@ -0,0 +1,47 @@ +From c33bbda5b0e127bb161fd4ad44bcfaa2a5daf153 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 18 Mar 2022 09:26:07 +0100 +Subject: [PATCH 09/61] mdadm: Update config manual +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Add missing HOMECLUSTER keyword description. + +Signed-off-by: Lukasz Florczak +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + mdadm.conf.5.in | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in +index dd331a6..cd4e6a9 100644 +--- a/mdadm.conf.5.in ++++ b/mdadm.conf.5.in +@@ -439,6 +439,23 @@ from any possible local name. e.g. + .B /dev/md/1_1 + or + .BR /dev/md/home_0 . ++ ++.TP ++.B HOMECLUSTER ++The ++.B homcluster ++line gives a default value for the ++.B \-\-homecluster= ++option to mdadm. It specifies the cluster name for the md device. ++The md device can be assembled only on the cluster which matches ++the name specified. If ++.B homcluster ++is not provided, mdadm tries to detect the cluster name automatically. ++ ++There should only be one ++.B homecluster ++line. Any subsequent lines will be silently ignored. ++ + .TP + .B AUTO + A list of names of metadata format can be given, each preceded by a +-- +2.35.3 + diff --git a/0010-Create-Build-use-default_layout.patch b/0010-Create-Build-use-default_layout.patch new file mode 100644 index 0000000..1d1cab6 --- /dev/null +++ b/0010-Create-Build-use-default_layout.patch @@ -0,0 +1,156 @@ +From 913f07d1db4a0078acc26d6ccabe1c315cf9273c Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Thu, 20 Jan 2022 13:18:32 +0100 +Subject: [PATCH 10/61] Create, Build: use default_layout() +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +This code is duplicated for Build mode so make default_layout() extern +and use it. Simplify the function structure. + +It introduced change for Build mode, now for raid0 RAID0_ORIG_LAYOUT +will be returned same as for Create. + +Signed-off-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Build.c | 23 +------------------ + Create.c | 67 ++++++++++++++++++++++++++++++++++---------------------- + mdadm.h | 1 + + 3 files changed, 43 insertions(+), 48 deletions(-) + +diff --git a/Build.c b/Build.c +index 962c2e3..8d6f6f5 100644 +--- a/Build.c ++++ b/Build.c +@@ -71,28 +71,7 @@ int Build(char *mddev, struct mddev_dev *devlist, + } + + if (s->layout == UnSet) +- switch(s->level) { +- default: /* no layout */ +- s->layout = 0; +- break; +- case 10: +- s->layout = 0x102; /* near=2, far=1 */ +- if (c->verbose > 0) +- pr_err("layout defaults to n1\n"); +- break; +- case 5: +- case 6: +- s->layout = map_name(r5layout, "default"); +- if (c->verbose > 0) +- pr_err("layout defaults to %s\n", map_num(r5layout, s->layout)); +- break; +- case LEVEL_FAULTY: +- s->layout = map_name(faultylayout, "default"); +- +- if (c->verbose > 0) +- pr_err("layout defaults to %s\n", map_num(faultylayout, s->layout)); +- break; +- } ++ s->layout = default_layout(NULL, s->level, c->verbose); + + /* We need to create the device. It can have no name. */ + map_lock(&map); +diff --git a/Create.c b/Create.c +index 0ff1922..9ea19de 100644 +--- a/Create.c ++++ b/Create.c +@@ -39,39 +39,54 @@ static int round_size_and_verify(unsigned long long *size, int chunk) + return 0; + } + +-static int default_layout(struct supertype *st, int level, int verbose) ++/** ++ * default_layout() - Get default layout for level. ++ * @st: metadata requested, could be NULL. ++ * @level: raid level requested. ++ * @verbose: verbose level. ++ * ++ * Try to ask metadata handler first, otherwise use global defaults. ++ * ++ * Return: Layout or &UnSet, return value meaning depends of level used. ++ */ ++int default_layout(struct supertype *st, int level, int verbose) + { + int layout = UnSet; ++ mapping_t *layout_map = NULL; ++ char *layout_name = NULL; + + if (st && st->ss->default_geometry) + st->ss->default_geometry(st, &level, &layout, NULL); + +- if (layout == UnSet) +- switch(level) { +- default: /* no layout */ +- layout = 0; +- break; +- case 0: +- layout = RAID0_ORIG_LAYOUT; +- break; +- case 10: +- layout = 0x102; /* near=2, far=1 */ +- if (verbose > 0) +- pr_err("layout defaults to n2\n"); +- break; +- case 5: +- case 6: +- layout = map_name(r5layout, "default"); +- if (verbose > 0) +- pr_err("layout defaults to %s\n", map_num(r5layout, layout)); +- break; +- case LEVEL_FAULTY: +- layout = map_name(faultylayout, "default"); ++ if (layout != UnSet) ++ return layout; + +- if (verbose > 0) +- pr_err("layout defaults to %s\n", map_num(faultylayout, layout)); +- break; +- } ++ switch (level) { ++ default: /* no layout */ ++ layout = 0; ++ break; ++ case 0: ++ layout = RAID0_ORIG_LAYOUT; ++ break; ++ case 10: ++ layout = 0x102; /* near=2, far=1 */ ++ layout_name = "n2"; ++ break; ++ case 5: ++ case 6: ++ layout_map = r5layout; ++ break; ++ case LEVEL_FAULTY: ++ layout_map = faultylayout; ++ break; ++ } ++ ++ if (layout_map) { ++ layout = map_name(layout_map, "default"); ++ layout_name = map_num(layout_map, layout); ++ } ++ if (layout_name && verbose > 0) ++ pr_err("layout defaults to %s\n", layout_name); + + return layout; + } +diff --git a/mdadm.h b/mdadm.h +index 26e7e5c..cd72e71 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1512,6 +1512,7 @@ extern int get_linux_version(void); + extern int mdadm_version(char *version); + extern unsigned long long parse_size(char *size); + extern int parse_uuid(char *str, int uuid[4]); ++int default_layout(struct supertype *st, int level, int verbose); + extern int is_near_layout_10(int layout); + extern int parse_layout_10(char *layout); + extern int parse_layout_faulty(char *layout); +-- +2.35.3 + diff --git a/0010-policy.c-prevent-NULL-pointer-referencing.patch b/0010-policy.c-prevent-NULL-pointer-referencing.patch deleted file mode 100644 index 1d1767c..0000000 --- a/0010-policy.c-prevent-NULL-pointer-referencing.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 467e6a1b4ece8e552ee638dab7f44a4d235ece1a Mon Sep 17 00:00:00 2001 -From: Gioh Kim -Date: Fri, 7 Dec 2018 12:04:44 +0100 -Subject: [PATCH] policy.c: prevent NULL pointer referencing -Git-commit: 467e6a1b4ece8e552ee638dab7f44a4d235ece1a -Patch-mainline: mdadm-4.1 -References: bsc#1106078 - -paths could be NULL and paths[0] should be followed by NULL pointer -checking. - -Reviewed-by: NeilBrown -Signed-off-by: Gioh Kim -Signed-off-by: Jes Sorensen ---- - policy.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/policy.c b/policy.c -index fa67d55..e3a0671 100644 ---- a/policy.c -+++ b/policy.c -@@ -383,7 +383,7 @@ struct dev_policy *path_policy(char **paths, char *type) - /* Now add any metadata-specific internal knowledge - * about this path - */ -- for (i=0; paths[0] && superlist[i]; i++) -+ 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( --- -2.25.0 - diff --git a/0011-mdadm-add-map_num_s.patch b/0011-mdadm-add-map_num_s.patch new file mode 100644 index 0000000..65825a4 --- /dev/null +++ b/0011-mdadm-add-map_num_s.patch @@ -0,0 +1,385 @@ +From 5f21d67472ad08c1e96b4385254adba79aa1c467 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Thu, 20 Jan 2022 13:18:33 +0100 +Subject: [PATCH 11/61] mdadm: add map_num_s() +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +map_num() returns NULL if key is not defined. This patch adds +alternative, non NULL version for cases where NULL is not expected. + +There are many printf() calls where map_num() is called on variable +without NULL verification. It works, even if NULL is passed because +gcc is able to ignore NULL argument quietly but the behavior is +undefined. For safety reasons such usages will use map_num_s() now. +It is a potential point of regression. + +Signed-off-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Assemble.c | 6 ++---- + Create.c | 2 +- + Detail.c | 4 ++-- + Grow.c | 16 ++++++++-------- + Query.c | 4 ++-- + maps.c | 24 ++++++++++++++++++++++++ + mdadm.c | 20 ++++++++++---------- + mdadm.h | 2 +- + super-ddf.c | 6 +++--- + super-intel.c | 2 +- + super0.c | 2 +- + super1.c | 2 +- + sysfs.c | 9 +++++---- + 13 files changed, 61 insertions(+), 38 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 704b829..9eac9ce 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -63,7 +63,7 @@ static void set_array_assembly_status(struct context *c, + struct assembly_array_info *arr) + { + int raid_disks = arr->preexist_cnt + arr->new_cnt; +- char *status_msg = map_num(assemble_statuses, status); ++ char *status_msg = map_num_s(assemble_statuses, status); + + if (c->export && result) + *result |= status; +@@ -77,9 +77,7 @@ static void set_array_assembly_status(struct context *c, + fprintf(stderr, " (%d new)", arr->new_cnt); + if (arr->exp_cnt) + fprintf(stderr, " ( + %d for expansion)", arr->exp_cnt); +- if (status_msg) +- fprintf(stderr, " %s", status_msg); +- fprintf(stderr, ".\n"); ++ fprintf(stderr, " %s.\n", status_msg); + } + + static int name_matches(char *found, char *required, char *homehost, int require_homehost) +diff --git a/Create.c b/Create.c +index 9ea19de..c84c1ac 100644 +--- a/Create.c ++++ b/Create.c +@@ -83,7 +83,7 @@ int default_layout(struct supertype *st, int level, int verbose) + + if (layout_map) { + layout = map_name(layout_map, "default"); +- layout_name = map_num(layout_map, layout); ++ layout_name = map_num_s(layout_map, layout); + } + if (layout_name && verbose > 0) + pr_err("layout defaults to %s\n", layout_name); +diff --git a/Detail.c b/Detail.c +index 95d4cc7..ce7a844 100644 +--- a/Detail.c ++++ b/Detail.c +@@ -495,8 +495,8 @@ int Detail(char *dev, struct context *c) + if (array.state & (1 << MD_SB_CLEAN)) { + if ((array.level == 0) || + (array.level == LEVEL_LINEAR)) +- arrayst = map_num(sysfs_array_states, +- sra->array_state); ++ arrayst = map_num_s(sysfs_array_states, ++ sra->array_state); + else + arrayst = "clean"; + } else { +diff --git a/Grow.c b/Grow.c +index 18c5719..8a242b0 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -547,7 +547,7 @@ int Grow_consistency_policy(char *devname, int fd, struct context *c, struct sha + if (s->consistency_policy != CONSISTENCY_POLICY_RESYNC && + s->consistency_policy != CONSISTENCY_POLICY_PPL) { + pr_err("Operation not supported for consistency policy %s\n", +- map_num(consistency_policies, s->consistency_policy)); ++ map_num_s(consistency_policies, s->consistency_policy)); + return 1; + } + +@@ -578,14 +578,14 @@ int Grow_consistency_policy(char *devname, int fd, struct context *c, struct sha + + if (sra->consistency_policy == (unsigned)s->consistency_policy) { + pr_err("Consistency policy is already %s\n", +- map_num(consistency_policies, s->consistency_policy)); ++ map_num_s(consistency_policies, s->consistency_policy)); + ret = 1; + goto free_info; + } else if (sra->consistency_policy != CONSISTENCY_POLICY_RESYNC && + sra->consistency_policy != CONSISTENCY_POLICY_PPL) { + pr_err("Current consistency policy is %s, cannot change to %s\n", +- map_num(consistency_policies, sra->consistency_policy), +- map_num(consistency_policies, s->consistency_policy)); ++ map_num_s(consistency_policies, sra->consistency_policy), ++ map_num_s(consistency_policies, s->consistency_policy)); + ret = 1; + goto free_info; + } +@@ -704,8 +704,8 @@ int Grow_consistency_policy(char *devname, int fd, struct context *c, struct sha + } + + ret = sysfs_set_str(sra, NULL, "consistency_policy", +- map_num(consistency_policies, +- s->consistency_policy)); ++ map_num_s(consistency_policies, ++ s->consistency_policy)); + if (ret) + pr_err("Failed to change array consistency policy\n"); + +@@ -2241,7 +2241,7 @@ size_change_error: + info.new_layout = UnSet; + if (info.array.level == 6 && info.new_level == UnSet) { + char l[40], *h; +- strcpy(l, map_num(r6layout, info.array.layout)); ++ strcpy(l, map_num_s(r6layout, info.array.layout)); + h = strrchr(l, '-'); + if (h && strcmp(h, "-6") == 0) { + *h = 0; +@@ -2266,7 +2266,7 @@ size_change_error: + info.new_layout = info.array.layout; + else if (info.array.level == 5 && info.new_level == 6) { + char l[40]; +- strcpy(l, map_num(r5layout, info.array.layout)); ++ strcpy(l, map_num_s(r5layout, info.array.layout)); + strcat(l, "-6"); + info.new_layout = map_name(r6layout, l); + } else { +diff --git a/Query.c b/Query.c +index 23fbf8a..adcd231 100644 +--- a/Query.c ++++ b/Query.c +@@ -93,7 +93,7 @@ int Query(char *dev) + else { + printf("%s: %s %s %d devices, %d spare%s. Use mdadm --detail for more detail.\n", + dev, human_size_brief(larray_size,IEC), +- map_num(pers, level), raid_disks, ++ map_num_s(pers, level), raid_disks, + spare_disks, spare_disks == 1 ? "" : "s"); + } + st = guess_super(fd); +@@ -131,7 +131,7 @@ int Query(char *dev) + dev, + info.disk.number, info.array.raid_disks, + activity, +- map_num(pers, info.array.level), ++ map_num_s(pers, info.array.level), + mddev); + if (st->ss == &super0) + put_md_name(mddev); +diff --git a/maps.c b/maps.c +index a4fd279..20fcf71 100644 +--- a/maps.c ++++ b/maps.c +@@ -166,6 +166,30 @@ mapping_t sysfs_array_states[] = { + { NULL, ARRAY_UNKNOWN_STATE } + }; + ++/** ++ * map_num_s() - Safer alternative of map_num() function. ++ * @map: map to search. ++ * @num: key to match. ++ * ++ * Shall be used only if key existence is quaranted. ++ * ++ * Return: Pointer to name of the element. ++ */ ++char *map_num_s(mapping_t *map, int num) ++{ ++ char *ret = map_num(map, num); ++ ++ assert(ret); ++ return ret; ++} ++ ++/** ++ * map_num() - get element name by key. ++ * @map: map to search. ++ * @num: key to match. ++ * ++ * Return: Pointer to name of the element or NULL. ++ */ + char *map_num(mapping_t *map, int num) + { + while (map->name) { +diff --git a/mdadm.c b/mdadm.c +index 26299b2..be40686 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -280,8 +280,8 @@ int main(int argc, char *argv[]) + else + fprintf(stderr, "-%c", opt); + fprintf(stderr, " would set mdadm mode to \"%s\", but it is already set to \"%s\".\n", +- map_num(modes, newmode), +- map_num(modes, mode)); ++ map_num_s(modes, newmode), ++ map_num_s(modes, mode)); + exit(2); + } else if (!mode && newmode) { + mode = newmode; +@@ -544,7 +544,7 @@ int main(int argc, char *argv[]) + switch(s.level) { + default: + pr_err("layout not meaningful for %s arrays.\n", +- map_num(pers, s.level)); ++ map_num_s(pers, s.level)); + exit(2); + case UnSet: + pr_err("raid level must be given before layout.\n"); +@@ -1248,10 +1248,10 @@ int main(int argc, char *argv[]) + if (option_index > 0) + pr_err(":option --%s not valid in %s mode\n", + long_options[option_index].name, +- map_num(modes, mode)); ++ map_num_s(modes, mode)); + else + pr_err("option -%c not valid in %s mode\n", +- opt, map_num(modes, mode)); ++ opt, map_num_s(modes, mode)); + exit(2); + + } +@@ -1276,7 +1276,7 @@ int main(int argc, char *argv[]) + if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN && + s.consistency_policy != CONSISTENCY_POLICY_JOURNAL) { + pr_err("--write-journal is not supported with consistency policy: %s\n", +- map_num(consistency_policies, s.consistency_policy)); ++ map_num_s(consistency_policies, s.consistency_policy)); + exit(2); + } + } +@@ -1285,12 +1285,12 @@ int main(int argc, char *argv[]) + s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) { + if (s.level <= 0) { + pr_err("--consistency-policy not meaningful with level %s.\n", +- map_num(pers, s.level)); ++ map_num_s(pers, s.level)); + exit(2); + } else if (s.consistency_policy == CONSISTENCY_POLICY_JOURNAL && + !s.journaldisks) { + pr_err("--write-journal is required for consistency policy: %s\n", +- map_num(consistency_policies, s.consistency_policy)); ++ map_num_s(consistency_policies, s.consistency_policy)); + exit(2); + } else if (s.consistency_policy == CONSISTENCY_POLICY_PPL && + s.level != 5) { +@@ -1300,14 +1300,14 @@ int main(int argc, char *argv[]) + (!s.bitmap_file || + strcmp(s.bitmap_file, "none") == 0)) { + pr_err("--bitmap is required for consistency policy: %s\n", +- map_num(consistency_policies, s.consistency_policy)); ++ map_num_s(consistency_policies, s.consistency_policy)); + exit(2); + } else if (s.bitmap_file && + strcmp(s.bitmap_file, "none") != 0 && + s.consistency_policy != CONSISTENCY_POLICY_BITMAP && + s.consistency_policy != CONSISTENCY_POLICY_JOURNAL) { + pr_err("--bitmap is not compatible with consistency policy: %s\n", +- map_num(consistency_policies, s.consistency_policy)); ++ map_num_s(consistency_policies, s.consistency_policy)); + exit(2); + } + } +diff --git a/mdadm.h b/mdadm.h +index cd72e71..09915a0 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -770,7 +770,7 @@ extern int restore_stripes(int *dest, unsigned long long *offsets, + #endif + + #define SYSLOG_FACILITY LOG_DAEMON +- ++extern char *map_num_s(mapping_t *map, int num); + extern char *map_num(mapping_t *map, int num); + extern int map_name(mapping_t *map, char *name); + extern mapping_t r0layout[], r5layout[], r6layout[], +diff --git a/super-ddf.c b/super-ddf.c +index 3f304cd..8cda23a 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -1477,13 +1477,13 @@ static void examine_vds(struct ddf_super *sb) + printf("\n"); + printf(" unit[%d] : %d\n", i, be16_to_cpu(ve->unit)); + printf(" state[%d] : %s, %s%s\n", i, +- map_num(ddf_state, ve->state & 7), ++ map_num_s(ddf_state, ve->state & 7), + (ve->state & DDF_state_morphing) ? "Morphing, ": "", + (ve->state & DDF_state_inconsistent)? "Not Consistent" : "Consistent"); + printf(" init state[%d] : %s\n", i, +- map_num(ddf_init_state, ve->init_state&DDF_initstate_mask)); ++ map_num_s(ddf_init_state, ve->init_state & DDF_initstate_mask)); + printf(" access[%d] : %s\n", i, +- map_num(ddf_access, (ve->init_state & DDF_access_mask) >> 6)); ++ map_num_s(ddf_access, (ve->init_state & DDF_access_mask) >> 6)); + printf(" Name[%d] : %.16s\n", i, ve->name); + examine_vd(i, sb, ve->guid); + } +diff --git a/super-intel.c b/super-intel.c +index 6ff336e..ba3bd41 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -5625,7 +5625,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, + free(dev); + free(dv); + pr_err("imsm does not support consistency policy %s\n", +- map_num(consistency_policies, s->consistency_policy)); ++ map_num_s(consistency_policies, s->consistency_policy)); + return 0; + } + +diff --git a/super0.c b/super0.c +index b79b97a..61c9ec1 100644 +--- a/super0.c ++++ b/super0.c +@@ -288,7 +288,7 @@ static void export_examine_super0(struct supertype *st) + { + mdp_super_t *sb = st->sb; + +- printf("MD_LEVEL=%s\n", map_num(pers, sb->level)); ++ printf("MD_LEVEL=%s\n", map_num_s(pers, sb->level)); + printf("MD_DEVICES=%d\n", sb->raid_disks); + if (sb->minor_version >= 90) + printf("MD_UUID=%08x:%08x:%08x:%08x\n", +diff --git a/super1.c b/super1.c +index a12a5bc..e3e2f95 100644 +--- a/super1.c ++++ b/super1.c +@@ -671,7 +671,7 @@ static void export_examine_super1(struct supertype *st) + int len = 32; + int layout; + +- printf("MD_LEVEL=%s\n", map_num(pers, __le32_to_cpu(sb->level))); ++ printf("MD_LEVEL=%s\n", map_num_s(pers, __le32_to_cpu(sb->level))); + printf("MD_DEVICES=%d\n", __le32_to_cpu(sb->raid_disks)); + for (i = 0; i < 32; i++) + if (sb->set_name[i] == '\n' || sb->set_name[i] == '\0') { +diff --git a/sysfs.c b/sysfs.c +index 2995713..0d98a65 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -689,7 +689,7 @@ int sysfs_set_array(struct mdinfo *info, int vers) + if (info->array.level < 0) + return 0; /* FIXME */ + rv |= sysfs_set_str(info, NULL, "level", +- map_num(pers, info->array.level)); ++ map_num_s(pers, info->array.level)); + if (info->reshape_active && info->delta_disks != UnSet) + raid_disks -= info->delta_disks; + rv |= sysfs_set_num(info, NULL, "raid_disks", raid_disks); +@@ -724,9 +724,10 @@ int sysfs_set_array(struct mdinfo *info, int vers) + } + + if (info->consistency_policy == CONSISTENCY_POLICY_PPL) { +- if (sysfs_set_str(info, NULL, "consistency_policy", +- map_num(consistency_policies, +- info->consistency_policy))) { ++ char *policy = map_num_s(consistency_policies, ++ info->consistency_policy); ++ ++ if (sysfs_set_str(info, NULL, "consistency_policy", policy)) { + pr_err("This kernel does not support PPL. Falling back to consistency-policy=resync.\n"); + info->consistency_policy = CONSISTENCY_POLICY_RESYNC; + } +-- +2.35.3 + diff --git a/0012-mdmon-Stop-parsing-duplicate-options.patch b/0012-mdmon-Stop-parsing-duplicate-options.patch new file mode 100644 index 0000000..a340eb6 --- /dev/null +++ b/0012-mdmon-Stop-parsing-duplicate-options.patch @@ -0,0 +1,125 @@ +From 1066ab83dbe9a4cc20f7db44a40aa2cbb9d5eed6 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 13 May 2022 09:19:42 +0200 +Subject: [PATCH 13/61] mdmon: Stop parsing duplicate options +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Introduce new function is_duplicate_opt() to check if given option +was already used and prevent setting it again along with an error +message. + +Move parsing above in_initrd() check to be able to detect --offroot +option duplicates. + +Now help option is executed after parsing to prevent executing commands +like: 'mdmon --help --ndlksnlksajndfjksndafasj'. + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + mdmon.c | 44 +++++++++++++++++++++++++++++++++++--------- + 1 file changed, 35 insertions(+), 9 deletions(-) + +diff --git a/mdmon.c b/mdmon.c +index 5570574..c057da6 100644 +--- a/mdmon.c ++++ b/mdmon.c +@@ -288,6 +288,15 @@ void usage(void) + exit(2); + } + ++static bool is_duplicate_opt(const int opt, const int set_val, const char *long_name) ++{ ++ if (opt == set_val) { ++ pr_err("--%s option duplicated!\n", long_name); ++ return true; ++ } ++ return false; ++} ++ + static int mdmon(char *devnm, int must_fork, int takeover); + + int main(int argc, char *argv[]) +@@ -299,6 +308,7 @@ int main(int argc, char *argv[]) + int all = 0; + int takeover = 0; + int dofork = 1; ++ bool help = false; + static struct option options[] = { + {"all", 0, NULL, 'a'}, + {"takeover", 0, NULL, 't'}, +@@ -308,37 +318,50 @@ int main(int argc, char *argv[]) + {NULL, 0, NULL, 0} + }; + +- if (in_initrd()) { +- /* +- * set first char of argv[0] to @. This is used by +- * systemd to signal that the task was launched from +- * initrd/initramfs and should be preserved during shutdown +- */ +- argv[0][0] = '@'; +- } +- + while ((opt = getopt_long(argc, argv, "thaF", options, NULL)) != -1) { + switch (opt) { + case 'a': ++ if (is_duplicate_opt(all, 1, "all")) ++ exit(1); + container_name = argv[optind-1]; + all = 1; + break; + case 't': ++ if (is_duplicate_opt(takeover, 1, "takeover")) ++ exit(1); + takeover = 1; + break; + case 'F': ++ if (is_duplicate_opt(dofork, 0, "foreground")) ++ exit(1); + dofork = 0; + break; + case OffRootOpt: ++ if (is_duplicate_opt(argv[0][0], '@', "offroot")) ++ exit(1); + argv[0][0] = '@'; + break; + case 'h': ++ if (is_duplicate_opt(help, true, "help")) ++ exit(1); ++ help = true; ++ break; + default: + usage(); + break; + } + } + ++ ++ if (in_initrd()) { ++ /* ++ * set first char of argv[0] to @. This is used by ++ * systemd to signal that the task was launched from ++ * initrd/initramfs and should be preserved during shutdown ++ */ ++ argv[0][0] = '@'; ++ } ++ + if (all == 0 && container_name == NULL) { + if (argv[optind]) + container_name = argv[optind]; +@@ -353,6 +376,9 @@ int main(int argc, char *argv[]) + if (strcmp(container_name, "/proc/mdstat") == 0) + all = 1; + ++ if (help) ++ usage(); ++ + if (all) { + struct mdstat_ent *mdstat, *e; + int container_len = strlen(container_name); +-- +2.35.3 + diff --git a/0012-policy.c-Fix-for-compiler-error.patch b/0012-policy.c-Fix-for-compiler-error.patch deleted file mode 100644 index 9436623..0000000 --- a/0012-policy.c-Fix-for-compiler-error.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 757e55435997e355ee9b03e5d913b5496a3c39a8 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 11 Dec 2018 15:04:07 +0100 -Subject: [PATCH] policy.c: Fix for compiler error -Git-commit: 757e55435997e355ee9b03e5d913b5496a3c39a8 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -After cd72f9d(policy: support devices with multiple paths.) compilation -on old compilers fails because "‘p’ may be used uninitialized -in this function". - -Initialize it with NULL to prevent this. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - policy.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/policy.c b/policy.c -index e3a0671..3c53bd3 100644 ---- a/policy.c -+++ b/policy.c -@@ -268,7 +268,7 @@ static int pol_match(struct rule *rule, char **paths, char *type, char **part) - - for (; rule; rule = rule->next) { - if (rule->name == rule_path) { -- char *p; -+ char *p = NULL; - int i; - if (pathok == 0) - pathok = -1; --- -2.25.0 - diff --git a/0013-Grow-block-n-on-external-volumes.patch b/0013-Grow-block-n-on-external-volumes.patch new file mode 100644 index 0000000..c45e532 --- /dev/null +++ b/0013-Grow-block-n-on-external-volumes.patch @@ -0,0 +1,44 @@ +From 20e114e334ed6ed3280c37a9a08fb95578393d1a Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Thu, 19 May 2022 09:16:08 +0200 +Subject: [PATCH 14/61] Grow: block -n on external volumes. +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Performing --raid-devices on external metadata volume should be blocked +as it causes unwanted behaviour. + +Eg. Performing +mdadm -G /dev/md/volume -l10 -n4 +on r0_d2 inside 4 disk container, returns +mdadm: Need 2 spares to avoid degraded array, only have 0. + +Signed-off-by: Mateusz Kusiak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Grow.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/Grow.c b/Grow.c +index 8a242b0..f6efbc4 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -1892,6 +1892,14 @@ int Grow_reshape(char *devname, int fd, + + if (retval) { + pr_err("Cannot read superblock for %s\n", devname); ++ close(cfd); ++ free(subarray); ++ return 1; ++ } ++ ++ if (s->raiddisks && subarray) { ++ pr_err("--raid-devices operation can be performed on a container only\n"); ++ close(cfd); + free(subarray); + return 1; + } +-- +2.35.3 + diff --git a/0013-imsm-finish-recovery-when-drive-with-rebuild-fails.patch b/0013-imsm-finish-recovery-when-drive-with-rebuild-fails.patch deleted file mode 100644 index 47fc81a..0000000 --- a/0013-imsm-finish-recovery-when-drive-with-rebuild-fails.patch +++ /dev/null @@ -1,98 +0,0 @@ -From a4e96fd8f3f0b5416783237c1cb6ee87e7eff23d Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 8 Feb 2019 11:07:10 +0100 -Subject: [PATCH] imsm: finish recovery when drive with rebuild fails -Git-commit: a4e96fd8f3f0b5416783237c1cb6ee87e7eff23d -Patch-mainline: mdadm-4.1-12 -References: bsc#1126975 - -Commit d7a1fda2769b ("imsm: update metadata correctly while raid10 double -degradation") resolves main Imsm double degradation problems but it -omits one case. Now metadata hangs in the rebuilding state if the drive -under rebuild is removed during recovery from double degradation. - -The root cause of this problem is comparing new map_state with current -and if they both are degraded assuming that nothing new happens. - -Don't rely on map states, just check if device is failed. If the drive -under rebuild fails then finish migration, in other cases update map -state only (second fail means that destination map state can't be normal). - -To avoid problems with reassembling move end_migration (called after -double degradation successful recovery) after check if recovery really -finished, for details see (7ce057018 "imsm: fix: rebuild does not -continue after reboot"). -Remove redundant code responsible for finishing rebuild process. Function -end_migration do exactly the same. Set last_checkpoint to 0, to prepare -it for the next rebuild. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - super-intel.c | 26 +++++++++++--------------- - 1 file changed, 11 insertions(+), 15 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index d2035cc..38a1b6c 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -8560,26 +8560,22 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - } - if (is_rebuilding(dev)) { - dprintf_cont("while rebuilding "); -- if (map->map_state != map_state) { -- dprintf_cont("map state change "); -+ if (state & DS_FAULTY) { -+ dprintf_cont("removing failed drive "); - if (n == map->failed_disk_num) { - dprintf_cont("end migration"); - end_migration(dev, super, map_state); -+ a->last_checkpoint = 0; - } else { -- dprintf_cont("raid10 double degradation, map state change"); -+ dprintf_cont("fail detected during rebuild, changing map state"); - map->map_state = map_state; - } - super->updates_pending++; -- } else if (!rebuild_done) -- break; -- else if (n == map->failed_disk_num) { -- /* r10 double degraded to degraded transition */ -- dprintf_cont("raid10 double degradation end migration"); -- end_migration(dev, super, map_state); -- a->last_checkpoint = 0; -- super->updates_pending++; - } - -+ if (!rebuild_done) -+ break; -+ - /* check if recovery is really finished */ - for (mdi = a->info.devs; mdi ; mdi = mdi->next) - if (mdi->recovery_start != MaxSector) { -@@ -8588,7 +8584,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - } - if (recovery_not_finished) { - dprintf_cont("\n"); -- dprintf_cont("Rebuild has not finished yet, map state changes only if raid10 double degradation happens"); -+ dprintf_cont("Rebuild has not finished yet"); - if (a->last_checkpoint < mdi->recovery_start) { - a->last_checkpoint = - mdi->recovery_start; -@@ -8598,9 +8594,9 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - } - - dprintf_cont(" Rebuild done, still degraded"); -- dev->vol.migr_state = 0; -- set_migr_type(dev, 0); -- dev->vol.curr_migr_unit = 0; -+ end_migration(dev, super, map_state); -+ a->last_checkpoint = 0; -+ super->updates_pending++; - - for (i = 0; i < map->num_members; i++) { - int idx = get_imsm_ord_tbl_ent(dev, i, MAP_0); --- -2.16.4 - diff --git a/0014-Incremental-Fix-possible-memory-and-resource-leaks.patch b/0014-Incremental-Fix-possible-memory-and-resource-leaks.patch new file mode 100644 index 0000000..85dac52 --- /dev/null +++ b/0014-Incremental-Fix-possible-memory-and-resource-leaks.patch @@ -0,0 +1,93 @@ +From de064c93e3819d72720e4fba6575265ba10e1553 Mon Sep 17 00:00:00 2001 +From: Mateusz Grzonka +Date: Mon, 13 Jun 2022 12:11:25 +0200 +Subject: [PATCH 15/61] Incremental: Fix possible memory and resource leaks +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +map allocated through map_by_uuid() is not freed if mdfd is invalid. +In addition mdfd is not closed, and mdinfo list is not freed too. + +Signed-off-by: Mateusz Grzonka +Change-Id: I25e726f0e2502cf7e8ce80c2bd7944b3b1e2b9dc +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Incremental.c | 32 +++++++++++++++++++++++--------- + 1 file changed, 23 insertions(+), 9 deletions(-) + +diff --git a/Incremental.c b/Incremental.c +index a57fc32..4d0cd9d 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -1499,7 +1499,7 @@ static int Incremental_container(struct supertype *st, char *devname, + return 0; + } + for (ra = list ; ra ; ra = ra->next) { +- int mdfd; ++ int mdfd = -1; + char chosen_name[1024]; + struct map_ent *mp; + struct mddev_ident *match = NULL; +@@ -1514,6 +1514,12 @@ static int Incremental_container(struct supertype *st, char *devname, + + if (mp) { + mdfd = open_dev(mp->devnm); ++ if (!is_fd_valid(mdfd)) { ++ pr_err("failed to open %s: %s.\n", ++ mp->devnm, strerror(errno)); ++ rv = 2; ++ goto release; ++ } + if (mp->path) + strcpy(chosen_name, mp->path); + else +@@ -1573,21 +1579,25 @@ static int Incremental_container(struct supertype *st, char *devname, + c->autof, + trustworthy, + chosen_name, 0); ++ ++ if (!is_fd_valid(mdfd)) { ++ pr_err("create_mddev failed with chosen name %s: %s.\n", ++ chosen_name, strerror(errno)); ++ rv = 2; ++ goto release; ++ } + } +- if (only && (!mp || strcmp(mp->devnm, only) != 0)) +- continue; + +- if (mdfd < 0) { +- pr_err("failed to open %s: %s.\n", +- chosen_name, strerror(errno)); +- return 2; ++ if (only && (!mp || strcmp(mp->devnm, only) != 0)) { ++ close_fd(&mdfd); ++ continue; + } + + assemble_container_content(st, mdfd, ra, c, + chosen_name, &result); + map_free(map); + map = NULL; +- close(mdfd); ++ close_fd(&mdfd); + } + if (c->export && result) { + char sep = '='; +@@ -1610,7 +1620,11 @@ static int Incremental_container(struct supertype *st, char *devname, + } + printf("\n"); + } +- return 0; ++ ++release: ++ map_free(map); ++ sysfs_free(list); ++ return rv; + } + + static void run_udisks(char *arg1, char *arg2) +-- +2.35.3 + diff --git a/0014-imsm-fix-reshape-for-2TB-drives.patch b/0014-imsm-fix-reshape-for-2TB-drives.patch deleted file mode 100644 index fe9a834..0000000 --- a/0014-imsm-fix-reshape-for-2TB-drives.patch +++ /dev/null @@ -1,327 +0,0 @@ -From 9f4218274cd4a1e1f356a1617f9a1d09960cf255 Mon Sep 17 00:00:00 2001 -From: Pawel Baldysiak -Date: Mon, 28 Jan 2019 17:10:41 +0100 -Subject: [PATCH] imsm: fix reshape for >2TB drives -Git-commit: 9f4218274cd4a1e1f356a1617f9a1d09960cf255 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -If reshape is performed on drives larger then 2 TB, -migration checkpoint area that is calculated exeeds 32-bit value. -This checkpoint area is a reserved space threated as backup -during reshape - at the end of the drive, right before metadata. -As a result - wrong space is used and the data that may exists there -is overwritten. - -Adding additional field to migration record to track high order 32-bits -of pba of this area. Three other fields that may exceed 32-bit value -for large drives are added as well. - -Signed-off-by: Pawel Baldysiak -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 149 ++++++++++++++++++++++++++++++++++++-------------- - 1 file changed, 107 insertions(+), 42 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 38a1b6c..1cc7d5f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -296,7 +296,7 @@ struct migr_record { - __u32 rec_status; /* Status used to determine how to restart - * migration in case it aborts - * in some fashion */ -- __u32 curr_migr_unit; /* 0..numMigrUnits-1 */ -+ __u32 curr_migr_unit_lo; /* 0..numMigrUnits-1 */ - __u32 family_num; /* Family number of MPB - * containing the RaidDev - * that is migrating */ -@@ -306,16 +306,23 @@ struct migr_record { - __u32 dest_depth_per_unit; /* Num member blocks each destMap - * member disk - * advances per unit-of-operation */ -- __u32 ckpt_area_pba; /* Pba of first block of ckpt copy area */ -- __u32 dest_1st_member_lba; /* First member lba on first -- * stripe of destination */ -- __u32 num_migr_units; /* Total num migration units-of-op */ -+ __u32 ckpt_area_pba_lo; /* Pba of first block of ckpt copy area */ -+ __u32 dest_1st_member_lba_lo; /* First member lba on first -+ * stripe of destination */ -+ __u32 num_migr_units_lo; /* Total num migration units-of-op */ - __u32 post_migr_vol_cap; /* Size of volume after - * migration completes */ - __u32 post_migr_vol_cap_hi; /* Expansion space for LBA64 */ - __u32 ckpt_read_disk_num; /* Which member disk in destSubMap[0] the - * migration ckpt record was read from - * (for recovered migrations) */ -+ __u32 curr_migr_unit_hi; /* 0..numMigrUnits-1 high order 32 bits */ -+ __u32 ckpt_area_pba_hi; /* Pba of first block of ckpt copy area -+ * high order 32 bits */ -+ __u32 dest_1st_member_lba_hi; /* First member lba on first stripe of -+ * destination - high order 32 bits */ -+ __u32 num_migr_units_hi; /* Total num migration units-of-op -+ * high order 32 bits */ - } __attribute__ ((__packed__)); - - struct md_list { -@@ -1208,6 +1215,38 @@ static unsigned long long imsm_dev_size(struct imsm_dev *dev) - return join_u32(dev->size_low, dev->size_high); - } - -+static unsigned long long migr_chkp_area_pba(struct migr_record *migr_rec) -+{ -+ if (migr_rec == NULL) -+ return 0; -+ return join_u32(migr_rec->ckpt_area_pba_lo, -+ migr_rec->ckpt_area_pba_hi); -+} -+ -+static unsigned long long current_migr_unit(struct migr_record *migr_rec) -+{ -+ if (migr_rec == NULL) -+ return 0; -+ return join_u32(migr_rec->curr_migr_unit_lo, -+ migr_rec->curr_migr_unit_hi); -+} -+ -+static unsigned long long migr_dest_1st_member_lba(struct migr_record *migr_rec) -+{ -+ if (migr_rec == NULL) -+ return 0; -+ return join_u32(migr_rec->dest_1st_member_lba_lo, -+ migr_rec->dest_1st_member_lba_hi); -+} -+ -+static unsigned long long get_num_migr_units(struct migr_record *migr_rec) -+{ -+ if (migr_rec == NULL) -+ return 0; -+ return join_u32(migr_rec->num_migr_units_lo, -+ migr_rec->num_migr_units_hi); -+} -+ - static void set_total_blocks(struct imsm_disk *disk, unsigned long long n) - { - split_ull(n, &disk->total_blocks_lo, &disk->total_blocks_hi); -@@ -1233,6 +1272,33 @@ static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n) - split_ull(n, &dev->size_low, &dev->size_high); - } - -+static void set_migr_chkp_area_pba(struct migr_record *migr_rec, -+ unsigned long long n) -+{ -+ split_ull(n, &migr_rec->ckpt_area_pba_lo, &migr_rec->ckpt_area_pba_hi); -+} -+ -+static void set_current_migr_unit(struct migr_record *migr_rec, -+ unsigned long long n) -+{ -+ split_ull(n, &migr_rec->curr_migr_unit_lo, -+ &migr_rec->curr_migr_unit_hi); -+} -+ -+static void set_migr_dest_1st_member_lba(struct migr_record *migr_rec, -+ unsigned long long n) -+{ -+ split_ull(n, &migr_rec->dest_1st_member_lba_lo, -+ &migr_rec->dest_1st_member_lba_hi); -+} -+ -+static void set_num_migr_units(struct migr_record *migr_rec, -+ unsigned long long n) -+{ -+ split_ull(n, &migr_rec->num_migr_units_lo, -+ &migr_rec->num_migr_units_hi); -+} -+ - static unsigned long long per_dev_array_size(struct imsm_map *map) - { - unsigned long long array_size = 0; -@@ -1629,12 +1695,14 @@ void convert_to_4k_imsm_migr_rec(struct intel_super *super) - struct migr_record *migr_rec = super->migr_rec; - - migr_rec->blocks_per_unit /= IMSM_4K_DIV; -- migr_rec->ckpt_area_pba /= IMSM_4K_DIV; -- migr_rec->dest_1st_member_lba /= IMSM_4K_DIV; - migr_rec->dest_depth_per_unit /= IMSM_4K_DIV; - split_ull((join_u32(migr_rec->post_migr_vol_cap, - migr_rec->post_migr_vol_cap_hi) / IMSM_4K_DIV), - &migr_rec->post_migr_vol_cap, &migr_rec->post_migr_vol_cap_hi); -+ set_migr_chkp_area_pba(migr_rec, -+ migr_chkp_area_pba(migr_rec) / IMSM_4K_DIV); -+ set_migr_dest_1st_member_lba(migr_rec, -+ migr_dest_1st_member_lba(migr_rec) / IMSM_4K_DIV); - } - - void convert_to_4k_imsm_disk(struct imsm_disk *disk) -@@ -1727,8 +1795,8 @@ void examine_migr_rec_imsm(struct intel_super *super) - printf("Normal\n"); - else - printf("Contains Data\n"); -- printf(" Current Unit : %u\n", -- __le32_to_cpu(migr_rec->curr_migr_unit)); -+ printf(" Current Unit : %llu\n", -+ current_migr_unit(migr_rec)); - printf(" Family : %u\n", - __le32_to_cpu(migr_rec->family_num)); - printf(" Ascending : %u\n", -@@ -1737,16 +1805,15 @@ void examine_migr_rec_imsm(struct intel_super *super) - __le32_to_cpu(migr_rec->blocks_per_unit)); - printf(" Dest. Depth Per Unit : %u\n", - __le32_to_cpu(migr_rec->dest_depth_per_unit)); -- printf(" Checkpoint Area pba : %u\n", -- __le32_to_cpu(migr_rec->ckpt_area_pba)); -- printf(" First member lba : %u\n", -- __le32_to_cpu(migr_rec->dest_1st_member_lba)); -- printf(" Total Number of Units : %u\n", -- __le32_to_cpu(migr_rec->num_migr_units)); -- printf(" Size of volume : %u\n", -- __le32_to_cpu(migr_rec->post_migr_vol_cap)); -- printf(" Expansion space for LBA64 : %u\n", -- __le32_to_cpu(migr_rec->post_migr_vol_cap_hi)); -+ printf(" Checkpoint Area pba : %llu\n", -+ migr_chkp_area_pba(migr_rec)); -+ printf(" First member lba : %llu\n", -+ migr_dest_1st_member_lba(migr_rec)); -+ printf(" Total Number of Units : %llu\n", -+ get_num_migr_units(migr_rec)); -+ printf(" Size of volume : %llu\n", -+ join_u32(migr_rec->post_migr_vol_cap, -+ migr_rec->post_migr_vol_cap_hi)); - printf(" Record was read from : %u\n", - __le32_to_cpu(migr_rec->ckpt_read_disk_num)); - -@@ -1759,13 +1826,15 @@ void convert_from_4k_imsm_migr_rec(struct intel_super *super) - struct migr_record *migr_rec = super->migr_rec; - - migr_rec->blocks_per_unit *= IMSM_4K_DIV; -- migr_rec->ckpt_area_pba *= IMSM_4K_DIV; -- migr_rec->dest_1st_member_lba *= IMSM_4K_DIV; - migr_rec->dest_depth_per_unit *= IMSM_4K_DIV; - split_ull((join_u32(migr_rec->post_migr_vol_cap, - migr_rec->post_migr_vol_cap_hi) * IMSM_4K_DIV), - &migr_rec->post_migr_vol_cap, - &migr_rec->post_migr_vol_cap_hi); -+ set_migr_chkp_area_pba(migr_rec, -+ migr_chkp_area_pba(migr_rec) * IMSM_4K_DIV); -+ set_migr_dest_1st_member_lba(migr_rec, -+ migr_dest_1st_member_lba(migr_rec) * IMSM_4K_DIV); - } - - void convert_from_4k(struct intel_super *super) -@@ -3096,7 +3165,7 @@ static int imsm_create_metadata_checkpoint_update( - return 0; - } - (*u)->type = update_general_migration_checkpoint; -- (*u)->curr_migr_unit = __le32_to_cpu(super->migr_rec->curr_migr_unit); -+ (*u)->curr_migr_unit = current_migr_unit(super->migr_rec); - dprintf("prepared for %u\n", (*u)->curr_migr_unit); - - return update_memory_size; -@@ -3397,13 +3466,13 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - case MIGR_GEN_MIGR: { - __u64 blocks_per_unit = blocks_per_migr_unit(super, - dev); -- __u64 units = __le32_to_cpu(migr_rec->curr_migr_unit); -+ __u64 units = current_migr_unit(migr_rec); - unsigned long long array_blocks; - int used_disks; - - if (__le32_to_cpu(migr_rec->ascending_migr) && - (units < -- (__le32_to_cpu(migr_rec->num_migr_units)-1)) && -+ (get_num_migr_units(migr_rec)-1)) && - (super->migr_rec->rec_status == - __cpu_to_le32(UNIT_SRC_IN_CP_AREA))) - units++; -@@ -10697,7 +10766,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev, - - if (array_blocks % __le32_to_cpu(migr_rec->blocks_per_unit)) - num_migr_units++; -- migr_rec->num_migr_units = __cpu_to_le32(num_migr_units); -+ set_num_migr_units(migr_rec, num_migr_units); - - migr_rec->post_migr_vol_cap = dev->size_low; - migr_rec->post_migr_vol_cap_hi = dev->size_high; -@@ -10714,7 +10783,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev, - min_dev_sectors = dev_sectors; - close(fd); - } -- migr_rec->ckpt_area_pba = __cpu_to_le32(min_dev_sectors - -+ set_migr_chkp_area_pba(migr_rec, min_dev_sectors - - RAID_DISK_RESERVED_BLOCKS_IMSM_HI); - - write_imsm_migr_rec(st); -@@ -10765,8 +10834,7 @@ int save_backup_imsm(struct supertype *st, - - start = info->reshape_progress * 512; - for (i = 0; i < new_disks; i++) { -- target_offsets[i] = (unsigned long long) -- __le32_to_cpu(super->migr_rec->ckpt_area_pba) * 512; -+ target_offsets[i] = migr_chkp_area_pba(super->migr_rec) * 512; - /* move back copy area adderss, it will be moved forward - * in restore_stripes() using start input variable - */ -@@ -10845,12 +10913,11 @@ int save_checkpoint_imsm(struct supertype *st, struct mdinfo *info, int state) - if (info->reshape_progress % blocks_per_unit) - curr_migr_unit++; - -- super->migr_rec->curr_migr_unit = -- __cpu_to_le32(curr_migr_unit); -+ set_current_migr_unit(super->migr_rec, curr_migr_unit); - super->migr_rec->rec_status = __cpu_to_le32(state); -- super->migr_rec->dest_1st_member_lba = -- __cpu_to_le32(curr_migr_unit * -- __le32_to_cpu(super->migr_rec->dest_depth_per_unit)); -+ set_migr_dest_1st_member_lba(super->migr_rec, -+ super->migr_rec->dest_depth_per_unit * curr_migr_unit); -+ - if (write_imsm_migr_rec(st) < 0) { - dprintf("imsm: Cannot write migration record outside backup area\n"); - return 1; -@@ -10884,8 +10951,8 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info) - char *buf = NULL; - int retval = 1; - unsigned int sector_size = super->sector_size; -- unsigned long curr_migr_unit = __le32_to_cpu(migr_rec->curr_migr_unit); -- unsigned long num_migr_units = __le32_to_cpu(migr_rec->num_migr_units); -+ unsigned long curr_migr_unit = current_migr_unit(migr_rec); -+ unsigned long num_migr_units = get_num_migr_units(migr_rec); - char buffer[20]; - int skipped_disks = 0; - -@@ -10912,11 +10979,9 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info) - map_dest = get_imsm_map(id->dev, MAP_0); - new_disks = map_dest->num_members; - -- read_offset = (unsigned long long) -- __le32_to_cpu(migr_rec->ckpt_area_pba) * 512; -+ read_offset = migr_chkp_area_pba(migr_rec) * 512; - -- write_offset = ((unsigned long long) -- __le32_to_cpu(migr_rec->dest_1st_member_lba) + -+ write_offset = (migr_dest_1st_member_lba(migr_rec) + - pba_of_lba0(map_dest)) * 512; - - unit_len = __le32_to_cpu(migr_rec->dest_depth_per_unit) * 512; -@@ -12019,12 +12084,12 @@ static int imsm_manage_reshape( - max_position = sra->component_size * ndata; - source_layout = imsm_level_to_layout(map_src->raid_level); - -- while (__le32_to_cpu(migr_rec->curr_migr_unit) < -- __le32_to_cpu(migr_rec->num_migr_units)) { -+ while (current_migr_unit(migr_rec) < -+ get_num_migr_units(migr_rec)) { - /* current reshape position [blocks] */ - unsigned long long current_position = - __le32_to_cpu(migr_rec->blocks_per_unit) -- * __le32_to_cpu(migr_rec->curr_migr_unit); -+ * current_migr_unit(migr_rec); - unsigned long long border; - - /* Check that array hasn't become failed. --- -2.25.0 - diff --git a/0015-Fix-spelling-typos.patch b/0015-Fix-spelling-typos.patch deleted file mode 100644 index 47966e0..0000000 --- a/0015-Fix-spelling-typos.patch +++ /dev/null @@ -1,106 +0,0 @@ -From ebf3be9931f31df54df52b1821479e6a80a4d9c6 Mon Sep 17 00:00:00 2001 -From: Dimitri John Ledkov -Date: Tue, 15 Jan 2019 19:08:37 +0000 -Subject: [PATCH] Fix spelling typos. -Git-commit: ebf3be9931f31df54df52b1821479e6a80a4d9c6 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Signed-off-by: Dimitri John Ledkov -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Assemble.c | 2 +- - Create.c | 2 +- - Grow.c | 6 +++--- - super-ddf.c | 2 +- - super-intel.c | 2 +- - 5 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 9f75c68..9f050c1 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -879,7 +879,7 @@ static int force_array(struct mdinfo *content, - current_events = devices[chosen_drive].i.events; - add_another: - if (c->verbose >= 0) -- pr_err("forcing event count in %s(%d) from %d upto %d\n", -+ pr_err("forcing event count in %s(%d) from %d up to %d\n", - devices[chosen_drive].devname, - devices[chosen_drive].i.disk.raid_disk, - (int)(devices[chosen_drive].i.events), -diff --git a/Create.c b/Create.c -index 04b1dfc..6f1b228 100644 ---- a/Create.c -+++ b/Create.c -@@ -823,7 +823,7 @@ int Create(struct supertype *st, char *mddev, - } - bitmap_fd = open(s->bitmap_file, O_RDWR); - if (bitmap_fd < 0) { -- pr_err("weird: %s cannot be openned\n", -+ pr_err("weird: %s cannot be opened\n", - s->bitmap_file); - goto abort_locked; - } -diff --git a/Grow.c b/Grow.c -index 363b209..6d32661 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -446,7 +446,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) - if (offset_setable) { - st->ss->getinfo_super(st, mdi, NULL); - if (sysfs_init(mdi, fd, NULL)) { -- pr_err("failed to intialize sysfs.\n"); -+ pr_err("failed to initialize sysfs.\n"); - free(mdi); - } - rv = sysfs_set_num_signed(mdi, NULL, "bitmap/location", -@@ -2178,7 +2178,7 @@ size_change_error: - memset(&info, 0, sizeof(info)); - info.array = array; - if (sysfs_init(&info, fd, NULL)) { -- pr_err("failed to intialize sysfs.\n"); -+ pr_err("failed to initialize sysfs.\n"); - rv = 1; - goto release; - } -@@ -2903,7 +2903,7 @@ static int impose_level(int fd, int level, char *devname, int verbose) - struct mdinfo info; - - if (sysfs_init(&info, fd, NULL)) { -- pr_err("failed to intialize sysfs.\n"); -+ pr_err("failed to initialize sysfs.\n"); - return 1; - } - -diff --git a/super-ddf.c b/super-ddf.c -index 618542c..c095e8a 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -1900,7 +1900,7 @@ static struct vd_config *find_vdcr(struct ddf_super *ddf, unsigned int inst, - return conf; - } - bad: -- pr_err("Could't find disk %d in array %u\n", n, inst); -+ pr_err("Couldn't find disk %d in array %u\n", n, inst); - return NULL; - } - -diff --git a/super-intel.c b/super-intel.c -index 1cc7d5f..c399433 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -10034,7 +10034,7 @@ static void imsm_process_update(struct supertype *st, - break; - } - default: -- pr_err("error: unsuported process update type:(type: %d)\n", type); -+ pr_err("error: unsupported process update type:(type: %d)\n", type); - } - } - --- -2.25.0 - diff --git a/0015-Mdmonitor-Fix-segfault.patch b/0015-Mdmonitor-Fix-segfault.patch new file mode 100644 index 0000000..e370091 --- /dev/null +++ b/0015-Mdmonitor-Fix-segfault.patch @@ -0,0 +1,101 @@ +From e702f392959d1c2ad2089e595b52235ed97b4e18 Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Mon, 6 Jun 2022 12:32:12 +0200 +Subject: [PATCH 16/61] Mdmonitor: Fix segfault +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Mdadm with "--monitor" parameter requires md device +as an argument to be monitored. If given argument is +not a md device, error shall be returned. Previously +it was not checked and invalid argument caused +segmentation fault. This commit adds checking +that devices passed to mdmonitor are md devices. + +Signed-off-by: Kinga Tanska +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Monitor.c | 10 +++++++++- + mdadm.h | 1 + + mdopen.c | 17 +++++++++++++++++ + 3 files changed, 27 insertions(+), 1 deletion(-) + +diff --git a/Monitor.c b/Monitor.c +index c0ab541..4e5802b 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -182,6 +182,7 @@ int Monitor(struct mddev_dev *devlist, + continue; + if (strcasecmp(mdlist->devname, "") == 0) + continue; ++ + st = xcalloc(1, sizeof *st); + if (mdlist->devname[0] == '/') + st->devname = xstrdup(mdlist->devname); +@@ -190,6 +191,8 @@ int Monitor(struct mddev_dev *devlist, + strcpy(strcpy(st->devname, "/dev/md/"), + mdlist->devname); + } ++ if (!is_mddev(mdlist->devname)) ++ return 1; + st->next = statelist; + st->devnm[0] = 0; + st->percent = RESYNC_UNKNOWN; +@@ -203,7 +206,12 @@ int Monitor(struct mddev_dev *devlist, + struct mddev_dev *dv; + + for (dv = devlist; dv; dv = dv->next) { +- struct state *st = xcalloc(1, sizeof *st); ++ struct state *st; ++ ++ if (!is_mddev(dv->devname)) ++ return 1; ++ ++ st = xcalloc(1, sizeof *st); + mdlist = conf_get_ident(dv->devname); + st->devname = xstrdup(dv->devname); + st->next = statelist; +diff --git a/mdadm.h b/mdadm.h +index 09915a0..d53df16 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1636,6 +1636,7 @@ extern int create_mddev(char *dev, char *name, int autof, int trustworthy, + #define FOREIGN 2 + #define METADATA 3 + extern int open_mddev(char *dev, int report_errors); ++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); +diff --git a/mdopen.c b/mdopen.c +index 245be53..d18c931 100644 +--- a/mdopen.c ++++ b/mdopen.c +@@ -475,6 +475,23 @@ int open_mddev(char *dev, int report_errors) + return mdfd; + } + ++/** ++ * is_mddev() - check that file name passed is an md device. ++ * @dev: file name that has to be checked. ++ * Return: 1 if file passed is an md device, 0 if not. ++ */ ++int is_mddev(char *dev) ++{ ++ int fd = open_mddev(dev, 1); ++ ++ if (fd >= 0) { ++ close(fd); ++ return 1; ++ } ++ ++ return 0; ++} ++ + char *find_free_devnm(int use_partitions) + { + static char devnm[32]; +-- +2.35.3 + diff --git a/0016-Detail.c-do-not-skip-first-character-when-calling-xs.patch b/0016-Detail.c-do-not-skip-first-character-when-calling-xs.patch deleted file mode 100644 index c40ee58..0000000 --- a/0016-Detail.c-do-not-skip-first-character-when-calling-xs.patch +++ /dev/null @@ -1,49 +0,0 @@ -From e3615ecb5b6ad8eb408296878aad5628e0e27166 Mon Sep 17 00:00:00 2001 -From: Coly Li -Date: Tue, 12 Feb 2019 12:53:18 +0800 -Subject: [PATCH] Detail.c: do not skip first character when calling xstrdup in - Detail() -Git-commit: e3615ecb5b6ad8eb408296878aad5628e0e27166 -Patch-mainline: mdadm-4.1+ -References: bsc#1123814 - -'Commit b9c9bd9bacaa ("Detail: ensure --export names are acceptable as -shell variables")' duplicates mdi->sys_name to sysdev string by, - char *sysdev = xstrdup(mdi->sys_name + 1); -which skips the first character of mdi->sys_name. Then when running -mdadm --detail --export, the output looks like, - MD_DEVICE_ev_sda2_ROLE=1 - MD_DEVICE_ev_sda2_DEV=/dev/sda2 -The first character of md device (between MD_DEVICE and _ROLE/_DEV) -is dropped. The expected output should be, - MD_DEVICE_dev_sda2_ROLE=1 - MD_DEVICE_dev_sda2_DEV=/dev/sda2 - -This patch removes the '+ 1' from calling xstrdup() in Detail(), which -gets the dropped first character back. - -Reported-by: Arvin Schnell -Fixes: b9c9bd9bacaa ("Detail: ensure --export names are acceptable as 4 shell variables") -Signed-off-by: Coly Li -Cc: NeilBrown -Signed-off-by: Jes Sorensen ---- - Detail.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index b3e857a..20ea03a 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -284,7 +284,7 @@ int Detail(char *dev, struct context *c) - struct mdinfo *mdi; - for (mdi = sra->devs; mdi; mdi = mdi->next) { - char *path; -- char *sysdev = xstrdup(mdi->sys_name + 1); -+ char *sysdev = xstrdup(mdi->sys_name); - char *cp; - - path = map_dev(mdi->disk.major, --- -2.25.0 - diff --git a/0016-Mdmonitor-Improve-logging-method.patch b/0016-Mdmonitor-Improve-logging-method.patch new file mode 100644 index 0000000..6893ed3 --- /dev/null +++ b/0016-Mdmonitor-Improve-logging-method.patch @@ -0,0 +1,64 @@ +From f5ff2988761625b43eb15555993f2797af29f166 Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Mon, 6 Jun 2022 12:32:13 +0200 +Subject: [PATCH 17/61] Mdmonitor: Improve logging method +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Change logging, and as a result, mdmonitor in verbose +mode will report its configuration. + +Signed-off-by: Kinga Tanska +Signed-off-by: Oleksandr Shchirskyi +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Monitor.c | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +diff --git a/Monitor.c b/Monitor.c +index 4e5802b..6ca1ebe 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -136,24 +136,27 @@ int Monitor(struct mddev_dev *devlist, + struct mddev_ident *mdlist; + int delay_for_event = c->delay; + +- if (!mailaddr) { ++ if (!mailaddr) + mailaddr = conf_get_mailaddr(); +- if (mailaddr && ! c->scan) +- pr_err("Monitor using email address \"%s\" from config file\n", +- mailaddr); +- } +- mailfrom = conf_get_mailfrom(); + +- if (!alert_cmd) { ++ if (!alert_cmd) + alert_cmd = conf_get_program(); +- if (alert_cmd && !c->scan) +- pr_err("Monitor using program \"%s\" from config file\n", +- alert_cmd); +- } ++ ++ mailfrom = conf_get_mailfrom(); ++ + if (c->scan && !mailaddr && !alert_cmd && !dosyslog) { + pr_err("No mail address or alert command - not monitoring.\n"); + return 1; + } ++ ++ if (c->verbose) { ++ pr_err("Monitor is started with delay %ds\n", c->delay); ++ if (mailaddr) ++ pr_err("Monitor using email address %s\n", mailaddr); ++ if (alert_cmd) ++ pr_err("Monitor using program %s\n", alert_cmd); ++ } ++ + info.alert_cmd = alert_cmd; + info.mailaddr = mailaddr; + info.mailfrom = mailfrom; +-- +2.35.3 + diff --git a/0017-Fix-possible-NULL-ptr-dereferences-and-memory-leaks.patch b/0017-Fix-possible-NULL-ptr-dereferences-and-memory-leaks.patch new file mode 100644 index 0000000..4962ca4 --- /dev/null +++ b/0017-Fix-possible-NULL-ptr-dereferences-and-memory-leaks.patch @@ -0,0 +1,76 @@ +From 626bc45396c4959f2c4685c2faa7c4f553f4efdf Mon Sep 17 00:00:00 2001 +From: Mateusz Grzonka +Date: Mon, 13 Jun 2022 11:59:34 +0200 +Subject: [PATCH 18/61] Fix possible NULL ptr dereferences and memory leaks +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +In Assemble there was a NULL check for sra variable, +which effectively didn't stop the execution in every case. +That might have resulted in a NULL pointer dereference. + +Also in super-ddf, mu variable was set to NULL for some condition, +and then immidiately dereferenced. +Additionally some memory wasn't freed as well. + +Signed-off-by: Mateusz Grzonka +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Assemble.c | 7 ++++++- + super-ddf.c | 9 +++++++-- + 2 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 9eac9ce..4b21356 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -1982,7 +1982,12 @@ int assemble_container_content(struct supertype *st, int mdfd, + } + + sra = sysfs_read(mdfd, NULL, GET_VERSION|GET_DEVS); +- if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) { ++ if (sra == NULL) { ++ pr_err("Failed to read sysfs parameters\n"); ++ return 1; ++ } ++ ++ if (strcmp(sra->text_version, content->text_version) != 0) { + if (content->array.major_version == -1 && + content->array.minor_version == -2 && + c->readonly && +diff --git a/super-ddf.c b/super-ddf.c +index 8cda23a..abbc8b0 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -5125,13 +5125,16 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a, + */ + vc = find_vdcr(ddf, a->info.container_member, rv->disk.raid_disk, + &n_bvd, &vcl); +- if (vc == NULL) ++ if (vc == NULL) { ++ free(rv); + return NULL; ++ } + + mu = xmalloc(sizeof(*mu)); + if (posix_memalign(&mu->space, 512, sizeof(struct vcl)) != 0) { + free(mu); +- mu = NULL; ++ free(rv); ++ return NULL; + } + + mu->len = ddf->conf_rec_len * 512 * vcl->conf.sec_elmnt_count; +@@ -5161,6 +5164,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a, + pr_err("BUG: can't find disk %d (%d/%d)\n", + di->disk.raid_disk, + di->disk.major, di->disk.minor); ++ free(mu); ++ free(rv); + return NULL; + } + vc->phys_refnum[i_prim] = ddf->phys->entries[dl->pdnum].refnum; +-- +2.35.3 + diff --git a/0018-Fix-reshape-for-decreasing-data-offset.patch b/0018-Fix-reshape-for-decreasing-data-offset.patch deleted file mode 100644 index 3f167e9..0000000 --- a/0018-Fix-reshape-for-decreasing-data-offset.patch +++ /dev/null @@ -1,75 +0,0 @@ -From cab114c5ca870e5f1b57fb2602cd9a038271c2e0 Mon Sep 17 00:00:00 2001 -From: Corey Hickey -Date: Mon, 11 Feb 2019 17:18:38 -0800 -Subject: [PATCH] Fix reshape for decreasing data offset -Git-commit: cab114c5ca870e5f1b57fb2602cd9a038271c2e0 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -...when not changing the number of disks. - -This patch needs context to explain. These are the relevant parts of -the original code (condensed and annotated): - -if (dir > 0) { - /* Increase data offset (reshape backwards) */ - if (data_offset < sd->data_offset + min) { - pr_err("--data-offset too small on %s\n", - dn); - goto release; - } -} else { - /* Decrease data offset (reshape forwards) */ - if (data_offset < sd->data_offset - min) { - pr_err("--data-offset too small on %s\n", - dn); - goto release; - } -} - -When this code is reached, mdadm has already decided on a reshape -direction. When increasing the data offset, the reshape runs backwards -(dir==1); when decreasing the data offset, the reshape runs forwards -(dir==-1). - -The conditional within the backwards reshape is correct: the requested -offset must be larger than the old offset plus a minimum delta; thus the -reshape has room to work. - -For the forwards reshape, the requested offset needs to be smaller than -the old offset minus a minimum delta; to do this correctly, the -comparison must be reversed. - -Also update the error message. - -Note: I have tested this change on a RAID 5 on Linux 4.18.0 and verified -that there were no errors from the kernel and that the device data -remained intact. I do not know if there are considerations for different -RAID levels. - -Signed-off-by: Corey Hickey -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Grow.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Grow.c b/Grow.c -index 6d32661..764374f 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -2613,8 +2613,8 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st, - goto release; - } - if (data_offset != INVALID_SECTORS && -- data_offset < sd->data_offset - min) { -- pr_err("--data-offset too small on %s\n", -+ data_offset > sd->data_offset - min) { -+ pr_err("--data-offset too large on %s\n", - dn); - goto release; - } --- -2.25.0 - diff --git a/0018-imsm-Remove-possibility-for-get_imsm_dev-to-return-N.patch b/0018-imsm-Remove-possibility-for-get_imsm_dev-to-return-N.patch new file mode 100644 index 0000000..9e4cb8d --- /dev/null +++ b/0018-imsm-Remove-possibility-for-get_imsm_dev-to-return-N.patch @@ -0,0 +1,304 @@ +From 756a15f32338fdf0c562678694bc8991ad6afb90 Mon Sep 17 00:00:00 2001 +From: Mateusz Grzonka +Date: Mon, 13 Jun 2022 12:00:09 +0200 +Subject: [PATCH 19/61] imsm: Remove possibility for get_imsm_dev to return + NULL +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Returning NULL from get_imsm_dev or __get_imsm_dev will cause segfault. +Guarantee that it never happens. + +Signed-off-by: Mateusz Grzonka +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super-intel.c | 153 +++++++++++++++++++++++++------------------------- + 1 file changed, 78 insertions(+), 75 deletions(-) + +diff --git a/super-intel.c b/super-intel.c +index ba3bd41..3788feb 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -851,6 +851,21 @@ static struct disk_info *get_disk_info(struct imsm_update_create_array *update) + return inf; + } + ++/** ++ * __get_imsm_dev() - Get device with index from imsm_super. ++ * @mpb: &imsm_super pointer, not NULL. ++ * @index: Device index. ++ * ++ * Function works as non-NULL, aborting in such a case, ++ * when NULL would be returned. ++ * ++ * Device index should be in range 0 up to num_raid_devs. ++ * Function assumes the index was already verified. ++ * Index must be valid, otherwise abort() is called. ++ * ++ * Return: Pointer to corresponding imsm_dev. ++ * ++ */ + static struct imsm_dev *__get_imsm_dev(struct imsm_super *mpb, __u8 index) + { + int offset; +@@ -858,30 +873,47 @@ static struct imsm_dev *__get_imsm_dev(struct imsm_super *mpb, __u8 index) + void *_mpb = mpb; + + if (index >= mpb->num_raid_devs) +- return NULL; ++ goto error; + + /* devices start after all disks */ + offset = ((void *) &mpb->disk[mpb->num_disks]) - _mpb; + +- for (i = 0; i <= index; i++) ++ for (i = 0; i <= index; i++, offset += sizeof_imsm_dev(_mpb + offset, 0)) + if (i == index) + return _mpb + offset; +- else +- offset += sizeof_imsm_dev(_mpb + offset, 0); +- +- return NULL; ++error: ++ pr_err("cannot find imsm_dev with index %u in imsm_super\n", index); ++ abort(); + } + ++/** ++ * get_imsm_dev() - Get device with index from intel_super. ++ * @super: &intel_super pointer, not NULL. ++ * @index: Device index. ++ * ++ * Function works as non-NULL, aborting in such a case, ++ * when NULL would be returned. ++ * ++ * Device index should be in range 0 up to num_raid_devs. ++ * Function assumes the index was already verified. ++ * Index must be valid, otherwise abort() is called. ++ * ++ * Return: Pointer to corresponding imsm_dev. ++ * ++ */ + static struct imsm_dev *get_imsm_dev(struct intel_super *super, __u8 index) + { + struct intel_dev *dv; + + if (index >= super->anchor->num_raid_devs) +- return NULL; ++ goto error; ++ + for (dv = super->devlist; dv; dv = dv->next) + if (dv->index == index) + return dv->dev; +- return NULL; ++error: ++ pr_err("cannot find imsm_dev with index %u in intel_super\n", index); ++ abort(); + } + + static inline unsigned long long __le48_to_cpu(const struct bbm_log_block_addr +@@ -4364,8 +4396,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 && +- dev_iter->vol.migr_state == 1 && ++ if (dev_iter->vol.migr_state == 1 && + dev_iter->vol.migr_type == MIGR_GEN_MIGR) { + /* This device is migrating */ + map0 = get_imsm_map(dev_iter, MAP_0); +@@ -4514,8 +4545,6 @@ static void clear_hi(struct intel_super *super) + } + for (i = 0; i < mpb->num_raid_devs; ++i) { + struct imsm_dev *dev = get_imsm_dev(super, i); +- if (!dev) +- return; + for (n = 0; n < 2; ++n) { + struct imsm_map *map = get_imsm_map(dev, n); + if (!map) +@@ -5836,7 +5865,7 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, + struct imsm_dev *_dev = __get_imsm_dev(mpb, 0); + + _disk = __get_imsm_disk(mpb, dl->index); +- if (!_dev || !_disk) { ++ if (!_disk) { + pr_err("BUG mpb setup error\n"); + return 1; + } +@@ -6171,10 +6200,10 @@ static int write_super_imsm(struct supertype *st, int doclose) + for (i = 0; i < mpb->num_raid_devs; i++) { + struct imsm_dev *dev = __get_imsm_dev(mpb, i); + struct imsm_dev *dev2 = get_imsm_dev(super, i); +- if (dev && dev2) { +- imsm_copy_dev(dev, dev2); +- mpb_size += sizeof_imsm_dev(dev, 0); +- } ++ ++ imsm_copy_dev(dev, dev2); ++ mpb_size += sizeof_imsm_dev(dev, 0); ++ + if (is_gen_migration(dev2)) + clear_migration_record = 0; + } +@@ -9033,29 +9062,26 @@ static int imsm_rebuild_allowed(struct supertype *cont, int dev_idx, int failed) + __u8 state; + + dev2 = get_imsm_dev(cont->sb, dev_idx); +- if (dev2) { +- state = imsm_check_degraded(cont->sb, dev2, failed, MAP_0); +- if (state == IMSM_T_STATE_FAILED) { +- map = get_imsm_map(dev2, MAP_0); +- if (!map) +- return 1; +- for (slot = 0; slot < map->num_members; slot++) { +- /* +- * Check if failed disks are deleted from intel +- * disk list or are marked to be deleted +- */ +- idx = get_imsm_disk_idx(dev2, slot, MAP_X); +- idisk = get_imsm_dl_disk(cont->sb, idx); +- /* +- * Do not rebuild the array if failed disks +- * from failed sub-array are not removed from +- * container. +- */ +- if (idisk && +- is_failed(&idisk->disk) && +- (idisk->action != DISK_REMOVE)) +- return 0; +- } ++ ++ state = imsm_check_degraded(cont->sb, dev2, failed, MAP_0); ++ if (state == IMSM_T_STATE_FAILED) { ++ map = get_imsm_map(dev2, MAP_0); ++ for (slot = 0; slot < map->num_members; slot++) { ++ /* ++ * Check if failed disks are deleted from intel ++ * disk list or are marked to be deleted ++ */ ++ idx = get_imsm_disk_idx(dev2, slot, MAP_X); ++ idisk = get_imsm_dl_disk(cont->sb, idx); ++ /* ++ * Do not rebuild the array if failed disks ++ * from failed sub-array are not removed from ++ * container. ++ */ ++ if (idisk && ++ is_failed(&idisk->disk) && ++ (idisk->action != DISK_REMOVE)) ++ return 0; + } + } + return 1; +@@ -10089,7 +10115,6 @@ static void imsm_process_update(struct supertype *st, + int victim = u->dev_idx; + struct active_array *a; + struct intel_dev **dp; +- struct imsm_dev *dev; + + /* sanity check that we are not affecting the uuid of + * active arrays, or deleting an active array +@@ -10105,8 +10130,7 @@ static void imsm_process_update(struct supertype *st, + * is active in the container, so checking + * mpb->num_raid_devs is just extra paranoia + */ +- dev = get_imsm_dev(super, victim); +- if (a || !dev || mpb->num_raid_devs == 1) { ++ if (a || mpb->num_raid_devs == 1 || victim >= super->anchor->num_raid_devs) { + dprintf("failed to delete subarray-%d\n", victim); + break; + } +@@ -10140,7 +10164,7 @@ static void imsm_process_update(struct supertype *st, + if (a->info.container_member == target) + break; + dev = get_imsm_dev(super, u->dev_idx); +- if (a || !dev || !check_name(super, name, 1)) { ++ if (a || !check_name(super, name, 1)) { + dprintf("failed to rename subarray-%d\n", target); + break; + } +@@ -10169,10 +10193,6 @@ static void imsm_process_update(struct supertype *st, + struct imsm_update_rwh_policy *u = (void *)update->buf; + int target = u->dev_idx; + struct imsm_dev *dev = get_imsm_dev(super, target); +- if (!dev) { +- dprintf("could not find subarray-%d\n", target); +- break; +- } + + if (dev->rwh_policy != u->new_policy) { + dev->rwh_policy = u->new_policy; +@@ -11397,8 +11417,10 @@ static int imsm_create_metadata_update_for_migration( + { + struct intel_super *super = st->sb; + int update_memory_size; ++ int current_chunk_size; + struct imsm_update_reshape_migration *u; +- struct imsm_dev *dev; ++ struct imsm_dev *dev = get_imsm_dev(super, super->current_vol); ++ struct imsm_map *map = get_imsm_map(dev, MAP_0); + int previous_level = -1; + + dprintf("(enter) New Level = %i\n", geo->level); +@@ -11415,23 +11437,15 @@ static int imsm_create_metadata_update_for_migration( + u->new_disks[0] = -1; + u->new_chunksize = -1; + +- dev = get_imsm_dev(super, u->subdev); +- if (dev) { +- struct imsm_map *map; ++ current_chunk_size = __le16_to_cpu(map->blocks_per_strip) / 2; + +- map = get_imsm_map(dev, MAP_0); +- if (map) { +- int current_chunk_size = +- __le16_to_cpu(map->blocks_per_strip) / 2; +- +- if (geo->chunksize != current_chunk_size) { +- u->new_chunksize = geo->chunksize / 1024; +- dprintf("imsm: chunk size change from %i to %i\n", +- current_chunk_size, u->new_chunksize); +- } +- previous_level = map->raid_level; +- } ++ if (geo->chunksize != current_chunk_size) { ++ u->new_chunksize = geo->chunksize / 1024; ++ dprintf("imsm: chunk size change from %i to %i\n", ++ current_chunk_size, u->new_chunksize); + } ++ previous_level = map->raid_level; ++ + if (geo->level == 5 && previous_level == 0) { + struct mdinfo *spares = NULL; + +@@ -12519,9 +12533,6 @@ static int validate_internal_bitmap_imsm(struct supertype *st) + unsigned long long offset; + struct dl *d; + +- if (!dev) +- return -1; +- + if (dev->rwh_policy != RWH_BITMAP) + return 0; + +@@ -12567,16 +12578,8 @@ static int add_internal_bitmap_imsm(struct supertype *st, int *chunkp, + return -1; + + dev = get_imsm_dev(super, vol_idx); +- +- if (!dev) { +- dprintf("cannot find the device for volume index %d\n", +- vol_idx); +- return -1; +- } + dev->rwh_policy = RWH_BITMAP; +- + *chunkp = calculate_bitmap_chunksize(st, dev); +- + return 0; + } + +-- +2.35.3 + diff --git a/0019-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch b/0019-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch new file mode 100644 index 0000000..860866a --- /dev/null +++ b/0019-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch @@ -0,0 +1,87 @@ +From 190dc029b141c423e724566cbed5d5afbb10b05a Mon Sep 17 00:00:00 2001 +From: Nigel Croxon +Date: Mon, 18 Apr 2022 13:44:23 -0400 +Subject: [PATCH 20/61] Revert "mdadm: fix coredump of mdadm --monitor -r" +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +This reverts commit 546047688e1c64638f462147c755b58119cabdc8. + +The change from commit mdadm: fix coredump of mdadm +--monitor -r broke the printing of the return message when +passing -r to mdadm --manage, the removal of a device from +an array. + +If the current code reverts this commit, both issues are +still fixed. + +The original problem reported that the fix tried to address +was: The --monitor -r option requires a parameter, +otherwise a null pointer will be manipulated when +converting to integer data, and a core dump will appear. + +The original problem was really fixed with: +60815698c0a Refactor parse_num and use it to parse optarg. +Which added a check for NULL in 'optarg' before moving it +to the 'increments' variable. + +New issue: When trying to remove a device using the short +argument -r, instead of the long argument --remove, the +output is empty. The problem started when commit +546047688e1c was added. + +Steps to Reproduce: +1. create/assemble /dev/md0 device +2. mdadm --manage /dev/md0 -r /dev/vdxx + +Actual results: +Nothing, empty output, nothing happens, the device is still +connected to the array. + +The output should have stated "mdadm: hot remove failed +for /dev/vdxx: Device or resource busy", if the device was +still active. Or it should remove the device and print +a message: + +mdadm: set /dev/vdd faulty in /dev/md0 +mdadm: hot removed /dev/vdd from /dev/md0 + +The following commit should be reverted as it breaks +mdadm --manage -r. + +commit 546047688e1c64638f462147c755b58119cabdc8 +Author: Wu Guanghao +Date: Mon Aug 16 15:24:51 2021 +0800 +mdadm: fix coredump of mdadm --monitor -r + +-Nigel + +Signed-off-by: Nigel Croxon +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + ReadMe.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/ReadMe.c b/ReadMe.c +index 8f873c4..bec1be9 100644 +--- a/ReadMe.c ++++ b/ReadMe.c +@@ -81,11 +81,11 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n"; + * found, it is started. + */ + +-char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k"; ++char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; + char short_bitmap_options[]= +- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; ++ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; + char short_bitmap_auto_options[]= +- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:"; ++ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:"; + + struct option long_options[] = { + {"manage", 0, 0, ManageOpt}, +-- +2.35.3 + diff --git a/0019-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch b/0019-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch deleted file mode 100644 index 694ae95..0000000 --- a/0019-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 76b906d2406cdf136f64de77e881eb2d180108d9 Mon Sep 17 00:00:00 2001 -From: Gioh Kim -Date: Fri, 7 Dec 2018 14:30:09 +0100 -Subject: [PATCH] mdadm/tests: add one test case for failfast of raid1 -Git-commit: 76b906d2406cdf136f64de77e881eb2d180108d9 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -This creates raid1 device with the failfast option and check all -slaves have the failfast flag. And it does assembling and growing -the raid1 device and check the failfast works fine. - -Signed-off-by: Gioh Kim -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - tests/05r1-failfast | 74 +++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 74 insertions(+) - create mode 100644 tests/05r1-failfast - -diff --git a/tests/05r1-failfast b/tests/05r1-failfast -new file mode 100644 -index 0000000..823dd6f ---- /dev/null -+++ b/tests/05r1-failfast -@@ -0,0 +1,74 @@ -+ -+# create a simple mirror and check failfast flag works -+mdadm -CR $md0 -e1.2 --level=raid1 --failfast -n2 $dev0 $dev1 -+check raid1 -+if grep -v failfast /sys/block/md0/md/rd*/state > /dev/null -+then -+ die "failfast missing" -+fi -+ -+# Removing works with the failfast flag -+mdadm $md0 -f $dev0 -+mdadm $md0 -r $dev0 -+if grep -v failfast /sys/block/md0/md/rd1/state > /dev/null -+then -+ die "failfast missing" -+fi -+ -+# Adding works with the failfast flag -+mdadm $md0 -a --failfast $dev0 -+check wait -+if grep -v failfast /sys/block/md0/md/rd0/state > /dev/null -+then -+ die "failfast missing" -+fi -+ -+mdadm -S $md0 -+ -+# Assembling works with the failfast flag -+mdadm -A $md0 $dev0 $dev1 -+check raid1 -+if grep -v failfast /sys/block/md0/md/rd*/state > /dev/null -+then -+ die "failfast missing" -+fi -+ -+# Adding works with the nofailfast flag -+mdadm $md0 -f $dev0 -+mdadm $md0 -r $dev0 -+mdadm $md0 -a --nofailfast $dev0 -+check wait -+if grep failfast /sys/block/md0/md/rd0/state > /dev/null -+then -+ die "failfast should be missing" -+fi -+ -+# Assembling with one faulty slave works with the failfast flag -+mdadm $md0 -f $dev0 -+mdadm $md0 -r $dev0 -+mdadm -S $md0 -+mdadm -A $md0 $dev0 $dev1 -+check raid1 -+mdadm -S $md0 -+ -+# Spare works with the failfast flag -+mdadm -CR $md0 -e1.2 --level=raid1 --failfast -n2 $dev0 $dev1 -+check raid1 -+mdadm $md0 -a --failfast $dev2 -+check wait -+check spares 1 -+if grep -v failfast /sys/block/md0/md/rd*/state > /dev/null -+then -+ die "failfast missing" -+fi -+ -+# Grow works with the failfast flag -+mdadm -G $md0 --raid-devices=3 -+check wait -+if grep -v failfast /sys/block/md0/md/rd*/state > /dev/null -+then -+ die "failfast missing" -+fi -+mdadm -S $md0 -+ -+exit 0 --- -2.25.0 - diff --git a/0020-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch b/0020-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch deleted file mode 100644 index fd31b0a..0000000 --- a/0020-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 69d084784de196acec8ab703cd1b379af211d624 Mon Sep 17 00:00:00 2001 -From: Artur Paszkiewicz -Date: Fri, 22 Feb 2019 10:15:45 +0100 -Subject: [PATCH] mdmon: don't attempt to manage new arrays when terminating -Git-commit: 69d084784de196acec8ab703cd1b379af211d624 -Patch-mainline: mdadm-4.1-12 -References: bsc#1127526 - -When mdmon gets a SIGTERM, it stops managing arrays that are clean. If -there is more that one array in the container and one of them is dirty -and the clean one is still present in mdstat, mdmon will treat it as a -new array and start managing it again. This leads to a cycle of -remove_old() / manage_new() calls for the clean array, until the other -one also becomes clean. - -Prevent this by not calling manage_new() if sigterm is set. Also, remove -a check for sigterm in manage_new() because the condition will never be -true. - -Signed-off-by: Artur Paszkiewicz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - managemon.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/managemon.c b/managemon.c -index 101231c..29b91ba 100644 ---- a/managemon.c -+++ b/managemon.c -@@ -727,9 +727,7 @@ static void manage_new(struct mdstat_ent *mdstat, - dprintf("inst: %s action: %d state: %d\n", inst, - new->action_fd, new->info.state_fd); - -- if (sigterm) -- new->info.safe_mode_delay = 1; -- else if (mdi->safe_mode_delay >= 50) -+ if (mdi->safe_mode_delay >= 50) - /* Normal start, mdadm set this. */ - new->info.safe_mode_delay = mdi->safe_mode_delay; - else -@@ -803,7 +801,7 @@ void manage(struct mdstat_ent *mdstat, struct supertype *container) - break; - } - } -- if (a == NULL || !a->container) -+ if ((a == NULL || !a->container) && !sigterm) - manage_new(mdstat, container, a); - } - } --- -2.16.4 - diff --git a/0020-util-replace-ioctl-use-with-function.patch b/0020-util-replace-ioctl-use-with-function.patch new file mode 100644 index 0000000..7651040 --- /dev/null +++ b/0020-util-replace-ioctl-use-with-function.patch @@ -0,0 +1,33 @@ +From 953cc7e5a485a91ddec7312c7a5d7779749fad5f Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Tue, 21 Jun 2022 00:10:39 +0800 +Subject: [PATCH 21/61] util: replace ioctl use with function +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Replace using of ioctl calling to get md array info with +special function prepared to it. + +Signed-off-by: Kinga Tanska +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + util.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util.c b/util.c +index cc94f96..38f0420 100644 +--- a/util.c ++++ b/util.c +@@ -267,7 +267,7 @@ int md_array_active(int fd) + * GET_ARRAY_INFO doesn't provide access to the proper state + * information, so fallback to a basic check for raid_disks != 0 + */ +- ret = ioctl(fd, GET_ARRAY_INFO, &array); ++ ret = md_get_array_info(fd, &array); + } + + return !ret; +-- +2.35.3 + diff --git a/1004-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch b/0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch similarity index 90% rename from 1004-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch rename to 0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch index 5b835b8..4bc6f21 100644 --- a/1004-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch +++ b/0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch @@ -1,12 +1,10 @@ -From 3a84e55858171f96321fa4c775fe7e4e851c6b85 Mon Sep 17 00:00:00 2001 +From 63902857b98c37c8ac4b837bb01d006b327a4532 Mon Sep 17 00:00:00 2001 From: Heming Zhao -Date: Thu, 31 Mar 2022 23:30:51 +0800 -Subject: [PATCH] mdadm/super1: restore commit 45a87c2f31335 to fix clustered - slot issue -To: linux-raid@vger.kernel.org, - jes@trained-monkey.org -Patch-mainline: N/A, maintainer didn't respond this patch. -References: bsc#1197158, bsc#1197571 +Date: Tue, 21 Jun 2022 00:10:40 +0800 +Subject: [PATCH 22/61] mdadm/super1: restore commit 45a87c2f31335 to fix + clustered slot issue +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 Commit 9d67f6496c71 ("mdadm:check the nodes when operate clustered array") modified assignment logic for st->nodes in write_bitmap1(), @@ -81,12 +79,13 @@ kernel: md0: detected capacity change from 0 to 612352 Acked-by: Coly Li Signed-off-by: Heming Zhao +Signed-off-by: Jes Sorensen --- super1.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/super1.c b/super1.c -index a12a5bc847b9..f08d4f831319 100644 +index e3e2f95..3a0c69f 100644 --- a/super1.c +++ b/super1.c @@ -2674,7 +2674,17 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update @@ -109,5 +108,5 @@ index a12a5bc847b9..f08d4f831319 100644 * Since the nodes num is not increased, no * need to check the space enough or not, -- -2.33.0 +2.35.3 diff --git a/0021-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch b/0021-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch deleted file mode 100644 index c555fd2..0000000 --- a/0021-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch +++ /dev/null @@ -1,62 +0,0 @@ -From d2e11da4b7fd0453e942f43e4196dc63b3dbd708 Mon Sep 17 00:00:00 2001 -From: Pawel Baldysiak -Date: Fri, 22 Feb 2019 13:30:27 +0100 -Subject: [PATCH] mdmon: wait for previous mdmon to exit during takeover -Git-commit: d2e11da4b7fd0453e942f43e4196dc63b3dbd708 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Since the patch c76242c5("mdmon: get safe mode delay file descriptor -early"), safe_mode_dalay is set properly by initrd mdmon. But in some -cases with filesystem traffic since the very start of the system, it -might take a while to transit to clean state. Due to fact that new -mdmon does not wait for the old one to exit - it might happen that the -new one switches safe_mode_delay back to seconds, before old one exits. -As the result two mdmons are running concurrently on same array. - -Wait for the old mdmon to exit by pinging it with SIGUSR1 signal, just -in case it is sleeping. - -Signed-off-by: Pawel Baldysiak -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdmon.c | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/mdmon.c b/mdmon.c -index 0955fcc..ff985d2 100644 ---- a/mdmon.c -+++ b/mdmon.c -@@ -171,6 +171,7 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock) - int fd; - int n; - long fl; -+ int rv; - - /* first rule of survival... don't off yourself */ - if (pid == getpid()) -@@ -201,9 +202,16 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock) - fl &= ~O_NONBLOCK; - fcntl(sock, F_SETFL, fl); - n = read(sock, buf, 100); -- /* Ignore result, it is just the wait that -- * matters -- */ -+ -+ /* If there is I/O going on it might took some time to get to -+ * clean state. Wait for monitor to exit fully to avoid races. -+ * Ping it with SIGUSR1 in case that it is sleeping */ -+ for (n = 0; n < 25; n++) { -+ rv = kill(pid, SIGUSR1); -+ if (rv < 0) -+ break; -+ usleep(200000); -+ } - } - - void remove_pidfile(char *devname) --- -2.25.0 - diff --git a/0022-Assemble-Fix-starting-array-with-initial-reshape-che.patch b/0022-Assemble-Fix-starting-array-with-initial-reshape-che.patch deleted file mode 100644 index 0cbbcbd..0000000 --- a/0022-Assemble-Fix-starting-array-with-initial-reshape-che.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 2b57e4fe041d52ae29866c93a878a11c07223cff Mon Sep 17 00:00:00 2001 -From: Pawel Baldysiak -Date: Fri, 22 Feb 2019 12:56:27 +0100 -Subject: [PATCH] Assemble: Fix starting array with initial reshape checkpoint -Git-commit: 2b57e4fe041d52ae29866c93a878a11c07223cff -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -If array was stopped during reshape initialization, -there might be a "0" checkpoint recorded in metadata. -If array with such condition (reshape with position 0) -is passed to kernel - it will refuse to start such array. - -Treat such array as normal during assemble, Grow_continue() will -reinitialize and start the reshape. - -Signed-off-by: Pawel Baldysiak -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Assemble.c | 18 ++++++++++++++++-- - 1 file changed, 16 insertions(+), 2 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 9f050c1..420c7b3 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -2061,8 +2061,22 @@ int assemble_container_content(struct supertype *st, int mdfd, - spare, &c->backup_file, c->verbose) == 1) - return 1; - -- err = sysfs_set_str(content, NULL, -- "array_state", "readonly"); -+ if (content->reshape_progress == 0) { -+ /* If reshape progress is 0 - we are assembling the -+ * array that was stopped, before reshape has started. -+ * Array needs to be started as active, Grow_continue() -+ * will start the reshape. -+ */ -+ sysfs_set_num(content, NULL, "reshape_position", -+ MaxSector); -+ err = sysfs_set_str(content, NULL, -+ "array_state", "active"); -+ sysfs_set_num(content, NULL, "reshape_position", 0); -+ } else { -+ err = sysfs_set_str(content, NULL, -+ "array_state", "readonly"); -+ } -+ - if (err) - return 1; - --- -2.25.0 - diff --git a/0022-imsm-introduce-get_disk_slot_in_dev.patch b/0022-imsm-introduce-get_disk_slot_in_dev.patch new file mode 100644 index 0000000..9251f74 --- /dev/null +++ b/0022-imsm-introduce-get_disk_slot_in_dev.patch @@ -0,0 +1,124 @@ +From 76c152ca9851e9fcdf52e8f6e7e6c09b936bdd14 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 21 Jun 2022 00:10:41 +0800 +Subject: [PATCH 23/61] imsm: introduce get_disk_slot_in_dev() +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +The routine was added to remove unnecessary get_imsm_dev() and +get_imsm_map() calls, used only to determine disk slot. + +Additionally, enum for IMSM return statues was added for further usage. + +Signed-off-by: Mariusz Tkaczyk +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + super-intel.c | 47 ++++++++++++++++++++++++++++++++++++----------- + 1 file changed, 36 insertions(+), 11 deletions(-) + +diff --git a/super-intel.c b/super-intel.c +index 3788feb..cd1f1e3 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -366,6 +366,18 @@ struct migr_record { + }; + ASSERT_SIZE(migr_record, 128) + ++/** ++ * enum imsm_status - internal IMSM return values representation. ++ * @STATUS_OK: function succeeded. ++ * @STATUS_ERROR: General error ocurred (not specified). ++ * ++ * Typedefed to imsm_status_t. ++ */ ++typedef enum imsm_status { ++ IMSM_STATUS_ERROR = -1, ++ IMSM_STATUS_OK = 0, ++} imsm_status_t; ++ + struct md_list { + /* usage marker: + * 1: load metadata +@@ -1183,7 +1195,7 @@ static void set_imsm_ord_tbl_ent(struct imsm_map *map, int slot, __u32 ord) + map->disk_ord_tbl[slot] = __cpu_to_le32(ord); + } + +-static int get_imsm_disk_slot(struct imsm_map *map, unsigned idx) ++static int get_imsm_disk_slot(struct imsm_map *map, const unsigned int idx) + { + int slot; + __u32 ord; +@@ -1194,7 +1206,7 @@ static int get_imsm_disk_slot(struct imsm_map *map, unsigned idx) + return slot; + } + +- return -1; ++ return IMSM_STATUS_ERROR; + } + + static int get_imsm_raid_level(struct imsm_map *map) +@@ -1209,6 +1221,23 @@ static int get_imsm_raid_level(struct imsm_map *map) + return map->raid_level; + } + ++/** ++ * get_disk_slot_in_dev() - retrieve disk slot from &imsm_dev. ++ * @super: &intel_super pointer, not NULL. ++ * @dev_idx: imsm device index. ++ * @idx: disk index. ++ * ++ * Return: Slot on success, IMSM_STATUS_ERROR otherwise. ++ */ ++static int get_disk_slot_in_dev(struct intel_super *super, const __u8 dev_idx, ++ const unsigned int idx) ++{ ++ struct imsm_dev *dev = get_imsm_dev(super, dev_idx); ++ struct imsm_map *map = get_imsm_map(dev, MAP_0); ++ ++ return get_imsm_disk_slot(map, idx); ++} ++ + static int cmp_extent(const void *av, const void *bv) + { + const struct extent *a = av; +@@ -1225,13 +1254,9 @@ static int count_memberships(struct dl *dl, struct intel_super *super) + int memberships = 0; + int i; + +- for (i = 0; i < super->anchor->num_raid_devs; i++) { +- struct imsm_dev *dev = get_imsm_dev(super, i); +- struct imsm_map *map = get_imsm_map(dev, MAP_0); +- +- if (get_imsm_disk_slot(map, dl->index) >= 0) ++ for (i = 0; i < super->anchor->num_raid_devs; i++) ++ if (get_disk_slot_in_dev(super, i, dl->index) >= 0) + memberships++; +- } + + return memberships; + } +@@ -1941,6 +1966,7 @@ void examine_migr_rec_imsm(struct intel_super *super) + + /* first map under migration */ + map = get_imsm_map(dev, MAP_0); ++ + if (map) + slot = get_imsm_disk_slot(map, super->disks->index); + if (map == NULL || slot > 1 || slot < 0) { +@@ -9655,10 +9681,9 @@ static int apply_update_activate_spare(struct imsm_update_activate_spare *u, + /* count arrays using the victim in the metadata */ + found = 0; + for (a = active_array; a ; a = a->next) { +- dev = get_imsm_dev(super, a->info.container_member); +- map = get_imsm_map(dev, MAP_0); ++ int dev_idx = a->info.container_member; + +- if (get_imsm_disk_slot(map, victim) >= 0) ++ if (get_disk_slot_in_dev(super, dev_idx, victim) >= 0) + found++; + } + +-- +2.35.3 + diff --git a/0023-add-missing-units-to-examine.patch b/0023-add-missing-units-to-examine.patch deleted file mode 100644 index 54f626e..0000000 --- a/0023-add-missing-units-to-examine.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 227aeaa872d4898273cf87a4253898823d556c43 Mon Sep 17 00:00:00 2001 -From: Corey Hickey -Date: Mon, 11 Feb 2019 17:42:27 -0800 -Subject: [PATCH] add missing units to --examine -Git-commit: 227aeaa872d4898273cf87a4253898823d556c43 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Within the output of "mdadm --examine", there are three sizes reported -on adjacent lines. For example: - -$ sudo mdadm --examine /dev/md3 -[...] - Avail Dev Size : 17580545024 (8383.06 GiB 9001.24 GB) - Array Size : 17580417024 (16765.99 GiB 18002.35 GB) - Used Dev Size : 11720278016 (5588.66 GiB 6000.78 GB) -[...] - -This can be confusing, since the first and third line are in 512-byte -sectors, and the second is in KiB. - -Add units to avoid ambiguity. - -(I don't particularly like the "KiB" notation, but it is at least -unambiguous.) - -Signed-off-by: Corey Hickey -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super1.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/super1.c b/super1.c -index 636a286..b85dc20 100644 ---- a/super1.c -+++ b/super1.c -@@ -360,7 +360,7 @@ static void examine_super1(struct supertype *st, char *homehost) - printf(" Raid Level : %s\n", c?c:"-unknown-"); - printf(" Raid Devices : %d\n", __le32_to_cpu(sb->raid_disks)); - printf("\n"); -- printf(" Avail Dev Size : %llu%s\n", -+ printf(" Avail Dev Size : %llu sectors%s\n", - (unsigned long long)__le64_to_cpu(sb->data_size), - human_size(__le64_to_cpu(sb->data_size)<<9)); - if (__le32_to_cpu(sb->level) > 0) { -@@ -378,11 +378,11 @@ static void examine_super1(struct supertype *st, char *homehost) - if (ddsks) { - long long asize = __le64_to_cpu(sb->size); - asize = (asize << 9) * ddsks / ddsks_denom; -- printf(" Array Size : %llu%s\n", -+ printf(" Array Size : %llu KiB%s\n", - asize >> 10, human_size(asize)); - } - if (sb->size != sb->data_size) -- printf(" Used Dev Size : %llu%s\n", -+ printf(" Used Dev Size : %llu sectors%s\n", - (unsigned long long)__le64_to_cpu(sb->size), - human_size(__le64_to_cpu(sb->size)<<9)); - } --- -2.25.0 - diff --git a/0023-imsm-use-same-slot-across-container.patch b/0023-imsm-use-same-slot-across-container.patch new file mode 100644 index 0000000..d500e01 --- /dev/null +++ b/0023-imsm-use-same-slot-across-container.patch @@ -0,0 +1,254 @@ +From 6d4d9ab295de165e57b5c30e044028dbffb8f297 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 21 Jun 2022 00:10:42 +0800 +Subject: [PATCH 24/61] imsm: use same slot across container +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Autolayout relies on drives order on super->disks list, but +it is not quaranted by readdir() in sysfs_read(). As a result +drive could be put in different slot in second volume. + +Make it consistent by reffering to first volume, if exists. + +Use enum imsm_status to unify error handling. + +Signed-off-by: Mariusz Tkaczyk +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + super-intel.c | 169 ++++++++++++++++++++++++++++++++------------------ + 1 file changed, 108 insertions(+), 61 deletions(-) + +diff --git a/super-intel.c b/super-intel.c +index cd1f1e3..deef7c8 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -7522,11 +7522,27 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, + return 1; + } + +-static int imsm_get_free_size(struct supertype *st, int raiddisks, +- unsigned long long size, int chunk, +- unsigned long long *freesize) ++/** ++ * imsm_get_free_size() - get the biggest, common free space from members. ++ * @super: &intel_super pointer, not NULL. ++ * @raiddisks: number of raid disks. ++ * @size: requested size, could be 0 (means max size). ++ * @chunk: requested chunk. ++ * @freesize: pointer for returned size value. ++ * ++ * Return: &IMSM_STATUS_OK or &IMSM_STATUS_ERROR. ++ * ++ * @freesize is set to meaningful value, this can be @size, or calculated ++ * max free size. ++ * super->create_offset value is modified and set appropriately in ++ * merge_extends() for further creation. ++ */ ++static imsm_status_t imsm_get_free_size(struct intel_super *super, ++ const int raiddisks, ++ unsigned long long size, ++ const int chunk, ++ unsigned long long *freesize) + { +- struct intel_super *super = st->sb; + struct imsm_super *mpb = super->anchor; + struct dl *dl; + int i; +@@ -7570,12 +7586,10 @@ static int imsm_get_free_size(struct supertype *st, int raiddisks, + /* chunk is in K */ + minsize = chunk * 2; + +- if (cnt < raiddisks || +- (super->orom && used && used != raiddisks) || +- maxsize < minsize || +- maxsize == 0) { ++ if (cnt < raiddisks || (super->orom && used && used != raiddisks) || ++ maxsize < minsize || maxsize == 0) { + pr_err("not enough devices with space to create array.\n"); +- return 0; /* No enough free spaces large enough */ ++ return IMSM_STATUS_ERROR; + } + + if (size == 0) { +@@ -7588,37 +7602,69 @@ static int imsm_get_free_size(struct supertype *st, int raiddisks, + } + if (mpb->num_raid_devs > 0 && size && size != maxsize) + pr_err("attempting to create a second volume with size less then remaining space.\n"); +- cnt = 0; +- for (dl = super->disks; dl; dl = dl->next) +- if (dl->e) +- dl->raiddisk = cnt++; +- + *freesize = size; + + dprintf("imsm: imsm_get_free_size() returns : %llu\n", size); + +- return 1; ++ return IMSM_STATUS_OK; + } + +-static int reserve_space(struct supertype *st, int raiddisks, +- unsigned long long size, int chunk, +- unsigned long long *freesize) ++/** ++ * autolayout_imsm() - automatically layout a new volume. ++ * @super: &intel_super pointer, not NULL. ++ * @raiddisks: number of raid disks. ++ * @size: requested size, could be 0 (means max size). ++ * @chunk: requested chunk. ++ * @freesize: pointer for returned size value. ++ * ++ * We are being asked to automatically layout a new volume based on the current ++ * contents of the container. If the parameters can be satisfied autolayout_imsm ++ * will record the disks, start offset, and will return size of the volume to ++ * be created. See imsm_get_free_size() for details. ++ * add_to_super() and getinfo_super() detect when autolayout is in progress. ++ * If first volume exists, slots are set consistently to it. ++ * ++ * Return: &IMSM_STATUS_OK on success, &IMSM_STATUS_ERROR otherwise. ++ * ++ * Disks are marked for creation via dl->raiddisk. ++ */ ++static imsm_status_t autolayout_imsm(struct intel_super *super, ++ const int raiddisks, ++ unsigned long long size, const int chunk, ++ unsigned long long *freesize) + { +- struct intel_super *super = st->sb; +- struct dl *dl; +- int cnt; +- int rv = 0; ++ int curr_slot = 0; ++ struct dl *disk; ++ int vol_cnt = super->anchor->num_raid_devs; ++ imsm_status_t rv; + +- rv = imsm_get_free_size(st, raiddisks, size, chunk, freesize); +- if (rv) { +- cnt = 0; +- for (dl = super->disks; dl; dl = dl->next) +- if (dl->e) +- dl->raiddisk = cnt++; +- rv = 1; ++ rv = imsm_get_free_size(super, raiddisks, size, chunk, freesize); ++ if (rv != IMSM_STATUS_OK) ++ return IMSM_STATUS_ERROR; ++ ++ for (disk = super->disks; disk; disk = disk->next) { ++ if (!disk->e) ++ continue; ++ ++ if (curr_slot == raiddisks) ++ break; ++ ++ if (vol_cnt == 0) { ++ disk->raiddisk = curr_slot; ++ } else { ++ int _slot = get_disk_slot_in_dev(super, 0, disk->index); ++ ++ if (_slot == -1) { ++ pr_err("Disk %s is not used in first volume, aborting\n", ++ disk->devname); ++ return IMSM_STATUS_ERROR; ++ } ++ disk->raiddisk = _slot; ++ } ++ curr_slot++; + } + +- return rv; ++ return IMSM_STATUS_OK; + } + + static int validate_geometry_imsm(struct supertype *st, int level, int layout, +@@ -7654,35 +7700,35 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, + } + + if (!dev) { +- if (st->sb) { +- struct intel_super *super = st->sb; +- if (!validate_geometry_imsm_orom(st->sb, level, layout, +- raiddisks, chunk, size, +- verbose)) ++ struct intel_super *super = st->sb; ++ ++ /* ++ * Autolayout mode, st->sb and freesize must be set. ++ */ ++ if (!super || !freesize) { ++ pr_vrb("freesize and superblock must be set for autolayout, aborting\n"); ++ return 1; ++ } ++ ++ if (!validate_geometry_imsm_orom(st->sb, level, layout, ++ raiddisks, chunk, size, ++ verbose)) ++ return 0; ++ ++ if (super->orom) { ++ imsm_status_t rv; ++ 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; +- /* we are being asked to automatically layout a +- * new volume based on the current contents of +- * the container. If the the parameters can be +- * satisfied reserve_space will record the disks, +- * start offset, and size of the volume to be +- * created. add_to_super and getinfo_super +- * detect when autolayout is in progress. +- */ +- /* assuming that freesize is always given when array is +- created */ +- if (super->orom && freesize) { +- int count; +- 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; +- } + } +- if (freesize) +- return reserve_space(st, raiddisks, size, +- *chunk, freesize); ++ ++ rv = autolayout_imsm(super, raiddisks, size, *chunk, ++ freesize); ++ if (rv != IMSM_STATUS_OK) ++ return 0; + } + return 1; + } +@@ -11538,7 +11584,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, + unsigned long long current_size; + unsigned long long free_size; + unsigned long long max_size; +- int rv; ++ imsm_status_t rv; + + getinfo_super_imsm_volume(st, &info, NULL); + if (geo->level != info.array.level && geo->level >= 0 && +@@ -11657,9 +11703,10 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, + } + /* check the maximum available size + */ +- rv = imsm_get_free_size(st, dev->vol.map->num_members, +- 0, chunk, &free_size); +- if (rv == 0) ++ rv = imsm_get_free_size(super, dev->vol.map->num_members, ++ 0, chunk, &free_size); ++ ++ if (rv != IMSM_STATUS_OK) + /* Cannot find maximum available space + */ + max_size = 0; +-- +2.35.3 + diff --git a/0024-imsm-block-changing-slots-during-creation.patch b/0024-imsm-block-changing-slots-during-creation.patch new file mode 100644 index 0000000..f2398eb --- /dev/null +++ b/0024-imsm-block-changing-slots-during-creation.patch @@ -0,0 +1,124 @@ +From 9a7df595bbe360132cb37c8b39aa1fd9ac24b43f Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 21 Jun 2022 00:10:43 +0800 +Subject: [PATCH 25/61] imsm: block changing slots during creation +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +If user specifies drives for array creation, then slot order across +volumes is not preserved. +Ideally, it should be checked in validate_geometry() but it is not +possible in current implementation (order is determined later). +Add verification in add_to_super_imsm_volume() and throw error if +mismatch is detected. +IMSM allows to use only same members within container. +This is not hardware dependency but metadata limitation. +Therefore, 09-imsm-overlap test is removed. Testing it is pointless. +After this patch, creation in this scenario is blocked. Offset +verification is covered in other tests. + +Signed-off-by: Mariusz Tkaczyk +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + super-intel.c | 33 ++++++++++++++++++++++----------- + tests/09imsm-overlap | 28 ---------------------------- + 2 files changed, 22 insertions(+), 39 deletions(-) + delete mode 100644 tests/09imsm-overlap + +diff --git a/super-intel.c b/super-intel.c +index deef7c8..8ffe485 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -5789,6 +5789,10 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, + struct imsm_map *map; + struct dl *dl, *df; + int slot; ++ int autolayout = 0; ++ ++ if (!is_fd_valid(fd)) ++ autolayout = 1; + + dev = get_imsm_dev(super, super->current_vol); + map = get_imsm_map(dev, MAP_0); +@@ -5799,25 +5803,32 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, + return 1; + } + +- if (!is_fd_valid(fd)) { +- /* we're doing autolayout so grab the pre-marked (in +- * validate_geometry) raid_disk +- */ +- for (dl = super->disks; dl; dl = dl->next) ++ for (dl = super->disks; dl ; dl = dl->next) { ++ if (autolayout) { + if (dl->raiddisk == dk->raid_disk) + break; +- } else { +- for (dl = super->disks; dl ; dl = dl->next) +- if (dl->major == dk->major && +- dl->minor == dk->minor) +- break; ++ } else if (dl->major == dk->major && dl->minor == dk->minor) ++ break; + } + + if (!dl) { +- pr_err("%s is not a member of the same container\n", devname); ++ if (!autolayout) ++ pr_err("%s is not a member of the same container.\n", ++ devname); + return 1; + } + ++ if (!autolayout && super->current_vol > 0) { ++ int _slot = get_disk_slot_in_dev(super, 0, dl->index); ++ ++ if (_slot != dk->raid_disk) { ++ pr_err("Member %s is in %d slot for the first volume, but is in %d slot for a new volume.\n", ++ dl->devname, _slot, dk->raid_disk); ++ pr_err("Raid members are in different order than for the first volume, aborting.\n"); ++ return 1; ++ } ++ } ++ + if (mpb->num_disks == 0) + if (!get_dev_sector_size(dl->fd, dl->devname, + &super->sector_size)) +diff --git a/tests/09imsm-overlap b/tests/09imsm-overlap +deleted file mode 100644 +index ff5d209..0000000 +--- a/tests/09imsm-overlap ++++ /dev/null +@@ -1,28 +0,0 @@ +- +-. tests/env-imsm-template +- +-# create raid arrays with varying degress of overlap +-mdadm -CR $container -e imsm -n 6 $dev0 $dev1 $dev2 $dev3 $dev4 $dev5 +-imsm_check container 6 +- +-size=1024 +-level=1 +-num_disks=2 +-mdadm -CR $member0 $dev0 $dev1 -n $num_disks -l $level -z $size +-mdadm -CR $member1 $dev1 $dev2 -n $num_disks -l $level -z $size +-mdadm -CR $member2 $dev2 $dev3 -n $num_disks -l $level -z $size +-mdadm -CR $member3 $dev3 $dev4 -n $num_disks -l $level -z $size +-mdadm -CR $member4 $dev4 $dev5 -n $num_disks -l $level -z $size +- +-udevadm settle +- +-offset=0 +-imsm_check member $member0 $num_disks $level $size 1024 $offset +-offset=$((offset+size+4096)) +-imsm_check member $member1 $num_disks $level $size 1024 $offset +-offset=$((offset+size+4096)) +-imsm_check member $member2 $num_disks $level $size 1024 $offset +-offset=$((offset+size+4096)) +-imsm_check member $member3 $num_disks $level $size 1024 $offset +-offset=$((offset+size+4096)) +-imsm_check member $member4 $num_disks $level $size 1024 $offset +-- +2.35.3 + diff --git a/0024-imsm-fix-spare-activation-for-old-matrix-arrays.patch b/0024-imsm-fix-spare-activation-for-old-matrix-arrays.patch deleted file mode 100644 index 5bd815f..0000000 --- a/0024-imsm-fix-spare-activation-for-old-matrix-arrays.patch +++ /dev/null @@ -1,121 +0,0 @@ -From 05501181f18cdccdb0b3cec1d8cf59f0995504d7 Mon Sep 17 00:00:00 2001 -From: Pawel Baldysiak -Date: Fri, 8 Mar 2019 12:19:11 +0100 -Subject: [PATCH] imsm: fix spare activation for old matrix arrays -Git-commit: 05501181f18cdccdb0b3cec1d8cf59f0995504d7 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -During spare activation get_extents() calculates metadata reserved space based -on smallest active RAID member or it will take the defaults. Since patch -611d9529("imsm: change reserved space to 4MB") default is extended. If array -was created prior that patch, reserved space is smaller. In case of matrix -RAID - spare is activated in each array one-by-one, so it is spare for first -activation, but treated as "active" during second one. - -In case of adding spare drive to old matrix RAID with the size the same as -already existing member drive the routine will take the defaults during second -run and mdmon will refuse to rebuild second volume, claiming that the drive -does not have enough free space. - -Add parameter to get_extents(), so the during spare activation reserved space -is always based on smallest active drive - even if given drive is already -active in some other array of matrix RAID. - -Signed-off-by: Pawel Baldysiak -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 19 ++++++++++--------- - 1 file changed, 10 insertions(+), 9 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index c399433..5a7c9f8 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1313,7 +1313,8 @@ static unsigned long long per_dev_array_size(struct imsm_map *map) - return array_size; - } - --static struct extent *get_extents(struct intel_super *super, struct dl *dl) -+static struct extent *get_extents(struct intel_super *super, struct dl *dl, -+ int get_minimal_reservation) - { - /* find a list of used extents on the given physical device */ - struct extent *rv, *e; -@@ -1325,7 +1326,7 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl) - * regardless of whether the OROM has assigned sectors from the - * IMSM_RESERVED_SECTORS region - */ -- if (dl->index == -1) -+ if (dl->index == -1 || get_minimal_reservation) - reservation = imsm_min_reserved_sectors(super); - else - reservation = MPB_SECTOR_CNT + IMSM_RESERVED_SECTORS; -@@ -1386,7 +1387,7 @@ static __u32 imsm_reserved_sectors(struct intel_super *super, struct dl *dl) - if (dl->index == -1) - return MPB_SECTOR_CNT; - -- e = get_extents(super, dl); -+ e = get_extents(super, dl, 0); - if (!e) - return MPB_SECTOR_CNT + IMSM_RESERVED_SECTORS; - -@@ -1478,7 +1479,7 @@ static __u32 imsm_min_reserved_sectors(struct intel_super *super) - return rv; - - /* find last lba used by subarrays on the smallest active disk */ -- e = get_extents(super, dl_min); -+ e = get_extents(super, dl_min, 0); - if (!e) - return rv; - for (i = 0; e[i].size; i++) -@@ -1519,7 +1520,7 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c) - if (!dl) - return -EINVAL; - /* find last lba used by subarrays */ -- e = get_extents(super, dl); -+ e = get_extents(super, dl, 0); - if (!e) - return -EINVAL; - for (i = 0; e[i].size; i++) -@@ -7203,7 +7204,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, - - pos = 0; - i = 0; -- e = get_extents(super, dl); -+ e = get_extents(super, dl, 0); - if (!e) continue; - do { - unsigned long long esize; -@@ -7261,7 +7262,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, - } - - /* retrieve the largest free space block */ -- e = get_extents(super, dl); -+ e = get_extents(super, dl, 0); - maxsize = 0; - i = 0; - if (e) { -@@ -7359,7 +7360,7 @@ static int imsm_get_free_size(struct supertype *st, int raiddisks, - if (super->orom && dl->index < 0 && mpb->num_raid_devs) - continue; - -- e = get_extents(super, dl); -+ e = get_extents(super, dl, 0); - if (!e) - continue; - for (i = 1; e[i-1].size; i++) -@@ -8846,7 +8847,7 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot, - /* Does this unused device have the requisite free space? - * It needs to be able to cover all member volumes - */ -- ex = get_extents(super, dl); -+ ex = get_extents(super, dl, 1); - if (!ex) { - dprintf("cannot get extents\n"); - continue; --- -2.25.0 - diff --git a/0025-Create-Block-rounding-size-to-max.patch b/0025-Create-Block-rounding-size-to-max.patch deleted file mode 100644 index d984bd2..0000000 --- a/0025-Create-Block-rounding-size-to-max.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 22dc741f63e6403d59c2c14f56fd4791265f9bbb Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 1 Apr 2019 16:53:41 +0200 -Subject: [PATCH] Create: Block rounding size to max -Git-commit: 22dc741f63e6403d59c2c14f56fd4791265f9bbb -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -When passed size is smaller than chunk, mdadm rounds it to 0 but 0 there -means max available space. -Block it for every metadata. Remove the same check from imsm routine. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Create.c | 23 ++++++++++++++++++++--- - super-intel.c | 5 ++--- - 2 files changed, 22 insertions(+), 6 deletions(-) - -diff --git a/Create.c b/Create.c -index 6f1b228..292f92a 100644 ---- a/Create.c -+++ b/Create.c -@@ -27,6 +27,18 @@ - #include "md_p.h" - #include - -+static int round_size_and_verify(unsigned long long *size, int chunk) -+{ -+ if (*size == 0) -+ return 0; -+ *size &= ~(unsigned long long)(chunk - 1); -+ if (*size == 0) { -+ pr_err("Size cannot be smaller than chunk.\n"); -+ return 1; -+ } -+ return 0; -+} -+ - static int default_layout(struct supertype *st, int level, int verbose) - { - int layout = UnSet; -@@ -248,11 +260,14 @@ int Create(struct supertype *st, char *mddev, - pr_err("unknown level %d\n", s->level); - return 1; - } -+ - if (s->size == MAX_SIZE) - /* use '0' to mean 'max' now... */ - s->size = 0; - if (s->size && s->chunk && s->chunk != UnSet) -- s->size &= ~(unsigned long long)(s->chunk - 1); -+ if (round_size_and_verify(&s->size, s->chunk)) -+ return 1; -+ - newsize = s->size * 2; - if (st && ! st->ss->validate_geometry(st, s->level, s->layout, s->raiddisks, - &s->chunk, s->size*2, -@@ -267,7 +282,8 @@ int Create(struct supertype *st, char *mddev, - /* default chunk was just set */ - if (c->verbose > 0) - pr_err("chunk size defaults to %dK\n", s->chunk); -- s->size &= ~(unsigned long long)(s->chunk - 1); -+ if (round_size_and_verify(&s->size, s->chunk)) -+ return 1; - do_default_chunk = 0; - } - } -@@ -413,7 +429,8 @@ int Create(struct supertype *st, char *mddev, - /* default chunk was just set */ - if (c->verbose > 0) - pr_err("chunk size defaults to %dK\n", s->chunk); -- s->size &= ~(unsigned long long)(s->chunk - 1); -+ if (round_size_and_verify(&s->size, s->chunk)) -+ return 1; - do_default_chunk = 0; - } - } -diff --git a/super-intel.c b/super-intel.c -index 5a7c9f8..2ba045a 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7455,9 +7455,8 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - verbose); - } - -- if (size && ((size < 1024) || (*chunk != UnSet && -- size < (unsigned long long) *chunk))) { -- pr_err("Given size must be greater than 1M and chunk size.\n"); -+ if (size && (size < 1024)) { -+ pr_err("Given size must be greater than 1M.\n"); - /* Depends on algorithm in Create.c : - * if container was given (dev == NULL) return -1, - * if block device was given ( dev != NULL) return 0. --- -2.25.0 - diff --git a/0025-mdadm-block-update-ppl-for-non-raid456-levels.patch b/0025-mdadm-block-update-ppl-for-non-raid456-levels.patch new file mode 100644 index 0000000..c4a6f8a --- /dev/null +++ b/0025-mdadm-block-update-ppl-for-non-raid456-levels.patch @@ -0,0 +1,180 @@ +From 70f1ff4291b0388adca1f4c91918ce1175e8b360 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Wed, 15 Jun 2022 14:28:39 +0200 +Subject: [PATCH 26/61] mdadm: block update=ppl for non raid456 levels +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Option ppl should be used only for raid levels 4, 5 and 6. Cancel update +for other levels. + +Applied globally for imsm and ddf format. + +Additionally introduce is_level456() helper function. + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Assemble.c | 11 +++++------ + Grow.c | 2 +- + Manage.c | 14 ++++++++++++-- + mdadm.h | 11 +++++++++++ + super0.c | 2 +- + super1.c | 3 +-- + 6 files changed, 31 insertions(+), 12 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 4b21356..6df6bfb 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -906,8 +906,7 @@ static int force_array(struct mdinfo *content, + * devices in RAID4 or last devices in RAID4/5/6. + */ + delta = devices[j].i.delta_disks; +- if (devices[j].i.array.level >= 4 && +- devices[j].i.array.level <= 6 && ++ if (is_level456(devices[j].i.array.level) && + i/2 >= content->array.raid_disks - delta) + /* OK */; + else if (devices[j].i.array.level == 4 && +@@ -1226,8 +1225,7 @@ static int start_array(int mdfd, + fprintf(stderr, ".\n"); + } + if (content->reshape_active && +- content->array.level >= 4 && +- content->array.level <= 6) { ++ is_level456(content->array.level)) { + /* might need to increase the size + * of the stripe cache - default is 256 + */ +@@ -1974,7 +1972,8 @@ int assemble_container_content(struct supertype *st, int mdfd, + int start_reshape; + char *avail; + int err; +- int is_raid456, is_clean, all_disks; ++ int is_clean, all_disks; ++ bool is_raid456; + + if (sysfs_init(content, mdfd, NULL)) { + pr_err("Unable to initialize sysfs\n"); +@@ -2107,7 +2106,7 @@ int assemble_container_content(struct supertype *st, int mdfd, + content->array.state |= 1; + } + +- is_raid456 = (content->array.level >= 4 && content->array.level <= 6); ++ is_raid456 = is_level456(content->array.level); + is_clean = content->array.state & 1; + + if (enough(content->array.level, content->array.raid_disks, +diff --git a/Grow.c b/Grow.c +index f6efbc4..8c520d4 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -2944,7 +2944,7 @@ static int impose_level(int fd, int level, char *devname, int verbose) + } + + md_get_array_info(fd, &array); +- if (level == 0 && (array.level >= 4 && array.level <= 6)) { ++ if (level == 0 && is_level456(array.level)) { + /* To convert to RAID0 we need to fail and + * remove any non-data devices. */ + int found = 0; +diff --git a/Manage.c b/Manage.c +index f789e0c..e5e6abe 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -307,7 +307,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) + * - unfreeze reshape + * - wait on 'sync_completed' for that point to be reached. + */ +- if (mdi && (mdi->array.level >= 4 && mdi->array.level <= 6) && ++ if (mdi && is_level456(mdi->array.level) && + sysfs_attribute_available(mdi, NULL, "sync_action") && + sysfs_attribute_available(mdi, NULL, "reshape_direction") && + sysfs_get_str(mdi, NULL, "sync_action", buf, 20) > 0 && +@@ -1679,6 +1679,7 @@ int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident + { + struct supertype supertype, *st = &supertype; + int fd, rv = 2; ++ struct mdinfo *info = NULL; + + memset(st, 0, sizeof(*st)); + +@@ -1696,6 +1697,13 @@ int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident + if (mdmon_running(st->devnm)) + st->update_tail = &st->updates; + ++ info = st->ss->container_content(st, subarray); ++ ++ if (strncmp(update, "ppl", 3) == 0 && !is_level456(info->array.level)) { ++ pr_err("RWH policy ppl is supported only for raid4, raid5 and raid6.\n"); ++ goto free_super; ++ } ++ + rv = st->ss->update_subarray(st, subarray, update, ident); + + if (rv) { +@@ -1711,7 +1719,9 @@ int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident + pr_err("Updated subarray-%s name from %s, UUIDs may have changed\n", + subarray, dev); + +- free_super: ++free_super: ++ if (info) ++ free(info); + st->ss->free_super(st); + close(fd); + +diff --git a/mdadm.h b/mdadm.h +index d53df16..974415b 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -796,6 +796,17 @@ static inline int is_fd_valid(int fd) + return (fd > -1); + } + ++/** ++ * is_level456() - check whether given level is between inclusive 4 and 6. ++ * @level: level to check. ++ * ++ * Return: true if condition is met, false otherwise ++ */ ++static inline bool is_level456(int level) ++{ ++ return (level >= 4 && level <= 6); ++} ++ + /** + * close_fd() - verify, close and unset file descriptor. + * @fd: pointer to file descriptor. +diff --git a/super0.c b/super0.c +index 61c9ec1..37f595e 100644 +--- a/super0.c ++++ b/super0.c +@@ -683,7 +683,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info, + int parity = sb->level == 6 ? 2 : 1; + rv = 0; + +- if (sb->level >= 4 && sb->level <= 6 && ++ if (is_level456(sb->level) && + sb->reshape_position % ( + sb->new_chunk/512 * + (sb->raid_disks - sb->delta_disks - parity))) { +diff --git a/super1.c b/super1.c +index 3a0c69f..71af860 100644 +--- a/super1.c ++++ b/super1.c +@@ -1530,8 +1530,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info, + * So we reject a revert-reshape unless the + * alignment is good. + */ +- if (__le32_to_cpu(sb->level) >= 4 && +- __le32_to_cpu(sb->level) <= 6) { ++ if (is_level456(__le32_to_cpu(sb->level))) { + reshape_sectors = + __le64_to_cpu(sb->reshape_position); + reshape_chunk = __le32_to_cpu(sb->new_chunk); +-- +2.35.3 + diff --git a/0026-mdadm-Fix-array-size-mismatch-after-grow.patch b/0026-mdadm-Fix-array-size-mismatch-after-grow.patch new file mode 100644 index 0000000..5cd9368 --- /dev/null +++ b/0026-mdadm-Fix-array-size-mismatch-after-grow.patch @@ -0,0 +1,33 @@ +From 42e02e613fb0b4a2c0c0d984b9e6e2933875bb44 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 22 Jul 2022 08:43:47 +0200 +Subject: [PATCH 27/61] mdadm: Fix array size mismatch after grow +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +imsm_fix_size_mismatch() is invoked to fix the problem, but it couldn't +proceed due to migration check. This patch allows for intended behavior. + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super-intel.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/super-intel.c b/super-intel.c +index 8ffe485..76b947f 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -11854,7 +11854,7 @@ static int imsm_fix_size_mismatch(struct supertype *st, int subarray_index) + unsigned long long d_size = imsm_dev_size(dev); + int u_size; + +- if (calc_size == d_size || dev->vol.migr_type == MIGR_GEN_MIGR) ++ if (calc_size == d_size) + continue; + + /* There is a difference, confirm that imsm_dev_size is +-- +2.35.3 + diff --git a/0026-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch b/0026-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch deleted file mode 100644 index 9054fcb..0000000 --- a/0026-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 3c9b46cf9ae15a9be98fc47e2080bd9494496246 Mon Sep 17 00:00:00 2001 -From: Liwei Song -Date: Tue, 19 Mar 2019 23:51:05 -0400 -Subject: [PATCH] udev: Add udev rules to create by-partuuid for md device -Git-commit: 3c9b46cf9ae15a9be98fc47e2080bd9494496246 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -This rules will create link under /dev/disk/by-partuuid/ for -MD devices partition, with which will support specify -root=PARTUUID=XXX to boot rootfs. - -Signed-off-by: Liwei Song -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - 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 c95ec7b..5b99d58 100644 ---- a/udev-md-raid-arrays.rules -+++ b/udev-md-raid-arrays.rules -@@ -30,6 +30,7 @@ IMPORT{builtin}="blkid" - OPTIONS+="link_priority=100" - OPTIONS+="watch" - 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}" - - ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" --- -2.25.0 - diff --git a/0027-mdadm-Remove-dead-code-in-imsm_fix_size_mismatch.patch b/0027-mdadm-Remove-dead-code-in-imsm_fix_size_mismatch.patch new file mode 100644 index 0000000..73d448e --- /dev/null +++ b/0027-mdadm-Remove-dead-code-in-imsm_fix_size_mismatch.patch @@ -0,0 +1,37 @@ +From 751757620afb25a4c02746bf8368a7b5f22352ec Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Fri, 22 Jul 2022 08:43:48 +0200 +Subject: [PATCH 28/61] mdadm: Remove dead code in imsm_fix_size_mismatch +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +imsm_create_metadata_update_for_size_change() that returns u_size value +could return 0 in the past. As its behavior changed, and returned value +is always the size of imsm_update_size_change structure, check for +u_size is no longer needed. + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super-intel.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/super-intel.c b/super-intel.c +index 76b947f..4ddfcf9 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -11869,10 +11869,6 @@ static int imsm_fix_size_mismatch(struct supertype *st, int subarray_index) + geo.size = d_size; + u_size = imsm_create_metadata_update_for_size_change(st, &geo, + &update); +- if (u_size < 1) { +- dprintf("imsm: Cannot prepare size change update\n"); +- goto exit; +- } + imsm_update_metadata_locally(st, update, u_size); + if (st->update_tail) { + append_metadata_update(st, update, u_size); +-- +2.35.3 + diff --git a/0027-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch b/0027-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch deleted file mode 100644 index 0741ebd..0000000 --- a/0027-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch +++ /dev/null @@ -1,114 +0,0 @@ -From ae7d61e35ec2ab6361c3e509a8db00698ef3396f Mon Sep 17 00:00:00 2001 -From: Artur Paszkiewicz -Date: Tue, 7 May 2019 16:08:47 +0200 -Subject: [PATCH] mdmon: fix wrong array state when disk fails during mdmon - startup -Git-commit: ae7d61e35ec2ab6361c3e509a8db00698ef3396f -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -If a member drive disappears and is set faulty by the kernel during -mdmon startup, after ss->load_container() but before manage_new(), mdmon -will try to readd the faulty drive to the array and start rebuilding. -Metadata on the active drive is updated, but the faulty drive is not -removed from the array and is left in a "blocked" state and any write -request to the array will block. If the faulty drive reappears in the -system e.g. after a reboot, the array will not assemble because metadata -on the drives will be incompatible (at least on imsm). - -Fix this by adding a new option for sysfs_read(): "GET_DEVS_ALL". This -is an extension for the "GET_DEVS" option and causes all member devices -to be returned, even if the associated block device has been removed. -Use this option in manage_new() to include the faulty device on the -active_array's devices list. Mdmon will then properly remove the faulty -device from the array and update the metadata to reflect the degraded -state. - -Signed-off-by: Artur Paszkiewicz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - managemon.c | 2 +- - mdadm.h | 1 + - super-intel.c | 2 +- - sysfs.c | 23 ++++++++++++++--------- - 4 files changed, 17 insertions(+), 11 deletions(-) - -diff --git a/managemon.c b/managemon.c -index 29b91ba..200cf83 100644 ---- a/managemon.c -+++ b/managemon.c -@@ -678,7 +678,7 @@ static void manage_new(struct mdstat_ent *mdstat, - mdi = sysfs_read(-1, mdstat->devnm, - GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT| - GET_SAFEMODE|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE| -- GET_LAYOUT); -+ GET_LAYOUT|GET_DEVS_ALL); - - if (!mdi) - return; -diff --git a/mdadm.h b/mdadm.h -index 705bd9b..427cc52 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -647,6 +647,7 @@ enum sysfs_read_flags { - GET_ERROR = (1 << 24), - GET_ARRAY_STATE = (1 << 25), - GET_CONSISTENCY_POLICY = (1 << 26), -+ GET_DEVS_ALL = (1 << 27), - }; - - /* If fd >= 0, get the array it is open on, -diff --git a/super-intel.c b/super-intel.c -index 2ba045a..4fd5e84 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -8560,7 +8560,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - disk = get_imsm_disk(super, ord_to_idx(ord)); - - /* check for new failures */ -- if (state & DS_FAULTY) { -+ if (disk && (state & DS_FAULTY)) { - if (mark_failure(super, dev, disk, ord_to_idx(ord))) - super->updates_pending++; - } -diff --git a/sysfs.c b/sysfs.c -index df6fdda..2dd9ab6 100644 ---- a/sysfs.c -+++ b/sysfs.c -@@ -313,17 +313,22 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) - /* assume this is a stale reference to a hot - * removed device - */ -- free(dev); -- continue; -+ if (!(options & GET_DEVS_ALL)) { -+ free(dev); -+ continue; -+ } -+ } else { -+ sscanf(buf, "%d:%d", &dev->disk.major, &dev->disk.minor); - } -- sscanf(buf, "%d:%d", &dev->disk.major, &dev->disk.minor); - -- /* special case check for block devices that can go 'offline' */ -- strcpy(dbase, "block/device/state"); -- if (load_sys(fname, buf, sizeof(buf)) == 0 && -- strncmp(buf, "offline", 7) == 0) { -- free(dev); -- continue; -+ if (!(options & GET_DEVS_ALL)) { -+ /* special case check for block devices that can go 'offline' */ -+ strcpy(dbase, "block/device/state"); -+ if (load_sys(fname, buf, sizeof(buf)) == 0 && -+ strncmp(buf, "offline", 7) == 0) { -+ free(dev); -+ continue; -+ } - } - - /* finally add this disk to the array */ --- -2.25.0 - diff --git a/0028-Enable-probe_roms-to-scan-more-than-6-roms.patch b/0028-Enable-probe_roms-to-scan-more-than-6-roms.patch deleted file mode 100644 index 8a89092..0000000 --- a/0028-Enable-probe_roms-to-scan-more-than-6-roms.patch +++ /dev/null @@ -1,216 +0,0 @@ -From 4ec389e3f0c1233f5aa2d5b4e63d96e33d2a37f0 Mon Sep 17 00:00:00 2001 -From: Roman Sobanski -Date: Tue, 2 Jul 2019 13:29:27 +0200 -Subject: [PATCH] Enable probe_roms to scan more than 6 roms. -Git-commit: 4ec389e3f0c1233f5aa2d5b4e63d96e33d2a37f0 -Patch-mainline: mdadm-4.1+ -References: bsc#1156040 - -In some cases if more than 6 oroms exist, resource for particular -controller may not be found. Change method for storing -adapter_rom_resources from array to list. - -Signed-off-by: Roman Sobanski -Signed-off-by: Jes Sorensen -Acked-by: Coly Li ---- - probe_roms.c | 98 ++++++++++++++++++++++++++++++++++-------------------------- - 1 file changed, 56 insertions(+), 42 deletions(-) - -diff --git a/probe_roms.c b/probe_roms.c -index b0b0883..7ea04c7 100644 ---- a/probe_roms.c -+++ b/probe_roms.c -@@ -35,6 +35,9 @@ static const int rom_len = 0xf0000 - 0xc0000; /* option-rom memory region */ - static int _sigbus; - static unsigned long rom_align; - -+static void roms_deinit(void); -+static int roms_init(void); -+ - static void sigbus(int sig) - { - _sigbus = 1; -@@ -75,6 +78,7 @@ void probe_roms_exit(void) - munmap(rom_mem, rom_len); - rom_mem = MAP_FAILED; - } -+ roms_deinit(); - } - - int probe_roms_init(unsigned long align) -@@ -91,6 +95,9 @@ int probe_roms_init(unsigned long align) - else - return -1; - -+ if (roms_init()) -+ return -1; -+ - if (signal(SIGBUS, sigbus) == SIG_ERR) - rc = -1; - if (rc == 0) { -@@ -131,6 +138,7 @@ struct resource { - unsigned long end; - unsigned long data; - const char *name; -+ struct resource *next; - }; - - static struct resource system_rom_resource = { -@@ -147,37 +155,7 @@ static struct resource extension_rom_resource = { - .end = 0xeffff, - }; - --static struct resource adapter_rom_resources[] = { { -- .name = "Adapter ROM", -- .start = 0xc8000, -- .data = 0, -- .end = 0, --}, { -- .name = "Adapter ROM", -- .start = 0, -- .data = 0, -- .end = 0, --}, { -- .name = "Adapter ROM", -- .start = 0, -- .data = 0, -- .end = 0, --}, { -- .name = "Adapter ROM", -- .start = 0, -- .data = 0, -- .end = 0, --}, { -- .name = "Adapter ROM", -- .start = 0, -- .data = 0, -- .end = 0, --}, { -- .name = "Adapter ROM", -- .start = 0, -- .data = 0, -- .end = 0, --} }; -+static struct resource *adapter_rom_resources; - - static struct resource video_rom_resource = { - .name = "Video ROM", -@@ -186,8 +164,35 @@ static struct resource video_rom_resource = { - .end = 0xc7fff, - }; - -+static int roms_init(void) -+{ -+ adapter_rom_resources = malloc(sizeof(struct resource)); -+ if (adapter_rom_resources == NULL) -+ return 1; -+ adapter_rom_resources->name = "Adapter ROM"; -+ adapter_rom_resources->start = 0xc8000; -+ adapter_rom_resources->data = 0; -+ adapter_rom_resources->end = 0; -+ adapter_rom_resources->next = NULL; -+ return 0; -+} -+ -+static void roms_deinit(void) -+{ -+ struct resource *res; -+ -+ res = adapter_rom_resources; -+ while (res) { -+ struct resource *tmp = res; -+ -+ res = res->next; -+ free(tmp); -+ } -+} -+ - #define ROMSIGNATURE 0xaa55 - -+ - static int romsignature(const unsigned char *rom) - { - const unsigned short * const ptr = (const unsigned short *)rom; -@@ -208,16 +213,14 @@ static int romchecksum(const unsigned char *rom, unsigned long length) - int scan_adapter_roms(scan_fn fn) - { - /* let scan_fn examing each of the adapter roms found by probe_roms */ -- unsigned int i; -+ struct resource *res = adapter_rom_resources; - int found; - - if (rom_fd < 0) - return 0; - - found = 0; -- for (i = 0; i < ARRAY_SIZE(adapter_rom_resources); i++) { -- struct resource *res = &adapter_rom_resources[i]; -- -+ while (res) { - if (res->start) { - found = fn(isa_bus_to_virt(res->start), - isa_bus_to_virt(res->end), -@@ -226,6 +229,7 @@ int scan_adapter_roms(scan_fn fn) - break; - } else - break; -+ res = res->next; - } - - return found; -@@ -241,14 +245,14 @@ void probe_roms(void) - const void *rom; - unsigned long start, length, upper; - unsigned char c; -- unsigned int i; -+ struct resource *res = adapter_rom_resources; - __u16 val=0; - - if (rom_fd < 0) - return; - - /* video rom */ -- upper = adapter_rom_resources[0].start; -+ upper = res->start; - for (start = video_rom_resource.start; start < upper; start += rom_align) { - rom = isa_bus_to_virt(start); - if (!romsignature(rom)) -@@ -283,8 +287,9 @@ void probe_roms(void) - upper = extension_rom_resource.start; - } - -+ struct resource *prev_res = res; - /* check for adapter roms on 2k boundaries */ -- for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += rom_align) { -+ for (; start < upper; start += rom_align) { - rom = isa_bus_to_virt(start); - if (!romsignature(rom)) - continue; -@@ -308,10 +313,19 @@ void probe_roms(void) - if (!length || start + length > upper || !romchecksum(rom, length)) - continue; - -- adapter_rom_resources[i].start = start; -- adapter_rom_resources[i].data = start + (unsigned long) val; -- adapter_rom_resources[i].end = start + length - 1; -+ if (res == NULL) { -+ res = calloc(1, sizeof(struct resource)); -+ if (res == NULL) -+ return; -+ prev_res->next = res; -+ } -+ -+ res->start = start; -+ res->data = start + (unsigned long)val; -+ res->end = start + length - 1; - -- start = adapter_rom_resources[i++].end & ~(rom_align - 1); -+ start = res->end & ~(rom_align - 1); -+ prev_res = res; -+ res = res->next; - } - } --- -2.16.4 - diff --git a/0028-Monitor-use-devname-as-char-array-instead-of-pointer.patch b/0028-Monitor-use-devname-as-char-array-instead-of-pointer.patch new file mode 100644 index 0000000..bda2ee2 --- /dev/null +++ b/0028-Monitor-use-devname-as-char-array-instead-of-pointer.patch @@ -0,0 +1,43 @@ +From c8d1c398505b62d9129a4e711f17e4469f4327ff Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Thu, 14 Jul 2022 09:02:10 +0200 +Subject: [PATCH 29/61] Monitor: use devname as char array instead of pointer +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Device name wasn't filled properly due to incorrect use of strcpy. +Strcpy was used twice. Firstly to fill devname with "/dev/md/" +and then to add chosen name. First strcpy result was overwritten by +second one (as a result instead of "/dev/md/" +was assigned). This commit changes this implementation to use snprintf +and devname with fixed size. + +Signed-off-by: Kinga Tanska +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Monitor.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/Monitor.c b/Monitor.c +index 6ca1ebe..a5b11ae 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -190,9 +190,11 @@ int Monitor(struct mddev_dev *devlist, + if (mdlist->devname[0] == '/') + st->devname = xstrdup(mdlist->devname); + else { +- st->devname = xmalloc(8+strlen(mdlist->devname)+1); +- strcpy(strcpy(st->devname, "/dev/md/"), +- mdlist->devname); ++ /* length of "/dev/md/" + device name + terminating byte */ ++ size_t _len = sizeof("/dev/md/") + strnlen(mdlist->devname, PATH_MAX); ++ ++ st->devname = xcalloc(_len, sizeof(char)); ++ snprintf(st->devname, _len, "/dev/md/%s", mdlist->devname); + } + if (!is_mddev(mdlist->devname)) + return 1; +-- +2.35.3 + diff --git a/0029-Monitor-use-snprintf-to-fill-device-name.patch b/0029-Monitor-use-snprintf-to-fill-device-name.patch new file mode 100644 index 0000000..ff5a84b --- /dev/null +++ b/0029-Monitor-use-snprintf-to-fill-device-name.patch @@ -0,0 +1,136 @@ +From 84d969be8f6d8a345b75f558fad26e4f62a558f6 Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Thu, 14 Jul 2022 09:02:11 +0200 +Subject: [PATCH 30/61] Monitor: use snprintf to fill device name +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Safe string functions are propagated in Monitor.c. + +Signed-off-by: Kinga Tanska +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Monitor.c | 37 ++++++++++++++----------------------- + 1 file changed, 14 insertions(+), 23 deletions(-) + +diff --git a/Monitor.c b/Monitor.c +index a5b11ae..93f36ac 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -33,8 +33,8 @@ + #endif + + struct state { +- char *devname; +- char devnm[32]; /* to sync with mdstat info */ ++ char devname[MD_NAME_MAX + sizeof("/dev/md/")]; /* length of "/dev/md/" + device name + terminating byte*/ ++ char devnm[MD_NAME_MAX]; /* to sync with mdstat info */ + unsigned int utime; + int err; + char *spare_group; +@@ -45,9 +45,9 @@ struct state { + int devstate[MAX_DISKS]; + dev_t devid[MAX_DISKS]; + int percent; +- char parent_devnm[32]; /* For subarray, devnm of parent. +- * For others, "" +- */ ++ char parent_devnm[MD_NAME_MAX]; /* For subarray, devnm of parent. ++ * For others, "" ++ */ + struct supertype *metadata; + struct state *subarray;/* for a container it is a link to first subarray + * for a subarray it is a link to next subarray +@@ -187,15 +187,8 @@ int Monitor(struct mddev_dev *devlist, + continue; + + st = xcalloc(1, sizeof *st); +- if (mdlist->devname[0] == '/') +- st->devname = xstrdup(mdlist->devname); +- else { +- /* length of "/dev/md/" + device name + terminating byte */ +- size_t _len = sizeof("/dev/md/") + strnlen(mdlist->devname, PATH_MAX); +- +- st->devname = xcalloc(_len, sizeof(char)); +- snprintf(st->devname, _len, "/dev/md/%s", mdlist->devname); +- } ++ snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"), ++ "/dev/md/%s", basename(mdlist->devname)); + if (!is_mddev(mdlist->devname)) + return 1; + st->next = statelist; +@@ -218,7 +211,7 @@ int Monitor(struct mddev_dev *devlist, + + st = xcalloc(1, sizeof *st); + mdlist = conf_get_ident(dv->devname); +- st->devname = xstrdup(dv->devname); ++ snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"), "%s", dv->devname); + st->next = statelist; + st->devnm[0] = 0; + st->percent = RESYNC_UNKNOWN; +@@ -301,7 +294,6 @@ int Monitor(struct mddev_dev *devlist, + for (stp = &statelist; (st = *stp) != NULL; ) { + if (st->from_auto && st->err > 5) { + *stp = st->next; +- free(st->devname); + free(st->spare_group); + free(st); + } else +@@ -554,7 +546,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, + goto disappeared; + + if (st->devnm[0] == 0) +- strcpy(st->devnm, fd2devnm(fd)); ++ snprintf(st->devnm, MD_NAME_MAX, "%s", fd2devnm(fd)); + + for (mse2 = mdstat; mse2; mse2 = mse2->next) + if (strcmp(mse2->devnm, st->devnm) == 0) { +@@ -684,7 +676,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, + strncmp(mse->metadata_version, "external:", 9) == 0 && + is_subarray(mse->metadata_version+9)) { + char *sl; +- strcpy(st->parent_devnm, 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; +@@ -772,14 +764,13 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist, + continue; + } + +- st->devname = xstrdup(name); ++ snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"), "%s", name); + if ((fd = open(st->devname, O_RDONLY)) < 0 || + md_get_array_info(fd, &array) < 0) { + /* no such array */ + if (fd >= 0) + close(fd); + put_md_name(st->devname); +- free(st->devname); + if (st->metadata) { + st->metadata->ss->free_super(st->metadata); + free(st->metadata); +@@ -791,7 +782,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist, + st->next = *statelist; + st->err = 1; + st->from_auto = 1; +- strcpy(st->devnm, mse->devnm); ++ snprintf(st->devnm, MD_NAME_MAX, "%s", mse->devnm); + st->percent = RESYNC_UNKNOWN; + st->expected_spares = -1; + if (mse->metadata_version && +@@ -799,8 +790,8 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist, + "external:", 9) == 0 && + is_subarray(mse->metadata_version+9)) { + char *sl; +- strcpy(st->parent_devnm, +- mse->metadata_version+10); ++ snprintf(st->parent_devnm, MD_NAME_MAX, ++ "%s", mse->metadata_version + 10); + sl = strchr(st->parent_devnm, '/'); + *sl = 0; + } else +-- +2.35.3 + diff --git a/0029-super-intel-Fix-issue-with-abs-being-irrelevant.patch b/0029-super-intel-Fix-issue-with-abs-being-irrelevant.patch deleted file mode 100644 index 272d2af..0000000 --- a/0029-super-intel-Fix-issue-with-abs-being-irrelevant.patch +++ /dev/null @@ -1,43 +0,0 @@ -From a4f7290c20c2ff78328c9db0b18029165cfb05b2 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Tue, 9 Jul 2019 13:26:08 -0400 -Subject: [PATCH] super-intel: Fix issue with abs() being irrelevant -Git-commit: a4f7290c20c2ff78328c9db0b18029165cfb05b2 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -gcc9 complains about subtracting unsigned from unsigned and code -assuming the result can be negative. - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 4fd5e84..230e164 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2875,7 +2875,7 @@ static unsigned long long calc_component_size(struct imsm_map *map, - { - unsigned long long component_size; - unsigned long long dev_size = imsm_dev_size(dev); -- unsigned long long calc_dev_size = 0; -+ long long calc_dev_size = 0; - unsigned int member_disks = imsm_num_data_members(map); - - if (member_disks == 0) -@@ -2889,7 +2889,7 @@ static unsigned long long calc_component_size(struct imsm_map *map, - * 2048 blocks per each device. If the difference is higher it means - * that array size was expanded and num_data_stripes was not updated. - */ -- if ((unsigned int)abs(calc_dev_size - dev_size) > -+ if (llabs(calc_dev_size - (long long)dev_size) > - (1 << SECT_PER_MB_SHIFT) * member_disks) { - component_size = dev_size / member_disks; - dprintf("Invalid num_data_stripes in metadata; expected=%llu, found=%llu\n", --- -2.25.0 - diff --git a/0030-Makefile-Don-t-build-static-build-with-everything-an.patch b/0030-Makefile-Don-t-build-static-build-with-everything-an.patch new file mode 100644 index 0000000..bfb0253 --- /dev/null +++ b/0030-Makefile-Don-t-build-static-build-with-everything-an.patch @@ -0,0 +1,45 @@ +From 14ae4c37bce9a53da08d59d6c2d7e0946e9c9f47 Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:06 -0600 +Subject: [PATCH 31/61] Makefile: Don't build static build with everything and + everything-test +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Running the test suite requires building everything, but it seems to be +difficult to build the static version of mdadm now seeing there +is no readily available static udev library. + +The test suite doesn't need the static binary so just don't build it +with the everything or everything-test targets. + +Leave the mdadm.static and install-static targets in place in case +someone still has a use case for the static binary. + +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index bf12603..ec1f99e 100644 +--- a/Makefile ++++ b/Makefile +@@ -182,9 +182,9 @@ check_rundir: + echo "***** or set CHECK_RUN_DIR=0"; exit 1; \ + fi + +-everything: all mdadm.static swap_super test_stripe raid6check \ ++everything: all swap_super test_stripe raid6check \ + mdadm.Os mdadm.O2 man +-everything-test: all mdadm.static swap_super test_stripe \ ++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.. +-- +2.35.3 + diff --git a/0030-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch b/0030-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch deleted file mode 100644 index 4c0dc5d..0000000 --- a/0030-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 7039d1f8200b9599b23db5953934fdb43b0442e0 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Tue, 9 Jul 2019 14:15:38 -0400 -Subject: [PATCH] mdadm.h: Introduced unaligned {get,put}_unaligned{16,32}() -Git-commit: 7039d1f8200b9599b23db5953934fdb43b0442e0 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -We need these to avoid gcc9 going all crazy on us. - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdadm.h | 30 ++++++++++++++++++++++++++++++ - 1 file changed, 30 insertions(+) - -diff --git a/mdadm.h b/mdadm.h -index 427cc52..0fa9e1b 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -191,6 +191,36 @@ struct dlm_lksb { - #endif - #endif /* __KLIBC__ */ - -+/* -+ * Partially stolen from include/linux/unaligned/packed_struct.h -+ */ -+struct __una_u16 { __u16 x; } __attribute__ ((packed)); -+struct __una_u32 { __u32 x; } __attribute__ ((packed)); -+ -+static inline __u16 __get_unaligned16(const void *p) -+{ -+ const struct __una_u16 *ptr = (const struct __una_u16 *)p; -+ return ptr->x; -+} -+ -+static inline __u32 __get_unaligned32(const void *p) -+{ -+ const struct __una_u32 *ptr = (const struct __una_u32 *)p; -+ return ptr->x; -+} -+ -+static inline void __put_unaligned16(__u16 val, void *p) -+{ -+ struct __una_u16 *ptr = (struct __una_u16 *)p; -+ ptr->x = val; -+} -+ -+static inline void __put_unaligned32(__u32 val, void *p) -+{ -+ struct __una_u32 *ptr = (struct __una_u32 *)p; -+ ptr->x = val; -+} -+ - /* - * Check at compile time that something is of a particular type. - * Always evaluates to 1 so you may use it easily in comparisons. --- -2.25.0 - diff --git a/0031-DDF-Cleanup-validate_geometry_ddf_container.patch b/0031-DDF-Cleanup-validate_geometry_ddf_container.patch new file mode 100644 index 0000000..92cd6c7 --- /dev/null +++ b/0031-DDF-Cleanup-validate_geometry_ddf_container.patch @@ -0,0 +1,144 @@ +From 679bd9508a30b2a0a1baecc9a21dd6c7d8d8d7dc Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:07 -0600 +Subject: [PATCH 32/61] DDF: Cleanup validate_geometry_ddf_container() +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Move the function up so that the function declaration is not necessary +and remove the unused arguments to the function. + +No functional changes are intended but will help with a bug fix in the +next patch. + +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super-ddf.c | 88 ++++++++++++++++++++++++----------------------------- + 1 file changed, 39 insertions(+), 49 deletions(-) + +diff --git a/super-ddf.c b/super-ddf.c +index abbc8b0..9d867f6 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -503,13 +503,6 @@ struct ddf_super { + static int load_super_ddf_all(struct supertype *st, int fd, + void **sbp, char *devname); + static int get_svd_state(const struct ddf_super *, const struct vcl *); +-static int +-validate_geometry_ddf_container(struct supertype *st, +- int level, int layout, int raiddisks, +- int chunk, unsigned long long size, +- unsigned long long data_offset, +- char *dev, unsigned long long *freesize, +- int verbose); + + static int validate_geometry_ddf_bvd(struct supertype *st, + int level, int layout, int raiddisks, +@@ -3322,6 +3315,42 @@ static int reserve_space(struct supertype *st, int raiddisks, + return 1; + } + ++static int ++validate_geometry_ddf_container(struct supertype *st, ++ int level, int raiddisks, ++ unsigned long long data_offset, ++ char *dev, unsigned long long *freesize, ++ int verbose) ++{ ++ int fd; ++ unsigned long long ldsize; ++ ++ if (level != LEVEL_CONTAINER) ++ return 0; ++ if (!dev) ++ return 1; ++ ++ fd = dev_open(dev, O_RDONLY|O_EXCL); ++ if (fd < 0) { ++ if (verbose) ++ pr_err("ddf: Cannot open %s: %s\n", ++ dev, strerror(errno)); ++ return 0; ++ } ++ if (!get_dev_size(fd, dev, &ldsize)) { ++ close(fd); ++ return 0; ++ } ++ close(fd); ++ if (freesize) { ++ *freesize = avail_size_ddf(st, ldsize >> 9, INVALID_SECTORS); ++ if (*freesize == 0) ++ return 0; ++ } ++ ++ return 1; ++} ++ + static int validate_geometry_ddf(struct supertype *st, + int level, int layout, int raiddisks, + int *chunk, unsigned long long size, +@@ -3347,11 +3376,9 @@ static int validate_geometry_ddf(struct supertype *st, + level = LEVEL_CONTAINER; + if (level == LEVEL_CONTAINER) { + /* Must be a fresh device to add to a container */ +- return validate_geometry_ddf_container(st, level, layout, +- raiddisks, *chunk, +- size, data_offset, dev, +- freesize, +- verbose); ++ return validate_geometry_ddf_container(st, level, raiddisks, ++ data_offset, dev, ++ freesize, verbose); + } + + if (!dev) { +@@ -3449,43 +3476,6 @@ static int validate_geometry_ddf(struct supertype *st, + return 1; + } + +-static int +-validate_geometry_ddf_container(struct supertype *st, +- int level, int layout, int raiddisks, +- int chunk, unsigned long long size, +- unsigned long long data_offset, +- char *dev, unsigned long long *freesize, +- int verbose) +-{ +- int fd; +- unsigned long long ldsize; +- +- if (level != LEVEL_CONTAINER) +- return 0; +- if (!dev) +- return 1; +- +- fd = dev_open(dev, O_RDONLY|O_EXCL); +- if (fd < 0) { +- if (verbose) +- pr_err("ddf: Cannot open %s: %s\n", +- dev, strerror(errno)); +- return 0; +- } +- if (!get_dev_size(fd, dev, &ldsize)) { +- close(fd); +- return 0; +- } +- close(fd); +- if (freesize) { +- *freesize = avail_size_ddf(st, ldsize >> 9, INVALID_SECTORS); +- if (*freesize == 0) +- return 0; +- } +- +- return 1; +-} +- + static int validate_geometry_ddf_bvd(struct supertype *st, + int level, int layout, int raiddisks, + int *chunk, unsigned long long size, +-- +2.35.3 + diff --git a/0031-super-intel-Use-put_unaligned-in-split_ull.patch b/0031-super-intel-Use-put_unaligned-in-split_ull.patch deleted file mode 100644 index 9218e04..0000000 --- a/0031-super-intel-Use-put_unaligned-in-split_ull.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 486720e0c2418e7e2e0a16221f7c42a308622254 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Tue, 9 Jul 2019 14:49:22 -0400 -Subject: [PATCH] super-intel: Use put_unaligned in split_ull -Git-commit: 486720e0c2418e7e2e0a16221f7c42a308622254 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Shut up some gcc9 errors by using put_unaligned() accessors. Not pretty, -but better than it was. - -Also correct to the correct swap macros. - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 230e164..d7e8a65 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1165,12 +1165,12 @@ static int count_memberships(struct dl *dl, struct intel_super *super) - - static __u32 imsm_min_reserved_sectors(struct intel_super *super); - --static int split_ull(unsigned long long n, __u32 *lo, __u32 *hi) -+static int split_ull(unsigned long long n, void *lo, void *hi) - { - if (lo == 0 || hi == 0) - return 1; -- *lo = __le32_to_cpu((unsigned)n); -- *hi = __le32_to_cpu((unsigned)(n >> 32)); -+ __put_unaligned32(__cpu_to_le32((__u32)n), lo); -+ __put_unaligned32(__cpu_to_le32((n >> 32)), hi); - return 0; - } - --- -2.25.0 - diff --git a/0032-DDF-Fix-NULL-pointer-dereference-in-validate_geometr.patch b/0032-DDF-Fix-NULL-pointer-dereference-in-validate_geometr.patch new file mode 100644 index 0000000..680c642 --- /dev/null +++ b/0032-DDF-Fix-NULL-pointer-dereference-in-validate_geometr.patch @@ -0,0 +1,52 @@ +From 2b93288a5650bb811932836f67f30d63c5ddcfbd Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:08 -0600 +Subject: [PATCH 33/61] DDF: Fix NULL pointer dereference in + validate_geometry_ddf() +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +A relatively recent patch added a call to validate_geometry() in +Manage_add() that has level=LEVEL_CONTAINER and chunk=NULL. + +This causes some ddf tests to segfault which aborts the test suite. + +To fix this, avoid dereferencing chunk when the level is +LEVEL_CONTAINER or LEVEL_NONE. + +Fixes: 1f5d54a06df0 ("Manage: Call validate_geometry when adding drive to external container") +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super-ddf.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/super-ddf.c b/super-ddf.c +index 9d867f6..949e7d1 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -3369,9 +3369,6 @@ static int validate_geometry_ddf(struct supertype *st, + * If given BVDs, we make an SVD, changing all the GUIDs in the process. + */ + +- if (*chunk == UnSet) +- *chunk = DEFAULT_CHUNK; +- + if (level == LEVEL_NONE) + level = LEVEL_CONTAINER; + if (level == LEVEL_CONTAINER) { +@@ -3381,6 +3378,9 @@ static int validate_geometry_ddf(struct supertype *st, + freesize, verbose); + } + ++ if (*chunk == UnSet) ++ *chunk = DEFAULT_CHUNK; ++ + if (!dev) { + mdu_array_info_t array = { + .level = level, +-- +2.35.3 + diff --git a/0032-mdadm-load-default-sysfs-attributes-after-assemblati.patch b/0032-mdadm-load-default-sysfs-attributes-after-assemblati.patch deleted file mode 100644 index e1cf302..0000000 --- a/0032-mdadm-load-default-sysfs-attributes-after-assemblati.patch +++ /dev/null @@ -1,349 +0,0 @@ -From b06815989179e0f153e44e4336290e655edce9a1 Mon Sep 17 00:00:00 2001 -From: Mariusz Dabrowski -Date: Wed, 10 Jul 2019 13:38:53 +0200 -Subject: [PATCH] mdadm: load default sysfs attributes after assemblation -Git-commit: b06815989179e0f153e44e4336290e655edce9a1 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Added new type of line to mdadm.conf which allows to specify values of -sysfs attributes for MD devices that should be loaded after the array is -assembled. Each line is interpreted as list of structures containing -sysname of MD device (md126 etc.) and list of sysfs attributes and their -values. - -Signed-off-by: Mariusz Dabrowski -Signed-off-by: Krzysztof Smolinski -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Assemble.c | 12 +++- - Incremental.c | 1 + - config.c | 7 ++- - mdadm.conf.5 | 25 ++++++++ - mdadm.h | 3 + - sysfs.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 202 insertions(+), 4 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 420c7b3..b2e6914 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1063,9 +1063,12 @@ static int start_array(int mdfd, - mddev, okcnt + sparecnt + journalcnt, - okcnt + sparecnt + journalcnt == 1 ? "" : "s"); - if (okcnt < (unsigned)content->array.raid_disks) -- fprintf(stderr, " (out of %d)", -+ fprintf(stderr, " (out of %d)\n", - content->array.raid_disks); -- fprintf(stderr, "\n"); -+ else { -+ fprintf(stderr, "\n"); -+ sysfs_rules_apply(mddev, content); -+ } - } - - if (st->ss->validate_container) { -@@ -1139,6 +1142,7 @@ static int start_array(int mdfd, - rv = ioctl(mdfd, RUN_ARRAY, NULL); - reopen_mddev(mdfd); /* drop O_EXCL */ - if (rv == 0) { -+ sysfs_rules_apply(mddev, content); - if (c->verbose >= 0) { - pr_err("%s has been started with %d drive%s", - mddev, okcnt, okcnt==1?"":"s"); -@@ -2130,10 +2134,12 @@ int assemble_container_content(struct supertype *st, int mdfd, - pr_err("array %s now has %d device%s", - chosen_name, working + preexist, - working + preexist == 1 ? "":"s"); -- else -+ else { -+ sysfs_rules_apply(chosen_name, content); - pr_err("Started %s with %d device%s", - chosen_name, working + preexist, - working + preexist == 1 ? "":"s"); -+ } - if (preexist) - fprintf(stderr, " (%d new)", working); - if (expansion) -diff --git a/Incremental.c b/Incremental.c -index d4d3c35..98dbcd9 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -480,6 +480,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, - pr_err("container %s now has %d device%s\n", - chosen_name, info.array.working_disks, - info.array.working_disks == 1?"":"s"); -+ sysfs_rules_apply(chosen_name, &info); - wait_for(chosen_name, mdfd); - if (st->ss->external) - strcpy(devnm, fd2devnm(mdfd)); -diff --git a/config.c b/config.c -index e14eae0..7592b2d 100644 ---- a/config.c -+++ b/config.c -@@ -80,7 +80,8 @@ char DefaultAltConfFile[] = CONFFILE2; - char DefaultAltConfDir[] = CONFFILE2 ".d"; - - enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev, -- Homehost, HomeCluster, AutoMode, Policy, PartPolicy, LTEnd }; -+ Homehost, HomeCluster, AutoMode, Policy, PartPolicy, Sysfs, -+ LTEnd }; - char *keywords[] = { - [Devices] = "devices", - [Array] = "array", -@@ -93,6 +94,7 @@ char *keywords[] = { - [AutoMode] = "auto", - [Policy] = "policy", - [PartPolicy]="part-policy", -+ [Sysfs] = "sysfs", - [LTEnd] = NULL - }; - -@@ -764,6 +766,9 @@ void conf_file(FILE *f) - case PartPolicy: - policyline(line, rule_part); - break; -+ case Sysfs: -+ sysfsline(line); -+ break; - default: - pr_err("Unknown keyword %s\n", line); - } -diff --git a/mdadm.conf.5 b/mdadm.conf.5 -index 47c962a..27dbab1 100644 ---- a/mdadm.conf.5 -+++ b/mdadm.conf.5 -@@ -587,6 +587,26 @@ be based on the domain, but with - appended, when N is the partition number for the partition that was - found. - -+.TP -+.B SYSFS -+The SYSFS line lists custom values of MD device's sysfs attributes which will be -+stored in sysfs after the array is assembled. Multiple lines are allowed and each -+line has to contain the uuid or the name of the device to which it relates. -+.RS 4 -+.TP -+.B uuid= -+hexadecimal identifier of MD device. This has to match the uuid stored in the -+superblock. -+.TP -+.B name= -+name of the MD device as was given to -+.I mdadm -+when the array was created. It will be ignored if -+.B uuid -+is not empty. -+.TP -+.RS 7 -+ - .SH EXAMPLE - DEVICE /dev/sd[bcdjkl]1 - .br -@@ -657,6 +677,11 @@ CREATE group=system mode=0640 auto=part\-8 - HOMEHOST - .br - AUTO +1.x homehost \-all -+.br -+SYSFS name=/dev/md/raid5 group_thread_cnt=4 sync_speed_max=1000000 -+.br -+SYSFS uuid=bead5eb6:31c17a27:da120ba2:7dfda40d group_thread_cnt=4 -+sync_speed_max=1000000 - - .SH SEE ALSO - .BR mdadm (8), -diff --git a/mdadm.h b/mdadm.h -index 0fa9e1b..c36d7fd 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1322,6 +1322,9 @@ void domain_add(struct domainlist **domp, char *domain); - extern void policy_save_path(char *id_path, struct map_ent *array); - extern int policy_check_path(struct mdinfo *disk, struct map_ent *array); - -+extern void sysfs_rules_apply(char *devnm, struct mdinfo *dev); -+extern void sysfsline(char *line); -+ - #if __GNUC__ < 3 - struct stat64; - #endif -diff --git a/sysfs.c b/sysfs.c -index 2dd9ab6..c313781 100644 ---- a/sysfs.c -+++ b/sysfs.c -@@ -26,9 +26,22 @@ - #include "mdadm.h" - #include - #include -+#include "dlink.h" - - #define MAX_SYSFS_PATH_LEN 120 - -+struct dev_sysfs_rule { -+ struct dev_sysfs_rule *next; -+ char *devname; -+ int uuid[4]; -+ int uuid_set; -+ struct sysfs_entry { -+ struct sysfs_entry *next; -+ char *name; -+ char *value; -+ } *entry; -+}; -+ - int load_sys(char *path, char *buf, int len) - { - int fd = open(path, O_RDONLY); -@@ -999,3 +1012,148 @@ int sysfs_wait(int fd, int *msec) - } - return n; - } -+ -+int sysfs_rules_apply_check(const struct mdinfo *sra, -+ const struct sysfs_entry *ent) -+{ -+ /* Check whether parameter is regular file, -+ * exists and is under specified directory. -+ */ -+ char fname[MAX_SYSFS_PATH_LEN]; -+ char dname[MAX_SYSFS_PATH_LEN]; -+ char resolved_path[PATH_MAX]; -+ char resolved_dir[PATH_MAX]; -+ -+ if (sra == NULL || ent == NULL) -+ return -1; -+ -+ snprintf(dname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/", sra->sys_name); -+ snprintf(fname, MAX_SYSFS_PATH_LEN, "%s/%s", dname, ent->name); -+ -+ if (realpath(fname, resolved_path) == NULL || -+ realpath(dname, resolved_dir) == NULL) -+ return -1; -+ -+ if (strncmp(resolved_dir, resolved_path, -+ strnlen(resolved_dir, PATH_MAX)) != 0) -+ return -1; -+ -+ return 0; -+} -+ -+static struct dev_sysfs_rule *sysfs_rules; -+ -+void sysfs_rules_apply(char *devnm, struct mdinfo *dev) -+{ -+ struct dev_sysfs_rule *rules = sysfs_rules; -+ -+ while (rules) { -+ struct sysfs_entry *ent = rules->entry; -+ int match = 0; -+ -+ if (!rules->uuid_set) { -+ if (rules->devname) -+ match = strcmp(devnm, rules->devname) == 0; -+ } else { -+ match = memcmp(dev->uuid, rules->uuid, -+ sizeof(int[4])) == 0; -+ } -+ -+ while (match && ent) { -+ if (sysfs_rules_apply_check(dev, ent) < 0) -+ pr_err("SYSFS: failed to write '%s' to '%s'\n", -+ ent->value, ent->name); -+ else -+ sysfs_set_str(dev, NULL, ent->name, ent->value); -+ ent = ent->next; -+ } -+ rules = rules->next; -+ } -+} -+ -+static void sysfs_rule_free(struct dev_sysfs_rule *rule) -+{ -+ struct sysfs_entry *entry; -+ -+ while (rule) { -+ struct dev_sysfs_rule *tmp = rule->next; -+ -+ entry = rule->entry; -+ while (entry) { -+ struct sysfs_entry *tmp = entry->next; -+ -+ free(entry->name); -+ free(entry->value); -+ free(entry); -+ entry = tmp; -+ } -+ -+ if (rule->devname) -+ free(rule->devname); -+ free(rule); -+ rule = tmp; -+ } -+} -+ -+void sysfsline(char *line) -+{ -+ struct dev_sysfs_rule *sr; -+ char *w; -+ -+ sr = xcalloc(1, sizeof(*sr)); -+ for (w = dl_next(line); w != line ; w = dl_next(w)) { -+ if (strncasecmp(w, "name=", 5) == 0) { -+ char *devname = w + 5; -+ -+ if (strncmp(devname, "/dev/md/", 8) == 0) { -+ if (sr->devname) -+ pr_err("Only give one device per SYSFS line: %s\n", -+ devname); -+ else -+ sr->devname = xstrdup(devname); -+ } else { -+ pr_err("%s is an invalid name for an md device - ignored.\n", -+ devname); -+ } -+ } else if (strncasecmp(w, "uuid=", 5) == 0) { -+ char *uuid = w + 5; -+ -+ if (sr->uuid_set) { -+ pr_err("Only give one uuid per SYSFS line: %s\n", -+ uuid); -+ } else { -+ if (parse_uuid(w + 5, sr->uuid) && -+ memcmp(sr->uuid, uuid_zero, -+ sizeof(int[4])) != 0) -+ sr->uuid_set = 1; -+ else -+ pr_err("Invalid uuid: %s\n", uuid); -+ } -+ } else { -+ struct sysfs_entry *prop; -+ -+ char *sep = strchr(w, '='); -+ -+ if (sep == NULL || *(sep + 1) == 0) { -+ pr_err("Cannot parse \"%s\" - ignoring.\n", w); -+ continue; -+ } -+ -+ prop = xmalloc(sizeof(*prop)); -+ prop->value = xstrdup(sep + 1); -+ *sep = 0; -+ prop->name = xstrdup(w); -+ prop->next = sr->entry; -+ sr->entry = prop; -+ } -+ } -+ -+ if (!sr->devname && !sr->uuid_set) { -+ pr_err("Device name not found in sysfs config entry - ignoring.\n"); -+ sysfs_rule_free(sr); -+ return; -+ } -+ -+ sr->next = sysfs_rules; -+ sysfs_rules = sr; -+} --- -2.25.0 - diff --git a/0033-mdadm-Grow-Fix-use-after-close-bug-by-closing-after-.patch b/0033-mdadm-Grow-Fix-use-after-close-bug-by-closing-after-.patch new file mode 100644 index 0000000..0715e29 --- /dev/null +++ b/0033-mdadm-Grow-Fix-use-after-close-bug-by-closing-after-.patch @@ -0,0 +1,88 @@ +From 548e9b916f86c06e2cdb50d8f49633f9bec66c7e Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:09 -0600 +Subject: [PATCH 34/61] mdadm/Grow: Fix use after close bug by closing after + fork +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +The test 07reshape-grow fails most of the time. But it succeeds around +1 in 5 times. When it does succeed, it causes the tests to die because +mdadm has segfaulted. + +The segfault was caused by mdadm attempting to repoen a file +descriptor that was already closed. The backtrace of the segfault +was: + + #0 __strncmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:101 + #1 0x000056146e31d44b in devnm2devid (devnm=0x0) at util.c:956 + #2 0x000056146e31dab4 in open_dev_flags (devnm=0x0, flags=0) + at util.c:1072 + #3 0x000056146e31db22 in open_dev (devnm=0x0) at util.c:1079 + #4 0x000056146e3202e8 in reopen_mddev (mdfd=4) at util.c:2244 + #5 0x000056146e329f36 in start_array (mdfd=4, + mddev=0x7ffc55342450 "/dev/md0", content=0x7ffc55342860, + st=0x56146fc78660, ident=0x7ffc55342f70, best=0x56146fc6f5d0, + bestcnt=10, chosen_drive=0, devices=0x56146fc706b0, okcnt=5, + sparecnt=0, rebuilding_cnt=0, journalcnt=0, c=0x7ffc55342e90, + clean=1, avail=0x56146fc78720 "\001\001\001\001\001", + start_partial_ok=0, err_ok=0, was_forced=0) + at Assemble.c:1206 + #6 0x000056146e32c36e in Assemble (st=0x56146fc78660, + mddev=0x7ffc55342450 "/dev/md0", ident=0x7ffc55342f70, + devlist=0x56146fc6e2d0, c=0x7ffc55342e90) + at Assemble.c:1914 + #7 0x000056146e312ac9 in main (argc=11, argv=0x7ffc55343238) + at mdadm.c:1510 + +The file descriptor was closed early in Grow_continue(). The noted commit +moved the close() call to close the fd above the fork which caused the +parent process to return with a closed fd. + +This meant reshape_array() and Grow_continue() would return in the parent +with the fd forked. The fd would eventually be passed to reopen_mddev() +which returned an unhandled NULL from fd2devnm() which would then be +dereferenced in devnm2devid. + +Fix this by moving the close() call below the fork. This appears to +fix the 07revert-grow test. While we're at it, switch to using +close_fd() to invalidate the file descriptor. + +Fixes: 77b72fa82813 ("mdadm/Grow: prevent md's fd from being occupied during delayed time") +Cc: Alex Wu +Cc: BingJing Chang +Cc: Danny Shih +Cc: ChangSyun Peng +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Grow.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Grow.c b/Grow.c +index 8c520d4..97f22c7 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -3514,7 +3514,6 @@ started: + return 0; + } + +- close(fd); + /* 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. +@@ -3535,6 +3534,9 @@ started: + break; + } + ++ /* Close unused file descriptor in the forked process */ ++ close_fd(&fd); ++ + /* If another array on the same devices is busy, the + * reshape will wait for them. This would mean that + * the first section that we suspend will stay suspended +-- +2.35.3 + diff --git a/0033-mdadm.h-include-sysmacros.h-unconditionally.patch b/0033-mdadm.h-include-sysmacros.h-unconditionally.patch deleted file mode 100644 index 8c5f4f8..0000000 --- a/0033-mdadm.h-include-sysmacros.h-unconditionally.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 452dc4d13a012cdcb05088c0dbc699959c4d6c73 Mon Sep 17 00:00:00 2001 -From: Baruch Siach -Date: Tue, 6 Aug 2019 16:05:23 +0300 -Subject: [PATCH] mdadm.h: include sysmacros.h unconditionally -Git-commit: 452dc4d13a012cdcb05088c0dbc699959c4d6c73 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -musl libc now also requires sys/sysmacros.h for the major/minor macros. -All supported libc implementations carry sys/sysmacros.h, including -diet-libc, klibc, and uclibc-ng. - -Cc: Hauke Mehrtens -Signed-off-by: Baruch Siach -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdadm.h | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/mdadm.h b/mdadm.h -index c36d7fd..d61a9ca 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -45,10 +45,8 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); - #include - #include - #include --#ifdef __GLIBC__ - /* Newer glibc requires sys/sysmacros.h directly for makedev() */ - #include --#endif - #ifdef __dietlibc__ - #include - /* dietlibc has deprecated random and srandom!! */ --- -2.25.0 - diff --git a/0034-mdadm-add-no-devices-to-avoid-component-devices-deta.patch b/0034-mdadm-add-no-devices-to-avoid-component-devices-deta.patch deleted file mode 100644 index 156e382..0000000 --- a/0034-mdadm-add-no-devices-to-avoid-component-devices-deta.patch +++ /dev/null @@ -1,161 +0,0 @@ -From d11abe4bd5cad39803726ddff1888674e417bda5 Mon Sep 17 00:00:00 2001 -From: Coly Li -Date: Wed, 31 Jul 2019 13:29:29 +0800 -Subject: [PATCH 1/2] mdadm: add --no-devices to avoid component devices detail - information -Git-commit: d11abe4bd5cad39803726ddff1888674e417bda5 -Patch-mainline: mdadm-4.1+ -References: bsc#1139709 - -When people assemble a md raid device with a large number of -component deivces (e.g. 1500 DASD disks), the raid device detail -information generated by 'mdadm --detail --export $devnode' is very -large. It is because the detail information contains information of -all the component disks (even the missing/failed ones). - -In such condition, when udev-md-raid-arrays.rules is triggered and -internally calls "mdadm --detail --no-devices --export $devnode", -user may observe systemd error message ""invalid message length". It -is because the following on-stack raw message buffer in systemd code -is not big enough, - systemd/src/libudev/libudev-monitor.c - _public_ struct udev_device *udev_monito ... - struct ucred *cred; - union { - struct udev_monitor_netlink_header nlh; - char raw[8192]; - } buf; -Even change size of raw[] from 8KB to larger size, it may still be not -enough for detail message of a md raid device with much larger number of -component devices. - -To fix this problem, an extra option '--no-devices' is added (the -original idea is proposed by Neil Brown). When printing detailed -information of a md raid device, if '--no-devices' is specified, then -all component devices information will not be printed, then the output -message size can be restricted to a small number, even with the systemd -only has 8KB on-disk raw buffer, the md raid array udev rules can work -correctly without failure message. - -Signed-off-by: Coly Li -Reviewed-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - Detail.c | 24 ++++++++++++++++-------- - ReadMe.c | 1 + - mdadm.c | 4 ++++ - mdadm.h | 2 ++ - 4 files changed, 23 insertions(+), 8 deletions(-) - -Index: mdadm-4.1/Detail.c -=================================================================== ---- mdadm-4.1.orig/Detail.c -+++ mdadm-4.1/Detail.c -@@ -56,7 +56,7 @@ int Detail(char *dev, struct context *c) - */ - int fd = open(dev, O_RDONLY); - mdu_array_info_t array; -- mdu_disk_info_t *disks; -+ mdu_disk_info_t *disks = NULL; - int next; - int d; - time_t atime; -@@ -280,7 +280,7 @@ int Detail(char *dev, struct context *c) - } - map_free(map); - } -- if (sra) { -+ if (!c->no_devices && sra) { - struct mdinfo *mdi; - for (mdi = sra->devs; mdi; mdi = mdi->next) { - char *path; -@@ -655,12 +655,17 @@ This is pretty boring - printf("\n\n"); - } - -- if (array.raid_disks) -- printf(" Number Major Minor RaidDevice State\n"); -- else -- printf(" Number Major Minor RaidDevice\n"); -+ if (!c->no_devices) { -+ if (array.raid_disks) -+ printf(" Number Major Minor RaidDevice State\n"); -+ else -+ printf(" Number Major Minor RaidDevice\n"); -+ } - } -- free(info); -+ -+ /* if --no_devices specified, not print component devices info */ -+ if (c->no_devices) -+ goto skip_devices_state; - - for (d = 0; d < max_disks * 2; d++) { - char *dv; -@@ -747,6 +752,8 @@ This is pretty boring - if (!c->brief) - printf("\n"); - } -+ -+skip_devices_state: - if (spares && c->brief && array.raid_disks) - printf(" spares=%d", spares); - if (c->brief && st && st->sb) -@@ -766,8 +773,9 @@ This is pretty boring - !enough(array.level, array.raid_disks, array.layout, 1, avail)) - rv = 2; - -- free(disks); - out: -+ free(info); -+ free(disks); - close(fd); - free(subarray); - free(avail); -Index: mdadm-4.1/ReadMe.c -=================================================================== ---- mdadm-4.1.orig/ReadMe.c -+++ mdadm-4.1/ReadMe.c -@@ -181,6 +181,7 @@ struct option long_options[] = { - - /* For Detail/Examine */ - {"brief", 0, 0, Brief}, -+ {"no-devices",0, 0, NoDevices}, - {"export", 0, 0, 'Y'}, - {"sparc2.2", 0, 0, Sparc22}, - {"test", 0, 0, 't'}, -Index: mdadm-4.1/mdadm.c -=================================================================== ---- mdadm-4.1.orig/mdadm.c -+++ mdadm-4.1/mdadm.c -@@ -159,6 +159,10 @@ int main(int argc, char *argv[]) - c.brief = 1; - continue; - -+ case NoDevices: -+ c.no_devices = 1; -+ continue; -+ - case 'Y': c.export++; - continue; - -Index: mdadm-4.1/mdadm.h -=================================================================== ---- mdadm-4.1.orig/mdadm.h -+++ mdadm-4.1/mdadm.h -@@ -412,6 +412,7 @@ enum special_options { - NoSharing, - HelpOptions, - Brief, -+ NoDevices, - ManageOpt, - Add, - AddSpare, -@@ -522,6 +523,7 @@ struct context { - int runstop; - int verbose; - int brief; -+ int no_devices; - int force; - char *homehost; - int require_homehost; diff --git a/0034-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch b/0034-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch new file mode 100644 index 0000000..2014ed1 --- /dev/null +++ b/0034-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch @@ -0,0 +1,39 @@ +From 9ae62977b51dab0f4bb46b1c8ea5ebd1705b2f4d Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:10 -0600 +Subject: [PATCH 35/61] monitor: Avoid segfault when calling NULL + get_bad_blocks +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Not all struct superswitch implement a get_bad_blocks() function, +yet mdmon seems to call it without checking for NULL and thus +occasionally segfaults in the test 10ddf-geometry. + +Fix this by checking for NULL before calling it. + +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + monitor.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/monitor.c b/monitor.c +index b877e59..820a93d 100644 +--- a/monitor.c ++++ b/monitor.c +@@ -311,6 +311,9 @@ static int check_for_cleared_bb(struct active_array *a, struct mdinfo *mdi) + struct md_bb *bb; + int i; + ++ if (!ss->get_bad_blocks) ++ return -1; ++ + /* + * Get a list of bad blocks for an array, then read list of + * acknowledged bad blocks from kernel and compare it against metadata +-- +2.35.3 + diff --git a/0035-mdadm-Fix-mdadm-r-remove-option-regression.patch b/0035-mdadm-Fix-mdadm-r-remove-option-regression.patch new file mode 100644 index 0000000..2656212 --- /dev/null +++ b/0035-mdadm-Fix-mdadm-r-remove-option-regression.patch @@ -0,0 +1,81 @@ +From 6c9d9260633f2c8491985b0782cf0fbd7e51651b Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:11 -0600 +Subject: [PATCH 36/61] mdadm: Fix mdadm -r remove option regression +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +The commit noted below globally adds a parameter to the -r option but missed +the fact that -r is used for another purpose: --remove. + +After that commit, a command such as: + + mdadm /dev/md0 -r /dev/loop0 + +will do nothing seeing the device parameter will be consumed as a +argument to the -r option; thus, there will only be one device +seen one the command line, devs_found will only be 1 and nothing will +happen. + +This caused the 01r5integ and 01raid6integ tests to hang indefinitely +as mdadm did not remove the failed device. With the device not removed, +it would not be readded. Then the loop waiting for the array status to +change would loop forever. + +This commit was recently reverted, but the legitimate fix for the +monitor operations was still not fixed. So add specific monitor +short ops to re-fix the --monitor -r option. + +Fixes: 546047688e1c ("mdadm: fix coredump of mdadm --monitor -r") +Fixes: 190dc029b141 ("Revert "mdadm: fix coredump of mdadm --monitor -r"") +Cc: Wu Guanghao +Cc: Mariusz Tkaczyk +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + ReadMe.c | 1 + + mdadm.c | 1 + + mdadm.h | 1 + + 3 files changed, 3 insertions(+) + +diff --git a/ReadMe.c b/ReadMe.c +index bec1be9..7518a32 100644 +--- a/ReadMe.c ++++ b/ReadMe.c +@@ -82,6 +82,7 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n"; + */ + + char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; ++char short_monitor_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k:"; + char short_bitmap_options[]= + "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; + char short_bitmap_auto_options[]= +diff --git a/mdadm.c b/mdadm.c +index be40686..d0c5e6d 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -227,6 +227,7 @@ int main(int argc, char *argv[]) + shortopt = short_bitmap_auto_options; + break; + case 'F': newmode = MONITOR; ++ shortopt = short_monitor_options; + break; + case 'G': newmode = GROW; + shortopt = short_bitmap_options; +diff --git a/mdadm.h b/mdadm.h +index 974415b..163f4a4 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -419,6 +419,7 @@ enum mode { + }; + + extern char short_options[]; ++extern char short_monitor_options[]; + extern char short_bitmap_options[]; + extern char short_bitmap_auto_options[]; + extern struct option long_options[]; +-- +2.35.3 + diff --git a/0035-udev-add-no-devices-option-for-calling-mdadm-detail.patch b/0035-udev-add-no-devices-option-for-calling-mdadm-detail.patch deleted file mode 100644 index 3fd1cdd..0000000 --- a/0035-udev-add-no-devices-option-for-calling-mdadm-detail.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 1a52f1fc0266d438c996789d4addbfac999a6139 Mon Sep 17 00:00:00 2001 -From: Coly Li -Date: Wed, 31 Jul 2019 13:29:30 +0800 -Subject: [PATCH 2/2] udev: add --no-devices option for calling 'mdadm - --detail' -Git-commit: 1a52f1fc0266d438c996789d4addbfac999a6139 -Patch-mainline: mdadm-4.1+ -References: bsc#1139709 - -When creating symlink of a md raid device, the detailed information of -component disks are unnecessary for rule udev-md-raid-arrays.rules. For -md raid devices with huge number of component disks (e.g. 1500 DASD -disks), the detail information of component devices can be very large -and exceed udev monitor's on-stack message buffer. - -This patch adds '--no-devices' option when calling mdadm by, -IMPORT{program}="BINDIR/mdadm --detail --no-devices --export $devnode" - -Now the detailed output won't include component disks information, -and the error message "invalid message length" reported by systemd can -be removed. - -Signed-off-by: Coly Li -Reviewed-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - udev-md-raid-arrays.rules | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules -index 5b99d58..d391665 100644 ---- a/udev-md-raid-arrays.rules -+++ b/udev-md-raid-arrays.rules -@@ -17,7 +17,7 @@ TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" - ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" - LABEL="md_ignore_state" - --IMPORT{program}="BINDIR/mdadm --detail --export $devnode" -+IMPORT{program}="BINDIR/mdadm --detail --no-devices --export $devnode" - ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" - ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" - ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" --- -2.16.4 - diff --git a/0036-imsm-close-removed-drive-fd.patch b/0036-imsm-close-removed-drive-fd.patch deleted file mode 100644 index 3f9ab8e..0000000 --- a/0036-imsm-close-removed-drive-fd.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 91c97c5432028875db5f8abeddb5cb5f31902001 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Mon, 15 Jul 2019 09:25:35 +0200 -Subject: [PATCH] imsm: close removed drive fd. -Git-commit: 91c97c5432028875db5f8abeddb5cb5f31902001 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -When member drive fails, managemon prepares metadata update and adds -the drive to disk_mgmt_list with DISK_REMOVE flag. It fills only -minor and major. It is enough to recognize the device later. - -Monitor thread while processing this update will remove the drive from -super only if it is a spare. It never removes failed member from -disks list. As a result, it still keeps opened descriptor to -non-existing device. - -If removed drive is not a spare fill fd in disk_cfg structure -(prepared by managemon), monitor will close fd during freeing it. - -Also set this drive fd to -1 in super to avoid double closing because -monitor will close the fd (if needed) while replacing removed drive -in array. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index d7e8a65..a103a3f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -9200,6 +9200,9 @@ static int add_remove_disk_update(struct intel_super *super) - remove_disk_super(super, - disk_cfg->major, - disk_cfg->minor); -+ } else { -+ disk_cfg->fd = disk->fd; -+ disk->fd = -1; - } - } - /* release allocate disk structure */ --- -2.25.0 - diff --git a/0036-mdadm-Fix-optional-write-behind-parameter.patch b/0036-mdadm-Fix-optional-write-behind-parameter.patch new file mode 100644 index 0000000..502174b --- /dev/null +++ b/0036-mdadm-Fix-optional-write-behind-parameter.patch @@ -0,0 +1,45 @@ +From 41edf6f45895193f4a523cb0a08d639c9ff9ccc9 Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 22 Jun 2022 14:25:12 -0600 +Subject: [PATCH 37/61] mdadm: Fix optional --write-behind parameter +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +The commit noted below changed the behaviour of --write-behind to +require an argument. This broke the 06wrmostly test with the error: + + mdadm: Invalid value for maximum outstanding write-behind writes: (null). + Must be between 0 and 16383. + +To fix this, check if optarg is NULL before parising it, as the origial +code did. + +Fixes: 60815698c0ac ("Refactor parse_num and use it to parse optarg.") +Cc: Mateusz Grzonka +Signed-off-by: Logan Gunthorpe +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + mdadm.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/mdadm.c b/mdadm.c +index d0c5e6d..56722ed 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -1201,8 +1201,9 @@ int main(int argc, char *argv[]) + case O(BUILD, WriteBehind): + case O(CREATE, WriteBehind): + s.write_behind = DEFAULT_MAX_WRITE_BEHIND; +- if (parse_num(&s.write_behind, optarg) != 0 || +- s.write_behind < 0 || s.write_behind > 16383) { ++ if (optarg && ++ (parse_num(&s.write_behind, optarg) != 0 || ++ s.write_behind < 0 || s.write_behind > 16383)) { + pr_err("Invalid value for maximum outstanding write-behind writes: %s.\n\tMust be between 0 and 16383.\n", + optarg); + exit(2); +-- +2.35.3 + diff --git a/0037-mdadm-Replace-obsolete-usleep-with-nanosleep.patch b/0037-mdadm-Replace-obsolete-usleep-with-nanosleep.patch new file mode 100644 index 0000000..99e2f22 --- /dev/null +++ b/0037-mdadm-Replace-obsolete-usleep-with-nanosleep.patch @@ -0,0 +1,319 @@ +From 239b3cc0b5da87e966746533b1873c439db54b16 Mon Sep 17 00:00:00 2001 +From: Mateusz Grzonka +Date: Fri, 12 Aug 2022 16:36:02 +0200 +Subject: [PATCH 45/61] mdadm: Replace obsolete usleep with nanosleep +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +According to POSIX.1-2001, usleep is considered obsolete. +Replace it with a wrapper that uses nanosleep, as recommended in man. +Add handy macros for conversions between msec, usec and nsec. + +Signed-off-by: Mateusz Grzonka +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Assemble.c | 2 +- + Grow.c | 4 ++-- + Manage.c | 10 +++++----- + managemon.c | 8 ++++---- + mdadm.h | 4 ++++ + mdmon.c | 4 ++-- + super-intel.c | 6 +++--- + util.c | 42 +++++++++++++++++++++++++++++++++--------- + 8 files changed, 54 insertions(+), 26 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 6df6bfb..be2160b 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -1947,7 +1947,7 @@ out: + break; + close(mdfd); + } +- usleep(usecs); ++ sleep_for(0, USEC_TO_NSEC(usecs), true); + usecs <<= 1; + } + } +diff --git a/Grow.c b/Grow.c +index 97f22c7..5780635 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -954,7 +954,7 @@ int start_reshape(struct mdinfo *sra, int already_running, + err = sysfs_set_str(sra, NULL, "sync_action", + "reshape"); + if (err) +- sleep(1); ++ sleep_for(1, 0, true); + } while (err && errno == EBUSY && cnt-- > 0); + } + return err; +@@ -5058,7 +5058,7 @@ int Grow_continue_command(char *devname, int fd, + } + st->ss->getinfo_super(st, content, NULL); + if (!content->reshape_active) +- sleep(3); ++ sleep_for(3, 0, true); + else + break; + } while (cnt-- > 0); +diff --git a/Manage.c b/Manage.c +index e5e6abe..a142f8b 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -244,7 +244,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) + "array_state", + "inactive")) < 0 && + errno == EBUSY) { +- usleep(200000); ++ sleep_for(0, MSEC_TO_NSEC(200), true); + count--; + } + if (err) { +@@ -328,7 +328,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) + sysfs_get_ll(mdi, NULL, "sync_max", &old_sync_max) == 0) { + /* must be in the critical section - wait a bit */ + delay -= 1; +- usleep(100000); ++ sleep_for(0, MSEC_TO_NSEC(100), true); + } + + if (sysfs_set_str(mdi, NULL, "sync_action", "frozen") != 0) +@@ -405,7 +405,7 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) + * quite started yet. Wait a bit and + * check 'sync_action' to see. + */ +- usleep(10000); ++ sleep_for(0, MSEC_TO_NSEC(10), true); + sysfs_get_str(mdi, NULL, "sync_action", buf, sizeof(buf)); + if (strncmp(buf, "reshape", 7) != 0) + break; +@@ -447,7 +447,7 @@ done: + count = 25; err = 0; + while (count && fd >= 0 && + (err = ioctl(fd, STOP_ARRAY, NULL)) < 0 && errno == EBUSY) { +- usleep(200000); ++ sleep_for(0, MSEC_TO_NSEC(200), true); + count --; + } + if (fd >= 0 && err) { +@@ -1105,7 +1105,7 @@ int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv, + ret = sysfs_unique_holder(devnm, rdev); + if (ret < 2) + break; +- usleep(100 * 1000); /* 100ms */ ++ sleep_for(0, MSEC_TO_NSEC(100), true); + } while (--count > 0); + + if (ret == 0) { +diff --git a/managemon.c b/managemon.c +index 0e9bdf0..a7bfa8f 100644 +--- a/managemon.c ++++ b/managemon.c +@@ -207,7 +207,7 @@ static void replace_array(struct supertype *container, + remove_old(); + while (pending_discard) { + while (discard_this == NULL) +- sleep(1); ++ sleep_for(1, 0, true); + remove_old(); + } + pending_discard = old; +@@ -568,7 +568,7 @@ static void manage_member(struct mdstat_ent *mdstat, + updates = NULL; + while (update_queue_pending || update_queue) { + check_update_queue(container); +- usleep(15*1000); ++ sleep_for(0, MSEC_TO_NSEC(15), true); + } + replace_array(container, a, newa); + if (sysfs_set_str(&a->info, NULL, +@@ -822,7 +822,7 @@ static void handle_message(struct supertype *container, struct metadata_update * + if (msg->len <= 0) + while (update_queue_pending || update_queue) { + check_update_queue(container); +- usleep(15*1000); ++ sleep_for(0, MSEC_TO_NSEC(15), true); + } + + if (msg->len == 0) { /* ping_monitor */ +@@ -836,7 +836,7 @@ static void handle_message(struct supertype *container, struct metadata_update * + wakeup_monitor(); + + while (monitor_loop_cnt - cnt < 0) +- usleep(10 * 1000); ++ sleep_for(0, MSEC_TO_NSEC(10), true); + } else if (msg->len == -1) { /* ping_manager */ + struct mdstat_ent *mdstat = mdstat_read(1, 0); + +diff --git a/mdadm.h b/mdadm.h +index 163f4a4..add9c0b 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1720,6 +1720,10 @@ extern int cluster_get_dlmlock(void); + extern int cluster_release_dlmlock(void); + extern void set_dlm_hooks(void); + ++#define MSEC_TO_NSEC(msec) ((msec) * 1000000) ++#define USEC_TO_NSEC(usec) ((usec) * 1000) ++extern void sleep_for(unsigned int sec, long nsec, bool wake_after_interrupt); ++ + #define _ROUND_UP(val, base) (((val) + (base) - 1) & ~(base - 1)) + #define ROUND_UP(val, base) _ROUND_UP(val, (typeof(val))(base)) + #define ROUND_UP_PTR(ptr, base) ((typeof(ptr)) \ +diff --git a/mdmon.c b/mdmon.c +index c057da6..e9d035e 100644 +--- a/mdmon.c ++++ b/mdmon.c +@@ -99,7 +99,7 @@ static int clone_monitor(struct supertype *container) + if (rc) + return rc; + while (mon_tid == -1) +- usleep(10); ++ sleep_for(0, USEC_TO_NSEC(10), true); + pthread_attr_destroy(&attr); + + mgr_tid = syscall(SYS_gettid); +@@ -209,7 +209,7 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock) + rv = kill(pid, SIGUSR1); + if (rv < 0) + break; +- usleep(200000); ++ sleep_for(0, MSEC_TO_NSEC(200), true); + } + } + +diff --git a/super-intel.c b/super-intel.c +index 4ddfcf9..4d82af3 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -5275,7 +5275,7 @@ static int get_super_block(struct intel_super **super_list, char *devnm, char *d + /* retry the load if we might have raced against mdmon */ + if (err == 3 && devnm && mdmon_running(devnm)) + for (retry = 0; retry < 3; retry++) { +- usleep(3000); ++ sleep_for(0, MSEC_TO_NSEC(3), true); + err = load_and_parse_mpb(dfd, s, NULL, keep_fd); + if (err != 3) + break; +@@ -5377,7 +5377,7 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname) + + if (mdstat && mdmon_running(mdstat->devnm) && getpid() != mdmon_pid(mdstat->devnm)) { + for (retry = 0; retry < 3; retry++) { +- usleep(3000); ++ sleep_for(0, MSEC_TO_NSEC(3), true); + rv = load_and_parse_mpb(fd, super, devname, 0); + if (rv != 3) + break; +@@ -12084,7 +12084,7 @@ int wait_for_reshape_imsm(struct mdinfo *sra, int ndata) + close(fd); + return 1; + } +- usleep(30000); ++ sleep_for(0, MSEC_TO_NSEC(30), true); + } else + break; + } while (retry--); +diff --git a/util.c b/util.c +index 38f0420..ca48d97 100644 +--- a/util.c ++++ b/util.c +@@ -166,7 +166,7 @@ retry: + pr_err("error %d when get PW mode on lock %s\n", errno, str); + /* let's try several times if EAGAIN happened */ + if (dlm_lock_res->lksb.sb_status == EAGAIN && retry_count < 10) { +- sleep(10); ++ sleep_for(10, 0, true); + retry_count++; + goto retry; + } +@@ -1085,7 +1085,7 @@ int open_dev_excl(char *devnm) + int i; + int flags = O_RDWR; + dev_t devid = devnm2devid(devnm); +- long delay = 1000; ++ unsigned int delay = 1; // miliseconds + + sprintf(buf, "%d:%d", major(devid), minor(devid)); + for (i = 0; i < 25; i++) { +@@ -1098,8 +1098,8 @@ int open_dev_excl(char *devnm) + } + if (errno != EBUSY) + return fd; +- usleep(delay); +- if (delay < 200000) ++ sleep_for(0, MSEC_TO_NSEC(delay), true); ++ if (delay < 200) + delay *= 2; + } + return -1; +@@ -1123,7 +1123,7 @@ void wait_for(char *dev, int fd) + { + int i; + struct stat stb_want; +- long delay = 1000; ++ unsigned int delay = 1; // miliseconds + + if (fstat(fd, &stb_want) != 0 || + (stb_want.st_mode & S_IFMT) != S_IFBLK) +@@ -1135,8 +1135,8 @@ void wait_for(char *dev, int fd) + (stb.st_mode & S_IFMT) == S_IFBLK && + (stb.st_rdev == stb_want.st_rdev)) + return; +- usleep(delay); +- if (delay < 200000) ++ sleep_for(0, MSEC_TO_NSEC(delay), true); ++ if (delay < 200) + delay *= 2; + } + if (i == 25) +@@ -1821,7 +1821,7 @@ int hot_remove_disk(int mdfd, unsigned long dev, int force) + while ((ret = ioctl(mdfd, HOT_REMOVE_DISK, dev)) == -1 && + errno == EBUSY && + cnt-- > 0) +- usleep(10000); ++ sleep_for(0, MSEC_TO_NSEC(10), true); + + return ret; + } +@@ -1834,7 +1834,7 @@ int sys_hot_remove_disk(int statefd, int force) + while ((ret = write(statefd, "remove", 6)) == -1 && + errno == EBUSY && + cnt-- > 0) +- usleep(10000); ++ sleep_for(0, MSEC_TO_NSEC(10), true); + return ret == 6 ? 0 : -1; + } + +@@ -2375,3 +2375,27 @@ out: + close(fd_zero); + return ret; + } ++ ++/** ++ * sleep_for() - Sleeps for specified time. ++ * @sec: Seconds to sleep for. ++ * @nsec: Nanoseconds to sleep for, has to be less than one second. ++ * @wake_after_interrupt: If set, wake up if interrupted. ++ * ++ * Function immediately returns if error different than EINTR occurs. ++ */ ++void sleep_for(unsigned int sec, long nsec, bool wake_after_interrupt) ++{ ++ struct timespec delay = {.tv_sec = sec, .tv_nsec = nsec}; ++ ++ assert(nsec < MSEC_TO_NSEC(1000)); ++ ++ do { ++ errno = 0; ++ nanosleep(&delay, &delay); ++ if (errno != 0 && errno != EINTR) { ++ pr_err("Error sleeping for %us %ldns: %s\n", sec, nsec, strerror(errno)); ++ return; ++ } ++ } while (!wake_after_interrupt && errno == EINTR); ++} +-- +2.35.3 + diff --git a/0037-mdadm-check-value-returned-by-snprintf-against-error.patch b/0037-mdadm-check-value-returned-by-snprintf-against-error.patch deleted file mode 100644 index cd6a422..0000000 --- a/0037-mdadm-check-value-returned-by-snprintf-against-error.patch +++ /dev/null @@ -1,50 +0,0 @@ -From fd5b09c9a9107f0393ce194c4aac6e7b8f163e85 Mon Sep 17 00:00:00 2001 -From: Krzysztof Smolinski -Date: Fri, 16 Aug 2019 11:06:17 +0200 -Subject: [PATCH] mdadm: check value returned by snprintf against errors -Git-commit: fd5b09c9a9107f0393ce194c4aac6e7b8f163e85 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -GCC 8 checks possible truncation during snprintf more strictly -than GCC 7 which result in compilation errors. To fix this -problem checking result of snprintf against errors has been added. - -Signed-off-by: Krzysztof Smolinski -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - sysfs.c | 12 ++++++++++-- - 1 file changed, 10 insertions(+), 2 deletions(-) - -diff --git a/sysfs.c b/sysfs.c -index c313781..2995713 100644 ---- a/sysfs.c -+++ b/sysfs.c -@@ -1023,12 +1023,20 @@ int sysfs_rules_apply_check(const struct mdinfo *sra, - char dname[MAX_SYSFS_PATH_LEN]; - char resolved_path[PATH_MAX]; - char resolved_dir[PATH_MAX]; -+ int result; - - if (sra == NULL || ent == NULL) - return -1; - -- snprintf(dname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md/", sra->sys_name); -- snprintf(fname, MAX_SYSFS_PATH_LEN, "%s/%s", dname, ent->name); -+ result = snprintf(dname, MAX_SYSFS_PATH_LEN, -+ "/sys/block/%s/md/", sra->sys_name); -+ if (result < 0 || result >= MAX_SYSFS_PATH_LEN) -+ return -1; -+ -+ result = snprintf(fname, MAX_SYSFS_PATH_LEN, -+ "%s/%s", dname, ent->name); -+ if (result < 0 || result >= MAX_SYSFS_PATH_LEN) -+ return -1; - - if (realpath(fname, resolved_path) == NULL || - realpath(dname, resolved_dir) == NULL) --- -2.25.0 - diff --git a/0038-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch b/0038-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch deleted file mode 100644 index c15b59d..0000000 --- a/0038-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 43ebc9105e9dafe5145b3e801c05da4736bf6e02 Mon Sep 17 00:00:00 2001 -From: "Guilherme G. Piccoli" -Date: Tue, 3 Sep 2019 16:49:01 -0300 -Subject: [PATCH] mdadm: Introduce new array state 'broken' for raid0/linear -Git-commit: 43ebc9105e9dafe5145b3e801c05da4736bf6e02 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Currently if a md raid0/linear array gets one or more members removed while -being mounted, kernel keeps showing state 'clean' in the 'array_state' -sysfs attribute. Despite udev signaling the member device is gone, 'mdadm' -cannot issue the STOP_ARRAY ioctl successfully, given the array is mounted. - -Nothing else hints that something is wrong (except that the removed devices -don't show properly in the output of mdadm 'detail' command). There is no -other property to be checked, and if user is not performing reads/writes -to the array, even kernel log is quiet and doesn't give a clue about the -missing member. - -This patch is the mdadm counterpart of kernel new array state 'broken'. -The 'broken' state mimics the state 'clean' in every aspect, being useful -only to distinguish if an array has some member missing. All necessary -paths in mdadm were changed to deal with 'broken' state, and in case the -tool runs in a kernel that is not updated, it'll work normally, i.e., it -doesn't require the 'broken' state in order to work. -Also, this patch changes the way the array state is showed in the 'detail' -command (for raid0/linear only) - now it takes the 'array_state' sysfs -attribute into account instead of only rely in the MD_SB_CLEAN flag. - -Cc: Jes Sorensen -Cc: NeilBrown -Cc: Song Liu -Signed-off-by: Guilherme G. Piccoli -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Detail.c | 14 ++++++++++++-- - Monitor.c | 8 ++++++-- - maps.c | 1 + - mdadm.h | 1 + - mdmon.h | 2 +- - monitor.c | 4 ++-- - 6 files changed, 23 insertions(+), 7 deletions(-) - -diff --git a/Detail.c b/Detail.c -index ad60434..3e61e37 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -81,6 +81,7 @@ int Detail(char *dev, struct context *c) - int external; - int inactive; - int is_container = 0; -+ char *arrayst; - - if (fd < 0) { - pr_err("cannot open %s: %s\n", -@@ -485,9 +486,18 @@ int Detail(char *dev, struct context *c) - else - st = ", degraded"; - -+ if (array.state & (1 << MD_SB_CLEAN)) { -+ if ((array.level == 0) || -+ (array.level == LEVEL_LINEAR)) -+ arrayst = map_num(sysfs_array_states, -+ sra->array_state); -+ else -+ arrayst = "clean"; -+ } else -+ arrayst = "active"; -+ - printf(" State : %s%s%s%s%s%s \n", -- (array.state & (1 << MD_SB_CLEAN)) ? -- "clean" : "active", st, -+ arrayst, st, - (!e || (e->percent < 0 && - e->percent != RESYNC_PENDING && - e->percent != RESYNC_DELAYED)) ? -diff --git a/Monitor.c b/Monitor.c -index 036103f..b527165 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -1055,8 +1055,11 @@ int Wait(char *dev) - } - } - -+/* The state "broken" is used only for RAID0/LINEAR - it's the same as -+ * "clean", but used in case the array has one or more members missing. -+ */ - static char *clean_states[] = { -- "clear", "inactive", "readonly", "read-auto", "clean", NULL }; -+ "clear", "inactive", "readonly", "read-auto", "clean", "broken", NULL }; - - int WaitClean(char *dev, int verbose) - { -@@ -1116,7 +1119,8 @@ int WaitClean(char *dev, int verbose) - rv = read(state_fd, buf, sizeof(buf)); - if (rv < 0) - break; -- if (sysfs_match_word(buf, clean_states) <= 4) -+ if (sysfs_match_word(buf, clean_states) < -+ (int)ARRAY_SIZE(clean_states) - 1) - break; - rv = sysfs_wait(state_fd, &delay); - if (rv < 0 && errno != EINTR) -diff --git a/maps.c b/maps.c -index 02a0474..49b7f2c 100644 ---- a/maps.c -+++ b/maps.c -@@ -150,6 +150,7 @@ mapping_t sysfs_array_states[] = { - { "read-auto", ARRAY_READ_AUTO }, - { "clean", ARRAY_CLEAN }, - { "write-pending", ARRAY_WRITE_PENDING }, -+ { "broken", ARRAY_BROKEN }, - { NULL, ARRAY_UNKNOWN_STATE } - }; - -diff --git a/mdadm.h b/mdadm.h -index 43b07d5..c88ceab 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -373,6 +373,7 @@ struct mdinfo { - ARRAY_ACTIVE, - ARRAY_WRITE_PENDING, - ARRAY_ACTIVE_IDLE, -+ ARRAY_BROKEN, - ARRAY_UNKNOWN_STATE, - } array_state; - struct md_bb bb; -diff --git a/mdmon.h b/mdmon.h -index 818367c..b3d72ac 100644 ---- a/mdmon.h -+++ b/mdmon.h -@@ -21,7 +21,7 @@ - extern const char Name[]; - - enum array_state { clear, inactive, suspended, readonly, read_auto, -- clean, active, write_pending, active_idle, bad_word}; -+ clean, active, write_pending, active_idle, broken, bad_word}; - - enum sync_action { idle, reshape, resync, recover, check, repair, bad_action }; - -diff --git a/monitor.c b/monitor.c -index 81537ed..e0d3be6 100644 ---- a/monitor.c -+++ b/monitor.c -@@ -26,7 +26,7 @@ - - static char *array_states[] = { - "clear", "inactive", "suspended", "readonly", "read-auto", -- "clean", "active", "write-pending", "active-idle", NULL }; -+ "clean", "active", "write-pending", "active-idle", "broken", NULL }; - static char *sync_actions[] = { - "idle", "reshape", "resync", "recover", "check", "repair", NULL - }; -@@ -476,7 +476,7 @@ static int read_and_act(struct active_array *a, fd_set *fds) - a->next_state = clean; - ret |= ARRAY_DIRTY; - } -- if (a->curr_state == clean) { -+ if ((a->curr_state == clean) || (a->curr_state == broken)) { - a->container->ss->set_array_state(a, 1); - } - if (a->curr_state == active || --- -2.25.0 - diff --git a/0038-mdadm-remove-symlink-option.patch b/0038-mdadm-remove-symlink-option.patch new file mode 100644 index 0000000..a12dff2 --- /dev/null +++ b/0038-mdadm-remove-symlink-option.patch @@ -0,0 +1,179 @@ +From e4a030a0d3a953b8e74c118200e58dc83c2fc608 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 19 Jul 2022 14:48:22 +0200 +Subject: [PATCH 48/61] mdadm: remove symlink option +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +The option is not used. Remove it from code. + +Signed-off-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + ReadMe.c | 1 - + config.c | 7 +------ + mdadm.8.in | 9 --------- + mdadm.c | 20 -------------------- + mdadm.conf.5.in | 15 --------------- + mdadm.h | 2 -- + 6 files changed, 1 insertion(+), 53 deletions(-) + +diff --git a/ReadMe.c b/ReadMe.c +index 7518a32..7f94847 100644 +--- a/ReadMe.c ++++ b/ReadMe.c +@@ -147,7 +147,6 @@ struct option long_options[] = { + {"nofailfast",0, 0, NoFailFast}, + {"re-add", 0, 0, ReAdd}, + {"homehost", 1, 0, HomeHost}, +- {"symlinks", 1, 0, Symlinks}, + {"data-offset",1, 0, DataOffset}, + {"nodes",1, 0, Nodes}, /* also for --assemble */ + {"home-cluster",1, 0, ClusterName}, +diff --git a/config.c b/config.c +index 9c72545..dc1620c 100644 +--- a/config.c ++++ b/config.c +@@ -194,7 +194,6 @@ struct mddev_dev *load_containers(void) + + struct createinfo createinfo = { + .autof = 2, /* by default, create devices with standard names */ +- .symlinks = 1, + .names = 0, /* By default, stick with numbered md devices. */ + .bblist = 1, /* Use a bad block list by default */ + #ifdef DEBIAN +@@ -310,11 +309,7 @@ static void createline(char *line) + if (!createinfo.supertype) + pr_err("metadata format %s unknown, ignoring\n", + w+9); +- } else if (strncasecmp(w, "symlinks=yes", 12) == 0) +- createinfo.symlinks = 1; +- else if (strncasecmp(w, "symlinks=no", 11) == 0) +- createinfo.symlinks = 0; +- else if (strncasecmp(w, "names=yes", 12) == 0) ++ } else if (strncasecmp(w, "names=yes", 12) == 0) + createinfo.names = 1; + else if (strncasecmp(w, "names=no", 11) == 0) + createinfo.names = 0; +diff --git a/mdadm.8.in b/mdadm.8.in +index 0be02e4..f273622 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -1048,11 +1048,6 @@ simultaneously. If not specified, this defaults to 4. + Specify journal device for the RAID-4/5/6 array. The journal device + should be a SSD with reasonable lifetime. + +-.TP +-.BR \-\-symlinks +-Auto creation of symlinks in /dev to /dev/md, option --symlinks must +-be 'no' or 'yes' and work with --create and --build. +- + .TP + .BR \-k ", " \-\-consistency\-policy= + Specify how the array maintains consistency in case of unexpected shutdown. +@@ -1405,10 +1400,6 @@ Reshape can be continued later using the + .B \-\-continue + option for the grow command. + +-.TP +-.BR \-\-symlinks +-See this option under Create and Build options. +- + .SH For Manage mode: + + .TP +diff --git a/mdadm.c b/mdadm.c +index 56722ed..180f7a9 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -59,7 +59,6 @@ int main(int argc, char *argv[]) + struct mddev_dev *dv; + mdu_array_info_t array; + int devs_found = 0; +- char *symlinks = NULL; + int grow_continue = 0; + /* autof indicates whether and how to create device node. + * bottom 3 bits are style. Rest (when shifted) are number of parts +@@ -663,13 +662,6 @@ int main(int argc, char *argv[]) + case O(ASSEMBLE,Auto): /* auto-creation of device node */ + c.autof = parse_auto(optarg, "--auto flag", 0); + continue; +- +- case O(CREATE,Symlinks): +- case O(BUILD,Symlinks): +- case O(ASSEMBLE,Symlinks): /* auto creation of symlinks in /dev to /dev/md */ +- symlinks = optarg; +- continue; +- + case O(BUILD,'f'): /* force honouring '-n 1' */ + case O(BUILD,Force): /* force honouring '-n 1' */ + case O(GROW,'f'): /* ditto */ +@@ -1325,18 +1317,6 @@ int main(int argc, char *argv[]) + exit(2); + } + +- if (symlinks) { +- struct createinfo *ci = conf_get_create_info(); +- +- if (strcasecmp(symlinks, "yes") == 0) +- ci->symlinks = 1; +- else if (strcasecmp(symlinks, "no") == 0) +- ci->symlinks = 0; +- else { +- pr_err("option --symlinks must be 'no' or 'yes'\n"); +- exit(2); +- } +- } + /* Ok, got the option parsing out of the way + * hopefully it's mostly right but there might be some stuff + * missing +diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in +index cd4e6a9..bc2295c 100644 +--- a/mdadm.conf.5.in ++++ b/mdadm.conf.5.in +@@ -338,21 +338,6 @@ missing device entries should be created. + The name of the metadata format to use if none is explicitly given. + This can be useful to impose a system-wide default of version-1 superblocks. + +-.TP +-.B symlinks=no +-Normally when creating devices in +-.B /dev/md/ +-.I mdadm +-will create a matching symlink from +-.B /dev/ +-with a name starting +-.B md +-or +-.BR md_ . +-Give +-.B symlinks=no +-to suppress this symlink creation. +- + .TP + .B names=yes + Since Linux 2.6.29 it has been possible to create +diff --git a/mdadm.h b/mdadm.h +index add9c0b..93e7278 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -394,7 +394,6 @@ struct createinfo { + int gid; + int autof; + int mode; +- int symlinks; + int names; + int bblist; + struct supertype *supertype; +@@ -442,7 +441,6 @@ enum special_options { + BackupFile, + HomeHost, + AutoHomeHost, +- Symlinks, + AutoDetect, + Waitclean, + DetailPlatform, +-- +2.35.3 + diff --git a/0039-mdadm-force-a-uuid-swap-on-big-endian.patch b/0039-mdadm-force-a-uuid-swap-on-big-endian.patch deleted file mode 100644 index 526f8a5..0000000 --- a/0039-mdadm-force-a-uuid-swap-on-big-endian.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 2c2d9c48d2daf0d78d20494c3779c0f6dc4bfa75 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Tue, 24 Sep 2019 11:39:24 -0400 -Subject: [PATCH] mdadm: force a uuid swap on big endian -Git-commit: 2c2d9c48d2daf0d78d20494c3779c0f6dc4bfa75 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -The code path for metadata 0.90 calls a common routine -fname_from_uuid that uses metadata 1.2. The code expects member -swapuuid to be setup and usable. But it is only setup when using -metadata 1.2. Since the metadata 0.90 did not create swapuuid -and set it. The test (st->ss == &super1) ? 1 : st->ss->swapuuid -fails. The swapuuid is set at compile time based on byte order. -Any call based on metadata 0.90 and on big endian processors, -the --export uuid will be incorrect. - -Signed-off-by: Nigel Croxon -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - util.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/util.c b/util.c -index c26cf5f..64dd409 100644 ---- a/util.c -+++ b/util.c -@@ -685,8 +685,12 @@ char *fname_from_uuid(struct supertype *st, struct mdinfo *info, - // 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 -+#if __BYTE_ORDER == BIG_ENDIAN -+ return __fname_from_uuid(info->uuid, 1, buf, sep); -+#else - return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 : - st->ss->swapuuid, buf, sep); -+#endif - } - - int check_ext2(int fd, char *name) --- -2.25.0 - diff --git a/0039-mdadm-move-data_offset-to-struct-shape.patch b/0039-mdadm-move-data_offset-to-struct-shape.patch new file mode 100644 index 0000000..f4fd958 --- /dev/null +++ b/0039-mdadm-move-data_offset-to-struct-shape.patch @@ -0,0 +1,235 @@ +From ae5dfc56b7a96805d5a0b50eaf93b9fec8604298 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Tue, 19 Jul 2022 14:48:23 +0200 +Subject: [PATCH 49/61] mdadm: move data_offset to struct shape +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Data offset is a shape property so move it there to remove additional +parameter from some functions. + +Signed-off-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Create.c | 16 ++++++++-------- + Grow.c | 7 +++---- + mdadm.c | 20 +++++++++----------- + mdadm.h | 5 ++--- + 4 files changed, 22 insertions(+), 26 deletions(-) + +diff --git a/Create.c b/Create.c +index c84c1ac..e06ec2a 100644 +--- a/Create.c ++++ b/Create.c +@@ -95,7 +95,7 @@ int Create(struct supertype *st, char *mddev, + char *name, int *uuid, + int subdevs, struct mddev_dev *devlist, + struct shape *s, +- struct context *c, unsigned long long data_offset) ++ struct context *c) + { + /* + * Create a new raid array. +@@ -288,7 +288,7 @@ int Create(struct supertype *st, char *mddev, + newsize = s->size * 2; + if (st && ! st->ss->validate_geometry(st, s->level, s->layout, s->raiddisks, + &s->chunk, s->size*2, +- data_offset, NULL, ++ s->data_offset, NULL, + &newsize, s->consistency_policy, + c->verbose >= 0)) + return 1; +@@ -323,10 +323,10 @@ int Create(struct supertype *st, char *mddev, + info.array.working_disks = 0; + dnum = 0; + for (dv = devlist; dv; dv = dv->next) +- if (data_offset == VARIABLE_OFFSET) ++ if (s->data_offset == VARIABLE_OFFSET) + dv->data_offset = INVALID_SECTORS; + else +- dv->data_offset = data_offset; ++ dv->data_offset = s->data_offset; + + for (dv=devlist; dv && !have_container; dv=dv->next, dnum++) { + char *dname = dv->devname; +@@ -342,7 +342,7 @@ int Create(struct supertype *st, char *mddev, + missing_disks ++; + continue; + } +- if (data_offset == VARIABLE_OFFSET) { ++ if (s->data_offset == VARIABLE_OFFSET) { + doff = strchr(dname, ':'); + if (doff) { + *doff++ = 0; +@@ -350,7 +350,7 @@ int Create(struct supertype *st, char *mddev, + } else + dv->data_offset = INVALID_SECTORS; + } else +- dv->data_offset = data_offset; ++ dv->data_offset = s->data_offset; + + dfd = open(dname, O_RDONLY); + if (dfd < 0) { +@@ -535,7 +535,7 @@ int Create(struct supertype *st, char *mddev, + if (!st->ss->validate_geometry(st, s->level, s->layout, + s->raiddisks, + &s->chunk, minsize*2, +- data_offset, ++ s->data_offset, + NULL, NULL, + s->consistency_policy, 0)) { + pr_err("devices too large for RAID level %d\n", s->level); +@@ -754,7 +754,7 @@ int Create(struct supertype *st, char *mddev, + } + } + if (!st->ss->init_super(st, &info.array, s, name, c->homehost, uuid, +- data_offset)) ++ s->data_offset)) + goto abort_locked; + + total_slots = info.array.nr_disks; +diff --git a/Grow.c b/Grow.c +index 5780635..868bdc3 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -1775,7 +1775,6 @@ static int reshape_container(char *container, char *devname, + + int Grow_reshape(char *devname, int fd, + struct mddev_dev *devlist, +- unsigned long long data_offset, + struct context *c, struct shape *s) + { + /* Make some changes in the shape of an array. +@@ -1821,7 +1820,7 @@ int Grow_reshape(char *devname, int fd, + return 1; + } + +- if (data_offset != INVALID_SECTORS && array.level != 10 && ++ if (s->data_offset != INVALID_SECTORS && array.level != 10 && + (array.level < 4 || array.level > 6)) { + pr_err("--grow --data-offset not yet supported\n"); + return 1; +@@ -2179,7 +2178,7 @@ size_change_error: + if ((s->level == UnSet || s->level == array.level) && + (s->layout_str == NULL) && + (s->chunk == 0 || s->chunk == array.chunk_size) && +- data_offset == INVALID_SECTORS && ++ s->data_offset == INVALID_SECTORS && + (s->raiddisks == 0 || s->raiddisks == array.raid_disks)) { + /* Nothing more to do */ + if (!changed && c->verbose >= 0) +@@ -2379,7 +2378,7 @@ size_change_error: + } + sync_metadata(st); + rv = reshape_array(container, fd, devname, st, &info, c->force, +- devlist, data_offset, c->backup_file, ++ devlist, s->data_offset, c->backup_file, + c->verbose, 0, 0, 0); + frozen = 0; + } +diff --git a/mdadm.c b/mdadm.c +index 180f7a9..845e446 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -49,7 +49,6 @@ int main(int argc, char *argv[]) + int i; + + unsigned long long array_size = 0; +- unsigned long long data_offset = INVALID_SECTORS; + struct mddev_ident ident; + char *configfile = NULL; + int devmode = 0; +@@ -79,6 +78,7 @@ int main(int argc, char *argv[]) + .layout = UnSet, + .bitmap_chunk = UnSet, + .consistency_policy = CONSISTENCY_POLICY_UNKNOWN, ++ .data_offset = INVALID_SECTORS, + }; + + char sys_hostname[256]; +@@ -479,15 +479,15 @@ int main(int argc, char *argv[]) + + case O(CREATE,DataOffset): + case O(GROW,DataOffset): +- if (data_offset != INVALID_SECTORS) { ++ if (s.data_offset != INVALID_SECTORS) { + pr_err("data-offset may only be specified one. Second value is %s.\n", optarg); + exit(2); + } + if (mode == CREATE && strcmp(optarg, "variable") == 0) +- data_offset = VARIABLE_OFFSET; ++ s.data_offset = VARIABLE_OFFSET; + else +- data_offset = parse_size(optarg); +- if (data_offset == INVALID_SECTORS) { ++ s.data_offset = parse_size(optarg); ++ if (s.data_offset == INVALID_SECTORS) { + pr_err("invalid data-offset: %s\n", + optarg); + exit(2); +@@ -1416,7 +1416,7 @@ int main(int argc, char *argv[]) + exit(1); + } + +- if (c.backup_file && data_offset != INVALID_SECTORS) { ++ if (c.backup_file && s.data_offset != INVALID_SECTORS) { + pr_err("--backup-file and --data-offset are incompatible\n"); + exit(2); + } +@@ -1587,8 +1587,7 @@ int main(int argc, char *argv[]) + + rv = Create(ss, devlist->devname, + ident.name, ident.uuid_set ? ident.uuid : NULL, +- devs_found-1, devlist->next, +- &s, &c, data_offset); ++ devs_found - 1, devlist->next, &s, &c); + break; + case MISC: + if (devmode == 'E') { +@@ -1706,10 +1705,9 @@ int main(int argc, char *argv[]) + c.verbose); + else if (s.size > 0 || s.raiddisks || s.layout_str || + s.chunk != 0 || s.level != UnSet || +- data_offset != INVALID_SECTORS) { ++ s.data_offset != INVALID_SECTORS) { + rv = Grow_reshape(devlist->devname, mdfd, +- devlist->next, +- data_offset, &c, &s); ++ devlist->next, &c, &s); + } else if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) { + rv = Grow_consistency_policy(devlist->devname, mdfd, &c, &s); + } else if (array_size == 0) +diff --git a/mdadm.h b/mdadm.h +index 93e7278..adb7cda 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -595,6 +595,7 @@ struct shape { + int assume_clean; + int write_behind; + unsigned long long size; ++ unsigned long long data_offset; + int consistency_policy; + }; + +@@ -1431,7 +1432,6 @@ extern int Grow_addbitmap(char *devname, int fd, + struct context *c, struct shape *s); + extern int Grow_reshape(char *devname, int fd, + struct mddev_dev *devlist, +- unsigned long long data_offset, + struct context *c, struct shape *s); + extern int Grow_restart(struct supertype *st, struct mdinfo *info, + int *fdlist, int cnt, char *backup_file, int verbose); +@@ -1462,8 +1462,7 @@ extern int Create(struct supertype *st, char *mddev, + char *name, int *uuid, + int subdevs, struct mddev_dev *devlist, + struct shape *s, +- struct context *c, +- unsigned long long data_offset); ++ struct context *c); + + extern int Detail(char *dev, struct context *c); + extern int Detail_Platform(struct superswitch *ss, int scan, int verbose, int export, char *controller_path); +-- +2.35.3 + diff --git a/0040-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch b/0040-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch new file mode 100644 index 0000000..554a5b4 --- /dev/null +++ b/0040-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch @@ -0,0 +1,165 @@ +From 27ad4900501c615b7c6b266bf23948e5606dba53 Mon Sep 17 00:00:00 2001 +From: Logan Gunthorpe +Date: Wed, 27 Jul 2022 15:52:46 -0600 +Subject: [PATCH 50/61] mdadm: Don't open md device for CREATE and ASSEMBLE +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +The mdadm command tries to open the md device for most modes, first +thing, no matter what. When running to create or assemble an array, +in most cases, the md device will not exist, the open call will fail +and everything will proceed correctly. + +However, when running tests, a create or assembly command may be run +shortly after stopping an array and the old md device file may still +be around. Then, if create_on_open is set in the kernel, a new md +device will be created when mdadm does its initial open. + +When mdadm gets around to creating the new device with the new_array +parameter it issues this error: + + mdadm: Fail to create md0 when using + /sys/module/md_mod/parameters/new_array, fallback to creation via node + +This is because an mddev was already created by the kernel with the +earlier open() call and thus the new one being created will fail with +EEXIST. The mdadm command will still successfully be created due to +falling back to the node creation method. However, the error message +itself will fail any test that's running it. + +This issue is a race condition that is very rare, but a recent change +in the kernel caused this to happen more frequently: about 1 in 50 +times. + +To fix this, don't bother trying to open the md device for CREATE, +ASSEMBLE and BUILD commands, as the file descriptor will never be used +anyway even if it is successfully openned. The mdfd has not been used +for these commands since: + + 7f91af49ad09 ("Delay creation of array devices for assemble/build/create") + +The checks that were done on the open device can be changed to being +done with stat. + +Side note: it would be nice to disable create_on_open as well to help +solve this, but it seems the work for this was never finished. By default, +mdadm will create using the old node interface when a name is specified +unless the user specifically puts names=yes in a config file, which +doesn't seem to be common or desirable to require this.. + +Signed-off-by: Logan Gunthorpe +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + lib.c | 12 ++++++++++++ + mdadm.c | 40 ++++++++++++++++++++-------------------- + mdadm.h | 1 + + 3 files changed, 33 insertions(+), 20 deletions(-) + +diff --git a/lib.c b/lib.c +index 7e3e3d4..e395b28 100644 +--- a/lib.c ++++ b/lib.c +@@ -164,6 +164,18 @@ char *stat2devnm(struct stat *st) + return devid2devnm(st->st_rdev); + } + ++bool stat_is_md_dev(struct stat *st) ++{ ++ if ((S_IFMT & st->st_mode) != S_IFBLK) ++ return false; ++ if (major(st->st_rdev) == MD_MAJOR) ++ return true; ++ if (major(st->st_rdev) == (unsigned)get_mdp_major()) ++ return true; ++ ++ return false; ++} ++ + char *fd2devnm(int fd) + { + struct stat stb; +diff --git a/mdadm.c b/mdadm.c +index 845e446..972adb5 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -1329,6 +1329,9 @@ int main(int argc, char *argv[]) + + if (mode == MANAGE || mode == BUILD || mode == CREATE || + mode == GROW || (mode == ASSEMBLE && ! c.scan)) { ++ struct stat stb; ++ int ret; ++ + if (devs_found < 1) { + pr_err("an md device must be given in this mode\n"); + exit(2); +@@ -1341,6 +1344,12 @@ int main(int argc, char *argv[]) + mdfd = open_mddev(devlist->devname, 1); + if (mdfd < 0) + exit(1); ++ ++ ret = fstat(mdfd, &stb); ++ if (ret) { ++ pr_err("fstat failed on %s.\n", devlist->devname); ++ exit(1); ++ } + } else { + char *bname = basename(devlist->devname); + +@@ -1348,30 +1357,21 @@ int main(int argc, char *argv[]) + pr_err("Name %s is too long.\n", devlist->devname); + exit(1); + } +- /* non-existent device is OK */ +- mdfd = open_mddev(devlist->devname, 0); +- } +- if (mdfd == -2) { +- pr_err("device %s exists but is not an md array.\n", devlist->devname); +- exit(1); +- } +- if ((int)ident.super_minor == -2) { +- struct stat stb; +- if (mdfd < 0) { ++ ++ ret = stat(devlist->devname, &stb); ++ if (ident.super_minor == -2 && ret != 0) { + pr_err("--super-minor=dev given, and listed device %s doesn't exist.\n", +- devlist->devname); ++ devlist->devname); ++ exit(1); ++ } ++ ++ if (!ret && !stat_is_md_dev(&stb)) { ++ pr_err("device %s exists but is not an md array.\n", devlist->devname); + exit(1); + } +- fstat(mdfd, &stb); +- ident.super_minor = minor(stb.st_rdev); +- } +- if (mdfd >= 0 && mode != MANAGE && mode != GROW) { +- /* We don't really want this open yet, we just might +- * have wanted to check some things +- */ +- close(mdfd); +- mdfd = -1; + } ++ if (ident.super_minor == -2) ++ ident.super_minor = minor(stb.st_rdev); + } + + if (s.raiddisks) { +diff --git a/mdadm.h b/mdadm.h +index adb7cda..8208b81 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1672,6 +1672,7 @@ void *super1_make_v0(struct supertype *st, struct mdinfo *info, mdp_super_t *sb0 + extern char *stat2kname(struct stat *st); + extern char *fd2kname(int fd); + extern char *stat2devnm(struct stat *st); ++bool stat_is_md_dev(struct stat *st); + extern char *fd2devnm(int fd); + extern void udev_block(char *devnm); + extern void udev_unblock(void); +-- +2.35.3 + diff --git a/0040-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch b/0040-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch deleted file mode 100644 index 6ad905a..0000000 --- a/0040-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch +++ /dev/null @@ -1,103 +0,0 @@ -From e53cb968691d9e40d83caf5570da3bb7b83c64e1 Mon Sep 17 00:00:00 2001 -From: Guoqing Jiang -Date: Fri, 31 May 2019 10:10:00 +0800 -Subject: [PATCH] mdadm/md.4: add the descriptions for bitmap sysfs nodes -Git-commit: e53cb968691d9e40d83caf5570da3bb7b83c64e1 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -The sysfs nodes under bitmap are not recorded in md.4, -add them based on md.rst and kernel source code. - -Cc: NeilBrown -Signed-off-by: Guoqing Jiang -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - md.4 | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 69 insertions(+) - -diff --git a/md.4 b/md.4 -index 3a1d677..e86707a 100644 ---- a/md.4 -+++ b/md.4 -@@ -1101,6 +1101,75 @@ stripe that requires some "prereading". For fairness this defaults to - maximizes sequential-write throughput at the cost of fairness to threads - doing small or random writes. - -+.TP -+.B md/bitmap/backlog -+The value stored in the file only has any effect on RAID1 when write-mostly -+devices are active, and write requests to those devices are proceed in the -+background. -+ -+This variable sets a limit on the number of concurrent background writes, -+the valid values are 0 to 16383, 0 means that write-behind is not allowed, -+while any other number means it can happen. If there are more write requests -+than the number, new writes will by synchronous. -+ -+.TP -+.B md/bitmap/can_clear -+This is for externally managed bitmaps, where the kernel writes the bitmap -+itself, but metadata describing the bitmap is managed by mdmon or similar. -+ -+When the array is degraded, bits mustn't be cleared. When the array becomes -+optimal again, bit can be cleared, but first the metadata needs to record -+the current event count. So md sets this to 'false' and notifies mdmon, -+then mdmon updates the metadata and writes 'true'. -+ -+There is no code in mdmon to actually do this, so maybe it doesn't even -+work. -+ -+.TP -+.B md/bitmap/chunksize -+The bitmap chunksize can only be changed when no bitmap is active, and -+the value should be power of 2 and at least 512. -+ -+.TP -+.B md/bitmap/location -+This indicates where the write-intent bitmap for the array is stored. -+It can be "none" or "file" or a signed offset from the array metadata -+- measured in sectors. You cannot set a file by writing here - that can -+only be done with the SET_BITMAP_FILE ioctl. -+ -+Write 'none' to 'bitmap/location' will clear bitmap, and the previous -+location value must be write to it to restore bitmap. -+ -+.TP -+.B md/bitmap/max_backlog_used -+This keeps track of the maximum number of concurrent write-behind requests -+for an md array, writing any value to this file will clear it. -+ -+.TP -+.B md/bitmap/metadata -+This can be 'internal' or 'clustered' or 'external'. 'internal' is set -+by default, which means the metadata for bitmap is stored in the first 256 -+bytes of the bitmap space. 'clustered' means separate bitmap metadata are -+used for each cluster node. 'external' means that bitmap metadata is managed -+externally to the kernel. -+ -+.TP -+.B md/bitmap/space -+This shows the space (in sectors) which is available at md/bitmap/location, -+and allows the kernel to know when it is safe to resize the bitmap to match -+a resized array. It should big enough to contain the total bytes in the bitmap. -+ -+For 1.0 metadata, assume we can use up to the superblock if before, else -+to 4K beyond superblock. For other metadata versions, assume no change is -+possible. -+ -+.TP -+.B md/bitmap/time_base -+This shows the time (in seconds) between disk flushes, and is used to looking -+for bits in the bitmap to be cleared. -+ -+The default value is 5 seconds, and it should be an unsigned long value. -+ - .SS KERNEL PARAMETERS - - The md driver recognised several different kernel parameters. --- -2.25.0 - diff --git a/0041-Grow-Split-Grow_reshape-into-helper-function.patch b/0041-Grow-Split-Grow_reshape-into-helper-function.patch new file mode 100644 index 0000000..98af135 --- /dev/null +++ b/0041-Grow-Split-Grow_reshape-into-helper-function.patch @@ -0,0 +1,233 @@ +From 7211116c295ba1f9e1fcbdc2dd2d3762855062e1 Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Thu, 28 Jul 2022 20:20:53 +0800 +Subject: [PATCH 51/61] Grow: Split Grow_reshape into helper function +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Grow_reshape should be split into helper functions given its size. +- Add helper function for preparing reshape on external metadata. +- Close cfd file descriptor. + +Signed-off-by: Mateusz Kusiak +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + Grow.c | 125 ++++++++++++++++++++++++++++++-------------------------- + mdadm.h | 1 + + util.c | 14 +++++++ + 3 files changed, 81 insertions(+), 59 deletions(-) + +diff --git a/Grow.c b/Grow.c +index 868bdc3..0f07a89 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -1773,6 +1773,65 @@ static int reshape_container(char *container, char *devname, + char *backup_file, int verbose, + int forked, int restart, int freeze_reshape); + ++/** ++ * prepare_external_reshape() - prepares update on external metadata if supported. ++ * @devname: Device name. ++ * @subarray: Subarray. ++ * @st: Supertype. ++ * @container: Container. ++ * @cfd: Container file descriptor. ++ * ++ * Function checks that the requested reshape is supported on external metadata, ++ * and performs an initial check that the container holds the pre-requisite ++ * spare devices (mdmon owns final validation). ++ * ++ * Return: 0 on success, else 1 ++ */ ++static int prepare_external_reshape(char *devname, char *subarray, ++ struct supertype *st, char *container, ++ const int cfd) ++{ ++ struct mdinfo *cc = NULL; ++ struct mdinfo *content = NULL; ++ ++ if (st->ss->load_container(st, cfd, NULL)) { ++ pr_err("Cannot read superblock for %s\n", devname); ++ return 1; ++ } ++ ++ if (!st->ss->container_content) ++ return 1; ++ ++ cc = st->ss->container_content(st, subarray); ++ for (content = cc; content ; content = content->next) { ++ /* ++ * check if reshape is allowed based on metadata ++ * indications stored in content.array.status ++ */ ++ if (is_bit_set(&content->array.state, MD_SB_BLOCK_VOLUME) || ++ is_bit_set(&content->array.state, MD_SB_BLOCK_CONTAINER_RESHAPE)) { ++ pr_err("Cannot reshape arrays in container with unsupported metadata: %s(%s)\n", ++ devname, container); ++ goto error; ++ } ++ if (content->consistency_policy == CONSISTENCY_POLICY_PPL) { ++ pr_err("Operation not supported when ppl consistency policy is enabled\n"); ++ goto error; ++ } ++ if (content->consistency_policy == CONSISTENCY_POLICY_BITMAP) { ++ pr_err("Operation not supported when write-intent bitmap consistency policy is enabled\n"); ++ goto error; ++ } ++ } ++ sysfs_free(cc); ++ if (mdmon_running(container)) ++ st->update_tail = &st->updates; ++ return 0; ++error: ++ sysfs_free(cc); ++ return 1; ++} ++ + int Grow_reshape(char *devname, int fd, + struct mddev_dev *devlist, + struct context *c, struct shape *s) +@@ -1799,7 +1858,7 @@ int Grow_reshape(char *devname, int fd, + struct supertype *st; + char *subarray = NULL; + +- int frozen; ++ int frozen = 0; + int changed = 0; + char *container = NULL; + int cfd = -1; +@@ -1808,7 +1867,7 @@ int Grow_reshape(char *devname, int fd, + int added_disks; + + struct mdinfo info; +- struct mdinfo *sra; ++ struct mdinfo *sra = NULL; + + if (md_get_array_info(fd, &array) < 0) { + pr_err("%s is not an active md array - aborting\n", +@@ -1865,13 +1924,7 @@ int Grow_reshape(char *devname, int fd, + } + } + +- /* in the external case we need to check that the requested reshape is +- * supported, and perform an initial check that the container holds the +- * pre-requisite spare devices (mdmon owns final validation) +- */ + if (st->ss->external) { +- int retval; +- + if (subarray) { + container = st->container_devnm; + cfd = open_dev_excl(st->container_devnm); +@@ -1887,13 +1940,12 @@ int Grow_reshape(char *devname, int fd, + return 1; + } + +- retval = st->ss->load_container(st, cfd, NULL); +- +- if (retval) { +- pr_err("Cannot read superblock for %s\n", devname); +- close(cfd); ++ rv = prepare_external_reshape(devname, subarray, st, ++ container, cfd); ++ if (rv > 0) { + free(subarray); +- return 1; ++ close(cfd); ++ goto release; + } + + if (s->raiddisks && subarray) { +@@ -1902,51 +1954,6 @@ int Grow_reshape(char *devname, int fd, + free(subarray); + return 1; + } +- +- /* check if operation is supported for metadata handler */ +- if (st->ss->container_content) { +- struct mdinfo *cc = NULL; +- struct mdinfo *content = NULL; +- +- cc = st->ss->container_content(st, subarray); +- for (content = cc; content ; content = content->next) { +- int allow_reshape = 1; +- +- /* check if reshape is allowed based on metadata +- * indications stored in content.array.status +- */ +- if (content->array.state & +- (1 << MD_SB_BLOCK_VOLUME)) +- allow_reshape = 0; +- if (content->array.state & +- (1 << MD_SB_BLOCK_CONTAINER_RESHAPE)) +- allow_reshape = 0; +- if (!allow_reshape) { +- pr_err("cannot reshape arrays in container with unsupported metadata: %s(%s)\n", +- devname, container); +- sysfs_free(cc); +- free(subarray); +- return 1; +- } +- if (content->consistency_policy == +- CONSISTENCY_POLICY_PPL) { +- pr_err("Operation not supported when ppl consistency policy is enabled\n"); +- sysfs_free(cc); +- free(subarray); +- return 1; +- } +- if (content->consistency_policy == +- CONSISTENCY_POLICY_BITMAP) { +- pr_err("Operation not supported when write-intent bitmap is enabled\n"); +- sysfs_free(cc); +- free(subarray); +- return 1; +- } +- } +- sysfs_free(cc); +- } +- if (mdmon_running(container)) +- st->update_tail = &st->updates; + } + + added_disks = 0; +diff --git a/mdadm.h b/mdadm.h +index 8208b81..941a5f3 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1539,6 +1539,7 @@ extern int stat_is_blkdev(char *devname, dev_t *rdev); + extern bool is_dev_alive(char *path); + extern int get_mdp_major(void); + extern int get_maj_min(char *dev, int *major, int *minor); ++extern bool is_bit_set(int *val, unsigned char index); + extern int dev_open(char *dev, int flags); + extern int open_dev(char *devnm); + extern void reopen_mddev(int mdfd); +diff --git a/util.c b/util.c +index ca48d97..26ffdce 100644 +--- a/util.c ++++ b/util.c +@@ -1027,6 +1027,20 @@ int get_maj_min(char *dev, int *major, int *minor) + *e == 0); + } + ++/** ++ * is_bit_set() - get bit value by index. ++ * @val: value. ++ * @index: index of the bit (LSB numbering). ++ * ++ * Return: bit value. ++ */ ++bool is_bit_set(int *val, unsigned char index) ++{ ++ if ((*val) & (1 << index)) ++ return true; ++ return false; ++} ++ + int dev_open(char *dev, int flags) + { + /* like 'open', but if 'dev' matches %d:%d, create a temp +-- +2.35.3 + diff --git a/0041-Init-devlist-as-an-array.patch b/0041-Init-devlist-as-an-array.patch deleted file mode 100644 index 219965e..0000000 --- a/0041-Init-devlist-as-an-array.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 8063fd0f9e8abd718bd65928c19bc607cee5acd8 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Mon, 30 Sep 2019 19:47:59 +0800 -Subject: [PATCH] Init devlist as an array -Git-commit: 8063fd0f9e8abd718bd65928c19bc607cee5acd8 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -devlist is an string. It will change to an array if there is disk that -is sbd disk. If one device is sbd, it runs devlist=(). -This line code changes devlist from a string to an array. If there is -no sbd device, it can't run this line code. So it will still be a string. -The later codes need an array, rather than an string. So init devlist -as an array to fix this problem. - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - clustermd_tests/func.sh | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/clustermd_tests/func.sh b/clustermd_tests/func.sh -index 642cc96..801d604 100644 ---- a/clustermd_tests/func.sh -+++ b/clustermd_tests/func.sh -@@ -39,6 +39,9 @@ fetch_devlist() - devlist=($(ls /dev/disk/by-path/*$ISCSI_ID*)) - fi - # sbd disk cannot use in testing -+ # Init devlist as an array -+ i='' -+ devlist=(${devlist[@]#$i}) - for i in ${devlist[@]} - do - sbd -d $i dump &> /dev/null --- -2.25.0 - diff --git a/0042-Assemble-check-if-device-is-container-before-schedul.patch b/0042-Assemble-check-if-device-is-container-before-schedul.patch new file mode 100644 index 0000000..e264894 --- /dev/null +++ b/0042-Assemble-check-if-device-is-container-before-schedul.patch @@ -0,0 +1,39 @@ +From 5c3c3df646dd3b7e8df81152f08e9ac4ddccc671 Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Fri, 19 Aug 2022 02:55:46 +0200 +Subject: [PATCH 52/61] Assemble: check if device is container before + scheduling force-clean update +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Up to now using assemble with force flag making each array as clean. +Force-clean should not be done for the container. This commit add +check if device is different than container before cleaning. + +Signed-off-by: Kinga Tanska +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Assemble.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index be2160b..1dd82a8 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -1809,10 +1809,9 @@ try_again: + } + #endif + } +- if (c->force && !clean && ++ if (c->force && !clean && content->array.level != LEVEL_CONTAINER && + !enough(content->array.level, content->array.raid_disks, +- content->array.layout, clean, +- avail)) { ++ content->array.layout, clean, avail)) { + change += st->ss->update_super(st, content, "force-array", + devices[chosen_drive].devname, c->verbose, + 0, NULL); +-- +2.35.3 + diff --git a/0042-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch b/0042-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch deleted file mode 100644 index ac6f758..0000000 --- a/0042-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 611093148574164fcf4f24f8c076d09473f655d7 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Mon, 30 Sep 2019 19:48:00 +0800 -Subject: [PATCH] Don't need to check recovery after re-add when no I/O writes - to raid -Git-commit: 611093148574164fcf4f24f8c076d09473f655d7 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -If there is no write I/O between removing member disk and re-add it, there is no -recovery after re-adding member disk. - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - clustermd_tests/02r1_Manage_re-add | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/clustermd_tests/02r1_Manage_re-add b/clustermd_tests/02r1_Manage_re-add -index dd9c416..d0d13e5 100644 ---- a/clustermd_tests/02r1_Manage_re-add -+++ b/clustermd_tests/02r1_Manage_re-add -@@ -9,8 +9,6 @@ check all state UU - check all dmesg - mdadm --manage $md0 --fail $dev0 --remove $dev0 - mdadm --manage $md0 --re-add $dev0 --check $NODE1 recovery --check all wait - check all state UU - check all dmesg - stop_md all $md0 --- -2.25.0 - diff --git a/0043-super1-report-truncated-device.patch b/0043-super1-report-truncated-device.patch new file mode 100644 index 0000000..c787f8c --- /dev/null +++ b/0043-super1-report-truncated-device.patch @@ -0,0 +1,115 @@ +From 171e9743881edf2dfb163ddff483566fbf913ccd Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Fri, 26 Aug 2022 08:55:56 +1000 +Subject: [PATCH 53/61] super1: report truncated device +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +When the metadata is at the start of the device, it is possible that it +describes a device large than the one it is actually stored on. When +this happens, report it loudly in --examine. + +.... + Unused Space : before=1968 sectors, after=-2047 sectors DEVICE TOO SMALL + State : clean TRUNCATED DEVICE +.... + +Also report in --assemble so that the failure which the kernel will +report will be explained. + +mdadm: Device /dev/sdb is not large enough for data described in superblock +mdadm: no RAID superblock on /dev/sdb +mdadm: /dev/sdb has no superblock - assembly aborted + +Scenario can be demonstrated as follows: + +mdadm: Note: this array has metadata at the start and + may not be suitable as a boot device. If you plan to + store '/boot' on this device please ensure that + your boot-loader understands md/v1.x metadata, or use + --metadata=0.90 +mdadm: Defaulting to version 1.2 metadata +mdadm: array /dev/md/test started. +mdadm: stopped /dev/md/test + Unused Space : before=1968 sectors, after=-2047 sectors DEVICE TOO SMALL + State : clean TRUNCATED DEVICE + Unused Space : before=1968 sectors, after=-2047 sectors DEVICE TOO SMALL + State : clean TRUNCATED DEVICE + +Signed-off-by: NeilBrown +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + super1.c | 35 ++++++++++++++++++++++++++++------- + 1 file changed, 28 insertions(+), 7 deletions(-) + +diff --git a/super1.c b/super1.c +index 71af860..58345e6 100644 +--- a/super1.c ++++ b/super1.c +@@ -406,12 +406,18 @@ static void examine_super1(struct supertype *st, char *homehost) + + st->ss->getinfo_super(st, &info, NULL); + if (info.space_after != 1 && +- !(__le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET)) +- printf(" Unused Space : before=%llu sectors, after=%llu sectors\n", +- info.space_before, info.space_after); +- +- printf(" State : %s\n", +- (__le64_to_cpu(sb->resync_offset)+1)? "active":"clean"); ++ !(__le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET)) { ++ printf(" Unused Space : before=%llu sectors, ", ++ info.space_before); ++ if (info.space_after < INT64_MAX) ++ printf("after=%llu sectors\n", info.space_after); ++ else ++ printf("after=-%llu sectors DEVICE TOO SMALL\n", ++ UINT64_MAX - info.space_after); ++ } ++ printf(" State : %s%s\n", ++ (__le64_to_cpu(sb->resync_offset)+1) ? "active":"clean", ++ (info.space_after > INT64_MAX) ? " TRUNCATED DEVICE" : ""); + printf(" Device UUID : "); + for (i=0; i<16; i++) { + if ((i&3)==0 && i != 0) +@@ -2206,6 +2212,7 @@ static int load_super1(struct supertype *st, int fd, char *devname) + tst.ss = &super1; + for (tst.minor_version = 0; tst.minor_version <= 2; + tst.minor_version++) { ++ tst.ignore_hw_compat = st->ignore_hw_compat; + switch(load_super1(&tst, fd, devname)) { + case 0: super = tst.sb; + if (bestvers == -1 || +@@ -2312,7 +2319,6 @@ static int load_super1(struct supertype *st, int fd, char *devname) + free(super); + return 2; + } +- st->sb = super; + + bsb = (struct bitmap_super_s *)(((char*)super)+MAX_SB_SIZE); + +@@ -2322,6 +2328,21 @@ static int load_super1(struct supertype *st, int fd, char *devname) + if (st->data_offset == INVALID_SECTORS) + st->data_offset = __le64_to_cpu(super->data_offset); + ++ if (st->minor_version >= 1 && ++ st->ignore_hw_compat == 0 && ++ (dsize < (__le64_to_cpu(super->data_offset) + ++ __le64_to_cpu(super->size)) ++ || ++ dsize < (__le64_to_cpu(super->data_offset) + ++ __le64_to_cpu(super->data_size)))) { ++ if (devname) ++ pr_err("Device %s is not large enough for data described in superblock\n", ++ devname); ++ free(super); ++ return 2; ++ } ++ st->sb = super; ++ + /* Now check on the bitmap superblock */ + if ((__le32_to_cpu(super->feature_map)&MD_FEATURE_BITMAP_OFFSET) == 0) + return 0; +-- +2.35.3 + diff --git a/0043-udev-allow-for-udev-attribute-reading-bug.patch b/0043-udev-allow-for-udev-attribute-reading-bug.patch deleted file mode 100644 index c491a41..0000000 --- a/0043-udev-allow-for-udev-attribute-reading-bug.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 7bd59e7926c6921121087eb067befaa896c900a4 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Wed, 18 Sep 2019 15:12:55 +1000 -Subject: [PATCH] udev: allow for udev attribute reading bug. -Git-commit: 7bd59e7926c6921121087eb067befaa896c900a4 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -There is a bug in udev (which will hopefully get fixed, but -we should allow for it anways). -When reading a sysfs attribute, it first reads the whole -value of the attribute, then reads again expecting to get -a read of 0 bytes, like you would with an ordinary file. -If the sysfs attribute changed between these two reads, it can -get a mixture of two values. - -In particular, if it reads when 'array_state' is changing from -'clear' to 'inactive', it can find the value as "clear\nve". - -This causes the test for "|clear|active" to fail, so systemd is allowed -to think that the array is ready - when it isn't. - -So change the pattern to allow for this but adding a wildcard at -the end. -Also don't allow for an empty string - reading array_state will -never return an empty string - if it exists at all, it will be -non-empty. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - udev-md-raid-arrays.rules | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules -index d391665..c8fa8e8 100644 ---- a/udev-md-raid-arrays.rules -+++ b/udev-md-raid-arrays.rules -@@ -14,7 +14,7 @@ ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" - # never leave state 'inactive' - 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/array_state}=="clear*|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" - LABEL="md_ignore_state" - - IMPORT{program}="BINDIR/mdadm --detail --no-devices --export $devnode" --- -2.25.0 - diff --git a/0044-imsm-save-current_vol-number.patch b/0044-imsm-save-current_vol-number.patch deleted file mode 100644 index 1759ae7..0000000 --- a/0044-imsm-save-current_vol-number.patch +++ /dev/null @@ -1,45 +0,0 @@ -From b6180160f78f0182b296bdceed6419b26a6fccc7 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 4 Oct 2019 12:07:28 +0200 -Subject: [PATCH] imsm: save current_vol number -Git-commit: b6180160f78f0182b296bdceed6419b26a6fccc7 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -The imsm container_content routine will set curr_volume index in super -for getting volume information. This flag has never been restored to -original value, later other function may rely on it. - -Restore this flag to original value. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index a103a3f..e02bbd7 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7826,6 +7826,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - int sb_errors = 0; - struct dl *d; - int spare_disks = 0; -+ int current_vol = super->current_vol; - - /* do not assemble arrays when not all attributes are supported */ - if (imsm_check_attributes(mpb->attributes) == 0) { -@@ -7993,6 +7994,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - rest = this; - } - -+ super->current_vol = current_vol; - return rest; - } - --- -2.25.0 - diff --git a/0044-mdadm-Correct-typos-punctuation-and-grammar-in-man.patch b/0044-mdadm-Correct-typos-punctuation-and-grammar-in-man.patch new file mode 100644 index 0000000..49ae568 --- /dev/null +++ b/0044-mdadm-Correct-typos-punctuation-and-grammar-in-man.patch @@ -0,0 +1,619 @@ +From 1a386f804d8392b849b3362da6b0157b0db83091 Mon Sep 17 00:00:00 2001 +From: Mateusz Grzonka +Date: Fri, 12 Aug 2022 16:52:12 +0200 +Subject: [PATCH 54/61] mdadm: Correct typos, punctuation and grammar in man +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Signed-off-by: Mateusz Grzonka +Reviewed-by: Wol +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + mdadm.8.in | 178 ++++++++++++++++++++++++++--------------------------- + 1 file changed, 88 insertions(+), 90 deletions(-) + +diff --git a/mdadm.8.in b/mdadm.8.in +index f273622..70c79d1 100644 +--- a/mdadm.8.in ++++ b/mdadm.8.in +@@ -158,7 +158,7 @@ adding new spares and removing faulty devices. + .B Misc + This is an 'everything else' mode that supports operations on active + arrays, operations on component devices such as erasing old superblocks, and +-information gathering operations. ++information-gathering operations. + .\"This mode allows operations on independent devices such as examine MD + .\"superblocks, erasing old superblocks and stopping active arrays. + +@@ -231,12 +231,12 @@ mode to be assumed. + + .TP + .BR \-h ", " \-\-help +-Display general help message or, after one of the above options, a ++Display a general help message or, after one of the above options, a + mode-specific help message. + + .TP + .B \-\-help\-options +-Display more detailed help about command line parsing and some commonly ++Display more detailed help about command-line parsing and some commonly + used options. + + .TP +@@ -266,7 +266,7 @@ the exact meaning of this option in different contexts. + + .TP + .BR \-c ", " \-\-config= +-Specify the config file or directory. If not specified, default config file ++Specify the config file or directory. If not specified, the default config file + and default conf.d directory will be used. See + .BR mdadm.conf (5) + for more details. +@@ -379,7 +379,7 @@ When creating an array, the + .B homehost + will be recorded in the metadata. For version-1 superblocks, it will + be prefixed to the array name. For version-0.90 superblocks, part of +-the SHA1 hash of the hostname will be stored in the later half of the ++the SHA1 hash of the hostname will be stored in the latter half of the + UUID. + + When reporting information about an array, any array which is tagged +@@ -388,7 +388,7 @@ for the given homehost will be reported as such. + When using Auto-Assemble, only arrays tagged for the given homehost + will be allowed to use 'local' names (i.e. not ending in '_' followed + by a digit string). See below under +-.BR "Auto Assembly" . ++.BR "Auto-Assembly" . + + The special name "\fBany\fP" can be used as a wild card. If an array + is created with +@@ -403,7 +403,7 @@ When + .I mdadm + needs to print the name for a device it normally finds the name in + .B /dev +-which refers to the device and is shortest. When a path component is ++which refers to the device and is the shortest. When a path component is + given with + .B \-\-prefer + .I mdadm +@@ -478,9 +478,9 @@ still be larger than any replacement. + + This option can be used with + .B \-\-create +-for determining initial size of an array. For external metadata, ++for determining the initial size of an array. For external metadata, + it can be used on a volume, but not on a container itself. +-Setting initial size of ++Setting the initial size of + .B RAID 0 + array is only valid for external metadata. + +@@ -545,20 +545,20 @@ Clustered arrays do not support this parameter yet. + + .TP + .BR \-c ", " \-\-chunk= +-Specify chunk size of kilobytes. The default when creating an ++Specify chunk size in kilobytes. The default when creating an + array is 512KB. To ensure compatibility with earlier versions, the + default when building an array with no persistent metadata is 64KB. + This is only meaningful for RAID0, RAID4, RAID5, RAID6, and RAID10. + + RAID4, RAID5, RAID6, and RAID10 require the chunk size to be a power +-of 2. In any case it must be a multiple of 4KB. ++of 2, with minimal chunk size being 4KB. + + A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes, + Megabytes, Gigabytes or Terabytes respectively. + + .TP + .BR \-\-rounding= +-Specify rounding factor for a Linear array. The size of each ++Specify the rounding factor for a Linear array. The size of each + component will be rounded down to a multiple of this size. + This is a synonym for + .B \-\-chunk +@@ -655,7 +655,8 @@ option to set subsequent failure modes. + and "flush" will clear any persistent faults. + + The layout options for RAID10 are one of 'n', 'o' or 'f' followed +-by a small number. The default is 'n2'. The supported options are: ++by a small number signifying the number of copies of each datablock. ++The default is 'n2'. The supported options are: + + .I 'n' + signals 'near' copies. Multiple copies of one data block are at +@@ -673,7 +674,7 @@ signals 'far' copies + (multiple copies have very different offsets). + See md(4) for more detail about 'near', 'offset', and 'far'. + +-The number is the number of copies of each datablock. 2 is normal, 3 ++As for the number of copies of each data block, 2 is normal, 3 + can be useful. This number can be at most equal to the number of + devices in the array. It does not need to divide evenly into that + number (e.g. it is perfectly legal to have an 'n2' layout for an array +@@ -684,7 +685,7 @@ A bug introduced in Linux 3.14 means that RAID0 arrays + started using a different layout. This could lead to + data corruption. Since Linux 5.4 (and various stable releases that received + backports), the kernel will not accept such an array unless +-a layout is explictly set. It can be set to ++a layout is explicitly set. It can be set to + .RB ' original ' + or + .RB ' alternate '. +@@ -760,13 +761,13 @@ or by selecting a different consistency policy with + + .TP + .BR \-\-bitmap\-chunk= +-Set the chunksize of the bitmap. Each bit corresponds to that many ++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 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 chunksize defaults to 64Meg, or larger if necessary to ++bitmap, the chunk size defaults to 64Meg, or larger if necessary to + fit the bitmap into the available space. + + A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes, +@@ -840,7 +841,7 @@ can be used with that command to avoid the automatic resync. + .BR \-\-backup\-file= + This is needed when + .B \-\-grow +-is used to increase the number of raid-devices in a RAID5 or RAID6 if ++is used to increase the number of raid devices in a RAID5 or RAID6 if + there are no spare devices available, or to shrink, change RAID level + or layout. See the GROW MODE section below on RAID\-DEVICES CHANGES. + The file must be stored on a separate device, not on the RAID array +@@ -879,7 +880,7 @@ When creating an array, + .B \-\-data\-offset + can be specified as + .BR variable . +-In the case each member device is expected to have a offset appended ++In the case each member device is expected to have an offset appended + to the name, separated by a colon. This makes it possible to recreate + exactly an array which has varying data offsets (as can happen when + different versions of +@@ -943,7 +944,7 @@ Insist that + .I mdadm + accept the geometry and layout specified without question. Normally + .I mdadm +-will not allow creation of an array with only one device, and will try ++will not allow the creation of an array with only one device, and will try + to create a RAID5 array with one missing drive (as this makes the + initial resync work faster). With + .BR \-\-force , +@@ -1004,7 +1005,7 @@ number added, e.g. + If the md device name is in a 'standard' format as described in DEVICE + NAMES, then it will be created, if necessary, with the appropriate + device number based on that name. If the device name is not in one of these +-formats, then a unused device number will be allocated. The device ++formats, then an unused device number will be allocated. The device + number will be considered unused if there is no active array for that + number, and there is no entry in /dev for that number and with a + non-standard name. Names that are not in 'standard' format are only +@@ -1032,25 +1033,25 @@ then + .B \-\-add + can be used to add some extra devices to be included in the array. + In most cases this is not needed as the extra devices can be added as +-spares first, and then the number of raid-disks can be changed. +-However for RAID0, it is not possible to add spares. So to increase ++spares first, and then the number of raid disks can be changed. ++However, for RAID0 it is not possible to add spares. So to increase + the number of devices in a RAID0, it is necessary to set the new + number of devices, and to add the new devices, in the same command. + + .TP + .BR \-\-nodes +-Only works when the array is for clustered environment. It specifies ++Only works when the array is created for a clustered environment. It specifies + the maximum number of nodes in the cluster that will use this device + simultaneously. If not specified, this defaults to 4. + + .TP + .BR \-\-write-journal + Specify journal device for the RAID-4/5/6 array. The journal device +-should be a SSD with reasonable lifetime. ++should be an SSD with a reasonable lifetime. + + .TP + .BR \-k ", " \-\-consistency\-policy= +-Specify how the array maintains consistency in case of unexpected shutdown. ++Specify how the array maintains consistency in the case of an unexpected shutdown. + Only relevant for RAID levels with redundancy. + Currently supported options are: + .RS +@@ -1058,7 +1059,7 @@ Currently supported options are: + .TP + .B resync + Full resync is performed and all redundancy is regenerated when the array is +-started after unclean shutdown. ++started after an unclean shutdown. + + .TP + .B bitmap +@@ -1067,8 +1068,8 @@ Resync assisted by a write-intent bitmap. Implicitly selected when using + + .TP + .B journal +-For RAID levels 4/5/6, journal device is used to log transactions and replay +-after unclean shutdown. Implicitly selected when using ++For RAID levels 4/5/6, the journal device is used to log transactions and replay ++after an unclean shutdown. Implicitly selected when using + .BR \-\-write\-journal . + + .TP +@@ -1237,7 +1238,7 @@ This can be useful if + reports a different "Preferred Minor" to + .BR \-\-detail . + In some cases this update will be performed automatically +-by the kernel driver. In particular the update happens automatically ++by the kernel driver. In particular, the update happens automatically + at the first write to an array with redundancy (RAID level 1 or + greater) on a 2.6 (or later) kernel. + +@@ -1277,7 +1278,7 @@ For version-1 superblocks, this involves updating the name. + The + .B home\-cluster + option will change the cluster name as recorded in the superblock and +-bitmap. This option only works for clustered environment. ++bitmap. This option only works for a clustered environment. + + The + .B resync +@@ -1390,10 +1391,10 @@ This option should be used with great caution. + + .TP + .BR \-\-freeze\-reshape +-Option is intended to be used in start-up scripts during initrd boot phase. +-When array under reshape is assembled during initrd phase, this option +-stops reshape after reshape critical section is being restored. This happens +-before file system pivot operation and avoids loss of file system context. ++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 +@@ -1437,9 +1438,9 @@ re\-add a device that was previously removed from an array. + If the metadata on the device reports that it is a member of the + array, and the slot that it used is still vacant, then the device will + be added back to the array in the same position. This will normally +-cause the data for that device to be recovered. However based on the ++cause the data for that device to be recovered. However, based on the + event count on the device, the recovery may only require sections that +-are flagged a write-intent bitmap to be recovered or may not require ++are flagged by a write-intent bitmap to be recovered or may not require + any recovery at all. + + When used on an array that has no metadata (i.e. it was built with +@@ -1447,13 +1448,12 @@ When used on an array that has no metadata (i.e. it was built with + it will be assumed that bitmap-based recovery is enough to make the + device fully consistent with the array. + +-When used with v1.x metadata, + .B \-\-re\-add +-can be accompanied by ++can also be accompanied by + .BR \-\-update=devicesize , + .BR \-\-update=bbl ", or" + .BR \-\-update=no\-bbl . +-See the description of these option when used in Assemble mode for an ++See descriptions of these options when used in Assemble mode for an + explanation of their use. + + If the device name given is +@@ -1480,7 +1480,7 @@ Add a device as a spare. This is similar to + except that it does not attempt + .B \-\-re\-add + first. The device will be added as a spare even if it looks like it +-could be an recent member of the array. ++could be a recent member of the array. + + .TP + .BR \-r ", " \-\-remove +@@ -1497,12 +1497,12 @@ and names like + .B set-A + can be given to + .BR \-\-remove . +-The first causes all failed device to be removed. The second causes ++The first causes all failed devices to be removed. The second causes + any device which is no longer connected to the system (i.e an 'open' + returns + .BR ENXIO ) + to be removed. +-The third will remove a set as describe below under ++The third will remove a set as described below under + .BR \-\-fail . + + .TP +@@ -1519,7 +1519,7 @@ For RAID10 arrays where the number of copies evenly divides the number + of devices, the devices can be conceptually divided into sets where + each set contains a single complete copy of the data on the array. + Sometimes a RAID10 array will be configured so that these sets are on +-separate controllers. In this case all the devices in one set can be ++separate controllers. In this case, all the devices in one set can be + failed by giving a name like + .B set\-A + or +@@ -1549,9 +1549,9 @@ This can follow a list of + .B \-\-replace + devices. The devices listed after + .B \-\-with +-will be preferentially used to replace the devices listed after ++will preferentially be used to replace the devices listed after + .BR \-\-replace . +-These device must already be spare devices in the array. ++These devices must already be spare devices in the array. + + .TP + .BR \-\-write\-mostly +@@ -1574,8 +1574,8 @@ the device is found or :missing in case the device is not found. + + .TP + .BR \-\-add-journal +-Add journal to an existing array, or recreate journal for RAID-4/5/6 array +-that lost a journal device. To avoid interrupting on-going write opertions, ++Add a journal to an existing array, or recreate journal for a RAID-4/5/6 array ++that lost a journal device. To avoid interrupting ongoing write operations, + .B \-\-add-journal + only works for array in Read-Only state. + +@@ -1631,9 +1631,9 @@ Print details of one or more md devices. + .TP + .BR \-\-detail\-platform + Print details of the platform's RAID capabilities (firmware / hardware +-topology) for a given metadata format. If used without argument, mdadm ++topology) for a given metadata format. If used without an argument, mdadm + will scan all controllers looking for their capabilities. Otherwise, mdadm +-will only look at the controller specified by the argument in form of an ++will only look at the controller specified by the argument in the form of an + absolute filepath or a link, e.g. + .IR /sys/devices/pci0000:00/0000:00:1f.2 . + +@@ -1742,8 +1742,8 @@ the block where the superblock would be is overwritten even if it + doesn't appear to be valid. + + .B Note: +-Be careful to call \-\-zero\-superblock with clustered raid, make sure +-array isn't used or assembled in other cluster node before execute it. ++Be careful when calling \-\-zero\-superblock with clustered raid. Make sure ++the array isn't used or assembled in another cluster node before executing it. + + .TP + .B \-\-kill\-subarray= +@@ -1790,7 +1790,7 @@ For each md device given, or each device in /proc/mdstat if + is given, arrange for the array to be marked clean as soon as possible. + .I mdadm + will return with success if the array uses external metadata and we +-successfully waited. For native arrays this returns immediately as the ++successfully waited. For native arrays, this returns immediately as the + kernel handles dirty-clean transitions at shutdown. No action is taken + if safe-mode handling is disabled. + +@@ -1830,7 +1830,7 @@ uses to help track which arrays are currently being assembled. + + .TP + .BR \-\-run ", " \-R +-Run any array assembled as soon as a minimal number of devices are ++Run any array assembled as soon as a minimal number of devices is + available, rather than waiting until all expected devices are present. + + .TP +@@ -1860,7 +1860,7 @@ Only used with \-\-fail. The 'path' given will be recorded so that if + a new device appears at the same location it can be automatically + added to the same array. This allows the failed device to be + automatically replaced by a new device without metadata if it appears +-at specified path. This option is normally only set by a ++at specified path. This option is normally only set by an + .I udev + script. + +@@ -1961,7 +1961,7 @@ Usage: + .PP + This usage assembles one or more RAID arrays from pre-existing components. + For each array, mdadm needs to know the md device, the identity of the +-array, and a number of component-devices. These can be found in a number of ways. ++array, and the number of component devices. These can be found in a number of ways. + + In the first usage example (without the + .BR \-\-scan ) +@@ -2001,7 +2001,7 @@ The config file is only used if explicitly named with + .B \-\-config + or requested with (a possibly implicit) + .BR \-\-scan . +-In the later case, default config file is used. See ++In the latter case, the default config file is used. See + .BR mdadm.conf (5) + for more details. + +@@ -2039,14 +2039,14 @@ detects that udev is not configured, it will create the devices in + .B /dev + itself. + +-In Linux kernels prior to version 2.6.28 there were two distinctly +-different types of md devices that could be created: one that could be ++In Linux kernels prior to version 2.6.28 there were two distinct ++types of md devices that could be created: one that could be + partitioned using standard partitioning tools and one that could not. +-Since 2.6.28 that distinction is no longer relevant as both type of ++Since 2.6.28 that distinction is no longer relevant as both types of + devices can be partitioned. + .I mdadm + will normally create the type that originally could not be partitioned +-as it has a well defined major number (9). ++as it has a well-defined major number (9). + + Prior to 2.6.28, it is important that mdadm chooses the correct type + of array device to use. This can be controlled with the +@@ -2066,7 +2066,7 @@ can also be given in the configuration file as a word starting + .B auto= + on the ARRAY line for the relevant array. + +-.SS Auto Assembly ++.SS Auto-Assembly + When + .B \-\-assemble + is used with +@@ -2122,11 +2122,11 @@ See + .IR mdadm.conf (5) + for further details. + +-Note: Auto assembly cannot be used for assembling and activating some ++Note: Auto-assembly cannot be used for assembling and activating some + arrays which are undergoing reshape. In particular as the + .B backup\-file +-cannot be given, any reshape which requires a backup-file to continue +-cannot be started by auto assembly. An array which is growing to more ++cannot be given, any reshape which requires a backup file to continue ++cannot be started by auto-assembly. An array which is growing to more + devices and has passed the critical section can be assembled using + auto-assembly. + +@@ -2233,7 +2233,7 @@ When creating a partition based array, using + .I mdadm + with version-1.x metadata, the partition type should be set to + .B 0xDA +-(non fs-data). This type selection allows for greater precision since ++(non fs-data). This type of selection allows for greater precision since + using any other [RAID auto-detect (0xFD) or a GNU/Linux partition (0x83)], + might create problems in the event of array recovery through a live cdrom. + +@@ -2249,7 +2249,7 @@ when creating a v0.90 array will silently override any + setting. + .\"If the + .\".B \-\-size +-.\"option is given, it is not necessary to list any component-devices in this command. ++.\"option is given, it is not necessary to list any component devices in this command. + .\"They can be added later, before a + .\".B \-\-run. + .\"If no +@@ -2263,7 +2263,7 @@ 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 ++option. In any case, space for a bitmap will be reserved so that one + can be added later with + .BR "\-\-grow \-\-bitmap=internal" . + +@@ -2313,7 +2313,7 @@ will firstly mark + as faulty in + .B /dev/md0 + and will then remove it from the array and finally add it back +-in as a spare. However only one md array can be affected by a single ++in as a spare. However, only one md array can be affected by a single + command. + + When a device is added to an active array, mdadm checks to see if it +@@ -2458,14 +2458,14 @@ config file to be examined. + If the device contains RAID metadata, a file will be created in the + .I directory + and the metadata will be written to it. The file will be the same +-size as the device and have the metadata written in the file at the +-same locate that it exists in the device. However the file will be "sparse" so ++size as the device and will have the metadata written at the ++same location as it exists in the device. However, the file will be "sparse" so + that only those blocks containing metadata will be allocated. The + total space used will be small. + +-The file name used in the ++The filename used in the + .I directory +-will be the base name of the device. Further if any links appear in ++will be the base name of the device. Further, if any links appear in + .I /dev/disk/by-id + which point to the device, then hard links to the file will be created + in +@@ -2567,7 +2567,7 @@ and if the destination array has a failed drive but no spares. + + If any devices are listed on the command line, + .I mdadm +-will only monitor those devices. Otherwise all arrays listed in the ++will only monitor those devices, otherwise, all arrays listed in the + configuration file will be monitored. Further, if + .B \-\-scan + is given, then any other md devices that appear in +@@ -2624,10 +2624,10 @@ check, repair). (syslog priority: Warning) + .BI Rebuild NN + Where + .I NN +-is a two-digit number (ie. 05, 48). This indicates that rebuild +-has passed that many percent of the total. The events are generated +-with fixed increment since 0. Increment size may be specified with +-a commandline option (default is 20). (syslog priority: Warning) ++is a two-digit number (eg. 05, 48). This indicates that the rebuild ++has reached that percentage of the total. The events are generated ++at a fixed increment from 0. The increment size may be specified with ++a command-line option (the default is 20). (syslog priority: Warning) + + .TP + .B RebuildFinished +@@ -2735,8 +2735,8 @@ When + detects that an array in a spare group has fewer active + devices than necessary for the complete array, and has no spare + devices, it will look for another array in the same spare group that +-has a full complement of working drive and a spare. It will then +-attempt to remove the spare from the second drive and add it to the ++has a full complement of working drives and a spare. It will then ++attempt to remove the spare from the second array and add it to the + first. + If the removal succeeds but the adding fails, then it is added back to + the original array. +@@ -2750,10 +2750,8 @@ and then follow similar steps as above if a matching spare is found. + .SH GROW MODE + The GROW mode is used for changing the size or shape of an active + array. +-For this to work, the kernel must support the necessary change. +-Various types of growth are being added during 2.6 development. + +-Currently the supported changes include ++During the kernel 2.6 era the following changes were added: + .IP \(bu 4 + change the "size" attribute for RAID1, RAID4, RAID5 and RAID6. + .IP \(bu 4 +@@ -2796,8 +2794,8 @@ use more than half of a spare device for backup space. + + .SS SIZE CHANGES + Normally when an array is built the "size" is taken from the smallest +-of the drives. If all the small drives in an arrays are, one at a +-time, removed and replaced with larger drives, then you could have an ++of the drives. If all the small drives in an arrays are, over time, ++removed and replaced with larger drives, then you could have an + array of large drives with only a small amount used. In this + situation, changing the "size" with "GROW" mode will allow the extra + space to start being used. If the size is increased in this way, a +@@ -2812,7 +2810,7 @@ after growing, or to reduce its size + .B prior + to shrinking the array. + +-Also the size of an array cannot be changed while it has an active ++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. + +@@ -2892,7 +2890,7 @@ long time. A + is required. If the array is not simultaneously being grown or + shrunk, so that the array size will remain the same - for example, + reshaping a 3-drive RAID5 into a 4-drive RAID6 - the backup file will +-be used not just for a "cricital section" but throughout the reshape ++be used not just for a "critical section" but throughout the reshape + operation, as described below under LAYOUT CHANGES. + + .SS CHUNK-SIZE AND LAYOUT CHANGES +@@ -2910,7 +2908,7 @@ slowly. + If the reshape is interrupted for any reason, this backup file must be + made available to + .B "mdadm --assemble" +-so the array can be reassembled. Consequently the file cannot be ++so the array can be reassembled. Consequently, the file cannot be + stored on the device being reshaped. + + +-- +2.35.3 + diff --git a/0045-Manage-Block-unsafe-member-failing.patch b/0045-Manage-Block-unsafe-member-failing.patch new file mode 100644 index 0000000..a16927a --- /dev/null +++ b/0045-Manage-Block-unsafe-member-failing.patch @@ -0,0 +1,94 @@ +From fc6fd4063769f4194c3fb8f77b32b2819e140fb9 Mon Sep 17 00:00:00 2001 +From: Mateusz Kusiak +Date: Thu, 18 Aug 2022 11:47:21 +0200 +Subject: [PATCH 55/61] Manage: Block unsafe member failing +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Kernel may or may not block mdadm from removing member device if it +will cause arrays failed state. It depends on raid personality +implementation in kernel. +Add verification on requested removal path (#mdadm --set-faulty +command). + +Signed-off-by: Mateusz Kusiak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Manage.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 52 insertions(+), 1 deletion(-) + +diff --git a/Manage.c b/Manage.c +index a142f8b..b1d0e63 100644 +--- a/Manage.c ++++ b/Manage.c +@@ -1285,6 +1285,50 @@ int Manage_with(struct supertype *tst, int fd, struct mddev_dev *dv, + return -1; + } + ++/** ++ * is_remove_safe() - Check if remove is safe. ++ * @array: Array info. ++ * @fd: Array file descriptor. ++ * @devname: Name of device to remove. ++ * @verbose: Verbose. ++ * ++ * The function determines if array will be operational ++ * after removing &devname. ++ * ++ * Return: True if array will be operational, false otherwise. ++ */ ++bool is_remove_safe(mdu_array_info_t *array, const int fd, char *devname, const int verbose) ++{ ++ dev_t devid = devnm2devid(devname + 5); ++ struct mdinfo *mdi = sysfs_read(fd, NULL, GET_DEVS | GET_DISKS | GET_STATE); ++ ++ if (!mdi) { ++ if (verbose) ++ pr_err("Failed to read sysfs attributes for %s\n", devname); ++ return false; ++ } ++ ++ char *avail = xcalloc(array->raid_disks, sizeof(char)); ++ ++ for (mdi = mdi->devs; mdi; mdi = mdi->next) { ++ if (mdi->disk.raid_disk < 0) ++ continue; ++ if (!(mdi->disk.state & (1 << MD_DISK_SYNC))) ++ continue; ++ if (makedev(mdi->disk.major, mdi->disk.minor) == devid) ++ continue; ++ avail[mdi->disk.raid_disk] = 1; ++ } ++ sysfs_free(mdi); ++ ++ bool is_enough = enough(array->level, array->raid_disks, ++ array->layout, (array->state & 1), ++ avail); ++ ++ free(avail); ++ return is_enough; ++} ++ + int Manage_subdevs(char *devname, int fd, + struct mddev_dev *devlist, int verbose, int test, + char *update, int force) +@@ -1598,7 +1642,14 @@ int Manage_subdevs(char *devname, int fd, + break; + + case 'f': /* set faulty */ +- /* FIXME check current member */ ++ 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); ++ goto abort; ++ } ++ + if ((sysfd >= 0 && write(sysfd, "faulty", 6) != 6) || + (sysfd < 0 && ioctl(fd, SET_DISK_FAULTY, + rdev))) { +-- +2.35.3 + diff --git a/0045-imsm-allow-to-specify-second-volume-size.patch b/0045-imsm-allow-to-specify-second-volume-size.patch deleted file mode 100644 index c669252..0000000 --- a/0045-imsm-allow-to-specify-second-volume-size.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 1a1ced1e2e64a6b4b349a3fb559f6b39e4cf7103 Mon Sep 17 00:00:00 2001 -From: Krzysztof Smolinski -Date: Fri, 8 Nov 2019 11:59:11 +0100 -Subject: [PATCH] imsm: allow to specify second volume size -Git-commit: 1a1ced1e2e64a6b4b349a3fb559f6b39e4cf7103 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Removed checks which limited second volume size only to max value (the -largest size that fits on all current drives). It is now permitted -to create second volume with size lower then maximum possible. - -Signed-off-by: Krzysztof Smolinski -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 14 ++++---------- - 1 file changed, 4 insertions(+), 10 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index e02bbd7..713058c 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7298,11 +7298,8 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, - - maxsize = merge_extents(super, i); - -- if (!check_env("IMSM_NO_PLATFORM") && -- mpb->num_raid_devs > 0 && size && size != maxsize) { -- pr_err("attempting to create a second volume with size less then remaining space. Aborting...\n"); -- return 0; -- } -+ if (mpb->num_raid_devs > 0 && size && size != maxsize) -+ pr_err("attempting to create a second volume with size less then remaining space.\n"); - - if (maxsize < size || maxsize == 0) { - if (verbose) { -@@ -7393,11 +7390,8 @@ static int imsm_get_free_size(struct supertype *st, int raiddisks, - } - maxsize = size; - } -- if (!check_env("IMSM_NO_PLATFORM") && -- mpb->num_raid_devs > 0 && size && size != maxsize) { -- pr_err("attempting to create a second volume with size less then remaining space. Aborting...\n"); -- return 0; -- } -+ if (mpb->num_raid_devs > 0 && size && size != maxsize) -+ pr_err("attempting to create a second volume with size less then remaining space.\n"); - cnt = 0; - for (dl = super->disks; dl; dl = dl->next) - if (dl->e) --- -2.25.0 - diff --git a/0046-Monitor-Fix-statelist-memory-leaks.patch b/0046-Monitor-Fix-statelist-memory-leaks.patch new file mode 100644 index 0000000..a5e5d52 --- /dev/null +++ b/0046-Monitor-Fix-statelist-memory-leaks.patch @@ -0,0 +1,115 @@ +From 55c10e4de13abe3e6934895e1fff7d2d20d0b2c2 Mon Sep 17 00:00:00 2001 +From: Pawel Baldysiak +Date: Thu, 1 Sep 2022 11:20:31 +0200 +Subject: [PATCH 56/61] Monitor: Fix statelist memory leaks +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Free statelist in error path in Monitor initialization. + +Signed-off-by: Pawel Baldysiak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Monitor.c | 40 +++++++++++++++++++++++++++++++--------- + 1 file changed, 31 insertions(+), 9 deletions(-) + +diff --git a/Monitor.c b/Monitor.c +index 93f36ac..b4e954c 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -74,6 +74,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist, + int test, struct alert_info *info); + static void try_spare_migration(struct state *statelist, struct alert_info *info); + static void link_containers_with_subarrays(struct state *list); ++static void free_statelist(struct state *statelist); + #ifndef NO_LIBUDEV + static int check_udev_activity(void); + #endif +@@ -128,7 +129,6 @@ int Monitor(struct mddev_dev *devlist, + */ + + struct state *statelist = NULL; +- struct state *st2; + int finished = 0; + struct mdstat_ent *mdstat = NULL; + char *mailfrom; +@@ -185,12 +185,14 @@ int Monitor(struct mddev_dev *devlist, + continue; + if (strcasecmp(mdlist->devname, "") == 0) + continue; ++ if (!is_mddev(mdlist->devname)) { ++ free_statelist(statelist); ++ return 1; ++ } + + st = xcalloc(1, sizeof *st); + snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"), + "/dev/md/%s", basename(mdlist->devname)); +- if (!is_mddev(mdlist->devname)) +- return 1; + st->next = statelist; + st->devnm[0] = 0; + st->percent = RESYNC_UNKNOWN; +@@ -206,8 +208,10 @@ int Monitor(struct mddev_dev *devlist, + for (dv = devlist; dv; dv = dv->next) { + struct state *st; + +- if (!is_mddev(dv->devname)) ++ if (!is_mddev(dv->devname)) { ++ free_statelist(statelist); + return 1; ++ } + + st = xcalloc(1, sizeof *st); + mdlist = conf_get_ident(dv->devname); +@@ -294,16 +298,16 @@ int Monitor(struct mddev_dev *devlist, + for (stp = &statelist; (st = *stp) != NULL; ) { + if (st->from_auto && st->err > 5) { + *stp = st->next; +- free(st->spare_group); ++ if (st->spare_group) ++ free(st->spare_group); ++ + free(st); + } else + stp = &st->next; + } + } +- for (st2 = statelist; st2; st2 = statelist) { +- statelist = st2->next; +- free(st2); +- } ++ ++ free_statelist(statelist); + + if (pidfile) + unlink(pidfile); +@@ -1056,6 +1060,24 @@ static void link_containers_with_subarrays(struct state *list) + } + } + ++/** ++ * free_statelist() - Frees statelist. ++ * @statelist: statelist to free ++ */ ++static void free_statelist(struct state *statelist) ++{ ++ struct state *tmp = NULL; ++ ++ while (statelist) { ++ if (statelist->spare_group) ++ free(statelist->spare_group); ++ ++ tmp = statelist; ++ statelist = statelist->next; ++ free(tmp); ++ } ++} ++ + #ifndef NO_LIBUDEV + /* function: check_udev_activity + * Description: Function waits for udev to finish +-- +2.35.3 + diff --git a/0046-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch b/0046-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch deleted file mode 100644 index 8db7bb3..0000000 --- a/0046-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 6636788aaf4ec0cacaefb6e77592e4a68e70a957 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Fri, 18 Oct 2019 11:10:34 +1100 -Subject: [PATCH] mdcheck: when mdcheck_start is enabled, enable - mdcheck_continue too. -Git-commit: 6636788aaf4ec0cacaefb6e77592e4a68e70a957 -Patch-mainline: mdadm-4.1+ -References: bsc#1153258 - -mdcheck_continue continues a regular array scan that was started by -mdcheck_start. -mdcheck_start will ensure that mdcheck_continue is active. -Howver if you reboot after a check has started, but before it finishes, -then mdcheck_continue won't cause it to continue, because nothing -starts it on boot. - -So add an install option for mdcheck_contine, and make sure it -gets enabled when mdcheck_start is enabled. - -Signed-off-by: NeilBrown ---- - systemd/mdcheck_continue.timer | 2 ++ - systemd/mdcheck_start.timer | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/systemd/mdcheck_continue.timer b/systemd/mdcheck_continue.timer -index 3ccfd7858a3f..dba1074c1f44 100644 ---- a/systemd/mdcheck_continue.timer -+++ b/systemd/mdcheck_continue.timer -@@ -11,3 +11,5 @@ Description=MD array scrubbing - continuation - [Timer] - OnCalendar= 1:05:00 - -+[Install] -+WantedBy= mdmonitor.service -diff --git a/systemd/mdcheck_start.timer b/systemd/mdcheck_start.timer -index 64807362d649..9e7e02ab7333 100644 ---- a/systemd/mdcheck_start.timer -+++ b/systemd/mdcheck_start.timer -@@ -13,3 +13,4 @@ OnCalendar=Sun *-*-1..7 1:00:00 - - [Install] - WantedBy= mdmonitor.service -+Also= mdcheck_continue.timer --- -2.23.0 - diff --git a/0047-mdadm-added-support-for-Intel-Alderlake-RST-on-VMD-p.patch b/0047-mdadm-added-support-for-Intel-Alderlake-RST-on-VMD-p.patch new file mode 100644 index 0000000..5af8585 --- /dev/null +++ b/0047-mdadm-added-support-for-Intel-Alderlake-RST-on-VMD-p.patch @@ -0,0 +1,64 @@ +From ea7a02a3294aae223e1329aed5da7f4aa3ac05c5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= +Date: Wed, 31 Aug 2022 19:57:29 +0200 +Subject: [PATCH 57/61] mdadm: added support for Intel Alderlake RST on VMD + platform +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Alderlake RST on VMD uses RstVmdV UEFI variable name, so detect it. + +Signed-off-by: Oldřich Jedlička +Reviewed-by: Kinga Tanska +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + platform-intel.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/platform-intel.c b/platform-intel.c +index 5a8729e..757f0b1 100644 +--- a/platform-intel.c ++++ b/platform-intel.c +@@ -512,7 +512,8 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) + #define AHCI_PROP "RstSataV" + #define AHCI_SSATA_PROP "RstsSatV" + #define AHCI_TSATA_PROP "RsttSatV" +-#define VMD_PROP "RstUefiV" ++#define VROC_VMD_PROP "RstUefiV" ++#define RST_VMD_PROP "RstVmdV" + + #define VENDOR_GUID \ + EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6) +@@ -605,6 +606,7 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) + 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")) +@@ -636,10 +638,16 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) + + break; + case SYS_DEV_VMD: +- if (!read_efi_variable(&orom, sizeof(orom), VMD_PROP, +- VENDOR_GUID)) +- break; +- return NULL; ++ 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)) ++ return NULL; ++ ++ break; + default: + return NULL; + } +-- +2.35.3 + diff --git a/0048-mdadm-Add-Documentation-entries-to-systemd-services.patch b/0048-mdadm-Add-Documentation-entries-to-systemd-services.patch new file mode 100644 index 0000000..dac59b6 --- /dev/null +++ b/0048-mdadm-Add-Documentation-entries-to-systemd-services.patch @@ -0,0 +1,113 @@ +From ea109700563d93704ebdc540c7770d874369f667 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Fri, 9 Sep 2022 15:50:33 +0200 +Subject: [PATCH 58/61] mdadm: Add Documentation entries to systemd services +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Add documentation section. +Copied from Debian. + +Cc: Felix Lechner +Signed-off-by: Mariusz Tkaczyk +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + systemd/mdadm-grow-continue@.service | 1 + + systemd/mdadm-last-resort@.service | 1 + + systemd/mdcheck_continue.service | 3 ++- + systemd/mdcheck_start.service | 1 + + systemd/mdmon@.service | 1 + + systemd/mdmonitor-oneshot.service | 1 + + systemd/mdmonitor.service | 1 + + 7 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/systemd/mdadm-grow-continue@.service b/systemd/mdadm-grow-continue@.service +index 9fdc8ec..64b8254 100644 +--- a/systemd/mdadm-grow-continue@.service ++++ b/systemd/mdadm-grow-continue@.service +@@ -8,6 +8,7 @@ + [Unit] + Description=Manage MD Reshape on /dev/%I + DefaultDependencies=no ++Documentation=man:mdadm(8) + + [Service] + ExecStart=BINDIR/mdadm --grow --continue /dev/%I +diff --git a/systemd/mdadm-last-resort@.service b/systemd/mdadm-last-resort@.service +index efeb3f6..e938112 100644 +--- a/systemd/mdadm-last-resort@.service ++++ b/systemd/mdadm-last-resort@.service +@@ -2,6 +2,7 @@ + Description=Activate md array %I even though degraded + DefaultDependencies=no + ConditionPathExists=!/sys/devices/virtual/block/%i/md/sync_action ++Documentation=man:mdadm(8) + + [Service] + Type=oneshot +diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service +index 854317f..f532490 100644 +--- a/systemd/mdcheck_continue.service ++++ b/systemd/mdcheck_continue.service +@@ -7,7 +7,8 @@ + + [Unit] + Description=MD array scrubbing - continuation +-ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_* ++ConditionPathExistsGlob=/var/lib/mdcheck/MD_UUID_* ++Documentation=man:mdadm(8) + + [Service] + Type=oneshot +diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service +index 3bb3d13..703a658 100644 +--- a/systemd/mdcheck_start.service ++++ b/systemd/mdcheck_start.service +@@ -8,6 +8,7 @@ + [Unit] + Description=MD array scrubbing + Wants=mdcheck_continue.timer ++Documentation=man:mdadm(8) + + [Service] + Type=oneshot +diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service +index 7753395..97a1acd 100644 +--- a/systemd/mdmon@.service ++++ b/systemd/mdmon@.service +@@ -9,6 +9,7 @@ + Description=MD Metadata Monitor on /dev/%I + DefaultDependencies=no + Before=initrd-switch-root.target ++Documentation=man:mdmon(8) + + [Service] + # mdmon should never complain due to lack of a platform, +diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service +index 373955a..ba86b44 100644 +--- a/systemd/mdmonitor-oneshot.service ++++ b/systemd/mdmonitor-oneshot.service +@@ -7,6 +7,7 @@ + + [Unit] + Description=Reminder for degraded MD arrays ++Documentation=man:mdadm(8) + + [Service] + Environment=MDADM_MONITOR_ARGS=--scan +diff --git a/systemd/mdmonitor.service b/systemd/mdmonitor.service +index 46f7b88..9c36478 100644 +--- a/systemd/mdmonitor.service ++++ b/systemd/mdmonitor.service +@@ -8,6 +8,7 @@ + [Unit] + Description=MD array monitor + DefaultDependencies=no ++Documentation=man:mdadm(8) + + [Service] + Environment= MDADM_MONITOR_ARGS=--scan +-- +2.35.3 + diff --git a/0049-ReadMe-fix-command-line-help.patch b/0049-ReadMe-fix-command-line-help.patch new file mode 100644 index 0000000..46b628b --- /dev/null +++ b/0049-ReadMe-fix-command-line-help.patch @@ -0,0 +1,34 @@ +From f7cbd810b639eb946ba1b3bddb1faefb9696de42 Mon Sep 17 00:00:00 2001 +From: Mariusz Tkaczyk +Date: Fri, 9 Sep 2022 15:50:34 +0200 +Subject: [PATCH 59/61] ReadMe: fix command-line help +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Make command-line help consistent with manual page. +Copied from Debian. + +Cc: Felix Lechner +Signed-off-by: Mariusz Tkaczyk +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + ReadMe.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ReadMe.c b/ReadMe.c +index 7f94847..50a5e36 100644 +--- a/ReadMe.c ++++ b/ReadMe.c +@@ -477,7 +477,7 @@ char Help_assemble[] = + ; + + char Help_manage[] = +-"Usage: mdadm arraydevice options component devices...\n" ++"Usage: mdadm [mode] arraydevice [options] \n" + "\n" + "This usage is for managing the component devices within an array.\n" + "The --manage option is not needed and is assumed if the first argument\n" +-- +2.35.3 + diff --git a/0050-mdadm-replace-container-level-checking-with-inline.patch b/0050-mdadm-replace-container-level-checking-with-inline.patch new file mode 100644 index 0000000..978691a --- /dev/null +++ b/0050-mdadm-replace-container-level-checking-with-inline.patch @@ -0,0 +1,259 @@ +From 6f2af6a48c541f207cb727a31fb86de2cd04fc21 Mon Sep 17 00:00:00 2001 +From: Kinga Tanska +Date: Fri, 2 Sep 2022 08:49:23 +0200 +Subject: [PATCH 60/61] mdadm: replace container level checking with inline +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +To unify all containers checks in code, is_container() function is +added and propagated. + +Signed-off-by: Kinga Tanska +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + Assemble.c | 7 +++---- + Create.c | 6 +++--- + Grow.c | 6 +++--- + Incremental.c | 4 ++-- + mdadm.h | 14 ++++++++++++++ + super-ddf.c | 6 +++--- + super-intel.c | 4 ++-- + super0.c | 2 +- + super1.c | 2 +- + sysfs.c | 2 +- + 10 files changed, 33 insertions(+), 20 deletions(-) + +diff --git a/Assemble.c b/Assemble.c +index 1dd82a8..8b0af0c 100644 +--- a/Assemble.c ++++ b/Assemble.c +@@ -1120,7 +1120,7 @@ static int start_array(int mdfd, + i/2, mddev); + } + +- if (content->array.level == LEVEL_CONTAINER) { ++ if (is_container(content->array.level)) { + sysfs_rules_apply(mddev, content); + if (c->verbose >= 0) { + pr_err("Container %s has been assembled with %d drive%s", +@@ -1549,8 +1549,7 @@ try_again: + */ + trustworthy = LOCAL; + +- if (name[0] == 0 && +- content->array.level == LEVEL_CONTAINER) { ++ if (!name[0] && is_container(content->array.level)) { + name = content->text_version; + trustworthy = METADATA; + } +@@ -1809,7 +1808,7 @@ try_again: + } + #endif + } +- if (c->force && !clean && content->array.level != LEVEL_CONTAINER && ++ if (c->force && !clean && !is_container(content->array.level) && + !enough(content->array.level, content->array.raid_disks, + content->array.layout, clean, avail)) { + change += st->ss->update_super(st, content, "force-array", +diff --git a/Create.c b/Create.c +index e06ec2a..953e737 100644 +--- a/Create.c ++++ b/Create.c +@@ -487,7 +487,7 @@ int Create(struct supertype *st, char *mddev, + st->minor_version >= 1) + /* metadata at front */ + warn |= check_partitions(fd, dname, 0, 0); +- else if (s->level == 1 || s->level == LEVEL_CONTAINER || ++ else if (s->level == 1 || is_container(s->level) || + (s->level == 0 && s->raiddisks == 1)) + /* partitions could be meaningful */ + warn |= check_partitions(fd, dname, freesize*2, s->size*2); +@@ -997,7 +997,7 @@ int Create(struct supertype *st, char *mddev, + * again returns container info. + */ + st->ss->getinfo_super(st, &info_new, NULL); +- if (st->ss->external && s->level != LEVEL_CONTAINER && ++ if (st->ss->external && !is_container(s->level) && + !same_uuid(info_new.uuid, info.uuid, 0)) { + map_update(&map, fd2devnm(mdfd), + info_new.text_version, +@@ -1040,7 +1040,7 @@ int Create(struct supertype *st, char *mddev, + map_unlock(&map); + free(infos); + +- if (s->level == LEVEL_CONTAINER) { ++ if (is_container(s->level)) { + /* No need to start. But we should signal udev to + * create links */ + sysfs_uevent(&info, "change"); +diff --git a/Grow.c b/Grow.c +index 0f07a89..e362403 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -2175,7 +2175,7 @@ size_change_error: + devname, s->size); + } + changed = 1; +- } else if (array.level != LEVEL_CONTAINER) { ++ } else if (!is_container(array.level)) { + s->size = get_component_size(fd)/2; + if (s->size == 0) + s->size = array.size; +@@ -2231,7 +2231,7 @@ size_change_error: + info.component_size = s->size*2; + info.new_level = s->level; + info.new_chunk = s->chunk * 1024; +- if (info.array.level == LEVEL_CONTAINER) { ++ if (is_container(info.array.level)) { + info.delta_disks = UnSet; + info.array.raid_disks = s->raiddisks; + } else if (s->raiddisks) +@@ -2344,7 +2344,7 @@ size_change_error: + printf("layout for %s set to %d\n", + devname, array.layout); + } +- } else if (array.level == LEVEL_CONTAINER) { ++ } else if (is_container(array.level)) { + /* This change is to be applied to every array in the + * container. This is only needed when the metadata imposes + * restraints of the various arrays in the container. +diff --git a/Incremental.c b/Incremental.c +index 4d0cd9d..5a5f4c4 100644 +--- a/Incremental.c ++++ b/Incremental.c +@@ -244,7 +244,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, + c->autof = ci->autof; + + name_to_use = info.name; +- if (name_to_use[0] == 0 && info.array.level == LEVEL_CONTAINER) { ++ if (name_to_use[0] == 0 && is_container(info.array.level)) { + name_to_use = info.text_version; + trustworthy = METADATA; + } +@@ -472,7 +472,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c, + + /* 7/ Is there enough devices to possibly start the array? */ + /* 7a/ if not, finish with success. */ +- if (info.array.level == LEVEL_CONTAINER) { ++ if (is_container(info.array.level)) { + char devnm[32]; + /* Try to assemble within the container */ + sysfs_uevent(sra, "change"); +diff --git a/mdadm.h b/mdadm.h +index 941a5f3..3673494 100644 +--- a/mdadm.h ++++ b/mdadm.h +@@ -1924,3 +1924,17 @@ enum r0layout { + * This is true for native and DDF, IMSM allows 16. + */ + #define MD_NAME_MAX 32 ++ ++/** ++ * is_container() - check if @level is &LEVEL_CONTAINER ++ * @level: level value ++ * ++ * return: ++ * 1 if level is equal to &LEVEL_CONTAINER, 0 otherwise. ++ */ ++static inline int is_container(const int level) ++{ ++ if (level == LEVEL_CONTAINER) ++ return 1; ++ return 0; ++} +diff --git a/super-ddf.c b/super-ddf.c +index 949e7d1..9d1e3b9 100644 +--- a/super-ddf.c ++++ b/super-ddf.c +@@ -3325,7 +3325,7 @@ validate_geometry_ddf_container(struct supertype *st, + int fd; + unsigned long long ldsize; + +- if (level != LEVEL_CONTAINER) ++ if (!is_container(level)) + return 0; + if (!dev) + return 1; +@@ -3371,7 +3371,7 @@ static int validate_geometry_ddf(struct supertype *st, + + if (level == LEVEL_NONE) + level = LEVEL_CONTAINER; +- if (level == LEVEL_CONTAINER) { ++ if (is_container(level)) { + /* Must be a fresh device to add to a container */ + return validate_geometry_ddf_container(st, level, raiddisks, + data_offset, dev, +@@ -3488,7 +3488,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st, + struct dl *dl; + unsigned long long maxsize; + /* ddf/bvd supports lots of things, but not containers */ +- if (level == LEVEL_CONTAINER) { ++ if (is_container(level)) { + if (verbose) + pr_err("DDF cannot create a container within an container\n"); + return 0; +diff --git a/super-intel.c b/super-intel.c +index 4d82af3..b056561 100644 +--- a/super-intel.c ++++ b/super-intel.c +@@ -6727,7 +6727,7 @@ static int validate_geometry_imsm_container(struct supertype *st, int level, + struct intel_super *super = NULL; + int rv = 0; + +- if (level != LEVEL_CONTAINER) ++ if (!is_container(level)) + return 0; + if (!dev) + return 1; +@@ -7692,7 +7692,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, + * if given unused devices create a container + * if given given devices in a container create a member volume + */ +- if (level == LEVEL_CONTAINER) ++ if (is_container(level)) + /* Must be a fresh device to add to a container */ + return validate_geometry_imsm_container(st, level, raiddisks, + data_offset, dev, +diff --git a/super0.c b/super0.c +index 37f595e..93876e2 100644 +--- a/super0.c ++++ b/super0.c +@@ -1273,7 +1273,7 @@ static int validate_geometry0(struct supertype *st, int level, + if (get_linux_version() < 3001000) + tbmax = 2; + +- if (level == LEVEL_CONTAINER) { ++ if (is_container(level)) { + if (verbose) + pr_err("0.90 metadata does not support containers\n"); + return 0; +diff --git a/super1.c b/super1.c +index 58345e6..0b505a7 100644 +--- a/super1.c ++++ b/super1.c +@@ -2830,7 +2830,7 @@ static int validate_geometry1(struct supertype *st, int level, + unsigned long long overhead; + int fd; + +- if (level == LEVEL_CONTAINER) { ++ if (is_container(level)) { + if (verbose) + pr_err("1.x metadata does not support containers\n"); + return 0; +diff --git a/sysfs.c b/sysfs.c +index 0d98a65..ca1d888 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -763,7 +763,7 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume) + + rv = sysfs_set_num(sra, sd, "offset", sd->data_offset); + rv |= sysfs_set_num(sra, sd, "size", (sd->component_size+1) / 2); +- if (sra->array.level != LEVEL_CONTAINER) { ++ if (!is_container(sra->array.level)) { + if (sra->consistency_policy == CONSISTENCY_POLICY_PPL) { + rv |= sysfs_set_num(sra, sd, "ppl_sector", sd->ppl_sector); + rv |= sysfs_set_num(sra, sd, "ppl_size", sd->ppl_size); +-- +2.35.3 + diff --git a/0050-mdcheck-use-to-pass-variable-to-mdcheck.patch b/0050-mdcheck-use-to-pass-variable-to-mdcheck.patch deleted file mode 100644 index b182f01..0000000 --- a/0050-mdcheck-use-to-pass-variable-to-mdcheck.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 4ca799c581703d4d0ad840833c037c2fff088ca7 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Wed, 30 Oct 2019 10:32:41 +1100 -Subject: [PATCH] mdcheck: use ${} to pass variable to mdcheck -Git-commit: 4ca799c581703d4d0ad840833c037c2fff088ca7 -Patch-mainline: mdadm-4.1+ -References: bsc#1153258 - -$MDADM_CHECK_DURATION allows the value to be split on spaces. -${MDADM_CHECK_DURATION} avoids such splitting. - -Making this change removes the need for double quoting when setting -the default Environment, and means that double quoting isn't needed -in the EnvironmentFile. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - systemd/mdcheck_continue.service | 5 ++--- - systemd/mdcheck_start.service | 4 ++-- - 2 files changed, 4 insertions(+), 5 deletions(-) - -diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service -index 592c607..deac695 100644 ---- a/systemd/mdcheck_continue.service -+++ b/systemd/mdcheck_continue.service -@@ -11,8 +11,7 @@ ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_* - - [Service] - Type=oneshot --Environment= MDADM_CHECK_DURATION='"6 hours"' -+Environment= MDADM_CHECK_DURATION="6 hours" - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh --ExecStart=/usr/share/mdadm/mdcheck --continue --duration $MDADM_CHECK_DURATION -- -+ExecStart=/usr/share/mdadm/mdcheck --continue --duration ${MDADM_CHECK_DURATION} -diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service -index 812141b..f17f1aa 100644 ---- a/systemd/mdcheck_start.service -+++ b/systemd/mdcheck_start.service -@@ -11,7 +11,7 @@ Wants=mdcheck_continue.timer - - [Service] - Type=oneshot --Environment= MDADM_CHECK_DURATION='"6 hours"' -+Environment= MDADM_CHECK_DURATION="6 hours" - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh --ExecStart=/usr/share/mdadm/mdcheck --duration $MDADM_CHECK_DURATION -+ExecStart=/usr/share/mdadm/mdcheck --duration ${MDADM_CHECK_DURATION} --- -2.25.0 - diff --git a/0051-Mdmonitor-Omit-non-md-devices.patch b/0051-Mdmonitor-Omit-non-md-devices.patch new file mode 100644 index 0000000..44a1c98 --- /dev/null +++ b/0051-Mdmonitor-Omit-non-md-devices.patch @@ -0,0 +1,61 @@ +From 8b668d4aa3305af5963162b7499b128bd71f8f29 Mon Sep 17 00:00:00 2001 +From: Lukasz Florczak +Date: Thu, 22 Sep 2022 08:29:50 +0200 +Subject: [PATCH 61/61] Mdmonitor: Omit non-md devices +Patch-mainline: mdadm-4.2+ +References: jsc#PED-1009 + +Fix segfault commit [1] introduced check whether given device is +mddevice, but it happend to terminate Mdmonitor if at least one of given +devices didn't fulfill that condition. In result Mdmonitor service was +no longer started on boot (with --scan option) when config contained some +non-existent array entry. + +This commit introduces ommiting non-md devices so scan option can still +be used when config is wrong and allow Mdmonitor service to run on boot. + +Giving a list of devices to monitor containing non-existing or +non-md devices will result in monitoring only confirmed mddevices. + +[1] https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=e702f392959d1c2ad2089e595b52235ed97b4e18 + +Signed-off-by: Lukasz Florczak +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Monitor.c | 12 ++++-------- + 1 file changed, 4 insertions(+), 8 deletions(-) + +diff --git a/Monitor.c b/Monitor.c +index b4e954c..7d7dc4d 100644 +--- a/Monitor.c ++++ b/Monitor.c +@@ -185,10 +185,8 @@ int Monitor(struct mddev_dev *devlist, + continue; + if (strcasecmp(mdlist->devname, "") == 0) + continue; +- if (!is_mddev(mdlist->devname)) { +- free_statelist(statelist); +- return 1; +- } ++ if (!is_mddev(mdlist->devname)) ++ continue; + + st = xcalloc(1, sizeof *st); + snprintf(st->devname, MD_NAME_MAX + sizeof("/dev/md/"), +@@ -208,10 +206,8 @@ int Monitor(struct mddev_dev *devlist, + for (dv = devlist; dv; dv = dv->next) { + struct state *st; + +- if (!is_mddev(dv->devname)) { +- free_statelist(statelist); +- return 1; +- } ++ if (!is_mddev(dv->devname)) ++ continue; + + st = xcalloc(1, sizeof *st); + mdlist = conf_get_ident(dv->devname); +-- +2.35.3 + diff --git a/0051-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch b/0051-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch deleted file mode 100644 index 779a384..0000000 --- a/0051-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 85b83a7920bca5b93d2458f093f2c640a130614c Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Wed, 30 Oct 2019 10:32:41 +1100 -Subject: [PATCH] SUSE-mdadm_env.sh: handle MDADM_CHECK_DURATION -Git-commit: 85b83a7920bca5b93d2458f093f2c640a130614c -Patch-mainline: mdadm-4.1+ -References: bsc#1153258 - -The suse sysconfig/mdadm allows MDADM_CHECK_DURATION -to be set, but it is currently ignored. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - systemd/SUSE-mdadm_env.sh | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/systemd/SUSE-mdadm_env.sh b/systemd/SUSE-mdadm_env.sh -index 10b2e74..c13b48a 100644 ---- a/systemd/SUSE-mdadm_env.sh -+++ b/systemd/SUSE-mdadm_env.sh -@@ -43,3 +43,6 @@ 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 --- -2.25.0 - diff --git a/0052-super-intel-don-t-mark-structs-packed-unnecessarily.patch b/0052-super-intel-don-t-mark-structs-packed-unnecessarily.patch deleted file mode 100644 index cd4e2fd..0000000 --- a/0052-super-intel-don-t-mark-structs-packed-unnecessarily.patch +++ /dev/null @@ -1,126 +0,0 @@ -From 761e3bd9f5e3aafa95ad3ae50a637dc67c8774f0 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 31 Oct 2019 15:15:38 +1100 -Subject: [PATCH] super-intel: don't mark structs 'packed' unnecessarily -Git-commit: 761e3bd9f5e3aafa95ad3ae50a637dc67c8774f0 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -super-intel marks a number of structures 'packed', but this -doesn't change the layout - they are already well organized. - -This is a problem a gcc warns when code takes the address -of a field in a packet struct - as super-intel sometimes does. - -So remove the marking where isn't needed. -Do ensure this does introduce a regression, add a compile-time -assertion that the size of the structure is exactly the value -it had before the 'packed' notation was removed. - -Note that a couple of structure do need to be packed. -As the address of fields is never taken, that is safe. - -Signed-off-by: NeilBrown -Acked-by: Artur Paszkiewicz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 32 ++++++++++++++++++++++++++------ - 1 file changed, 26 insertions(+), 6 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 713058c..a7fbed4 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -96,6 +96,19 @@ - * mutliple PPL area - */ - -+/* -+ * This macro let's us ensure that no-one accidentally -+ * changes the size of a struct -+ */ -+#define ASSERT_SIZE(_struct, size) \ -+static inline void __assert_size_##_struct(void) \ -+{ \ -+ switch (0) { \ -+ case 0: break; \ -+ case (sizeof(struct _struct) == size): break; \ -+ } \ -+} -+ - /* Disk configuration info. */ - #define IMSM_MAX_DEVICES 255 - struct imsm_disk { -@@ -112,6 +125,7 @@ struct imsm_disk { - #define IMSM_DISK_FILLERS 3 - __u32 filler[IMSM_DISK_FILLERS]; /* 0xF5 - 0x107 MPB_DISK_FILLERS for future expansion */ - }; -+ASSERT_SIZE(imsm_disk, 48) - - /* map selector for map managment - */ -@@ -146,7 +160,8 @@ struct imsm_map { - __u32 disk_ord_tbl[1]; /* disk_ord_tbl[num_members], - * top byte contains some flags - */ --} __attribute__ ((packed)); -+}; -+ASSERT_SIZE(imsm_map, 52) - - struct imsm_vol { - __u32 curr_migr_unit; -@@ -169,7 +184,8 @@ struct imsm_vol { - __u32 filler[4]; - struct imsm_map map[1]; - /* here comes another one if migr_state */ --} __attribute__ ((packed)); -+}; -+ASSERT_SIZE(imsm_vol, 84) - - struct imsm_dev { - __u8 volume[MAX_RAID_SERIAL_LEN]; -@@ -220,7 +236,8 @@ struct imsm_dev { - #define IMSM_DEV_FILLERS 3 - __u32 filler[IMSM_DEV_FILLERS]; - struct imsm_vol vol; --} __attribute__ ((packed)); -+}; -+ASSERT_SIZE(imsm_dev, 164) - - struct imsm_super { - __u8 sig[MAX_SIGNATURE_LENGTH]; /* 0x00 - 0x1F */ -@@ -248,7 +265,8 @@ struct imsm_super { - struct imsm_disk disk[1]; /* 0xD8 diskTbl[numDisks] */ - /* here comes imsm_dev[num_raid_devs] */ - /* here comes BBM logs */ --} __attribute__ ((packed)); -+}; -+ASSERT_SIZE(imsm_super, 264) - - #define BBM_LOG_MAX_ENTRIES 254 - #define BBM_LOG_MAX_LBA_ENTRY_VAL 256 /* Represents 256 LBAs */ -@@ -269,7 +287,8 @@ struct bbm_log { - __u32 signature; /* 0xABADB10C */ - __u32 entry_count; - struct bbm_log_entry marked_block_entries[BBM_LOG_MAX_ENTRIES]; --} __attribute__ ((__packed__)); -+}; -+ASSERT_SIZE(bbm_log, 2040) - - static char *map_state_str[] = { "normal", "uninitialized", "degraded", "failed" }; - -@@ -323,7 +342,8 @@ struct migr_record { - * destination - high order 32 bits */ - __u32 num_migr_units_hi; /* Total num migration units-of-op - * high order 32 bits */ --} __attribute__ ((__packed__)); -+}; -+ASSERT_SIZE(migr_record, 64) - - struct md_list { - /* usage marker: --- -2.25.0 - diff --git a/0053-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch b/0053-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch deleted file mode 100644 index 816e3d0..0000000 --- a/0053-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 1cc3965d48deb0fb3e0657159c608ffb124643c1 Mon Sep 17 00:00:00 2001 -From: Xiao Yang -Date: Wed, 27 Nov 2019 11:59:24 +0800 -Subject: [PATCH] Manage: Remove the legacy code for md driver prior to 0.90.03 -Git-commit: 1cc3965d48deb0fb3e0657159c608ffb124643c1 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Previous re-add operation only calls ioctl(HOT_ADD_DISK) for array without -metadata(e.g. mdadm -B/--build) when md driver is less than 0.90.02, but -commit 091e8e6 breaks the logic and current re-add operation can call -ioctl(HOT_ADD_DISK) even if md driver is 0.90.03. - -This issue is reproduced by 05r1-re-add-nosuper: - -Signed-off-by: Coly Li - ------------------------------------------------- -++ die 'resync or recovery is happening!' -++ echo -e '\n\tERROR: resync or recovery is happening! \n' -ERROR: resync or recovery is happening! ------------------------------------------------- - -Fixes: 091e8e6("Manage: Remove all references to md_get_version()") -Reported-by: kernel test robot -Signed-off-by: Xiao Yang -Signed-off-by: Jes Sorensen ---- - Manage.c | 12 ------------ - 1 file changed, 12 deletions(-) - -diff --git a/Manage.c b/Manage.c -index 21536f5..ffe55f8 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -741,18 +741,6 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, - " Adding anyway as --force was given.\n", - dv->devname, devname); - } -- if (!tst->ss->external && array->major_version == 0) { -- if (ioctl(fd, HOT_ADD_DISK, rdev)==0) { -- if (verbose >= 0) -- pr_err("hot added %s\n", -- dv->devname); -- return 1; -- } -- -- pr_err("hot add failed for %s: %s\n", -- dv->devname, strerror(errno)); -- return -1; -- } - - if (array->not_persistent == 0 || tst->ss->external) { - --- -2.25.0 - diff --git a/0054-Remove-last-traces-of-HOT_ADD_DISK.patch b/0054-Remove-last-traces-of-HOT_ADD_DISK.patch deleted file mode 100644 index b4169fd..0000000 --- a/0054-Remove-last-traces-of-HOT_ADD_DISK.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 02af379337c73e751ad97c0fed9123121f8b4289 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Wed, 27 Nov 2019 10:19:54 -0500 -Subject: [PATCH] Remove last traces of HOT_ADD_DISK -Git-commit: 02af379337c73e751ad97c0fed9123121f8b4289 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -This ioctl is no longer used, so remove all references to it. - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Manage.c | 2 -- - md_u.h | 1 - - 2 files changed, 3 deletions(-) - -diff --git a/Manage.c b/Manage.c -index ffe55f8..deeba2b 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -1289,8 +1289,6 @@ int Manage_subdevs(char *devname, int fd, - /* Do something to each dev. - * devmode can be - * 'a' - add the device -- * try HOT_ADD_DISK -- * If that fails EINVAL, try ADD_NEW_DISK - * 'S' - add the device as a spare - don't try re-add - * 'j' - add the device as a journal device - * 'A' - re-add the device -diff --git a/md_u.h b/md_u.h -index 2d66d52..b30893c 100644 ---- a/md_u.h -+++ b/md_u.h -@@ -28,7 +28,6 @@ - #define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t) - #define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22) - #define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t) --#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28) - #define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29) - #define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int) - --- -2.25.0 - diff --git a/0055-Fix-up-a-few-formatting-issues.patch b/0055-Fix-up-a-few-formatting-issues.patch deleted file mode 100644 index bebeaa2..0000000 --- a/0055-Fix-up-a-few-formatting-issues.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 9cf361f8791d86aaced821c19af556819bc03732 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Wed, 27 Nov 2019 11:33:15 -0500 -Subject: [PATCH] Fix up a few formatting issues -Git-commit: 9cf361f8791d86aaced821c19af556819bc03732 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Manage.c | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -diff --git a/Manage.c b/Manage.c -index deeba2b..b22c396 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -1728,8 +1728,10 @@ 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); -+ if (fd1 >= 0) -+ close(fd1); -+ if (fd2 >= 0) -+ close(fd2); - return 0; - } - -@@ -1743,7 +1745,8 @@ int move_spare(char *from_devname, char *to_devname, dev_t devid) - devlist.disposition = 'r'; - if (Manage_subdevs(from_devname, fd2, &devlist, -1, 0, NULL, 0) == 0) { - devlist.disposition = 'a'; -- if (Manage_subdevs(to_devname, fd1, &devlist, -1, 0, NULL, 0) == 0) { -+ if (Manage_subdevs(to_devname, fd1, &devlist, -1, 0, -+ NULL, 0) == 0) { - /* make sure manager is aware of changes */ - ping_manager(to_devname); - ping_manager(from_devname); -@@ -1751,7 +1754,9 @@ int move_spare(char *from_devname, char *to_devname, dev_t devid) - close(fd2); - return 1; - } -- else Manage_subdevs(from_devname, fd2, &devlist, -1, 0, NULL, 0); -+ else -+ Manage_subdevs(from_devname, fd2, &devlist, -+ -1, 0, NULL, 0); - } - close(fd1); - close(fd2); --- -2.25.0 - diff --git a/0056-Remove-unused-code.patch b/0056-Remove-unused-code.patch deleted file mode 100644 index 6439df8..0000000 --- a/0056-Remove-unused-code.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 4b31846f3f90aa24f883ceed80e91f204c0a9389 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Fri, 29 Nov 2019 17:14:47 +0800 -Subject: [PATCH] Remove unused code -Git-commit: 4b31846f3f90aa24f883ceed80e91f204c0a9389 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - platform-intel.h | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/platform-intel.h b/platform-intel.h -index 29c85f1..7cb370e 100644 ---- a/platform-intel.h -+++ b/platform-intel.h -@@ -169,7 +169,6 @@ static inline int fls(int x) - r -= 2; - } - if (!(x & 0x80000000u)) { -- x <<= 1; - r -= 1; - } - return r; --- -2.25.0 - diff --git a/0057-imsm-return-correct-uuid-for-volume-in-detail.patch b/0057-imsm-return-correct-uuid-for-volume-in-detail.patch deleted file mode 100644 index a3e3c20..0000000 --- a/0057-imsm-return-correct-uuid-for-volume-in-detail.patch +++ /dev/null @@ -1,181 +0,0 @@ -From b771faef931c798a4553db0a8c1366aff90079c6 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 29 Nov 2019 15:21:08 +0100 -Subject: [PATCH] imsm: return correct uuid for volume in detail -Git-commit: b771faef931c798a4553db0a8c1366aff90079c6 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Fixes the side effect of the patch b6180160f ("imsm: save current_vol number") -- wrong UUID is printed in detail for each volume. -New parameter "subarray" is added to determine what info should be extracted -from metadata (subarray or container). -The parameter affects only IMSM metadata. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Detail.c | 4 ++-- - mdadm.h | 5 +++-- - super-ddf.c | 5 +++-- - super-intel.c | 20 ++++++++++++++++++-- - super0.c | 4 ++-- - super1.c | 4 ++-- - 6 files changed, 30 insertions(+), 12 deletions(-) - -diff --git a/Detail.c b/Detail.c -index 3e61e37..24fa462 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -623,7 +623,7 @@ This is pretty boring - free_mdstat(ms); - - if (st && st->sb) -- st->ss->detail_super(st, c->homehost); -+ st->ss->detail_super(st, c->homehost, subarray); - - if (array.raid_disks == 0 && sra && - sra->array.major_version == -1 && -@@ -767,7 +767,7 @@ skip_devices_state: - if (spares && c->brief && array.raid_disks) - printf(" spares=%d", spares); - if (c->brief && st && st->sb) -- st->ss->brief_detail_super(st); -+ st->ss->brief_detail_super(st, subarray); - if (st) - st->ss->free_super(st); - -diff --git a/mdadm.h b/mdadm.h -index c88ceab..91f1338 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -847,8 +847,9 @@ extern struct superswitch { - /* Used to report details of an active array. - * ->load_super was possibly given a 'component' string. - */ -- void (*detail_super)(struct supertype *st, char *homehost); -- void (*brief_detail_super)(struct supertype *st); -+ void (*detail_super)(struct supertype *st, char *homehost, -+ char *subarray); -+ void (*brief_detail_super)(struct supertype *st, char *subarray); - void (*export_detail_super)(struct supertype *st); - - /* Optional: platform hardware / firmware details */ -diff --git a/super-ddf.c b/super-ddf.c -index c095e8a..7802063 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -1730,7 +1730,8 @@ err: - return 1; - } - --static void detail_super_ddf(struct supertype *st, char *homehost) -+static void detail_super_ddf(struct supertype *st, char *homehost, -+ char *subarray) - { - struct ddf_super *sb = st->sb; - int cnt = be16_to_cpu(sb->virt->populated_vdes); -@@ -1787,7 +1788,7 @@ static void uuid_of_ddf_subarray(const struct ddf_super *ddf, - memcpy(uuid, sha, 4*4); - } - --static void brief_detail_super_ddf(struct supertype *st) -+static void brief_detail_super_ddf(struct supertype *st, char *subarray) - { - struct mdinfo info; - char nbuf[64]; -diff --git a/super-intel.c b/super-intel.c -index a7fbed4..86dcb69 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2183,23 +2183,39 @@ err: - return 1; - } - --static void detail_super_imsm(struct supertype *st, char *homehost) -+static void detail_super_imsm(struct supertype *st, char *homehost, -+ char *subarray) - { - struct mdinfo info; - char nbuf[64]; -+ struct intel_super *super = st->sb; -+ int temp_vol = super->current_vol; -+ -+ if (subarray) -+ super->current_vol = strtoul(subarray, NULL, 10); - - getinfo_super_imsm(st, &info, NULL); - fname_from_uuid(st, &info, nbuf, ':'); - printf("\n UUID : %s\n", nbuf + 5); -+ -+ super->current_vol = temp_vol; - } - --static void brief_detail_super_imsm(struct supertype *st) -+static void brief_detail_super_imsm(struct supertype *st, char *subarray) - { - struct mdinfo info; - char nbuf[64]; -+ struct intel_super *super = st->sb; -+ int temp_vol = super->current_vol; -+ -+ if (subarray) -+ super->current_vol = strtoul(subarray, NULL, 10); -+ - getinfo_super_imsm(st, &info, NULL); - fname_from_uuid(st, &info, nbuf, ':'); - printf(" UUID=%s", nbuf + 5); -+ -+ super->current_vol = temp_vol; - } - - static int imsm_read_serial(int fd, char *devname, __u8 *serial); -diff --git a/super0.c b/super0.c -index 42989b9..6b7c0e3 100644 ---- a/super0.c -+++ b/super0.c -@@ -348,7 +348,7 @@ err: - return 1; - } - --static void detail_super0(struct supertype *st, char *homehost) -+static void detail_super0(struct supertype *st, char *homehost, char *subarray) - { - mdp_super_t *sb = st->sb; - printf(" UUID : "); -@@ -368,7 +368,7 @@ static void detail_super0(struct supertype *st, char *homehost) - printf("\n Events : %d.%d\n\n", sb->events_hi, sb->events_lo); - } - --static void brief_detail_super0(struct supertype *st) -+static void brief_detail_super0(struct supertype *st, char *subarray) - { - mdp_super_t *sb = st->sb; - printf(" UUID="); -diff --git a/super1.c b/super1.c -index b85dc20..929466d 100644 ---- a/super1.c -+++ b/super1.c -@@ -833,7 +833,7 @@ err: - return 1; - } - --static void detail_super1(struct supertype *st, char *homehost) -+static void detail_super1(struct supertype *st, char *homehost, char *subarray) - { - struct mdp_superblock_1 *sb = st->sb; - bitmap_super_t *bms = (bitmap_super_t*)(((char*)sb) + MAX_SB_SIZE); -@@ -857,7 +857,7 @@ static void detail_super1(struct supertype *st, char *homehost) - (unsigned long long)__le64_to_cpu(sb->events)); - } - --static void brief_detail_super1(struct supertype *st) -+static void brief_detail_super1(struct supertype *st, char *subarray) - { - struct mdp_superblock_1 *sb = st->sb; - int i; --- -2.25.0 - diff --git a/0058-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch b/0058-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch deleted file mode 100644 index 6de1a3b..0000000 --- a/0058-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch +++ /dev/null @@ -1,213 +0,0 @@ -From 6da53c0e2aab200605722795798b1e4f2352cd64 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Mon, 2 Dec 2019 10:52:05 +0100 -Subject: [PATCH] imsm: Change the way of printing nvme drives in - detail-platform. -Git-commit: 6da53c0e2aab200605722795798b1e4f2352cd64 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Change NVMe controller path to device node path -in mdadm --detail-platform and print serial number. -The method imsm_read_serial always trimes serial to -MAX_RAID_SERIAL_LEN, added parameter 'serial_buf_len' -will be used to check the serial fit -to passed buffor, if not, will be trimed. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 97 ++++++++++++++++++++++++--------------------------- - 1 file changed, 46 insertions(+), 51 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 86dcb69..5c1f759 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2218,7 +2218,8 @@ static void brief_detail_super_imsm(struct supertype *st, char *subarray) - super->current_vol = temp_vol; - } - --static int imsm_read_serial(int fd, char *devname, __u8 *serial); -+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) -@@ -2364,8 +2365,9 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b - else { - fd2devname(fd, buf); - printf(" Port%d : %s", port, buf); -- if (imsm_read_serial(fd, NULL, (__u8 *) buf) == 0) -- printf(" (%.*s)\n", MAX_RAID_SERIAL_LEN, buf); -+ if (imsm_read_serial(fd, NULL, (__u8 *)buf, -+ sizeof(buf)) == 0) -+ printf(" (%s)\n", buf); - else - printf(" ()\n"); - close(fd); -@@ -2388,52 +2390,45 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b - return err; - } - --static int print_vmd_attached_devs(struct sys_dev *hba) -+static int print_nvme_info(struct sys_dev *hba) - { -+ char buf[1024]; - struct dirent *ent; - DIR *dir; -- char path[292]; -- char link[256]; -- char *c, *rp; -- -- if (hba->type != SYS_DEV_VMD) -- return 1; -+ char *rp; -+ int fd; - -- /* scroll through /sys/dev/block looking for devices attached to -- * this hba -- */ -- dir = opendir("/sys/bus/pci/drivers/nvme"); -+ dir = opendir("/sys/block/"); - if (!dir) - return 1; - - for (ent = readdir(dir); ent; ent = readdir(dir)) { -- int n; -- -- /* is 'ent' a device? check that the 'subsystem' link exists and -- * that its target matches 'bus' -- */ -- sprintf(path, "/sys/bus/pci/drivers/nvme/%s/subsystem", -- ent->d_name); -- n = readlink(path, link, sizeof(link)); -- if (n < 0 || n >= (int)sizeof(link)) -- continue; -- link[n] = '\0'; -- c = strrchr(link, '/'); -- if (!c) -- continue; -- if (strncmp("pci", c+1, strlen("pci")) != 0) -- continue; -- -- sprintf(path, "/sys/bus/pci/drivers/nvme/%s", ent->d_name); -- -- rp = realpath(path, NULL); -- if (!rp) -- continue; -+ if (strstr(ent->d_name, "nvme")) { -+ sprintf(buf, "/sys/block/%s", ent->d_name); -+ rp = realpath(buf, NULL); -+ if (!rp) -+ continue; -+ if (path_attached_to_hba(rp, hba->path)) { -+ fd = open_dev(ent->d_name); -+ if (fd < 0) { -+ free(rp); -+ continue; -+ } - -- if (path_attached_to_hba(rp, hba->path)) { -- printf(" NVMe under VMD : %s\n", rp); -+ fd2devname(fd, buf); -+ if (hba->type == SYS_DEV_VMD) -+ printf(" NVMe under VMD : %s", buf); -+ else if (hba->type == SYS_DEV_NVME) -+ printf(" NVMe Device : %s", buf); -+ if (!imsm_read_serial(fd, NULL, (__u8 *)buf, -+ sizeof(buf))) -+ printf(" (%s)\n", buf); -+ else -+ printf("()\n"); -+ close(fd); -+ } -+ free(rp); - } -- free(rp); - } - - closedir(dir); -@@ -2648,7 +2643,7 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle - char buf[PATH_MAX]; - printf(" I/O Controller : %s (%s)\n", - vmd_domain_to_controller(hba, buf), get_sys_dev_type(hba->type)); -- if (print_vmd_attached_devs(hba)) { -+ if (print_nvme_info(hba)) { - if (verbose > 0) - pr_err("failed to get devices attached to VMD domain.\n"); - result |= 2; -@@ -2663,7 +2658,7 @@ static int detail_platform_imsm(int verbose, int enumerate_only, char *controlle - if (entry->type == SYS_DEV_NVME) { - for (hba = list; hba; hba = hba->next) { - if (hba->type == SYS_DEV_NVME) -- printf(" NVMe Device : %s\n", hba->path); -+ print_nvme_info(hba); - } - printf("\n"); - continue; -@@ -4028,11 +4023,11 @@ static int nvme_get_serial(int fd, void *buf, size_t buf_len) - extern int scsi_get_serial(int fd, void *buf, size_t buf_len); - - static int imsm_read_serial(int fd, char *devname, -- __u8 serial[MAX_RAID_SERIAL_LEN]) -+ __u8 *serial, size_t serial_buf_len) - { - char buf[50]; - int rv; -- int len; -+ size_t len; - char *dest; - char *src; - unsigned int i; -@@ -4075,13 +4070,13 @@ static int imsm_read_serial(int fd, char *devname, - len = dest - buf; - dest = buf; - -- /* truncate leading characters */ -- if (len > MAX_RAID_SERIAL_LEN) { -- dest += len - MAX_RAID_SERIAL_LEN; -- len = MAX_RAID_SERIAL_LEN; -+ if (len > serial_buf_len) { -+ /* truncate leading characters */ -+ dest += len - serial_buf_len; -+ len = serial_buf_len; - } - -- memset(serial, 0, MAX_RAID_SERIAL_LEN); -+ memset(serial, 0, serial_buf_len); - memcpy(serial, dest, len); - - return 0; -@@ -4136,7 +4131,7 @@ load_imsm_disk(int fd, struct intel_super *super, char *devname, int keep_fd) - char name[40]; - __u8 serial[MAX_RAID_SERIAL_LEN]; - -- rv = imsm_read_serial(fd, devname, serial); -+ rv = imsm_read_serial(fd, devname, serial, MAX_RAID_SERIAL_LEN); - - if (rv != 0) - return 2; -@@ -5844,7 +5839,7 @@ int mark_spare(struct dl *disk) - return ret_val; - - ret_val = 0; -- if (!imsm_read_serial(disk->fd, NULL, serial)) { -+ if (!imsm_read_serial(disk->fd, NULL, serial, MAX_RAID_SERIAL_LEN)) { - /* Restore disk serial number, because takeover marks disk - * as failed and adds to serial ':0' before it becomes - * a spare disk. -@@ -5895,7 +5890,7 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - dd->fd = fd; - dd->e = NULL; - dd->action = DISK_ADD; -- rv = imsm_read_serial(fd, devname, dd->serial); -+ rv = imsm_read_serial(fd, devname, dd->serial, MAX_RAID_SERIAL_LEN); - if (rv) { - pr_err("failed to retrieve scsi serial, aborting\n"); - if (dd->devname) --- -2.25.0 - diff --git a/0059-Create-add-support-for-RAID0-layouts.patch b/0059-Create-add-support-for-RAID0-layouts.patch deleted file mode 100644 index b488712..0000000 --- a/0059-Create-add-support-for-RAID0-layouts.patch +++ /dev/null @@ -1,345 +0,0 @@ -From 329dfc28debb58ffe7bd1967cea00fc583139aca Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Mon, 4 Nov 2019 14:27:49 +1100 -Subject: [PATCH] Create: add support for RAID0 layouts. -Git-commit: 329dfc28debb58ffe7bd1967cea00fc583139aca -Patch-mainline: mdadm-4.1+ -References: bsc#1162479 - -Since Linux 5.4 a layout is needed for RAID0 arrays with -varying device sizes. -This patch makes the layout of an array visible (via --examine) -and sets the layout on newly created arrays. ---layout=dangerous -can be used to avoid setting a layout so that they array -can be used on older kernels. - -Tested-by: dann frazier -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - Create.c | 11 +++++++++++ - Detail.c | 5 +++++ - maps.c | 12 ++++++++++++ - md.4 | 14 ++++++++++++++ - mdadm.8.in | 30 +++++++++++++++++++++++++++++- - mdadm.c | 8 ++++++++ - mdadm.h | 8 +++++++- - super0.c | 6 ++++++ - super1.c | 30 +++++++++++++++++++++++++++++- - 9 files changed, 121 insertions(+), 3 deletions(-) - -diff --git a/Create.c b/Create.c -index 292f92a..6f84e5b 100644 ---- a/Create.c -+++ b/Create.c -@@ -51,6 +51,9 @@ static int default_layout(struct supertype *st, int level, int verbose) - default: /* no layout */ - layout = 0; - break; -+ case 0: -+ layout = RAID0_ORIG_LAYOUT; -+ break; - case 10: - layout = 0x102; /* near=2, far=1 */ - if (verbose > 0) -@@ -950,6 +953,11 @@ int Create(struct supertype *st, char *mddev, - if (rv) { - pr_err("ADD_NEW_DISK for %s failed: %s\n", - dv->devname, strerror(errno)); -+ if (errno == EINVAL && -+ info.array.level == 0) { -+ pr_err("Possibly your kernel doesn't support RAID0 layouts.\n"); -+ pr_err("Either upgrade, or use --layout=dangerous\n"); -+ } - goto abort_locked; - } - break; -@@ -1046,6 +1054,9 @@ int Create(struct supertype *st, char *mddev, - if (ioctl(mdfd, RUN_ARRAY, ¶m)) { - pr_err("RUN_ARRAY failed: %s\n", - strerror(errno)); -+ if (errno == 524 /* ENOTSUP */ && -+ info.array.level == 0) -+ cont_err("Please use --layout=original or --layout=alternate\n"); - if (info.array.chunk_size & (info.array.chunk_size-1)) { - cont_err("Problem may be that chunk size is not a power of 2\n"); - } -diff --git a/Detail.c b/Detail.c -index 24fa462..832485f 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -525,6 +525,11 @@ int Detail(char *dev, struct context *c) - printf(" Layout : %s\n", - str ? str : "-unknown-"); - } -+ if (array.level == 0 && array.layout) { -+ str = map_num(r0layout, array.layout); -+ printf(" Layout : %s\n", -+ str ? str : "-unknown-"); -+ } - if (array.level == 6) { - str = map_num(r6layout, array.layout); - printf(" Layout : %s\n", -diff --git a/maps.c b/maps.c -index 49b7f2c..a4fd279 100644 ---- a/maps.c -+++ b/maps.c -@@ -73,6 +73,18 @@ mapping_t r6layout[] = { - { NULL, UnSet } - }; - -+/* raid0 layout is only needed because of a bug in 3.14 which changed -+ * the effective layout of raid0 arrays with varying device sizes. -+ */ -+mapping_t r0layout[] = { -+ { "original", RAID0_ORIG_LAYOUT}, -+ { "alternate", RAID0_ALT_MULTIZONE_LAYOUT}, -+ { "1", 1}, /* aka ORIG */ -+ { "2", 2}, /* aka ALT */ -+ { "dangerous", 0}, -+ { NULL, UnSet}, -+}; -+ - mapping_t pers[] = { - { "linear", LEVEL_LINEAR}, - { "raid0", 0}, -diff --git a/md.4 b/md.4 -index e86707a..6fe2755 100644 ---- a/md.4 -+++ b/md.4 -@@ -193,6 +193,20 @@ smallest device has been exhausted, the RAID0 driver starts - collecting chunks into smaller stripes that only span the drives which - still have remaining space. - -+A bug was introduced in linux 3.14 which changed the layout of blocks in -+a RAID0 beyond the region that is striped over all devices. This bug -+does not affect an array with all devices the same size, but can affect -+other RAID0 arrays. -+ -+Linux 5.4 (and some stable kernels to which the change was backported) -+will not normally assemble such an array as it cannot know which layout -+to use. There is a module parameter "raid0.default_layout" which can be -+set to "1" to force the kernel to use the pre-3.14 layout or to "2" to -+force it to use the 3.14-and-later layout. when creating a new RAID0 -+array, -+.I mdadm -+will record the chosen layout in the metadata in a way that allows newer -+kernels to assemble the array without needing a module parameter. - - .SS RAID1 - -diff --git a/mdadm.8.in b/mdadm.8.in -index 9aec9f4..fc9b6a6 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -593,6 +593,8 @@ to change the RAID level in some cases. See LEVEL CHANGES below. - This option configures the fine details of data layout for RAID5, RAID6, - and RAID10 arrays, and controls the failure modes for - .IR faulty . -+It can also be used for working around a kernel bug with RAID0, but generally -+doesn't need to be used explicitly. - - The layout of the RAID5 parity block can be one of - .BR left\-asymmetric , -@@ -652,7 +654,7 @@ option to set subsequent failure modes. - "clear" or "none" will remove any pending or periodic failure modes, - and "flush" will clear any persistent faults. - --Finally, the layout options for RAID10 are one of 'n', 'o' or 'f' followed -+The layout options for RAID10 are one of 'n', 'o' or 'f' followed - by a small number. The default is 'n2'. The supported options are: - - .I 'n' -@@ -677,6 +679,32 @@ devices in the array. It does not need to divide evenly into that - number (e.g. it is perfectly legal to have an 'n2' layout for an array - with an odd number of devices). - -+A bug introduced in Linux 3.14 means that RAID0 arrays -+.B "with devices of differing sizes" -+started using a different layout. This could lead to -+data corruption. Since Linux 5.4 (and various stable releases that received -+backports), the kernel will not accept such an array unless -+a layout is explictly set. It can be set to -+.RB ' original ' -+or -+.RB ' alternate '. -+When creating a new array, -+.I mdadm -+will select -+.RB ' original ' -+by default, so the layout does not normally need to be set. -+An array created for either -+.RB ' original ' -+or -+.RB ' alternate ' -+will not be recognized by an (unpatched) kernel prior to 5.4. To create -+a RAID0 array with devices of differing sizes that can be used on an -+older kernel, you can set the layout to -+.RB ' dangerous '. -+This will use whichever layout the running kernel supports, so the data -+on the array may become corrupt when changing kernel from pre-3.14 to a -+later kernel. -+ - When an array is converted between RAID5 and RAID6 an intermediate - RAID6 layout is used in which the second parity block (Q) is always on - the last device. To convert a RAID5 to RAID6 and leave it in this new -diff --git a/mdadm.c b/mdadm.c -index 1fb8086..e438f9c 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -550,6 +550,14 @@ int main(int argc, char *argv[]) - pr_err("raid level must be given before layout.\n"); - exit(2); - -+ case 0: -+ s.layout = map_name(r0layout, optarg); -+ if (s.layout == UnSet) { -+ pr_err("layout %s not understood for raid0.\n", -+ optarg); -+ exit(2); -+ } -+ break; - case 5: - s.layout = map_name(r5layout, optarg); - if (s.layout == UnSet) { -diff --git a/mdadm.h b/mdadm.h -index 91f1338..9e98778 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -763,7 +763,8 @@ extern int restore_stripes(int *dest, unsigned long long *offsets, - - extern char *map_num(mapping_t *map, int num); - extern int map_name(mapping_t *map, char *name); --extern mapping_t r5layout[], r6layout[], pers[], modes[], faultylayout[]; -+extern mapping_t r0layout[], r5layout[], r6layout[], -+ pers[], modes[], faultylayout[]; - extern mapping_t consistency_policies[], sysfs_array_states[]; - - extern char *map_dev_preferred(int major, int minor, int create, -@@ -1758,6 +1759,11 @@ char *xstrdup(const char *str); - #define makedev(M,m) (((M)<<8) | (m)) - #endif - -+enum r0layout { -+ RAID0_ORIG_LAYOUT = 1, -+ RAID0_ALT_MULTIZONE_LAYOUT = 2, -+}; -+ - /* for raid4/5/6 */ - #define ALGORITHM_LEFT_ASYMMETRIC 0 - #define ALGORITHM_RIGHT_ASYMMETRIC 1 -diff --git a/super0.c b/super0.c -index 6b7c0e3..6af140b 100644 ---- a/super0.c -+++ b/super0.c -@@ -1291,6 +1291,12 @@ static int validate_geometry0(struct supertype *st, int level, - if (*chunk == UnSet) - *chunk = DEFAULT_CHUNK; - -+ if (level == 0 && layout != UnSet) { -+ if (verbose) -+ pr_err("0.90 metadata does not support layouts for RAID0\n"); -+ return 0; -+ } -+ - if (!subdev) - return 1; - -diff --git a/super1.c b/super1.c -index 929466d..cedbb53 100644 ---- a/super1.c -+++ b/super1.c -@@ -43,7 +43,7 @@ struct mdp_superblock_1 { - - __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; /* only for raid5 currently */ -+ __u32 layout; /* used for raid5, raid6, raid10, and raid0 */ - __u64 size; /* used size of component devices, in 512byte sectors */ - - __u32 chunksize; /* in 512byte sectors */ -@@ -144,6 +144,7 @@ struct misc_dev_info { - #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 \ -@@ -155,6 +156,7 @@ struct misc_dev_info { - |MD_FEATURE_JOURNAL \ - |MD_FEATURE_PPL \ - |MD_FEATURE_MULTIPLE_PPLS \ -+ |MD_FEATURE_RAID0_LAYOUT \ - ) - - static int role_from_sb(struct mdp_superblock_1 *sb) -@@ -498,6 +500,11 @@ static void examine_super1(struct supertype *st, char *homehost) - printf(" Events : %llu\n", - (unsigned long long)__le64_to_cpu(sb->events)); - printf("\n"); -+ if (__le32_to_cpu(sb->level) == 0 && -+ (sb->feature_map & __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT))) { -+ c = map_num(r0layout, __le32_to_cpu(sb->layout)); -+ printf(" Layout : %s\n", c?c:"-unknown-"); -+ } - if (__le32_to_cpu(sb->level) == 5) { - c = map_num(r5layout, __le32_to_cpu(sb->layout)); - printf(" Layout : %s\n", c?c:"-unknown-"); -@@ -1646,6 +1653,7 @@ struct devinfo { - int fd; - char *devname; - long long data_offset; -+ unsigned long long dev_size; - mdu_disk_info_t disk; - struct devinfo *next; - }; -@@ -1687,6 +1695,7 @@ 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); - di->next = NULL; - *dip = di; - -@@ -1888,10 +1897,25 @@ static int write_init_super1(struct supertype *st) - unsigned long long sb_offset; - unsigned long long data_offset; - long bm_offset; -+ int raid0_need_layout = 0; - - for (di = st->info; di; di = di->next) { - if (di->disk.state & (1 << MD_DISK_JOURNAL)) - sb->feature_map |= __cpu_to_le32(MD_FEATURE_JOURNAL); -+ if (sb->level == 0 && sb->layout != 0) { -+ struct devinfo *di2 = st->info; -+ unsigned long long s1, s2; -+ s1 = di->dev_size; -+ if (di->data_offset != INVALID_SECTORS) -+ s1 -= di->data_offset; -+ s1 /= __le32_to_cpu(sb->chunksize); -+ s2 = di2->dev_size; -+ if (di2->data_offset != INVALID_SECTORS) -+ s2 -= di2->data_offset; -+ s2 /= __le32_to_cpu(sb->chunksize); -+ if (s1 != s2) -+ raid0_need_layout = 1; -+ } - } - - for (di = st->info; di; di = di->next) { -@@ -2039,6 +2063,10 @@ static int write_init_super1(struct supertype *st) - sb->bblog_offset = 0; - } - -+ /* RAID0 needs a layout if devices aren't all the same size */ -+ if (raid0_need_layout) -+ sb->feature_map |= __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT); -+ - sb->sb_csum = calc_sb_1_csum(sb); - rv = store_super1(st, di->fd); - --- -2.16.4 - diff --git a/0060-Assemble-add-support-for-RAID0-layouts.patch b/0060-Assemble-add-support-for-RAID0-layouts.patch deleted file mode 100644 index ac91fa0..0000000 --- a/0060-Assemble-add-support-for-RAID0-layouts.patch +++ /dev/null @@ -1,153 +0,0 @@ -From 027c099fd1a31fb3815e592de75d0791a22353b4 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Mon, 4 Nov 2019 14:27:49 +1100 -Subject: [PATCH] Assemble: add support for RAID0 layouts. -Git-commit: 027c099fd1a31fb3815e592de75d0791a22353b4 -Patch-mainline: mdadm-4.1+ -References: bsc#1162479 - -If you have a RAID0 array with varying sized devices -on a kernel before 5.4, you cannot assembling it on -5.4 or later without explicitly setting the layout. -This is now possible with - --update=layout-original (For 3.13 and earlier kernels) -or - --update=layout-alternate (for 3.14 and later kernels) - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - Assemble.c | 8 ++++++++ - md.4 | 7 +++++++ - mdadm.8.in | 17 +++++++++++++++++ - mdadm.c | 4 ++++ - super1.c | 12 +++++++++++- - 5 files changed, 47 insertions(+), 1 deletion(-) - -diff --git a/Assemble.c b/Assemble.c -index b2e6914..6b5a7c8 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1031,6 +1031,11 @@ static int start_array(int mdfd, - pr_err("failed to add %s to %s: %s\n", - devices[j].devname, mddev, - strerror(errno)); -+ if (errno == EINVAL && content->array.level == 0 && -+ content->array.layout != 0) { -+ cont_err("Possibly your kernel doesn't support RAID0 layouts.\n"); -+ cont_err("Please upgrade.\n"); -+ } - if (i < content->array.raid_disks * 2 || - i == bestcnt) - okcnt--; -@@ -1220,6 +1225,9 @@ static int start_array(int mdfd, - return 0; - } - pr_err("failed to RUN_ARRAY %s: %s\n", mddev, strerror(errno)); -+ if (errno == 524 /* ENOTSUP */ && -+ content->array.level == 0 && content->array.layout == 0) -+ cont_err("Please use --update=layout-original or --update=layout-alternate\n"); - - if (!enough(content->array.level, content->array.raid_disks, - content->array.layout, 1, avail)) -diff --git a/md.4 b/md.4 -index 6fe2755..0712af2 100644 ---- a/md.4 -+++ b/md.4 -@@ -208,6 +208,13 @@ array, - will record the chosen layout in the metadata in a way that allows newer - kernels to assemble the array without needing a module parameter. - -+To assemble an old array on a new kernel without using the module parameter, -+use either the -+.B "--update=layout-original" -+option or the -+.B "--update=layout-alternate" -+option. -+ - .SS RAID1 - - A RAID1 array is also known as a mirrored set (though mirrors tend to -diff --git a/mdadm.8.in b/mdadm.8.in -index fc9b6a6..6b63bb4 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -1213,6 +1213,8 @@ argument given to this flag can be one of - .BR no\-bbl , - .BR ppl , - .BR no\-ppl , -+.BR layout\-original , -+.BR layout\-alternate , - .BR metadata , - or - .BR super\-minor . -@@ -1364,6 +1366,21 @@ The - .B no\-ppl - option will disable PPL in the superblock. - -+The -+.B layout\-original -+and -+.B layout\-alternate -+options are for RAID0 arrays in use before Linux 5.4. If the array was being -+used with Linux 3.13 or earlier, then to assemble the array on a new kernel, -+.B \-\-update=layout\-original -+must be given. If the array was created and used with a kernel from Linux 3.14 to -+Linux 5.3, then -+.B \-\-update=layout\-alternate -+must be given. This only needs to be given once. Subsequent assembly of the array -+will happen normally. -+For more information, see -+.IR md (4). -+ - .TP - .BR \-\-freeze\-reshape - Option is intended to be used in start-up scripts during initrd boot phase. -diff --git a/mdadm.c b/mdadm.c -index e438f9c..256a97e 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -795,6 +795,9 @@ int main(int argc, char *argv[]) - continue; - if (strcmp(c.update, "revert-reshape") == 0) - continue; -+ if (strcmp(c.update, "layout-original") == 0 || -+ strcmp(c.update, "layout-alternate") == 0) -+ continue; - if (strcmp(c.update, "byteorder") == 0) { - if (ss) { - pr_err("must not set metadata type with --update=byteorder.\n"); -@@ -825,6 +828,7 @@ int main(int argc, char *argv[]) - " 'summaries', 'homehost', 'home-cluster', 'byteorder', 'devicesize',\n" - " 'no-bitmap', 'metadata', 'revert-reshape'\n" - " 'bbl', 'no-bbl', 'force-no-bbl', 'ppl', 'no-ppl'\n" -+ " 'layout-original', 'layout-alternate'\n" - ); - exit(outf == stdout ? 0 : 2); - -diff --git a/super1.c b/super1.c -index cedbb53..e0d80be 100644 ---- a/super1.c -+++ b/super1.c -@@ -1550,7 +1550,17 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - sb->devflags |= FailFast1; - else if (strcmp(update, "nofailfast") == 0) - sb->devflags &= ~FailFast1; -- else -+ else if (strcmp(update, "layout-original") == 0 || -+ strcmp(update, "layout-alternate") == 0) { -+ if (__le32_to_cpu(sb->level) != 0) { -+ pr_err("%s: %s only supported for RAID0\n", -+ devname?:"", update); -+ rv = -1; -+ } else { -+ sb->feature_map |= __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT); -+ sb->layout = __cpu_to_le32(update[7] == 'o' ? 1 : 2); -+ } -+ } else - rv = -1; - - sb->sb_csum = calc_sb_1_csum(sb); --- -2.16.4 - diff --git a/0061-Respect-CROSS_COMPILE-when-CC-is-the-default.patch b/0061-Respect-CROSS_COMPILE-when-CC-is-the-default.patch deleted file mode 100644 index 761624b..0000000 --- a/0061-Respect-CROSS_COMPILE-when-CC-is-the-default.patch +++ /dev/null @@ -1,40 +0,0 @@ -From aced6fc9542077a69b00d05bc9cd66c12fc34950 Mon Sep 17 00:00:00 2001 -From: dann frazier -Date: Mon, 9 Dec 2019 13:54:13 -0700 -Subject: [PATCH] Respect $(CROSS_COMPILE) when $(CC) is the default -Git-commit: aced6fc9542077a69b00d05bc9cd66c12fc34950 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Commit 1180ed5 told make to only respect $(CROSS_COMPILE) when $(CC) -was unset. But that will never be the case, as make provides -a default value for $(CC). Change this logic to respect $(CROSS_COMPILE) -when $(CC) is the default. Patch originally by Helmet Grohne. - -Fixes: 1180ed5 ("Makefile: make the CC definition conditional") -Signed-off-by: dann frazier -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Makefile | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index dfe00b0..a33319a 100644 ---- a/Makefile -+++ b/Makefile -@@ -46,7 +46,9 @@ ifdef COVERITY - COVERITY_FLAGS=-include coverity-gcc-hack.h - endif - --CC ?= $(CROSS_COMPILE)gcc -+ifeq ($(origin CC),default) -+CC := $(CROSS_COMPILE)gcc -+endif - CXFLAGS ?= -ggdb - CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter - ifdef WARN_UNUSED --- -2.25.0 - diff --git a/0062-Change-warning-message.patch b/0062-Change-warning-message.patch deleted file mode 100644 index c874a13..0000000 --- a/0062-Change-warning-message.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 1a87493014050e3bd94000cd36122c3cadf21270 Mon Sep 17 00:00:00 2001 -From: Kinga Tanska -Date: Tue, 10 Dec 2019 12:21:21 +0100 -Subject: [PATCH] Change warning message -Git-commit: 1a87493014050e3bd94000cd36122c3cadf21270 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -In commit 039b7225e6 ("md: allow creation of mdNNN arrays via -md_mod/parameters/new_array") support for name like mdNNN -was added. Special warning, when kernel is unable to handle -request, was added in commit 7105228e19 -("mdadm/mdopen: create new function create_named_array for -writing to new_array"), but it was not adequate enough, -because in this situation mdadm tries to do it in old way. -This commit changes warning to be more relevant when -creating RAID container with "/dev/mdNNN" name and mdadm -back to old approach. - -Signed-off-by: Kinga Tanska -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdopen.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/mdopen.c b/mdopen.c -index 98c54e4..245be53 100644 ---- a/mdopen.c -+++ b/mdopen.c -@@ -120,7 +120,8 @@ int create_named_array(char *devnm) - close(fd); - } - if (fd < 0 || n != (int)strlen(devnm)) { -- pr_err("Fail create %s when using %s\n", devnm, new_array_file); -+ pr_err("Fail to create %s when using %s, fallback to creation via node\n", -+ devnm, new_array_file); - return 0; - } - --- -2.25.0 - diff --git a/0063-mdcheck-service-can-t-start-succesfully-because-of-s.patch b/0063-mdcheck-service-can-t-start-succesfully-because-of-s.patch deleted file mode 100644 index 944cc25..0000000 --- a/0063-mdcheck-service-can-t-start-succesfully-because-of-s.patch +++ /dev/null @@ -1,50 +0,0 @@ -From e1512e7b7d060f0346738b237ea34eac21b29a26 Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Wed, 18 Dec 2019 14:46:21 +0800 -Subject: [PATCH] mdcheck service can't start succesfully because of syntax - error -Git-commit: e1512e7b7d060f0346738b237ea34eac21b29a26 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -It reports error when starting mdcheck_start and mdcheck_continue service. -Invalid environment assignment, ignoring: MDADM_CHECK_DURATION="6 hours" - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - systemd/mdcheck_continue.service | 2 +- - systemd/mdcheck_start.service | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service -index deac695..aa02dde 100644 ---- a/systemd/mdcheck_continue.service -+++ b/systemd/mdcheck_continue.service -@@ -11,7 +11,7 @@ ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_* - - [Service] - Type=oneshot --Environment= MDADM_CHECK_DURATION="6 hours" -+Environment= "MDADM_CHECK_DURATION=6 hours" - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh - ExecStart=/usr/share/mdadm/mdcheck --continue --duration ${MDADM_CHECK_DURATION} -diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service -index f17f1aa..da62d5f 100644 ---- a/systemd/mdcheck_start.service -+++ b/systemd/mdcheck_start.service -@@ -11,7 +11,7 @@ Wants=mdcheck_continue.timer - - [Service] - Type=oneshot --Environment= MDADM_CHECK_DURATION="6 hours" -+Environment= "MDADM_CHECK_DURATION=6 hours" - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh - ExecStart=/usr/share/mdadm/mdcheck --duration ${MDADM_CHECK_DURATION} --- -2.25.0 - diff --git a/0064-imsm-Update-grow-manual.patch b/0064-imsm-Update-grow-manual.patch deleted file mode 100644 index 1b0f996..0000000 --- a/0064-imsm-Update-grow-manual.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 4431efebabd0dd39f33dc1dd8ada312b8da1c9d8 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Thu, 16 Jan 2020 09:34:44 +0100 -Subject: [PATCH] imsm: Update grow manual. -Git-commit: 4431efebabd0dd39f33dc1dd8ada312b8da1c9d8 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Update --grow option description in manual, according to -the supported grow operations by IMSM. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdadm.8.in | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index 6b63bb4..ca02a33 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -481,9 +481,7 @@ still be larger than any replacement. - This value can be set with - .B \-\-grow - for RAID level 1/4/5/6 though --.B CONTAINER --based arrays such as those with IMSM metadata may not be able to --support this. -+DDF arrays may not be able to support this. - If the array was created with a size smaller than the currently - active drives, the extra space can be accessed using - .BR \-\-grow . -@@ -2759,9 +2757,7 @@ container format. The number of devices in a container can be - increased - which affects all arrays in the container - or an array - in a container can be converted between levels where those levels are - supported by the container, and the conversion is on of those listed --above. Resizing arrays in an IMSM container with --.B "--grow --size" --is not yet supported. -+above. - - .PP - Notes: --- -2.25.0 - diff --git a/0065-Add-support-for-Tebibytes.patch b/0065-Add-support-for-Tebibytes.patch deleted file mode 100644 index 9becf54..0000000 --- a/0065-Add-support-for-Tebibytes.patch +++ /dev/null @@ -1,197 +0,0 @@ -From 42e641abeb312a91b841f1b1ea73661e4bd5a31c Mon Sep 17 00:00:00 2001 -From: Kinga Tanska -Date: Tue, 21 Jan 2020 10:38:52 +0100 -Subject: [PATCH] Add support for Tebibytes -Git-commit: 42e641abeb312a91b841f1b1ea73661e4bd5a31c -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Adding support for Tebibytes enables display size of -volumes in Tebibytes and Terabytes when they are -bigger than 2048 GiB (or GB). - -Signed-off-by: Kinga Tanska -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdadm.8.in | 20 ++++++++++---------- - util.c | 47 +++++++++++++++++++++++++++++++++-------------- - 2 files changed, 43 insertions(+), 24 deletions(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index ca02a33..5d00faf 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -467,8 +467,8 @@ If this is not specified - size, though if there is a variance among the drives of greater than 1%, a warning is - issued. - --A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or --Gigabytes respectively. -+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes, -+Megabytes, Gigabytes or Terabytes respectively. - - Sometimes a replacement drive can be a little smaller than the - original drives though this should be minimised by IDEMA standards. -@@ -532,8 +532,8 @@ problems the array can be made bigger again with no loss with another - .B "\-\-grow \-\-array\-size=" - command. - --A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or --Gigabytes respectively. -+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes, -+Megabytes, Gigabytes or Terabytes respectively. - A value of - .B max - restores the apparent size of the array to be whatever the real -@@ -551,8 +551,8 @@ This is only meaningful for RAID0, RAID4, RAID5, RAID6, and RAID10. - RAID4, RAID5, RAID6, and RAID10 require the chunk size to be a power - of 2. In any case it must be a multiple of 4KB. - --A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or --Gigabytes respectively. -+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes, -+Megabytes, Gigabytes or Terabytes respectively. - - .TP - .BR \-\-rounding= -@@ -767,8 +767,8 @@ When using an - bitmap, the chunksize defaults to 64Meg, or larger if necessary to - fit the bitmap into the available space. - --A suffix of 'K', 'M' or 'G' can be given to indicate Kilobytes, Megabytes or --Gigabytes respectively. -+A suffix of 'K', 'M', 'G' or 'T' can be given to indicate Kilobytes, -+Megabytes, Gigabytes or Terabytes respectively. - - .TP - .BR \-W ", " \-\-write\-mostly -@@ -857,8 +857,8 @@ an array which was originally created using a different version of - which computed a different offset. - - Setting the offset explicitly over-rides the default. The value given --is in Kilobytes unless a suffix of 'K', 'M' or 'G' is used to explicitly --indicate Kilobytes, Megabytes or Gigabytes respectively. -+is in Kilobytes unless a suffix of 'K', 'M', 'G' or 'T' is used to explicitly -+indicate Kilobytes, Megabytes, Gigabytes or Terabytes respectively. - - Since Linux 3.4, - .B \-\-data\-offset -diff --git a/util.c b/util.c -index 64dd409..07f9dc3 100644 ---- a/util.c -+++ b/util.c -@@ -389,7 +389,7 @@ int mdadm_version(char *version) - unsigned long long parse_size(char *size) - { - /* parse 'size' which should be a number optionally -- * followed by 'K', 'M', or 'G'. -+ * followed by 'K', 'M'. 'G' or 'T'. - * Without a suffix, K is assumed. - * Number returned is in sectors (half-K) - * INVALID_SECTORS returned on error. -@@ -411,6 +411,10 @@ unsigned long long parse_size(char *size) - c++; - s *= 1024 * 1024 * 2; - break; -+ case 'T': -+ c++; -+ s *= 1024 * 1024 * 1024 * 2LL; -+ break; - case 's': /* sectors */ - c++; - break; -@@ -893,13 +897,14 @@ char *human_size(long long bytes) - { - static char buf[47]; - -- /* We convert bytes to either centi-M{ega,ibi}bytes or -- * centi-G{igi,ibi}bytes, with appropriate rounding, -- * and then print 1/100th of those as a decimal. -+ /* We convert bytes to either centi-M{ega,ibi}bytes, -+ * centi-G{igi,ibi}bytes or centi-T{era,ebi}bytes -+ * with appropriate rounding, and then print -+ * 1/100th of those as a decimal. - * We allow upto 2048Megabytes before converting to -- * gigabytes, as that shows more precision and isn't -+ * gigabytes and 2048Gigabytes before converting to -+ * terabytes, as that shows more precision and isn't - * too large a number. -- * Terabytes are not yet handled. - */ - - if (bytes < 5000*1024) -@@ -909,11 +914,16 @@ char *human_size(long long bytes) - long cMB = (bytes / ( 1000000LL / 200LL ) +1) /2; - snprintf(buf, sizeof(buf), " (%ld.%02ld MiB %ld.%02ld MB)", - cMiB/100, cMiB % 100, cMB/100, cMB % 100); -- } else { -+ } else if (bytes < 2*1024LL*1024LL*1024LL*1024LL) { - long cGiB = (bytes * 200LL / (1LL<<30) +1) / 2; - long cGB = (bytes / (1000000000LL/200LL ) +1) /2; - snprintf(buf, sizeof(buf), " (%ld.%02ld GiB %ld.%02ld GB)", - cGiB/100, cGiB % 100, cGB/100, cGB % 100); -+ } else { -+ long cTiB = (bytes * 200LL / (1LL<<40) + 1) / 2; -+ long cTB = (bytes / (1000000000000LL / 200LL) + 1) / 2; -+ snprintf(buf, sizeof(buf), " (%ld.%02ld TiB %ld.%02ld TB)", -+ cTiB/100, cTiB % 100, cTB/100, cTB % 100); - } - return buf; - } -@@ -922,13 +932,14 @@ char *human_size_brief(long long bytes, int prefix) - { - static char buf[30]; - -- /* We convert bytes to either centi-M{ega,ibi}bytes or -- * centi-G{igi,ibi}bytes, with appropriate rounding, -- * and then print 1/100th of those as a decimal. -+ /* We convert bytes to either centi-M{ega,ibi}bytes, -+ * centi-G{igi,ibi}bytes or centi-T{era,ebi}bytes -+ * with appropriate rounding, and then print -+ * 1/100th of those as a decimal. - * We allow upto 2048Megabytes before converting to -- * gigabytes, as that shows more precision and isn't -+ * gigabytes and 2048Gigabytes before converting to -+ * terabytes, as that shows more precision and isn't - * too large a number. -- * Terabytes are not yet handled. - * - * If prefix == IEC, we mean prefixes like kibi,mebi,gibi etc. - * If prefix == JEDEC, we mean prefixes like kilo,mega,giga etc. -@@ -941,10 +952,14 @@ char *human_size_brief(long long bytes, int prefix) - long cMiB = (bytes * 200LL / (1LL<<20) +1) /2; - snprintf(buf, sizeof(buf), "%ld.%02ldMiB", - cMiB/100, cMiB % 100); -- } else { -+ } else if (bytes < 2*1024LL*1024LL*1024LL*1024LL) { - long cGiB = (bytes * 200LL / (1LL<<30) +1) /2; - snprintf(buf, sizeof(buf), "%ld.%02ldGiB", - cGiB/100, cGiB % 100); -+ } else { -+ long cTiB = (bytes * 200LL / (1LL<<40) + 1) / 2; -+ snprintf(buf, sizeof(buf), "%ld.%02ldTiB", -+ cTiB/100, cTiB % 100); - } - } - else if (prefix == JEDEC) { -@@ -952,10 +967,14 @@ char *human_size_brief(long long bytes, int prefix) - long cMB = (bytes / ( 1000000LL / 200LL ) +1) /2; - snprintf(buf, sizeof(buf), "%ld.%02ldMB", - cMB/100, cMB % 100); -- } else { -+ } else if (bytes < 2*1024LL*1024LL*1024LL*1024LL) { - long cGB = (bytes / (1000000000LL/200LL ) +1) /2; - snprintf(buf, sizeof(buf), "%ld.%02ldGB", - cGB/100, cGB % 100); -+ } else { -+ long cTB = (bytes / (1000000000000LL / 200LL) + 1) / 2; -+ snprintf(buf, sizeof(buf), "%ld.%02ldTB", -+ cTB/100, cTB % 100); - } - } - else --- -2.25.0 - diff --git a/0066-imsm-fill-working_disks-according-to-metadata.patch b/0066-imsm-fill-working_disks-according-to-metadata.patch deleted file mode 100644 index b2035ec..0000000 --- a/0066-imsm-fill-working_disks-according-to-metadata.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 1e93d0d15913c3fa6d0de5af3fb5e4e3b3f068da Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 17 Jan 2020 15:24:04 +0100 -Subject: [PATCH] imsm: fill working_disks according to metadata. -Git-commit: 1e93d0d15913c3fa6d0de5af3fb5e4e3b3f068da -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Imsm tracks as "working_disk" each visible drive. -Assemble routine expects that the value will return count -of active member drives recorded in metadata. -As a side effect "--no-degraded" doesn't work correctly for imsm. -Align this field to others. -Added check, if the option --no-degraded is called with --scan. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - mdadm.c | 9 ++++++--- - super-intel.c | 5 ++--- - 2 files changed, 8 insertions(+), 6 deletions(-) - -diff --git a/mdadm.c b/mdadm.c -index 256a97e..13dc24e 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -1485,9 +1485,12 @@ int main(int argc, char *argv[]) - rv = Manage_stop(devlist->devname, mdfd, c.verbose, 0); - break; - case ASSEMBLE: -- if (devs_found == 1 && ident.uuid_set == 0 && -- ident.super_minor == UnSet && ident.name[0] == 0 && -- !c.scan ) { -+ if (!c.scan && c.runstop == -1) { -+ pr_err("--no-degraded not meaningful without a --scan assembly.\n"); -+ exit(1); -+ } else if (devs_found == 1 && ident.uuid_set == 0 && -+ ident.super_minor == UnSet && ident.name[0] == 0 && -+ !c.scan) { - /* Only a device has been given, so get details from config file */ - struct mddev_ident *array_ident = conf_get_ident(devlist->devname); - if (array_ident == NULL) { -diff --git a/super-intel.c b/super-intel.c -index 5c1f759..47809bc 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7946,7 +7946,8 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - skip = 1; - if (!skip && (ord & IMSM_ORD_REBUILD)) - recovery_start = 0; -- -+ if (!(ord & IMSM_ORD_REBUILD)) -+ this->array.working_disks++; - /* - * if we skip some disks the array will be assmebled degraded; - * reset resync start to avoid a dirty-degraded -@@ -7988,8 +7989,6 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - else - this->array.spare_disks++; - } -- if (info_d->recovery_start == MaxSector) -- this->array.working_disks++; - - info_d->events = __le32_to_cpu(mpb->generation_num); - info_d->data_offset = pba_of_lba0(map); --- -2.25.0 - diff --git a/0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch b/0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch deleted file mode 100644 index 4bef2f2..0000000 --- a/0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 2551061c253b8fd45ee93d1aab3e91d2c7ac9c20 Mon Sep 17 00:00:00 2001 -From: Coly Li -Date: Mon, 24 Feb 2020 12:34:09 +0100 -Subject: [PATCH] mdadm.8: add note information for raid0 growing operation -Git-commit: 2551061c253b8fd45ee93d1aab3e91d2c7ac9c20 -Patch-mainline: mdadm-4.1+ -References: bsc#1129900 - -When growing a raid0 device, if the new component disk size is not -big enough, the grow operation may fail due to lack of backup space. - -The minimum backup space should be larger than: - LCM(old, new) * chunk-size * 2 - -where LCM() is the least common multiple of the old and new count of -component disks, and "* 2" comes from the fact that mdadm refuses to -use more than half of a spare device for backup space. - -There are users reporting such failure when they grew a raid0 array -with small component disk. Neil Brown points out this is not a bug -and how the failure comes. This patch adds note information into -mdadm(8) man page in the Notes part of GROW MODE section to explain -the minimum size requirement of new component disk size or external -backup size. - -Reviewed-by: Petr Vorel -Cc: NeilBrown -Cc: Jes Sorensen -Cc: Paul Menzel -Cc: Wols Lists -Cc: Nix -Signed-off-by: Coly Li -Signed-off-by: Jes Sorensen - ---- - mdadm.8.in | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/mdadm.8.in b/mdadm.8.in -index 5d00faf..a3494a1 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -2768,6 +2768,12 @@ option and it is transparent for assembly feature. - .IP \(bu 4 - Roaming between Windows(R) and Linux systems for IMSM metadata is not - supported during grow process. -+.IP \(bu 4 -+When growing a raid0 device, the new component disk size (or external -+backup size) should be larger than LCM(old, new) * chunk-size * 2, -+where LCM() is the least common multiple of the old and new count of -+component disks, and "* 2" comes from the fact that mdadm refuses to -+use more than half of a spare device for backup space. - - .SS SIZE CHANGES - Normally when an array is built the "size" is taken from the smallest --- -2.25.0 - diff --git a/0068-Remove-the-legacy-whitespace.patch b/0068-Remove-the-legacy-whitespace.patch deleted file mode 100644 index 3d5ceee..0000000 --- a/0068-Remove-the-legacy-whitespace.patch +++ /dev/null @@ -1,64 +0,0 @@ -From fd38b8ea80ff8e0317e12d1d70431148ceedd5fd Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 11 Feb 2020 21:44:15 +0800 -Subject: [PATCH] Remove the legacy whitespace -Git-commit: fd38b8ea80ff8e0317e12d1d70431148ceedd5fd -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -The whitespace between Environment= and the true value causes confusion. -To avoid confusing other people in future, remove the whitespace to keep -it a simple, unambiguous syntax - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - systemd/mdcheck_continue.service | 2 +- - systemd/mdcheck_start.service | 2 +- - systemd/mdmonitor-oneshot.service | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service -index aa02dde..854317f 100644 ---- a/systemd/mdcheck_continue.service -+++ b/systemd/mdcheck_continue.service -@@ -11,7 +11,7 @@ ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_* - - [Service] - Type=oneshot --Environment= "MDADM_CHECK_DURATION=6 hours" -+Environment="MDADM_CHECK_DURATION=6 hours" - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh - ExecStart=/usr/share/mdadm/mdcheck --continue --duration ${MDADM_CHECK_DURATION} -diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service -index da62d5f..3bb3d13 100644 ---- a/systemd/mdcheck_start.service -+++ b/systemd/mdcheck_start.service -@@ -11,7 +11,7 @@ Wants=mdcheck_continue.timer - - [Service] - Type=oneshot --Environment= "MDADM_CHECK_DURATION=6 hours" -+Environment="MDADM_CHECK_DURATION=6 hours" - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh - ExecStart=/usr/share/mdadm/mdcheck --duration ${MDADM_CHECK_DURATION} -diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service -index fd469b1..373955a 100644 ---- a/systemd/mdmonitor-oneshot.service -+++ b/systemd/mdmonitor-oneshot.service -@@ -9,7 +9,7 @@ - Description=Reminder for degraded MD arrays - - [Service] --Environment= MDADM_MONITOR_ARGS=--scan -+Environment=MDADM_MONITOR_ARGS=--scan - EnvironmentFile=-/run/sysconfig/mdadm - ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh - ExecStart=BINDIR/mdadm --monitor --oneshot $MDADM_MONITOR_ARGS --- -2.25.0 - diff --git a/0069-imsm-pass-subarray-id-to-kill_subarray-function.patch b/0069-imsm-pass-subarray-id-to-kill_subarray-function.patch deleted file mode 100644 index 6b9d454..0000000 --- a/0069-imsm-pass-subarray-id-to-kill_subarray-function.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 3364781b929f571a3dc3a6afed09eb1b03ce607c Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 19 Feb 2020 10:54:49 +0100 -Subject: [PATCH] imsm: pass subarray id to kill_subarray function -Git-commit: 3364781b929f571a3dc3a6afed09eb1b03ce607c -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -After patch b6180160f ("imsm: save current_vol number") -current_vol for imsm is not set and kill_subarray() -cannot determine which volume has to be deleted. -Volume has to be passed as "subarray_id". -The parameter affects only IMSM metadata. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Kill.c | 2 +- - mdadm.h | 3 ++- - super-ddf.c | 2 +- - super-intel.c | 9 ++++----- - 4 files changed, 8 insertions(+), 8 deletions(-) - -diff --git a/Kill.c b/Kill.c -index d4767e2..bfd0efd 100644 ---- a/Kill.c -+++ b/Kill.c -@@ -119,7 +119,7 @@ int Kill_subarray(char *dev, char *subarray, int verbose) - st->update_tail = &st->updates; - - /* ok we've found our victim, drop the axe */ -- rv = st->ss->kill_subarray(st); -+ rv = st->ss->kill_subarray(st, subarray); - if (rv) { - if (verbose >= 0) - pr_err("Failed to delete subarray-%s from %s\n", -diff --git a/mdadm.h b/mdadm.h -index 9e98778..d94569f 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1038,7 +1038,8 @@ extern struct superswitch { - /* query the supertype for default geometry */ - void (*default_geometry)(struct supertype *st, int *level, int *layout, int *chunk); /* optional */ - /* Permit subarray's to be deleted from inactive containers */ -- int (*kill_subarray)(struct supertype *st); /* optional */ -+ int (*kill_subarray)(struct supertype *st, -+ char *subarray_id); /* optional */ - /* Permit subarray's to be modified */ - int (*update_subarray)(struct supertype *st, char *subarray, - char *update, struct mddev_ident *ident); /* optional */ -diff --git a/super-ddf.c b/super-ddf.c -index 7802063..7cd5702 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -4446,7 +4446,7 @@ static int _kill_subarray_ddf(struct ddf_super *ddf, const char *guid) - return 0; - } - --static int kill_subarray_ddf(struct supertype *st) -+static int kill_subarray_ddf(struct supertype *st, char *subarray_id) - { - struct ddf_super *ddf = st->sb; - /* -diff --git a/super-intel.c b/super-intel.c -index 47809bc..e4d2122 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7600,18 +7600,17 @@ static void default_geometry_imsm(struct supertype *st, int *level, int *layout, - - static void handle_missing(struct intel_super *super, struct imsm_dev *dev); - --static int kill_subarray_imsm(struct supertype *st) -+static int kill_subarray_imsm(struct supertype *st, char *subarray_id) - { -- /* remove the subarray currently referenced by ->current_vol */ -+ /* remove the subarray currently referenced by subarray_id */ - __u8 i; - struct intel_dev **dp; - struct intel_super *super = st->sb; -- __u8 current_vol = super->current_vol; -+ __u8 current_vol = strtoul(subarray_id, NULL, 10); - struct imsm_super *mpb = super->anchor; - -- if (super->current_vol < 0) -+ if (mpb->num_raid_devs == 0) - return 2; -- super->current_vol = -1; /* invalidate subarray cursor */ - - /* block deletions that would change the uuid of active subarrays - * --- -2.25.0 - diff --git a/0070-imsm-Remove-dump-restore-implementation.patch b/0070-imsm-Remove-dump-restore-implementation.patch deleted file mode 100644 index ec62952..0000000 --- a/0070-imsm-Remove-dump-restore-implementation.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 45c43276d02a32876c7e1f9f0d04580595141b3d Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 19 Feb 2020 11:13:17 +0100 -Subject: [PATCH] imsm: Remove --dump/--restore implementation -Git-commit: 45c43276d02a32876c7e1f9f0d04580595141b3d -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-10078, jsc#SLE-9348 - -Functionalities --dump and --restore are not supported. -Remove dead code from imsm. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - super-intel.c | 56 --------------------------------------------------- - 1 file changed, 56 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index e4d2122..c9a1af5 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2128,61 +2128,6 @@ static void export_examine_super_imsm(struct supertype *st) - printf("MD_DEVICES=%u\n", mpb->num_disks); - } - --static int copy_metadata_imsm(struct supertype *st, int from, int to) --{ -- /* The second last sector of the device contains -- * the "struct imsm_super" metadata. -- * This contains mpb_size which is the size in bytes of the -- * extended metadata. This is located immediately before -- * the imsm_super. -- * We want to read all that, plus the last sector which -- * may contain a migration record, and write it all -- * to the target. -- */ -- void *buf; -- unsigned long long dsize, offset; -- int sectors; -- struct imsm_super *sb; -- struct intel_super *super = st->sb; -- unsigned int sector_size = super->sector_size; -- unsigned int written = 0; -- -- if (posix_memalign(&buf, MAX_SECTOR_SIZE, MAX_SECTOR_SIZE) != 0) -- return 1; -- -- if (!get_dev_size(from, NULL, &dsize)) -- goto err; -- -- if (lseek64(from, dsize-(2*sector_size), 0) < 0) -- goto err; -- if ((unsigned int)read(from, buf, sector_size) != sector_size) -- goto err; -- sb = buf; -- if (strncmp((char*)sb->sig, MPB_SIGNATURE, MPB_SIG_LEN) != 0) -- goto err; -- -- sectors = mpb_sectors(sb, sector_size) + 2; -- offset = dsize - sectors * sector_size; -- if (lseek64(from, offset, 0) < 0 || -- lseek64(to, offset, 0) < 0) -- goto err; -- while (written < sectors * sector_size) { -- int n = sectors*sector_size - written; -- if (n > 4096) -- n = 4096; -- if (read(from, buf, n) != n) -- goto err; -- if (write(to, buf, n) != n) -- goto err; -- written += n; -- } -- free(buf); -- return 0; --err: -- free(buf); -- return 1; --} -- - static void detail_super_imsm(struct supertype *st, char *homehost, - char *subarray) - { -@@ -12270,7 +12215,6 @@ struct superswitch super_imsm = { - .reshape_super = imsm_reshape_super, - .manage_reshape = imsm_manage_reshape, - .recover_backup = recover_backup_imsm, -- .copy_metadata = copy_metadata_imsm, - .examine_badblocks = examine_badblocks_imsm, - .match_home = match_home_imsm, - .uuid_from_super= uuid_from_super_imsm, --- -2.25.0 - diff --git a/0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch b/0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch deleted file mode 100644 index bb98c11..0000000 --- a/0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch +++ /dev/null @@ -1,112 +0,0 @@ -From 185ec4397e61ad00dd68c841e15eaa8629eb9514 Mon Sep 17 00:00:00 2001 -From: Coly Li -Date: Sat, 11 Apr 2020 00:24:46 +0800 -Subject: [PATCH] Monitor: improve check_one_sharer() for checking duplicated - process -Git-commit: 185ec4397e61ad00dd68c841e15eaa8629eb9514 -Patch-mainline: mdadm-4.1+ -References: bsc#1168953 - -When running mdadm monitor with scan mode, only one autorebuild process -is allowed. check_one_sharer() checks duplicated process by following -steps, -1) Read autorebuild.pid file, - - if file does not exist, no duplicated process, go to 3). - - if file exists, continue to next step. -2) Read pid number from autorebuild.pid file, then check procfs pid - directory /proc/, - - if the directory does not exist, no duplicated process, go to 3) - - if the directory exists, print error message for duplicated process - and exit this mdadm. -3) Write current pid into autorebuild.pid file, continue to monitor in - scan mode. - -The problem for the above step 2) is, if after system reboots and -another different process happens to have exact same pid number which -autorebuild.pid file records, check_one_sharer() will treat it as a -duplicated mdadm process and returns error with message "Only one -autorebuild process allowed in scan mode, aborting". - -This patch tries to fix the above same-pid-but-different-process issue -by one more step to check the process command name, -1) Read autorebuild.pid file - - if file does not exist, no duplicated process, go to 4). - - if file exists, continue to next step. -2) Read pid number from autorebuild.pid file, then check procfs file - comm with the specific pid directory /proc//comm - - if the file does not exit, it means the directory /proc/ does - not exist, go to 4) - - if the file exits, continue next step -3) Read process command name from /proc//comm, compare the command - name with "mdadm" process name, - - if not equal, no duplicated process, goto 4) - - if strings are equal, print error message for duplicated process - and exit this mdadm. -4) Write current pid into autorebuild.pid file, continue to monitor in - scan mode. - -Now check_one_sharer() returns error for duplicated process only when -the recorded pid from autorebuild.pid exists, and the process has exact -same command name as "mdadm". - -Reported-by: Shinkichi Yamazaki -Signed-off-by: Coly Li -Signed-off-by: Jes Sorensen ---- - Monitor.c | 32 ++++++++++++++++++++------------ - 1 file changed, 20 insertions(+), 12 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index b527165..2d6b3b9 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -301,26 +301,34 @@ static int make_daemon(char *pidfile) - - static int check_one_sharer(int scan) - { -- int pid, rv; -+ int pid; -+ FILE *comm_fp; - FILE *fp; -- char dir[20]; -+ char comm_path[100]; - char path[100]; -- struct stat buf; -+ char comm[20]; -+ - sprintf(path, "%s/autorebuild.pid", MDMON_DIR); - fp = fopen(path, "r"); - if (fp) { - if (fscanf(fp, "%d", &pid) != 1) - pid = -1; -- sprintf(dir, "/proc/%d", pid); -- rv = stat(dir, &buf); -- if (rv != -1) { -- if (scan) { -- pr_err("Only one autorebuild process allowed in scan mode, aborting\n"); -- fclose(fp); -- return 1; -- } else { -- pr_err("Warning: One autorebuild process already running.\n"); -+ snprintf(comm_path, sizeof(comm_path), -+ "/proc/%d/comm", pid); -+ comm_fp = fopen(comm_path, "r"); -+ if (comm_fp) { -+ if (fscanf(comm_fp, "%s", comm) && -+ strncmp(basename(comm), Name, strlen(Name)) == 0) { -+ if (scan) { -+ pr_err("Only one autorebuild process allowed in scan mode, aborting\n"); -+ fclose(comm_fp); -+ fclose(fp); -+ return 1; -+ } else { -+ pr_err("Warning: One autorebuild process already running.\n"); -+ } - } -+ fclose(comm_fp); - } - fclose(fp); - } --- -2.25.0 - diff --git a/0072-Detail-adding-sync-status-for-cluster-device.patch b/0072-Detail-adding-sync-status-for-cluster-device.patch deleted file mode 100644 index fbe6786..0000000 --- a/0072-Detail-adding-sync-status-for-cluster-device.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 1c294b5d960abeeb9e0f188af294d019bc82b20e Mon Sep 17 00:00:00 2001 -From: Lidong Zhong -Date: Tue, 14 Apr 2020 16:19:41 +0800 -Subject: [PATCH] Detail: adding sync status for cluster device -Git-commit: 1c294b5d960abeeb9e0f188af294d019bc82b20e -Patch-mainline: mdadm-4.1+ -References: bsc#1163727 - -On the node with /proc/mdstat is - -Personalities : [raid1] -md0 : active raid1 sdb[4] sdc[3] sdd[2] - 1046528 blocks super 1.2 [3/2] [UU_] - recover=REMOTE - bitmap: 1/1 pages [4KB], 65536KB chunk - -Let's change the 'State' of 'mdadm -Q -D' accordingly -State : clean, degraded -With this patch, it will be -State : clean, degraded, recovering (REMOTE) - -Signed-off-by: Lidong Zhong -Acked-by: Guoqing Jiang -Signed-off-by: Jes Sorensen ---- - Detail.c | 9 ++++++--- - mdadm.h | 3 ++- - mdstat.c | 2 ++ - 3 files changed, 10 insertions(+), 4 deletions(-) - -diff --git a/Detail.c b/Detail.c -index daec4f1..24eeba0 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -498,17 +498,20 @@ int Detail(char *dev, struct context *c) - } else - arrayst = "active"; - -- printf(" State : %s%s%s%s%s%s \n", -+ printf(" State : %s%s%s%s%s%s%s \n", - arrayst, st, - (!e || (e->percent < 0 && - e->percent != RESYNC_PENDING && -- e->percent != RESYNC_DELAYED)) ? -+ e->percent != RESYNC_DELAYED && -+ e->percent != RESYNC_REMOTE)) ? - "" : sync_action[e->resync], - larray_size ? "": ", Not Started", - (e && e->percent == RESYNC_DELAYED) ? - " (DELAYED)": "", - (e && e->percent == RESYNC_PENDING) ? -- " (PENDING)": ""); -+ " (PENDING)": "", -+ (e && e->percent == RESYNC_REMOTE) ? -+ " (REMOTE)": ""); - } else if (inactive && !is_container) { - printf(" State : inactive\n"); - } -diff --git a/mdadm.h b/mdadm.h -index d94569f..399478b 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1815,7 +1815,8 @@ enum r0layout { - #define RESYNC_NONE -1 - #define RESYNC_DELAYED -2 - #define RESYNC_PENDING -3 --#define RESYNC_UNKNOWN -4 -+#define RESYNC_REMOTE -4 -+#define RESYNC_UNKNOWN -5 - - /* When using "GET_DISK_INFO" it isn't certain how high - * we need to check. So we impose an absolute limit of -diff --git a/mdstat.c b/mdstat.c -index 7e600d0..20577a3 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -257,6 +257,8 @@ struct mdstat_ent *mdstat_read(int hold, int start) - ent->percent = RESYNC_DELAYED; - if (l > 8 && strcmp(w+l-8, "=PENDING") == 0) - ent->percent = RESYNC_PENDING; -+ if (l > 7 && strcmp(w+l-7, "=REMOTE") == 0) -+ ent->percent = RESYNC_REMOTE; - } else if (ent->percent == RESYNC_NONE && - w[0] >= '0' && - w[0] <= '9' && --- -2.25.0 - diff --git a/0073-imsm-Correct-minimal-device-size.patch b/0073-imsm-Correct-minimal-device-size.patch deleted file mode 100644 index f9eefbf..0000000 --- a/0073-imsm-Correct-minimal-device-size.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 06a6101c0a4d2658798dc42f461ace8e6900f840 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 11 Mar 2020 15:40:13 +0100 -Subject: [PATCH 66/89] imsm: Correct minimal device size. -Git-commit: 06a6101c0a4d2658798dc42f461ace8e6900f840 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Check if given size of member drive is not less than 1 MibiByte. - -Signed-off-by: Blazej Kucman -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - super-intel.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index c9a1af5..6680df2 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7425,7 +7425,10 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - verbose); - } - -- if (size && (size < 1024)) { -+ /* -+ * Size is given in sectors. -+ */ -+ if (size && (size < 2048)) { - pr_err("Given size must be greater than 1M.\n"); - /* Depends on algorithm in Create.c : - * if container was given (dev == NULL) return -1, --- -2.26.2 - diff --git a/0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch b/0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch deleted file mode 100644 index a61d0d5..0000000 --- a/0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 9e4494051de3f53228fabae56c116879bff5a0c8 Mon Sep 17 00:00:00 2001 -From: Lidong Zhong -Date: Mon, 16 Mar 2020 10:16:49 +0800 -Subject: [PATCH 67/89] Detail: show correct bitmap info for cluster raid - device -Git-commit: 9e4494051de3f53228fabae56c116879bff5a0c8 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Signed-off-by: Lidong Zhong -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Detail.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index 832485f..daec4f1 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -468,7 +468,9 @@ int Detail(char *dev, struct context *c) - if (ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 && bmf.pathname[0]) { - printf(" Intent Bitmap : %s\n", bmf.pathname); - printf("\n"); -- } else if (array.state & (1< -Date: Tue, 17 Mar 2020 10:20:12 +0100 -Subject: [PATCH 68/89] imsm: support the Array Creation Time field in metadata -Git-commit: e48aed3c81a75fa3f761fb5b84e5d16f2baee709 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Also present its value in --examine and --examine --export. - -Signed-off-by: Artur Paszkiewicz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - super-intel.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 6680df2..8840fff 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -260,8 +260,9 @@ struct imsm_super { - * (starts at 1) - */ - __u16 filler1; /* 0x4E - 0x4F */ --#define IMSM_FILLERS 34 -- __u32 filler[IMSM_FILLERS]; /* 0x50 - 0xD7 RAID_MPB_FILLERS */ -+ __u64 creation_time; /* 0x50 - 0x57 Array creation time */ -+#define IMSM_FILLERS 32 -+ __u32 filler[IMSM_FILLERS]; /* 0x58 - 0xD7 RAID_MPB_FILLERS */ - struct imsm_disk disk[1]; /* 0xD8 diskTbl[numDisks] */ - /* here comes imsm_dev[num_raid_devs] */ - /* here comes BBM logs */ -@@ -2014,6 +2015,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost) - __u32 sum; - __u32 reserved = imsm_reserved_sectors(super, super->disks); - struct dl *dl; -+ time_t creation_time; - - strncpy(str, (char *)mpb->sig, MPB_SIG_LEN); - str[MPB_SIG_LEN-1] = '\0'; -@@ -2022,6 +2024,9 @@ static void examine_super_imsm(struct supertype *st, char *homehost) - printf(" Orig Family : %08x\n", __le32_to_cpu(mpb->orig_family_num)); - printf(" Family : %08x\n", __le32_to_cpu(mpb->family_num)); - printf(" Generation : %08x\n", __le32_to_cpu(mpb->generation_num)); -+ 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"); -@@ -2126,6 +2131,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)); - } - - static void detail_super_imsm(struct supertype *st, char *homehost, -@@ -5762,6 +5768,7 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, - sum += __gen_imsm_checksum(mpb); - mpb->family_num = __cpu_to_le32(sum); - mpb->orig_family_num = mpb->family_num; -+ mpb->creation_time = __cpu_to_le64((__u64)time(NULL)); - } - super->current_disk = dl; - return 0; --- -2.26.2 - diff --git a/0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch b/0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch deleted file mode 100644 index 8624097..0000000 --- a/0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch +++ /dev/null @@ -1,42 +0,0 @@ -From ba1b3bc80ea555c288f1119e69d9273249967081 Mon Sep 17 00:00:00 2001 -From: Artur Paszkiewicz -Date: Tue, 17 Mar 2020 10:21:03 +0100 -Subject: [PATCH 69/89] imsm: show Subarray and Volume ID in --examine output -Git-commit: ba1b3bc80ea555c288f1119e69d9273249967081 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Show the index of the subarray as 'Subarray' and the value of the -my_vol_raid_dev_num field as 'Volume ID'. - -Signed-off-by: Artur Paszkiewicz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - super-intel.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index 8840fff..562a58c 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1579,6 +1579,7 @@ static void print_imsm_dev(struct intel_super *super, - - printf("\n"); - printf("[%.16s]:\n", dev->volume); -+ printf(" Subarray : %d\n", super->current_vol); - printf(" UUID : %s\n", uuid); - printf(" RAID Level : %d", get_imsm_raid_level(map)); - if (map2) -@@ -1683,6 +1684,8 @@ static void print_imsm_dev(struct intel_super *super, - printf("Multiple PPLs on journaling drive\n"); - else - printf("\n", dev->rwh_policy); -+ -+ printf(" Volume ID : %u\n", dev->my_vol_raid_dev_num); - } - - static void print_imsm_disk(struct imsm_disk *disk, --- -2.26.2 - diff --git a/0077-udev-Ignore-change-event-for-imsm.patch b/0077-udev-Ignore-change-event-for-imsm.patch deleted file mode 100644 index b697c1b..0000000 --- a/0077-udev-Ignore-change-event-for-imsm.patch +++ /dev/null @@ -1,39 +0,0 @@ -From e1b92ee0de26576a33b20c9dd6ef6bd8cab8e283 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 8 Apr 2020 16:44:52 +0200 -Subject: [PATCH 70/89] udev: Ignore change event for imsm -Git-commit: e1b92ee0de26576a33b20c9dd6ef6bd8cab8e283 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -When adding a device to a container mdadm has to close its file -descriptor before sysfs_add_disk(). This generates change event. -There is race possibility because metadata is already written and other --I process can place drive differently. As a result device can be added -to two containers simultaneously. -From IMSM perspective there is no need to react for change event. IMSM -doesn't support stacked devices. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - udev-md-raid-assembly.rules | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules -index 9f055ed..d668cdd 100644 ---- a/udev-md-raid-assembly.rules -+++ b/udev-md-raid-assembly.rules -@@ -23,7 +23,7 @@ IMPORT{cmdline}="nodmraid" - ENV{nodmraid}=="?*", GOTO="md_inc_end" - ENV{ID_FS_TYPE}=="ddf_raid_member", GOTO="md_inc" - ENV{noiswmd}=="?*", GOTO="md_inc_end" --ENV{ID_FS_TYPE}=="isw_raid_member", GOTO="md_inc" -+ENV{ID_FS_TYPE}=="isw_raid_member", ACTION!="change", GOTO="md_inc" - GOTO="md_inc_end" - - LABEL="md_inc" --- -2.26.2 - diff --git a/0078-Manage-imsm-Write-metadata-before-add.patch b/0078-Manage-imsm-Write-metadata-before-add.patch deleted file mode 100644 index b42add4..0000000 --- a/0078-Manage-imsm-Write-metadata-before-add.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 12724c018c964596aa277489fd287d5c3506361a Mon Sep 17 00:00:00 2001 -From: Tkaczyk Mariusz -Date: Fri, 17 Apr 2020 13:55:55 +0200 -Subject: [PATCH 73/89] Manage, imsm: Write metadata before add -Commit: 12724c018c964596aa277489fd287d5c3506361a -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -New drive in container always appears as spare. Manager is able to -handle that, and queues appropriative update to monitor. -No update from mdadm side has to be processed, just insert the drive and -ping the mdmon. Metadata has to be written if no mdmon is running (case -for Raid0 or container without arrays). - -If bare drive is added very early on startup (by custom bare rule), -there is possiblity that mdmon was not restarted after switch root. Old -one is not able to handle new drive. New one fails because there is -drive without metadata in container and metadata cannot be loaded. - -To prevent this, write spare metadata before adding device -to container. Mdmon will overwrite it (same case as spare migration, -if drive appears it writes the most recent metadata). -Metadata has to be written only on new drive before sysfs_add_disk(), -don't race with mdmon if running. - -Signed-off-by: Tkaczyk Mariusz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Manage.c | 6 +---- - super-intel.c | 66 +++++++++++++++++++++++++++++++++------------------ - 2 files changed, 44 insertions(+), 28 deletions(-) - -diff --git a/Manage.c b/Manage.c -index b22c396..0a5f09b 100644 ---- a/Manage.c -+++ b/Manage.c -@@ -994,17 +994,13 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv, - - Kill(dv->devname, NULL, 0, -1, 0); - dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT); -- if (mdmon_running(tst->container_devnm)) -- tst->update_tail = &tst->updates; - if (tst->ss->add_to_super(tst, &disc, dfd, - dv->devname, INVALID_SECTORS)) { - close(dfd); - close(container_fd); - return -1; - } -- if (tst->update_tail) -- flush_metadata_updates(tst); -- else -+ if (!mdmon_running(tst->container_devnm)) - tst->ss->sync_metadata(tst); - - sra = sysfs_read(container_fd, NULL, 0); -diff --git a/super-intel.c b/super-intel.c -index 562a58c..3a73d2b 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -5809,6 +5809,9 @@ int mark_spare(struct dl *disk) - return ret_val; - } - -+ -+static int write_super_imsm_spare(struct intel_super *super, struct dl *d); -+ - static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - int fd, char *devname, - unsigned long long data_offset) -@@ -5938,9 +5941,13 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - dd->next = super->disk_mgmt_list; - super->disk_mgmt_list = dd; - } else { -+ /* this is called outside of mdmon -+ * write initial spare metadata -+ * mdmon will overwrite it. -+ */ - dd->next = super->disks; - super->disks = dd; -- super->updates_pending++; -+ write_super_imsm_spare(super, dd); - } - - return 0; -@@ -5979,15 +5986,15 @@ static union { - struct imsm_super anchor; - } spare_record __attribute__ ((aligned(MAX_SECTOR_SIZE))); - --/* spare records have their own family number and do not have any defined raid -- * devices -- */ --static int write_super_imsm_spares(struct intel_super *super, int doclose) -+ -+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; -- struct dl *d; -+ -+ if (d->index != -1) -+ return 1; - - spare->mpb_size = __cpu_to_le32(sizeof(struct imsm_super)); - spare->generation_num = __cpu_to_le32(1UL); -@@ -6000,28 +6007,41 @@ static int write_super_imsm_spares(struct intel_super *super, int doclose) - snprintf((char *) spare->sig, MAX_SIGNATURE_LENGTH, - MPB_SIGNATURE MPB_VERSION_RAID0); - -- for (d = super->disks; d; d = d->next) { -- if (d->index != -1) -- continue; -+ spare->disk[0] = d->disk; -+ if (__le32_to_cpu(d->disk.total_blocks_hi) > 0) -+ spare->attributes |= MPB_ATTRIB_2TB_DISK; - -- spare->disk[0] = d->disk; -- if (__le32_to_cpu(d->disk.total_blocks_hi) > 0) -- spare->attributes |= MPB_ATTRIB_2TB_DISK; -+ if (super->sector_size == 4096) -+ convert_to_4k_imsm_disk(&spare->disk[0]); - -- if (super->sector_size == 4096) -- convert_to_4k_imsm_disk(&spare->disk[0]); -+ sum = __gen_imsm_checksum(spare); -+ spare->family_num = __cpu_to_le32(sum); -+ spare->orig_family_num = 0; -+ sum = __gen_imsm_checksum(spare); -+ spare->check_sum = __cpu_to_le32(sum); - -- sum = __gen_imsm_checksum(spare); -- spare->family_num = __cpu_to_le32(sum); -- spare->orig_family_num = 0; -- sum = __gen_imsm_checksum(spare); -- spare->check_sum = __cpu_to_le32(sum); -+ if (store_imsm_mpb(d->fd, spare)) { -+ pr_err("failed for device %d:%d %s\n", -+ d->major, d->minor, strerror(errno)); -+ return 1; -+ } -+ -+ return 0; -+} -+/* spare records have their own family number and do not have any defined raid -+ * devices -+ */ -+static int write_super_imsm_spares(struct intel_super *super, int doclose) -+{ -+ struct dl *d; -+ -+ for (d = super->disks; d; d = d->next) { -+ if (d->index != -1) -+ continue; - -- if (store_imsm_mpb(d->fd, spare)) { -- pr_err("failed for device %d:%d %s\n", -- d->major, d->minor, strerror(errno)); -+ if (write_super_imsm_spare(super, d)) - return 1; -- } -+ - if (doclose) { - close(d->fd); - d->fd = -1; --- -2.26.2 - diff --git a/0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch b/0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch deleted file mode 100644 index 52d8eb1..0000000 --- a/0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 5cfb79dea26d9d7266f79c7c196a1a9f70c16a28 Mon Sep 17 00:00:00 2001 -From: Gioh Kim -Date: Tue, 16 Apr 2019 18:08:17 +0200 -Subject: [PATCH 74/89] Assemble: print error message if mdadm fails assembling - with --uuid option -Git-commit: 5cfb79dea26d9d7266f79c7c196a1a9f70c16a28 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -When mdadm tries to assemble one working device and one zeroed-out device, -it failed but print successful message because there is --uuid option. - -Following script always reproduce it. - -dd if=/dev/zero of=/dev/ram0 oflag=direct -dd if=/dev/zero of=/dev/ram1 oflag=direct -./mdadm -C /dev/md111 -e 1.2 --uuid="12345678:12345678:12345678:12345678" \ - -l1 -n2 /dev/ram0 /dev/ram1 -./mdadm -S /dev/md111 -dd if=/dev/zero of=/dev/ram1 oflag=direct -./mdadm -A /dev/md111 --uuid="12345678:12345678:12345678:12345678" \ - /dev/ram0 /dev/ram1 - -Following is message from mdadm. - -mdadm: No super block found on /dev/ram1 (Expected magic a92b4efc, got 00000000) -mdadm: no RAID superblock on /dev/ram1 -mdadm: /dev/md111 assembled from 1 drive - need all 2 to start it (use --run to insist). - -The mdadm say that it assembled but mdadm does not create /dev/md111. -The message is wrong. - -After applying this patch, mdadm reports error correctly as following. - -mdadm: No super block found on /dev/ram1 (Expected magic a92b4efc, got 00000000) -mdadm: no RAID superblock on /dev/ram1 -mdadm: /dev/ram1 has no superblock - assembly aborted - -Signed-off-by: Gioh Kim -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Assemble.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Assemble.c b/Assemble.c -index 6b5a7c8..2ed5884 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -269,7 +269,7 @@ static int select_devices(struct mddev_dev *devlist, - if (auto_assem || !inargv) - /* Ignore unrecognised devices during auto-assembly */ - goto loop; -- if (ident->uuid_set || ident->name[0] || -+ if (ident->name[0] || - ident->super_minor != UnSet) - /* Ignore unrecognised device if looking for - * specific array */ --- -2.26.2 - diff --git a/0080-clean-up-meaning-of-small-typo.patch b/0080-clean-up-meaning-of-small-typo.patch deleted file mode 100644 index c5e2e64..0000000 --- a/0080-clean-up-meaning-of-small-typo.patch +++ /dev/null @@ -1,33 +0,0 @@ -From ec7d7ceefc1c2b9ba82cac1ba0f6a34d41a4a913 Mon Sep 17 00:00:00 2001 -From: Nigel Croxon -Date: Mon, 4 May 2020 12:27:45 -0400 -Subject: [PATCH 75/89] clean up meaning of small typo -Git-commit: ec7d7ceefc1c2b9ba82cac1ba0f6a34d41a4a913 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Clean up the typo which leads to wrong understanding. - -Signed-off-by: Nigel Croxon -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - mdadm.8.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index a3494a1..9e7cb96 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -2878,7 +2878,7 @@ operation, as described below under LAYOUT CHANGES. - - .SS CHUNK-SIZE AND LAYOUT CHANGES - --Changing the chunk-size of layout without also changing the number of -+Changing the chunk-size or layout without also changing the number of - devices as the same time will involve re-writing all blocks in-place. - To ensure against data loss in the case of a crash, a - .B --backup-file --- -2.26.2 - diff --git a/0081-Assemble.c-respect-force-flag.patch b/0081-Assemble.c-respect-force-flag.patch deleted file mode 100644 index e893909..0000000 --- a/0081-Assemble.c-respect-force-flag.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 7b99edab2834d5d08ef774b4cff784caaa1a186f Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 5 May 2020 12:17:17 +0200 -Subject: [PATCH 76/89] Assemble.c: respect force flag. -Git-commit: 7b99edab2834d5d08ef774b4cff784caaa1a186f -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -If the array is dirty handler will set resync_start to 0 to inform kernel -that resync is needed. RWH affects only raid456 module, for other -levels array will be started even array is degraded and resync cannot be -performed. - -Force is really meaningful for raid456. If array is degraded and resync -is requested, kernel will reject an attempt to start the array. To -respect force, it has to be marked as clean (this will be done for each -array without PPL) and remove the resync request (only for raid 456). -Data corruption may occur so proper warning is added. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Assemble.c | 51 ++++++++++++++++++++++++++++++++++++++------------- - 1 file changed, 38 insertions(+), 13 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 2ed5884..3e5d4e6 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -2030,6 +2030,15 @@ int assemble_container_content(struct supertype *st, int mdfd, - free(avail); - return err; - } -+ } else if (c->force) { -+ /* Set the array as 'clean' so that we can proceed with starting -+ * it even if we don't have all devices. Mdmon doesn't care -+ * if the dirty flag is set in metadata, it will start managing -+ * it anyway. -+ * This is really important for raid456 (RWH case), other levels -+ * are started anyway. -+ */ -+ content->array.state |= 1; - } - - if (enough(content->array.level, content->array.raid_disks, -@@ -2049,20 +2058,36 @@ int assemble_container_content(struct supertype *st, int mdfd, - } - free(avail); - -- if (c->runstop <= 0 && -- (working + preexist + expansion) < -- content->array.working_disks) { -- if (c->export && result) -- *result |= INCR_UNSAFE; -- else if (c->verbose >= 0) { -- pr_err("%s assembled with %d device%s", -- chosen_name, preexist + working, -- preexist + working == 1 ? "":"s"); -- if (preexist) -- fprintf(stderr, " (%d new)", working); -- fprintf(stderr, " but not safe to start\n"); -+ if ((working + preexist + expansion) < content->array.working_disks) { -+ if (c->runstop <= 0) { -+ if (c->export && result) -+ *result |= INCR_UNSAFE; -+ else if (c->verbose >= 0) { -+ pr_err("%s assembled with %d device%s", -+ chosen_name, preexist + working, -+ preexist + working == 1 ? "":"s"); -+ if (preexist) -+ fprintf(stderr, " (%d new)", working); -+ fprintf(stderr, " but not safe to start\n"); -+ if (c->force) -+ pr_err("Consider --run to start array as degraded.\n"); -+ } -+ return 1; -+ } else if (content->array.level >= 4 && -+ content->array.level <= 6 && -+ content->resync_start != MaxSector && -+ c->force) { -+ /* Don't inform the kernel that the array is not -+ * clean and requires resync. -+ */ -+ content->resync_start = MaxSector; -+ err = sysfs_set_num(content, NULL, "resync_start", -+ MaxSector); -+ if (err) -+ return 1; -+ pr_err("%s array state forced to clean. It may cause data corruption.\n", -+ chosen_name); - } -- return 1; - } - - --- -2.26.2 - diff --git a/0082-mdcheck-Log-when-done.patch b/0082-mdcheck-Log-when-done.patch deleted file mode 100644 index 8e72f66..0000000 --- a/0082-mdcheck-Log-when-done.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 3b7aae927bdb6e150d1aaf3aaf0d183a06abda0b Mon Sep 17 00:00:00 2001 -From: Donald Buczek -Date: Wed, 13 May 2020 15:16:46 +0200 -Subject: [PATCH 77/89] mdcheck: Log when done -Git-commit: 3b7aae927bdb6e150d1aaf3aaf0d183a06abda0b -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Currently mdcheck (when called with `--duration`) logs only the -beginning of the check, the pausing and the continuation but not the -completion. - -So, log the completion, too, so that it can be determined how long the -raid check took. - - 2020-05-08T18:00:02+02:00 deadpool root: mdcheck start checking /dev/md0 - 2020-05-08T18:00:02+02:00 deadpool root: mdcheck start checking /dev/md1 - 2020-05-09T15:32:04+02:00 deadpool root: mdcheck finished checking /dev/md1 - 2020-05-09T17:38:04+02:00 deadpool root: mdcheck finished checking /dev/md0 - -Cc: linux-raid@vger.kernel.org -Signed-off-by: Paul Menzel -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - misc/mdcheck | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/misc/mdcheck b/misc/mdcheck -index 42d4094..700c3e2 100644 ---- a/misc/mdcheck -+++ b/misc/mdcheck -@@ -125,11 +125,13 @@ do - do - eval fl=\$MD_${i}_fl - eval sys=\$MD_${i}_sys -+ eval dev=\$MD_${i}_dev - - if [ -z "$fl" ]; then continue; fi - - if [ "`cat $sys/md/sync_action`" != 'check' ] - then -+ logger -p daemon.info mdcheck finished checking $dev - eval MD_${i}_fl= - rm -f $fl - continue; --- -2.26.2 - diff --git a/0083-Makefile-add-EXTRAVERSION-support.patch b/0083-Makefile-add-EXTRAVERSION-support.patch deleted file mode 100644 index 8610db6..0000000 --- a/0083-Makefile-add-EXTRAVERSION-support.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 03ab9763f51ddf2030f60f83e76cf9c1b50b726c Mon Sep 17 00:00:00 2001 -From: Tkaczyk Mariusz -Date: Fri, 15 May 2020 11:23:14 +0200 -Subject: [PATCH 78/89] Makefile: add EXTRAVERSION support -Git-commit: 03ab9763f51ddf2030f60f83e76cf9c1b50b726c -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Add optional EXTRAVERSION parameter to Makefile and allow to mark version -by user friendly label. It might be useful when creating custom -spins of mdadm, or labeling some instance in between major releases. - -Signed-off-by: Tkaczyk Mariusz -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Makefile | 3 ++- - ReadMe.c | 5 ++++- - 2 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/Makefile b/Makefile -index a33319a..0a20b75 100644 ---- a/Makefile -+++ b/Makefile -@@ -105,7 +105,8 @@ VERSION = $(shell [ -d .git ] && git describe HEAD | sed 's/mdadm-//') - VERS_DATE = $(shell [ -d .git ] && date --iso-8601 --date="`git log -n1 --format=format:%cd --date=iso --date=short`") - DVERS = $(if $(VERSION),-DVERSION=\"$(VERSION)\",) - DDATE = $(if $(VERS_DATE),-DVERS_DATE="\"$(VERS_DATE)\"",) --CFLAGS += $(DVERS) $(DDATE) -+DEXTRAVERSION = $(if $(EXTRAVERSION),-DEXTRAVERSION="\" - $(EXTRAVERSION)\"",) -+CFLAGS += $(DVERS) $(DDATE) $(DEXTRAVERSION) - - # The glibc TLS ABI requires applications that call clone(2) to set up - # TLS data structures, use pthreads until mdmon implements this support -diff --git a/ReadMe.c b/ReadMe.c -index eaf1042..06b8f7e 100644 ---- a/ReadMe.c -+++ b/ReadMe.c -@@ -33,7 +33,10 @@ - #ifndef VERS_DATE - #define VERS_DATE "2018-10-01" - #endif --char Version[] = "mdadm - v" VERSION " - " VERS_DATE "\n"; -+#ifndef EXTRAVERSION -+#define EXTRAVERSION "" -+#endif -+char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n"; - - /* - * File: ReadMe.c --- -2.26.2 - diff --git a/0084-uuid.c-split-uuid-stuffs-from-util.c.patch b/0084-uuid.c-split-uuid-stuffs-from-util.c.patch deleted file mode 100644 index 6faa6f2..0000000 --- a/0084-uuid.c-split-uuid-stuffs-from-util.c.patch +++ /dev/null @@ -1,288 +0,0 @@ -From f4c8a605d2467c0ed25fcba5d27dd56540660e55 Mon Sep 17 00:00:00 2001 -From: Guoqing Jiang -Date: Mon, 18 May 2020 23:53:35 +0200 -Subject: [PATCH 79/89] uuid.c: split uuid stuffs from util.c -Git-commit: f4c8a605d2467c0ed25fcba5d27dd56540660e55 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Currently, 'make raid6check' is build broken since commit b06815989 -("mdadm: load default sysfs attributes after assemblation"). - -/usr/bin/ld: sysfs.o: in function `sysfsline': -sysfs.c:(.text+0x2707): undefined reference to `parse_uuid' -/usr/bin/ld: sysfs.c:(.text+0x271a): undefined reference to `uuid_zero' -/usr/bin/ld: sysfs.c:(.text+0x2721): undefined reference to `uuid_zero' - -Apparently, the compile of mdadm or raid6check are coupled with uuid -functions inside util.c. However, we can't just add util.o to CHECK_OBJS -which raid6check is needed, because it caused other worse problems. - -So, let's introduce a uuid.c file which is indenpended file to fix the -problem, all the contents are splitted from util.c. - -Signed-off-by: Guoqing Jiang -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Makefile | 6 +-- - util.c | 87 ------------------------------------------ - uuid.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 115 insertions(+), 90 deletions(-) - create mode 100644 uuid.c - -diff --git a/Makefile b/Makefile -index 0a20b75..15d05d1 100644 ---- a/Makefile -+++ b/Makefile -@@ -140,7 +140,7 @@ else - ECHO=: - endif - --OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o maps.o lib.o \ -+OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o uuid.o util.o maps.o lib.o \ - Manage.o Assemble.o Build.o \ - Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \ - Incremental.o Dump.o \ -@@ -149,13 +149,13 @@ OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o maps.o lib.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 - --CHECK_OBJS = restripe.o sysfs.o maps.o lib.o xmalloc.o dlink.o -+CHECK_OBJS = restripe.o uuid.o sysfs.o maps.o lib.o xmalloc.o dlink.o - - SRCS = $(patsubst %.o,%.c,$(OBJS)) - - INCL = mdadm.h part.h bitmap.h - --MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \ -+MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o \ - policy.o lib.o \ - Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \ - super-mbr.o super-gpt.o \ -diff --git a/util.c b/util.c -index 07f9dc3..579dd42 100644 ---- a/util.c -+++ b/util.c -@@ -306,43 +306,6 @@ int md_get_disk_info(int fd, struct mdu_disk_info_s *disk) - return ioctl(fd, GET_DISK_INFO, disk); - } - --/* -- * Parse a 128 bit uuid in 4 integers -- * format is 32 hexx nibbles with options :. separator -- * If not exactly 32 hex digits are found, return 0 -- * else return 1 -- */ --int parse_uuid(char *str, int uuid[4]) --{ -- int hit = 0; /* number of Hex digIT */ -- int i; -- char c; -- for (i = 0; i < 4; i++) -- uuid[i] = 0; -- -- while ((c = *str++) != 0) { -- int n; -- if (c >= '0' && c <= '9') -- n = c-'0'; -- else if (c >= 'a' && c <= 'f') -- n = 10 + c - 'a'; -- else if (c >= 'A' && c <= 'F') -- n = 10 + c - 'A'; -- else if (strchr(":. -", c)) -- continue; -- else return 0; -- -- if (hit<32) { -- uuid[hit/8] <<= 4; -- uuid[hit/8] += n; -- } -- hit++; -- } -- if (hit == 32) -- return 1; -- return 0; --} -- - int get_linux_version() - { - struct utsname name; -@@ -611,56 +574,6 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail) - } - } - --const int uuid_zero[4] = { 0, 0, 0, 0 }; -- --int same_uuid(int a[4], int b[4], int swapuuid) --{ -- if (swapuuid) { -- /* parse uuids are hostendian. -- * uuid's from some superblocks are big-ending -- * if there is a difference, we need to swap.. -- */ -- unsigned char *ac = (unsigned char *)a; -- unsigned char *bc = (unsigned char *)b; -- int i; -- for (i = 0; i < 16; i += 4) { -- if (ac[i+0] != bc[i+3] || -- ac[i+1] != bc[i+2] || -- ac[i+2] != bc[i+1] || -- ac[i+3] != bc[i+0]) -- return 0; -- } -- return 1; -- } else { -- if (a[0]==b[0] && -- a[1]==b[1] && -- a[2]==b[2] && -- a[3]==b[3]) -- return 1; -- return 0; -- } --} -- --void copy_uuid(void *a, int b[4], int swapuuid) --{ -- if (swapuuid) { -- /* parse uuids are hostendian. -- * uuid's from some superblocks are big-ending -- * if there is a difference, we need to swap.. -- */ -- unsigned char *ac = (unsigned char *)a; -- unsigned char *bc = (unsigned char *)b; -- int i; -- for (i = 0; i < 16; i += 4) { -- ac[i+0] = bc[i+3]; -- ac[i+1] = bc[i+2]; -- ac[i+2] = bc[i+1]; -- ac[i+3] = bc[i+0]; -- } -- } else -- memcpy(a, b, 16); --} -- - char *__fname_from_uuid(int id[4], int swap, char *buf, char sep) - { - int i, j; -diff --git a/uuid.c b/uuid.c -new file mode 100644 -index 0000000..94b5abd ---- /dev/null -+++ b/uuid.c -@@ -0,0 +1,112 @@ -+/* -+ * mdadm - manage Linux "md" devices aka RAID arrays. -+ * -+ * Copyright (C) 2001-2013 Neil Brown -+ * -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ * -+ * Author: Neil Brown -+ * Email: -+ */ -+ -+#include -+ -+const int uuid_zero[4] = { 0, 0, 0, 0 }; -+ -+int same_uuid(int a[4], int b[4], int swapuuid) -+{ -+ if (swapuuid) { -+ /* parse uuids are hostendian. -+ * uuid's from some superblocks are big-ending -+ * if there is a difference, we need to swap.. -+ */ -+ unsigned char *ac = (unsigned char *)a; -+ unsigned char *bc = (unsigned char *)b; -+ int i; -+ for (i = 0; i < 16; i += 4) { -+ if (ac[i+0] != bc[i+3] || -+ ac[i+1] != bc[i+2] || -+ ac[i+2] != bc[i+1] || -+ ac[i+3] != bc[i+0]) -+ return 0; -+ } -+ return 1; -+ } else { -+ if (a[0]==b[0] && -+ a[1]==b[1] && -+ a[2]==b[2] && -+ a[3]==b[3]) -+ return 1; -+ return 0; -+ } -+} -+ -+void copy_uuid(void *a, int b[4], int swapuuid) -+{ -+ if (swapuuid) { -+ /* parse uuids are hostendian. -+ * uuid's from some superblocks are big-ending -+ * if there is a difference, we need to swap.. -+ */ -+ unsigned char *ac = (unsigned char *)a; -+ unsigned char *bc = (unsigned char *)b; -+ int i; -+ for (i = 0; i < 16; i += 4) { -+ ac[i+0] = bc[i+3]; -+ ac[i+1] = bc[i+2]; -+ ac[i+2] = bc[i+1]; -+ ac[i+3] = bc[i+0]; -+ } -+ } else -+ memcpy(a, b, 16); -+} -+ -+/* -+ * Parse a 128 bit uuid in 4 integers -+ * format is 32 hexx nibbles with options :. separator -+ * If not exactly 32 hex digits are found, return 0 -+ * else return 1 -+ */ -+int parse_uuid(char *str, int uuid[4]) -+{ -+ int hit = 0; /* number of Hex digIT */ -+ int i; -+ char c; -+ for (i = 0; i < 4; i++) -+ uuid[i] = 0; -+ -+ while ((c = *str++) != 0) { -+ int n; -+ if (c >= '0' && c <= '9') -+ n = c-'0'; -+ else if (c >= 'a' && c <= 'f') -+ n = 10 + c - 'a'; -+ else if (c >= 'A' && c <= 'F') -+ n = 10 + c - 'A'; -+ else if (strchr(":. -", c)) -+ continue; -+ else return 0; -+ -+ if (hit<32) { -+ uuid[hit/8] <<= 4; -+ uuid[hit/8] += n; -+ } -+ hit++; -+ } -+ if (hit == 32) -+ return 1; -+ return 0; -+} --- -2.26.2 - diff --git a/0085-Include-count-for-0-character-when-using-strncpy-to-.patch b/0085-Include-count-for-0-character-when-using-strncpy-to-.patch deleted file mode 100644 index 5d4f67f..0000000 --- a/0085-Include-count-for-0-character-when-using-strncpy-to-.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 7d90f7603af6b59e7144cef6617a1e9dd42161bd Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Mon, 18 May 2020 20:19:53 -0400 -Subject: [PATCH 80/89] Include count for \0 character when using strncpy to - implement strdup. -Git-commit: 7d90f7603af6b59e7144cef6617a1e9dd42161bd -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -We have to include the \0 character in the length when copying a -string with strncpy() for which length was found with strlen(). -Otherwise the destination will not get null terminated - except that -we explicitly zeroed it out earlier. - -This quiets down the compiler's warnings. - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - dlink.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/dlink.c b/dlink.c -index 3efa94b..69aa7aa 100644 ---- a/dlink.c -+++ b/dlink.c -@@ -63,7 +63,7 @@ char *dl_strndup(char *s, int l) - if (s == NULL) - return NULL; - n = dl_newv(char, l+1); -- strncpy(n, s, l); -+ strncpy(n, s, l+1); - n[l] = 0; - return n; - } --- -2.26.2 - diff --git a/0086-restripe-fix-ignoring-return-value-of-read-and-lseek.patch b/0086-restripe-fix-ignoring-return-value-of-read-and-lseek.patch deleted file mode 100644 index fe492d1..0000000 --- a/0086-restripe-fix-ignoring-return-value-of-read-and-lseek.patch +++ /dev/null @@ -1,53 +0,0 @@ -From d92cee7b374db9944b63bdd6c1784a2dd90ee9ca Mon Sep 17 00:00:00 2001 -From: Guoqing Jiang -Date: Mon, 18 May 2020 23:53:36 +0200 -Subject: [PATCH 81/89] restripe: fix ignoring return value of read and lseek -Commit: d92cee7b374db9944b63bdd6c1784a2dd90ee9ca -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Got below error when run "make everything". - -restripe.c: In function test_stripes: -restripe.c:870:4: error: ignoring return value of read, declared with attribute warn_unused_result [-Werror=unused-result] - read(source[i], stripes[i], chunk_size); - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Fix it by check the return value of read, and free memory -in the failure case. - -And check the return value of lseek as well per Jes's comment. - -Signed-off-by: Guoqing Jiang -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - restripe.c | 12 ++++++++++-- - 1 file changed, 10 insertions(+), 2 deletions(-) - -diff --git a/restripe.c b/restripe.c -index 31b07e8..86e1d00 100644 ---- a/restripe.c -+++ b/restripe.c -@@ -866,8 +866,16 @@ int test_stripes(int *source, unsigned long long *offsets, - int disk; - - for (i = 0 ; i < raid_disks ; i++) { -- lseek64(source[i], offsets[i]+start, 0); -- read(source[i], stripes[i], chunk_size); -+ if ((lseek64(source[i], offsets[i]+start, 0) < 0) || -+ (read(source[i], stripes[i], chunk_size) != -+ chunk_size)) { -+ free(q); -+ free(p); -+ free(blocks); -+ free(stripes); -+ free(stripe_buf); -+ return -1; -+ } - } - for (i = 0 ; i < data_disks ; i++) { - int disk = geo_map(i, start/chunk_size, raid_disks, --- -2.26.2 - diff --git a/0087-Block-overwriting-existing-links-while-manual-assemb.patch b/0087-Block-overwriting-existing-links-while-manual-assemb.patch deleted file mode 100644 index 3c97e57..0000000 --- a/0087-Block-overwriting-existing-links-while-manual-assemb.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 7758ada9f3872cc9cb4c76c733dbc553562b3d7d Mon Sep 17 00:00:00 2001 -From: Kinga Tanska -Date: Fri, 29 May 2020 08:31:36 +0200 -Subject: [PATCH 82/89] Block overwriting existing links while manual assembly -Commit: 7758ada9f3872cc9cb4c76c733dbc553562b3d7d -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Manual assembly with existing link caused overwriting -this link. Add checking link and block this situation. - -Signed-off-by: Kinga Tanska -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Assemble.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/Assemble.c b/Assemble.c -index 3e5d4e6..ed0ddfb 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1482,6 +1482,10 @@ try_again: - name = content->name; - break; - } -+ if (mddev && map_by_name(&map, mddev) != NULL) { -+ pr_err("Cannot create device with %s because is in use\n", mddev); -+ goto out; -+ } - if (!auto_assem) - /* If the array is listed in mdadm.conf or on - * command line, then we trust the name --- -2.26.2 - diff --git a/0088-Detect-too-small-device-error-rather-than-underflow-.patch b/0088-Detect-too-small-device-error-rather-than-underflow-.patch deleted file mode 100644 index 943bfd7..0000000 --- a/0088-Detect-too-small-device-error-rather-than-underflow-.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 2cf0433063203fca10d26629c9e090b51fb1d806 Mon Sep 17 00:00:00 2001 -From: David Favro -Date: Sat, 23 May 2020 08:24:59 -0400 -Subject: [PATCH 83/89] Detect too-small device: error rather than - underflow/crash -Commit: 2cf0433063203fca10d26629c9e090b51fb1d806 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -For 1.x metadata, when the user requested creation of an array on -component devices that were too small even to hold the superblock, -an undetected integer wraparound (underflow) resulted in an enormous -computed size which resulted in various follow-on errors such as -floating-point exception. - -This patch detects this condition, prints a reasonable diagnostic -message, and refuses to continue. - -Signed-off-by: David Favro -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - super1.c | 19 ++++++++++++++----- - 1 file changed, 14 insertions(+), 5 deletions(-) - -diff --git a/super1.c b/super1.c -index e0d80be..7664883 100644 ---- a/super1.c -+++ b/super1.c -@@ -2753,6 +2753,7 @@ static int validate_geometry1(struct supertype *st, int level, - unsigned long long ldsize, devsize; - int bmspace; - unsigned long long headroom; -+ unsigned long long overhead; - int fd; - - if (level == LEVEL_CONTAINER) { -@@ -2785,10 +2786,6 @@ static int validate_geometry1(struct supertype *st, int level, - close(fd); - - devsize = ldsize >> 9; -- if (devsize < 24) { -- *freesize = 0; -- return 0; -- } - - /* creating: allow suitable space for bitmap or PPL */ - if (consistency_policy == CONSISTENCY_POLICY_PPL) -@@ -2829,15 +2826,27 @@ static int validate_geometry1(struct supertype *st, int level, - case 0: /* metadata at end. Round down and subtract space to reserve */ - devsize = (devsize & ~(4ULL*2-1)); - /* space for metadata, bblog, bitmap/ppl */ -- devsize -= 8*2 + 8 + bmspace; -+ overhead = 8*2 + 8 + bmspace; -+ if (devsize < overhead) /* detect underflow */ -+ goto dev_too_small_err; -+ devsize -= overhead; - break; - case 1: - case 2: -+ if (devsize < data_offset) /* detect underflow */ -+ goto dev_too_small_err; - devsize -= data_offset; - break; - } - *freesize = devsize; - return 1; -+ -+/* Error condition, device cannot even hold the overhead. */ -+dev_too_small_err: -+ fprintf(stderr, "device %s is too small (%lluK) for " -+ "required metadata!\n", subdev, devsize>>1); -+ *freesize = 0; -+ return 0; - } - - void *super1_make_v0(struct supertype *st, struct mdinfo *info, mdp_super_t *sb0) --- -2.26.2 - diff --git a/0089-Use-more-secure-HTTPS-URLs.patch b/0089-Use-more-secure-HTTPS-URLs.patch deleted file mode 100644 index aca0bd5..0000000 --- a/0089-Use-more-secure-HTTPS-URLs.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 8e41153c91cdce696618c527906648625217470c Mon Sep 17 00:00:00 2001 -From: Paul Menzel -Date: Thu, 28 May 2020 16:52:24 +0200 -Subject: [PATCH 84/89] Use more secure HTTPS URLs -Commit: 8e41153c91cdce696618c527906648625217470c -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -All URLs in the source are available over HTTPS, so convert all URLs to -HTTPS with the command below. - - git grep -l 'http://' | xargs sed -i 's,http://,https://,g' - -Revert the changes to announcement files `ANNOUNCE-*` as requested by -the maintainer. - -Cc: linux-raid@vger.kernel.org -Signed-off-by: Paul Menzel -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - external-reshape-design.txt | 2 +- - mdadm.8.in | 6 +++--- - mdadm.spec | 4 ++-- - raid6check.8 | 2 +- - restripe.c | 2 +- - udev-md-raid-safe-timeouts.rules | 2 +- - 6 files changed, 9 insertions(+), 9 deletions(-) - -diff --git a/external-reshape-design.txt b/external-reshape-design.txt -index 10c57cc..e4cf4e1 100644 ---- a/external-reshape-design.txt -+++ b/external-reshape-design.txt -@@ -277,4 +277,4 @@ sync_action - - ... - --[1]: Linux kernel design patterns - part 3, Neil Brown http://lwn.net/Articles/336262/ -+[1]: Linux kernel design patterns - part 3, Neil Brown https://lwn.net/Articles/336262/ -diff --git a/mdadm.8.in b/mdadm.8.in -index 9e7cb96..7f32762 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -367,7 +367,7 @@ Use the Intel(R) Matrix Storage Manager metadata format. This creates a - which is managed in a similar manner to DDF, and is supported by an - option-rom on some platforms: - .IP --.B http://www.intel.com/design/chipsets/matrixstorage_sb.htm -+.B https://www.intel.com/design/chipsets/matrixstorage_sb.htm - .PP - .RE - -@@ -3407,7 +3407,7 @@ was previously known as - For further information on mdadm usage, MD and the various levels of - RAID, see: - .IP --.B http://raid.wiki.kernel.org/ -+.B https://raid.wiki.kernel.org/ - .PP - (based upon Jakob \(/Ostergaard's Software\-RAID.HOWTO) - .PP -@@ -3415,7 +3415,7 @@ The latest version of - .I mdadm - should always be available from - .IP --.B http://www.kernel.org/pub/linux/utils/raid/mdadm/ -+.B https://www.kernel.org/pub/linux/utils/raid/mdadm/ - .PP - Related man pages: - .PP -diff --git a/mdadm.spec b/mdadm.spec -index 1c66894..506ea33 100644 ---- a/mdadm.spec -+++ b/mdadm.spec -@@ -2,8 +2,8 @@ Summary: mdadm is used for controlling Linux md devices (aka RAID arrays) - Name: mdadm - Version: 4.1 - Release: 1 --Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.gz --URL: http://neil.brown.name/blog/mdadm -+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 -diff --git a/raid6check.8 b/raid6check.8 -index 5003343..8999ca8 100644 ---- a/raid6check.8 -+++ b/raid6check.8 -@@ -86,7 +86,7 @@ The latest version of - .I raid6check - should always be available from - .IP --.B http://www.kernel.org/pub/linux/utils/raid/mdadm/ -+.B https://www.kernel.org/pub/linux/utils/raid/mdadm/ - .PP - Related man pages: - .PP -diff --git a/restripe.c b/restripe.c -index 86e1d00..a7a7229 100644 ---- a/restripe.c -+++ b/restripe.c -@@ -333,7 +333,7 @@ void make_tables(void) - - /* Compute log and inverse log */ - /* Modified code from: -- * http://web.eecs.utk.edu/~plank/plank/papers/CS-96-332.html -+ * https://web.eecs.utk.edu/~plank/plank/papers/CS-96-332.html - */ - b = 1; - raid6_gflog[0] = 0; -diff --git a/udev-md-raid-safe-timeouts.rules b/udev-md-raid-safe-timeouts.rules -index 13c23d8..12bdcaa 100644 ---- a/udev-md-raid-safe-timeouts.rules -+++ b/udev-md-raid-safe-timeouts.rules -@@ -13,7 +13,7 @@ - # - # You should have received a copy of the GNU General Public License - # along with mdraid-safe-timeouts. If not, see --# . -+# . - - # This file causes block devices with Linux RAID (mdadm) signatures to - # attempt to set safe timeouts for the drives involved --- -2.26.2 - diff --git a/0090-Update-link-to-Intel-page-for-IMSM.patch b/0090-Update-link-to-Intel-page-for-IMSM.patch deleted file mode 100644 index b1c9836..0000000 --- a/0090-Update-link-to-Intel-page-for-IMSM.patch +++ /dev/null @@ -1,32 +0,0 @@ -From bcf40dbb5bf7db9d55a877b805ebb95c2008a132 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen -Date: Fri, 12 Jun 2020 10:49:11 -0400 -Subject: [PATCH 85/89] Update link to Intel page for IMSM -Commit: bcf40dbb5bf7db9d55a877b805ebb95c2008a132 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -The old design page is gone, so update to the current overview page. - -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - mdadm.8.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index 7f32762..1474602 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -367,7 +367,7 @@ Use the Intel(R) Matrix Storage Manager metadata format. This creates a - which is managed in a similar manner to DDF, and is supported by an - option-rom on some platforms: - .IP --.B https://www.intel.com/design/chipsets/matrixstorage_sb.htm -+.B https://www.intel.com/content/www/us/en/support/products/122484/memory-and-storage/ssd-software/intel-virtual-raid-on-cpu-intel-vroc.html - .PP - .RE - --- -2.26.2 - diff --git a/0091-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch b/0091-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch deleted file mode 100644 index c762ff4..0000000 --- a/0091-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 77b72fa828132a35c8b2e08d3fb07eea80b11895 Mon Sep 17 00:00:00 2001 -From: allenpeng -Date: Fri, 12 Jun 2020 17:00:39 +0800 -Subject: [PATCH 86/89] mdadm/Grow: prevent md's fd from being occupied during - delayed time -Commit: 77b72fa828132a35c8b2e08d3fb07eea80b11895 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -If we start reshaping on md which shares sub-devices with another -resyncing md, it may be forced to wait for others to complete. mdadm -occupies the md's fd during this time, which causes the md can not be -stopped and the filesystem can not be mounted on the md. We can close -md's fd earlier to solve this problem. - -Reproducible Steps: - -1. create two partitions on sda, sdb, sdc, sdd -2. create raid1 with sda1, sdb1 -mdadm -C /dev/md1 --assume-clean -l1 -n2 /dev/sda1 /dev/sdb1 -3. create raid5 with sda2, sdb2, sdc2 -mdadm -C /dev/md2 --assume-clean -l5 -n3 /dev/sda2 /dev/sdb2 /dev/sdc2 -4. start resync at md1 -echo repair > /sys/block/md1/md/sync_action -5. reshape raid5 to raid6 -mdadm -a /dev/md2 /dev/sdd2 -mdadm --grow /dev/md2 -n4 -l6 --backup-file=/root/md2-backup - -Now mdadm is occupying the fd of md2, causing md2 unable to be stopped - -6.Try to stop md2, an error message shows -mdadm -S /dev/md2 -mdadm: Cannot get exclusive access to /dev/md3:Perhaps a running process, -mounted filesystem or active volume group? - -Reviewed-by: Alex Wu -Reviewed-by: BingJing Chang -Reviewed-by: Danny Shih -Signed-off-by: ChangSyun Peng -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - Grow.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Grow.c b/Grow.c -index 764374f..57db7d4 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -3517,6 +3517,7 @@ started: - return 0; - } - -+ close(fd); - /* 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. -@@ -3569,7 +3570,6 @@ started: - mdstat_wait(30 - (delayed-1) * 25); - } while (delayed); - mdstat_close(); -- close(fd); - if (check_env("MDADM_GROW_VERIFY")) - fd = open(devname, O_RDONLY | O_DIRECT); - else --- -2.26.2 - diff --git a/0092-Specify-nodes-number-when-updating-cluster-nodes.patch b/0092-Specify-nodes-number-when-updating-cluster-nodes.patch deleted file mode 100644 index 49ff568..0000000 --- a/0092-Specify-nodes-number-when-updating-cluster-nodes.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 138a9e9bbe2622eafc90c976b82f3d84895dbebd Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Mon, 27 Jul 2020 09:14:20 +0800 -Subject: [PATCH 87/89] Specify nodes number when updating cluster nodes -Commit: 138a9e9bbe2622eafc90c976b82f3d84895dbebd -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Now it allows updating cluster nodes without specify --nodes. It can write superblock -with zero nodes. It can break the current cluster. Add this check to avoid this problem. - -v2: It needs check c.update first to avoid NULL pointer reference -v3: Wol points the typo error - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - mdadm.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/mdadm.c b/mdadm.c -index 13dc24e..1b3467f 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -1433,6 +1433,11 @@ int main(int argc, char *argv[]) - } - } - -+ if (c.update && strcmp(c.update, "nodes") == 0 && c.nodes == 0) { -+ pr_err("Please specify nodes number with --nodes\n"); -+ exit(1); -+ } -+ - if (c.backup_file && data_offset != INVALID_SECTORS) { - pr_err("--backup-file and --data-offset are incompatible\n"); - exit(2); --- -2.26.2 - diff --git a/0093-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch b/0093-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch deleted file mode 100644 index b899892..0000000 --- a/0093-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 5e592e1ed809b94670872b7a4629317fc1c8a5c1 Mon Sep 17 00:00:00 2001 -From: Winston Weinert -Date: Wed, 22 Jul 2020 08:33:22 -0500 -Subject: [PATCH 88/89] mdadm/md.4: update path to in-kernel-tree documentation -Commit: 5e592e1ed809b94670872b7a4629317fc1c8a5c1 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -Documentation/md.txt was renamed to Documentation/admin-guide/md.rst -in linux commit 9d85025b0418163fae079c9ba8f8445212de8568 (Oct 26, -2016). - -Signed-off-by: Winston Weinert -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - md.4 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/md.4 b/md.4 -index 0712af2..aecff38 100644 ---- a/md.4 -+++ b/md.4 -@@ -1061,7 +1061,7 @@ which contains various files for providing access to information about - the array. - - This interface is documented more fully in the file --.B Documentation/md.txt -+.B Documentation/admin-guide/md.rst - which is distributed with the kernel sources. That file should be - consulted for full documentation. The following are just a selection - of attribute files that are available. --- -2.26.2 - diff --git a/0094-manual-update-examine-badblocks.patch b/0094-manual-update-examine-badblocks.patch deleted file mode 100644 index 3fe8839..0000000 --- a/0094-manual-update-examine-badblocks.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 5f4184557a98bb641a7889e280265109c73e2f43 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Thu, 6 Aug 2020 13:57:50 +0200 -Subject: [PATCH 89/89] manual: update --examine-badblocks -Commit: 5f4184557a98bb641a7889e280265109c73e2f43 -Patch-mainline: mdadm-4.1+ -References: jsc#SLE-13700 - -IMSM also supports it. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - mdadm.8.in | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index 1474602..ab832e8 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -1695,9 +1695,11 @@ does not report the bitmap for that array. - .TP - .B \-\-examine\-badblocks - List the bad-blocks recorded for the device, if a bad-blocks list has --been configured. Currently only -+been configured. Currently only - .B 1.x --metadata supports bad-blocks lists. -+and -+.B IMSM -+metadata support bad-blocks lists. - - .TP - .BI \-\-dump= directory --- -2.26.2 - diff --git a/0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch b/0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch deleted file mode 100644 index 120b7f2..0000000 --- a/0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 64bf4dff34301a4b44883a8bc03f7835faef121e Mon Sep 17 00:00:00 2001 -From: Lidong Zhong -Date: Mon, 14 Sep 2020 10:52:18 +0800 -Subject: [PATCH 01/17] Detail: show correct raid level when the array is - inactive -Git-commit: 64bf4dff34301a4b44883a8bc03f7835faef121e -References: jsc#SLE-13700 - -Sometimes the raid level in the output of `mdadm -D /dev/mdX` is -misleading when the array is in inactive state. Here is a testcase for -introduction. -1\ creating a raid1 device with two disks. Specify a different hostname -rather than the real one for later verfication. - -node1:~ # mdadm --create /dev/md0 --homehost TESTARRAY -o -l 1 -n 2 /dev/sdb -/dev/sdc -2\ remove one of the devices and reboot -3\ show the detail of raid1 device - -node1:~ # mdadm -D /dev/md127 -/dev/md127: Version : 1.2 - Raid Level : raid0 - Total Devices : 1 - Persistence : Superblock is persistent - State : inactive -Working Devices : 1 - -You can see that the "Raid Level" in /dev/md127 is raid0 now. -After step 2\ is done, the degraded raid1 device is recognized -as a "foreign" array in 64-md-raid-assembly.rules. And thus the -timer to activate the raid1 device is not triggered. The array -level returned from GET_ARRAY_INFO ioctl is 0. And the string -shown for "Raid Level" is -str = map_num(pers, array.level); -And the definition of pers is -mapping_t pers[] = { -{ "linear", LEVEL_LINEAR}, -{ "raid0", 0}, -{ "0", 0} -... -So the misleading "raid0" is shown in this testcase. - -Changelog: -V1: don't show "Raid Level" when array is inactive -Signed-off-by: Lidong Zhong -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Detail.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index 24eeba0..b6587c8 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -224,7 +224,10 @@ int Detail(char *dev, struct context *c) - } - - /* Ok, we have some info to print... */ -- str = map_num(pers, array.level); -+ if (inactive) -+ str = map_num(pers, info->array.level); -+ else -+ str = map_num(pers, array.level); - - if (c->export) { - if (array.raid_disks) { --- -2.26.2 - diff --git a/0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch b/0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch deleted file mode 100644 index e72e97e..0000000 --- a/0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 2ce091724031e18f522994ffd1e5eb0dc404bcba Mon Sep 17 00:00:00 2001 -From: Xiao Ni -Date: Tue, 15 Sep 2020 15:44:42 +0800 -Subject: [PATCH 02/17] Don't create bitmap for raid5 with journal disk -Git-commit: 2ce091724031e18f522994ffd1e5eb0dc404bcba -References: jsc#SLE-13700 - -Journal disk and bitmap can't exist at the same time. It needs to check if the raid -has a journal disk when creating bitmap. - -Signed-off-by: Xiao Ni -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Create.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Create.c b/Create.c -index 6f84e5b..0efa19c 100644 ---- a/Create.c -+++ b/Create.c -@@ -542,6 +542,7 @@ int Create(struct supertype *st, char *mddev, - if (!s->bitmap_file && - s->level >= 1 && - st->ss->add_internal_bitmap && -+ s->journaldisks == 0 && - (s->consistency_policy != CONSISTENCY_POLICY_RESYNC && - s->consistency_policy != CONSISTENCY_POLICY_PPL) && - (s->write_behind || s->size > 100*1024*1024ULL)) { --- -2.26.2 - diff --git a/0097-Monitor-refresh-mdstat-fd-after-select.patch b/0097-Monitor-refresh-mdstat-fd-after-select.patch deleted file mode 100644 index d7f93c2..0000000 --- a/0097-Monitor-refresh-mdstat-fd-after-select.patch +++ /dev/null @@ -1,74 +0,0 @@ -From e2308733910a157b0a4d4e78721f239d44b91a24 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 9 Sep 2020 10:31:17 +0200 -Subject: [PATCH 03/17] Monitor: refresh mdstat fd after select -Git-commit: e2308733910a157b0a4d4e78721f239d44b91a24 -References: jsc#SLE-13700 - -After 52209d6ee118 ("Monitor: release /proc/mdstat fd when no arrays -present") mdstat fd is closed if mdstat is empty or cannot be opened. -It causes that monitor is not able to select on mdstat. Select -doesn't fail because it gets valid descriptor to a different resource. -As a result any new event will be unnoticed until timeout (delay). - -Refresh mdstat after wake up, don't poll on wrong resource. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Monitor.c | 6 +++--- - mdstat.c | 4 ++-- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index 2d6b3b9..80a3200 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -216,8 +216,6 @@ int Monitor(struct mddev_dev *devlist, - if (mdstat) - free_mdstat(mdstat); - mdstat = mdstat_read(oneshot ? 0 : 1, 0); -- if (!mdstat) -- mdstat_close(); - - for (st = statelist; st; st = st->next) - if (check_array(st, mdstat, c->test, &info, -@@ -238,8 +236,10 @@ int Monitor(struct mddev_dev *devlist, - if (!new_found) { - if (oneshot) - break; -- else -+ else { - mdstat_wait(c->delay); -+ mdstat_close(); -+ } - } - c->test = 0; - -diff --git a/mdstat.c b/mdstat.c -index 20577a3..48559e6 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -135,7 +135,6 @@ struct mdstat_ent *mdstat_read(int hold, int start) - if (hold && mdstat_fd != -1) { - off_t offset = lseek(mdstat_fd, 0L, 0); - if (offset == (off_t)-1) { -- mdstat_close(); - return NULL; - } - fd = dup(mdstat_fd); -@@ -312,7 +311,8 @@ void mdstat_wait(int seconds) - if (mdstat_fd >= 0) { - FD_SET(mdstat_fd, &fds); - maxfd = mdstat_fd; -- } -+ } else -+ return; - tm.tv_sec = seconds; - tm.tv_usec = 0; - select(maxfd + 1, NULL, NULL, &fds, &tm); --- -2.26.2 - diff --git a/0098-Monitor-stop-notifing-about-containers.patch b/0098-Monitor-stop-notifing-about-containers.patch deleted file mode 100644 index f8cb767..0000000 --- a/0098-Monitor-stop-notifing-about-containers.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 007087d0898a045901e4e120296e6d9b845b20a6 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 9 Sep 2020 10:31:18 +0200 -Subject: [PATCH 04/17] Monitor: stop notifing about containers. -Git-commit: 007087d0898a045901e4e120296e6d9b845b20a6 -References: jsc#SLE-13700 - -Stop reporting any events from container but still track them, -it is important for spare migration. -Stop mdmonitor if no redundant array is presented in mdstat. -There is nothing to follow. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Monitor.c | 19 ++++++++++++++++--- - 1 file changed, 16 insertions(+), 3 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index 80a3200..aed7a69 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -212,15 +212,24 @@ int Monitor(struct mddev_dev *devlist, - int new_found = 0; - struct state *st, **stp; - int anydegraded = 0; -+ int anyredundant = 0; - - if (mdstat) - free_mdstat(mdstat); - mdstat = mdstat_read(oneshot ? 0 : 1, 0); - -- for (st = statelist; st; st = st->next) -+ for (st = statelist; st; st = st->next) { - if (check_array(st, mdstat, c->test, &info, - increments, c->prefer)) - anydegraded = 1; -+ /* for external arrays, metadata is filled for -+ * containers only -+ */ -+ if (st->metadata && st->metadata->ss->external) -+ continue; -+ if (st->err == 0 && !anyredundant) -+ anyredundant = 1; -+ } - - /* now check if there are any new devices found in mdstat */ - if (c->scan) -@@ -236,6 +245,9 @@ int Monitor(struct mddev_dev *devlist, - if (!new_found) { - if (oneshot) - break; -+ else if (!anyredundant) { -+ break; -+ } - else { - mdstat_wait(c->delay); - mdstat_close(); -@@ -542,7 +554,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, - st->err = 0; - st->percent = RESYNC_NONE; - new_array = 1; -- alert("NewArray", st->devname, NULL, ainfo); -+ if (!is_container) -+ alert("NewArray", st->devname, NULL, ainfo); - } - - if (st->utime == array.utime && st->failed == sra->array.failed_disks && -@@ -676,7 +689,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, - return retval; - - disappeared: -- if (!st->err) -+ if (!st->err && !is_container) - alert("DeviceDisappeared", dev, NULL, ainfo); - st->err++; - goto out; --- -2.26.2 - diff --git a/0099-mdmonitor-set-small-delay-once.patch b/0099-mdmonitor-set-small-delay-once.patch deleted file mode 100644 index 895c384..0000000 --- a/0099-mdmonitor-set-small-delay-once.patch +++ /dev/null @@ -1,107 +0,0 @@ -From cab9c67d461c65a1138359f9f6d39636466b90e4 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 9 Sep 2020 10:31:19 +0200 -Subject: [PATCH 05/17] mdmonitor: set small delay once -Git-commit: cab9c67d461c65a1138359f9f6d39636466b90e4 -References: jsc#SLE-13700 - -If mdmonitor is awakened by event, set small delay once -to deal with udev and mdadm. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Monitor.c | 14 +++++++++++++- - mdadm.h | 2 +- - mdstat.c | 18 +++++++++++++++--- - 3 files changed, 29 insertions(+), 5 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index aed7a69..0fb4f77 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -128,6 +128,7 @@ int Monitor(struct mddev_dev *devlist, - char *mailfrom; - struct alert_info info; - struct mddev_ident *mdlist; -+ int delay_for_event = c->delay; - - if (!mailaddr) { - mailaddr = conf_get_mailaddr(); -@@ -249,7 +250,18 @@ int Monitor(struct mddev_dev *devlist, - break; - } - else { -- mdstat_wait(c->delay); -+ int wait_result = mdstat_wait(delay_for_event); -+ -+ /* -+ * If mdmonitor is awaken by event, set small delay once -+ * to deal with udev and mdadm. -+ */ -+ if (wait_result != 0) { -+ if (c->delay > 5) -+ delay_for_event = 5; -+ } else -+ delay_for_event = c->delay; -+ - mdstat_close(); - } - } -diff --git a/mdadm.h b/mdadm.h -index 399478b..4961c0f 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -628,7 +628,7 @@ struct mdstat_ent { - extern struct mdstat_ent *mdstat_read(int hold, int start); - extern void mdstat_close(void); - extern void free_mdstat(struct mdstat_ent *ms); --extern void mdstat_wait(int seconds); -+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); -diff --git a/mdstat.c b/mdstat.c -index 48559e6..dd96cca 100644 ---- a/mdstat.c -+++ b/mdstat.c -@@ -302,7 +302,17 @@ void mdstat_close(void) - mdstat_fd = -1; - } - --void mdstat_wait(int seconds) -+/* -+ * function: mdstat_wait -+ * Description: Function waits for event on mdstat. -+ * Parameters: -+ * seconds - timeout for waiting -+ * Returns: -+ * > 0 - detected event -+ * 0 - timeout -+ * < 0 - detected error -+ */ -+int mdstat_wait(int seconds) - { - fd_set fds; - struct timeval tm; -@@ -312,10 +322,12 @@ void mdstat_wait(int seconds) - FD_SET(mdstat_fd, &fds); - maxfd = mdstat_fd; - } else -- return; -+ return -1; -+ - tm.tv_sec = seconds; - tm.tv_usec = 0; -- select(maxfd + 1, NULL, NULL, &fds, &tm); -+ -+ return select(maxfd + 1, NULL, NULL, &fds, &tm); - } - - void mdstat_wait_fd(int fd, const sigset_t *sigmask) --- -2.26.2 - diff --git a/0100-Check-if-other-Monitor-instance-running-before-fork.patch b/0100-Check-if-other-Monitor-instance-running-before-fork.patch deleted file mode 100644 index 0759ae2..0000000 --- a/0100-Check-if-other-Monitor-instance-running-before-fork.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 7f3b2d1d1621cbdc60b5af4a41445391010fe9e1 Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Wed, 9 Sep 2020 10:31:20 +0200 -Subject: [PATCH 06/17] Check if other Monitor instance running before fork. -Git-commit: 7f3b2d1d1621cbdc60b5af4a41445391010fe9e1 -References: jsc#SLE-13700 - -Make error message visible to the user. - -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Monitor.c | 44 ++++++++++++++++++++++++++++---------------- - 1 file changed, 28 insertions(+), 16 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index 0fb4f77..7fd4808 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -63,6 +63,7 @@ struct alert_info { - }; - static int make_daemon(char *pidfile); - static int check_one_sharer(int scan); -+static void write_autorebuild_pid(void); - static void alert(char *event, char *dev, char *disc, struct alert_info *info); - static int check_array(struct state *st, struct mdstat_ent *mdstat, - int test, struct alert_info *info, -@@ -153,6 +154,11 @@ int Monitor(struct mddev_dev *devlist, - info.mailfrom = mailfrom; - info.dosyslog = dosyslog; - -+ if (share){ -+ if (check_one_sharer(c->scan)) -+ return 1; -+ } -+ - if (daemonise) { - int rv = make_daemon(pidfile); - if (rv >= 0) -@@ -160,8 +166,7 @@ int Monitor(struct mddev_dev *devlist, - } - - if (share) -- if (check_one_sharer(c->scan)) -- return 1; -+ write_autorebuild_pid(); - - if (devlist == NULL) { - mdlist = conf_get_ident(NULL); -@@ -328,8 +333,8 @@ static int check_one_sharer(int scan) - int pid; - FILE *comm_fp; - FILE *fp; -- char comm_path[100]; -- char path[100]; -+ char comm_path[PATH_MAX]; -+ char path[PATH_MAX]; - char comm[20]; - - sprintf(path, "%s/autorebuild.pid", MDMON_DIR); -@@ -356,21 +361,28 @@ static int check_one_sharer(int scan) - } - fclose(fp); - } -- if (scan) { -- if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) { -+ return 0; -+} -+ -+static void write_autorebuild_pid() -+{ -+ char path[PATH_MAX]; -+ int pid; -+ FILE *fp; -+ sprintf(path, "%s/autorebuild.pid", MDMON_DIR); -+ -+ if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) { -+ pr_err("Can't create autorebuild.pid file\n"); -+ } else { -+ fp = fopen(path, "w"); -+ if (!fp) - pr_err("Can't create autorebuild.pid file\n"); -- } else { -- fp = fopen(path, "w"); -- if (!fp) -- pr_err("Cannot create autorebuild.pidfile\n"); -- else { -- pid = getpid(); -- fprintf(fp, "%d\n", pid); -- fclose(fp); -- } -+ else { -+ pid = getpid(); -+ fprintf(fp, "%d\n", pid); -+ fclose(fp); - } - } -- return 0; - } - - static void alert(char *event, char *dev, char *disc, struct alert_info *info) --- -2.26.2 - diff --git a/0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch b/0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch deleted file mode 100644 index c2134bd..0000000 --- a/0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 97b51a2c2d00b79a59f2a8e37134031b0c9e0223 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Wed, 14 Oct 2020 13:12:48 +1100 -Subject: [PATCH 07/17] Super1: allow RAID0 layout setting to be removed. -Git-commit: 97b51a2c2d00b79a59f2a8e37134031b0c9e0223 -References: jsc#SLE-13700 - -Once the RAID0 layout has been set, the RAID0 array cannot be assembled -on an older kernel which doesn't understand layouts. -This is an intentional safety feature, but sometimes people need the -ability to roll-back to a previously working configuration. - -So add "--update=layout-unspecified" to remove RAID0 layout information -from the superblock. -Running "--assemble --update=layout-unspecified" will cause the assembly -the fail when run on a newer kernel, but will allow it to work on -an older kernel. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - md.4 | 13 +++++++++++++ - mdadm.8.in | 15 +++++++++++++-- - mdadm.c | 5 +++-- - super1.c | 6 +++++- - 4 files changed, 34 insertions(+), 5 deletions(-) - -diff --git a/md.4 b/md.4 -index aecff38..60fdd27 100644 ---- a/md.4 -+++ b/md.4 -@@ -215,6 +215,19 @@ option or the - .B "--update=layout-alternate" - option. - -+Once you have updated the layout you will not be able to mount the array -+on an older kernel. If you need to revert to an older kernel, the -+layout information can be erased with the -+.B "--update=layout-unspecificed" -+option. If you use this option to -+.B --assemble -+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 -+this bug, and you must be sure that the kernel you use matches the -+layout of the array. -+ - .SS RAID1 - - A RAID1 array is also known as a mirrored set (though mirrors tend to -diff --git a/mdadm.8.in b/mdadm.8.in -index ab832e8..34a93a8 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -1213,6 +1213,7 @@ argument given to this flag can be one of - .BR no\-ppl , - .BR layout\-original , - .BR layout\-alternate , -+.BR layout\-unspecified , - .BR metadata , - or - .BR super\-minor . -@@ -1368,8 +1369,9 @@ The - .B layout\-original - and - .B layout\-alternate --options are for RAID0 arrays in use before Linux 5.4. If the array was being --used with Linux 3.13 or earlier, then to assemble the array on a new kernel, -+options are for RAID0 arrays with non-uniform devices size that were in -+use before Linux 5.4. If the array was being used with Linux 3.13 or -+earlier, then to assemble the array on a new kernel, - .B \-\-update=layout\-original - must be given. If the array was created and used with a kernel from Linux 3.14 to - Linux 5.3, then -@@ -1379,6 +1381,15 @@ will happen normally. - For more information, see - .IR md (4). - -+The -+.B layout\-unspecified -+option reverts the effect of -+.B layout\-orignal -+or -+.B layout\-alternate -+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 - Option is intended to be used in start-up scripts during initrd boot phase. -diff --git a/mdadm.c b/mdadm.c -index 1b3467f..493d70e 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -796,7 +796,8 @@ int main(int argc, char *argv[]) - if (strcmp(c.update, "revert-reshape") == 0) - continue; - if (strcmp(c.update, "layout-original") == 0 || -- strcmp(c.update, "layout-alternate") == 0) -+ strcmp(c.update, "layout-alternate") == 0 || -+ strcmp(c.update, "layout-unspecified") == 0) - continue; - if (strcmp(c.update, "byteorder") == 0) { - if (ss) { -@@ -828,7 +829,7 @@ int main(int argc, char *argv[]) - " 'summaries', 'homehost', 'home-cluster', 'byteorder', 'devicesize',\n" - " 'no-bitmap', 'metadata', 'revert-reshape'\n" - " 'bbl', 'no-bbl', 'force-no-bbl', 'ppl', 'no-ppl'\n" -- " 'layout-original', 'layout-alternate'\n" -+ " 'layout-original', 'layout-alternate', 'layout-unspecified'\n" - ); - exit(outf == stdout ? 0 : 2); - -diff --git a/super1.c b/super1.c -index 7664883..8b0d6ff 100644 ---- a/super1.c -+++ b/super1.c -@@ -1551,11 +1551,15 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - else if (strcmp(update, "nofailfast") == 0) - sb->devflags &= ~FailFast1; - else if (strcmp(update, "layout-original") == 0 || -- strcmp(update, "layout-alternate") == 0) { -+ strcmp(update, "layout-alternate") == 0 || -+ strcmp(update, "layout-unspecified") == 0) { - if (__le32_to_cpu(sb->level) != 0) { - pr_err("%s: %s only supported for RAID0\n", - devname?:"", update); - rv = -1; -+ } else if (strcmp(update, "layout-unspecified") == 0) { -+ sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_RAID0_LAYOUT); -+ sb->layout = 0; - } else { - sb->feature_map |= __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT); - sb->layout = __cpu_to_le32(update[7] == 'o' ? 1 : 2); --- -2.26.2 - diff --git a/0102-Detail-fix-segfault-during-IMSM-raid-creation.patch b/0102-Detail-fix-segfault-during-IMSM-raid-creation.patch deleted file mode 100644 index 3b7651e..0000000 --- a/0102-Detail-fix-segfault-during-IMSM-raid-creation.patch +++ /dev/null @@ -1,37 +0,0 @@ -From c3129b39a7d467eec063681529f46f84a2a85308 Mon Sep 17 00:00:00 2001 -From: Lidong Zhong -Date: Sun, 22 Nov 2020 23:12:29 +0800 -Subject: [PATCH 08/17] Detail: fix segfault during IMSM raid creation -Git-commit: c3129b39a7d467eec063681529f46f84a2a85308 -References: jsc#SLE-13700 - -It can be reproduced with non IMSM hardware and IMSM_NO_PLATFORM -environmental variable set. The array state is inactive when creating -an IMSM container. And the structure info is NULL because load_super() -always fails since no intel HBA information could be obtained. - -Signed-off-by: Lidong Zhong -Reported-by: Tkaczyk Mariusz -Fixes: 64bf4dff3430 (Detail: show correct raid level when the array is inactive) -Signed-off-by: Coly Li - ---- - Detail.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index b6587c8..ea86884 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -224,7 +224,7 @@ int Detail(char *dev, struct context *c) - } - - /* Ok, we have some info to print... */ -- if (inactive) -+ if (inactive && info) - str = map_num(pers, info->array.level); - else - str = map_num(pers, array.level); --- -2.26.2 - diff --git a/0103-Create.c-close-mdfd-and-generate-uevent.patch b/0103-Create.c-close-mdfd-and-generate-uevent.patch deleted file mode 100644 index b2fb9ea..0000000 --- a/0103-Create.c-close-mdfd-and-generate-uevent.patch +++ /dev/null @@ -1,41 +0,0 @@ -From ce559078a5650afb9f635204b31a89a1fa0061e3 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 24 Nov 2020 13:39:49 +0100 -Subject: [PATCH 09/17] Create.c: close mdfd and generate uevent -Git-commit: ce559078a5650afb9f635204b31a89a1fa0061e3 -References: jsc#SLE-13700 - -During mdfd closing change event is not generated because open() is -called before start watching mddevice by udev. -Device is ready at this stage. Unblock device, close fd and -generate event to give a chance next layers to work. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - Create.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/Create.c b/Create.c -index 0efa19c..51f8826 100644 ---- a/Create.c -+++ b/Create.c -@@ -1083,12 +1083,9 @@ int Create(struct supertype *st, char *mddev, - } else { - pr_err("not starting array - not enough devices.\n"); - } -- close(mdfd); -- /* Give udev a moment to process the Change event caused -- * by the close. -- */ -- usleep(100*1000); - udev_unblock(); -+ close(mdfd); -+ sysfs_uevent(&info, "change"); - return 0; - - abort: --- -2.26.2 - diff --git a/0104-imsm-update-num_data_stripes-according-to-dev_size.patch b/0104-imsm-update-num_data_stripes-according-to-dev_size.patch deleted file mode 100644 index ff129c9..0000000 --- a/0104-imsm-update-num_data_stripes-according-to-dev_size.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 895ffd992954069e4ea67efb8a85bb0fd72c3707 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 24 Nov 2020 14:15:15 +0100 -Subject: [PATCH 10/17] imsm: update num_data_stripes according to dev_size -Git-commit: 895ffd992954069e4ea67efb8a85bb0fd72c3707 -References: jsc#SLE-13700 - -If array was created in UEFI there is possibility that -member size is not rounded to 1MB. After any size reconfiguration -it will be rounded down to 1MB per each member but the old -component size will remain in metadata. -During reshape old array size is calculated from component size because -dev_size is not a part of map and is bumped to new value quickly. -It may result in size mismatch if array is assembled during reshape. - -If difference in calculated size and dev_size is observed try to fix it. -num_data_stripes value can be safety updated to smaller value if array -doesn't occuppy whole reserved component space. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - super-intel.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++---- - 1 file changed, 78 insertions(+), 6 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 3a73d2b..9562064 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -3453,7 +3453,6 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - __u64 blocks_per_unit = blocks_per_migr_unit(super, - dev); - __u64 units = current_migr_unit(migr_rec); -- unsigned long long array_blocks; - int used_disks; - - if (__le32_to_cpu(migr_rec->ascending_migr) && -@@ -3472,12 +3471,8 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - - used_disks = imsm_num_data_members(prev_map); - if (used_disks > 0) { -- array_blocks = per_dev_array_size(map) * -+ info->custom_array_size = per_dev_array_size(map) * - used_disks; -- info->custom_array_size = -- round_size_to_mb(array_blocks, -- used_disks); -- - } - } - case MIGR_VERIFY: -@@ -11682,6 +11677,68 @@ int imsm_takeover(struct supertype *st, struct geo_params *geo) - return 0; - } - -+/* Flush size update if size calculated by num_data_stripes is higher than -+ * imsm_dev_size to eliminate differences during reshape. -+ * Mdmon will recalculate them correctly. -+ * If subarray index is not set then check whole container. -+ * Returns: -+ * 0 - no error occurred -+ * 1 - error detected -+ */ -+static int imsm_fix_size_mismatch(struct supertype *st, int subarray_index) -+{ -+ struct intel_super *super = st->sb; -+ int tmp = super->current_vol; -+ int ret_val = 1; -+ int i; -+ -+ for (i = 0; i < super->anchor->num_raid_devs; i++) { -+ if (subarray_index >= 0 && i != subarray_index) -+ continue; -+ super->current_vol = i; -+ struct imsm_dev *dev = get_imsm_dev(super, super->current_vol); -+ struct imsm_map *map = get_imsm_map(dev, MAP_0); -+ unsigned int disc_count = imsm_num_data_members(map); -+ struct geo_params geo; -+ struct imsm_update_size_change *update; -+ unsigned long long calc_size = per_dev_array_size(map) * disc_count; -+ unsigned long long d_size = imsm_dev_size(dev); -+ int u_size; -+ -+ if (calc_size == d_size || dev->vol.migr_type == MIGR_GEN_MIGR) -+ continue; -+ -+ /* There is a difference, verify that imsm_dev_size is -+ * rounded correctly and push update. -+ */ -+ if (d_size != round_size_to_mb(d_size, disc_count)) { -+ dprintf("imsm: Size of volume %d is not rounded correctly\n", -+ i); -+ goto exit; -+ } -+ memset(&geo, 0, sizeof(struct geo_params)); -+ geo.size = d_size; -+ u_size = imsm_create_metadata_update_for_size_change(st, &geo, -+ &update); -+ if (u_size < 1) { -+ dprintf("imsm: Cannot prepare size change update\n"); -+ goto exit; -+ } -+ imsm_update_metadata_locally(st, update, u_size); -+ if (st->update_tail) { -+ append_metadata_update(st, update, u_size); -+ flush_metadata_updates(st); -+ st->update_tail = &st->updates; -+ } else { -+ imsm_sync_metadata(st); -+ } -+ } -+ ret_val = 0; -+exit: -+ super->current_vol = tmp; -+ return ret_val; -+} -+ - static int imsm_reshape_super(struct supertype *st, unsigned long long size, - int level, - int layout, int chunksize, int raid_disks, -@@ -11718,6 +11775,11 @@ static int imsm_reshape_super(struct supertype *st, unsigned long long size, - struct imsm_update_reshape *u = NULL; - int len; - -+ if (imsm_fix_size_mismatch(st, -1)) { -+ dprintf("imsm: Cannot fix size mismatch\n"); -+ goto exit_imsm_reshape_super; -+ } -+ - len = imsm_create_metadata_update_for_reshape( - st, &geo, old_raid_disks, &u); - -@@ -12020,6 +12082,7 @@ static int imsm_manage_reshape( - unsigned long long start_buf_shift; /* [bytes] */ - int degraded = 0; - int source_layout = 0; -+ int subarray_index = -1; - - if (!sra) - return ret_val; -@@ -12033,6 +12096,7 @@ static int imsm_manage_reshape( - dv->dev->vol.migr_state == 1) { - dev = dv->dev; - migr_vol_qan++; -+ subarray_index = dv->index; - } - } - /* Only one volume can migrate at the same time */ -@@ -12217,6 +12281,14 @@ static int imsm_manage_reshape( - - /* return '1' if done */ - ret_val = 1; -+ -+ /* After the reshape eliminate size mismatch in metadata. -+ * Don't update md/component_size here, volume hasn't -+ * to take whole space. It is allowed by kernel. -+ * md/component_size will be set propoperly after next assembly. -+ */ -+ imsm_fix_size_mismatch(st, subarray_index); -+ - abort: - free(buf); - /* See Grow.c: abort_reshape() for further explanation */ --- -2.26.2 - diff --git a/0105-imsm-remove-redundant-calls-to-imsm_get_map.patch b/0105-imsm-remove-redundant-calls-to-imsm_get_map.patch deleted file mode 100644 index aa12762..0000000 --- a/0105-imsm-remove-redundant-calls-to-imsm_get_map.patch +++ /dev/null @@ -1,39 +0,0 @@ -From b65c1f4a2340e24ae00babc4399fb4030ff99517 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 24 Nov 2020 15:58:53 +0100 -Subject: [PATCH 11/17] imsm: remove redundant calls to imsm_get_map -Git-commit: b65c1f4a2340e24ae00babc4399fb4030ff99517 -References: jsc#SLE-13700 - -MAP_0 is gotten and the beginning, there is no need to get it again. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - super-intel.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 9562064..95f4eaf 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -8598,7 +8598,6 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - break; - } - end_migration(dev, super, map_state); -- map = get_imsm_map(dev, MAP_0); - map->failed_disk_num = ~0; - super->updates_pending++; - a->last_checkpoint = 0; -@@ -8610,7 +8609,6 @@ static void imsm_set_disk(struct active_array *a, int n, int state) - end_migration(dev, super, map_state); - else - map->map_state = map_state; -- map = get_imsm_map(dev, MAP_0); - map->failed_disk_num = ~0; - super->updates_pending++; - break; --- -2.26.2 - diff --git a/0106-Monitor-don-t-use-default-modes-when-creating-a-file.patch b/0106-Monitor-don-t-use-default-modes-when-creating-a-file.patch deleted file mode 100644 index 32b15c0..0000000 --- a/0106-Monitor-don-t-use-default-modes-when-creating-a-file.patch +++ /dev/null @@ -1,59 +0,0 @@ -From ca4b156b2059ee00a9143313267ee4a098967d76 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Tue, 24 Nov 2020 16:41:01 +0100 -Subject: [PATCH 12/17] Monitor: don't use default modes when creating a file -Git-commit: ca4b156b2059ee00a9143313267ee4a098967d76 -References: jsc#SLE-13700 - -Replace fopen() calls by open() with creation mode directly specified. -This fixes the potential security issue. Use octal values instead masks. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - Monitor.c | 17 ++++++++++++----- - 1 file changed, 12 insertions(+), 5 deletions(-) - -diff --git a/Monitor.c b/Monitor.c -index 7fd4808..a82e99d 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -305,8 +305,11 @@ static int make_daemon(char *pidfile) - if (!pidfile) - printf("%d\n", pid); - else { -- FILE *pid_file; -- pid_file=fopen(pidfile, "w"); -+ FILE *pid_file = NULL; -+ int fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, -+ 0644); -+ if (fd >= 0) -+ pid_file = fdopen(fd, "w"); - if (!pid_file) - perror("cannot create pid file"); - else { -@@ -368,13 +371,17 @@ static void write_autorebuild_pid() - { - char path[PATH_MAX]; - int pid; -- FILE *fp; -+ FILE *fp = NULL; - sprintf(path, "%s/autorebuild.pid", MDMON_DIR); - -- if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) { -+ if (mkdir(MDMON_DIR, 0700) < 0 && errno != EEXIST) { - pr_err("Can't create autorebuild.pid file\n"); - } else { -- fp = fopen(path, "w"); -+ int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0700); -+ -+ if (fd >= 0) -+ fp = fdopen(fd, "w"); -+ - if (!fp) - pr_err("Can't create autorebuild.pid file\n"); - else { --- -2.26.2 - diff --git a/0107-imsm-limit-support-to-first-NVMe-namespace.patch b/0107-imsm-limit-support-to-first-NVMe-namespace.patch deleted file mode 100644 index 8a26f63..0000000 --- a/0107-imsm-limit-support-to-first-NVMe-namespace.patch +++ /dev/null @@ -1,99 +0,0 @@ -From a8f3cfd54e45c8aabc4a99cdc92b6b9080b26607 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 4 Nov 2020 10:01:28 +0100 -Subject: [PATCH 13/17] imsm: limit support to first NVMe namespace -Git-commit: a8f3cfd54e45c8aabc4a99cdc92b6b9080b26607 -References: jsc#SLE-13700 - -Due to metadata limitations NVMe multinamespace support has to be removed. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - platform-intel.c | 31 +++++++++++++++++++++++++++++++ - platform-intel.h | 1 + - super-intel.c | 11 ++++++++++- - 3 files changed, 42 insertions(+), 1 deletion(-) - -diff --git a/platform-intel.c b/platform-intel.c -index 04bffc5..f1f6d4c 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -766,3 +766,34 @@ char *vmd_domain_to_controller(struct sys_dev *hba, char *buf) - closedir(dir); - return NULL; - } -+/* Verify that NVMe drive is supported by IMSM -+ * Returns: -+ * 0 - not supported -+ * 1 - supported -+ */ -+int imsm_is_nvme_supported(int disk_fd, int verbose) -+{ -+ char nsid_path[PATH_MAX]; -+ char buf[PATH_MAX]; -+ struct stat stb; -+ -+ if (disk_fd < 0) -+ return 0; -+ -+ if (fstat(disk_fd, &stb)) -+ return 0; -+ -+ snprintf(nsid_path, PATH_MAX-1, "/sys/dev/block/%d:%d/nsid", -+ major(stb.st_rdev), minor(stb.st_rdev)); -+ -+ if (load_sys(nsid_path, buf, sizeof(buf))) { -+ pr_err("Cannot read %s, rejecting drive\n", nsid_path); -+ return 0; -+ } -+ if (strtoll(buf, NULL, 10) != 1) { -+ if (verbose) -+ pr_err("Only first namespace is supported by IMSM, aborting\n"); -+ return 0; -+ } -+ return 1; -+} -diff --git a/platform-intel.h b/platform-intel.h -index 7cb370e..7371478 100644 ---- a/platform-intel.h -+++ b/platform-intel.h -@@ -251,4 +251,5 @@ 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); - struct sys_dev *device_by_id_and_path(__u16 device_id, const char *path); -+int imsm_is_nvme_supported(int disk_fd, int verbose); - char *vmd_domain_to_controller(struct sys_dev *hba, char *buf); -diff --git a/super-intel.c b/super-intel.c -index 95f4eaf..715febf 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2364,7 +2364,9 @@ static int print_nvme_info(struct sys_dev *hba) - continue; - if (path_attached_to_hba(rp, hba->path)) { - fd = open_dev(ent->d_name); -- if (fd < 0) { -+ if (!imsm_is_nvme_supported(fd, 0)) { -+ if (fd >= 0) -+ close(fd); - free(rp); - continue; - } -@@ -5868,6 +5870,13 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - snprintf(controller_path, PATH_MAX-1, "%s/device", devpath); - free(devpath); - -+ if (!imsm_is_nvme_supported(dd->fd, 1)) { -+ if (dd->devname) -+ free(dd->devname); -+ free(dd); -+ return 1; -+ } -+ - if (devpath_to_vendor(controller_path) == 0x8086) { - /* - * If Intel's NVMe drive has serial ended with --- -2.26.2 - diff --git a/0108-mdadm-Unify-forks-behaviour.patch b/0108-mdadm-Unify-forks-behaviour.patch deleted file mode 100644 index 84c26e0..0000000 --- a/0108-mdadm-Unify-forks-behaviour.patch +++ /dev/null @@ -1,358 +0,0 @@ -From ff6bb131a46e1bac84a26e5b2c4bf408c0e56926 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 4 Nov 2020 10:02:36 +0100 -Subject: [PATCH 14/17] mdadm: Unify forks behaviour -Git-commit: ff6bb131a46e1bac84a26e5b2c4bf408c0e56926 -References: jsc#SLE-13700 - -If mdadm is run by udev or systemd, it gets a pipe as each stream. -Forks in the background may run after an event or service has been -processed when udev is detached from pipe. As a result process -fails quietly if any message is written. -To prevent from it, each fork has to close all parent streams. Leave -stderr and stdout opened only for debug purposes. -Unify it across all forks. Introduce other descriptors detection by -scanning /proc/self/fd directory. Add generic method for -managing systemd services. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - Grow.c | 52 +++------------------ - Incremental.c | 1 + - Monitor.c | 5 +- - mdadm.h | 10 ++++ - mdmon.c | 9 +--- - util.c | 124 ++++++++++++++++++++++++++++++++------------------ - 6 files changed, 100 insertions(+), 101 deletions(-) - -diff --git a/Grow.c b/Grow.c -index 57db7d4..6b8321c 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -2982,47 +2982,6 @@ static void catch_term(int sig) - sigterm = 1; - } - --static int continue_via_systemd(char *devnm) --{ -- int skipped, i, pid, status; -- char pathbuf[1024]; -- /* In a systemd/udev world, it is best to get systemd to -- * run "mdadm --grow --continue" rather than running in the -- * background. -- */ -- switch(fork()) { -- case 0: -- /* FIXME yuk. CLOSE_EXEC?? */ -- skipped = 0; -- for (i = 3; skipped < 20; i++) -- if (close(i) < 0) -- skipped++; -- else -- skipped = 0; -- -- /* Don't want to see error messages from -- * systemctl. If the service doesn't exist, -- * we fork ourselves. -- */ -- close(2); -- open("/dev/null", O_WRONLY); -- snprintf(pathbuf, sizeof(pathbuf), -- "mdadm-grow-continue@%s.service", 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. */ -- break; -- default: /* parent - good */ -- pid = wait(&status); -- if (pid >= 0 && status == 0) -- return 1; -- } -- return 0; --} -- - static int reshape_array(char *container, int fd, char *devname, - struct supertype *st, struct mdinfo *info, - int force, struct mddev_dev *devlist, -@@ -3401,6 +3360,7 @@ static int reshape_array(char *container, int fd, char *devname, - default: /* parent */ - return 0; - case 0: -+ manage_fork_fds(0); - map_fork(); - break; - } -@@ -3509,8 +3469,9 @@ started: - return 1; - } - -- if (!forked && !check_env("MDADM_NO_SYSTEMCTL")) -- if (continue_via_systemd(container ?: sra->sys_name)) { -+ if (!forked) -+ if (continue_via_systemd(container ?: sra->sys_name, -+ GROW_SERVICE)) { - free(fdlist); - free(offsets); - sysfs_free(sra); -@@ -3704,8 +3665,8 @@ int reshape_container(char *container, char *devname, - */ - ping_monitor(container); - -- if (!forked && !freeze_reshape && !check_env("MDADM_NO_SYSTEMCTL")) -- if (continue_via_systemd(container)) -+ if (!forked && !freeze_reshape) -+ if (continue_via_systemd(container, GROW_SERVICE)) - return 0; - - switch (forked ? 0 : fork()) { -@@ -3718,6 +3679,7 @@ int reshape_container(char *container, char *devname, - printf("%s: multi-array reshape continues in background\n", Name); - return 0; - case 0: /* child */ -+ manage_fork_fds(0); - map_fork(); - break; - } -diff --git a/Incremental.c b/Incremental.c -index 98dbcd9..ad9ec1c 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -1679,6 +1679,7 @@ static void run_udisks(char *arg1, char *arg2) - int pid = fork(); - int status; - if (pid == 0) { -+ manage_fork_fds(1); - execl("/usr/bin/udisks", "udisks", arg1, arg2, NULL); - execl("/bin/udisks", "udisks", arg1, arg2, NULL); - exit(1); -diff --git a/Monitor.c b/Monitor.c -index a82e99d..3f3005b 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -323,10 +323,7 @@ static int make_daemon(char *pidfile) - perror("daemonise"); - return 1; - } -- close(0); -- open("/dev/null", O_RDWR); -- dup2(0, 1); -- dup2(0, 2); -+ manage_fork_fds(0); - setsid(); - return -1; - } -diff --git a/mdadm.h b/mdadm.h -index 4961c0f..56b1b19 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -129,6 +129,14 @@ struct dlm_lksb { - #define FAILED_SLOTS_DIR "/run/mdadm/failed-slots" - #endif /* FAILED_SLOTS */ - -+#ifndef MDMON_SERVICE -+#define MDMON_SERVICE "mdmon" -+#endif /* MDMON_SERVICE */ -+ -+#ifndef GROW_SERVICE -+#define GROW_SERVICE "mdadm-grow-continue" -+#endif /* GROW_SERVICE */ -+ - #include "md_u.h" - #include "md_p.h" - #include "bitmap.h" -@@ -1497,6 +1505,8 @@ extern int is_standard(char *dev, int *nump); - 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); - - extern int parse_auto(char *str, char *msg, int config); - extern struct mddev_ident *conf_get_ident(char *dev); -diff --git a/mdmon.c b/mdmon.c -index ff985d2..c71e62c 100644 ---- a/mdmon.c -+++ b/mdmon.c -@@ -546,14 +546,7 @@ static int mdmon(char *devnm, int must_fork, int takeover) - } - - setsid(); -- close(0); -- open("/dev/null", O_RDWR); -- close(1); -- ignore = dup(0); --#ifndef DEBUG -- close(2); -- ignore = dup(0); --#endif -+ manage_fork_fds(0); - - /* This silliness is to stop the compiler complaining - * that we ignore 'ignore' -diff --git a/util.c b/util.c -index 579dd42..5879694 100644 ---- a/util.c -+++ b/util.c -@@ -1915,7 +1915,7 @@ int mdmon_running(char *devnm) - - int start_mdmon(char *devnm) - { -- int i, skipped; -+ int i; - int len; - pid_t pid; - int status; -@@ -1929,7 +1929,10 @@ int start_mdmon(char *devnm) - - if (check_env("MDADM_NO_MDMON")) - return 0; -+ if (continue_via_systemd(devnm, MDMON_SERVICE)) -+ return 0; - -+ /* That failed, try running mdmon directly */ - len = readlink("/proc/self/exe", pathbuf, sizeof(pathbuf)-1); - if (len > 0) { - char *sl; -@@ -1943,51 +1946,9 @@ int start_mdmon(char *devnm) - } else - pathbuf[0] = '\0'; - -- /* First try to run systemctl */ -- if (!check_env("MDADM_NO_SYSTEMCTL")) -- switch(fork()) { -- case 0: -- /* FIXME yuk. CLOSE_EXEC?? */ -- skipped = 0; -- for (i = 3; skipped < 20; i++) -- if (close(i) < 0) -- skipped++; -- else -- skipped = 0; -- -- /* Don't want to see error messages from -- * systemctl. If the service doesn't exist, -- * we start mdmon ourselves. -- */ -- close(2); -- open("/dev/null", O_WRONLY); -- snprintf(pathbuf, sizeof(pathbuf), "mdmon@%s.service", -- devnm); -- status = execl("/usr/bin/systemctl", "systemctl", -- "start", -- pathbuf, NULL); -- status = execl("/bin/systemctl", "systemctl", "start", -- pathbuf, NULL); -- exit(1); -- case -1: pr_err("cannot run mdmon. Array remains readonly\n"); -- return -1; -- default: /* parent - good */ -- pid = wait(&status); -- if (pid >= 0 && status == 0) -- return 0; -- } -- -- /* That failed, try running mdmon directly */ - switch(fork()) { - case 0: -- /* FIXME yuk. CLOSE_EXEC?? */ -- skipped = 0; -- for (i = 3; skipped < 20; i++) -- if (close(i) < 0) -- skipped++; -- else -- skipped = 0; -- -+ manage_fork_fds(1); - for (i = 0; paths[i]; i++) - if (paths[i][0]) { - execl(paths[i], paths[i], -@@ -2192,6 +2153,81 @@ void enable_fds(int devices) - setrlimit(RLIMIT_NOFILE, &lim); - } - -+/* Close all opened descriptors if needed and redirect -+ * streams to /dev/null. -+ * For debug purposed, leave STDOUT and STDERR untouched -+ * Returns: -+ * 1- if any error occurred -+ * 0- otherwise -+ */ -+void manage_fork_fds(int close_all) -+{ -+ DIR *dir; -+ struct dirent *dirent; -+ -+ close(0); -+ open("/dev/null", O_RDWR); -+ -+#ifndef DEBUG -+ dup2(0, 1); -+ dup2(0, 2); -+#endif -+ -+ if (close_all == 0) -+ return; -+ -+ dir = opendir("/proc/self/fd"); -+ if (!dir) { -+ pr_err("Cannot open /proc/self/fd directory.\n"); -+ return; -+ } -+ for (dirent = readdir(dir); dirent; dirent = readdir(dir)) { -+ int fd = -1; -+ -+ if ((strcmp(dirent->d_name, ".") == 0) || -+ (strcmp(dirent->d_name, "..")) == 0) -+ continue; -+ -+ fd = strtol(dirent->d_name, NULL, 10); -+ if (fd > 2) -+ close(fd); -+ } -+} -+ -+/* 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 -+ */ -+int continue_via_systemd(char *devnm, char *service_name) -+{ -+ int pid, status; -+ char pathbuf[1024]; -+ -+ /* Simply return that service cannot be started */ -+ if (check_env("MDADM_NO_SYSTEMCTL")) -+ return 0; -+ switch (fork()) { -+ case 0: -+ manage_fork_fds(1); -+ snprintf(pathbuf, sizeof(pathbuf), -+ "%s@%s.service", service_name, 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. */ -+ break; -+ default: /* parent - good */ -+ pid = wait(&status); -+ if (pid >= 0 && status == 0) -+ return 1; -+ } -+ return 0; -+} -+ - int in_initrd(void) - { - /* This is based on similar function in systemd. */ --- -2.26.2 - diff --git a/0109-mdadm-Detail-show-correct-state-for-clustered-array.patch b/0109-mdadm-Detail-show-correct-state-for-clustered-array.patch deleted file mode 100644 index 8779050..0000000 --- a/0109-mdadm-Detail-show-correct-state-for-clustered-array.patch +++ /dev/null @@ -1,201 +0,0 @@ -From 9c030dadba89b90a4e52b6afe0290076c809684c Mon Sep 17 00:00:00 2001 -From: Zhao Heming -Date: Sat, 24 Oct 2020 17:43:12 +0800 -Subject: [PATCH 15/17] mdadm/Detail: show correct state for clustered array -Git-commit: 9c030dadba89b90a4e52b6afe0290076c809684c -References: jsc#SLE-13700 - -After kernel md module commit 480523feae581, in clustered env, -mddev->in_sync always zero, it will make array.state never set -up MD_SB_CLEAN. it causes "mdadm -D /dev/mdX" show state 'active' -all the time. - -Bitmap.c: add a new API IsBitmapDirty() to support inquiry bitmap -dirty or clean. - -Signed-off-by: Zhao Heming -Signed-off-by: Coly Li - ---- - Detail.c | 20 ++++++++++++++- - bitmap.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++------- - mdadm.h | 1 + - 3 files changed, 86 insertions(+), 10 deletions(-) - -diff --git a/Detail.c b/Detail.c -index ea86884..f8dea6f 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -498,8 +498,26 @@ int Detail(char *dev, struct context *c) - sra->array_state); - else - arrayst = "clean"; -- } else -+ } else { - arrayst = "active"; -+ if (array.state & (1<prefer); -+ if (!dv) -+ continue; -+ arrayst = IsBitmapDirty(dv) ? "active" : "clean"; -+ break; -+ } -+ } -+ } -+ } - - printf(" State : %s%s%s%s%s%s%s \n", - arrayst, st, -diff --git a/bitmap.c b/bitmap.c -index e38cb96..9a7ffe3 100644 ---- a/bitmap.c -+++ b/bitmap.c -@@ -180,13 +180,14 @@ out: - } - - static int --bitmap_file_open(char *filename, struct supertype **stp, int node_num) -+bitmap_file_open(char *filename, struct supertype **stp, int node_num, int fd) - { -- int fd; - struct stat stb; - struct supertype *st = *stp; - -- fd = open(filename, O_RDONLY|O_DIRECT); -+ /* won't re-open filename when (fd >= 0) */ -+ if (fd < 0) -+ fd = open(filename, O_RDONLY|O_DIRECT); - if (fd < 0) { - pr_err("failed to open bitmap file %s: %s\n", - filename, strerror(errno)); -@@ -249,7 +250,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) - int fd, i; - __u32 uuid32[4]; - -- fd = bitmap_file_open(filename, &st, 0); -+ fd = bitmap_file_open(filename, &st, 0, -1); - if (fd < 0) - return rv; - -@@ -263,7 +264,6 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) - pr_err("Reporting bitmap that would be used if this array were used\n"); - pr_err("as a member of some other array\n"); - } -- close(fd); - printf(" Filename : %s\n", filename); - printf(" Magic : %08x\n", sb->magic); - if (sb->magic != BITMAP_MAGIC) { -@@ -332,15 +332,13 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) - for (i = 0; i < (int)sb->nodes; i++) { - st = NULL; - free(info); -- fd = bitmap_file_open(filename, &st, i); -+ fd = bitmap_file_open(filename, &st, i, fd); - if (fd < 0) { - printf(" Unable to open bitmap file on node: %i\n", i); -- - continue; - } - info = bitmap_fd_read(fd, brief); - if (!info) { -- close(fd); - printf(" Unable to read bitmap on node: %i\n", i); - continue; - } -@@ -359,13 +357,72 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st) - printf(" Bitmap : %llu bits (chunks), %llu dirty (%2.1f%%)\n", - info->total_bits, info->dirty_bits, - 100.0 * info->dirty_bits / (info->total_bits?:1)); -- close(fd); - } - } - - free_info: -+ close(fd); -+ free(info); -+ return rv; -+} -+ -+int IsBitmapDirty(char *filename) -+{ -+ /* -+ * Read the bitmap file -+ * It will break reading bitmap action immediately when meeting any error. -+ * -+ * Return: 1(dirty), 0 (clean), -1(error) -+ */ -+ -+ int fd = -1, rv = 0, i; -+ struct supertype *st = NULL; -+ bitmap_info_t *info = NULL; -+ bitmap_super_t *sb = NULL; -+ -+ fd = bitmap_file_open(filename, &st, 0, fd); -+ free(st); -+ if (fd < 0) -+ goto out; -+ -+ info = bitmap_fd_read(fd, 0); -+ if (!info) { -+ close(fd); -+ goto out; -+ } -+ -+ sb = &info->sb; -+ for (i = 0; i < (int)sb->nodes; i++) { -+ st = NULL; -+ free(info); -+ info = NULL; -+ -+ fd = bitmap_file_open(filename, &st, i, fd); -+ free(st); -+ if (fd < 0) -+ goto out; -+ -+ info = bitmap_fd_read(fd, 0); -+ if (!info) { -+ close(fd); -+ goto out; -+ } -+ -+ sb = &info->sb; -+ if (sb->magic != BITMAP_MAGIC) { /* invalid bitmap magic */ -+ free(info); -+ close(fd); -+ goto out; -+ } -+ -+ if (info->dirty_bits) -+ rv = 1; -+ } -+ close(fd); - free(info); - return rv; -+out: -+ return -1; - } - - int CreateBitmap(char *filename, int force, char uuid[16], -diff --git a/mdadm.h b/mdadm.h -index 56b1b19..1ee6c92 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1455,6 +1455,7 @@ extern int CreateBitmap(char *filename, int force, char uuid[16], - unsigned long long array_size, - int major); - extern int ExamineBitmap(char *filename, int brief, struct supertype *st); -+extern int IsBitmapDirty(char *filename); - extern int Write_rules(char *rule_name); - extern int bitmap_update_uuid(int fd, int *uuid, int swap); - --- -2.26.2 - diff --git a/0110-Make-target-to-install-binaries-only.patch b/0110-Make-target-to-install-binaries-only.patch deleted file mode 100644 index c56af50..0000000 --- a/0110-Make-target-to-install-binaries-only.patch +++ /dev/null @@ -1,47 +0,0 @@ -From b4a5ad4958cb3ad87c3c5fa993e7572c38596d09 Mon Sep 17 00:00:00 2001 -From: Kinga Tanska -Date: Thu, 22 Oct 2020 14:22:29 +0200 -Subject: [PATCH 16/17] Make target to install binaries only -Git-commit: b4a5ad4958cb3ad87c3c5fa993e7572c38596d09 -References: jsc#SLE-13700 - -Make install causes installation of binaries, udev and man. -This commit contains new target make install-bin, which -results in installation of binaries only. - -Signed-off-by: Kinga Tanska -Signed-off-by: Coly Li - ---- - Makefile | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/Makefile b/Makefile -index 15d05d1..4cd4c9d 100644 ---- a/Makefile -+++ b/Makefile -@@ -245,9 +245,7 @@ $(MON_OBJS) : $(INCL) mdmon.h - sha1.o : sha1.c sha1.h md5.h - $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c - --install : mdadm mdmon install-man install-udev -- $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm -- $(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon -+install : install-bin install-man install-udev - - install-static : mdadm.static install-man - $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm -@@ -297,6 +295,10 @@ install-systemd: systemd/mdmon@.service - 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 -+ $(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon -+ - uninstall: - rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm - --- -2.26.2 - diff --git a/0111-udev-start-grow-service-automatically.patch b/0111-udev-start-grow-service-automatically.patch deleted file mode 100644 index d4760bb..0000000 --- a/0111-udev-start-grow-service-automatically.patch +++ /dev/null @@ -1,41 +0,0 @@ -From a64f1263a56bd8653267c1a9800daa0bc993a743 Mon Sep 17 00:00:00 2001 -From: Tkaczyk Mariusz -Date: Thu, 15 Oct 2020 10:45:29 +0200 -Subject: [PATCH 17/17] udev: start grow service automatically -Git-commit: a64f1263a56bd8653267c1a9800daa0bc993a743 -References: jsc#SLE-13700 - -Grow continue via service or fork is started during raid assembly. -If raid was assembled in initrd it will be newer restarted after -switch root. -Add udev support for starting mdadm-grow-continue service. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Coly Li - ---- - udev-md-raid-arrays.rules | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules -index c8fa8e8..13c9076 100644 ---- a/udev-md-raid-arrays.rules -+++ b/udev-md-raid-arrays.rules -@@ -15,6 +15,7 @@ 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" -@@ -38,5 +39,6 @@ ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" - # Tell systemd to run mdmon for our container, if we need it. - 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}=="?*", 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" - - LABEL="md_end" --- -2.26.2 - diff --git a/0112-Incremental-Remove-redundant-spare-movement-logic.patch b/0112-Incremental-Remove-redundant-spare-movement-logic.patch deleted file mode 100644 index ab342b2..0000000 --- a/0112-Incremental-Remove-redundant-spare-movement-logic.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 69068584f9ed68b8b2736287a1c9863e11b741d5 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Fri, 11 Dec 2020 12:28:38 +0100 -Subject: [PATCH 1/2] Incremental: Remove redundant spare movement logic -Git-commit: 69068584f9ed68b8b2736287a1c9863e11b741d5 -References: jsc#SLE-13700, bsc#1180220 - -If policy is set then mdmonitor is responsible for moving spares. -This logic is reduntant and potentialy dangerus, spare could be moved at -initrd stage depending on drives appearance order. - -Remove it. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Incremental.c | 62 --------------------------------------------------- - 1 file changed, 62 deletions(-) - -diff --git a/Incremental.c b/Incremental.c -index ad9ec1c..e849bdd 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -1460,12 +1460,6 @@ static int Incremental_container(struct supertype *st, char *devname, - int trustworthy; - struct mddev_ident *match; - int rv = 0; -- struct domainlist *domains; -- struct map_ent *smp; -- int suuid[4]; -- int sfd; -- int ra_blocked = 0; -- int ra_all = 0; - int result = 0; - - st->ss->getinfo_super(st, &info, NULL); -@@ -1509,12 +1503,10 @@ static int Incremental_container(struct supertype *st, char *devname, - struct map_ent *mp; - struct mddev_ident *match = NULL; - -- ra_all++; - /* do not activate arrays blocked by metadata handler */ - if (ra->array.state & (1 << MD_SB_BLOCK_VOLUME)) { - pr_err("Cannot activate array %s in %s.\n", - ra->text_version, devname); -- ra_blocked++; - continue; - } - mp = map_by_uuid(&map, ra->uuid); -@@ -1617,60 +1609,6 @@ static int Incremental_container(struct supertype *st, char *devname, - } - printf("\n"); - } -- -- /* don't move spares to container with volume being activated -- when all volumes are blocked */ -- if (ra_all == ra_blocked) -- return 0; -- -- /* Now move all suitable spares from spare container */ -- domains = domain_from_array(list, st->ss->name); -- memcpy(suuid, uuid_zero, sizeof(int[4])); -- if (domains && -- (smp = map_by_uuid(&map, suuid)) != NULL && -- (sfd = open(smp->path, O_RDONLY)) >= 0) { -- /* spare container found */ -- struct supertype *sst = -- super_imsm.match_metadata_desc("imsm"); -- struct mdinfo *sinfo; -- -- if (!sst->ss->load_container(sst, sfd, NULL)) { -- struct spare_criteria sc = {0, 0}; -- -- if (st->ss->get_spare_criteria) -- st->ss->get_spare_criteria(st, &sc); -- -- close(sfd); -- sinfo = container_choose_spares(sst, &sc, -- domains, NULL, -- st->ss->name, 0); -- sst->ss->free_super(sst); -- if (sinfo){ -- int count = 0; -- struct mdinfo *disks = sinfo->devs; -- while (disks) { -- /* move spare from spare -- * container to currently -- * assembled one -- */ -- if (move_spare( -- smp->path, -- devname, -- makedev(disks->disk.major, -- disks->disk.minor))) -- count++; -- disks = disks->next; -- } -- if (count) -- pr_err("Added %d spare%s to %s\n", -- count, count>1?"s":"", devname); -- } -- sysfs_free(sinfo); -- } else -- close(sfd); -- } -- domain_free(domains); -- map_free(map); - return 0; - } - --- -2.26.2 - diff --git a/0113-Dump-get-stat-from-a-wrong-metadata-file-when-restor.patch b/0113-Dump-get-stat-from-a-wrong-metadata-file-when-restor.patch deleted file mode 100644 index e3a0c7d..0000000 --- a/0113-Dump-get-stat-from-a-wrong-metadata-file-when-restor.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 75562b57d43bd252399b55d0004b8eac4b337a67 Mon Sep 17 00:00:00 2001 -From: Lidong Zhong -Date: Mon, 14 Dec 2020 22:51:33 +0800 -Subject: [PATCH 2/2] Dump: get stat from a wrong metadata file when restoring - metadata -Git-commit: 75562b57d43bd252399b55d0004b8eac4b337a67 -References: jsc#SLE-13700 - -The dumped metadata files are shown as below -localhost:~ # ll -ih test/ -total 16K -34565564 -rw-r--r-- 2 root root 1.0G Dec 14 21:15 -scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-3 -34565563 -rw-r--r-- 2 root root 1.0G Dec 14 21:15 -scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-4 -34565563 -rw-r--r-- 2 root root 1.0G Dec 14 21:15 sda -34565564 -rw-r--r-- 2 root root 1.0G Dec 14 21:15 sdb - -It reports such error when trying to restore metadata for /dev/sda -localhost:~ # mdadm --restore=test /dev/sda -Mdadm: test/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-4 is not the same -size as /dev/sda - cannot restore. -It's because the stb value has been changed to other metadata file in -the while statement. - -Signed-off-by: Lidong Zhong -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li - ---- - Dump.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/Dump.c b/Dump.c -index 38e8f23..736bcb6 100644 ---- a/Dump.c -+++ b/Dump.c -@@ -272,6 +272,11 @@ int Restore_metadata(char *dev, char *dir, struct context *c, - fname); - goto err; - } -+ if (stat(fname, &stb) != 0) { -+ pr_err("Could not stat %s for --restore.\n", -+ fname); -+ goto err; -+ } - if (((unsigned long long)stb.st_size) != size) { - pr_err("%s is not the same size as %s - cannot restore.\n", - fname, dev); --- -2.26.2 - diff --git a/0114-super1-fix-Floating-point-exception.patch b/0114-super1-fix-Floating-point-exception.patch deleted file mode 100644 index dd2ab12..0000000 --- a/0114-super1-fix-Floating-point-exception.patch +++ /dev/null @@ -1,41 +0,0 @@ -From e6561c4defe853eaa6be27da0bb6bbd36e197b1f Mon Sep 17 00:00:00 2001 -From: Zhao Heming -Date: Sat, 30 Jan 2021 17:49:54 +0800 -Subject: [PATCH 1/2] super1: fix Floating point exception - -write_bitmap1 didn't check return value of locate_bitmap1, which will -operate bitmap area under invalid bitmap info. - -mdadm core dumped when doing below steps: -``` -node1 # mdadm -C /dev/md0 -b none -e 1.2 -n 2 -l mirror /dev/sda /dev/sdb -node1 # mdadm -Ss -node1 # mdadm -A -U home-cluster --home-cluster=abc /dev/md0 /dev/sda /dev/sdb -Floating point exception (core dumped) -``` - -Signed-off-by: Zhao Heming -Signed-off-by: Jes Sorensen ---- - super1.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/super1.c b/super1.c -index 7bee02659b18..70aa1d3d0219 100644 ---- a/super1.c -+++ b/super1.c -@@ -2717,7 +2717,10 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update - - init_afd(&afd, fd); - -- locate_bitmap1(st, fd, 0); -+ if (locate_bitmap1(st, fd, 0) < 0) { -+ pr_err("Error: Invalid bitmap\n"); -+ return -EINVAL; -+ } - - if (posix_memalign(&buf, 4096, 4096)) - return -ENOMEM; --- -1.8.3.1 - diff --git a/0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch b/0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch deleted file mode 100644 index dff3218..0000000 --- a/0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch +++ /dev/null @@ -1,57 +0,0 @@ -From f7a6246bab1541d7208a5f0f9f0c6cac114e38da Mon Sep 17 00:00:00 2001 -From: Zhao Heming -Date: Wed, 3 Feb 2021 08:22:51 +0800 -Subject: [PATCH 2/2] super1.c: avoid useless sync when bitmap switches from - clustered to none - -With kernel commit 480523feae58 ("md: only call set_in_sync() when it -is expected to succeed."), mddev->in_sync in clustered array is always -zero. It makes metadata resync_offset to always zero. -When assembling a clusterd array with "-U no-bitmap" option, kernel -md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will -trigger raid1 do sync on every bitmap chunk. the sync action is useless, -we should avoid it. - -Related kernel flow: -``` -md_do_sync - mddev->pers->sync_request - raid1_sync_request - md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) - __bitmap_start_sync(bitmap, offset,&blocks1, degraded) - if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */ - *blocks = 1024; - return 1; /* always resync if no bitmap */ - } -``` - -Reprodusible steps: -``` -node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sd{a,b} -node1 # mdadm -Ss -(in another shell, executing & watching: watch -n 1 'cat /proc/mdstat') -node1 # mdadm -A -U no-bitmap /dev/md0 /dev/sd{a,b} -``` - -Signed-off-by: Zhao Heming -Signed-off-by: Jes Sorensen ---- - super1.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/super1.c b/super1.c -index 70aa1d3d0219..7b03329dac91 100644 ---- a/super1.c -+++ b/super1.c -@@ -1346,6 +1346,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - memcpy(bms->uuid, sb->set_uuid, 16); - } else if (strcmp(update, "no-bitmap") == 0) { - sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); -+ if (bms->version == BITMAP_MAJOR_CLUSTERED && !IsBitmapDirty(devname)) -+ sb->resync_offset = MaxSector; - } else if (strcmp(update, "bbl") == 0) { - /* only possible if there is room after the bitmap, or if - * there is no bitmap --- -1.8.3.1 - diff --git a/0116-imsm-nvme-multipath-support.patch b/0116-imsm-nvme-multipath-support.patch deleted file mode 100644 index 4ac6856..0000000 --- a/0116-imsm-nvme-multipath-support.patch +++ /dev/null @@ -1,232 +0,0 @@ -From d835518b6b5381da773e1ce1ae10614239017ecf Mon Sep 17 00:00:00 2001 -From: Blazej Kucman -Date: Fri, 12 Mar 2021 10:30:16 +0100 -Subject: [PATCH] imsm: nvme multipath support -Patch-mainline: mdadm-4.1+ -Git-commit: d835518b6b5381da773e1ce1ae10614239017ecf -References: bsc#1175758 - -Add support for nvme devices which are represented -via nvme-subsystem. -Print warning when multi-path disk is added to RAID. - -Signed-off-by: Oleksandr Shchirskyi -Signed-off-by: Blazej Kucman -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Signed-off-by: Coly Li ---- - platform-intel.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++- - platform-intel.h | 2 ++ - super-intel.c | 38 ++++++++++++++--------- - 3 files changed, 104 insertions(+), 15 deletions(-) - -diff --git a/platform-intel.c b/platform-intel.c -index f1f6d4c..0e1ec3d 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -30,6 +30,8 @@ - #include - #include - -+#define NVME_SUBSYS_PATH "/sys/devices/virtual/nvme-subsystem/" -+ - static int devpath_to_ll(const char *dev_path, const char *entry, - unsigned long long *val); - -@@ -668,12 +670,63 @@ const struct imsm_orom *find_imsm_capability(struct sys_dev *hba) - return NULL; - } - -+/* Check whether the nvme device is represented by nvme subsytem, -+ * if yes virtual path should be changed to hardware device path, -+ * to allow IMSM capabilities detection. -+ * Returns: -+ * hardware path to device - if the device is represented via -+ * nvme virtual subsytem -+ * NULL - if the device is not represented via nvme virtual subsytem -+ */ -+char *get_nvme_multipath_dev_hw_path(const char *dev_path) -+{ -+ DIR *dir; -+ struct dirent *ent; -+ char *rp = NULL; -+ -+ if (strncmp(dev_path, NVME_SUBSYS_PATH, strlen(NVME_SUBSYS_PATH)) != 0) -+ return NULL; -+ -+ dir = opendir(dev_path); -+ if (!dir) -+ return NULL; -+ -+ for (ent = readdir(dir); ent; ent = readdir(dir)) { -+ char buf[strlen(dev_path) + strlen(ent->d_name) + 1]; -+ -+ /* 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); -+ rp = realpath(buf, NULL); -+ break; -+ } -+ -+ closedir(dir); -+ return rp; -+} -+ - char *devt_to_devpath(dev_t dev) - { - char device[46]; -+ char *rp; -+ char *buf; - - sprintf(device, "/sys/dev/block/%d:%d/device", major(dev), minor(dev)); -- return realpath(device, NULL); -+ -+ rp = realpath(device, NULL); -+ if (!rp) -+ return NULL; -+ -+ buf = get_nvme_multipath_dev_hw_path(rp); -+ if (buf) { -+ free(rp); -+ return buf; -+ } -+ -+ return rp; - } - - char *diskfd_to_devpath(int fd) -@@ -797,3 +850,27 @@ int imsm_is_nvme_supported(int disk_fd, int verbose) - } - return 1; - } -+ -+/* Verify if multipath is supported by NVMe controller -+ * Returns: -+ * 0 - not supported -+ * 1 - supported -+ */ -+int is_multipath_nvme(int disk_fd) -+{ -+ char path_buf[PATH_MAX]; -+ char ns_path[PATH_MAX]; -+ char *kname = fd2kname(disk_fd); -+ -+ if (!kname) -+ return 0; -+ sprintf(path_buf, "/sys/block/%s", kname); -+ -+ if (!realpath(path_buf, ns_path)) -+ return 0; -+ -+ if (strncmp(ns_path, NVME_SUBSYS_PATH, strlen(NVME_SUBSYS_PATH)) == 0) -+ return 1; -+ -+ return 0; -+} -diff --git a/platform-intel.h b/platform-intel.h -index 7371478..8396a0f 100644 ---- a/platform-intel.h -+++ b/platform-intel.h -@@ -236,6 +236,7 @@ static inline char *guid_str(char *buf, struct efi_guid guid) - return buf; - } - -+char *get_nvme_multipath_dev_hw_path(const char *dev_path); - char *diskfd_to_devpath(int fd); - __u16 devpath_to_vendor(const char *dev_path); - struct sys_dev *find_driver_devices(const char *bus, const char *driver); -@@ -252,4 +253,5 @@ const struct imsm_orom *get_orom_by_device_id(__u16 device_id); - struct sys_dev *device_by_id(__u16 device_id); - struct sys_dev *device_by_id_and_path(__u16 device_id, const char *path); - int imsm_is_nvme_supported(int disk_fd, int verbose); -+int is_multipath_nvme(int disk_fd); - char *vmd_domain_to_controller(struct sys_dev *hba, char *buf); -diff --git a/super-intel.c b/super-intel.c -index 2bfcad1..6617dd6 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2386,9 +2386,9 @@ static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_b - static int print_nvme_info(struct sys_dev *hba) - { - char buf[1024]; -+ char *device_path; - struct dirent *ent; - DIR *dir; -- char *rp; - int fd; - - dir = opendir("/sys/block/"); -@@ -2397,19 +2397,23 @@ static int print_nvme_info(struct sys_dev *hba) - - for (ent = readdir(dir); ent; ent = readdir(dir)) { - if (strstr(ent->d_name, "nvme")) { -- sprintf(buf, "/sys/block/%s", ent->d_name); -- rp = realpath(buf, NULL); -- if (!rp) -+ fd = open_dev(ent->d_name); -+ if (fd < 0) - continue; -- if (path_attached_to_hba(rp, hba->path)) { -- fd = open_dev(ent->d_name); -- if (!imsm_is_nvme_supported(fd, 0)) { -- if (fd >= 0) -- close(fd); -- free(rp); -- continue; -- } - -+ if (!imsm_is_nvme_supported(fd, 0)) { -+ if (fd >= 0) -+ close(fd); -+ continue; -+ } -+ -+ device_path = diskfd_to_devpath(fd); -+ if (!device_path) { -+ close(fd); -+ continue; -+ } -+ -+ if (path_attached_to_hba(device_path, hba->path)) { - fd2devname(fd, buf); - if (hba->type == SYS_DEV_VMD) - printf(" NVMe under VMD : %s", buf); -@@ -2420,9 +2424,9 @@ static int print_nvme_info(struct sys_dev *hba) - printf(" (%s)\n", buf); - else - printf("()\n"); -- close(fd); - } -- free(rp); -+ free(device_path); -+ close(fd); - } - } - -@@ -5938,6 +5942,7 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - int i; - char *devpath = diskfd_to_devpath(fd); - char controller_path[PATH_MAX]; -+ char *controller_name; - - if (!devpath) { - pr_err("failed to get devpath, aborting\n"); -@@ -5948,6 +5953,11 @@ static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk, - } - - snprintf(controller_path, PATH_MAX-1, "%s/device", devpath); -+ -+ controller_name = basename(devpath); -+ if (is_multipath_nvme(fd)) -+ pr_err("%s controller supports Multi-Path I/O, Intel (R) VROC does not support multipathing\n", controller_name); -+ - free(devpath); - - if (!imsm_is_nvme_supported(dd->fd, 1)) { --- -2.26.2 - diff --git a/0117-Grow-be-careful-of-corrupt-dev_roles-list.patch b/0117-Grow-be-careful-of-corrupt-dev_roles-list.patch deleted file mode 100644 index 4f09315..0000000 --- a/0117-Grow-be-careful-of-corrupt-dev_roles-list.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 8818d4e7fe7cda900d5c00014b05cdde058bdd29 Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Fri, 26 Feb 2021 12:02:36 +1100 -Subject: [PATCH] Grow: be careful of corrupt dev_roles list -Git-commit: 8818d4e7fe7cda900d5c00014b05cdde058bdd29 -Patch-mainline: mdadm-4.1+ -References: bsc#1181619 - -I've seen a case where the dev_roles list of a linear array -was corrupt. ->max_dev was > 128 and > raid_disks, and the -extra slots were '0', not 0xFFFE or 0xFFFF. - -This caused problems when a 128th device was added. - -So: - 1/ make Grow_Add_device more robust so that if numbers - look wrong, it fails-safe. - - 2/ make examine_super1() report details if the dev_roles - array is corrupt. - -Signed-off-by: NeilBrown -Signed-off-by: Jes Sorensen ---- - Grow.c | 15 ++++++++++++--- - super1.c | 48 ++++++++++++++++++++++++++++++++++++++---------- - 2 files changed, 50 insertions(+), 13 deletions(-) - -diff --git a/Grow.c b/Grow.c -index 5c2512f..cec8388 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -197,7 +197,12 @@ int Grow_Add_device(char *devname, int fd, char *newdev) - info.disk.minor = minor(rdev); - info.disk.raid_disk = d; - info.disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE); -- st->ss->update_super(st, &info, "linear-grow-new", newdev, 0, 0, NULL); -+ if (st->ss->update_super(st, &info, "linear-grow-new", newdev, -+ 0, 0, NULL) != 0) { -+ pr_err("Preparing new metadata failed on %s\n", newdev); -+ close(nfd); -+ return 1; -+ } - - if (st->ss->store_super(st, nfd)) { - pr_err("Cannot store new superblock on %s\n", newdev); -@@ -250,8 +255,12 @@ int Grow_Add_device(char *devname, int fd, char *newdev) - info.array.active_disks = nd+1; - info.array.working_disks = nd+1; - -- st->ss->update_super(st, &info, "linear-grow-update", dv, -- 0, 0, NULL); -+ if (st->ss->update_super(st, &info, "linear-grow-update", dv, -+ 0, 0, NULL) != 0) { -+ pr_err("Updating metadata failed on %s\n", dv); -+ close(fd2); -+ return 1; -+ } - - if (st->ss->store_super(st, fd2)) { - pr_err("Cannot store new superblock on %s\n", dv); -diff --git a/super1.c b/super1.c -index b5b379b..7bee026 100644 ---- a/super1.c -+++ b/super1.c -@@ -330,6 +330,7 @@ static void examine_super1(struct supertype *st, char *homehost) - int layout; - unsigned long long sb_offset; - struct mdinfo info; -+ int inconsistent = 0; - - printf(" Magic : %08x\n", __le32_to_cpu(sb->magic)); - printf(" Version : 1"); -@@ -576,14 +577,16 @@ static void examine_super1(struct supertype *st, char *homehost) - if (role == d) - cnt++; - } -- if (cnt == 2) -+ if (cnt == 2 && __le32_to_cpu(sb->level) > 0) - printf("R"); - else if (cnt == 1) - printf("A"); - else if (cnt == 0) - printf("."); -- else -+ else { - printf("?"); -+ inconsistent = 1; -+ } - } - #if 0 - /* This is confusing too */ -@@ -598,6 +601,21 @@ static void examine_super1(struct supertype *st, char *homehost) - #endif - printf(" ('A' == active, '.' == missing, 'R' == replacing)"); - printf("\n"); -+ for (d = 0; d < __le32_to_cpu(sb->max_dev); d++) { -+ unsigned int r = __le16_to_cpu(sb->dev_roles[d]); -+ if (r <= MD_DISK_ROLE_MAX && -+ r > __le32_to_cpu(sb->raid_disks) + delta_extra) -+ inconsistent = 1; -+ } -+ if (inconsistent) { -+ printf("WARNING Array state is inconsistent - each number should appear only once\n"); -+ for (d = 0; d < __le32_to_cpu(sb->max_dev); d++) -+ if (__le16_to_cpu(sb->dev_roles[d]) >= MD_DISK_ROLE_FAULTY) -+ printf(" %d:-", d); -+ else -+ printf(" %d:%d", d, __le16_to_cpu(sb->dev_roles[d])); -+ printf("\n"); -+ } - } - - static void brief_examine_super1(struct supertype *st, int verbose) -@@ -1264,19 +1282,25 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - rv = 1; - } - } else if (strcmp(update, "linear-grow-new") == 0) { -- unsigned int i; -+ int i; - int fd; -- unsigned int max = __le32_to_cpu(sb->max_dev); -+ int max = __le32_to_cpu(sb->max_dev); -+ -+ if (max > MAX_DEVS) -+ return -2; - - for (i = 0; i < max; i++) - if (__le16_to_cpu(sb->dev_roles[i]) >= - MD_DISK_ROLE_FAULTY) - break; -+ if (i != info->disk.number) -+ return -2; - sb->dev_number = __cpu_to_le32(i); -- info->disk.number = i; -- if (i >= max) { -+ -+ if (i == max) - sb->max_dev = __cpu_to_le32(max+1); -- } -+ if (i > max) -+ return -2; - - random_uuid(sb->device_uuid); - -@@ -1302,10 +1326,14 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - } - } else if (strcmp(update, "linear-grow-update") == 0) { - int max = __le32_to_cpu(sb->max_dev); -- sb->raid_disks = __cpu_to_le32(info->array.raid_disks); -- if (info->array.raid_disks > max) { -+ int i = info->disk.number; -+ if (max > MAX_DEVS || i > MAX_DEVS) -+ return -2; -+ if (i > max) -+ return -2; -+ if (i == max) - sb->max_dev = __cpu_to_le32(max+1); -- } -+ sb->raid_disks = __cpu_to_le32(info->array.raid_disks); - sb->dev_roles[info->disk.number] = - __cpu_to_le16(info->disk.raid_disk); - } else if (strcmp(update, "resync") == 0) { --- -2.26.2 - diff --git a/0118-Remove-Spare-drives-line-from-details-for-external-m.patch b/0118-Remove-Spare-drives-line-from-details-for-external-m.patch deleted file mode 100644 index 5a3eb88..0000000 --- a/0118-Remove-Spare-drives-line-from-details-for-external-m.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 8d69bf147ec77447c5d45c17bed7dc017808cc44 Mon Sep 17 00:00:00 2001 -From: Oleksandr Shchirskyi -Date: Fri, 18 Jun 2021 15:53:31 +0200 -Subject: [PATCH] Remove Spare drives line from details for external metadata -Git-commit: 8d69bf147ec77447c5d45c17bed7dc017808cc44 -Patch-mainline: mdadm-4.1+ -References: bsc#1180661, bsc#1182642 - -Arrays with external metadata do not have spare disks directly -assigned to volumes; spare disks belong to containers and are -moved to arrays when the array is degraded/reshaping. -Thus, the display of zero spare disks in volume details is -incorrect and can be confusing. - -Signed-off-by: Oleksandr Shchirskyi -Signed-off-by: Jes Sorensen -Acked-by: Coly Li ---- - Detail.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index cd26fb0..ad56344 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -548,7 +548,8 @@ int Detail(char *dev, struct context *c) - array.working_disks); - if (array.raid_disks) { - printf(" Failed Devices : %d\n", array.failed_disks); -- printf(" Spare Devices : %d\n", array.spare_disks); -+ if (!external) -+ printf(" Spare Devices : %d\n", array.spare_disks); - } - printf("\n"); - if (array.level == 5) { --- -2.31.1 - diff --git a/0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch b/0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch deleted file mode 100644 index 1bb609a..0000000 --- a/0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 601ffa784f03cea843b9b732e561ffea0b8c036f Mon Sep 17 00:00:00 2001 -From: Oleksandr Shchirskyi -Date: Fri, 18 Jun 2021 15:53:32 +0200 -Subject: [PATCH] Don't associate spares with other arrays during RAID Examine -Git-commit: 601ffa784f03cea843b9b732e561ffea0b8c036f -Patch-mainline: mdadm-4.1+ -References: bsc#1180661, bsc#1182642 - -Spares in imsm belong to containers, not volumes, and must go into -a separate container when assembling the RAID. -Remove association spares with other arrays and make Examine print -separate containers for spares. -Auto assemble without config file already works like this. So make -creating a config file and assembling from it consistent with auto -assemble. -With this change, mdadm -Es will add this line to output if spares -are found: -ARRAY metadata=imsm UUID=00000000:00000000:00000000:00000000 - -Signed-off-by: Oleksandr Shchirskyi -Signed-off-by: Jes Sorensen -Acked-by: Coly Li ---- - Examine.c | 2 +- - super-intel.c | 74 +++++++++++++-------------------------------------- - 2 files changed, 20 insertions(+), 56 deletions(-) - -Index: mdadm-4.1/Examine.c -=================================================================== ---- mdadm-4.1.orig/Examine.c -+++ mdadm-4.1/Examine.c -@@ -166,7 +166,7 @@ int Examine(struct mddev_dev *devlist, - int newline = 0; - - ap->st->ss->brief_examine_super(ap->st, c->verbose > 0); -- if (ap->spares) -+ if (ap->spares && !ap->st->ss->external) - newline += printf(" spares=%d", ap->spares); - if (c->verbose > 0) { - newline += printf(" devices"); -Index: mdadm-4.1/super-intel.c -=================================================================== ---- mdadm-4.1.orig/super-intel.c -+++ mdadm-4.1/super-intel.c -@@ -2084,12 +2084,6 @@ static void brief_examine_super_imsm(str - /* We just write a generic IMSM ARRAY entry */ - struct mdinfo info; - char nbuf[64]; -- struct intel_super *super = st->sb; -- -- if (!super->anchor->num_raid_devs) { -- printf("ARRAY metadata=imsm\n"); -- return; -- } - - getinfo_super_imsm(st, &info, NULL); - fname_from_uuid(st, &info, nbuf, ':'); -@@ -3835,12 +3829,9 @@ static void imsm_copy_dev(struct imsm_de - - static int compare_super_imsm(struct supertype *st, struct supertype *tst) - { -- /* -- * return: -+ /* return: - * 0 same, or first was empty, and second was copied -- * 1 second had wrong number -- * 2 wrong uuid -- * 3 wrong other info -+ * 1 sb are different - */ - struct intel_super *first = st->sb; - struct intel_super *sec = tst->sb; -@@ -3852,27 +3843,27 @@ static int compare_super_imsm(struct sup - } - /* in platform dependent environment test if the disks - * use the same Intel hba -- * If not on Intel hba at all, allow anything. -+ * if not on Intel hba at all, allow anything. -+ * doesn't check HBAs if num_raid_devs is not set, as it means -+ * it is a free floating spare, and all spares regardless of HBA type -+ * will fall into separate container during the assembly - */ -- if (!check_env("IMSM_NO_PLATFORM") && first->hba && sec->hba) { -+ if (first->hba && sec->hba && first->anchor->num_raid_devs != 0) { - if (first->hba->type != sec->hba->type) { - fprintf(stderr, - "HBAs of devices do not match %s != %s\n", - get_sys_dev_type(first->hba->type), - get_sys_dev_type(sec->hba->type)); -- return 3; -+ return 1; - } - if (first->orom != sec->orom) { - fprintf(stderr, - "HBAs of devices do not match %s != %s\n", - first->hba->pci_id, sec->hba->pci_id); -- return 3; -+ return 1; - } - } - -- /* if an anchor does not have num_raid_devs set then it is a free -- * floating spare -- */ - if (first->anchor->num_raid_devs > 0 && - sec->anchor->num_raid_devs > 0) { - /* Determine if these disks might ever have been -@@ -3884,7 +3875,7 @@ static int compare_super_imsm(struct sup - - if (memcmp(first->anchor->sig, sec->anchor->sig, - MAX_SIGNATURE_LENGTH) != 0) -- return 3; -+ return 1; - - if (first_family == 0) - first_family = first->anchor->family_num; -@@ -3892,43 +3883,17 @@ static int compare_super_imsm(struct sup - sec_family = sec->anchor->family_num; - - if (first_family != sec_family) -- return 3; -+ return 1; - - } - -- /* if 'first' is a spare promote it to a populated mpb with sec's -- * family number -- */ -- if (first->anchor->num_raid_devs == 0 && -- sec->anchor->num_raid_devs > 0) { -- int i; -- struct intel_dev *dv; -- struct imsm_dev *dev; -- -- /* we need to copy raid device info from sec if an allocation -- * fails here we don't associate the spare -- */ -- for (i = 0; i < sec->anchor->num_raid_devs; i++) { -- dv = xmalloc(sizeof(*dv)); -- dev = xmalloc(sizeof_imsm_dev(get_imsm_dev(sec, i), 1)); -- dv->dev = dev; -- dv->index = i; -- dv->next = first->devlist; -- first->devlist = dv; -- } -- if (i < sec->anchor->num_raid_devs) { -- /* allocation failure */ -- free_devlist(first); -- pr_err("imsm: failed to associate spare\n"); -- return 3; -- } -- first->anchor->num_raid_devs = sec->anchor->num_raid_devs; -- first->anchor->orig_family_num = sec->anchor->orig_family_num; -- first->anchor->family_num = sec->anchor->family_num; -- memcpy(first->anchor->sig, sec->anchor->sig, MAX_SIGNATURE_LENGTH); -- for (i = 0; i < sec->anchor->num_raid_devs; i++) -- imsm_copy_dev(get_imsm_dev(first, i), get_imsm_dev(sec, i)); -- } -+ /* if an anchor does not have num_raid_devs set then it is a free -+ * floating spare. don't assosiate spare with any array, as during assembly -+ * spares shall fall into separate container, from which they can be moved -+ * when necessary -+ */ -+ if (first->anchor->num_raid_devs ^ sec->anchor->num_raid_devs) -+ return 1; - - return 0; - } diff --git a/0120-udev-md-raid-assembly.rules-skip-if-DM_UDEV_DISABLE_.patch b/0120-udev-md-raid-assembly.rules-skip-if-DM_UDEV_DISABLE_.patch deleted file mode 100644 index 2259d39..0000000 --- a/0120-udev-md-raid-assembly.rules-skip-if-DM_UDEV_DISABLE_.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 9e67cb85d6d2aeab773aab56b8b6cdf5b37c1a4e Mon Sep 17 00:00:00 2001 -From: Martin Wilck -Date: Wed, 16 Feb 2022 21:48:52 +0100 -Subject: [PATCH] udev-md-raid-assembly.rules: skip if - DM_UDEV_DISABLE_OTHER_RULES_FLAG - -device-mapper sets the flag DM_UDEV_DISABLE_OTHER_RULES_FLAG to 1 for -devices which are unusable. They may be no set up yet, suspended, or -otherwise unusable (e.g. multipath maps without usable path). This -flag does not necessarily imply SYSTEMD_READY=0 and must therefore -be tested separately. - -Signed-off-by: Martin Wilck ---- - udev-md-raid-assembly.rules | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules -index d668cdd..bc9679f 100644 ---- a/udev-md-raid-assembly.rules -+++ b/udev-md-raid-assembly.rules -@@ -9,6 +9,9 @@ SUBSYSTEM!="block", GOTO="md_inc_end" - - # skip non-initialized devices - ENV{SYSTEMD_READY}=="0", GOTO="md_inc_end" -+# device mapper sets DM_UDEV_DISABLE_OTHER_RULES_FLAG for devices which -+# aren't ready to use -+KERNEL=="dm-*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="md_inc_end" - - # handle potential components of arrays (the ones supported by md) - ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="md_inc" --- -2.35.1 - diff --git a/0121-imsm-support-for-third-Sata-controller.patch b/0121-imsm-support-for-third-Sata-controller.patch deleted file mode 100644 index 316548b..0000000 --- a/0121-imsm-support-for-third-Sata-controller.patch +++ /dev/null @@ -1,125 +0,0 @@ -From f94df5cf83917df50a3436dd067c751504bfc665 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk -Date: Wed, 17 Mar 2021 13:01:54 +0100 -Subject: [PATCH] imsm: support for third Sata controller -Git-commit: f94df5cf83917df50a3436dd067c751504bfc665 -Patch-mainline: mdadm-4.2-rc1~4 -References: bsc#1201297 - -Add new UEFI TSata variable. Remove CSata variable. -This variable has been never exposed by UEFI. -Remove vulnerability to match different hbas with SATA variable. - -Signed-off-by: Mariusz Tkaczyk -Signed-off-by: Jes Sorensen -Acked-by: Coly Li ---- - platform-intel.c | 58 ++++++++++++++++++++++++++---------------------- - 1 file changed, 31 insertions(+), 27 deletions(-) - -diff --git a/platform-intel.c b/platform-intel.c -index 0e1ec3d..2da152f 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -488,7 +488,7 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) - #define SCU_PROP "RstScuV" - #define AHCI_PROP "RstSataV" - #define AHCI_SSATA_PROP "RstsSatV" --#define AHCI_CSATA_PROP "RstCSatV" -+#define AHCI_TSATA_PROP "RsttSatV" - #define VMD_PROP "RstUefiV" - - #define VENDOR_GUID \ -@@ -496,7 +496,8 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) - - #define PCI_CLASS_RAID_CNTRL 0x010400 - --static int read_efi_var(void *buffer, ssize_t buf_size, char *variable_name, struct efi_guid guid) -+static int read_efi_var(void *buffer, ssize_t buf_size, -+ const char *variable_name, struct efi_guid guid) - { - char path[PATH_MAX]; - char buf[GUID_STR_MAX]; -@@ -525,7 +526,8 @@ static int read_efi_var(void *buffer, ssize_t buf_size, char *variable_name, str - return 0; - } - --static int read_efi_variable(void *buffer, ssize_t buf_size, char *variable_name, struct efi_guid guid) -+static int read_efi_variable(void *buffer, ssize_t buf_size, -+ const char *variable_name, struct efi_guid guid) - { - char path[PATH_MAX]; - char buf[GUID_STR_MAX]; -@@ -578,7 +580,9 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) - { - struct imsm_orom orom; - struct orom_entry *ret; -- int err; -+ static const char * const sata_efivars[] = {AHCI_PROP, AHCI_SSATA_PROP, -+ AHCI_TSATA_PROP}; -+ unsigned long i; - - if (check_env("IMSM_TEST_AHCI_EFI") || check_env("IMSM_TEST_SCU_EFI")) - return imsm_platform_test(hba); -@@ -587,35 +591,35 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) - if (check_env("IMSM_TEST_OROM")) - return NULL; - -- if (hba->type == SYS_DEV_SATA && hba->class != PCI_CLASS_RAID_CNTRL) -- return NULL; -- -- err = read_efi_variable(&orom, sizeof(orom), hba->type == SYS_DEV_SAS ? SCU_PROP : AHCI_PROP, VENDOR_GUID); -+ switch (hba->type) { -+ case SYS_DEV_SAS: -+ if (!read_efi_variable(&orom, sizeof(orom), SCU_PROP, -+ VENDOR_GUID)) -+ break; - -- /* try to read variable for second AHCI controller */ -- if (err && hba->type == SYS_DEV_SATA) -- err = read_efi_variable(&orom, sizeof(orom), AHCI_SSATA_PROP, VENDOR_GUID); -+ return NULL; -+ case SYS_DEV_SATA: -+ if (hba->class != PCI_CLASS_RAID_CNTRL) -+ return NULL; - -- /* try to read variable for combined AHCI controllers */ -- if (err && hba->type == SYS_DEV_SATA) { -- static struct orom_entry *csata; -+ for (i = 0; i < ARRAY_SIZE(sata_efivars); i++) { -+ if (!read_efi_variable(&orom, sizeof(orom), -+ sata_efivars[i], VENDOR_GUID)) -+ break; - -- err = read_efi_variable(&orom, sizeof(orom), AHCI_CSATA_PROP, VENDOR_GUID); -- if (!err) { -- if (!csata) -- csata = add_orom(&orom); -- add_orom_device_id(csata, hba->dev_id); -- csata->type = hba->type; -- return &csata->orom; - } -- } -+ if (i == ARRAY_SIZE(sata_efivars)) -+ return NULL; - -- if (hba->type == SYS_DEV_VMD) { -- err = read_efi_variable(&orom, sizeof(orom), VMD_PROP, VENDOR_GUID); -- } -- -- if (err) -+ break; -+ case SYS_DEV_VMD: -+ if (!read_efi_variable(&orom, sizeof(orom), VMD_PROP, -+ VENDOR_GUID)) -+ break; - return NULL; -+ default: -+ return NULL; -+ } - - ret = add_orom(&orom); - add_orom_device_id(ret, hba->dev_id); --- -2.35.3 - diff --git a/0000-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch b/1004-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch similarity index 96% rename from 0000-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch rename to 1004-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch index 1094a45..bd123f0 100644 --- a/0000-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch +++ b/1004-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch @@ -2,6 +2,7 @@ From 6e79d4bd229e5db4e435917daf4c57cd79db9265 Mon Sep 17 00:00:00 2001 From: colyli Date: Wed, 17 Oct 2018 11:08:39 +0800 Subject: [PATCH] Makefile: install mdadm_env.sh to /usr/lib/mdadm +Patch-mainline: N/A, SUSE only patch References: bsc#1111960 Current Makefile installs mdadm_env.sh to /usr/libexec/mdadm but calls it diff --git a/1005-mdadm-enable-Intel-Alderlake-RSTe-configuration.patch b/1005-mdadm-enable-Intel-Alderlake-RSTe-configuration.patch index c6ace72..d312c3b 100644 --- a/1005-mdadm-enable-Intel-Alderlake-RSTe-configuration.patch +++ b/1005-mdadm-enable-Intel-Alderlake-RSTe-configuration.patch @@ -16,18 +16,19 @@ Acked-by: Coly Li platform-intel.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -diff --git a/platform-intel.c b/platform-intel.c -index 5a8729e7..a4d55a38 100644 ---- a/platform-intel.c -+++ b/platform-intel.c -@@ -512,12 +512,14 @@ static const struct imsm_orom *find_imsm_hba_orom(struct sys_dev *hba) +Index: mdadm-4.2/platform-intel.c +=================================================================== +--- mdadm-4.2.orig/platform-intel.c ++++ mdadm-4.2/platform-intel.c +@@ -512,6 +512,7 @@ static const struct imsm_orom *find_imsm #define AHCI_PROP "RstSataV" #define AHCI_SSATA_PROP "RstsSatV" #define AHCI_TSATA_PROP "RsttSatV" +#define AHCI_RST_PROP "RstVmdV" - #define VMD_PROP "RstUefiV" + #define VROC_VMD_PROP "RstUefiV" + #define RST_VMD_PROP "RstVmdV" - #define VENDOR_GUID \ +@@ -519,6 +520,7 @@ static const struct imsm_orom *find_imsm EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6) #define PCI_CLASS_RAID_CNTRL 0x010400 @@ -35,17 +36,17 @@ index 5a8729e7..a4d55a38 100644 static int read_efi_var(void *buffer, ssize_t buf_size, const char *variable_name, struct efi_guid guid) -@@ -604,7 +606,8 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) +@@ -605,7 +607,8 @@ const struct imsm_orom *find_imsm_efi(st struct imsm_orom orom; struct orom_entry *ret; static const char * const sata_efivars[] = {AHCI_PROP, AHCI_SSATA_PROP, - AHCI_TSATA_PROP}; + AHCI_TSATA_PROP, + AHCI_RST_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")) -@@ -622,7 +625,8 @@ const struct imsm_orom *find_imsm_efi(struct sys_dev *hba) +@@ -624,7 +627,8 @@ const struct imsm_orom *find_imsm_efi(st return NULL; case SYS_DEV_SATA: @@ -55,6 +56,3 @@ index 5a8729e7..a4d55a38 100644 return NULL; for (i = 0; i < ARRAY_SIZE(sata_efivars); i++) { --- -2.35.3 - diff --git a/mdadm-4.1.tar.xz b/mdadm-4.1.tar.xz deleted file mode 100644 index 292304e..0000000 --- a/mdadm-4.1.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a -size 440756 diff --git a/mdadm-4.2.tar.xz b/mdadm-4.2.tar.xz new file mode 100644 index 0000000..28ff165 --- /dev/null +++ b/mdadm-4.2.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48567f4688112018d8be8588fd3e6c830d7d2a9ece33334a82973034836b2a0d +size 453624 diff --git a/mdadm.changes b/mdadm.changes index 0b42129..c31ff01 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,282 @@ +------------------------------------------------------------------- +Thu Nov 3 15:58:38 UTC 2022 - Coly Li + +- Update mdadm package to latest mdadm since mdadm-4.2 + (jsc#PED-1009) + * Only patches directly change runtime programs included, + - Unify error message. + 0001-Unify-error-message.patch + - mdadm: Fix double free + 0002-mdadm-Fix-double-free.patch + - Grow_reshape: Add r0 grow size error message and update + 0003-Grow_reshape-Add-r0-grow-size-error-message-and-upda.patch + - udev: adapt rules to systemd v247 + 0004-udev-adapt-rules-to-systemd-v247.patch + - Replace error prone signal() with sigaction() + 0005-Replace-error-prone-signal-with-sigaction.patch + - mdadm: Respect config file location in man + 0006-mdadm-Respect-config-file-location-in-man.patch + - mdadm: Update ReadMe + 0007-mdadm-Update-ReadMe.patch + - mdadm: Update config man regarding default files and + 0008-mdadm-Update-config-man-regarding-default-files-and-.patch + - mdadm: Update config manual + 0009-mdadm-Update-config-manual.patch + - Create, Build: use default_layout() + 0010-Create-Build-use-default_layout.patch + - mdadm: add map_num_s() + 0011-mdadm-add-map_num_s.patch + - mdmon: Stop parsing duplicate options + 0012-mdmon-Stop-parsing-duplicate-options.patch + - Grow: block -n on external volumes. + 0013-Grow-block-n-on-external-volumes.patch + - Incremental: Fix possible memory and resource leaks + 0014-Incremental-Fix-possible-memory-and-resource-leaks.patch + - Mdmonitor: Fix segfault + 0015-Mdmonitor-Fix-segfault.patch + - Mdmonitor: Improve logging method + 0016-Mdmonitor-Improve-logging-method.patch + - Fix possible NULL ptr dereferences and memory leaks + 0017-Fix-possible-NULL-ptr-dereferences-and-memory-leaks.patch + - imsm: Remove possibility for get_imsm_dev to return + 0018-imsm-Remove-possibility-for-get_imsm_dev-to-return-N.patch + - Revert "mdadm: fix coredump of mdadm --monitor -r" + 0019-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch + - util: replace ioctl use with function + 0020-util-replace-ioctl-use-with-function.patch + - mdadm/super1: restore commit 45a87c2f31335 to fix + 0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch + - imsm: introduce get_disk_slot_in_dev() + 0022-imsm-introduce-get_disk_slot_in_dev.patch + - imsm: use same slot across container + 0023-imsm-use-same-slot-across-container.patch + - imsm: block changing slots during creation + 0024-imsm-block-changing-slots-during-creation.patch + - mdadm: block update=ppl for non raid456 levels + 0025-mdadm-block-update-ppl-for-non-raid456-levels.patch + - mdadm: Fix array size mismatch after grow + 0026-mdadm-Fix-array-size-mismatch-after-grow.patch + - mdadm: Remove dead code in imsm_fix_size_mismatch + 0027-mdadm-Remove-dead-code-in-imsm_fix_size_mismatch.patch + - Monitor: use devname as char array instead of pointer + 0028-Monitor-use-devname-as-char-array-instead-of-pointer.patch + - Monitor: use snprintf to fill device name + 0029-Monitor-use-snprintf-to-fill-device-name.patch + - Makefile: Don't build static build with everything and + 0030-Makefile-Don-t-build-static-build-with-everything-an.patch + - DDF: Cleanup validate_geometry_ddf_container() + 0031-DDF-Cleanup-validate_geometry_ddf_container.patch + - DDF: Fix NULL pointer dereference in + 0032-DDF-Fix-NULL-pointer-dereference-in-validate_geometr.patch + - mdadm/Grow: Fix use after close bug by closing after + 0033-mdadm-Grow-Fix-use-after-close-bug-by-closing-after-.patch + - monitor: Avoid segfault when calling NULL + 0034-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch + - mdadm: Fix mdadm -r remove option regression + 0035-mdadm-Fix-mdadm-r-remove-option-regression.patch + - mdadm: Fix optional --write-behind parameter + 0036-mdadm-Fix-optional-write-behind-parameter.patch + - mdadm: Replace obsolete usleep with nanosleep + 0037-mdadm-Replace-obsolete-usleep-with-nanosleep.patch + - mdadm: remove symlink option + 0038-mdadm-remove-symlink-option.patch + - mdadm: move data_offset to struct shape + 0039-mdadm-move-data_offset-to-struct-shape.patch + - mdadm: Don't open md device for CREATE and ASSEMBLE + 0040-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch + - Grow: Split Grow_reshape into helper function + 0041-Grow-Split-Grow_reshape-into-helper-function.patch + - Assemble: check if device is container before + 0042-Assemble-check-if-device-is-container-before-schedul.patch + - super1: report truncated device + 0043-super1-report-truncated-device.patch + - mdadm: Correct typos, punctuation and grammar in man + 0044-mdadm-Correct-typos-punctuation-and-grammar-in-man.patch + - Manage: Block unsafe member failing + 0045-Manage-Block-unsafe-member-failing.patch + - Monitor: Fix statelist memory leaks + 0046-Monitor-Fix-statelist-memory-leaks.patch + - mdadm: added support for Intel Alderlake RST on VMD + 0047-mdadm-added-support-for-Intel-Alderlake-RST-on-VMD-p.patch + - mdadm: Add Documentation entries to systemd services + 0048-mdadm-Add-Documentation-entries-to-systemd-services.patch + - ReadMe: fix command-line help + 0049-ReadMe-fix-command-line-help.patch + - mdadm: replace container level checking with inline + 0050-mdadm-replace-container-level-checking-with-inline.patch + - Mdmonitor: Omit non-md devices + 0051-Mdmonitor-Omit-non-md-devices.patch + +- Remove the following in house patch + 1004-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch + because upstream merged version added in as + 0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch +- Rename 0000-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch + to 1004-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch. + +- Update mdadm package to mdadm-4.2 (jsc#PED-1009) + All important modifications since previous update to mdadm-4.2 + are listed here. + * The patches about Intel Matrix Storage Manager (including + VROC support), + - super-intel.c: Handle errors from calls to get_dev_sector_size() + - imsm: change wrong size verification + - imsm: add generic method to resolve "device" links + - imsm: add devpath_to_char method + - imsm: Limit support to the lowest namespace + - imsm: correct offset for 4k disks in --examine output + - imsm: Fix possible memory leaks and refactor freeing struct dl + - imsm: fix num_data_stripes after raid0 takeover + - imsm: introduce helpers to manage file descriptors + - imsm: free allocated memory in imsm_fix_size_mismatch + - imsm: assert if there is migration but prev_map doesn't exist + * The patches to fix program issues, + - mdadm/super1: It needs to specify int32 for bitmap_offset + - Fix memory leak after "mdadm --detail" + - Utils: Change sprintf to snprintf + - mdadm: fix coredump of mdadm --monitor -r + - Fix error message when creating raid 4, 5 and 10 + - Fix buffer size warning for strcp + - Fix potential overlap dest buffer + - Correct checking if file descriptors are valid + - Monitor: print message before quit for no array to monitor + * Improvement or bug fixes for mdadm itself, + - Assemble: skip devices that don't match uuid instead of aborting the + assembly. + - Assemble: apply sysfs rules + - Assemble: start dirty and degraded array. + - Incremental: Close unclosed mdfd in IncrementalScan() + - Monitor: make libudev dependency optional + - Manage: Call validate_geometry when adding drive to external + container + - Remove Spare drives line from details for external metadata + - Don't associate spares with other arrays during RAID Examine + - Add error handling for chunk size in RAID1 + - Add monitor delay parameter to mdadm.conf + - disallow create or grow clustered bitmap with writemostly set + - mdadm/Detail: Can't show container name correctly when unpluging disks + - mdadm: block creation with long names + - mdadm: fix growing containers + +- Remove the following patches because they are all included + in mdadm-4.2, + - 0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch + - 0002-Document-PART-POLICY-lines.patch + - 0003-policy-support-devices-with-multiple-paths.patch + - 0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch + - 0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch + - 0006-imsm-update-metadata-correctly-while-raid10-double-d.patch + - 0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch + - 0008-Grow-avoid-overflow-in-compute_backup_blocks.patch + - 0009-Grow-report-correct-new-chunk-size.patch + - 0010-policy.c-prevent-NULL-pointer-referencing.patch + - 0012-policy.c-Fix-for-compiler-error.patch + - 0013-imsm-finish-recovery-when-drive-with-rebuild-fails.patch + - 0014-imsm-fix-reshape-for-2TB-drives.patch + - 0015-Fix-spelling-typos.patch + - 0016-Detail.c-do-not-skip-first-character-when-calling-xs.patch + - 0018-Fix-reshape-for-decreasing-data-offset.patch + - 0019-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch + - 0020-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch + - 0021-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch + - 0022-Assemble-Fix-starting-array-with-initial-reshape-che.patch + - 0023-add-missing-units-to-examine.patch + - 0024-imsm-fix-spare-activation-for-old-matrix-arrays.patch + - 0025-Create-Block-rounding-size-to-max.patch + - 0026-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch + - 0027-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch + - 0028-Enable-probe_roms-to-scan-more-than-6-roms.patch + - 0029-super-intel-Fix-issue-with-abs-being-irrelevant.patch + - 0030-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch + - 0031-super-intel-Use-put_unaligned-in-split_ull.patch + - 0032-mdadm-load-default-sysfs-attributes-after-assemblati.patch + - 0033-mdadm.h-include-sysmacros.h-unconditionally.patch + - 0034-mdadm-add-no-devices-to-avoid-component-devices-deta.patch + - 0035-udev-add-no-devices-option-for-calling-mdadm-detail.patch + - 0036-imsm-close-removed-drive-fd.patch + - 0037-mdadm-check-value-returned-by-snprintf-against-error.patch + - 0038-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch + - 0039-mdadm-force-a-uuid-swap-on-big-endian.patch + - 0040-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch + - 0041-Init-devlist-as-an-array.patch + - 0042-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch + - 0043-udev-allow-for-udev-attribute-reading-bug.patch + - 0044-imsm-save-current_vol-number.patch + - 0045-imsm-allow-to-specify-second-volume-size.patch + - 0046-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch + - 0050-mdcheck-use-to-pass-variable-to-mdcheck.patch + - 0051-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch + - 0052-super-intel-don-t-mark-structs-packed-unnecessarily.patch + - 0053-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch + - 0054-Remove-last-traces-of-HOT_ADD_DISK.patch + - 0055-Fix-up-a-few-formatting-issues.patch + - 0056-Remove-unused-code.patch + - 0057-imsm-return-correct-uuid-for-volume-in-detail.patch + - 0058-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch + - 0059-Create-add-support-for-RAID0-layouts.patch + - 0060-Assemble-add-support-for-RAID0-layouts.patch + - 0061-Respect-CROSS_COMPILE-when-CC-is-the-default.patch + - 0062-Change-warning-message.patch + - 0063-mdcheck-service-can-t-start-succesfully-because-of-s.patch + - 0064-imsm-Update-grow-manual.patch + - 0065-Add-support-for-Tebibytes.patch + - 0066-imsm-fill-working_disks-according-to-metadata.patch + - 0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch + - 0068-Remove-the-legacy-whitespace.patch + - 0069-imsm-pass-subarray-id-to-kill_subarray-function.patch + - 0070-imsm-Remove-dump-restore-implementation.patch + - 0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch + - 0072-Detail-adding-sync-status-for-cluster-device.patch + - 0073-imsm-Correct-minimal-device-size.patch + - 0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch + - 0075-imsm-support-the-Array-Creation-Time-field-in-metada.patch + - 0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch + - 0077-udev-Ignore-change-event-for-imsm.patch + - 0078-Manage-imsm-Write-metadata-before-add.patch + - 0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch + - 0080-clean-up-meaning-of-small-typo.patch + - 0081-Assemble.c-respect-force-flag.patch + - 0082-mdcheck-Log-when-done.patch + - 0083-Makefile-add-EXTRAVERSION-support.patch + - 0084-uuid.c-split-uuid-stuffs-from-util.c.patch + - 0085-Include-count-for-0-character-when-using-strncpy-to-.patch + - 0086-restripe-fix-ignoring-return-value-of-read-and-lseek.patch + - 0087-Block-overwriting-existing-links-while-manual-assemb.patch + - 0088-Detect-too-small-device-error-rather-than-underflow-.patch + - 0089-Use-more-secure-HTTPS-URLs.patch + - 0090-Update-link-to-Intel-page-for-IMSM.patch + - 0091-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch + - 0092-Specify-nodes-number-when-updating-cluster-nodes.patch + - 0093-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch + - 0094-manual-update-examine-badblocks.patch + - 0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch + - 0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch + - 0097-Monitor-refresh-mdstat-fd-after-select.patch + - 0098-Monitor-stop-notifing-about-containers.patch + - 0099-mdmonitor-set-small-delay-once.patch + - 0100-Check-if-other-Monitor-instance-running-before-fork.patch + - 0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch + - 0102-Detail-fix-segfault-during-IMSM-raid-creation.patch + - 0103-Create.c-close-mdfd-and-generate-uevent.patch + - 0104-imsm-update-num_data_stripes-according-to-dev_size.patch + - 0105-imsm-remove-redundant-calls-to-imsm_get_map.patch + - 0106-Monitor-don-t-use-default-modes-when-creating-a-file.patch + - 0107-imsm-limit-support-to-first-NVMe-namespace.patch + - 0108-mdadm-Unify-forks-behaviour.patch + - 0109-mdadm-Detail-show-correct-state-for-clustered-array.patch + - 0110-Make-target-to-install-binaries-only.patch + - 0111-udev-start-grow-service-automatically.patch + - 0112-Incremental-Remove-redundant-spare-movement-logic.patch + - 0113-Dump-get-stat-from-a-wrong-metadata-file-when-restor.patch + - 0114-super1-fix-Floating-point-exception.patch + - 0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch + - 0116-imsm-nvme-multipath-support.patch + - 0117-Grow-be-careful-of-corrupt-dev_roles-list.patch + - 0118-Remove-Spare-drives-line-from-details-for-external-m.patch + - 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch + - 0120-udev-md-raid-assembly.rules-skip-if-DM_UDEV_DISABLE_.patch + - 0121-imsm-support-for-third-Sata-controller.patch + ------------------------------------------------------------------- Mon Sep 19 14:18:41 CST 2022 - Coly Li diff --git a/mdadm.spec b/mdadm.spec index 970133d..10487c3 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -22,7 +22,7 @@ %endif Name: mdadm -Version: 4.1 +Version: 4.2 Release: 0 BuildRequires: binutils-devel BuildRequires: groff @@ -43,127 +43,61 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.xz Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm -Patch0: 0000-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch -Patch1: 0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch -Patch2: 0002-Document-PART-POLICY-lines.patch -Patch3: 0003-policy-support-devices-with-multiple-paths.patch -Patch4: 0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch -Patch5: 0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch -Patch6: 0006-imsm-update-metadata-correctly-while-raid10-double-d.patch -Patch7: 0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch -Patch8: 0008-Grow-avoid-overflow-in-compute_backup_blocks.patch -Patch9: 0009-Grow-report-correct-new-chunk-size.patch -Patch10: 0010-policy.c-prevent-NULL-pointer-referencing.patch -Patch11: 0012-policy.c-Fix-for-compiler-error.patch -Patch12: 0013-imsm-finish-recovery-when-drive-with-rebuild-fails.patch -Patch13: 0014-imsm-fix-reshape-for-2TB-drives.patch -Patch14: 0015-Fix-spelling-typos.patch -Patch15: 0016-Detail.c-do-not-skip-first-character-when-calling-xs.patch -Patch16: 0018-Fix-reshape-for-decreasing-data-offset.patch -Patch17: 0019-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch -Patch18: 0020-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch -Patch19: 0021-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch -Patch20: 0022-Assemble-Fix-starting-array-with-initial-reshape-che.patch -Patch21: 0023-add-missing-units-to-examine.patch -Patch22: 0024-imsm-fix-spare-activation-for-old-matrix-arrays.patch -Patch23: 0025-Create-Block-rounding-size-to-max.patch -Patch24: 0026-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch -Patch25: 0027-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch -Patch26: 0028-Enable-probe_roms-to-scan-more-than-6-roms.patch -Patch27: 0029-super-intel-Fix-issue-with-abs-being-irrelevant.patch -Patch28: 0030-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch -Patch29: 0031-super-intel-Use-put_unaligned-in-split_ull.patch -Patch30: 0032-mdadm-load-default-sysfs-attributes-after-assemblati.patch -Patch31: 0033-mdadm.h-include-sysmacros.h-unconditionally.patch -Patch32: 0034-mdadm-add-no-devices-to-avoid-component-devices-deta.patch -Patch33: 0035-udev-add-no-devices-option-for-calling-mdadm-detail.patch -Patch34: 0036-imsm-close-removed-drive-fd.patch -Patch35: 0037-mdadm-check-value-returned-by-snprintf-against-error.patch -Patch36: 0038-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch -Patch37: 0039-mdadm-force-a-uuid-swap-on-big-endian.patch -Patch38: 0040-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch -Patch39: 0041-Init-devlist-as-an-array.patch -Patch40: 0042-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch -Patch41: 0043-udev-allow-for-udev-attribute-reading-bug.patch -Patch42: 0044-imsm-save-current_vol-number.patch -Patch43: 0045-imsm-allow-to-specify-second-volume-size.patch -Patch44: 0046-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch -Patch45: 0050-mdcheck-use-to-pass-variable-to-mdcheck.patch -Patch46: 0051-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch -Patch47: 0052-super-intel-don-t-mark-structs-packed-unnecessarily.patch -Patch48: 0053-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch -Patch49: 0054-Remove-last-traces-of-HOT_ADD_DISK.patch -Patch50: 0055-Fix-up-a-few-formatting-issues.patch -Patch51: 0056-Remove-unused-code.patch -Patch52: 0057-imsm-return-correct-uuid-for-volume-in-detail.patch -Patch53: 0058-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch -Patch54: 0059-Create-add-support-for-RAID0-layouts.patch -Patch55: 0060-Assemble-add-support-for-RAID0-layouts.patch -Patch56: 0061-Respect-CROSS_COMPILE-when-CC-is-the-default.patch -Patch57: 0062-Change-warning-message.patch -Patch58: 0063-mdcheck-service-can-t-start-succesfully-because-of-s.patch -Patch59: 0064-imsm-Update-grow-manual.patch -Patch60: 0065-Add-support-for-Tebibytes.patch -Patch61: 0066-imsm-fill-working_disks-according-to-metadata.patch -Patch62: 0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch -Patch63: 0068-Remove-the-legacy-whitespace.patch -Patch64: 0069-imsm-pass-subarray-id-to-kill_subarray-function.patch -Patch65: 0070-imsm-Remove-dump-restore-implementation.patch -Patch66: 0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch -Patch67: 0072-Detail-adding-sync-status-for-cluster-device.patch -Patch73: 0073-imsm-Correct-minimal-device-size.patch -Patch74: 0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch -Patch75: 0075-imsm-support-the-Array-Creation-Time-field-in-metada.patch -Patch76: 0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch -Patch77: 0077-udev-Ignore-change-event-for-imsm.patch -Patch78: 0078-Manage-imsm-Write-metadata-before-add.patch -Patch79: 0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch -Patch80: 0080-clean-up-meaning-of-small-typo.patch -Patch81: 0081-Assemble.c-respect-force-flag.patch -Patch82: 0082-mdcheck-Log-when-done.patch -Patch83: 0083-Makefile-add-EXTRAVERSION-support.patch -Patch84: 0084-uuid.c-split-uuid-stuffs-from-util.c.patch -Patch85: 0085-Include-count-for-0-character-when-using-strncpy-to-.patch -Patch86: 0086-restripe-fix-ignoring-return-value-of-read-and-lseek.patch -Patch87: 0087-Block-overwriting-existing-links-while-manual-assemb.patch -Patch88: 0088-Detect-too-small-device-error-rather-than-underflow-.patch -Patch89: 0089-Use-more-secure-HTTPS-URLs.patch -Patch90: 0090-Update-link-to-Intel-page-for-IMSM.patch -Patch91: 0091-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch -Patch92: 0092-Specify-nodes-number-when-updating-cluster-nodes.patch -Patch93: 0093-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch -Patch94: 0094-manual-update-examine-badblocks.patch -Patch95: 0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch -Patch96: 0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch -Patch97: 0097-Monitor-refresh-mdstat-fd-after-select.patch -Patch98: 0098-Monitor-stop-notifing-about-containers.patch -Patch99: 0099-mdmonitor-set-small-delay-once.patch -Patch100: 0100-Check-if-other-Monitor-instance-running-before-fork.patch -Patch101: 0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch -Patch102: 0102-Detail-fix-segfault-during-IMSM-raid-creation.patch -Patch103: 0103-Create.c-close-mdfd-and-generate-uevent.patch -Patch104: 0104-imsm-update-num_data_stripes-according-to-dev_size.patch -Patch105: 0105-imsm-remove-redundant-calls-to-imsm_get_map.patch -Patch106: 0106-Monitor-don-t-use-default-modes-when-creating-a-file.patch -Patch107: 0107-imsm-limit-support-to-first-NVMe-namespace.patch -Patch108: 0108-mdadm-Unify-forks-behaviour.patch -Patch109: 0109-mdadm-Detail-show-correct-state-for-clustered-array.patch -Patch110: 0110-Make-target-to-install-binaries-only.patch -Patch111: 0111-udev-start-grow-service-automatically.patch -Patch112: 0112-Incremental-Remove-redundant-spare-movement-logic.patch -Patch113: 0113-Dump-get-stat-from-a-wrong-metadata-file-when-restor.patch -Patch114: 0114-super1-fix-Floating-point-exception.patch -Patch115: 0115-super1.c-avoid-useless-sync-when-bitmap-switches-fro.patch -Patch116: 0116-imsm-nvme-multipath-support.patch -Patch117: 0117-Grow-be-careful-of-corrupt-dev_roles-list.patch -Patch118: 0118-Remove-Spare-drives-line-from-details-for-external-m.patch -Patch119: 0119-Don-t-associate-spares-with-other-arrays-during-RAID.patch -Patch120: 0120-udev-md-raid-assembly.rules-skip-if-DM_UDEV_DISABLE_.patch -Patch121: 0121-imsm-support-for-third-Sata-controller.patch +Patch1: 0001-Unify-error-message.patch +Patch2: 0002-mdadm-Fix-double-free.patch +Patch3: 0003-Grow_reshape-Add-r0-grow-size-error-message-and-upda.patch +Patch4: 0004-udev-adapt-rules-to-systemd-v247.patch +Patch5: 0005-Replace-error-prone-signal-with-sigaction.patch +Patch6: 0006-mdadm-Respect-config-file-location-in-man.patch +Patch7: 0007-mdadm-Update-ReadMe.patch +Patch8: 0008-mdadm-Update-config-man-regarding-default-files-and-.patch +Patch9: 0009-mdadm-Update-config-manual.patch +Patch10: 0010-Create-Build-use-default_layout.patch +Patch11: 0011-mdadm-add-map_num_s.patch +Patch12: 0012-mdmon-Stop-parsing-duplicate-options.patch +Patch13: 0013-Grow-block-n-on-external-volumes.patch +Patch14: 0014-Incremental-Fix-possible-memory-and-resource-leaks.patch +Patch15: 0015-Mdmonitor-Fix-segfault.patch +Patch16: 0016-Mdmonitor-Improve-logging-method.patch +Patch17: 0017-Fix-possible-NULL-ptr-dereferences-and-memory-leaks.patch +Patch18: 0018-imsm-Remove-possibility-for-get_imsm_dev-to-return-N.patch +Patch19: 0019-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch +Patch20: 0020-util-replace-ioctl-use-with-function.patch +Patch21: 0021-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch +Patch22: 0022-imsm-introduce-get_disk_slot_in_dev.patch +Patch23: 0023-imsm-use-same-slot-across-container.patch +Patch24: 0024-imsm-block-changing-slots-during-creation.patch +Patch25: 0025-mdadm-block-update-ppl-for-non-raid456-levels.patch +Patch26: 0026-mdadm-Fix-array-size-mismatch-after-grow.patch +Patch27: 0027-mdadm-Remove-dead-code-in-imsm_fix_size_mismatch.patch +Patch28: 0028-Monitor-use-devname-as-char-array-instead-of-pointer.patch +Patch29: 0029-Monitor-use-snprintf-to-fill-device-name.patch +Patch30: 0030-Makefile-Don-t-build-static-build-with-everything-an.patch +Patch31: 0031-DDF-Cleanup-validate_geometry_ddf_container.patch +Patch32: 0032-DDF-Fix-NULL-pointer-dereference-in-validate_geometr.patch +Patch33: 0033-mdadm-Grow-Fix-use-after-close-bug-by-closing-after-.patch +Patch34: 0034-monitor-Avoid-segfault-when-calling-NULL-get_bad_blo.patch +Patch35: 0035-mdadm-Fix-mdadm-r-remove-option-regression.patch +Patch36: 0036-mdadm-Fix-optional-write-behind-parameter.patch +Patch37: 0037-mdadm-Replace-obsolete-usleep-with-nanosleep.patch +Patch38: 0038-mdadm-remove-symlink-option.patch +Patch39: 0039-mdadm-move-data_offset-to-struct-shape.patch +Patch40: 0040-mdadm-Don-t-open-md-device-for-CREATE-and-ASSEMBLE.patch +Patch41: 0041-Grow-Split-Grow_reshape-into-helper-function.patch +Patch42: 0042-Assemble-check-if-device-is-container-before-schedul.patch +Patch43: 0043-super1-report-truncated-device.patch +Patch44: 0044-mdadm-Correct-typos-punctuation-and-grammar-in-man.patch +Patch45: 0045-Manage-Block-unsafe-member-failing.patch +Patch46: 0046-Monitor-Fix-statelist-memory-leaks.patch +Patch47: 0047-mdadm-added-support-for-Intel-Alderlake-RST-on-VMD-p.patch +Patch48: 0048-mdadm-Add-Documentation-entries-to-systemd-services.patch +Patch49: 0049-ReadMe-fix-command-line-help.patch +Patch50: 0050-mdadm-replace-container-level-checking-with-inline.patch +Patch51: 0051-Mdmonitor-Omit-non-md-devices.patch Patch1001: 1001-display-timeout-status.patch Patch1002: 1002-OnCalendar-format-fix-of-mdcheck_start-timer.patch Patch1003: 1003-mdadm-treat-the-Dell-softraid-array-as-local-array.patch -Patch1004: 1004-mdadm-super1-restore-commit-45a87c2f31335-to-fix-clu.patch +Patch1004: 1004-Makefile-install-mdadm_env.sh-to-usr-lib-mdadm.patch Patch1005: 1005-mdadm-enable-Intel-Alderlake-RSTe-configuration.patch %define _udevdir %(pkg-config --variable=udevdir udev) %define _systemdshutdowndir %{_unitdir}/../system-shutdown @@ -173,7 +107,6 @@ mdadm is a program that can be used to control Linux md devices. %prep %setup -q -a1 -%patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 @@ -225,71 +158,6 @@ mdadm is a program that can be used to control Linux md devices. %patch49 -p1 %patch50 -p1 %patch51 -p1 -%patch52 -p1 -%patch53 -p1 -%patch54 -p1 -%patch55 -p1 -%patch56 -p1 -%patch57 -p1 -%patch58 -p1 -%patch59 -p1 -%patch60 -p1 -%patch61 -p1 -%patch62 -p1 -%patch63 -p1 -%patch64 -p1 -%patch65 -p1 -%patch66 -p1 -%patch67 -p1 -%patch73 -p1 -%patch74 -p1 -%patch75 -p1 -%patch76 -p1 -%patch77 -p1 -%patch78 -p1 -%patch79 -p1 -%patch80 -p1 -%patch81 -p1 -%patch82 -p1 -%patch83 -p1 -%patch84 -p1 -%patch85 -p1 -%patch86 -p1 -%patch87 -p1 -%patch88 -p1 -%patch89 -p1 -%patch90 -p1 -%patch91 -p1 -%patch92 -p1 -%patch93 -p1 -%patch94 -p1 -%patch95 -p1 -%patch96 -p1 -%patch97 -p1 -%patch98 -p1 -%patch99 -p1 -%patch100 -p1 -%patch101 -p1 -%patch102 -p1 -%patch103 -p1 -%patch104 -p1 -%patch105 -p1 -%patch106 -p1 -%patch107 -p1 -%patch108 -p1 -%patch109 -p1 -%patch110 -p1 -%patch111 -p1 -%patch112 -p1 -%patch113 -p1 -%patch114 -p1 -%patch115 -p1 -%patch116 -p1 -%patch117 -p1 -%patch118 -p1 -%patch119 -p1 -%patch120 -p1 -%patch121 -p1 %patch1001 -p1 %patch1002 -p1 %patch1003 -p1