Hello community,
here is the log from the commit of package mdadm for openSUSE:Factory checked in at 2017-12-08 12:54:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mdadm (Old)
and /work/SRC/openSUSE:Factory/.mdadm.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mdadm"
Fri Dec 8 12:54:36 2017 rev:111 rq:548348 version:4.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/mdadm/mdadm.changes 2017-11-25 08:40:37.422706974 +0100
+++ /work/SRC/openSUSE:Factory/.mdadm.new/mdadm.changes 2017-12-08 12:54:42.311498638 +0100
@@ -1,0 +2,209 @@
+Mon Dec 4 17:11:14 UTC 2017 - colyli@suse.com
+
+- Update mdadm for SLE15, for bug fixes and new feature enhancement
+- 1000-The-mdcheck-script-now-adds-messages-to-the-system.patch is
+ removed because upstream has similar fix with almost identical
+ funcationality.
+- The following patches are not deleted indeed, they are renamed
+ and added into all other new-added patches with different perfix
+ numbers,
+ 0038-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
+ 0039-Create-Fixup-various-whitespace-issues.patch
+ 0040-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
+ 0041-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
+ 0042-mdadm-manpage-update-manpage-for-readonly-parameter.patch
+ 0043-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
+ 0044-maps-Terminate-modes-map-correctly.patch
+ 0045-Grow_continue_command-ensure-content-is-properly-ini.patch
+ 0046-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
+ 0047-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
+ 0048-Grow-set-component-size-prior-to-array-size.patch
+ 0049-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
+ 0050-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
+ 0051-IMSM-Correct-examine-output-for-4k-disks.patch
+ 0052-imsm-allow-drives-in-a-container-regardless-of-secto.patch
+ 0053-imsm-allocate-buffer-to-support-maximum-sector-size.patch
+ 0054-imsm-don-t-allow-disks-with-different-sector-size-in.patch
+ 0055-Allow-more-spare-selection-criteria.patch
+ 0056-Add-sector-size-as-spare-selection-criterion.patch
+ 0057-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
+ 0058-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
+ 0059-To-support-clustered-raid10.patch
+ 0060-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
+- The following patche set includes the above renamed patches,
+ they have bug fixes for bsc#1068030, bsc#1069165, bsc#1069167,
+ and some other fixes and enhancement for raid5 ppl, imsm, and
+ general mdadm code,
+ 0038-mdadm-Create-declaring-an-existing-struct-within-sam.patch
+ 0039-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
+ 0040-Create-Fixup-various-whitespace-issues.patch
+ 0041-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
+ 0042-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
+ 0043-mdadm-manpage-update-manpage-for-readonly-parameter.patch
+ 0044-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
+ 0045-maps-Terminate-modes-map-correctly.patch
+ 0046-Grow_continue_command-ensure-content-is-properly-ini.patch
+ 0047-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
+ 0048-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
+ 0049-Grow-set-component-size-prior-to-array-size.patch
+ 0050-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
+ 0051-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
+ 0052-IMSM-Correct-examine-output-for-4k-disks.patch
+ 0053-imsm-allow-drives-in-a-container-regardless-of-secto.patch
+ 0054-imsm-allocate-buffer-to-support-maximum-sector-size.patch
+ 0055-imsm-don-t-allow-disks-with-different-sector-size-in.patch
+ 0056-mdadm-mdmon-deleted-the-abort_reshape-never-invoked.patch
+ 0057-util-Introduce-md_get_array_info.patch
+ 0058-Incremental-Remove-redundant-call-for-GET_ARRAY_INFO.patch
+ 0059-util-Introduce-md_get_disk_info.patch
+ 0060-util-Introduce-md_set_array_info.patch
+ 0061-md_u-Remove-some-unused-ioctl-declarations.patch
+ 0062-mdadm-grow-reshape-would-be-stuck-from-raid1-to-raid.patch
+ 0063-sysfs-Use-the-presence-of-sys-block-dev-md-as-indica.patch
+ 0064-sysfs-Make-sysfs_init-return-an-error-code.patch
+ 0065-util-must_be_container-Use-sysfs_read-GET_VERSION-to.patch
+ 0066-util-set_array_info-Simplify-code-since-md_get_versi.patch
+ 0067-Assemble-Assemble-Stop-checking-kernel-md-driver-ver.patch
+ 0068-Build-Stop-bothering-about-supporting-md-driver-olde.patch
+ 0069-Grow-Stop-bothering-about-md-driver-versions-older-t.patch
+ 0070-Detail-Stop-bothering-about-md-drivers-older-than-0..patch
+ 0071-Create-Remove-all-attemps-to-handle-md-driver-older-.patch
+ 0072-Manage-Remove-all-references-to-md_get_version.patch
+ 0073-Query-Remove-all-references-to-md_get_version.patch
+ 0074-bitmap-Remove-use-of-md_get_version.patch
+ 0075-mdmon-Stop-bothering-about-md_get_version.patch
+ 0076-mdopen-open_mddev-Use-md_get_array_info-to-determine.patch
+ 0077-mdassemble-Use-md_get_array_info-to-check-for-valid-.patch
+ 0078-Assemble-Assemble-Get-rid-of-last-use-of-md_get_vers.patch
+ 0079-util-Finally-kill-off-md_get_version.patch
+ 0080-mdadm-Fail-for-kernels-older-than-2.6.15.patch
+ 0081-Revert-mdadm-grow-reshape-would-be-stuck-from-raid1-.patch
+ 0082-Retire-mdassemble.patch
+ 0083-super1-Clean-up-various-style-abuses.patch
+ 0084-Detail-Remove-pre-2.6-code-for-printing-info-on-rebu.patch
+ 0085-Assemble-Remove-obsolete-test-for-kernels-older-than.patch
+ 0086-Detail-Fixup-ugly-if-foo-abuse.patch
+ 0087-Query-Handle-error-returned-by-fstat.patch
+ 0088-Query-Use-sysfs-to-obtain-data-if-possible.patch
+ 0089-sysfs-Parse-array_state-in-sysfs_read.patch
+ 0090-util-Introduce-md_array_active-helper.patch
+ 0091-maps-Use-keyvalue-for-null-terminator-to-indicate-un.patch
+ 0092-util-Get-rid-of-unused-enough_fd.patch
+ 0093-mdadm-retire-mdassemble-in-make-everything.patch
+ 0094-Query-Quiet-gcc-since-it-cannot-know-errno-0-in-this.patch
+ 0095-Makefile-Default-to-O2-optimization.patch
+ 0096-maps-Simplify-implementation-of-map_name.patch
+ 0097-Don-t-use-UnSet-with-consistency_policy.patch
+ 0098-Detail-determine-array-state-from-sysfs.patch
+ 0099-Detail-Respect-code-lines-are-80-character-wide.patch
+ 0100-Detail-Reinstate-support-for-not-having-sysfs.patch
+ 0101-Incremental-Use-md_array_active-where-applicable.patch
+ 0102-Incremental-Cleanup-some-if-statement-spaghetti.patch
+ 0103-Create-tell-udev-md-device-is-not-ready-when-first-c.patch
+ 0104-Incremental-Use-md_array_active-to-determine-state-o.patch
+ 0105-Manage-Manage_ro-Use-md_array_active.patch
+ 0106-IMSM-Initialize-my_vol_raid_dev_num-during-vol-creat.patch
+ 0107-Grow-Grow_continue_command-Avoid-aliasing-array-vari.patch
+ 0108-change-back-0644-permission-for-Grow.c.patch
+ 0109-util-md_array_valid-Introduce-md_array_valid-helper.patch
+ 0110-kernel-patch-Remove-obsolete-kernel-patches-against-.patch
+ 0111-mdassemble-Kill-off-the-last-remains.patch
+ 0112-mdadm-util-unify-fstat-checking-blkdev-into-function.patch
+ 0113-mdadm-util-unify-stat-checking-blkdev-into-function.patch
+ 0114-Fix-typo-in-new-udev-rule.patch
+ 0115-Incremental-return-is-not-a-function.patch
+ 0116-sysfs-sysfs_read-Count-active_disks-and-failed_disks.patch
+ 0117-container_members_max_degradation-Switch-to-using-sy.patch
+ 0118-IncrementalScan-Use-md_array_active-instead-of-md_ge.patch
+ 0119-Mention-endian-in-documentation-for-update-byte-orde.patch
+ 0120-Monitor-Use-md_array_active-instead-of-manually-fidd.patch
+ 0121-Monitor-Code-is-80-characters-per-line.patch
+ 0122-mdadm-md.4-set-page-length-as-1000-to-avoid-warnings.patch
+ 0123-Allow-more-spare-selection-criteria.patch
+ 0124-Add-sector-size-as-spare-selection-criterion.patch
+ 0125-Monitor-check_array-Centralize-exit-path.patch
+ 0126-Monitor-check_array-Reduce-duplicated-error-handling.patch
+ 0127-Monitor-check_array-Declate-mdinfo-instance-globally.patch
+ 0128-Monitor-check_array-Read-sysfs-entry-earlier.patch
+ 0129-Monitor-check_array-Obtain-RAID-level-from-syfs.patch
+ 0130-Monitor-check_array-Get-failed_disks-from-sysfs.patch
+ 0131-Monitor-check_array-Get-array_disks-from-sysfs.patch
+ 0132-Monitor-check_array-Get-nr_disks-active_disks-and-sp.patch
+ 0133-sysfs-sysfs_read-Count-working_disks.patch
+ 0134-Monitor-check_array-Use-working_disks-from-sysfs.patch
+ 0135-retire-the-APIs-that-driver-no-longer-supports.patch
+ 0136-Monitor-Not-much-point-declaring-mdlist-in-both-fork.patch
+ 0137-Monitor-mailfrom-is-initialized-correctly.patch
+ 0138-Monitor-Fixup-a-pile-of-whitespace-issues.patch
+ 0139-mdadm-Uninitialized-variable-rdev.patch
+ 0140-super-ddf-sysfs_read-takes-a-pointer-as-device-name-.patch
+ 0141-mdadm-Fixup-a-large-number-of-bad-formatting-of-logi.patch
+ 0142-mdadm-Fixup-more-broken-logical-operator-formatting.patch
+ 0143-mdadm-Fix-broken-formatting.patch
+ 0144-mdadm-Fixup-broken-formatting.patch
+ 0145-Detail-don-t-exit-if-ioctl-has-been-successful.patch
+ 0146-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
+ 0147-md_u-Remove-unused-ioctl-declaration-of-START_ARRAY.patch
+ 0148-Get-failed-disk-count-from-array-state.patch
+ 0149-Monitor-don-t-assume-mdadm-parameter-is-a-block-devi.patch
+ 0150-super1-Always-round-data-offset-to-1M.patch
+ 0151-mdadm-r5cache-allow-adding-journal-to-array-without-.patch
+ 0152-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
+ 0153-Detail-correct-output-for-active-arrays.patch
+ 0154-imsm-rebuild-from-2-disk-RAID10.patch (bsc#1069165)
+ 0155-Error-messages-should-end-with-a-newline-character.patch
+ 0156-Use-correct-syntax-for-passing-DEVLINKS-to-mdadm-fro.patch
+ 0157-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
+ 0158-Don-t-use-exit-ERANGE.patch
+ 0159-Monitor-containers-don-t-have-the-same-sysfs-propert.patch
+ 0160-Monitor-Include-containers-in-spare-migration.patch
+ 0161-Detail-differentiate-between-container-and-inactive-.patch
+ 0162-mdadm-install-two-more-udev-rules-in-mdadm.spec.patch
+ 0163-mdadm-set-journal_clean-after-scanning-all-disks.patch
+ 0164-mdadm-bitmap-examine-bitmap-failed-when-bitmap-is-ex.patch
+ 0165-mdopen-call-modprobe-md_mod-if-it-might-be-needed.patch
+ 0166-lib-devid2kname-should-take-a-dev_t.patch
+ 0167-sysfs_init_dev-take-a-dev_t-argument.patch
+ 0168-Manage_subdevs-Use-a-dev_t.patch
+ 0169-util-Code-is-80-characters-wide.patch
+ 0170-Close-mdfd-before-returning-main-function.patch
+ 0171-Grow-stop-previous-reshape-process-first.patch
+ 0172-imsm-New-disk-controller-domains.patch
+ 0173-Monitor-Check-redundancy-for-arrays.patch
+ 0174-mdadm-grow-Component-size-must-be-larger-than-chunk-.patch
+ 0175-mdadm-manpage-disable-bitmap_resize-for-external-fil.patch
+ 0176-mdadm-fixes-some-trivial-typos-in-comments.patch
+ (The following 12 patches are specifically for bsc#1068030)
+ 0177-Don-t-abort-starting-the-array-if-kernel-does-not-su.patch
+ 0178-super1-Add-support-for-multiple-ppls.patch
+ 0179-imsm-Add-support-for-multiple-ppls.patch
+ 0180-imsm-validate-multiple-ppls-during-assemble.patch
+ 0181-Zeroout-whole-ppl-space-during-creation-force-assemb.patch
+ 0182-imsm-switch-to-multiple-ppls-automatically-during-as.patch
+ 0183-Grow-fix-switching-on-PPL-during-recovery.patch
+ 0184-imsm-don-t-skip-resync-when-an-invalid-ppl-header-is.patch
+ 0185-imsm-Write-empty-PPL-header-if-assembling-regular-cl.patch
+ 0186-imsm-always-do-ppl-recovery-when-starting-a-rebuildi.patch
+ 0187-imsm-use-correct-map-when-validating-ppl.patch
+ 0188-imsm-write-initial-ppl-on-a-disk-added-for-rebuild.patch
+ 0189-Grow-Use-all-80-characters.patch
+ 0190-imsm-Set-disk-slot-number.patch
+ (The following 1 patch is specifically for bsc#1069167)
+ 0191-mdmon-get-safe-mode-delay-file-descriptor-early.patch
+ 0192-mdadm-mdstat-fixup-a-number-of-broken-formatting.patch
+ 0193-mdadm-mdstat-correct-the-strncmp-number-4-as-6.patch
+ 0194-mdcheck-add-some-logging.patch
+ 0195-mdcheck-improve-cleanup.patch
+ 0196-Move-mdadm_env.sh-out-of-usr-lib-systemd.patch
++++ 12 more lines (skipped)
++++ between /work/SRC/openSUSE:Factory/mdadm/mdadm.changes
++++ and /work/SRC/openSUSE:Factory/.mdadm.new/mdadm.changes
Old:
----
0038-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
0039-Create-Fixup-various-whitespace-issues.patch
0040-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
0041-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
0042-mdadm-manpage-update-manpage-for-readonly-parameter.patch
0043-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
0044-maps-Terminate-modes-map-correctly.patch
0045-Grow_continue_command-ensure-content-is-properly-ini.patch
0046-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
0047-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
0048-Grow-set-component-size-prior-to-array-size.patch
0049-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
0050-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
0051-IMSM-Correct-examine-output-for-4k-disks.patch
0052-imsm-allow-drives-in-a-container-regardless-of-secto.patch
0053-imsm-allocate-buffer-to-support-maximum-sector-size.patch
0054-imsm-don-t-allow-disks-with-different-sector-size-in.patch
0055-Allow-more-spare-selection-criteria.patch
0056-Add-sector-size-as-spare-selection-criterion.patch
0057-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
0058-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
0059-To-support-clustered-raid10.patch
0060-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
1000-The-mdcheck-script-now-adds-messages-to-the-system.patch
New:
----
0038-mdadm-Create-declaring-an-existing-struct-within-sam.patch
0039-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
0040-Create-Fixup-various-whitespace-issues.patch
0041-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
0042-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
0043-mdadm-manpage-update-manpage-for-readonly-parameter.patch
0044-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
0045-maps-Terminate-modes-map-correctly.patch
0046-Grow_continue_command-ensure-content-is-properly-ini.patch
0047-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
0048-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
0049-Grow-set-component-size-prior-to-array-size.patch
0050-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
0051-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
0052-IMSM-Correct-examine-output-for-4k-disks.patch
0053-imsm-allow-drives-in-a-container-regardless-of-secto.patch
0054-imsm-allocate-buffer-to-support-maximum-sector-size.patch
0055-imsm-don-t-allow-disks-with-different-sector-size-in.patch
0056-mdadm-mdmon-deleted-the-abort_reshape-never-invoked.patch
0057-util-Introduce-md_get_array_info.patch
0058-Incremental-Remove-redundant-call-for-GET_ARRAY_INFO.patch
0059-util-Introduce-md_get_disk_info.patch
0060-util-Introduce-md_set_array_info.patch
0061-md_u-Remove-some-unused-ioctl-declarations.patch
0062-mdadm-grow-reshape-would-be-stuck-from-raid1-to-raid.patch
0063-sysfs-Use-the-presence-of-sys-block-dev-md-as-indica.patch
0064-sysfs-Make-sysfs_init-return-an-error-code.patch
0065-util-must_be_container-Use-sysfs_read-GET_VERSION-to.patch
0066-util-set_array_info-Simplify-code-since-md_get_versi.patch
0067-Assemble-Assemble-Stop-checking-kernel-md-driver-ver.patch
0068-Build-Stop-bothering-about-supporting-md-driver-olde.patch
0069-Grow-Stop-bothering-about-md-driver-versions-older-t.patch
0070-Detail-Stop-bothering-about-md-drivers-older-than-0..patch
0071-Create-Remove-all-attemps-to-handle-md-driver-older-.patch
0072-Manage-Remove-all-references-to-md_get_version.patch
0073-Query-Remove-all-references-to-md_get_version.patch
0074-bitmap-Remove-use-of-md_get_version.patch
0075-mdmon-Stop-bothering-about-md_get_version.patch
0076-mdopen-open_mddev-Use-md_get_array_info-to-determine.patch
0077-mdassemble-Use-md_get_array_info-to-check-for-valid-.patch
0078-Assemble-Assemble-Get-rid-of-last-use-of-md_get_vers.patch
0079-util-Finally-kill-off-md_get_version.patch
0080-mdadm-Fail-for-kernels-older-than-2.6.15.patch
0081-Revert-mdadm-grow-reshape-would-be-stuck-from-raid1-.patch
0082-Retire-mdassemble.patch
0083-super1-Clean-up-various-style-abuses.patch
0084-Detail-Remove-pre-2.6-code-for-printing-info-on-rebu.patch
0085-Assemble-Remove-obsolete-test-for-kernels-older-than.patch
0086-Detail-Fixup-ugly-if-foo-abuse.patch
0087-Query-Handle-error-returned-by-fstat.patch
0088-Query-Use-sysfs-to-obtain-data-if-possible.patch
0089-sysfs-Parse-array_state-in-sysfs_read.patch
0090-util-Introduce-md_array_active-helper.patch
0091-maps-Use-keyvalue-for-null-terminator-to-indicate-un.patch
0092-util-Get-rid-of-unused-enough_fd.patch
0093-mdadm-retire-mdassemble-in-make-everything.patch
0094-Query-Quiet-gcc-since-it-cannot-know-errno-0-in-this.patch
0095-Makefile-Default-to-O2-optimization.patch
0096-maps-Simplify-implementation-of-map_name.patch
0097-Don-t-use-UnSet-with-consistency_policy.patch
0098-Detail-determine-array-state-from-sysfs.patch
0099-Detail-Respect-code-lines-are-80-character-wide.patch
0100-Detail-Reinstate-support-for-not-having-sysfs.patch
0101-Incremental-Use-md_array_active-where-applicable.patch
0102-Incremental-Cleanup-some-if-statement-spaghetti.patch
0103-Create-tell-udev-md-device-is-not-ready-when-first-c.patch
0104-Incremental-Use-md_array_active-to-determine-state-o.patch
0105-Manage-Manage_ro-Use-md_array_active.patch
0106-IMSM-Initialize-my_vol_raid_dev_num-during-vol-creat.patch
0107-Grow-Grow_continue_command-Avoid-aliasing-array-vari.patch
0108-change-back-0644-permission-for-Grow.c.patch
0109-util-md_array_valid-Introduce-md_array_valid-helper.patch
0110-kernel-patch-Remove-obsolete-kernel-patches-against-.patch
0111-mdassemble-Kill-off-the-last-remains.patch
0112-mdadm-util-unify-fstat-checking-blkdev-into-function.patch
0113-mdadm-util-unify-stat-checking-blkdev-into-function.patch
0114-Fix-typo-in-new-udev-rule.patch
0115-Incremental-return-is-not-a-function.patch
0116-sysfs-sysfs_read-Count-active_disks-and-failed_disks.patch
0117-container_members_max_degradation-Switch-to-using-sy.patch
0118-IncrementalScan-Use-md_array_active-instead-of-md_ge.patch
0119-Mention-endian-in-documentation-for-update-byte-orde.patch
0120-Monitor-Use-md_array_active-instead-of-manually-fidd.patch
0121-Monitor-Code-is-80-characters-per-line.patch
0122-mdadm-md.4-set-page-length-as-1000-to-avoid-warnings.patch
0123-Allow-more-spare-selection-criteria.patch
0124-Add-sector-size-as-spare-selection-criterion.patch
0125-Monitor-check_array-Centralize-exit-path.patch
0126-Monitor-check_array-Reduce-duplicated-error-handling.patch
0127-Monitor-check_array-Declate-mdinfo-instance-globally.patch
0128-Monitor-check_array-Read-sysfs-entry-earlier.patch
0129-Monitor-check_array-Obtain-RAID-level-from-syfs.patch
0130-Monitor-check_array-Get-failed_disks-from-sysfs.patch
0131-Monitor-check_array-Get-array_disks-from-sysfs.patch
0132-Monitor-check_array-Get-nr_disks-active_disks-and-sp.patch
0133-sysfs-sysfs_read-Count-working_disks.patch
0134-Monitor-check_array-Use-working_disks-from-sysfs.patch
0135-retire-the-APIs-that-driver-no-longer-supports.patch
0136-Monitor-Not-much-point-declaring-mdlist-in-both-fork.patch
0137-Monitor-mailfrom-is-initialized-correctly.patch
0138-Monitor-Fixup-a-pile-of-whitespace-issues.patch
0139-mdadm-Uninitialized-variable-rdev.patch
0140-super-ddf-sysfs_read-takes-a-pointer-as-device-name-.patch
0141-mdadm-Fixup-a-large-number-of-bad-formatting-of-logi.patch
0142-mdadm-Fixup-more-broken-logical-operator-formatting.patch
0143-mdadm-Fix-broken-formatting.patch
0144-mdadm-Fixup-broken-formatting.patch
0145-Detail-don-t-exit-if-ioctl-has-been-successful.patch
0146-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
0147-md_u-Remove-unused-ioctl-declaration-of-START_ARRAY.patch
0148-Get-failed-disk-count-from-array-state.patch
0149-Monitor-don-t-assume-mdadm-parameter-is-a-block-devi.patch
0150-super1-Always-round-data-offset-to-1M.patch
0151-mdadm-r5cache-allow-adding-journal-to-array-without-.patch
0152-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
0153-Detail-correct-output-for-active-arrays.patch
0154-imsm-rebuild-from-2-disk-RAID10.patch
0155-Error-messages-should-end-with-a-newline-character.patch
0156-Use-correct-syntax-for-passing-DEVLINKS-to-mdadm-fro.patch
0157-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
0158-Don-t-use-exit-ERANGE.patch
0159-Monitor-containers-don-t-have-the-same-sysfs-propert.patch
0160-Monitor-Include-containers-in-spare-migration.patch
0161-Detail-differentiate-between-container-and-inactive-.patch
0162-mdadm-install-two-more-udev-rules-in-mdadm.spec.patch
0163-mdadm-set-journal_clean-after-scanning-all-disks.patch
0164-mdadm-bitmap-examine-bitmap-failed-when-bitmap-is-ex.patch
0165-mdopen-call-modprobe-md_mod-if-it-might-be-needed.patch
0166-lib-devid2kname-should-take-a-dev_t.patch
0167-sysfs_init_dev-take-a-dev_t-argument.patch
0168-Manage_subdevs-Use-a-dev_t.patch
0169-util-Code-is-80-characters-wide.patch
0170-Close-mdfd-before-returning-main-function.patch
0171-Grow-stop-previous-reshape-process-first.patch
0172-imsm-New-disk-controller-domains.patch
0173-Monitor-Check-redundancy-for-arrays.patch
0174-mdadm-grow-Component-size-must-be-larger-than-chunk-.patch
0175-mdadm-manpage-disable-bitmap_resize-for-external-fil.patch
0176-mdadm-fixes-some-trivial-typos-in-comments.patch
0177-Don-t-abort-starting-the-array-if-kernel-does-not-su.patch
0178-super1-Add-support-for-multiple-ppls.patch
0179-imsm-Add-support-for-multiple-ppls.patch
0180-imsm-validate-multiple-ppls-during-assemble.patch
0181-Zeroout-whole-ppl-space-during-creation-force-assemb.patch
0182-imsm-switch-to-multiple-ppls-automatically-during-as.patch
0183-Grow-fix-switching-on-PPL-during-recovery.patch
0184-imsm-don-t-skip-resync-when-an-invalid-ppl-header-is.patch
0185-imsm-Write-empty-PPL-header-if-assembling-regular-cl.patch
0186-imsm-always-do-ppl-recovery-when-starting-a-rebuildi.patch
0187-imsm-use-correct-map-when-validating-ppl.patch
0188-imsm-write-initial-ppl-on-a-disk-added-for-rebuild.patch
0189-Grow-Use-all-80-characters.patch
0190-imsm-Set-disk-slot-number.patch
0191-mdmon-get-safe-mode-delay-file-descriptor-early.patch
0192-mdadm-mdstat-fixup-a-number-of-broken-formatting.patch
0193-mdadm-mdstat-correct-the-strncmp-number-4-as-6.patch
0194-mdcheck-add-some-logging.patch
0195-mdcheck-improve-cleanup.patch
0197-mdadm-grow-adding-a-test-to-ensure-resize-was-requir.patch
0198-mdadm-mdopen-create-new-function-create_named_array-.patch
0199-systemd-add-I-to-description-of-mdadm-last-resort-se.patch
0200-Incremental-Use-validate_geometry-instead-of-avail_s.patch
0201-imsm-fix-reading-scsi-serial.patch
0202-To-support-clustered-raid10.patch
0203-imsm-More-precise-message-when-spanned-raid-is-creat.patch
0204-sysfs-include-faulty-drive-in-disk-count.patch
0205-Monitor-msg-Don-t-print-error-message-if-mdmon-doesn.patch
0206-imsm-continue-resync-on-3-disk-RAID10.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ mdadm.spec ++++++
--- /var/tmp/diff_new_pack.94u751/_old 2017-12-08 12:54:45.359388562 +0100
+++ /var/tmp/diff_new_pack.94u751/_new 2017-12-08 12:54:45.363388417 +0100
@@ -1,7 +1,7 @@
#
# spec file for package mdadm
#
-# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -81,30 +81,174 @@
Patch35: 0035-Grow-Do-not-shadow-an-existing-variable.patch
Patch36: 0036-imsm-use-rounded-size-for-metadata-initialization.patch
Patch37: 0037-mdadm.c-fix-compile-error-switch-condition-has-boole.patch
-Patch38: 0038-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
-Patch39: 0039-Create-Fixup-various-whitespace-issues.patch
-Patch40: 0040-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
-Patch41: 0041-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
-Patch42: 0042-mdadm-manpage-update-manpage-for-readonly-parameter.patch
-Patch43: 0043-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
-Patch44: 0044-maps-Terminate-modes-map-correctly.patch
-Patch45: 0045-Grow_continue_command-ensure-content-is-properly-ini.patch
-Patch46: 0046-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
-Patch47: 0047-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
-Patch48: 0048-Grow-set-component-size-prior-to-array-size.patch
-Patch49: 0049-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
-Patch50: 0050-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
-Patch51: 0051-IMSM-Correct-examine-output-for-4k-disks.patch
-Patch52: 0052-imsm-allow-drives-in-a-container-regardless-of-secto.patch
-Patch53: 0053-imsm-allocate-buffer-to-support-maximum-sector-size.patch
-Patch54: 0054-imsm-don-t-allow-disks-with-different-sector-size-in.patch
-Patch55: 0055-Allow-more-spare-selection-criteria.patch
-Patch56: 0056-Add-sector-size-as-spare-selection-criterion.patch
-Patch57: 0057-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
-Patch58: 0058-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
-Patch59: 0059-To-support-clustered-raid10.patch
-Patch60: 0060-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
-Patch1000: 1000-The-mdcheck-script-now-adds-messages-to-the-system.patch
+Patch38: 0038-mdadm-Create-declaring-an-existing-struct-within-sam.patch
+Patch39: 0039-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
+Patch40: 0040-Create-Fixup-various-whitespace-issues.patch
+Patch41: 0041-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
+Patch42: 0042-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
+Patch43: 0043-mdadm-manpage-update-manpage-for-readonly-parameter.patch
+Patch44: 0044-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
+Patch45: 0045-maps-Terminate-modes-map-correctly.patch
+Patch46: 0046-Grow_continue_command-ensure-content-is-properly-ini.patch
+Patch47: 0047-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
+Patch48: 0048-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
+Patch49: 0049-Grow-set-component-size-prior-to-array-size.patch
+Patch50: 0050-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
+Patch51: 0051-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
+Patch52: 0052-IMSM-Correct-examine-output-for-4k-disks.patch
+Patch53: 0053-imsm-allow-drives-in-a-container-regardless-of-secto.patch
+Patch54: 0054-imsm-allocate-buffer-to-support-maximum-sector-size.patch
+Patch55: 0055-imsm-don-t-allow-disks-with-different-sector-size-in.patch
+Patch56: 0056-mdadm-mdmon-deleted-the-abort_reshape-never-invoked.patch
+Patch57: 0057-util-Introduce-md_get_array_info.patch
+Patch58: 0058-Incremental-Remove-redundant-call-for-GET_ARRAY_INFO.patch
+Patch59: 0059-util-Introduce-md_get_disk_info.patch
+Patch60: 0060-util-Introduce-md_set_array_info.patch
+Patch61: 0061-md_u-Remove-some-unused-ioctl-declarations.patch
+Patch62: 0062-mdadm-grow-reshape-would-be-stuck-from-raid1-to-raid.patch
+Patch63: 0063-sysfs-Use-the-presence-of-sys-block-dev-md-as-indica.patch
+Patch64: 0064-sysfs-Make-sysfs_init-return-an-error-code.patch
+Patch65: 0065-util-must_be_container-Use-sysfs_read-GET_VERSION-to.patch
+Patch66: 0066-util-set_array_info-Simplify-code-since-md_get_versi.patch
+Patch67: 0067-Assemble-Assemble-Stop-checking-kernel-md-driver-ver.patch
+Patch68: 0068-Build-Stop-bothering-about-supporting-md-driver-olde.patch
+Patch69: 0069-Grow-Stop-bothering-about-md-driver-versions-older-t.patch
+Patch70: 0070-Detail-Stop-bothering-about-md-drivers-older-than-0..patch
+Patch71: 0071-Create-Remove-all-attemps-to-handle-md-driver-older-.patch
+Patch72: 0072-Manage-Remove-all-references-to-md_get_version.patch
+Patch73: 0073-Query-Remove-all-references-to-md_get_version.patch
+Patch74: 0074-bitmap-Remove-use-of-md_get_version.patch
+Patch75: 0075-mdmon-Stop-bothering-about-md_get_version.patch
+Patch76: 0076-mdopen-open_mddev-Use-md_get_array_info-to-determine.patch
+Patch77: 0077-mdassemble-Use-md_get_array_info-to-check-for-valid-.patch
+Patch78: 0078-Assemble-Assemble-Get-rid-of-last-use-of-md_get_vers.patch
+Patch79: 0079-util-Finally-kill-off-md_get_version.patch
+Patch80: 0080-mdadm-Fail-for-kernels-older-than-2.6.15.patch
+Patch81: 0081-Revert-mdadm-grow-reshape-would-be-stuck-from-raid1-.patch
+Patch82: 0082-Retire-mdassemble.patch
+Patch83: 0083-super1-Clean-up-various-style-abuses.patch
+Patch84: 0084-Detail-Remove-pre-2.6-code-for-printing-info-on-rebu.patch
+Patch85: 0085-Assemble-Remove-obsolete-test-for-kernels-older-than.patch
+Patch86: 0086-Detail-Fixup-ugly-if-foo-abuse.patch
+Patch87: 0087-Query-Handle-error-returned-by-fstat.patch
+Patch88: 0088-Query-Use-sysfs-to-obtain-data-if-possible.patch
+Patch89: 0089-sysfs-Parse-array_state-in-sysfs_read.patch
+Patch90: 0090-util-Introduce-md_array_active-helper.patch
+Patch91: 0091-maps-Use-keyvalue-for-null-terminator-to-indicate-un.patch
+Patch92: 0092-util-Get-rid-of-unused-enough_fd.patch
+Patch93: 0093-mdadm-retire-mdassemble-in-make-everything.patch
+Patch94: 0094-Query-Quiet-gcc-since-it-cannot-know-errno-0-in-this.patch
+Patch95: 0095-Makefile-Default-to-O2-optimization.patch
+Patch96: 0096-maps-Simplify-implementation-of-map_name.patch
+Patch97: 0097-Don-t-use-UnSet-with-consistency_policy.patch
+Patch98: 0098-Detail-determine-array-state-from-sysfs.patch
+Patch99: 0099-Detail-Respect-code-lines-are-80-character-wide.patch
+Patch100: 0100-Detail-Reinstate-support-for-not-having-sysfs.patch
+Patch101: 0101-Incremental-Use-md_array_active-where-applicable.patch
+Patch102: 0102-Incremental-Cleanup-some-if-statement-spaghetti.patch
+Patch103: 0103-Create-tell-udev-md-device-is-not-ready-when-first-c.patch
+Patch104: 0104-Incremental-Use-md_array_active-to-determine-state-o.patch
+Patch105: 0105-Manage-Manage_ro-Use-md_array_active.patch
+Patch106: 0106-IMSM-Initialize-my_vol_raid_dev_num-during-vol-creat.patch
+Patch107: 0107-Grow-Grow_continue_command-Avoid-aliasing-array-vari.patch
+Patch108: 0108-change-back-0644-permission-for-Grow.c.patch
+Patch109: 0109-util-md_array_valid-Introduce-md_array_valid-helper.patch
+Patch110: 0110-kernel-patch-Remove-obsolete-kernel-patches-against-.patch
+Patch111: 0111-mdassemble-Kill-off-the-last-remains.patch
+Patch112: 0112-mdadm-util-unify-fstat-checking-blkdev-into-function.patch
+Patch113: 0113-mdadm-util-unify-stat-checking-blkdev-into-function.patch
+Patch114: 0114-Fix-typo-in-new-udev-rule.patch
+Patch115: 0115-Incremental-return-is-not-a-function.patch
+Patch116: 0116-sysfs-sysfs_read-Count-active_disks-and-failed_disks.patch
+Patch117: 0117-container_members_max_degradation-Switch-to-using-sy.patch
+Patch118: 0118-IncrementalScan-Use-md_array_active-instead-of-md_ge.patch
+Patch119: 0119-Mention-endian-in-documentation-for-update-byte-orde.patch
+Patch120: 0120-Monitor-Use-md_array_active-instead-of-manually-fidd.patch
+Patch121: 0121-Monitor-Code-is-80-characters-per-line.patch
+Patch122: 0122-mdadm-md.4-set-page-length-as-1000-to-avoid-warnings.patch
+Patch123: 0123-Allow-more-spare-selection-criteria.patch
+Patch124: 0124-Add-sector-size-as-spare-selection-criterion.patch
+Patch125: 0125-Monitor-check_array-Centralize-exit-path.patch
+Patch126: 0126-Monitor-check_array-Reduce-duplicated-error-handling.patch
+Patch127: 0127-Monitor-check_array-Declate-mdinfo-instance-globally.patch
+Patch128: 0128-Monitor-check_array-Read-sysfs-entry-earlier.patch
+Patch129: 0129-Monitor-check_array-Obtain-RAID-level-from-syfs.patch
+Patch130: 0130-Monitor-check_array-Get-failed_disks-from-sysfs.patch
+Patch131: 0131-Monitor-check_array-Get-array_disks-from-sysfs.patch
+Patch132: 0132-Monitor-check_array-Get-nr_disks-active_disks-and-sp.patch
+Patch133: 0133-sysfs-sysfs_read-Count-working_disks.patch
+Patch134: 0134-Monitor-check_array-Use-working_disks-from-sysfs.patch
+Patch135: 0135-retire-the-APIs-that-driver-no-longer-supports.patch
+Patch136: 0136-Monitor-Not-much-point-declaring-mdlist-in-both-fork.patch
+Patch137: 0137-Monitor-mailfrom-is-initialized-correctly.patch
+Patch138: 0138-Monitor-Fixup-a-pile-of-whitespace-issues.patch
+Patch139: 0139-mdadm-Uninitialized-variable-rdev.patch
+Patch140: 0140-super-ddf-sysfs_read-takes-a-pointer-as-device-name-.patch
+Patch141: 0141-mdadm-Fixup-a-large-number-of-bad-formatting-of-logi.patch
+Patch142: 0142-mdadm-Fixup-more-broken-logical-operator-formatting.patch
+Patch143: 0143-mdadm-Fix-broken-formatting.patch
+Patch144: 0144-mdadm-Fixup-broken-formatting.patch
+Patch145: 0145-Detail-don-t-exit-if-ioctl-has-been-successful.patch
+Patch146: 0146-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
+Patch147: 0147-md_u-Remove-unused-ioctl-declaration-of-START_ARRAY.patch
+Patch148: 0148-Get-failed-disk-count-from-array-state.patch
+Patch149: 0149-Monitor-don-t-assume-mdadm-parameter-is-a-block-devi.patch
+Patch150: 0150-super1-Always-round-data-offset-to-1M.patch
+Patch151: 0151-mdadm-r5cache-allow-adding-journal-to-array-without-.patch
+Patch152: 0152-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
+Patch153: 0153-Detail-correct-output-for-active-arrays.patch
+Patch154: 0154-imsm-rebuild-from-2-disk-RAID10.patch
+Patch155: 0155-Error-messages-should-end-with-a-newline-character.patch
+Patch156: 0156-Use-correct-syntax-for-passing-DEVLINKS-to-mdadm-fro.patch
+Patch157: 0157-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
+Patch158: 0158-Don-t-use-exit-ERANGE.patch
+Patch159: 0159-Monitor-containers-don-t-have-the-same-sysfs-propert.patch
+Patch160: 0160-Monitor-Include-containers-in-spare-migration.patch
+Patch161: 0161-Detail-differentiate-between-container-and-inactive-.patch
+Patch162: 0162-mdadm-install-two-more-udev-rules-in-mdadm.spec.patch
+Patch163: 0163-mdadm-set-journal_clean-after-scanning-all-disks.patch
+Patch164: 0164-mdadm-bitmap-examine-bitmap-failed-when-bitmap-is-ex.patch
+Patch165: 0165-mdopen-call-modprobe-md_mod-if-it-might-be-needed.patch
+Patch166: 0166-lib-devid2kname-should-take-a-dev_t.patch
+Patch167: 0167-sysfs_init_dev-take-a-dev_t-argument.patch
+Patch168: 0168-Manage_subdevs-Use-a-dev_t.patch
+Patch169: 0169-util-Code-is-80-characters-wide.patch
+Patch170: 0170-Close-mdfd-before-returning-main-function.patch
+Patch171: 0171-Grow-stop-previous-reshape-process-first.patch
+Patch172: 0172-imsm-New-disk-controller-domains.patch
+Patch173: 0173-Monitor-Check-redundancy-for-arrays.patch
+Patch174: 0174-mdadm-grow-Component-size-must-be-larger-than-chunk-.patch
+Patch175: 0175-mdadm-manpage-disable-bitmap_resize-for-external-fil.patch
+Patch176: 0176-mdadm-fixes-some-trivial-typos-in-comments.patch
+Patch177: 0177-Don-t-abort-starting-the-array-if-kernel-does-not-su.patch
+Patch178: 0178-super1-Add-support-for-multiple-ppls.patch
+Patch179: 0179-imsm-Add-support-for-multiple-ppls.patch
+Patch180: 0180-imsm-validate-multiple-ppls-during-assemble.patch
+Patch181: 0181-Zeroout-whole-ppl-space-during-creation-force-assemb.patch
+Patch182: 0182-imsm-switch-to-multiple-ppls-automatically-during-as.patch
+Patch183: 0183-Grow-fix-switching-on-PPL-during-recovery.patch
+Patch184: 0184-imsm-don-t-skip-resync-when-an-invalid-ppl-header-is.patch
+Patch185: 0185-imsm-Write-empty-PPL-header-if-assembling-regular-cl.patch
+Patch186: 0186-imsm-always-do-ppl-recovery-when-starting-a-rebuildi.patch
+Patch187: 0187-imsm-use-correct-map-when-validating-ppl.patch
+Patch188: 0188-imsm-write-initial-ppl-on-a-disk-added-for-rebuild.patch
+Patch189: 0189-Grow-Use-all-80-characters.patch
+Patch190: 0190-imsm-Set-disk-slot-number.patch
+Patch191: 0191-mdmon-get-safe-mode-delay-file-descriptor-early.patch
+Patch192: 0192-mdadm-mdstat-fixup-a-number-of-broken-formatting.patch
+Patch193: 0193-mdadm-mdstat-correct-the-strncmp-number-4-as-6.patch
+Patch194: 0194-mdcheck-add-some-logging.patch
+Patch195: 0195-mdcheck-improve-cleanup.patch
+Patch197: 0197-mdadm-grow-adding-a-test-to-ensure-resize-was-requir.patch
+Patch198: 0198-mdadm-mdopen-create-new-function-create_named_array-.patch
+Patch199: 0199-systemd-add-I-to-description-of-mdadm-last-resort-se.patch
+Patch200: 0200-Incremental-Use-validate_geometry-instead-of-avail_s.patch
+Patch201: 0201-imsm-fix-reading-scsi-serial.patch
+Patch202: 0202-To-support-clustered-raid10.patch
+Patch203: 0203-imsm-More-precise-message-when-spanned-raid-is-creat.patch
+Patch204: 0204-sysfs-include-faulty-drive-in-disk-count.patch
+Patch205: 0205-Monitor-msg-Don-t-print-error-message-if-mdmon-doesn.patch
+Patch206: 0206-imsm-continue-resync-on-3-disk-RAID10.patch
%define _udevdir %(pkg-config --variable=udevdir udev)
%define _systemdshutdowndir %{_unitdir}/../system-shutdown
@@ -176,7 +320,151 @@
%patch58 -p1
%patch59 -p1
%patch60 -p1
-%patch1000 -p1
+%patch61 -p1
+%patch62 -p1
+%patch63 -p1
+%patch64 -p1
+%patch65 -p1
+%patch66 -p1
+%patch67 -p1
+%patch68 -p1
+%patch69 -p1
+%patch70 -p1
+%patch71 -p1
+%patch72 -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
+%patch122 -p1
+%patch123 -p1
+%patch124 -p1
+%patch125 -p1
+%patch126 -p1
+%patch127 -p1
+%patch128 -p1
+%patch129 -p1
+%patch130 -p1
+%patch131 -p1
+%patch132 -p1
+%patch133 -p1
+%patch134 -p1
+%patch135 -p1
+%patch136 -p1
+%patch137 -p1
+%patch138 -p1
+%patch139 -p1
+%patch140 -p1
+%patch141 -p1
+%patch142 -p1
+%patch143 -p1
+%patch144 -p1
+%patch145 -p1
+%patch146 -p1
+%patch147 -p1
+%patch148 -p1
+%patch149 -p1
+%patch150 -p1
+%patch151 -p1
+%patch152 -p1
+%patch153 -p1
+%patch154 -p1
+%patch155 -p1
+%patch156 -p1
+%patch157 -p1
+%patch158 -p1
+%patch159 -p1
+%patch160 -p1
+%patch161 -p1
+%patch162 -p1
+%patch163 -p1
+%patch164 -p1
+%patch165 -p1
+%patch166 -p1
+%patch167 -p1
+%patch168 -p1
+%patch169 -p1
+%patch170 -p1
+%patch171 -p1
+%patch172 -p1
+%patch173 -p1
+%patch174 -p1
+%patch175 -p1
+%patch176 -p1
+%patch177 -p1
+%patch178 -p1
+%patch179 -p1
+%patch180 -p1
+%patch181 -p1
+%patch182 -p1
+%patch183 -p1
+%patch184 -p1
+%patch185 -p1
+%patch186 -p1
+%patch187 -p1
+%patch188 -p1
+%patch189 -p1
+%patch190 -p1
+%patch191 -p1
+%patch192 -p1
+%patch193 -p1
+%patch194 -p1
+%patch195 -p1
+%patch197 -p1
+%patch198 -p1
+%patch199 -p1
+%patch200 -p1
+%patch201 -p1
+%patch202 -p1
+%patch203 -p1
+%patch204 -p1
+%patch205 -p1
+%patch206 -p1
%build
make %{?_smp_mflags} CC="%__cc" CXFLAGS="$RPM_OPT_FLAGS -Wno-error" SUSE=yes
@@ -229,6 +517,7 @@
%dir /usr/share/mdadm
/usr/share/mdadm/*
%{_fillupdir}/sysconfig.mdadm
+%{_udevdir}/rules.d/01-md-raid-creating.rules
%{_udevdir}/rules.d/63-md-raid-arrays.rules
%{_udevdir}/rules.d/64-md-raid-assembly.rules
%{_udevdir}/rules.d/69-md-clustered-confirm-device.rules
++++++ 0038-mdadm-Create-declaring-an-existing-struct-within-sam.patch ++++++
From 230a0dde0926125b8895e02a669b4701f79c0f07 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Sat, 1 Apr 2017 20:51:44 +0800
Subject: [PATCH] mdadm/Create: declaring an existing struct within same
function
Git-commit: 230a0dde0926125b8895e02a669b4701f79c0f07
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Create:declaring 'struct stat stb' twice within the same
function, rename stb as stb2 when declares 'struct stat'
at the second time.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Create.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Create.c b/Create.c
index 32987af..ba24606 100644
--- a/Create.c
+++ b/Create.c
@@ -868,7 +868,7 @@ int Create(struct supertype *st, char *mddev,
for (dnum=0, raid_disk_num=0, dv = devlist ; dv ;
dv=(dv->next)?(dv->next):moved_disk, dnum++) {
int fd;
- struct stat stb;
+ struct stat stb2;
struct mdinfo *inf = &infos[dnum];
if (dnum >= total_slots)
@@ -924,9 +924,9 @@ int Create(struct supertype *st, char *mddev,
dv->devname);
goto abort_locked;
}
- fstat(fd, &stb);
- inf->disk.major = major(stb.st_rdev);
- inf->disk.minor = minor(stb.st_rdev);
+ fstat(fd, &stb2);
+ inf->disk.major = major(stb2.st_rdev);
+ inf->disk.minor = minor(stb2.st_rdev);
}
if (fd >= 0)
remove_partitions(fd);
@@ -947,8 +947,8 @@ int Create(struct supertype *st, char *mddev,
if (!have_container) {
/* getinfo_super might have lost these ... */
- inf->disk.major = major(stb.st_rdev);
- inf->disk.minor = minor(stb.st_rdev);
+ inf->disk.major = major(stb2.st_rdev);
+ inf->disk.minor = minor(stb2.st_rdev);
}
break;
case 2:
--
2.13.6
++++++ 0038-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch -> 0039-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0038-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch 2017-08-24 18:18:06.783166860 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0039-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch 2017-12-08 12:54:39.035616948 +0100
@@ -3,10 +3,15 @@
Date: Wed, 5 Apr 2017 11:53:12 -0400
Subject: [PATCH] Create: Fixup bad placement of logical || && in multi-line if
statements
+Git-commit: cf622ec1d81a5bb3f882922667bac494b3a16581
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
These always go at the end of the line, never at the front
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Create.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
++++++ 0039-Create-Fixup-various-whitespace-issues.patch -> 0040-Create-Fixup-various-whitespace-issues.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0039-Create-Fixup-various-whitespace-issues.patch 2017-08-24 18:18:06.815162355 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0040-Create-Fixup-various-whitespace-issues.patch 2017-12-08 12:54:39.111614203 +0100
@@ -2,17 +2,22 @@
From: Jes Sorensen
Date: Wed, 5 Apr 2017 11:57:30 -0400
Subject: [PATCH] Create: Fixup various whitespace issues
+Git-commit: 98dbf73cba81cd846f9c706f37edc22e21038cf4
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Create.c | 50 ++++++++++++++++++++++++--------------------------
1 file changed, 24 insertions(+), 26 deletions(-)
-Index: mdadm/Create.c
-===================================================================
---- mdadm.orig/Create.c
-+++ mdadm/Create.c
-@@ -84,12 +84,12 @@ int Create(struct supertype *st, char *m
+diff --git a/Create.c b/Create.c
+index 17333ce..4f98c58 100644
+--- a/Create.c
++++ b/Create.c
+@@ -84,12 +84,12 @@ int Create(struct supertype *st, char *mddev,
* RUN_ARRAY
*/
int mdfd;
@@ -27,7 +32,7 @@
struct stat stb;
int first_missing = subdevs * 2;
int second_missing = subdevs * 2;
-@@ -260,7 +260,7 @@ int Create(struct supertype *st, char *m
+@@ -259,7 +259,7 @@ int Create(struct supertype *st, char *mddev,
&s->chunk, s->size*2,
data_offset, NULL,
&newsize, s->consistency_policy,
@@ -36,7 +41,7 @@
return 1;
if (s->chunk && s->chunk != UnSet) {
-@@ -291,7 +291,7 @@ int Create(struct supertype *st, char *m
+@@ -290,7 +290,7 @@ int Create(struct supertype *st, char *mddev,
info.array.active_disks = 0;
info.array.working_disks = 0;
dnum = 0;
@@ -45,7 +50,7 @@
if (data_offset == VARIABLE_OFFSET)
dv->data_offset = INVALID_SECTORS;
else
-@@ -303,7 +303,7 @@ int Create(struct supertype *st, char *m
+@@ -302,7 +302,7 @@ int Create(struct supertype *st, char *mddev,
int dfd;
char *doff;
@@ -54,7 +59,7 @@
if (first_missing > dnum)
first_missing = dnum;
if (second_missing > dnum && dnum > first_missing)
-@@ -349,7 +349,7 @@ int Create(struct supertype *st, char *m
+@@ -348,7 +348,7 @@ int Create(struct supertype *st, char *mddev,
*/
int i;
char *name = "default";
@@ -63,7 +68,7 @@
st = superlist[i]->match_metadata_desc(name);
if (!st)
continue;
-@@ -445,10 +445,10 @@ int Create(struct supertype *st, char *m
+@@ -444,10 +444,10 @@ int Create(struct supertype *st, char *mddev,
skip_size_check:
if (c->runstop != 1 || c->verbose >= 0) {
int fd = open(dname, O_RDONLY);
@@ -76,7 +81,7 @@
continue;
}
warn |= check_ext2(fd, dname);
-@@ -497,7 +497,7 @@ int Create(struct supertype *st, char *m
+@@ -496,7 +496,7 @@ int Create(struct supertype *st, char *mddev,
return 1;
}
if (s->level > 0 || s->level == LEVEL_MULTIPATH ||
@@ -85,7 +90,7 @@
/* size is meaningful */
if (!st->ss->validate_geometry(st, s->level, s->layout,
s->raiddisks,
-@@ -572,9 +572,9 @@ int Create(struct supertype *st, char *m
+@@ -571,9 +571,9 @@ int Create(struct supertype *st, char *mddev,
* as missing, so that a reconstruct happens (faster than re-parity)
* FIX: Can we do this for raid6 as well?
*/
@@ -98,7 +103,7 @@
case 4:
case 5:
insert_point = s->raiddisks-1;
-@@ -649,7 +649,7 @@ int Create(struct supertype *st, char *m
+@@ -648,7 +648,7 @@ int Create(struct supertype *st, char *mddev,
* with, but it chooses to trust me instead. Sigh
*/
info.array.md_minor = 0;
@@ -107,7 +112,7 @@
info.array.md_minor = minor(stb.st_rdev);
info.array.not_persistent = 0;
-@@ -715,13 +715,11 @@ int Create(struct supertype *st, char *m
+@@ -714,13 +714,11 @@ int Create(struct supertype *st, char *mddev,
name = strrchr(mddev, '/');
if (name) {
name++;
@@ -125,7 +130,7 @@
(name-mddev) == 5 /* /dev/ */)
name += 2;
}
-@@ -769,9 +767,9 @@ int Create(struct supertype *st, char *m
+@@ -771,9 +769,9 @@ int Create(struct supertype *st, char *mddev,
#endif
}
@@ -138,7 +143,7 @@
pr_err("internal bitmaps not supported by this kernel.\n");
goto abort_locked;
}
-@@ -851,11 +849,11 @@ int Create(struct supertype *st, char *m
+@@ -856,11 +854,11 @@ int Create(struct supertype *st, char *mddev,
infos = xmalloc(sizeof(*infos) * total_slots);
enable_fds(total_slots);
@@ -151,9 +156,9 @@
+ for (dnum = 0, raid_disk_num = 0, dv = devlist; dv;
+ dv = (dv->next) ? (dv->next) : moved_disk, dnum++) {
int fd;
- struct stat stb;
+ struct stat stb2;
struct mdinfo *inf = &infos[dnum];
-@@ -867,7 +865,7 @@ int Create(struct supertype *st, char *m
+@@ -872,7 +870,7 @@ int Create(struct supertype *st, char *mddev,
moved_disk = dv;
continue;
}
@@ -162,3 +167,6 @@
raid_disk_num += 1;
continue;
}
+--
+2.13.6
+
++++++ 0040-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch -> 0041-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0040-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch 2017-08-24 18:18:06.839158976 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0041-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch 2017-12-08 12:54:39.135613337 +0100
@@ -2,6 +2,9 @@
From: Zhilong Liu
Date: Mon, 10 Apr 2017 12:49:52 +0800
Subject: [PATCH] mdadm.c:fix compile warning "mdfd is uninitialized"
+Git-commit: 5fbc1f1527ec86ae904739a27c0af4e3bc89084e
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Initialized the mdfd as -1 to prevent compile error
of some compilers.
@@ -9,6 +12,8 @@
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
mdadm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
++++++ 0041-mdopen-use-parameters-new_array-to-create-arrays-whe.patch -> 0042-mdopen-use-parameters-new_array-to-create-arrays-whe.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0041-mdopen-use-parameters-new_array-to-create-arrays-whe.patch 2017-08-24 18:18:06.875153908 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0042-mdopen-use-parameters-new_array-to-create-arrays-whe.patch 2017-12-08 12:54:39.159612470 +0100
@@ -3,6 +3,9 @@
Date: Wed, 12 Apr 2017 16:29:04 +1000
Subject: [PATCH] mdopen: use parameters/new_array to create arrays whenever
possible.
+Git-commit: 039df36231335fabe4da1a22fa3accb160d8bc1b
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
In a sufficiently recent kernel, an md%d array can be
created by writing to .../parameters/new_array.
@@ -22,6 +25,8 @@
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
mdopen.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
++++++ 0042-mdadm-manpage-update-manpage-for-readonly-parameter.patch -> 0043-mdadm-manpage-update-manpage-for-readonly-parameter.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0042-mdadm-manpage-update-manpage-for-readonly-parameter.patch 2017-08-24 18:18:06.903149966 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0043-mdadm-manpage-update-manpage-for-readonly-parameter.patch 2017-12-08 12:54:39.175611892 +0100
@@ -2,6 +2,9 @@
From: Zhilong Liu
Date: Wed, 12 Apr 2017 16:36:38 +0800
Subject: [PATCH] mdadm/manpage:update manpage for readonly parameter
+Git-commit: 8a70632fc2f9026e0f4895f5348cc7cd20d9fbb3
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
update readonly in manpage:
Currently both the readwrite and readonly are worked well,
@@ -11,6 +14,8 @@
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
mdadm.8.in | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
++++++ 0043-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch -> 0044-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0043-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch 2017-08-24 18:18:06.931146024 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0044-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch 2017-12-08 12:54:39.199611025 +0100
@@ -2,12 +2,17 @@
From: Zhilong Liu
Date: Wed, 12 Apr 2017 16:37:27 +0800
Subject: [PATCH] mdadm/manpage:clustered arrays don't support array-size yet
+Git-commit: e39c76b9b72db00d32780e9f30dfba25f58922d2
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Update manpage for array-size section:
Clustered arrays don't support the --array-size yet.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
mdadm.8.in | 2 ++
1 file changed, 2 insertions(+)
++++++ 0044-maps-Terminate-modes-map-correctly.patch -> 0045-maps-Terminate-modes-map-correctly.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0044-maps-Terminate-modes-map-correctly.patch 2017-08-24 18:18:06.955142645 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0045-maps-Terminate-modes-map-correctly.patch 2017-12-08 12:54:39.211610592 +0100
@@ -2,11 +2,16 @@
From: Jes Sorensen
Date: Thu, 20 Apr 2017 00:13:31 -0400
Subject: [PATCH] maps: Terminate 'modes' map correctly.
+Git-commit: e47781fcea24778a16e4be53e5b84eab8db9413c
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
While we are unlikely to fail here, terminate the modes map correctly
to ensure we don't start running over undefined data.
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
maps.c | 1 +
1 file changed, 1 insertion(+)
++++++ 0045-Grow_continue_command-ensure-content-is-properly-ini.patch -> 0046-Grow_continue_command-ensure-content-is-properly-ini.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0045-Grow_continue_command-ensure-content-is-properly-ini.patch 2017-08-24 18:18:06.983138704 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0046-Grow_continue_command-ensure-content-is-properly-ini.patch 2017-12-08 12:54:39.231609869 +0100
@@ -3,6 +3,9 @@
Date: Thu, 20 Apr 2017 12:40:05 +1000
Subject: [PATCH] Grow_continue_command: ensure 'content' is properly
initialised.
+Git-commit: a250ce240f245df594570a5e25398680d403af67
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Grow_continue_command() call verify_reshape_position(), which assumes
that info->sys_name is initialised.
@@ -15,6 +18,8 @@
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Grow.c | 1 +
1 file changed, 1 insertion(+)
++++++ 0046-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch -> 0047-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0046-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch 2017-08-24 18:18:07.083124626 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0047-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch 2017-12-08 12:54:39.243609436 +0100
@@ -3,6 +3,9 @@
Date: Thu, 20 Apr 2017 12:40:05 +1000
Subject: [PATCH] systemd/mdadm-last-resort: use ConditionPathExists instead of
Conflicts
+Git-commit: 5c4b3b9aa9f576305b36d5ccbd4b929b51307ce9
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Commit cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.")
@@ -27,6 +30,8 @@
Fixes: cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.")
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
systemd/mdadm-last-resort@.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
++++++ 0047-Detail-ensure-export-names-are-acceptable-as-shell-v.patch -> 0048-Detail-ensure-export-names-are-acceptable-as-shell-v.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0047-Detail-ensure-export-names-are-acceptable-as-shell-v.patch 2017-08-24 18:18:07.115120121 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0048-Detail-ensure-export-names-are-acceptable-as-shell-v.patch 2017-12-08 12:54:39.267608570 +0100
@@ -3,6 +3,9 @@
Date: Thu, 20 Apr 2017 12:40:06 +1000
Subject: [PATCH] Detail: ensure --export names are acceptable as shell
variables.
+Git-commit: b9c9bd9bacaab701d5b3cb3e4b6cb02ea8d36e47
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
If an array contains a device which has a name that
contains something other than alphnumerics and underscores,
@@ -22,6 +25,8 @@
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Detail.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
++++++ 0048-Grow-set-component-size-prior-to-array-size.patch -> 0049-Grow-set-component-size-prior-to-array-size.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0048-Grow-set-component-size-prior-to-array-size.patch 2017-08-24 18:18:07.147115615 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0049-Grow-set-component-size-prior-to-array-size.patch 2017-12-08 12:54:39.283607992 +0100
@@ -2,6 +2,9 @@
From: Tomasz Majchrzak
Date: Mon, 5 Jun 2017 16:09:44 +0200
Subject: [PATCH] Grow: set component size prior to array size
+Git-commit: 07c45a1871df0a70beb8da80d11601d33c7a5de2
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
It is a partial revert of commit 758b327cf5a7 ("Grow: Remove unnecessary
optimization"). For native metadata component size is set in kernel for
@@ -11,6 +14,8 @@
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Grow.c | 2 ++
1 file changed, 2 insertions(+)
++++++ 0049-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch -> 0050-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0049-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch 2017-08-24 18:18:07.183110547 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0050-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch 2017-12-08 12:54:39.303607269 +0100
@@ -2,12 +2,17 @@
From: Tomasz Majchrzak
Date: Fri, 9 Jun 2017 16:20:19 +0200
Subject: [PATCH] Grow: don't allow to enable PPL when reshape is in progress
+Git-commit: 922a58292fafa4efcfcd44fbc46b0665681c955a
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Don't allow to enable PPL consistency policy when reshape is in progress.
Current PPL implementation doesn't work when reshape is taking place.
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Grow.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
++++++ 0050-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch -> 0051-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0050-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch 2017-08-24 18:18:07.215106042 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0051-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch 2017-12-08 12:54:39.319606691 +0100
@@ -2,6 +2,9 @@
From: Tomasz Majchrzak
Date: Thu, 8 Jun 2017 16:05:51 +0200
Subject: [PATCH] Grow: don't allow array geometry change with ppl enabled
+Git-commit: b208f817ec538e56df7280f0353e6bda532b9432
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Don't allow array geometry change (size expand, disk adding) when PPL
consistency policy is enabled. Current PPL implementation doesn't work when
@@ -9,6 +12,8 @@
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Grow.c | 7 +++++++
1 file changed, 7 insertions(+)
++++++ 0051-IMSM-Correct-examine-output-for-4k-disks.patch -> 0052-IMSM-Correct-examine-output-for-4k-disks.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0051-IMSM-Correct-examine-output-for-4k-disks.patch 2017-08-24 18:18:07.251100974 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0052-IMSM-Correct-examine-output-for-4k-disks.patch 2017-12-08 12:54:39.331606258 +0100
@@ -2,6 +2,9 @@
From: Maksymilian Kunt
Date: Tue, 9 May 2017 14:03:27 +0200
Subject: [PATCH] IMSM: Correct --examine output for 4k disks
+Git-commit: 84918897ee8bb450ea09f7c95b9da44df8e925e4
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
"Array Size" and "Per Dev Size" are incorrect for disks with sector size
different than 512B.
@@ -12,6 +15,8 @@
Signed-off-by: Maksymilian Kunt
Signed-off-by: Mariusz Dabrowski
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
super-intel.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
++++++ 0052-imsm-allow-drives-in-a-container-regardless-of-secto.patch -> 0053-imsm-allow-drives-in-a-container-regardless-of-secto.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0052-imsm-allow-drives-in-a-container-regardless-of-secto.patch 2017-08-24 18:18:07.331089712 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0053-imsm-allow-drives-in-a-container-regardless-of-secto.patch 2017-12-08 12:54:39.351605536 +0100
@@ -2,6 +2,9 @@
From: Alexey Obitotskiy
Date: Tue, 9 May 2017 12:25:43 +0200
Subject: [PATCH] imsm: allow drives in a container regardless of sector size
+Git-commit: 5c5ea85b4deedf5e7491a905bbb4f4a3bc284f2c
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
IMSM doesn't allow to create arrays including drives with different
sector sizes. The initial idea was not to permit to combine drives
@@ -16,6 +19,8 @@
Signed-off-by: Alexey Obitotskiy
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
super-intel.c | 6 ------
1 file changed, 6 deletions(-)
++++++ 0053-imsm-allocate-buffer-to-support-maximum-sector-size.patch -> 0054-imsm-allocate-buffer-to-support-maximum-sector-size.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0053-imsm-allocate-buffer-to-support-maximum-sector-size.patch 2017-08-24 18:18:07.355086333 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0054-imsm-allocate-buffer-to-support-maximum-sector-size.patch 2017-12-08 12:54:39.375604669 +0100
@@ -2,6 +2,9 @@
From: Alexey Obitotskiy
Date: Tue, 9 May 2017 12:25:44 +0200
Subject: [PATCH] imsm: allocate buffer to support maximum sector size
+Git-commit: 853375734edcfd70ba64b444b9e69f7e336a30b7
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Allocate migration record buffer to support maximum sector size. Disk with
non-matching sector size is not going to be included in the array, however
@@ -12,6 +15,8 @@
Signed-off-by: Alexey Obitotskiy
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
super-intel.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
++++++ 0054-imsm-don-t-allow-disks-with-different-sector-size-in.patch -> 0055-imsm-don-t-allow-disks-with-different-sector-size-in.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0054-imsm-don-t-allow-disks-with-different-sector-size-in.patch 2017-08-24 18:18:07.379082954 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0055-imsm-don-t-allow-disks-with-different-sector-size-in.patch 2017-12-08 12:54:39.391604091 +0100
@@ -3,6 +3,9 @@
Date: Tue, 9 May 2017 12:25:45 +0200
Subject: [PATCH] imsm: don't allow disks with different sector size in one
array
+Git-commit: f2cc4f7d829e1b849e78bdf6c38b7bd6e234c600
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
As there is no support in IMSM for arrays including disks with different
sector sizes, don't allow to create such configuration. Also skip the
@@ -12,6 +15,8 @@
Signed-off-by: Alexey Obitotskiy
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
super-intel.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
++++++ 0056-mdadm-mdmon-deleted-the-abort_reshape-never-invoked.patch ++++++
From e81070a69bf0c6e20f95806b6c60f6ec5c952a20 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Mon, 20 Mar 2017 13:21:24 +0800
Subject: [PATCH] mdadm/mdmon:deleted the abort_reshape never invoked
Git-commit: e81070a69bf0c6e20f95806b6c60f6ec5c952a20
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Mdmon.c: abort_reshape() has implemented in Grow.c,
this function doesn't make a lot of sense here.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdmon.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/mdmon.c b/mdmon.c
index e4b73d9..95e9bba 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -580,11 +580,6 @@ int restore_stripes(int *dest, unsigned long long *offsets,
return 1;
}
-void abort_reshape(struct mdinfo *sra)
-{
- return;
-}
-
int save_stripes(int *source, unsigned long long *offsets,
int raid_disks, int chunk_size, int level, int layout,
int nwrites, int *dest,
--
2.13.6
++++++ 0057-util-Introduce-md_get_array_info.patch ++++++
From 9cd39f015558dba82c293a4433b481b921ceec87 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 29 Mar 2017 14:35:41 -0400
Subject: [PATCH] util: Introduce md_get_array_info()
Git-commit: 9cd39f015558dba82c293a4433b481b921ceec87
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Remove most direct ioctl calls for GET_ARRAY_INFO, except for one,
which will be addressed in the next patch.
This is the start of the effort to clean up the use of ioctl calls and
introduce a more structured API, which will use sysfs and fall back to
ioctl for backup.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Create.c | 5 ++---
Detail.c | 2 +-
Grow.c | 31 ++++++++++++++++---------------
Incremental.c | 11 +++++------
Manage.c | 13 ++++++-------
Monitor.c | 7 ++++---
Query.c | 7 ++++---
mdadm.h | 1 +
mdassemble.c | 2 +-
util.c | 14 +++++++++++---
10 files changed, 51 insertions(+), 42 deletions(-)
diff --git a/Create.c b/Create.c
index 10e7d10..0e0778f 100644
--- a/Create.c
+++ b/Create.c
@@ -156,8 +156,7 @@ int Create(struct supertype *st, char *mddev,
memset(&inf, 0, sizeof(inf));
fd = open(devlist->devname, O_RDONLY);
if (fd >= 0 &&
- ioctl(fd, GET_ARRAY_INFO, &inf) == 0 &&
- inf.raid_disks == 0) {
+ md_get_array_info(fd, &inf) == 0 && inf.raid_disks == 0) {
/* yep, looks like a container */
if (st) {
rv = st->ss->load_container(st, fd,
@@ -634,7 +633,7 @@ int Create(struct supertype *st, char *mddev,
} else {
mdu_array_info_t inf;
memset(&inf, 0, sizeof(inf));
- ioctl(mdfd, GET_ARRAY_INFO, &inf);
+ md_get_array_info(mdfd, &inf);
if (inf.working_disks != 0) {
pr_err("another array by this name is already running.\n");
goto abort_locked;
diff --git a/Detail.c b/Detail.c
index 136875b..d7e886a 100644
--- a/Detail.c
+++ b/Detail.c
@@ -107,7 +107,7 @@ int Detail(char *dev, struct context *c)
external = (sra != NULL && sra->array.major_version == -1
&& sra->array.minor_version == -2);
st = super_by_fd(fd, &subarray);
- if (ioctl(fd, GET_ARRAY_INFO, &array) == 0) {
+ if (md_get_array_info(fd, &array) == 0) {
inactive = 0;
} else if (errno == ENODEV && sra) {
if (sra->array.major_version == -1 &&
diff --git a/Grow.c b/Grow.c
index 6405f0e..4eab5cc 100755
--- a/Grow.c
+++ b/Grow.c
@@ -115,7 +115,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
struct supertype *st = NULL;
char *subarray = NULL;
- if (ioctl(fd, GET_ARRAY_INFO, &info.array) < 0) {
+ if (md_get_array_info(fd, &info.array) < 0) {
pr_err("cannot get array info for %s\n", devname);
return 1;
}
@@ -221,7 +221,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
* Now go through and update all superblocks
*/
- if (ioctl(fd, GET_ARRAY_INFO, &info.array) < 0) {
+ if (md_get_array_info(fd, &info.array) < 0) {
pr_err("cannot get array info for %s\n", devname);
return 1;
}
@@ -328,7 +328,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
devname, bmf.pathname);
return 1;
}
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
pr_err("cannot get array status for %s\n", devname);
return 1;
}
@@ -1784,7 +1784,7 @@ int Grow_reshape(char *devname, int fd,
struct mdinfo info;
struct mdinfo *sra;
- if (ioctl(fd, GET_ARRAY_INFO, &array) < 0) {
+ if (md_get_array_info(fd, &array) < 0) {
pr_err("%s is not an active md array - aborting\n",
devname);
return 1;
@@ -2030,7 +2030,7 @@ int Grow_reshape(char *devname, int fd,
/* get array parameters after takeover
* to change one parameter at time only
*/
- rv = ioctl(fd, GET_ARRAY_INFO, &array);
+ rv = md_get_array_info(fd, &array);
}
}
/* make sure mdmon is
@@ -2072,7 +2072,7 @@ int Grow_reshape(char *devname, int fd,
/* go back to raid0, drop parity disk
*/
sysfs_set_str(sra, NULL, "level", "raid0");
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
}
size_change_error:
@@ -2101,7 +2101,7 @@ size_change_error:
sysfs_set_str(sra, NULL, "resync_start", "none") < 0)
pr_err("--assume-clean not supported with --grow on this kernel\n");
}
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
s->size = get_component_size(fd)/2;
if (s->size == 0)
s->size = array.size;
@@ -2267,7 +2267,7 @@ size_change_error:
rv =1 ;
}
if (s->layout_str) {
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
dprintf("Cannot get array information.\n");
goto release;
}
@@ -2830,7 +2830,7 @@ static int impose_reshape(struct mdinfo *sra,
* reshape->after.data_disks);
}
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
if (info->array.chunk_size == info->new_chunk &&
reshape->before.layout == reshape->after.layout &&
st->ss->external == 0) {
@@ -2885,7 +2885,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
struct mdinfo info;
sysfs_init(&info, fd, NULL);
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
if (level == 0 &&
(array.level >= 4 && array.level <= 6)) {
/* To convert to RAID0 we need to fail and
@@ -2921,7 +2921,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
makedev(disk.major, disk.minor));
}
/* Now fail anything left */
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
for (d = 0, found = 0;
d < MAX_DISKS && found < array.nr_disks;
d++) {
@@ -3042,7 +3042,7 @@ static int reshape_array(char *container, int fd, char *devname,
/* when reshaping a RAID0, the component_size might be zero.
* So try to fix that up.
*/
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
dprintf("Cannot get array information.\n");
goto release;
}
@@ -3230,7 +3230,7 @@ static int reshape_array(char *container, int fd, char *devname,
* some more changes: layout, raid_disks, chunk_size
*/
/* read current array info */
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
dprintf("Cannot get array information.\n");
goto release;
}
@@ -4994,8 +4994,9 @@ int Grow_continue_command(char *devname, int fd,
int d;
int cnt = 5;
dprintf_cont("native array (%s)\n", devname);
- if (ioctl(fd, GET_ARRAY_INFO, &array.array) < 0) {
- pr_err("%s is not an active md array - aborting\n", devname);
+ if (md_get_array_info(fd, &array.array) < 0) {
+ pr_err("%s is not an active md array - aborting\n",
+ devname);
ret_val = 1;
goto Grow_continue_command_exit;
}
diff --git a/Incremental.c b/Incremental.c
index 81afc7e..1f12c77 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -398,7 +398,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
&& ! policy_action_allows(policy, st->ss->name,
act_re_add)
&& c->runstop < 1) {
- if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+ if (md_get_array_info(mdfd, &ainf) == 0) {
pr_err("not adding %s to active array (without --run) %s\n",
devname, chosen_name);
rv = 2;
@@ -549,7 +549,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
/* + add any bitmap file */
/* + start the array (auto-readonly). */
- if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+ if (md_get_array_info(mdfd, &ainf) == 0) {
if (c->export) {
printf("MD_STARTED=already\n");
} else if (c->verbose >= 0)
@@ -664,7 +664,7 @@ static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
struct mdinfo *d;
mdu_array_info_t ra;
- if (ioctl(mdfd, GET_ARRAY_INFO, &ra) == 0)
+ if (md_get_array_info(mdfd, &ra) == 0)
return; /* not safe to remove from active arrays
* without thinking more */
@@ -837,7 +837,7 @@ static int container_members_max_degradation(struct map_ent *map, struct map_ent
if (afd < 0)
continue;
/* most accurate information regarding array degradation */
- if (ioctl(afd, GET_ARRAY_INFO, &array) >= 0) {
+ if (md_get_array_info(afd, &array) >= 0) {
int degraded = array.raid_disks - array.active_disks -
array.spare_disks;
if (degraded > max_degraded)
@@ -1390,8 +1390,7 @@ restart:
rv = 1;
continue;
}
- if (ioctl(mdfd, GET_ARRAY_INFO, &array) == 0 ||
- errno != ENODEV) {
+ if (md_get_array_info(mdfd, &array) == 0 || errno != ENODEV) {
close(mdfd);
continue;
}
diff --git a/Manage.c b/Manage.c
index 55218d9..24ed370 100644
--- a/Manage.c
+++ b/Manage.c
@@ -95,7 +95,7 @@ int Manage_ro(char *devname, int fd, int readonly)
goto out;
}
#endif
- if (ioctl(fd, GET_ARRAY_INFO, &array)) {
+ if (md_get_array_info(fd, &array)) {
pr_err("%s does not appear to be active.\n",
devname);
rv = 1;
@@ -539,7 +539,7 @@ static void add_faulty(struct mddev_dev *dv, int fd, char disp)
int remaining_disks;
int i;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0)
+ if (md_get_array_info(fd, &array) != 0)
return;
remaining_disks = array.nr_disks;
@@ -565,7 +565,7 @@ static void add_detached(struct mddev_dev *dv, int fd, char disp)
int remaining_disks;
int i;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0)
+ if (md_get_array_info(fd, &array) != 0)
return;
remaining_disks = array.nr_disks;
@@ -602,7 +602,7 @@ static void add_set(struct mddev_dev *dv, int fd, char set_char)
int copies, set;
int i;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0)
+ if (md_get_array_info(fd, &array) != 0)
return;
if (array.level != 10)
return;
@@ -1383,9 +1383,8 @@ int Manage_subdevs(char *devname, int fd,
int busy = 0;
int raid_slot = -1;
- if (ioctl(fd, GET_ARRAY_INFO, &array)) {
- pr_err("Cannot get array info for %s\n",
- devname);
+ if (md_get_array_info(fd, &array)) {
+ pr_err("Cannot get array info for %s\n", devname);
goto abort;
}
sysfs_init(&info, fd, NULL);
diff --git a/Monitor.c b/Monitor.c
index bdd3e63..0a0a1e2 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -497,7 +497,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
return 0;
}
fcntl(fd, F_SETFD, FD_CLOEXEC);
- if (ioctl(fd, GET_ARRAY_INFO, &array)<0) {
+ if (md_get_array_info(fd, &array) < 0) {
if (!st->err)
alert("DeviceDisappeared", dev, NULL, ainfo);
st->err++;
@@ -709,9 +709,10 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
st->devname = xstrdup(name);
if ((fd = open(st->devname, O_RDONLY)) < 0 ||
- ioctl(fd, GET_ARRAY_INFO, &array)< 0) {
+ md_get_array_info(fd, &array) < 0) {
/* no such array */
- if (fd >=0) close(fd);
+ if (fd >= 0)
+ close(fd);
put_md_name(st->devname);
free(st->devname);
if (st->metadata) {
diff --git a/Query.c b/Query.c
index fbc1d10..cae75d1 100644
--- a/Query.c
+++ b/Query.c
@@ -53,9 +53,10 @@ int Query(char *dev)
}
vers = md_get_version(fd);
- if (ioctl(fd, GET_ARRAY_INFO, &array)<0)
+ if (md_get_array_info(fd, &array) < 0)
ioctlerr = errno;
- else ioctlerr = 0;
+ else
+ ioctlerr = 0;
fstat(fd, &stb);
@@ -100,7 +101,7 @@ int Query(char *dev)
activity = "undetected";
if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
if (md_get_version(fd) >= 9000 &&
- ioctl(fd, GET_ARRAY_INFO, &array)>= 0) {
+ md_get_array_info(fd, &array) >= 0) {
if (ioctl(fd, GET_DISK_INFO, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
activity = "active";
diff --git a/mdadm.h b/mdadm.h
index dbf1f92..7770585 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1405,6 +1405,7 @@ extern int Restore_metadata(char *dev, char *dir, struct context *c,
struct supertype *st, int only);
extern int md_get_version(int fd);
+int md_get_array_info(int fd, struct mdu_array_info_s *array);
extern int get_linux_version(void);
extern int mdadm_version(char *version);
extern unsigned long long parse_size(char *size);
diff --git a/mdassemble.c b/mdassemble.c
index 471ffeb..a24b324 100644
--- a/mdassemble.c
+++ b/mdassemble.c
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
if (strcasecmp(array_list->devname, "<ignore>") == 0)
continue;
mdfd = open_mddev(array_list->devname, 0);
- if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
+ if (mdfd >= 0 && md_get_array_info(mdfd, &array) == 0) {
rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
continue;
}
diff --git a/util.c b/util.c
index 374015e..725877d 100644
--- a/util.c
+++ b/util.c
@@ -212,6 +212,15 @@ int cluster_release_dlmlock(int lockid)
#endif
/*
+ * Get array info from the kernel. Longer term we want to deprecate the
+ * ioctl and get it from sysfs.
+ */
+int md_get_array_info(int fd, struct mdu_array_info_s *array)
+{
+ return ioctl(fd, GET_ARRAY_INFO, array);
+}
+
+/*
* Parse a 128 bit uuid in 4 integers
* format is 32 hexx nibbles with options :.<space> separator
* If not exactly 32 hex digits are found, return 0
@@ -539,8 +548,7 @@ int enough_fd(int fd)
int i, rv;
char *avail;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0 ||
- array.raid_disks <= 0)
+ if (md_get_array_info(fd, &array) != 0 || array.raid_disks <= 0)
return 0;
avail = xcalloc(array.raid_disks, 1);
for (i = 0; i < MAX_DISKS && array.nr_disks > 0; i++) {
@@ -1175,7 +1183,7 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
minor = sra->array.minor_version;
verstr = sra->text_version;
} else {
- if (ioctl(fd, GET_ARRAY_INFO, &array))
+ if (md_get_array_info(fd, &array))
array.major_version = array.minor_version = 0;
vers = array.major_version;
minor = array.minor_version;
--
2.13.6
++++++ 0058-Incremental-Remove-redundant-call-for-GET_ARRAY_INFO.patch ++++++
From 5b13d2e1fb8abecddd4e28e67facac5d7ef2cef3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 29 Mar 2017 14:40:36 -0400
Subject: [PATCH] Incremental: Remove redundant call for GET_ARRAY_INFO
Git-commit: 5b13d2e1fb8abecddd4e28e67facac5d7ef2cef3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
The code above just called md_get_array_info() and only reached this
point if it returned an error that isn't ENODEV, so it's pointless to
check this again here.
In addition it was incorrectly retrieving ioctl data into a
mdu_bitmap_file_t instead of mdu_array_info_t.
Fixes: ("8382f19 Add new mode: --incremental")
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 1f12c77..802e525 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1345,7 +1345,6 @@ int IncrementalScan(struct context *c, char *devnm)
restart:
for (me = mapl ; me ; me = me->next) {
mdu_array_info_t array;
- mdu_bitmap_file_t bmf;
struct mdinfo *sra;
int mdfd;
@@ -1405,13 +1404,12 @@ restart:
* is a hint only
*/
int added = -1;
- if (ioctl(mdfd, GET_ARRAY_INFO, &bmf) < 0) {
- int bmfd = open(mddev->bitmap_file, O_RDWR);
- if (bmfd >= 0) {
- added = ioctl(mdfd, SET_BITMAP_FILE,
- bmfd);
- close(bmfd);
- }
+ int bmfd;
+
+ bmfd = open(mddev->bitmap_file, O_RDWR);
+ if (bmfd >= 0) {
+ added = ioctl(mdfd, SET_BITMAP_FILE, bmfd);
+ close(bmfd);
}
if (c->verbose >= 0) {
if (added == 0)
--
2.13.6
++++++ 0059-util-Introduce-md_get_disk_info.patch ++++++
From d97572f5a59ca1ddde9971a79d47c9ea4db5891b Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 29 Mar 2017 15:23:50 -0400
Subject: [PATCH] util: Introduce md_get_disk_info()
Git-commit: d97572f5a59ca1ddde9971a79d47c9ea4db5891b
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This removes all the inline ioctl calls for GET_DISK_INFO, allowing us
to switch to sysfs in one place, and improves type checking.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 8 +++-----
Grow.c | 14 +++++++-------
Manage.c | 19 +++++++++----------
Monitor.c | 2 +-
Query.c | 2 +-
mdadm.h | 1 +
util.c | 10 +++++++++-
7 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/Detail.c b/Detail.c
index d7e886a..fa6d4c7 100644
--- a/Detail.c
+++ b/Detail.c
@@ -51,10 +51,8 @@ static int add_device(const char *dev, char ***p_devices,
int Detail(char *dev, struct context *c)
{
/*
- * Print out details for an md array by using
- * GET_ARRAY_INFO and GET_DISK_INFO ioctl calls
+ * Print out details for an md array
*/
-
int fd = open(dev, O_RDONLY);
int vers;
mdu_array_info_t array;
@@ -165,7 +163,7 @@ int Detail(char *dev, struct context *c)
disk = subdev->disk;
else {
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ if (md_get_disk_info(fd, &disk) < 0)
continue;
if (d >= array.raid_disks &&
disk.major == 0 &&
@@ -322,7 +320,7 @@ int Detail(char *dev, struct context *c)
} else for (d = 0; d < max_disks; d++) {
mdu_disk_info_t disk;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0) {
+ if (md_get_disk_info(fd, &disk) < 0) {
if (d < array.raid_disks)
pr_err("cannot get device detail for device %d: %s\n",
d, strerror(errno));
diff --git a/Grow.c b/Grow.c
index 4eab5cc..1c90902 100755
--- a/Grow.c
+++ b/Grow.c
@@ -161,7 +161,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
st->ss->free_super(st);
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0) {
+ if (md_get_disk_info(fd, &disk) < 0) {
pr_err("cannot get device detail for device %d\n",
d);
close(nfd);
@@ -232,7 +232,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
char *dv;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0) {
+ if (md_get_disk_info(fd, &disk) < 0) {
pr_err("cannot get device detail for device %d\n",
d);
return 1;
@@ -422,7 +422,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
int fd2;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ if (md_get_disk_info(fd, &disk) < 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
@@ -483,7 +483,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
char *dv;
int fd2;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ if (md_get_disk_info(fd, &disk) < 0)
continue;
if ((disk.major==0 && disk.minor == 0) ||
(disk.state & (1 << MD_DISK_REMOVED)))
@@ -2908,7 +2908,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
d++) {
mdu_disk_info_t disk;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ if (md_get_disk_info(fd, &disk) < 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
@@ -2927,7 +2927,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
d++) {
mdu_disk_info_t disk;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ if (md_get_disk_info(fd, &disk) < 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
@@ -5011,7 +5011,7 @@ int Grow_continue_command(char *devname, int fd,
char *dv;
int err;
disk.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ if (md_get_disk_info(fd, &disk) < 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
diff --git a/Manage.c b/Manage.c
index 24ed370..0ffb6c6 100644
--- a/Manage.c
+++ b/Manage.c
@@ -546,7 +546,7 @@ static void add_faulty(struct mddev_dev *dv, int fd, char disp)
for (i = 0; i < MAX_DISKS && remaining_disks > 0; i++) {
char buf[40];
disk.number = i;
- if (ioctl(fd, GET_DISK_INFO, &disk) != 0)
+ if (md_get_disk_info(fd, &disk) != 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
@@ -573,7 +573,7 @@ static void add_detached(struct mddev_dev *dv, int fd, char disp)
char buf[40];
int sfd;
disk.number = i;
- if (ioctl(fd, GET_DISK_INFO, &disk) != 0)
+ if (md_get_disk_info(fd, &disk) != 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
@@ -615,7 +615,7 @@ static void add_set(struct mddev_dev *dv, int fd, char set_char)
for (i = 0; i < MAX_DISKS && remaining_disks > 0; i++) {
char buf[40];
disk.number = i;
- if (ioctl(fd, GET_DISK_INFO, &disk) != 0)
+ if (md_get_disk_info(fd, &disk) != 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
@@ -661,9 +661,8 @@ int attempt_re_add(int fd, int tfd, struct mddev_dev *dv,
get_linux_version() <= 2006018)
goto skip_re_add;
disc.number = mdi.disk.number;
- if (ioctl(fd, GET_DISK_INFO, &disc) != 0
- || disc.major != 0 || disc.minor != 0
- )
+ if (md_get_disk_info(fd, &disc) != 0 ||
+ disc.major != 0 || disc.minor != 0)
goto skip_re_add;
disc.major = major(rdev);
disc.minor = minor(rdev);
@@ -805,7 +804,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
char *dev;
int dfd;
disc.number = j;
- if (ioctl(fd, GET_DISK_INFO, &disc))
+ if (md_get_disk_info(fd, &disc))
continue;
if (disc.major==0 && disc.minor==0)
continue;
@@ -888,7 +887,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
for (d = 0; d < MAX_DISKS && found < array->nr_disks; d++) {
disc.number = d;
- if (ioctl(fd, GET_DISK_INFO, &disc))
+ if (md_get_disk_info(fd, &disc))
continue;
if (disc.major == 0 && disc.minor == 0)
continue;
@@ -929,7 +928,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
*/
for (j = array->raid_disks; j < tst->max_devs; j++) {
disc.number = j;
- if (ioctl(fd, GET_DISK_INFO, &disc))
+ if (md_get_disk_info(fd, &disc))
break;
if (disc.major==0 && disc.minor==0)
break;
@@ -994,7 +993,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
for (j = 0; j < tst->max_devs; j++) {
mdu_disk_info_t disc2;
disc2.number = j;
- if (ioctl(fd, GET_DISK_INFO, &disc2))
+ if (md_get_disk_info(fd, &disc2))
continue;
if (disc2.major==0 && disc2.minor==0)
continue;
diff --git a/Monitor.c b/Monitor.c
index 0a0a1e2..2c0f717 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -608,7 +608,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
i++) {
mdu_disk_info_t disc;
disc.number = i;
- if (ioctl(fd, GET_DISK_INFO, &disc) >= 0) {
+ if (md_get_disk_info(fd, &disc) >= 0) {
info[i].state = disc.state;
info[i].major = disc.major;
info[i].minor = disc.minor;
diff --git a/Query.c b/Query.c
index cae75d1..a2c839c 100644
--- a/Query.c
+++ b/Query.c
@@ -102,7 +102,7 @@ int Query(char *dev)
if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
if (md_get_version(fd) >= 9000 &&
md_get_array_info(fd, &array) >= 0) {
- if (ioctl(fd, GET_DISK_INFO, &disc) >= 0 &&
+ if (md_get_disk_info(fd, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
activity = "active";
else
diff --git a/mdadm.h b/mdadm.h
index 7770585..3ab548f 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1406,6 +1406,7 @@ extern int Restore_metadata(char *dev, char *dir, struct context *c,
extern int md_get_version(int fd);
int md_get_array_info(int fd, struct mdu_array_info_s *array);
+int md_get_disk_info(int fd, struct mdu_disk_info_s *disk);
extern int get_linux_version(void);
extern int mdadm_version(char *version);
extern unsigned long long parse_size(char *size);
diff --git a/util.c b/util.c
index 725877d..aa27e59 100644
--- a/util.c
+++ b/util.c
@@ -221,6 +221,14 @@ int md_get_array_info(int fd, struct mdu_array_info_s *array)
}
/*
+ * Get disk info from the kernel.
+ */
+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 :.<space> separator
* If not exactly 32 hex digits are found, return 0
@@ -553,7 +561,7 @@ int enough_fd(int fd)
avail = xcalloc(array.raid_disks, 1);
for (i = 0; i < MAX_DISKS && array.nr_disks > 0; i++) {
disk.number = i;
- if (ioctl(fd, GET_DISK_INFO, &disk) != 0)
+ if (md_get_disk_info(fd, &disk) != 0)
continue;
if (disk.major == 0 && disk.minor == 0)
continue;
--
2.13.6
++++++ 0060-util-Introduce-md_set_array_info.patch ++++++
From 018a488238e2ff55d7c2fd29333c1f7305354318 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 29 Mar 2017 15:43:53 -0400
Subject: [PATCH] util: Introduce md_set_array_info()
Git-commit: 018a488238e2ff55d7c2fd29333c1f7305354318
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Switch from using ioctl(SET_ARRAY_INFO) to using md_set_array_info()
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Build.c | 4 ++--
Grow.c | 17 ++++++++---------
mdadm.h | 1 +
util.c | 12 ++++++++++--
4 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/Build.c b/Build.c
index a5fcc06..691dd6f 100644
--- a/Build.c
+++ b/Build.c
@@ -148,8 +148,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
s->chunk = 64;
array.chunk_size = s->chunk*1024;
array.layout = s->layout;
- if (ioctl(mdfd, SET_ARRAY_INFO, &array)) {
- pr_err("SET_ARRAY_INFO failed for %s: %s\n",
+ if (md_set_array_info(mdfd, &array)) {
+ pr_err("md_set_array_info() failed for %s: %s\n",
mddev, strerror(errno));
goto abort;
}
diff --git a/Grow.c b/Grow.c
index 1c90902..af8d520 100755
--- a/Grow.c
+++ b/Grow.c
@@ -335,7 +335,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
if (array.state & (1 << MD_SB_BITMAP_PRESENT)) {
if (strcmp(s->bitmap_file, "none")==0) {
array.state &= ~(1 << MD_SB_BITMAP_PRESENT);
- if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
+ if (md_set_array_info(fd, &array) != 0) {
if (array.state & (1 << MD_SB_CLUSTERED))
pr_err("failed to remove clustered bitmap.\n");
else
@@ -463,7 +463,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
if (strcmp(s->bitmap_file, "clustered") == 0)
array.state |= (1 << MD_SB_CLUSTERED);
array.state |= (1 << MD_SB_BITMAP_PRESENT);
- rv = ioctl(fd, SET_ARRAY_INFO, &array);
+ rv = md_set_array_info(fd, &array);
}
if (rv < 0) {
if (errno == EBUSY)
@@ -1823,7 +1823,7 @@ int Grow_reshape(char *devname, int fd,
(array.state & (1<verbose >= 0)
@@ -2836,8 +2836,7 @@ static int impose_reshape(struct mdinfo *sra,
st->ss->external == 0) {
/* use SET_ARRAY_INFO but only if reshape hasn't started */
array.raid_disks = reshape->after.data_disks + reshape->parity;
- if (!restart &&
- ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
+ if (!restart && md_set_array_info(fd, &array) != 0) {
int err = errno;
pr_err("Cannot set device shape for %s: %s\n",
@@ -3239,7 +3238,7 @@ static int reshape_array(char *container, int fd, char *devname,
if (info->new_layout != UnSet &&
info->new_layout != array.layout) {
array.layout = info->new_layout;
- if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
+ if (md_set_array_info(fd, &array) != 0) {
pr_err("failed to set new layout\n");
goto release;
} else if (verbose >= 0)
@@ -3250,7 +3249,7 @@ static int reshape_array(char *container, int fd, char *devname,
info->delta_disks != 0 &&
array.raid_disks != (info->array.raid_disks + info->delta_disks)) {
array.raid_disks += info->delta_disks;
- if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
+ if (md_set_array_info(fd, &array) != 0) {
pr_err("failed to set raid disks\n");
goto release;
} else if (verbose >= 0) {
diff --git a/mdadm.h b/mdadm.h
index 3ab548f..084bc97 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1406,6 +1406,7 @@ extern int Restore_metadata(char *dev, char *dir, struct context *c,
extern int md_get_version(int fd);
int md_get_array_info(int fd, struct mdu_array_info_s *array);
+int md_set_array_info(int fd, struct mdu_array_info_s *array);
int md_get_disk_info(int fd, struct mdu_disk_info_s *disk);
extern int get_linux_version(void);
extern int mdadm_version(char *version);
diff --git a/util.c b/util.c
index aa27e59..9fc7ba0 100644
--- a/util.c
+++ b/util.c
@@ -221,6 +221,14 @@ int md_get_array_info(int fd, struct mdu_array_info_s *array)
}
/*
+ * Set array info
+ */
+int md_set_array_info(int fd, struct mdu_array_info_s *array)
+{
+ return ioctl(fd, SET_ARRAY_INFO, array);
+}
+
+/*
* Get disk info from the kernel.
*/
int md_get_disk_info(int fd, struct mdu_disk_info_s *disk)
@@ -1858,9 +1866,9 @@ int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info)
memset(&inf, 0, sizeof(inf));
inf.major_version = info->array.major_version;
inf.minor_version = info->array.minor_version;
- rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
+ rv = md_set_array_info(mdfd, &inf);
} else
- rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
+ rv = md_set_array_info(mdfd, NULL);
return rv;
}
--
2.13.6
++++++ 0061-md_u-Remove-some-unused-ioctl-declarations.patch ++++++
From b0ba6a1dee995b3cd7331b4df92d115e51d8ac0c Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 29 Mar 2017 15:48:24 -0400
Subject: [PATCH] md_u: Remove some unused ioctl declarations
Git-commit: b0ba6a1dee995b3cd7331b4df92d115e51d8ac0c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
These were no longer used in the code, so get rid of them.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
md_u.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/md_u.h b/md_u.h
index f570a34..d59aa2d 100644
--- a/md_u.h
+++ b/md_u.h
@@ -21,19 +21,13 @@
#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t)
#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t)
#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
-#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
#define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t)
/* configuration */
-#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
#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 SET_DISK_INFO _IO (MD_MAJOR, 0x24)
-#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
-#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
-#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
#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.13.6
++++++ 0062-mdadm-grow-reshape-would-be-stuck-from-raid1-to-raid.patch ++++++
From 5b2846684ef5172eccc432e3520b79efbc2abba5 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Thu, 30 Mar 2017 15:38:08 +0800
Subject: [PATCH] mdadm/grow: reshape would be stuck from raid1 to raid5
Git-commit: 5b2846684ef5172eccc432e3520b79efbc2abba5
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
systemctl doesn't interpret mdadm-grow-continue@.service
correctly due to the wrong argument provided in [service],
it should be corrected %I as %i. Otherwise, if the service
cannot start by systemctl and the reshap progress would be
stuck all time when grows array from raid1 to raid5.
reproduce steps:
./mdadm -CR /dev/md0 -l1 -b internal -n2 /dev/loop[0-1]
./mdadm --grow /dev/md0 -l5 -n3 -a /dev/loop2
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
systemd/mdadm-grow-continue@.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/systemd/mdadm-grow-continue@.service b/systemd/mdadm-grow-continue@.service
index 5c667d2..882bc0b 100644
--- a/systemd/mdadm-grow-continue@.service
+++ b/systemd/mdadm-grow-continue@.service
@@ -10,7 +10,7 @@ Description=Manage MD Reshape on /dev/%I
DefaultDependencies=no
[Service]
-ExecStart=BINDIR/mdadm --grow --continue /dev/%I
+ExecStart=BINDIR/mdadm --grow --continue /dev/%i
StandardInput=null
StandardOutput=null
StandardError=null
--
2.13.6
++++++ 0063-sysfs-Use-the-presence-of-sys-block-dev-md-as-indica.patch ++++++
From 67a02d520085b01a1b9e6ea59fb30e79c5649c9c Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 30 Mar 2017 16:02:36 -0400
Subject: [PATCH] sysfs: Use the presence of /sys/block/<dev>/md as indicator
of valid device
Git-commit: 67a02d520085b01a1b9e6ea59fb30e79c5649c9c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Rather than calling ioctl(RAID_VERSION), use the presence of
/sys/block/<dev>/md as indicator of the device being valid and sysfs
being active for it. The ioctl could return valid data, but sysfs
not mounted, which renders sysfs_init() useless anyway.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
sysfs.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/sysfs.c b/sysfs.c
index 2a91ba0..93ec3de 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -86,15 +86,22 @@ void sysfs_init_dev(struct mdinfo *mdi, unsigned long devid)
void sysfs_init(struct mdinfo *mdi, int fd, char *devnm)
{
+ struct stat stb;
+ char fname[MAX_SYSFS_PATH_LEN];
+
mdi->sys_name[0] = 0;
- if (fd >= 0) {
- mdu_version_t vers;
- if (ioctl(fd, RAID_VERSION, &vers) != 0)
- return;
+ if (fd >= 0)
devnm = fd2devnm(fd);
- }
+
if (devnm == NULL)
return;
+
+ snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md", devnm);
+
+ if (stat(fname, &stb))
+ return;
+ if (!S_ISDIR(stb.st_mode))
+ return;
strcpy(mdi->sys_name, devnm);
}
--
2.13.6
++++++ 0064-sysfs-Make-sysfs_init-return-an-error-code.patch ++++++
From dae131379f9fd82e2867aed25a3ff719f957e9a3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 30 Mar 2017 16:52:37 -0400
Subject: [PATCH] sysfs: Make sysfs_init() return an error code
Git-commit: dae131379f9fd82e2867aed25a3ff719f957e9a3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Rather than have the caller inspect the returned content, return an
error code from sysfs_init(). In addition make all callers actually
check it.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 12 ++++++++++--
Create.c | 10 ++++++++--
Grow.c | 39 +++++++++++++++++++++++++++++++++------
Incremental.c | 12 ++++++++++--
Manage.c | 7 +++++--
Monitor.c | 4 +++-
mdadm.c | 11 ++++++++---
mdadm.h | 2 +-
sysfs.c | 16 ++++++++++------
9 files changed, 88 insertions(+), 25 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 6a6a56b..672cd12 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1670,7 +1670,12 @@ try_again:
}
st->ss->getinfo_super(st, content, NULL);
#ifndef MDASSEMBLE
- sysfs_init(content, mdfd, NULL);
+ if (sysfs_init(content, mdfd, NULL)) {
+ pr_err("Unable to initialize sysfs\n");
+ close(mdfd);
+ free(devices);
+ return 1;
+ }
#endif
/* after reload context, store journal_clean in context */
content->journal_clean = journal_clean;
@@ -1885,7 +1890,10 @@ int assemble_container_content(struct supertype *st, int mdfd,
char *avail;
int err;
- sysfs_init(content, mdfd, NULL);
+ if (sysfs_init(content, mdfd, NULL)) {
+ pr_err("Unable to initialize sysfs\n");
+ return 1;
+ }
sra = sysfs_read(mdfd, NULL, GET_VERSION|GET_DEVS);
if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) {
diff --git a/Create.c b/Create.c
index 0e0778f..32987af 100644
--- a/Create.c
+++ b/Create.c
@@ -737,7 +737,10 @@ int Create(struct supertype *st, char *mddev,
total_slots = info.array.nr_disks;
st->ss->getinfo_super(st, &info, NULL);
- sysfs_init(&info, mdfd, NULL);
+ if (sysfs_init(&info, mdfd, NULL)) {
+ pr_err("unable to initialize sysfs\n");
+ goto abort_locked;
+ }
if (did_default && c->verbose >= 0) {
if (is_subarray(info.text_version)) {
@@ -794,7 +797,10 @@ int Create(struct supertype *st, char *mddev,
s->bitmap_file = NULL;
}
- sysfs_init(&info, mdfd, NULL);
+ if (sysfs_init(&info, mdfd, NULL)) {
+ pr_err("unable to initialize sysfs\n");
+ goto abort_locked;
+ }
if (st->ss->external && st->container_devnm[0]) {
/* member */
diff --git a/Grow.c b/Grow.c
index 0c16d5b..78a3474 100755
--- a/Grow.c
+++ b/Grow.c
@@ -455,7 +455,10 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
}
if (offset_setable) {
st->ss->getinfo_super(st, mdi, NULL);
- sysfs_init(mdi, fd, NULL);
+ if (sysfs_init(mdi, fd, NULL)) {
+ pr_err("failed to intialize sysfs.\n");
+ free(mdi);
+ }
rv = sysfs_set_num_signed(mdi, NULL, "bitmap/location",
mdi->bitmap_offset);
free(mdi);
@@ -2149,7 +2152,11 @@ size_change_error:
memset(&info, 0, sizeof(info));
info.array = array;
- sysfs_init(&info, fd, NULL);
+ if (sysfs_init(&info, fd, NULL)) {
+ pr_err("failed to intialize sysfs.\n");
+ rv = 1;
+ goto release;
+ }
strcpy(info.text_version, sra->text_version);
info.component_size = s->size*2;
info.new_level = s->level;
@@ -2870,7 +2877,11 @@ static int impose_level(int fd, int level, char *devname, int verbose)
char *c;
struct mdu_array_info_s array;
struct mdinfo info;
- sysfs_init(&info, fd, NULL);
+
+ if (sysfs_init(&info, fd, NULL)) {
+ pr_err("failed to intialize sysfs.\n");
+ return 1;
+ }
md_get_array_info(fd, &array);
if (level == 0 &&
@@ -3178,7 +3189,12 @@ static int reshape_array(char *container, int fd, char *devname,
struct mdinfo *d;
if (info2) {
- sysfs_init(info2, fd, st->devnm);
+ if (sysfs_init(info2, fd, st->devnm)) {
+ pr_err("unable to initialize sysfs for %s",
+ st->devnm);
+ free(info2);
+ goto release;
+ }
/* When increasing number of devices, we need to set
* new raid_disks before adding these, or they might
* be rejected.
@@ -3777,7 +3793,12 @@ int reshape_container(char *container, char *devname,
}
strcpy(last_devnm, mdstat->devnm);
- sysfs_init(content, fd, mdstat->devnm);
+ if (sysfs_init(content, fd, mdstat->devnm)) {
+ pr_err("Unable to initialize sysfs for %s\n",
+ mdstat->devnm);
+ rv = 1;
+ break;
+ }
if (mdmon_running(container))
flush_mdmon(container);
@@ -5110,7 +5131,13 @@ int Grow_continue_command(char *devname, int fd,
goto Grow_continue_command_exit;
}
- sysfs_init(content, fd2, mdstat->devnm);
+ if (sysfs_init(content, fd2, mdstat->devnm)) {
+ pr_err("Unable to initialize sysfs for %s, Grow cannot continue",
+ mdstat->devnm);
+ ret_val = 1;
+ close(fd2);
+ goto Grow_continue_command_exit;
+ }
close(fd2);
diff --git a/Incremental.c b/Incremental.c
index 802e525..28f1f77 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -326,7 +326,12 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
if (mdfd < 0)
goto out_unlock;
- sysfs_init(&info, mdfd, NULL);
+ if (sysfs_init(&info, mdfd, NULL)) {
+ pr_err("unable to initialize sysfs for %s\n",
+ chosen_name);
+ rv = 2;
+ goto out_unlock;
+ }
if (set_array_info(mdfd, st, &info) != 0) {
pr_err("failed to set array info for %s: %s\n",
@@ -1734,7 +1739,10 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
pr_err("%s does not appear to be a component of any array\n", devname);
return 1;
}
- sysfs_init(&mdi, -1, ent->devnm);
+ if (sysfs_init(&mdi, -1, ent->devnm)) {
+ pr_err("unable to initialize sysfs for: %s\n", devname);
+ return 1;
+ }
mdfd = open_dev_excl(ent->devnm);
if (mdfd > 0) {
close(mdfd);
diff --git a/Manage.c b/Manage.c
index 0ffb6c6..618c98b 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1382,12 +1382,15 @@ int Manage_subdevs(char *devname, int fd,
int busy = 0;
int raid_slot = -1;
+ if (sysfs_init(&info, fd, NULL)) {
+ pr_err("sysfs not availabile for %s\n", devname);
+ goto abort;
+ }
+
if (md_get_array_info(fd, &array)) {
pr_err("Cannot get array info for %s\n", devname);
goto abort;
}
- sysfs_init(&info, fd, NULL);
-
/* array.size is only 32 bits and may be truncated.
* So read from sysfs if possible, and record number of sectors
*/
diff --git a/Monitor.c b/Monitor.c
index 2c0f717..036a561 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1026,7 +1026,9 @@ int Wait(char *dev)
*/
struct mdinfo mdi;
char buf[21];
- sysfs_init(&mdi, -1, devnm);
+
+ if (sysfs_init(&mdi, -1, devnm))
+ return 2;
if (sysfs_get_str(&mdi, NULL, "sync_action",
buf, 20) > 0 &&
strcmp(buf,"idle\n") != 0) {
diff --git a/mdadm.c b/mdadm.c
index d6b5437..3fe17fc 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1631,7 +1631,10 @@ int main(int argc, char *argv[])
rv = 1;
break;
}
- sysfs_init(&sra, mdfd, NULL);
+ if (sysfs_init(&sra, mdfd, NULL)) {
+ rv = 1;
+ break;
+ }
if (array_size == MAX_SIZE)
err = sysfs_set_str(&sra, NULL, "array_size", "default");
else
@@ -1998,13 +2001,15 @@ int SetAction(char *dev, char *action)
{
int fd = open(dev, O_RDONLY);
struct mdinfo mdi;
+ int retval;
+
if (fd < 0) {
pr_err("Couldn't open %s: %s\n", dev, strerror(errno));
return 1;
}
- sysfs_init(&mdi, fd, NULL);
+ retval = sysfs_init(&mdi, fd, NULL);
close(fd);
- if (!mdi.sys_name[0]) {
+ if (retval) {
pr_err("%s is no an md array\n", dev);
return 1;
}
diff --git a/mdadm.h b/mdadm.h
index 084bc97..612bd86 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -639,7 +639,7 @@ enum sysfs_read_flags {
* else use devnm.
*/
extern int sysfs_open(char *devnm, char *devname, char *attr);
-extern void sysfs_init(struct mdinfo *mdi, int fd, char *devnm);
+extern int sysfs_init(struct mdinfo *mdi, int fd, char *devnm);
extern void sysfs_init_dev(struct mdinfo *mdi, unsigned long devid);
extern void sysfs_free(struct mdinfo *sra);
extern struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options);
diff --git a/sysfs.c b/sysfs.c
index 93ec3de..51deb23 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -84,25 +84,30 @@ void sysfs_init_dev(struct mdinfo *mdi, unsigned long devid)
sizeof(mdi->sys_name), "dev-%s", devid2kname(devid));
}
-void sysfs_init(struct mdinfo *mdi, int fd, char *devnm)
+int sysfs_init(struct mdinfo *mdi, int fd, char *devnm)
{
struct stat stb;
char fname[MAX_SYSFS_PATH_LEN];
+ int retval = -ENODEV;
mdi->sys_name[0] = 0;
if (fd >= 0)
devnm = fd2devnm(fd);
if (devnm == NULL)
- return;
+ goto out;
snprintf(fname, MAX_SYSFS_PATH_LEN, "/sys/block/%s/md", devnm);
if (stat(fname, &stb))
- return;
+ goto out;
if (!S_ISDIR(stb.st_mode))
- return;
+ goto out;
strcpy(mdi->sys_name, devnm);
+
+ retval = 0;
+out:
+ return retval;
}
struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
@@ -117,8 +122,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
struct dirent *de;
sra = xcalloc(1, sizeof(*sra));
- sysfs_init(sra, fd, devnm);
- if (sra->sys_name[0] == 0) {
+ if (sysfs_init(sra, fd, devnm)) {
free(sra);
return NULL;
}
--
2.13.6
++++++ 0065-util-must_be_container-Use-sysfs_read-GET_VERSION-to.patch ++++++
From f5c924f441cedce2a13c48b12be35250560ee575 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 14:01:30 -0400
Subject: [PATCH] util/must_be_container: Use sysfs_read(GET_VERSION) to
determine valid array
Git-commit: f5c924f441cedce2a13c48b12be35250560ee575
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Use sysfs_read() instead of ioctl(RAID_VERSION) to determine this is
in fact a valid raid array fd.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
util.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 9fc7ba0..56daee3 100644
--- a/util.c
+++ b/util.c
@@ -1376,9 +1376,14 @@ int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep)
*/
int must_be_container(int fd)
{
+ struct mdinfo *mdi;
unsigned long long size;
- if (md_get_version(fd) < 0)
+
+ mdi = sysfs_read(fd, NULL, GET_VERSION);
+ if (!mdi)
return 0;
+ sysfs_free(mdi);
+
if (get_dev_size(fd, NULL, &size) == 0)
return 1;
if (size == 0)
--
2.13.6
++++++ 0066-util-set_array_info-Simplify-code-since-md_get_versi.patch ++++++
From 700483a22340f2f25a761acd08e6db87e92d90e9 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:06:24 -0400
Subject: [PATCH] util/set_array_info: Simplify code since md_get_version
returns a constant
Git-commit: 700483a22340f2f25a761acd08e6db87e92d90e9
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
md_get_version() always returns (0 * 1000) + (90 * 100) + 3, so no
point in calling it.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
util.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/util.c b/util.c
index 56daee3..afeb6a5 100644
--- a/util.c
+++ b/util.c
@@ -1858,22 +1858,19 @@ int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info)
* This varies between externally managed arrays
* and older kernels
*/
- int vers = md_get_version(mdfd);
+ mdu_array_info_t inf;
int rv;
#ifndef MDASSEMBLE
if (st->ss->external)
- rv = sysfs_set_array(info, vers);
- else
+ return sysfs_set_array(info, 9003);
#endif
- if ((vers % 100) >= 1) { /* can use different versions */
- mdu_array_info_t inf;
- memset(&inf, 0, sizeof(inf));
- inf.major_version = info->array.major_version;
- inf.minor_version = info->array.minor_version;
- rv = md_set_array_info(mdfd, &inf);
- } else
- rv = md_set_array_info(mdfd, NULL);
+
+ memset(&inf, 0, sizeof(inf));
+ inf.major_version = info->array.major_version;
+ inf.minor_version = info->array.minor_version;
+ rv = md_set_array_info(mdfd, &inf);
+
return rv;
}
--
2.13.6
++++++ 0067-Assemble-Assemble-Stop-checking-kernel-md-driver-ver.patch ++++++
From 6142741d144824c31b733f9d6e6e240b159effc0 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:09:18 -0400
Subject: [PATCH] Assemble/Assemble: Stop checking kernel md driver version
Git-commit: 6142741d144824c31b733f9d6e6e240b159effc0
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Any kernel released during the last decade will return 9003 from
md_get_version() so no point in checking that.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 672cd12..fa5fdbe 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1477,8 +1477,7 @@ try_again:
return 1;
}
mddev = chosen_name;
- if (get_linux_version() < 2004000 ||
- md_get_version(mdfd) < 9000) {
+ if (get_linux_version() < 2004000) {
pr_err("Assemble requires Linux 2.4 or later, and\n"
" md driver version 0.90.0 or later.\n"
" Upgrade your kernel or try --build\n");
--
2.13.6
++++++ 0068-Build-Stop-bothering-about-supporting-md-driver-olde.patch ++++++
From e6e5f8f1267de4f310415231b3434fce2d25f02a Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:20:52 -0400
Subject: [PATCH] Build: Stop bothering about supporting md driver older than
0.90.00
Git-commit: e6e5f8f1267de4f310415231b3434fce2d25f02a
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
The kernel has been stuck at md driver version 0.90.03 for at least a
decade. No point in continuing to support the older API.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Build.c | 187 ++++++++++++++++++++++++----------------------------------------
1 file changed, 69 insertions(+), 118 deletions(-)
diff --git a/Build.c b/Build.c
index 691dd6f..11ba12f 100644
--- a/Build.c
+++ b/Build.c
@@ -39,13 +39,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
* geometry is 0xpp00cc
* where pp is personality: 1==linear, 2=raid0
* cc = chunk size factor: 0==4k, 1==8k etc.
- *
- * For md_version >= 0.90.0 we call
- * SET_ARRAY_INFO, ADD_NEW_DISK, RUN_ARRAY
- *
*/
int i;
- int vers;
struct stat stb;
int subdevs = 0, missing_disks = 0;
struct mddev_dev *dv;
@@ -55,6 +50,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
char chosen_name[1024];
int uuid[4] = {0,0,0,0};
struct map_ent *map = NULL;
+ mdu_array_info_t array;
+ mdu_param_t param; /* not used by syscall */
if (s->level == UnSet) {
pr_err("a RAID level is needed to Build an array.\n");
@@ -122,39 +119,30 @@ int Build(char *mddev, struct mddev_dev *devlist,
map_update(&map, fd2devnm(mdfd), "none", uuid, chosen_name);
map_unlock(&map);
- vers = md_get_version(mdfd);
-
- /* looks Ok, go for it */
- if (vers >= 9000) {
- mdu_array_info_t array;
- array.level = s->level;
- if (s->size == MAX_SIZE)
- s->size = 0;
- array.size = s->size;
- array.nr_disks = s->raiddisks;
- array.raid_disks = s->raiddisks;
- array.md_minor = 0;
- if (fstat(mdfd, &stb)==0)
- array.md_minor = minor(stb.st_rdev);
- array.not_persistent = 1;
- array.state = 0; /* not clean, but no errors */
- if (s->assume_clean)
- array.state |= 1;
- array.active_disks = s->raiddisks - missing_disks;
- array.working_disks = s->raiddisks - missing_disks;
- array.spare_disks = 0;
- array.failed_disks = missing_disks;
- if (s->chunk == 0 && (s->level==0 || s->level==LEVEL_LINEAR))
- s->chunk = 64;
- array.chunk_size = s->chunk*1024;
- array.layout = s->layout;
- if (md_set_array_info(mdfd, &array)) {
- pr_err("md_set_array_info() failed for %s: %s\n",
- mddev, strerror(errno));
- goto abort;
- }
- } else if (s->bitmap_file) {
- pr_err("bitmaps not supported with this kernel\n");
+ array.level = s->level;
+ if (s->size == MAX_SIZE)
+ s->size = 0;
+ array.size = s->size;
+ array.nr_disks = s->raiddisks;
+ array.raid_disks = s->raiddisks;
+ array.md_minor = 0;
+ if (fstat(mdfd, &stb) == 0)
+ array.md_minor = minor(stb.st_rdev);
+ array.not_persistent = 1;
+ array.state = 0; /* not clean, but no errors */
+ if (s->assume_clean)
+ array.state |= 1;
+ array.active_disks = s->raiddisks - missing_disks;
+ array.working_disks = s->raiddisks - missing_disks;
+ array.spare_disks = 0;
+ array.failed_disks = missing_disks;
+ if (s->chunk == 0 && (s->level==0 || s->level==LEVEL_LINEAR))
+ s->chunk = 64;
+ array.chunk_size = s->chunk*1024;
+ array.layout = s->layout;
+ if (md_set_array_info(mdfd, &array)) {
+ pr_err("md_set_array_info() failed for %s: %s\n",
+ mddev, strerror(errno));
goto abort;
}
@@ -167,8 +155,10 @@ int Build(char *mddev, struct mddev_dev *devlist,
}
/* now add the devices */
for ((i=0), (dv = devlist) ; dv ; i++, dv=dv->next) {
+ mdu_disk_info_t disk;
unsigned long long dsize;
int fd;
+
if (strcmp("missing", dv->devname) == 0)
continue;
if (stat(dv->devname, &stb)) {
@@ -191,94 +181,58 @@ int Build(char *mddev, struct mddev_dev *devlist,
(s->size == 0 || s->size == MAX_SIZE || dsize < s->size))
s->size = dsize;
close(fd);
- if (vers >= 9000) {
- mdu_disk_info_t disk;
- disk.number = i;
- disk.raid_disk = i;
- disk.state = (1<writemostly == FlagSet)
- disk.state |= 1<devname, strerror(errno));
- goto abort;
- }
- } else {
- if (ioctl(mdfd, REGISTER_DEV, &stb.st_rdev)) {
- pr_err("REGISTER_DEV failed for %s: %s.\n",
- dv->devname, strerror(errno));
- goto abort;
- }
+ disk.number = i;
+ disk.raid_disk = i;
+ disk.state = (1<writemostly == FlagSet)
+ disk.state |= 1<devname, strerror(errno));
+ goto abort;
}
}
/* now to start it */
- if (vers >= 9000) {
- mdu_param_t param; /* not used by syscall */
- if (s->bitmap_file) {
- bitmap_fd = open(s->bitmap_file, O_RDWR);
- if (bitmap_fd < 0) {
- int major = BITMAP_MAJOR_HI;
+ if (s->bitmap_file) {
+ bitmap_fd = open(s->bitmap_file, O_RDWR);
+ if (bitmap_fd < 0) {
+ int major = BITMAP_MAJOR_HI;
#if 0
- if (s->bitmap_chunk == UnSet) {
- pr_err("%s cannot be openned.",
- s->bitmap_file);
- goto abort;
- }
-#endif
- if (vers < 9003) {
- major = BITMAP_MAJOR_HOSTENDIAN;
-#ifdef __BIG_ENDIAN
- pr_err("Warning - bitmaps created on this kernel are not portable\n"
- " between different architectures. Consider upgrading the Linux kernel.\n");
+ if (s->bitmap_chunk == UnSet) {
+ pr_err("%s cannot be openned.", s->bitmap_file);
+ goto abort;
+ }
#endif
- }
- bitmapsize = s->size>>9; /* FIXME wrong for RAID10 */
- if (CreateBitmap(s->bitmap_file, 1, NULL, s->bitmap_chunk,
- c->delay, s->write_behind, bitmapsize, major)) {
- goto abort;
- }
- bitmap_fd = open(s->bitmap_file, O_RDWR);
- if (bitmap_fd < 0) {
- pr_err("%s cannot be openned.",
- s->bitmap_file);
- goto abort;
- }
+ bitmapsize = s->size >> 9; /* FIXME wrong for RAID10 */
+ if (CreateBitmap(s->bitmap_file, 1, NULL,
+ s->bitmap_chunk, c->delay,
+ s->write_behind, bitmapsize, major)) {
+ goto abort;
}
- if (bitmap_fd >= 0) {
- if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
- pr_err("Cannot set bitmap file for %s: %s\n",
- mddev, strerror(errno));
- goto abort;
- }
+ bitmap_fd = open(s->bitmap_file, O_RDWR);
+ if (bitmap_fd < 0) {
+ pr_err("%s cannot be openned.", s->bitmap_file);
+ goto abort;
}
}
- if (ioctl(mdfd, RUN_ARRAY, ¶m)) {
- pr_err("RUN_ARRAY failed: %s\n",
- strerror(errno));
- if (s->chunk & (s->chunk-1)) {
- cont_err("Problem may be that chunk size is not a power of 2\n");
+ if (bitmap_fd >= 0) {
+ if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
+ pr_err("Cannot set bitmap file for %s: %s\n",
+ mddev, strerror(errno));
+ goto abort;
}
- goto abort;
- }
- } else {
- unsigned long arg;
- arg=0;
- while (s->chunk > 4096) {
- arg++;
- s->chunk >>= 1;
}
- if (s->level == 0)
- arg |= 0x20000;
- else
- arg |= 0x10000;
- if (ioctl(mdfd, START_MD, arg)) {
- pr_err("START_MD failed: %s\n",
- strerror(errno));
- goto abort;
+ }
+ if (ioctl(mdfd, RUN_ARRAY, ¶m)) {
+ pr_err("RUN_ARRAY failed: %s\n", strerror(errno));
+ if (s->chunk & (s->chunk - 1)) {
+ cont_err("Problem may be that chunk size is not a power of 2\n");
}
+ goto abort;
}
+
if (c->verbose >= 0)
pr_err("array %s built and started.\n",
mddev);
@@ -287,10 +241,7 @@ int Build(char *mddev, struct mddev_dev *devlist,
return 0;
abort:
- if (vers >= 9000)
- ioctl(mdfd, STOP_ARRAY, 0);
- else
- ioctl(mdfd, STOP_MD, 0);
+ ioctl(mdfd, STOP_ARRAY, 0);
close(mdfd);
return 1;
}
--
2.13.6
++++++ 0069-Grow-Stop-bothering-about-md-driver-versions-older-t.patch ++++++
From 6ae8b2b3140475b1a70485052454210aba4065a6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:22:36 -0400
Subject: [PATCH] Grow: Stop bothering about md driver versions older than
0.90.00
Git-commit: 6ae8b2b3140475b1a70485052454210aba4065a6
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Grow.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/Grow.c b/Grow.c
index 78a3474..15f4ed1 100755
--- a/Grow.c
+++ b/Grow.c
@@ -288,16 +288,9 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
struct supertype *st;
char *subarray = NULL;
int major = BITMAP_MAJOR_HI;
- int vers = md_get_version(fd);
unsigned long long bitmapsize, array_size;
struct mdinfo *mdi;
- if (vers < 9003) {
- major = BITMAP_MAJOR_HOSTENDIAN;
- pr_err("Warning - bitmaps created on this kernel are not portable\n"
- " between different architectures. Consider upgrading the Linux kernel.\n");
- }
-
/*
* We only ever get called if s->bitmap_file is != NULL, so this check
* is just here to quiet down static code checkers.
--
2.13.6
++++++ 0070-Detail-Stop-bothering-about-md-drivers-older-than-0..patch ++++++
From 901d5ee6da145033ac30fee68f4fec0e8af9eddc Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:26:53 -0400
Subject: [PATCH] Detail: Stop bothering about md drivers older than 0.90.00
Git-commit: 901d5ee6da145033ac30fee68f4fec0e8af9eddc
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Remove further handling of md driver version older than 0.90.00
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff --git a/Detail.c b/Detail.c
index fa6d4c7..d4e6204 100644
--- a/Detail.c
+++ b/Detail.c
@@ -54,7 +54,6 @@ int Detail(char *dev, struct context *c)
* Print out details for an md array
*/
int fd = open(dev, O_RDONLY);
- int vers;
mdu_array_info_t array;
mdu_disk_info_t *disks;
int next;
@@ -88,22 +87,14 @@ int Detail(char *dev, struct context *c)
dev, strerror(errno));
return rv;
}
- vers = md_get_version(fd);
- if (vers < 0) {
- pr_err("%s does not appear to be an md device\n",
- dev);
- close(fd);
- return rv;
- }
- if (vers < 9000) {
- pr_err("cannot get detail for md device %s: driver version too old.\n",
- dev);
+ sra = sysfs_read(fd, NULL, GET_VERSION|GET_DEVS);
+ if (!sra) {
+ pr_err("%s does not appear to be an md device\n", dev);
close(fd);
return rv;
}
- sra = sysfs_read(fd, NULL, GET_VERSION|GET_DEVS);
- external = (sra != NULL && sra->array.major_version == -1
- && sra->array.minor_version == -2);
+ external = (sra != NULL && sra->array.major_version == -1 &&
+ sra->array.minor_version == -2);
st = super_by_fd(fd, &subarray);
if (md_get_array_info(fd, &array) == 0) {
inactive = 0;
@@ -378,9 +369,7 @@ int Detail(char *dev, struct context *c)
}
/* Only try GET_BITMAP_FILE for 0.90.01 and later */
- if (vers >= 9001 &&
- ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 &&
- bmf.pathname[0]) {
+ if (ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 && bmf.pathname[0]) {
printf(" bitmap=%s", bmf.pathname);
}
} else {
@@ -449,9 +438,7 @@ int Detail(char *dev, struct context *c)
array.not_persistent?"not ":"");
printf("\n");
/* Only try GET_BITMAP_FILE for 0.90.01 and later */
- if (vers >= 9001 &&
- ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 &&
- bmf.pathname[0]) {
+ 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<
From 5f4cc2392689528a9234fae1935cd442f7917738 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:32:40 -0400
Subject: [PATCH] Create: Remove all attemps to handle md driver older than
0.90.03
Git-commit: 5f4cc2392689528a9234fae1935cd442f7917738
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
More legacy code moved to the bit-bucket.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Create.c | 30 +++++-------------------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/Create.c b/Create.c
index 4f98c58..6ca0924 100644
--- a/Create.c
+++ b/Create.c
@@ -97,7 +97,6 @@ int Create(struct supertype *st, char *mddev,
int insert_point = subdevs * 2; /* where to insert a missing drive */
int total_slots;
int pass;
- int vers;
int rv;
int bitmap_fd;
int have_container = 0;
@@ -112,6 +111,7 @@ int Create(struct supertype *st, char *mddev,
char chosen_name[1024];
struct map_ent *map = NULL;
unsigned long long newsize;
+ mdu_array_info_t inf;
int major_num = BITMAP_MAJOR_HI;
if (s->bitmap_file && strcmp(s->bitmap_file, "clustered") == 0) {
@@ -150,7 +150,6 @@ int Create(struct supertype *st, char *mddev,
/* If given a single device, it might be a container, and we can
* extract a device list from there
*/
- mdu_array_info_t inf;
int fd;
memset(&inf, 0, sizeof(inf));
@@ -625,18 +624,11 @@ int Create(struct supertype *st, char *mddev,
}
mddev = chosen_name;
- vers = md_get_version(mdfd);
- if (vers < 9000) {
- pr_err("Create requires md driver version 0.90.0 or later\n");
+ memset(&inf, 0, sizeof(inf));
+ md_get_array_info(mdfd, &inf);
+ if (inf.working_disks != 0) {
+ pr_err("another array by this name is already running.\n");
goto abort_locked;
- } else {
- mdu_array_info_t inf;
- memset(&inf, 0, sizeof(inf));
- md_get_array_info(mdfd, &inf);
- if (inf.working_disks != 0) {
- pr_err("another array by this name is already running.\n");
- goto abort_locked;
- }
}
/* Ok, lets try some ioctls */
@@ -761,20 +753,8 @@ int Create(struct supertype *st, char *mddev,
* to stop another mdadm from finding and using those devices.
*/
- if (s->bitmap_file && vers < 9003) {
- major_num = BITMAP_MAJOR_HOSTENDIAN;
-#ifdef __BIG_ENDIAN
- pr_err("Warning - bitmaps created on this kernel are not portable\n"
- " between different architectured. Consider upgrading the Linux kernel.\n");
-#endif
- }
-
if (s->bitmap_file && (strcmp(s->bitmap_file, "internal") == 0 ||
strcmp(s->bitmap_file, "clustered") == 0)) {
- if ((vers % 100) < 2) {
- pr_err("internal bitmaps not supported by this kernel.\n");
- goto abort_locked;
- }
if (!st->ss->add_internal_bitmap) {
pr_err("internal bitmaps not supported with %s metadata\n",
st->ss->name);
--
2.13.6
++++++ 0072-Manage-Remove-all-references-to-md_get_version.patch ++++++
From 091e8e6e061a5739be68d214bbd4a25e38bec65c Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:34:44 -0400
Subject: [PATCH] Manage: Remove all references to md_get_version()
Git-commit: 091e8e6e061a5739be68d214bbd4a25e38bec65c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
At this point, support for md driver prior to 0.90.03 is going to
disappear.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Manage.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/Manage.c b/Manage.c
index 618c98b..9e69132 100644
--- a/Manage.c
+++ b/Manage.c
@@ -46,10 +46,6 @@ int Manage_ro(char *devname, int fd, int readonly)
#endif
int rv = 0;
- if (md_get_version(fd) < 9000) {
- pr_err("need md driver version 0.90.0 or later\n");
- return 1;
- }
#ifndef MDASSEMBLE
/* If this is an externally-managed array, we need to modify the
* metadata_version so that mdmon doesn't undo our change.
@@ -176,10 +172,6 @@ int Manage_run(char *devname, int fd, struct context *c)
*/
char nm[32], *nmp;
- if (md_get_version(fd) < 9000) {
- pr_err("need md driver version 0.90.0 or later\n");
- return 1;
- }
nmp = fd2devnm(fd);
if (!nmp) {
pr_err("Cannot find %s in sysfs!!\n", devname);
@@ -207,14 +199,6 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
if (will_retry && verbose == 0)
verbose = -1;
- if (md_get_version(fd) < 9000) {
- if (ioctl(fd, STOP_MD, 0) == 0)
- return 0;
- pr_err("stopping device %s failed: %s\n",
- devname, strerror(errno));
- return 1;
- }
-
strcpy(devnm, fd2devnm(fd));
/* Get EXCL access first. If this fails, then attempting
* to stop is probably a bad idea.
@@ -773,9 +757,7 @@ 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 &&
- md_get_version(fd)%100 < 2) {
+ 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",
--
2.13.6
++++++ 0073-Query-Remove-all-references-to-md_get_version.patch ++++++
From 5cb859962febacba3bb9257fc6ed9553ecc16752 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:37:38 -0400
Subject: [PATCH] Query: Remove all references to md_get_version()
Git-commit: 5cb859962febacba3bb9257fc6ed9553ecc16752
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
More legacy code removed
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Query.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/Query.c b/Query.c
index a2c839c..bea273f 100644
--- a/Query.c
+++ b/Query.c
@@ -33,7 +33,6 @@ int Query(char *dev)
* a superblock
*/
int fd = open(dev, O_RDONLY);
- int vers;
int ioctlerr;
int superror;
struct mdinfo info;
@@ -52,7 +51,6 @@ int Query(char *dev)
return 1;
}
- vers = md_get_version(fd);
if (md_get_array_info(fd, &array) < 0)
ioctlerr = errno;
else
@@ -60,16 +58,12 @@ int Query(char *dev)
fstat(fd, &stb);
- if (vers>=9000 && !ioctlerr) {
+ if (!ioctlerr) {
if (!get_dev_size(fd, NULL, &larray_size))
larray_size = 0;
}
- if (vers < 0)
- printf("%s: is not an md array\n", dev);
- else if (vers < 9000)
- printf("%s: is an md device, but kernel cannot provide details\n", dev);
- else if (ioctlerr == ENODEV)
+ if (ioctlerr == ENODEV)
printf("%s: is an md device which is not active\n", dev);
else if (ioctlerr)
printf("%s: is an md device, but gives \"%s\" when queried\n",
@@ -100,8 +94,7 @@ int Query(char *dev)
disc.number = info.disk.number;
activity = "undetected";
if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
- if (md_get_version(fd) >= 9000 &&
- md_get_array_info(fd, &array) >= 0) {
+ if (md_get_array_info(fd, &array) >= 0) {
if (md_get_disk_info(fd, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
activity = "active";
--
2.13.6
++++++ 0074-bitmap-Remove-use-of-md_get_version.patch ++++++
From 5d89b18da805cb9ce2b0f726cd534bcbf4dce8c6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:38:48 -0400
Subject: [PATCH] bitmap: Remove use of md_get_version()
Git-commit: 5d89b18da805cb9ce2b0f726cd534bcbf4dce8c6
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
bitmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bitmap.c b/bitmap.c
index ccedfd3..16a6b73 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -260,7 +260,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
if (!info)
return rv;
sb = &info->sb;
- if (sb->magic != BITMAP_MAGIC && md_get_version(fd) > 0) {
+ if (sb->magic != BITMAP_MAGIC) {
pr_err("This is an md array. To view a bitmap you need to examine\n");
pr_err("a member device, not the array.\n");
pr_err("Reporting bitmap that would be used if this array were used\n");
--
2.13.6
++++++ 0075-mdmon-Stop-bothering-about-md_get_version.patch ++++++
From 15d924d363a2bc02aa4a489241333be3d7820978 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:39:51 -0400
Subject: [PATCH] mdmon: Stop bothering about md_get_version()
Git-commit: 15d924d363a2bc02aa4a489241333be3d7820978
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If anyone has a kernel with md driver older than 0.90.03 they will
also know where to find older versions of mdadm.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdmon.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/mdmon.c b/mdmon.c
index 95e9bba..0955fcc 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -408,10 +408,6 @@ static int mdmon(char *devnm, int must_fork, int takeover)
pr_err("%s: %s\n", devnm, strerror(errno));
return 1;
}
- if (md_get_version(mdfd) < 0) {
- pr_err("%s: Not an md device\n", devnm);
- return 1;
- }
/* Fork, and have the child tell us when they are ready */
if (must_fork) {
--
2.13.6
++++++ 0076-mdopen-open_mddev-Use-md_get_array_info-to-determine.patch ++++++
From 40b054e1dc9e334621fd2081bf6fc46b01dd7ef4 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:44:20 -0400
Subject: [PATCH] mdopen/open_mddev: Use md_get_array_info() to determine valid
array
Git-commit: 40b054e1dc9e334621fd2081bf6fc46b01dd7ef4
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
md_get_array_info() can be used instead of md_get_version() to
determine this is in fact a valid array.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdopen.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mdopen.c b/mdopen.c
index 685ca32..fe240e5 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -416,19 +416,23 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
*/
int open_mddev(char *dev, int report_errors)
{
+ struct mdu_array_info_s array;
int mdfd = open(dev, O_RDONLY);
+
if (mdfd < 0) {
if (report_errors)
pr_err("error opening %s: %s\n",
dev, strerror(errno));
return -1;
}
- if (md_get_version(mdfd) <= 0) {
+
+ if (md_get_array_info(mdfd, &array) != 0) {
close(mdfd);
if (report_errors)
pr_err("%s does not appear to be an md device\n", dev);
return -2;
}
+
return mdfd;
}
--
2.13.6
++++++ 0077-mdassemble-Use-md_get_array_info-to-check-for-valid-.patch ++++++
From 1c9591115d577841522acd245cd2445cb77ee204 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:46:35 -0400
Subject: [PATCH] mdassemble: Use md_get_array_info() to check for valid array
Git-commit: 1c9591115d577841522acd245cd2445cb77ee204
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Get rid of another use of md_get_version()
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdassemble.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/mdassemble.c b/mdassemble.c
index a24b324..f0833bc 100644
--- a/mdassemble.c
+++ b/mdassemble.c
@@ -32,13 +32,12 @@ char const Name[] = "mdassemble";
/* from mdopen.c */
int open_mddev(char *dev, int report_errors/*unused*/)
{
+ struct mdu_array_info_s array;
int mdfd = open(dev, O_RDONLY);
if (mdfd < 0)
- pr_err("error opening %s: %s\n",
- dev, strerror(errno));
- else if (md_get_version(mdfd) <= 0) {
- pr_err("%s does not appear to be an md device\n",
- dev);
+ pr_err("error opening %s: %s\n", dev, strerror(errno));
+ else if (md_get_array_info(mdfd, &array) != 0) {
+ pr_err("%s does not appear to be an md device\n", dev);
close(mdfd);
mdfd = -1;
}
--
2.13.6
++++++ 0078-Assemble-Assemble-Get-rid-of-last-use-of-md_get_vers.patch ++++++
From b6e60be6281a2a4ec326a72de114867797a42d7f Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:47:37 -0400
Subject: [PATCH] Assemble/Assemble: Get rid of last use of md_get_version()
Git-commit: b6e60be6281a2a4ec326a72de114867797a42d7f
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
At this point in the code, we know we have a valid array, and any
recent kernel will return 9003, so no point in querying the kernel for
this.
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 fa5fdbe..0db428f 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1901,7 +1901,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
c->readonly &&
content->text_version[0] == '/')
content->text_version[0] = '-';
- if (sysfs_set_array(content, md_get_version(mdfd)) != 0) {
+ if (sysfs_set_array(content, 9003) != 0) {
sysfs_free(sra);
return 1;
}
--
2.13.6
++++++ 0079-util-Finally-kill-off-md_get_version.patch ++++++
From 303949f6f00b750a88bcdfc39ffdfe9f0463f6f2 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 5 Apr 2017 15:49:18 -0400
Subject: [PATCH] util: Finally kill off md_get_version()
Git-commit: 303949f6f00b750a88bcdfc39ffdfe9f0463f6f2
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.h | 1 -
util.c | 29 -----------------------------
2 files changed, 30 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index 612bd86..f1f643c 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1404,7 +1404,6 @@ extern int Dump_metadata(char *dev, char *dir, struct context *c,
extern int Restore_metadata(char *dev, char *dir, struct context *c,
struct supertype *st, int only);
-extern int md_get_version(int fd);
int md_get_array_info(int fd, struct mdu_array_info_s *array);
int md_set_array_info(int fd, struct mdu_array_info_s *array);
int md_get_disk_info(int fd, struct mdu_disk_info_s *disk);
diff --git a/util.c b/util.c
index afeb6a5..a536f81 100644
--- a/util.c
+++ b/util.c
@@ -273,35 +273,6 @@ int parse_uuid(char *str, int uuid[4])
return 0;
}
-/*
- * Get the md version number.
- * We use the RAID_VERSION ioctl if it is supported
- * If not, but we have a block device with major '9', we assume
- * 0.36.0
- *
- * Return version number as 24 but number - assume version parts
- * always < 255
- */
-
-int md_get_version(int fd)
-{
- struct stat stb;
- mdu_version_t vers;
-
- if (fstat(fd, &stb)<0)
- return -1;
- if ((S_IFMT&stb.st_mode) != S_IFBLK)
- return -1;
-
- if (ioctl(fd, RAID_VERSION, &vers) == 0)
- return (vers.major*10000) + (vers.minor*100) + vers.patchlevel;
- if (errno == EACCES)
- return -1;
- if (major(stb.st_rdev) == MD_MAJOR)
- return (3600);
- return -1;
-}
-
int get_linux_version()
{
struct utsname name;
--
2.13.6
++++++ 0080-mdadm-Fail-for-kernels-older-than-2.6.15.patch ++++++
From dcf3d4de95d1a4cbc65b24a844173ba1c1300b55 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 6 Apr 2017 15:46:31 -0400
Subject: [PATCH] mdadm: Fail for kernels older than 2.6.15
Git-commit: dcf3d4de95d1a4cbc65b24a844173ba1c1300b55
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
With the removal of old kernel API support, mdadm will no longer run
on kernels older than 2.6.15.
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 3fe17fc..001ff68 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -120,6 +120,11 @@ int main(int argc, char *argv[])
ident.container = NULL;
ident.member = NULL;
+ if (get_linux_version() < 2006015) {
+ pr_err("This version of mdadm does not support kernels older than 2.6.15\n");
+ exit(1);
+ }
+
while ((option_index = -1),
(opt = getopt_long(argc, argv, shortopt, long_options,
&option_index)) != -1) {
--
2.13.6
++++++ 0081-Revert-mdadm-grow-reshape-would-be-stuck-from-raid1-.patch ++++++
From 2cfe6f7c646ebc25043f7607f5756edad0bc3071 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 11 Apr 2017 11:30:23 -0400
Subject: [PATCH] Revert "mdadm/grow: reshape would be stuck from raid1 to
raid5"
Git-commit: 2cfe6f7c646ebc25043f7607f5756edad0bc3071
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This reverts commit 5b2846684ef5172eccc432e3520b79efbc2abba5.
This was a red herring and shouldn't have been applied in the first
place.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
systemd/mdadm-grow-continue@.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/systemd/mdadm-grow-continue@.service b/systemd/mdadm-grow-continue@.service
index 882bc0b..5c667d2 100644
--- a/systemd/mdadm-grow-continue@.service
+++ b/systemd/mdadm-grow-continue@.service
@@ -10,7 +10,7 @@ Description=Manage MD Reshape on /dev/%I
DefaultDependencies=no
[Service]
-ExecStart=BINDIR/mdadm --grow --continue /dev/%i
+ExecStart=BINDIR/mdadm --grow --continue /dev/%I
StandardInput=null
StandardOutput=null
StandardError=null
--
2.13.6
++++++ 0082-Retire-mdassemble.patch ++++++
++++ 1401 lines (skipped)
++++++ 0083-super1-Clean-up-various-style-abuses.patch ++++++
++++ 914 lines (skipped)
++++++ 0084-Detail-Remove-pre-2.6-code-for-printing-info-on-rebu.patch ++++++
From 5e13ef714df4734c455b5e4389352c8ab7902038 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 12 Apr 2017 14:48:10 -0400
Subject: [PATCH] Detail: Remove pre-2.6 code for printing info on rebuilding
Git-commit: 5e13ef714df4734c455b5e4389352c8ab7902038
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Since we no longer support anything pre-2.6.15, there is no point in
keeping this around.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/Detail.c b/Detail.c
index d4e6204..8f74832 100644
--- a/Detail.c
+++ b/Detail.c
@@ -64,8 +64,6 @@ int Detail(char *dev, struct context *c)
int max_devices = 0, n_devices = 0;
int spares = 0;
struct stat stb;
- int is_26 = get_linux_version() >= 2006000;
- int is_rebuilding = 0;
int failed = 0;
struct supertype *st;
char *subarray = NULL;
@@ -527,7 +525,6 @@ int Detail(char *dev, struct context *c)
"Reshape", "Check"};
printf(" %7s Status : %d%% complete\n",
sync_action[e->resync], e->percent);
- is_rebuilding = 1;
}
free_mdstat(ms);
@@ -676,19 +673,9 @@ This is pretty boring
|(1<= 0)
- printf(" rebuilding");
- } else if (is_rebuilding && failed) {
- /* Taking a bit of a risk here, we remove the
- * device from the array, and then put it back.
- * If this fails, we are rebuilding
- */
- int err = ioctl(fd, HOT_REMOVE_DISK, makedev(disk.major, disk.minor));
- if (err == 0) ioctl(fd, HOT_ADD_DISK, makedev(disk.major, disk.minor));
- if (err && errno == EBUSY)
- printf(" rebuilding");
- }
+ if (disk.raid_disk < array.raid_disks &&
+ disk.raid_disk >= 0)
+ printf(" rebuilding");
}
}
if (disk.state == 0) spares++;
--
2.13.6
++++++ 0085-Assemble-Remove-obsolete-test-for-kernels-older-than.patch ++++++
From 0ef1043ce8dd3f36c7227aa4a260819c4c17c78d Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 12 Apr 2017 14:50:02 -0400
Subject: [PATCH] Assemble: Remove obsolete test for kernels older than 2.4
Git-commit: 0ef1043ce8dd3f36c7227aa4a260819c4c17c78d
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
We only support 2.6.15+ at this point
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 22596b5..d6beb23 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1487,13 +1487,6 @@ try_again:
return 1;
}
mddev = chosen_name;
- if (get_linux_version() < 2004000) {
- pr_err("Assemble requires Linux 2.4 or later, and\n"
- " md driver version 0.90.0 or later.\n"
- " Upgrade your kernel or try --build\n");
- close(mdfd);
- return 1;
- }
if (pre_exist == NULL) {
if (mddev_busy(fd2devnm(mdfd))) {
pr_err("%s already active, cannot restart it!\n",
--
2.13.6
++++++ 0086-Detail-Fixup-ugly-if-foo-abuse.patch ++++++
From 776b199e41d10e344efc47008366ca46715c5acc Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 12 Apr 2017 17:05:55 -0400
Subject: [PATCH] Detail: Fixup ugly if () foo() abuse
Git-commit: 776b199e41d10e344efc47008366ca46715c5acc
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Cosmetic change only
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Detail.c b/Detail.c
index 8f74832..e40cd8f 100644
--- a/Detail.c
+++ b/Detail.c
@@ -141,13 +141,15 @@ int Detail(char *dev, struct context *c)
}
/* try to load a superblock. Try sra->devs first, then try ioctl */
- if (st && !info) for (d = 0, subdev = sra ? sra->devs : NULL;
- d < max_disks || subdev;
- subdev ? (void)(subdev = subdev->next) : (void)(d++)){
+ if (st && !info)
+ for (d = 0, subdev = sra ? sra->devs : NULL;
+ d < max_disks || subdev;
+ subdev ? (void)(subdev = subdev->next) : (void)(d++)){
mdu_disk_info_t disk;
char *dv;
int fd2;
int err;
+
if (subdev)
disk = subdev->disk;
else {
--
2.13.6
++++++ 0087-Query-Handle-error-returned-by-fstat.patch ++++++
From 8d0cd09d73a9a9d57ee73b7a79114e881dad1507 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 13 Apr 2017 11:53:21 -0400
Subject: [PATCH] Query: Handle error returned by fstat()
Git-commit: 8d0cd09d73a9a9d57ee73b7a79114e881dad1507
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
We shouldn't ignore any error returned by fstat() even if open() didn't
fail.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Query.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/Query.c b/Query.c
index bea273f..0d18da4 100644
--- a/Query.c
+++ b/Query.c
@@ -32,22 +32,21 @@ int Query(char *dev)
* whether it is an md device and whether it has
* a superblock
*/
- int fd = open(dev, O_RDONLY);
- int ioctlerr;
+ int fd;
+ int ioctlerr, staterr;
int superror;
struct mdinfo info;
mdu_array_info_t array;
struct supertype *st = NULL;
-
unsigned long long larray_size;
struct stat stb;
char *mddev;
mdu_disk_info_t disc;
char *activity;
+ fd = open(dev, O_RDONLY);
if (fd < 0){
- pr_err("cannot open %s: %s\n",
- dev, strerror(errno));
+ pr_err("cannot open %s: %s\n", dev, strerror(errno));
return 1;
}
@@ -56,9 +55,12 @@ int Query(char *dev)
else
ioctlerr = 0;
- fstat(fd, &stb);
+ if (fstat(fd, &stb) < 0)
+ staterr = errno;
+ else
+ staterr = 0;
- if (!ioctlerr) {
+ if (!ioctlerr && !staterr) {
if (!get_dev_size(fd, NULL, &larray_size))
larray_size = 0;
}
@@ -68,6 +70,9 @@ int Query(char *dev)
else if (ioctlerr)
printf("%s: is an md device, but gives \"%s\" when queried\n",
dev, strerror(ioctlerr));
+ else if (staterr)
+ printf("%s: is not a valid md device, returning %s\n",
+ dev, strerror(ioctlerr));
else {
printf("%s: %s %s %d devices, %d spare%s. Use mdadm --detail for more detail.\n",
dev,
--
2.13.6
++++++ 0088-Query-Use-sysfs-to-obtain-data-if-possible.patch ++++++
From f22d6cde7c7e4be38230ac4c51c3af850ed1614e Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 13 Apr 2017 12:20:46 -0400
Subject: [PATCH] Query: Use sysfs to obtain data if possible
Git-commit: f22d6cde7c7e4be38230ac4c51c3af850ed1614e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Use sysfs to obtain leve, raid_disks, and spare_disks. If sysfs fails,
fall back to calling the ioctl via md_get_array_info().
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Query.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/Query.c b/Query.c
index 0d18da4..b761c47 100644
--- a/Query.c
+++ b/Query.c
@@ -35,7 +35,9 @@ int Query(char *dev)
int fd;
int ioctlerr, staterr;
int superror;
+ int level, raid_disks, spare_disks;
struct mdinfo info;
+ struct mdinfo *sra;
mdu_array_info_t array;
struct supertype *st = NULL;
unsigned long long larray_size;
@@ -50,16 +52,28 @@ int Query(char *dev)
return 1;
}
- if (md_get_array_info(fd, &array) < 0)
- ioctlerr = errno;
- else
- ioctlerr = 0;
-
if (fstat(fd, &stb) < 0)
staterr = errno;
else
staterr = 0;
+ ioctlerr = 0;
+
+ sra = sysfs_read(fd, dev, GET_DISKS | GET_LEVEL | GET_DEVS | GET_STATE);
+ if (sra) {
+ level = sra->array.level;
+ raid_disks = sra->array.raid_disks;
+ spare_disks = sra->array.spare_disks;
+ } else {
+ if (md_get_array_info(fd, &array) < 0) {
+ ioctlerr = errno;
+ } else {
+ level = array.level;
+ raid_disks = array.raid_disks;
+ spare_disks = array.spare_disks;
+ }
+ }
+
if (!ioctlerr && !staterr) {
if (!get_dev_size(fd, NULL, &larray_size))
larray_size = 0;
@@ -75,11 +89,9 @@ int Query(char *dev)
dev, strerror(ioctlerr));
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, array.level),
- array.raid_disks,
- array.spare_disks, array.spare_disks==1?"":"s");
+ dev, human_size_brief(larray_size,IEC),
+ map_num(pers, level), raid_disks,
+ spare_disks, spare_disks == 1 ? "" : "s");
}
st = guess_super(fd);
if (st && st->ss->compare_super != NULL)
--
2.13.6
++++++ 0089-sysfs-Parse-array_state-in-sysfs_read.patch ++++++
From 5e4ca8bb82e98400c9258cb3d7e4d030576f21df Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 19 Apr 2017 23:27:58 -0400
Subject: [PATCH] sysfs: Parse array_state in sysfs_read()
Git-commit: 5e4ca8bb82e98400c9258cb3d7e4d030576f21df
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Rather than copying in the array_state string, parse it and use an
enum to indicate the state.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Manage.c | 2 +-
maps.c | 17 +++++++++++++++++
mdadm.h | 17 ++++++++++++++---
sysfs.c | 9 +++++----
4 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/Manage.c b/Manage.c
index bb84d28..8966e33 100644
--- a/Manage.c
+++ b/Manage.c
@@ -929,7 +929,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
return -1;
}
- if (strncmp(mdp->sysfs_array_state, "readonly", 8) != 0) {
+ if (mdp->array_state != ARRAY_READONLY) {
sysfs_free(mdp);
pr_err("%s is not readonly, cannot add journal.\n", devname);
return -1;
diff --git a/maps.c b/maps.c
index d9ee7de..a8a4639 100644
--- a/maps.c
+++ b/maps.c
@@ -139,6 +139,23 @@ mapping_t consistency_policies[] = {
{ NULL, 0}
};
+mapping_t sysfs_array_states[] = {
+ /*
+ * Beware map_name() uses strcmp() so active-idle must come before
+ * active, to be detected correctly.
+ */
+ { "active-idle", ARRAY_ACTIVE_IDLE },
+ { "active", ARRAY_ACTIVE },
+ { "clear", ARRAY_CLEAR },
+ { "inactive", ARRAY_INACTIVE },
+ { "suspended", ARRAY_SUSPENDED },
+ { "readonly", ARRAY_READONLY },
+ { "read-auto", ARRAY_READ_AUTO },
+ { "clean", ARRAY_CLEAN },
+ { "write-pending", ARRAY_WRITE_PENDING },
+ { NULL, 0 }
+};
+
char *map_num(mapping_t *map, int num)
{
while (map->name) {
diff --git a/mdadm.h b/mdadm.h
index f1f643c..a379973 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -335,8 +335,18 @@ struct mdinfo {
int prev_state, curr_state, next_state;
/* info read from sysfs */
- char sysfs_array_state[20];
-
+ enum {
+ ARRAY_CLEAR,
+ ARRAY_INACTIVE,
+ ARRAY_SUSPENDED,
+ ARRAY_READONLY,
+ ARRAY_READ_AUTO,
+ ARRAY_CLEAN,
+ ARRAY_ACTIVE,
+ ARRAY_WRITE_PENDING,
+ ARRAY_ACTIVE_IDLE,
+ ARRAY_UNKNOWN_STATE,
+ } array_state;
struct md_bb bb;
};
@@ -716,7 +726,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[], consistency_policies[];
+extern mapping_t r5layout[], r6layout[], pers[], modes[], faultylayout[];
+extern mapping_t consistency_policies[], sysfs_array_states[];
extern char *map_dev_preferred(int major, int minor, int create,
char *prefer);
diff --git a/sysfs.c b/sysfs.c
index 51deb23..c6df9b0 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -247,11 +247,12 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
if (options & GET_ARRAY_STATE) {
strcpy(base, "array_state");
- if (load_sys(fname, sra->sysfs_array_state,
- sizeof(sra->sysfs_array_state)))
+ if (load_sys(fname, buf, sizeof(buf)))
goto abort;
- } else
- sra->sysfs_array_state[0] = 0;
+ sra->array_state = map_name(sysfs_array_states, buf);
+ if (sra->array_state == UnSet)
+ sra->array_state = ARRAY_UNKNOWN_STATE;
+ }
if (options & GET_CONSISTENCY_POLICY) {
strcpy(base, "consistency_policy");
--
2.13.6
++++++ 0090-util-Introduce-md_array_active-helper.patch ++++++
From 3ab8f4bf33d906cb1084f7b4036556bfb4bb73ec Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 13 Apr 2017 13:30:17 -0400
Subject: [PATCH] util: Introduce md_array_active() helper
Git-commit: 3ab8f4bf33d906cb1084f7b4036556bfb4bb73ec
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Rather than querying md_get_array_info() to determine whether an array
is valid, do the work in md_array_active() using sysfs, and fall back
on md_get_array_info() if sysfs fails.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Query.c | 5 +++--
mdadm.h | 1 +
util.c | 27 +++++++++++++++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/Query.c b/Query.c
index b761c47..4dec9f5 100644
--- a/Query.c
+++ b/Query.c
@@ -38,7 +38,6 @@ int Query(char *dev)
int level, raid_disks, spare_disks;
struct mdinfo info;
struct mdinfo *sra;
- mdu_array_info_t array;
struct supertype *st = NULL;
unsigned long long larray_size;
struct stat stb;
@@ -65,6 +64,8 @@ int Query(char *dev)
raid_disks = sra->array.raid_disks;
spare_disks = sra->array.spare_disks;
} else {
+ mdu_array_info_t array;
+
if (md_get_array_info(fd, &array) < 0) {
ioctlerr = errno;
} else {
@@ -111,7 +112,7 @@ int Query(char *dev)
disc.number = info.disk.number;
activity = "undetected";
if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
- if (md_get_array_info(fd, &array) >= 0) {
+ if (md_array_active(fd)) {
if (md_get_disk_info(fd, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
activity = "active";
diff --git a/mdadm.h b/mdadm.h
index a379973..f6e97fd 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1415,6 +1415,7 @@ extern int Dump_metadata(char *dev, char *dir, struct context *c,
extern int Restore_metadata(char *dev, char *dir, struct context *c,
struct supertype *st, int only);
+int md_array_active(int fd);
int md_get_array_info(int fd, struct mdu_array_info_s *array);
int md_set_array_info(int fd, struct mdu_array_info_s *array);
int md_get_disk_info(int fd, struct mdu_disk_info_s *disk);
diff --git a/util.c b/util.c
index a695c45..3adc675 100644
--- a/util.c
+++ b/util.c
@@ -200,6 +200,33 @@ out:
return ret;
}
+int md_array_active(int fd)
+{
+ struct mdinfo *sra;
+ struct mdu_array_info_s array;
+ int ret;
+
+ sra = sysfs_read(fd, NULL, GET_ARRAY_STATE);
+ if (sra) {
+ if (sra->array_state != ARRAY_CLEAR &&
+ sra->array_state != ARRAY_INACTIVE &&
+ sra->array_state != ARRAY_UNKNOWN_STATE)
+ ret = 0;
+ else
+ ret = -ENODEV;
+
+ free(sra);
+ } else {
+ /*
+ * 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);
+ }
+
+ return !ret;
+}
+
/*
* Get array info from the kernel. Longer term we want to deprecate the
* ioctl and get it from sysfs.
--
2.13.6
++++++ 0091-maps-Use-keyvalue-for-null-terminator-to-indicate-un.patch ++++++
From 5e8e35fb7e17495032e144f319517dcae38d1b56 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 20 Apr 2017 00:19:44 -0400
Subject: [PATCH] maps: Use keyvalue for null terminator to indicate 'unset'
value
Git-commit: 5e8e35fb7e17495032e144f319517dcae38d1b56
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This simplifies the code calling map_name() so it no longer has to
manually check for UnSet and convert the value manually.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
maps.c | 17 +++++++++--------
sysfs.c | 2 --
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/maps.c b/maps.c
index a2d293b..11dd3d2 100644
--- a/maps.c
+++ b/maps.c
@@ -44,7 +44,7 @@ mapping_t r5layout[] = {
{ "ddf-N-restart", ALGORITHM_LEFT_ASYMMETRIC},
{ "ddf-N-continue", ALGORITHM_LEFT_SYMMETRIC},
- { NULL, 0}
+ { NULL, UnSet }
};
mapping_t r6layout[] = {
{ "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
@@ -70,7 +70,7 @@ mapping_t r6layout[] = {
{ "right-symmetric-6", ALGORITHM_RIGHT_SYMMETRIC_6},
{ "parity-first-6", ALGORITHM_PARITY_0_6},
- { NULL, 0}
+ { NULL, UnSet }
};
mapping_t pers[] = {
@@ -93,7 +93,7 @@ mapping_t pers[] = {
{ "10", 10},
{ "faulty", LEVEL_FAULTY},
{ "container", LEVEL_CONTAINER},
- { NULL, 0}
+ { NULL, UnSet }
};
mapping_t modes[] = {
@@ -106,7 +106,7 @@ mapping_t modes[] = {
{ "grow", GROW},
{ "incremental", INCREMENTAL},
{ "auto-detect", AUTODETECT},
- { NULL, 0 }
+ { NULL, UnSet }
};
mapping_t faultylayout[] = {
@@ -127,7 +127,7 @@ mapping_t faultylayout[] = {
{ "flush", ClearFaults},
{ "none", ClearErrors},
{ "default", ClearErrors},
- { NULL, 0}
+ { NULL, UnSet }
};
mapping_t consistency_policies[] = {
@@ -137,7 +137,7 @@ mapping_t consistency_policies[] = {
{ "bitmap", CONSISTENCY_POLICY_BITMAP},
{ "journal", CONSISTENCY_POLICY_JOURNAL},
{ "ppl", CONSISTENCY_POLICY_PPL},
- { NULL, 0}
+ { NULL, UnSet }
};
mapping_t sysfs_array_states[] = {
@@ -154,7 +154,7 @@ mapping_t sysfs_array_states[] = {
{ "read-auto", ARRAY_READ_AUTO },
{ "clean", ARRAY_CLEAN },
{ "write-pending", ARRAY_WRITE_PENDING },
- { NULL, 0 }
+ { NULL, ARRAY_UNKNOWN_STATE }
};
char *map_num(mapping_t *map, int num)
@@ -174,5 +174,6 @@ int map_name(mapping_t *map, char *name)
return map->num;
map++;
}
- return UnSet;
+
+ return map->num;
}
diff --git a/sysfs.c b/sysfs.c
index c6df9b0..712f8b3 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -250,8 +250,6 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
if (load_sys(fname, buf, sizeof(buf)))
goto abort;
sra->array_state = map_name(sysfs_array_states, buf);
- if (sra->array_state == UnSet)
- sra->array_state = ARRAY_UNKNOWN_STATE;
}
if (options & GET_CONSISTENCY_POLICY) {
--
2.13.6
++++++ 0092-util-Get-rid-of-unused-enough_fd.patch ++++++
From 44356754ec8d7c38720db6c9916fef8f24921831 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 20 Apr 2017 11:53:30 -0400
Subject: [PATCH] util: Get rid of unused enough_fd()
Git-commit: 44356754ec8d7c38720db6c9916fef8f24921831
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
enough_fd() is no longer used, so lets get rid of it.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.h | 1 -
util.c | 31 -------------------------------
2 files changed, 32 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index f6e97fd..1bbacfe 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1485,7 +1485,6 @@ extern char *fname_from_uuid(struct supertype *st,
extern unsigned long calc_csum(void *super, int bytes);
extern int enough(int level, int raid_disks, int layout, int clean,
char *avail);
-extern int enough_fd(int fd);
extern int ask(char *mesg);
extern unsigned long long get_component_size(int fd);
extern void remove_partitions(int fd);
diff --git a/util.c b/util.c
index 3adc675..21a63c9 100644
--- a/util.c
+++ b/util.c
@@ -542,37 +542,6 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail)
}
}
-int enough_fd(int fd)
-{
- struct mdu_array_info_s array;
- struct mdu_disk_info_s disk;
- int i, rv;
- char *avail;
-
- if (md_get_array_info(fd, &array) != 0 || array.raid_disks <= 0)
- return 0;
- avail = xcalloc(array.raid_disks, 1);
- for (i = 0; i < MAX_DISKS && array.nr_disks > 0; i++) {
- disk.number = i;
- if (md_get_disk_info(fd, &disk) != 0)
- continue;
- if (disk.major == 0 && disk.minor == 0)
- continue;
- array.nr_disks--;
-
- if (! (disk.state & (1<= array.raid_disks)
- continue;
- avail[disk.raid_disk] = 1;
- }
- /* This is used on an active array, so assume it is clean */
- rv = enough(array.level, array.raid_disks, array.layout,
- 1, avail);
- free(avail);
- return rv;
-}
-
const int uuid_zero[4] = { 0, 0, 0, 0 };
int same_uuid(int a[4], int b[4], int swapuuid)
--
2.13.6
++++++ 0093-mdadm-retire-mdassemble-in-make-everything.patch ++++++
From b63804583e25fbc00b96c7f37f97d568b5b1ba9c Mon Sep 17 00:00:00 2001
From: Coly Li
Date: Sun, 16 Apr 2017 15:01:29 +0800
Subject: [PATCH] mdadm: retire mdassemble in make everything
Git-commit: b63804583e25fbc00b96c7f37f97d568b5b1ba9c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
make everything reports no rule to make mdassemble, because mdassemble
is removed from mdadm. This patch removes mdassemble from "everything"
in Makefile, now there is no failure when compiling a static mdadm binary.
Signed-off-by: Coly Li
Signed-off-by: Jes Sorensen
---
Makefile | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
index a5d2a0a..5655812 100644
--- a/Makefile
+++ b/Makefile
@@ -169,12 +169,10 @@ check_rundir:
fi
everything: all mdadm.static swap_super test_stripe raid6check \
- mdassemble mdassemble.auto mdassemble.static mdassemble.man \
mdadm.Os mdadm.O2 man
everything-test: all mdadm.static swap_super test_stripe \
- mdassemble.auto mdassemble.static mdassemble.man \
mdadm.Os mdadm.O2 man
-# mdadm.uclibc and mdassemble.uclibc don't work on x86-64
+# mdadm.uclibc doesn't work on x86-64
# mdadm.tcc doesn't work..
mdadm : $(OBJS) | check_rundir
@@ -226,9 +224,6 @@ md.man : md.4
mdadm.conf.man : mdadm.conf.5
man -l mdadm.conf.5 > mdadm.conf.man
-mdassemble.man : mdassemble.8
- man -l mdassemble.8 > mdassemble.man
-
raid6check.man : raid6check.8
man -l raid6check.8 > raid6check.man
@@ -293,9 +288,7 @@ test: mdadm mdmon test_stripe swap_super raid6check
clean :
rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt .merge_file_* \
- mdadm.Os mdadm.O2 mdmon.O2 \
- mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
- mdassemble.klibc swap_super \
+ mdadm.Os mdadm.O2 mdmon.O2 swap_super \
init.cpio.gz mdadm.uclibc.static test_stripe raid6check raid6check.o mdmon \
mdadm.8
--
2.13.6
++++++ 0094-Query-Quiet-gcc-since-it-cannot-know-errno-0-in-this.patch ++++++
From 0dfff0f24355ad4b5c1776f7f19a404ffae25415 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 21 Apr 2017 12:04:05 -0400
Subject: [PATCH] Query: Quiet gcc since it cannot know errno != 0 in this case
Git-commit: 0dfff0f24355ad4b5c1776f7f19a404ffae25415
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Query.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Query.c b/Query.c
index 4dec9f5..2bd0e2a 100644
--- a/Query.c
+++ b/Query.c
@@ -68,6 +68,9 @@ int Query(char *dev)
if (md_get_array_info(fd, &array) < 0) {
ioctlerr = errno;
+ level = -1;
+ raid_disks = -1;
+ spare_disks = -1;
} else {
level = array.level;
raid_disks = array.raid_disks;
--
2.13.6
++++++ 0095-Makefile-Default-to-O2-optimization.patch ++++++
From 17d80e6eb64230593ee8d599b94005d303eb58ae Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 21 Apr 2017 12:06:35 -0400
Subject: [PATCH] Makefile: Default to -O2 optimization
Git-commit: 17d80e6eb64230593ee8d599b94005d303eb58ae
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile
index 5655812..6850696 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@
# define "CXFLAGS" to give extra flags to CC.
# e.g. make CXFLAGS=-O to optimise
+CXFLAGS ?=-O2
TCC = tcc
UCLIBC_GCC = $(shell for nm in i386-uclibc-linux-gcc i386-uclibc-gcc; do which $$nm > /dev/null && { echo $$nm ; exit; } ; done; echo false No uclibc found )
#DIET_GCC = diet gcc
--
2.13.6
++++++ 0096-maps-Simplify-implementation-of-map_name.patch ++++++
From 4a4379b054a72b3c4abd93dd6e1283d6aa992ee2 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 21 Apr 2017 12:11:21 -0400
Subject: [PATCH] maps: Simplify implementation of map_name()
Git-commit: 4a4379b054a72b3c4abd93dd6e1283d6aa992ee2
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Reported-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
maps.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/maps.c b/maps.c
index 81f29c4..bb28ba6 100644
--- a/maps.c
+++ b/maps.c
@@ -165,11 +165,8 @@ char *map_num(mapping_t *map, int num)
int map_name(mapping_t *map, char *name)
{
- while (map->name) {
- if (strcmp(map->name, name)==0)
- return map->num;
+ while (map->name && strcmp(map->name, name) != 0)
map++;
- }
return map->num;
}
--
2.13.6
++++++ 0097-Don-t-use-UnSet-with-consistency_policy.patch ++++++
From b75805662e7208799207a8e5f8a61f69a44888f0 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Mon, 24 Apr 2017 16:03:26 +0200
Subject: [PATCH] Don't use UnSet with consistency_policy
Git-commit: b75805662e7208799207a8e5f8a61f69a44888f0
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Use CONSISTENCY_POLICY_UNKNOWN instead. Simplify some checks because
since 5e8e35fb7e17 ("maps: Use keyvalue for null terminator to indicate
'unset' value") map_name() can return this default directly.
Suggested-by: Jes Sorensen
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Coly Li
---
maps.c | 2 +-
mdadm.c | 12 ++++++------
super-intel.c | 4 +---
sysfs.c | 10 ++++------
4 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/maps.c b/maps.c
index bb28ba6..02a0474 100644
--- a/maps.c
+++ b/maps.c
@@ -137,7 +137,7 @@ mapping_t consistency_policies[] = {
{ "bitmap", CONSISTENCY_POLICY_BITMAP},
{ "journal", CONSISTENCY_POLICY_JOURNAL},
{ "ppl", CONSISTENCY_POLICY_PPL},
- { NULL, UnSet }
+ { NULL, CONSISTENCY_POLICY_UNKNOWN }
};
mapping_t sysfs_array_states[] = {
diff --git a/mdadm.c b/mdadm.c
index 41dae1d..b689e32 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
.level = UnSet,
.layout = UnSet,
.bitmap_chunk = UnSet,
- .consistency_policy = UnSet,
+ .consistency_policy = CONSISTENCY_POLICY_UNKNOWN,
};
char sys_hostname[256];
@@ -1228,8 +1228,7 @@ int main(int argc, char *argv[])
case O(GROW, 'k'):
s.consistency_policy = map_name(consistency_policies,
optarg);
- if (s.consistency_policy == UnSet ||
- s.consistency_policy < CONSISTENCY_POLICY_RESYNC) {
+ if (s.consistency_policy < CONSISTENCY_POLICY_RESYNC) {
pr_err("Invalid consistency policy: %s\n",
optarg);
exit(2);
@@ -1267,7 +1266,7 @@ int main(int argc, char *argv[])
pr_err("--write-journal is only supported for RAID level 4/5/6.\n");
exit(2);
}
- if (s.consistency_policy != UnSet &&
+ 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));
@@ -1275,7 +1274,8 @@ int main(int argc, char *argv[])
}
}
- if (mode == CREATE && s.consistency_policy != UnSet) {
+ if (mode == CREATE &&
+ 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));
@@ -1687,7 +1687,7 @@ int main(int argc, char *argv[])
rv = Grow_reshape(devlist->devname, mdfd,
devlist->next,
data_offset, &c, &s);
- } else if (s.consistency_policy != UnSet) {
+ } else if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) {
rv = Grow_consistency_policy(devlist->devname, mdfd, &c, &s);
} else if (array_size == 0)
pr_err("no changes to --grow\n");
diff --git a/super-intel.c b/super-intel.c
index 0aed57c..fbff215 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5369,9 +5369,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
}
mpb->num_raid_devs++;
- if (s->consistency_policy == UnSet ||
- s->consistency_policy == CONSISTENCY_POLICY_RESYNC ||
- s->consistency_policy == CONSISTENCY_POLICY_NONE) {
+ if (s->consistency_policy <= CONSISTENCY_POLICY_RESYNC) {
dev->rwh_policy = RWH_OFF;
} else if (s->consistency_policy == CONSISTENCY_POLICY_PPL) {
dev->rwh_policy = RWH_DISTRIBUTED;
diff --git a/sysfs.c b/sysfs.c
index 712f8b3..aa30de5 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -254,13 +254,11 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
if (options & GET_CONSISTENCY_POLICY) {
strcpy(base, "consistency_policy");
- if (load_sys(fname, buf, sizeof(buf))) {
+ if (load_sys(fname, buf, sizeof(buf)))
sra->consistency_policy = CONSISTENCY_POLICY_UNKNOWN;
- } else {
- sra->consistency_policy = map_name(consistency_policies, buf);
- if (sra->consistency_policy == UnSet)
- sra->consistency_policy = CONSISTENCY_POLICY_UNKNOWN;
- }
+ else
+ sra->consistency_policy = map_name(consistency_policies,
+ buf);
}
if (! (options & GET_DEVS))
--
2.13.6
++++++ 0098-Detail-determine-array-state-from-sysfs.patch ++++++
From a4dcdb23ea639d14e92d1c86336de7ad505b2f7d Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 25 Apr 2017 11:40:27 -0400
Subject: [PATCH] Detail: determine array state from sysfs
Git-commit: a4dcdb23ea639d14e92d1c86336de7ad505b2f7d
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This is easily obtained from sysfs as part of the existing call to
sysfs_read() and it simplifies the code a little too.
Another small step in the process of getting rid of the GET_ARRAY_STATE
ioctl.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/Detail.c b/Detail.c
index 91c5a98..eb69276 100644
--- a/Detail.c
+++ b/Detail.c
@@ -86,7 +86,7 @@ int Detail(char *dev, struct context *c)
dev, strerror(errno));
return rv;
}
- sra = sysfs_read(fd, NULL, GET_VERSION|GET_DEVS);
+ sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS | GET_ARRAY_STATE);
if (!sra) {
pr_err("%s does not appear to be an md device\n", dev);
close(fd);
@@ -94,10 +94,10 @@ int Detail(char *dev, struct context *c)
}
external = (sra != NULL && sra->array.major_version == -1 &&
sra->array.minor_version == -2);
+ inactive = (sra->array_state == ARRAY_ACTIVE ||
+ sra->array_state == ARRAY_CLEAR);
st = super_by_fd(fd, &subarray);
- if (md_get_array_info(fd, &array) == 0) {
- inactive = 0;
- } else if (errno == ENODEV && sra) {
+ if (md_get_array_info(fd, &array) && errno == ENODEV) {
if (sra->array.major_version == -1 &&
sra->array.minor_version == -1 &&
sra->devs == NULL) {
@@ -107,7 +107,6 @@ int Detail(char *dev, struct context *c)
return rv;
}
array = sra->array;
- inactive = 1;
} else {
pr_err("cannot get array detail for %s: %s\n",
dev, strerror(errno));
--
2.13.6
++++++ 0099-Detail-Respect-code-lines-are-80-character-wide.patch ++++++
From 5737086ed7a39e4d940ed1459d1afad359c3182c Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 25 Apr 2017 12:21:39 -0400
Subject: [PATCH] Detail: Respect code lines are 80 character wide
Git-commit: 5737086ed7a39e4d940ed1459d1afad359c3182c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
In addition apply spaces and don'f do 'if () action()' on the same line.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 239 ++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 138 insertions(+), 101 deletions(-)
diff --git a/Detail.c b/Detail.c
index eb69276..ceb21b1 100644
--- a/Detail.c
+++ b/Detail.c
@@ -157,8 +157,7 @@ int Detail(char *dev, struct context *c)
if (md_get_disk_info(fd, &disk) < 0)
continue;
if (d >= array.raid_disks &&
- disk.major == 0 &&
- disk.minor == 0)
+ disk.major == 0 && disk.minor == 0)
continue;
}
@@ -236,7 +235,8 @@ int Detail(char *dev, struct context *c)
printf("MD_METADATA=%s\n", sra->text_version);
else
printf("MD_METADATA=%d.%d\n",
- array.major_version, array.minor_version);
+ array.major_version,
+ array.minor_version);
}
if (st && st->sb && info) {
@@ -244,12 +244,12 @@ int Detail(char *dev, struct context *c)
struct map_ent *mp, *map = NULL;
fname_from_uuid(st, info, nbuf, ':');
- printf("MD_UUID=%s\n", nbuf+5);
+ printf("MD_UUID=%s\n", nbuf + 5);
mp = map_by_uuid(&map, info->uuid);
if (mp && mp->path &&
strncmp(mp->path, "/dev/md/", 8) == 0) {
printf("MD_DEVNAME=");
- print_escape(mp->path+8);
+ print_escape(mp->path + 8);
putchar('\n');
}
@@ -273,11 +273,12 @@ int Detail(char *dev, struct context *c)
if (sra) {
struct mdinfo *mdi;
for (mdi = sra->devs; mdi; mdi = mdi->next) {
- char *path =
- map_dev(mdi->disk.major,
- mdi->disk.minor, 0);
+ char *path;
char *sysdev = xstrdup(mdi->sys_name + 1);
char *cp;
+
+ path = map_dev(mdi->disk.major,
+ mdi->disk.minor, 0);
for (cp = sysdev; *cp; cp++)
if (!isalnum(*cp))
*cp = '_';
@@ -299,19 +300,19 @@ int Detail(char *dev, struct context *c)
disks = xmalloc(max_disks * 2 * sizeof(mdu_disk_info_t));
for (d = 0; d < max_disks * 2; d++) {
- disks[d].state = (1<devs; mdi; mdi = mdi->next) {
disks[next++] = mdi->disk;
- disks[next-1].number = -1;
+ disks[next - 1].number = -1;
}
} else for (d = 0; d < max_disks; d++) {
mdu_disk_info_t disk;
@@ -324,21 +325,23 @@ int Detail(char *dev, struct context *c)
}
if (disk.major == 0 && disk.minor == 0)
continue;
- if (disk.raid_disk >= 0 && disk.raid_disk < array.raid_disks
- && disks[disk.raid_disk*2].state == (1<= 0 && disk.raid_disk < array.raid_disks
- && disks[disk.raid_disk*2+1].state == (1<= 0 && disk.raid_disk < array.raid_disks &&
+ disks[disk.raid_disk * 2].state == (1 << MD_DISK_REMOVED) &&
+ ((disk.state & (1 << MD_DISK_JOURNAL)) == 0))
+ disks[disk.raid_disk * 2] = disk;
+ else if (disk.raid_disk >= 0 &&
+ disk.raid_disk < array.raid_disks &&
+ disks[disk.raid_disk * 2 + 1].state ==
+ (1 << MD_DISK_REMOVED) &&
+ !(disk.state & (1 << MD_DISK_JOURNAL)))
+ disks[disk.raid_disk * 2 + 1] = disk;
+ else if (next < max_disks * 2)
disks[next++] = disk;
}
avail = xcalloc(array.raid_disks, 1);
- for (d= 0; d < array.raid_disks; d++) {
+ for (d = 0; d < array.raid_disks; d++) {
if ((disks[d*2].state & (1<verbose > 0) {
if (array.raid_disks)
printf(" level=%s num-devices=%d",
- str?str:"-unknown-",
- array.raid_disks );
+ str ? str : "-unknown-",
+ array.raid_disks);
else if (!inactive)
printf(" level=container num-devices=%d",
array.nr_disks);
@@ -369,8 +372,8 @@ int Detail(char *dev, struct context *c)
if (sra && sra->array.major_version < 0)
printf(" metadata=%s", sra->text_version);
else
- printf(" metadata=%d.%d",
- array.major_version, array.minor_version);
+ printf(" metadata=%d.%d", array.major_version,
+ array.minor_version);
}
/* Only try GET_BITMAP_FILE for 0.90.01 and later */
@@ -385,7 +388,7 @@ int Detail(char *dev, struct context *c)
char *devnm;
devnm = stat2devnm(&stb);
- for (e=ms; e; e=e->next)
+ for (e = ms; e; e = e->next)
if (strcmp(e->devnm, devnm) == 0)
break;
if (!get_dev_size(fd, NULL, &larray_size))
@@ -394,14 +397,16 @@ int Detail(char *dev, struct context *c)
printf("%s:\n", dev);
if (container)
- printf(" Container : %s, member %s\n", container,
- member);
+ printf(" Container : %s, member %s\n",
+ container, member);
else {
- if (sra && sra->array.major_version < 0)
- printf(" Version : %s\n", sra->text_version);
- else
- printf(" Version : %d.%d\n",
- array.major_version, array.minor_version);
+ if (sra && sra->array.major_version < 0)
+ printf(" Version : %s\n",
+ sra->text_version);
+ else
+ printf(" Version : %d.%d\n",
+ array.major_version,
+ array.minor_version);
}
atime = array.ctime;
@@ -412,14 +417,17 @@ int Detail(char *dev, struct context *c)
if (str)
printf(" Raid Level : %s\n", str);
if (larray_size)
- printf(" Array Size : %llu%s\n", (larray_size>>10),
+ printf(" Array Size : %llu%s\n",
+ (larray_size >> 10),
human_size(larray_size));
if (array.level >= 1) {
if (sra)
array.major_version = sra->array.major_version;
if (array.major_version != 0 &&
(larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {
- unsigned long long dsize = get_component_size(fd);
+ unsigned long long dsize;
+
+ dsize = get_component_size(fd);
if (dsize > 0)
printf(" Used Dev Size : %llu%s\n",
dsize/2,
@@ -429,7 +437,8 @@ int Detail(char *dev, struct context *c)
} else
printf(" Used Dev Size : %lu%s\n",
(unsigned long)array.size,
- human_size((unsigned long long)array.size<<10));
+ human_size((unsigned long long)
+ array.size << 10));
}
if (array.raid_disks)
printf(" Raid Devices : %d\n", array.raid_disks);
@@ -440,7 +449,7 @@ int Detail(char *dev, struct context *c)
printf(" Preferred Minor : %d\n", array.md_minor);
if (sra == NULL || sra->array.major_version >= 0)
printf(" Persistence : Superblock is %spersistent\n",
- array.not_persistent?"not ":"");
+ array.not_persistent ? "not " : "");
printf("\n");
/* Only try GET_BITMAP_FILE for 0.90.01 and later */
if (ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 && bmf.pathname[0]) {
@@ -465,19 +474,25 @@ int Detail(char *dev, struct context *c)
st = ", degraded";
printf(" State : %s%s%s%s%s%s \n",
- (array.state&(1<percent < 0 && e->percent != RESYNC_PENDING &&
- e->percent != RESYNC_DELAYED)) ? "" : sync_action[e->resync],
+ (array.state & (1 << MD_SB_CLEAN)) ?
+ "clean" : "active", st,
+ (!e || (e->percent < 0 &&
+ e->percent != RESYNC_PENDING &&
+ e->percent != RESYNC_DELAYED)) ?
+ "" : sync_action[e->resync],
larray_size ? "": ", Not Started",
- (e && e->percent == RESYNC_DELAYED) ? " (DELAYED)": "",
- (e && e->percent == RESYNC_PENDING) ? " (PENDING)": "");
+ (e && e->percent == RESYNC_DELAYED) ?
+ " (DELAYED)": "",
+ (e && e->percent == RESYNC_PENDING) ?
+ " (PENDING)": "");
} else if (inactive) {
printf(" State : inactive\n");
}
if (array.raid_disks)
printf(" Active Devices : %d\n", array.active_disks);
if (array.working_disks > 0)
- printf(" Working Devices : %d\n", array.working_disks);
+ printf(" Working Devices : %d\n",
+ array.working_disks);
if (array.raid_disks) {
printf(" Failed Devices : %d\n", array.failed_disks);
printf(" Spare Devices : %d\n", array.spare_disks);
@@ -485,11 +500,13 @@ int Detail(char *dev, struct context *c)
printf("\n");
if (array.level == 5) {
str = map_num(r5layout, array.layout);
- printf(" Layout : %s\n", str?str:"-unknown-");
+ printf(" Layout : %s\n",
+ str ? str : "-unknown-");
}
if (array.level == 6) {
str = map_num(r6layout, array.layout);
- printf(" Layout : %s\n", str?str:"-unknown-");
+ printf(" Layout : %s\n",
+ str ? str : "-unknown-");
}
if (array.level == 10) {
printf(" Layout :");
@@ -510,12 +527,14 @@ int Detail(char *dev, struct context *c)
printf(" Rounding : %dK\n\n",
array.chunk_size/1024);
break;
- default: break;
+ default:
+ break;
}
if (array.raid_disks) {
- struct mdinfo *mdi = sysfs_read(fd, NULL,
- GET_CONSISTENCY_POLICY);
+ struct mdinfo *mdi;
+
+ mdi = sysfs_read(fd, NULL, GET_CONSISTENCY_POLICY);
if (mdi) {
char *policy = map_num(consistency_policies,
mdi->consistency_policy);
@@ -528,8 +547,7 @@ int Detail(char *dev, struct context *c)
if (e && e->percent >= 0) {
static char *sync_action[] = {
- "Rebuild", "Resync",
- "Reshape", "Check"};
+ "Rebuild", "Resync", "Reshape", "Check"};
printf(" %7s Status : %d%% complete\n",
sync_action[e->resync], e->percent);
}
@@ -539,8 +557,9 @@ int Detail(char *dev, struct context *c)
#if 0
This is pretty boring
printf(" Reshape pos'n : %llu%s\n",
- (unsigned long long) info->reshape_progress<<9,
- human_size((unsigned long long)info->reshape_progress<<9));
+ (unsigned long long) info->reshape_progress << 9,
+ human_size((unsigned long long)
+ info->reshape_progress << 9));
#endif
if (info->delta_disks != 0)
printf(" Delta Devices : %d, (%d->%d)\n",
@@ -549,25 +568,29 @@ This is pretty boring
array.raid_disks);
if (info->new_level != array.level) {
str = map_num(pers, info->new_level);
- printf(" New Level : %s\n", str?str:"-unknown-");
+ printf(" New Level : %s\n",
+ str ? str : "-unknown-");
}
if (info->new_level != array.level ||
info->new_layout != array.layout) {
if (info->new_level == 5) {
- str = map_num(r5layout, info->new_layout);
+ str = map_num(r5layout,
+ info->new_layout);
printf(" New Layout : %s\n",
- str?str:"-unknown-");
+ str ? str : "-unknown-");
}
if (info->new_level == 6) {
- str = map_num(r6layout, info->new_layout);
+ str = map_num(r6layout,
+ info->new_layout);
printf(" New Layout : %s\n",
- str?str:"-unknown-");
+ str ? str : "-unknown-");
}
if (info->new_level == 10) {
printf(" New Layout : near=%d, %s=%d\n",
- info->new_layout&255,
- (info->new_layout&0x10000)?"offset":"far",
- (info->new_layout>>8)&255);
+ info->new_layout & 255,
+ (info->new_layout & 0x10000) ?
+ "offset" : "far",
+ (info->new_layout >> 8) & 255);
}
}
if (info->new_chunk != array.chunk_size)
@@ -579,8 +602,10 @@ This is pretty boring
if (st && st->sb)
st->ss->detail_super(st, c->homehost);
- if (array.raid_disks == 0 && sra && sra->array.major_version == -1
- && sra->array.minor_version == -2 && sra->text_version[0] != '/') {
+ if (array.raid_disks == 0 && sra &&
+ sra->array.major_version == -1 &&
+ sra->array.minor_version == -2 &&
+ sra->text_version[0] != '/') {
/* This looks like a container. Find any active arrays
* That claim to be a member.
*/
@@ -596,19 +621,21 @@ This is pretty boring
dev_t devid;
if (de->d_name[0] == '.')
continue;
- sprintf(path, "/sys/block/%s/md/metadata_version",
+ sprintf(path,
+ "/sys/block/%s/md/metadata_version",
de->d_name);
if (load_sys(path, vbuf, sizeof(vbuf)) < 0)
continue;
- if (strncmp(vbuf, "external:", 9) != 0 ||
- !is_subarray(vbuf+9) ||
- strncmp(vbuf+10, sra->sys_name, nlen) != 0 ||
- vbuf[10+nlen] != '/')
+ if (strncmp(vbuf, "external:", 9) ||
+ !is_subarray(vbuf + 9) ||
+ strncmp(vbuf + 10, sra->sys_name, nlen) ||
+ vbuf[10 + nlen] != '/')
continue;
devid = devnm2devid(de->d_name);
- printf(" %s", map_dev_preferred(
- major(devid),
- minor(devid), 1, c->prefer));
+ printf(" %s",
+ map_dev_preferred(major(devid),
+ minor(devid), 1,
+ c->prefer));
}
if (dir)
closedir(dir);
@@ -622,24 +649,23 @@ This is pretty boring
}
free(info);
- for (d= 0; d < max_disks * 2; d++) {
+ for (d = 0; d < max_disks * 2; d++) {
char *dv;
mdu_disk_info_t disk = disks[d];
- if (d >= array.raid_disks*2 &&
- disk.major == 0 &&
- disk.minor == 0)
+ if (d >= array.raid_disks * 2 &&
+ disk.major == 0 && disk.minor == 0)
continue;
- if ((d & 1) &&
- disk.major == 0 &&
- disk.minor == 0)
+ if ((d & 1) && disk.major == 0 && disk.minor == 0)
continue;
if (!c->brief) {
- if (d == array.raid_disks*2) printf("\n");
+ if (d == array.raid_disks*2)
+ printf("\n");
if (disk.number < 0 && disk.raid_disk < 0)
printf(" - %5d %5d - ",
disk.major, disk.minor);
- else if (disk.raid_disk < 0 || disk.state & (1<brief && array.raid_disks) {
-
- if (disk.state & (1<= 0)
failed++;
}
- if (disk.state & (1<> 8) & 0xff;
int copies = nc*fc;
- if (fc == 1 && array.raid_disks % copies == 0 && copies <= 26) {
- /* We can divide the devices into 'sets' */
- int set = disk.raid_disk % copies;
+ if (fc == 1 &&
+ array.raid_disks % copies == 0 &&
+ copies <= 26) {
+ /* We can divide the devices
+ into 'sets' */
+ int set;
+ set = disk.raid_disk % copies;
printf(" set-%c", set + 'A');
}
}
}
- if (disk.state & (1<prefer);
+ if (disk.state == 0)
+ spares++;
+ dv = map_dev_preferred(disk.major, disk.minor, 0, c->prefer);
if (dv != NULL) {
if (c->brief)
n_devices = add_device(dv, &devices,
- &max_devices,
- n_devices);
+ &max_devices, n_devices);
else
printf(" %s", dv);
}
- if (!c->brief) printf("\n");
+ if (!c->brief)
+ printf("\n");
}
- if (spares && c->brief && array.raid_disks) printf(" spares=%d", spares);
+ if (spares && c->brief && array.raid_disks)
+ printf(" spares=%d", spares);
if (c->brief && st && st->sb)
st->ss->brief_detail_super(st);
if (st)
@@ -712,8 +750,7 @@ This is pretty boring
if (c->brief)
printf("\n");
if (c->test &&
- !enough(array.level, array.raid_disks, array.layout,
- 1, avail))
+ !enough(array.level, array.raid_disks, array.layout, 1, avail))
rv = 2;
free(disks);
--
2.13.6
++++++ 0100-Detail-Reinstate-support-for-not-having-sysfs.patch ++++++
From 0885b942b3575c7f2a8290087751d83902587371 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 25 Apr 2017 14:34:31 -0400
Subject: [PATCH] Detail: Reinstate support for not having sysfs
Git-commit: 0885b942b3575c7f2a8290087751d83902587371
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
While sysfs support will hopefully go away eventually, lets not break
it unnecessarily for now.
Fixes: 901d5ee ("Detail: Stop bothering about md drivers older than 0.90.00")
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Detail.c b/Detail.c
index ceb21b1..ef2370c 100644
--- a/Detail.c
+++ b/Detail.c
@@ -88,9 +88,11 @@ int Detail(char *dev, struct context *c)
}
sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS | GET_ARRAY_STATE);
if (!sra) {
- pr_err("%s does not appear to be an md device\n", dev);
- close(fd);
- return rv;
+ if (md_get_array_info(fd, &array)) {
+ pr_err("%s does not appear to be an md device\n", dev);
+ close(fd);
+ return rv;
+ }
}
external = (sra != NULL && sra->array.major_version == -1 &&
sra->array.minor_version == -2);
--
2.13.6
++++++ 0101-Incremental-Use-md_array_active-where-applicable.patch ++++++
From ff4ad24b1c261ab4d286cbe54157d7c588191692 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 25 Apr 2017 14:57:46 -0400
Subject: [PATCH] Incremental: Use md_array_active() where applicable
Git-commit: ff4ad24b1c261ab4d286cbe54157d7c588191692
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
md_get_array_info() == 0 implies an array is active, however this is more
correct.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 28f1f77..a351151 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -403,7 +403,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
&& ! policy_action_allows(policy, st->ss->name,
act_re_add)
&& c->runstop < 1) {
- if (md_get_array_info(mdfd, &ainf) == 0) {
+ if (md_array_active(mdfd)) {
pr_err("not adding %s to active array (without --run) %s\n",
devname, chosen_name);
rv = 2;
@@ -667,9 +667,8 @@ static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
* and events less than the passed events, and remove the device.
*/
struct mdinfo *d;
- mdu_array_info_t ra;
- if (md_get_array_info(mdfd, &ra) == 0)
+ if (md_array_active(mdfd))
return; /* not safe to remove from active arrays
* without thinking more */
--
2.13.6
++++++ 0102-Incremental-Cleanup-some-if-statement-spaghetti.patch ++++++
From f8c432bfc9929dbbcb659b2d11552dc9fc76ad24 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 25 Apr 2017 15:01:43 -0400
Subject: [PATCH] Incremental: Cleanup some if() statement spaghetti
Git-commit: f8c432bfc9929dbbcb659b2d11552dc9fc76ad24
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 50 +++++++++++++++++++++-----------------------------
1 file changed, 21 insertions(+), 29 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index a351151..66c5b03 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -225,8 +225,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
if (!match && rv == 2)
goto out;
- if (match && match->devname
- && strcasecmp(match->devname, "<ignore>") == 0) {
+ if (match && match->devname &&
+ strcasecmp(match->devname, "<ignore>") == 0) {
if (c->verbose >= 0)
pr_err("array containing %s is explicitly ignored by mdadm.conf\n",
devname);
@@ -267,8 +267,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 && info.array.level == LEVEL_CONTAINER) {
name_to_use = info.text_version;
trustworthy = METADATA;
}
@@ -398,11 +397,10 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
* flag has a different meaning. The test has to happen
* at the device level there
*/
- if (!st->ss->external
- && (info.disk.state & (1<ss->name,
- act_re_add)
- && c->runstop < 1) {
+ if (!st->ss->external &&
+ (info.disk.state & (1 << MD_DISK_SYNC)) != 0 &&
+ !policy_action_allows(policy, st->ss->name, act_re_add) &&
+ c->runstop < 1) {
if (md_array_active(mdfd)) {
pr_err("not adding %s to active array (without --run) %s\n",
devname, chosen_name);
@@ -537,8 +535,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
info.array.state |= 1;
if (enough(info.array.level, info.array.raid_disks,
- info.array.layout, info.array.state & 1,
- avail) == 0) {
+ info.array.layout, info.array.state & 1, avail) == 0) {
if (c->export) {
printf("MD_STARTED=no\n");
} else if (c->verbose >= 0)
@@ -599,8 +596,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
if (d->disk.state & (1<= info.array.working_disks)
- && trustworthy != FOREIGN)
+ if ((sra == NULL || active_disks >= info.array.working_disks) &&
+ trustworthy != FOREIGN)
rv = ioctl(mdfd, RUN_ARRAY, NULL);
else
rv = sysfs_set_str(sra, NULL,
@@ -624,7 +621,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
* those devices we should re-add them now.
*/
for (dsk = sra->devs; dsk ; dsk = dsk->next) {
- if (disk_action_allows(dsk, st->ss->name, act_re_add) &&
+ if (disk_action_allows(dsk, st->ss->name,
+ act_re_add) &&
add_disk(mdfd, st, sra, dsk) == 0)
pr_err("%s re-added to %s\n",
dsk->sys_name, chosen_name);
@@ -688,8 +686,7 @@ static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
st->ss->free_super(st);
close(dfd);
- if (info.disk.number != number ||
- info.events >= events)
+ if (info.disk.number != number || info.events >= events)
continue;
if (d->disk.raid_disk > -1)
@@ -970,11 +967,9 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
}
if ((sra->component_size > 0 &&
st2->ss->avail_size(st2, devsize,
- sra->devs
- ? sra->devs->data_offset
- : INVALID_SECTORS)
- < sra->component_size)
- ||
+ sra->devs ? sra->devs->data_offset :
+ INVALID_SECTORS) <
+ sra->component_size) ||
(sra->component_size == 0 && devsize < component_size)) {
if (verbose > 1)
pr_err("not adding %s to %s as it is too small\n",
@@ -1107,8 +1102,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
char *devname = NULL;
unsigned long long devsectors;
- if (de->d_ino == 0 ||
- de->d_name[0] == '.' ||
+ if (de->d_ino == 0 || de->d_name[0] == '.' ||
(de->d_type != DT_LNK && de->d_type != DT_UNKNOWN))
goto next;
@@ -1146,8 +1140,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
st2 = dup_super(st);
else
st2 = guess_super_type(fd, guess_partitions);
- if (st2 == NULL ||
- st2->ss->load_super(st2, fd, NULL) < 0)
+ if (st2 == NULL || st2->ss->load_super(st2, fd, NULL) < 0)
goto next;
st2->ignore_hw_compat = 0;
@@ -1175,8 +1168,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
* metadata which makes better use of the device can
* be found.
*/
- if (chosen == NULL ||
- chosen_size < info.component_size) {
+ if (chosen == NULL || chosen_size < info.component_size) {
chosen_size = info.component_size;
free(chosen);
chosen = devname;
@@ -1399,8 +1391,8 @@ restart:
}
/* Ok, we can try this one. Maybe it needs a bitmap */
for (mddev = devs ; mddev ; mddev = mddev->next)
- if (mddev->devname && me->path
- && devname_matches(mddev->devname, me->path))
+ if (mddev->devname && me->path &&
+ devname_matches(mddev->devname, me->path))
break;
if (mddev && mddev->bitmap_file) {
/*
--
2.13.6
++++++ 0103-Create-tell-udev-md-device-is-not-ready-when-first-c.patch ++++++
From cd6cbb08c458cee07acb1d854e04532b29ec87bf Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 28 Apr 2017 15:05:50 +1000
Subject: [PATCH] Create: tell udev md device is not ready when first created.
Git-commit: cd6cbb08c458cee07acb1d854e04532b29ec87bf
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
When an array is created the content is not initialized,
so it could have remnants of an old filesystem or md array
etc on it.
udev will see this and might try to activate it, which is almost
certainly not what is wanted.
So create a mechanism for mdadm to communicate with udev to tell
it that the device isn't ready. This mechanism is the existance
of a file /run/mdadm/created-mdXXX where mdXXX is the md device name.
When creating an array, mdadm will create the file.
A new udev rule file, 01-md-raid-creating.rules, will detect the
precense of thst file and set ENV{SYSTEMD_READY}="0".
This is fairly uniformly used to suppress actions based on the
contents of the device.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 2 +-
Build.c | 2 +-
Create.c | 9 +++++++-
Incremental.c | 4 ++--
Makefile | 4 ++--
lib.c | 29 +++++++++++++++++++++++++
mdadm.h | 4 +++-
mdopen.c | 52 ++++++++++++++++++++++++++++-----------------
udev-md-raid-creating.rules | 7 ++++++
9 files changed, 86 insertions(+), 27 deletions(-)
create mode 100644 udev-md-raid-creating.rules
diff --git a/Assemble.c b/Assemble.c
index d6beb23..a9442c8 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1478,7 +1478,7 @@ try_again:
name = strchr(name, ':')+1;
mdfd = create_mddev(mddev, name, ident->autof, trustworthy,
- chosen_name);
+ chosen_name, 0);
}
if (mdfd < 0) {
st->ss->free_super(st);
diff --git a/Build.c b/Build.c
index 11ba12f..665d906 100644
--- a/Build.c
+++ b/Build.c
@@ -109,7 +109,7 @@ int Build(char *mddev, struct mddev_dev *devlist,
/* We need to create the device. It can have no name. */
map_lock(&map);
mdfd = create_mddev(mddev, NULL, c->autof, LOCAL,
- chosen_name);
+ chosen_name, 0);
if (mdfd < 0) {
map_unlock(&map);
return 1;
diff --git a/Create.c b/Create.c
index 6ca0924..df1bc20 100644
--- a/Create.c
+++ b/Create.c
@@ -605,7 +605,7 @@ int Create(struct supertype *st, char *mddev,
/* We need to create the device */
map_lock(&map);
- mdfd = create_mddev(mddev, name, c->autof, LOCAL, chosen_name);
+ mdfd = create_mddev(mddev, name, c->autof, LOCAL, chosen_name, 1);
if (mdfd < 0) {
map_unlock(&map);
return 1;
@@ -620,6 +620,7 @@ int Create(struct supertype *st, char *mddev,
chosen_name);
close(mdfd);
map_unlock(&map);
+ udev_unblock();
return 1;
}
mddev = chosen_name;
@@ -1053,9 +1054,15 @@ int Create(struct supertype *st, char *mddev,
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();
return 0;
abort:
+ udev_unblock();
map_lock(&map);
abort_locked:
map_remove(&map, fd2devnm(mdfd));
diff --git a/Incremental.c b/Incremental.c
index 66c5b03..4789e36 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -320,7 +320,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
/* Couldn't find an existing array, maybe make a new one */
mdfd = create_mddev(match ? match->devname : NULL,
- name_to_use, c->autof, trustworthy, chosen_name);
+ name_to_use, c->autof, trustworthy, chosen_name, 0);
if (mdfd < 0)
goto out_unlock;
@@ -1596,7 +1596,7 @@ static int Incremental_container(struct supertype *st, char *devname,
ra->name,
c->autof,
trustworthy,
- chosen_name);
+ chosen_name, 0);
}
if (only && (!mp || strcmp(mp->devnm, only) != 0))
continue;
diff --git a/Makefile b/Makefile
index 6850696..021d3ad 100644
--- a/Makefile
+++ b/Makefile
@@ -256,8 +256,8 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
$(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
$(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
-install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules
- @for file in 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \
+install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid-creating.rules
+ @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \
do sed -e 's,BINDIR,$(BINDIR),g' udev-$${file#??-} > .install.tmp.1 && \
$(ECHO) $(INSTALL) -D -m 644 udev-$${file#??-} $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \
$(INSTALL) -D -m 644 .install.tmp.1 $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \
diff --git a/lib.c b/lib.c
index b640634..7e44b1f 100644
--- a/lib.c
+++ b/lib.c
@@ -163,6 +163,35 @@ char *fd2devnm(int fd)
return NULL;
}
+/* When we create a new array, we don't want the content to
+ * be immediately examined by udev - it is probably meaningless.
+ * So create /run/mdadm/creating-FOO and expect that a udev
+ * rule will noticed this and act accordingly.
+ */
+static char block_path[] = "/run/mdadm/creating-%s";
+static char *unblock_path = NULL;
+void udev_block(char *devnm)
+{
+ int fd;
+ char *path = NULL;
+
+ xasprintf(&path, block_path, devnm);
+ fd = open(path, O_CREAT|O_RDWR, 0600);
+ if (fd >= 0) {
+ close(fd);
+ unblock_path = path;
+ } else
+ free(path);
+}
+
+void udev_unblock(void)
+{
+ if (unblock_path)
+ unlink(unblock_path);
+ free(unblock_path);
+ unblock_path = NULL;
+}
+
/*
* convert a major/minor pair for a block device into a name in /dev, if possible.
* On the first call, walk /dev collecting name.
diff --git a/mdadm.h b/mdadm.h
index 1bbacfe..6a382a7 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1533,7 +1533,7 @@ extern char *get_md_name(char *devnm);
extern char DefaultConfFile[];
extern int create_mddev(char *dev, char *name, int autof, int trustworthy,
- char *chosen);
+ char *chosen, int block_udev);
/* values for 'trustworthy' */
#define LOCAL 1
#define LOCAL_ANY 10
@@ -1567,6 +1567,8 @@ extern char *stat2kname(struct stat *st);
extern char *fd2kname(int fd);
extern char *stat2devnm(struct stat *st);
extern char *fd2devnm(int fd);
+extern void udev_block(char *devnm);
+extern void udev_unblock(void);
extern int in_initrd(void);
diff --git a/mdopen.c b/mdopen.c
index 82b97fc..099efa0 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -135,7 +135,7 @@ void make_parts(char *dev, int cnt)
*/
int create_mddev(char *dev, char *name, int autof, int trustworthy,
- char *chosen)
+ char *chosen, int block_udev)
{
int mdfd;
struct stat stb;
@@ -147,6 +147,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
char devname[37];
char devnm[32];
char cbuf[400];
+
+ if (!use_udev())
+ block_udev = 0;
+
if (chosen == NULL)
chosen = cbuf;
@@ -305,43 +309,53 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
int fd;
int n = -1;
sprintf(devnm, "md_%s", cname);
+ if (block_udev)
+ udev_block(devnm);
fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
if (fd >= 0) {
n = write(fd, devnm, strlen(devnm));
close(fd);
}
- if (n < 0)
+ if (n < 0) {
devnm[0] = 0;
+ udev_unblock();
+ }
}
if (num >= 0) {
int fd;
int n = -1;
sprintf(devnm, "md%d", num);
+ if (block_udev)
+ udev_block(devnm);
fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
if (fd >= 0) {
n = write(fd, devnm, strlen(devnm));
close(fd);
}
- if (n < 0)
+ if (n < 0) {
devnm[0] = 0;
- }
- if (devnm[0])
- ;
- else if (num < 0) {
- /* need to choose a free number. */
- char *_devnm = find_free_devnm(use_mdp);
- if (_devnm == NULL) {
- pr_err("No avail md devices - aborting\n");
- return -1;
+ udev_unblock();
}
- strcpy(devnm, _devnm);
- } else {
- sprintf(devnm, "%s%d", use_mdp?"md_d":"md", num);
- if (mddev_busy(devnm)) {
- pr_err("%s is already in use.\n",
- dev);
- return -1;
+ }
+ if (devnm[0] == 0) {
+ if (num < 0) {
+ /* need to choose a free number. */
+ char *_devnm = find_free_devnm(use_mdp);
+ if (_devnm == NULL) {
+ pr_err("No avail md devices - aborting\n");
+ return -1;
+ }
+ strcpy(devnm, _devnm);
+ } else {
+ sprintf(devnm, "%s%d", use_mdp?"md_d":"md", num);
+ if (mddev_busy(devnm)) {
+ pr_err("%s is already in use.\n",
+ dev);
+ return -1;
+ }
}
+ if (block_udev)
+ udev_block(devnm);
}
sprintf(devname, "/dev/%s", devnm);
diff --git a/udev-md-raid-creating.rules b/udev-md-raid-creating.rules
new file mode 100644
index 0000000..2be466b
--- /dev/null
+++ b/udev-md-raid-creating.rules
@@ -0,0 +1,7 @@
+# do not edit this file, it will be overwritten on update
+# While mdadm is creating an array, it creates a file
+# /run/mdadm/creating-mdXXX. If that file exists, then
+# the array is not "ready" and we should make sure the
+# content is ignored.
+
+KERNEL=="md*", TEST="/run/mdadm/creating-$kernel", ENV{SYSTEMD_READY}="0"
--
2.13.6
++++++ 0104-Incremental-Use-md_array_active-to-determine-state-o.patch ++++++
From 6921010d95dbc32c812aa8ffdbfa28e78b54b342 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 2 May 2017 10:36:51 -0400
Subject: [PATCH] Incremental: Use md_array_active() to determine state of
array
Git-commit: 6921010d95dbc32c812aa8ffdbfa28e78b54b342
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
One less call to md_get_array_info()
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 4789e36..8909f2f 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -99,7 +99,6 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
int active_disks;
int trustworthy;
char *name_to_use;
- mdu_array_info_t ainf;
struct dev_policy *policy = NULL;
struct map_ent target_array;
int have_target;
@@ -551,7 +550,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
/* + add any bitmap file */
/* + start the array (auto-readonly). */
- if (md_get_array_info(mdfd, &ainf) == 0) {
+ if (md_array_active(mdfd)) {
if (c->export) {
printf("MD_STARTED=already\n");
} else if (c->verbose >= 0)
--
2.13.6
++++++ 0105-Manage-Manage_ro-Use-md_array_active.patch ++++++
From 80223cb4db3358a24c41a76414a3804c26d5ea3a Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 2 May 2017 10:40:07 -0400
Subject: [PATCH] Manage: Manage_ro(): Use md_array_active()
Git-commit: 80223cb4db3358a24c41a76414a3804c26d5ea3a
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
One call less to md_get_array_info() for determining whether an array
is active or not.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Manage.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/Manage.c b/Manage.c
index 8966e33..230309b 100644
--- a/Manage.c
+++ b/Manage.c
@@ -40,7 +40,6 @@ int Manage_ro(char *devname, int fd, int readonly)
* use RESTART_ARRAY_RW or STOP_ARRAY_RO
*
*/
- mdu_array_info_t array;
struct mdinfo *mdi;
int rv = 0;
@@ -88,9 +87,8 @@ int Manage_ro(char *devname, int fd, int readonly)
goto out;
}
- if (md_get_array_info(fd, &array)) {
- pr_err("%s does not appear to be active.\n",
- devname);
+ if (!md_array_active(fd)) {
+ pr_err("%s does not appear to be active.\n", devname);
rv = 1;
goto out;
}
--
2.13.6
++++++ 0106-IMSM-Initialize-my_vol_raid_dev_num-during-vol-creat.patch ++++++
From 2a24dc1b0988a7d924de6339754d4160762a61f7 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Wed, 26 Apr 2017 11:08:07 +0200
Subject: [PATCH] IMSM: Initialize my_vol_raid_dev_num during vol creation
Git-commit: 2a24dc1b0988a7d924de6339754d4160762a61f7
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This field was not initialized so far. This ID needs to be unique
for every newly created array in container.
Signed-off-by: Pawel Baldysiak
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 fbff215..36f77d3 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -232,8 +232,13 @@ struct imsm_super {
__u32 orig_family_num; /* 0x40 - 0x43 original family num */
__u32 pwr_cycle_count; /* 0x44 - 0x47 simulated power cycle count for array */
__u32 bbm_log_size; /* 0x48 - 0x4B - size of bad Block Mgmt Log in bytes */
-#define IMSM_FILLERS 35
- __u32 filler[IMSM_FILLERS]; /* 0x4C - 0xD7 RAID_MPB_FILLERS */
+ __u16 num_raid_devs_created; /* 0x4C - 0x4D Used for generating unique
+ * volume IDs for raid_dev created in this array
+ * (starts at 1)
+ */
+ __u16 filler1; /* 0x4E - 0x4F */
+#define IMSM_FILLERS 34
+ __u32 filler[IMSM_FILLERS]; /* 0x50 - 0xD7 RAID_MPB_FILLERS */
struct imsm_disk disk[1]; /* 0xD8 diskTbl[numDisks] */
/* here comes imsm_dev[num_raid_devs] */
/* here comes BBM logs */
@@ -5368,6 +5373,8 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
set_imsm_ord_tbl_ent(map, i, IMSM_ORD_REBUILD);
}
mpb->num_raid_devs++;
+ mpb->num_raid_devs_created++;
+ dev->my_vol_raid_dev_num = mpb->num_raid_devs_created;
if (s->consistency_policy <= CONSISTENCY_POLICY_RESYNC) {
dev->rwh_policy = RWH_OFF;
--
2.13.6
++++++ 0107-Grow-Grow_continue_command-Avoid-aliasing-array-vari.patch ++++++
From 9e4524df1c6c85c362278a08fd4425888d27581f Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 2 May 2017 11:46:49 -0400
Subject: [PATCH] Grow: Grow_continue_command: Avoid aliasing array variable
Git-commit: 9e4524df1c6c85c362278a08fd4425888d27581f
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
While this would cause a warning since the two are different types,
lets avoid aliasing an existing variable.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Grow.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Grow.c b/Grow.c
index c6967ed..f4bd301 100755
--- a/Grow.c
+++ b/Grow.c
@@ -5075,7 +5075,7 @@ int Grow_continue_command(char *devname, int fd,
cc = st->ss->container_content(st, subarray);
for (content = cc; content ; content = content->next) {
- char *array;
+ char *array_name;
int allow_reshape = 1;
if (content->reshape_active == 0)
@@ -5100,8 +5100,8 @@ int Grow_continue_command(char *devname, int fd,
goto Grow_continue_command_exit;
}
- array = strchr(content->text_version+1, '/')+1;
- mdstat = mdstat_by_subdev(array, container);
+ array_name = strchr(content->text_version+1, '/')+1;
+ mdstat = mdstat_by_subdev(array_name, container);
if (!mdstat)
continue;
if (mdstat->active == 0) {
--
2.13.6
++++++ 0108-change-back-0644-permission-for-Grow.c.patch ++++++
From 99148c19bd9149bb938309ffb6b4dcde20b67934 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Tue, 2 May 2017 17:27:13 +0800
Subject: [PATCH] change back 0644 permission for Grow.c
Git-commit: 99148c19bd9149bb938309ffb6b4dcde20b67934
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Fixes commit:
26714713cd2b ("mdadm: Change timestamps to unsigned data type.")
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Grow.c | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 Grow.c
diff --git a/Grow.c b/Grow.c
old mode 100755
new mode 100644
--
2.13.6
++++++ 0109-util-md_array_valid-Introduce-md_array_valid-helper.patch ++++++
From 9db2ab4e9b1ad79b9364b6e03bdd675716a688a5 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Wed, 3 May 2017 14:25:57 -0400
Subject: [PATCH] util: md_array_valid(): Introduce md_array_valid() helper
Git-commit: 9db2ab4e9b1ad79b9364b6e03bdd675716a688a5
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Using md_get_array_info() to determine if an array is valid is broken
during creation, since the ioctl() returns -ENODEV if the device is
valid but not active.
Where did I leave my stash of brown paper bags?
Fixes: ("40b054e mdopen/open_mddev: Use md_get_array_info() to determine valid array")
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.h | 1 +
mdopen.c | 3 +--
util.c | 24 ++++++++++++++++++++++++
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index 6a382a7..07ee963 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1415,6 +1415,7 @@ extern int Dump_metadata(char *dev, char *dir, struct context *c,
extern int Restore_metadata(char *dev, char *dir, struct context *c,
struct supertype *st, int only);
+int md_array_valid(int fd);
int md_array_active(int fd);
int md_get_array_info(int fd, struct mdu_array_info_s *array);
int md_set_array_info(int fd, struct mdu_array_info_s *array);
diff --git a/mdopen.c b/mdopen.c
index 099efa0..c4f1c12 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -442,7 +442,6 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
*/
int open_mddev(char *dev, int report_errors)
{
- struct mdu_array_info_s array;
int mdfd = open(dev, O_RDONLY);
if (mdfd < 0) {
@@ -452,7 +451,7 @@ int open_mddev(char *dev, int report_errors)
return -1;
}
- if (md_get_array_info(mdfd, &array) != 0) {
+ if (md_array_valid(mdfd) == 0) {
close(mdfd);
if (report_errors)
pr_err("%s does not appear to be an md device\n", dev);
diff --git a/util.c b/util.c
index 21a63c9..c7585ac 100644
--- a/util.c
+++ b/util.c
@@ -200,6 +200,30 @@ out:
return ret;
}
+int md_array_valid(int fd)
+{
+ struct mdinfo *sra;
+ int ret;
+
+ sra = sysfs_read(fd, NULL, GET_ARRAY_STATE);
+ if (sra) {
+ if (sra->array_state != ARRAY_UNKNOWN_STATE)
+ ret = 0;
+ else
+ ret = -ENODEV;
+
+ free(sra);
+ } else {
+ /*
+ * 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, RAID_VERSION);
+ }
+
+ return !ret;
+}
+
int md_array_active(int fd)
{
struct mdinfo *sra;
--
2.13.6
++++++ 0110-kernel-patch-Remove-obsolete-kernel-patches-against-.patch ++++++
From 2b7bddf06c30da08f8d6270b40f0d382c1c5fc6e Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 4 May 2017 11:39:05 -0400
Subject: [PATCH] kernel-patch: Remove obsolete kernel patches against 2.6
Git-commit: 2b7bddf06c30da08f8d6270b40f0d382c1c5fc6e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
While we still support some of these kernels, I do not think it makes
sense to carry this patches around at this point.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
kernel-patch-2.6.18 | 35 ---------
kernel-patch-2.6.18.6 | 35 ---------
kernel-patch-2.6.19 | 34 ---------
kernel-patch-2.6.25 | 199 --------------------------------------------------
kernel-patch-2.6.27 | 36 ---------
5 files changed, 339 deletions(-)
delete mode 100644 kernel-patch-2.6.18
delete mode 100644 kernel-patch-2.6.18.6
delete mode 100644 kernel-patch-2.6.19
delete mode 100644 kernel-patch-2.6.25
delete mode 100644 kernel-patch-2.6.27
diff --git a/kernel-patch-2.6.18 b/kernel-patch-2.6.18
deleted file mode 100644
index 87496ea..0000000
--- a/kernel-patch-2.6.18
+++ /dev/null
@@ -1,35 +0,0 @@
-
-### Diffstat output
- ./drivers/md/md.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
-
-diff .prev/drivers/md/md.c ./drivers/md/md.c
---- .prev/drivers/md/md.c 2006-10-23 10:26:37.000000000 +1000
-+++ ./drivers/md/md.c 2006-12-21 16:28:29.000000000 +1100
-@@ -1783,7 +1783,8 @@ state_store(mdk_rdev_t *rdev, const char
- else {
- mddev_t *mddev = rdev->mddev;
- kick_rdev_from_array(rdev);
-- md_update_sb(mddev);
-+ if (mddev->pers)
-+ md_update_sb(mddev);
- md_new_event(mddev);
- err = 0;
- }
-@@ -1994,6 +1995,8 @@ static mdk_rdev_t *md_import_device(dev_
- kobject_init(&rdev->kobj);
-
- rdev->desc_nr = -1;
-+ rdev->saved_raid_disk = -1;
-+ rdev->raid_disk = -1;
- rdev->flags = 0;
- rdev->data_offset = 0;
- rdev->sb_events = 0;
-@@ -3991,6 +3994,7 @@ static int set_array_info(mddev_t * mdde
- mddev->major_version = info->major_version;
- mddev->minor_version = info->minor_version;
- mddev->patch_version = info->patch_version;
-+ mddev->persistent = ! info->not_persistent;
- return 0;
- }
- mddev->major_version = MD_MAJOR_VERSION;
diff --git a/kernel-patch-2.6.18.6 b/kernel-patch-2.6.18.6
deleted file mode 100644
index e702e14..0000000
--- a/kernel-patch-2.6.18.6
+++ /dev/null
@@ -1,35 +0,0 @@
-Signed-off-by: Neil Brown
-
-### Diffstat output
- ./drivers/md/md.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff .prev/drivers/md/md.c ./drivers/md/md.c
---- .prev/drivers/md/md.c 2006-12-21 17:08:23.000000000 +1100
-+++ ./drivers/md/md.c 2006-12-21 17:08:26.000000000 +1100
-@@ -1783,7 +1783,8 @@ state_store(mdk_rdev_t *rdev, const char
- else {
- mddev_t *mddev = rdev->mddev;
- kick_rdev_from_array(rdev);
-- md_update_sb(mddev);
-+ if (mddev->pers)
-+ md_update_sb(mddev);
- md_new_event(mddev);
- err = 0;
- }
-@@ -1995,6 +1996,7 @@ static mdk_rdev_t *md_import_device(dev_
-
- rdev->desc_nr = -1;
- rdev->saved_raid_disk = -1;
-+ rdev->raid_disk = -1;
- rdev->flags = 0;
- rdev->data_offset = 0;
- rdev->sb_events = 0;
-@@ -3993,6 +3995,7 @@ static int set_array_info(mddev_t * mdde
- mddev->major_version = info->major_version;
- mddev->minor_version = info->minor_version;
- mddev->patch_version = info->patch_version;
-+ mddev->persistent = ! info->not_persistent;
- return 0;
- }
- mddev->major_version = MD_MAJOR_VERSION;
diff --git a/kernel-patch-2.6.19 b/kernel-patch-2.6.19
deleted file mode 100644
index 22a67a3..0000000
--- a/kernel-patch-2.6.19
+++ /dev/null
@@ -1,34 +0,0 @@
-
-### Diffstat output
- ./drivers/md/md.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff .prev/drivers/md/md.c ./drivers/md/md.c
---- .prev/drivers/md/md.c 2006-12-21 15:55:01.000000000 +1100
-+++ ./drivers/md/md.c 2006-12-21 16:28:09.000000000 +1100
-@@ -1792,7 +1792,8 @@ state_store(mdk_rdev_t *rdev, const char
- else {
- mddev_t *mddev = rdev->mddev;
- kick_rdev_from_array(rdev);
-- md_update_sb(mddev, 1);
-+ if (mddev->pers)
-+ md_update_sb(mddev, 1);
- md_new_event(mddev);
- err = 0;
- }
-@@ -2004,6 +2005,7 @@ static mdk_rdev_t *md_import_device(dev_
-
- rdev->desc_nr = -1;
- rdev->saved_raid_disk = -1;
-+ rdev->raid_disk = -1;
- rdev->flags = 0;
- rdev->data_offset = 0;
- rdev->sb_events = 0;
-@@ -3977,6 +3979,7 @@ static int set_array_info(mddev_t * mdde
- mddev->major_version = info->major_version;
- mddev->minor_version = info->minor_version;
- mddev->patch_version = info->patch_version;
-+ mddev->persistent = ! info->not_persistent;
- return 0;
- }
- mddev->major_version = MD_MAJOR_VERSION;
diff --git a/kernel-patch-2.6.25 b/kernel-patch-2.6.25
deleted file mode 100644
index 2329007..0000000
--- a/kernel-patch-2.6.25
+++ /dev/null
@@ -1,199 +0,0 @@
-Status: ok
-
-Support adding a spare to a live md array with external metadata.
-
-i.e. extend the 'md/dev-XXX/slot' attribute so that you can
-tell a device to fill an vacant slot in an and md array.
-
-
-Signed-off-by: Neil Brown
-
-### Diffstat output
- ./drivers/md/md.c | 44 ++++++++++++++++++++++++++++++++++++++++----
- ./drivers/md/multipath.c | 7 ++++++-
- ./drivers/md/raid1.c | 7 ++++++-
- ./drivers/md/raid10.c | 10 ++++++++--
- ./drivers/md/raid5.c | 10 ++++++++--
- 5 files changed, 68 insertions(+), 10 deletions(-)
-
-diff .prev/drivers/md/md.c ./drivers/md/md.c
---- .prev/drivers/md/md.c 2008-06-05 09:19:56.000000000 +1000
-+++ ./drivers/md/md.c 2008-06-10 10:41:21.000000000 +1000
-@@ -1932,7 +1932,7 @@ slot_store(mdk_rdev_t *rdev, const char
- slot = -1;
- else if (e==buf || (*e && *e!= '\n'))
- return -EINVAL;
-- if (rdev->mddev->pers) {
-+ if (rdev->mddev->pers && slot == -1) {
- /* Setting 'slot' on an active array requires also
- * updating the 'rd%d' link, and communicating
- * with the personality with ->hot_*_disk.
-@@ -1940,8 +1940,6 @@ slot_store(mdk_rdev_t *rdev, const char
- * failed/spare devices. This normally happens automatically,
- * but not when the metadata is externally managed.
- */
-- if (slot != -1)
-- return -EBUSY;
- if (rdev->raid_disk == -1)
- return -EEXIST;
- /* personality does all needed checks */
-@@ -1955,6 +1953,44 @@ slot_store(mdk_rdev_t *rdev, const char
- sysfs_remove_link(&rdev->mddev->kobj, nm);
- set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery);
- md_wakeup_thread(rdev->mddev->thread);
-+ } else if (rdev->mddev->pers) {
-+ mdk_rdev_t *rdev2;
-+ struct list_head *tmp;
-+ /* Activating a spare .. or possibly reactivating
-+ * if we every get bitmaps working here.
-+ */
-+
-+ if (rdev->raid_disk != -1)
-+ return -EBUSY;
-+
-+ if (rdev->mddev->pers->hot_add_disk == NULL)
-+ return -EINVAL;
-+
-+ rdev_for_each(rdev2, tmp, rdev->mddev)
-+ if (rdev2->raid_disk == slot)
-+ return -EEXIST;
-+
-+ rdev->raid_disk = slot;
-+ if (test_bit(In_sync, &rdev->flags))
-+ rdev->saved_raid_disk = slot;
-+ else
-+ rdev->saved_raid_disk = -1;
-+ err = rdev->mddev->pers->
-+ hot_add_disk(rdev->mddev, rdev);
-+ if (err != 1) {
-+ rdev->raid_disk = -1;
-+ if (err == 0)
-+ return -EEXIST;
-+ return err;
-+ }
-+ sprintf(nm, "rd%d", rdev->raid_disk);
-+ if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm))
-+ printk(KERN_WARNING
-+ "md: cannot register "
-+ "%s for %s\n",
-+ nm, mdname(rdev->mddev));
-+
-+ /* don't wakeup anyone, leave that to userspace. */
- } else {
- if (slot >= rdev->mddev->raid_disks)
- return -ENOSPC;
-@@ -4205,7 +4241,7 @@ static int add_new_disk(mddev_t * mddev,
- super_types[mddev->major_version].
- validate_super(mddev, rdev);
- err = mddev->pers->hot_add_disk(mddev, rdev);
-- if (err)
-+ if (err < 0)
- unbind_rdev_from_array(rdev);
- }
- if (err)
-
-diff .prev/drivers/md/multipath.c ./drivers/md/multipath.c
---- .prev/drivers/md/multipath.c 2008-05-30 14:49:31.000000000 +1000
-+++ ./drivers/md/multipath.c 2008-06-10 10:35:03.000000000 +1000
-@@ -284,10 +284,15 @@ static int multipath_add_disk(mddev_t *m
- int found = 0;
- int path;
- struct multipath_info *p;
-+ int first = 0;
-+ int last = mddev->raid_disks - 1;
-+
-+ if (rdev->raid_disk >= 0)
-+ first = last = rdev->raid_disk;
-
- print_multipath_conf(conf);
-
-- for (path=0; path<mddev->raid_disks; path++)
-+ for (path = first; path <= last; path++)
- if ((p=conf->multipaths+path)->rdev == NULL) {
- q = rdev->bdev->bd_disk->queue;
- blk_queue_stack_limits(mddev->queue, q);
-
-diff .prev/drivers/md/raid10.c ./drivers/md/raid10.c
---- .prev/drivers/md/raid10.c 2008-05-30 14:49:31.000000000 +1000
-+++ ./drivers/md/raid10.c 2008-06-10 10:28:53.000000000 +1000
-@@ -1116,6 +1116,8 @@ static int raid10_add_disk(mddev_t *mdde
- int found = 0;
- int mirror;
- mirror_info_t *p;
-+ int first = 0;
-+ int last = mddev->raid_disks - 1;
-
- if (mddev->recovery_cp < MaxSector)
- /* only hot-add to in-sync arrays, as recovery is
-@@ -1125,12 +1127,16 @@ static int raid10_add_disk(mddev_t *mdde
- if (!enough(conf))
- return 0;
-
-+ if (rdev->raid_disk)
-+ first = last = rdev->raid_disk;
-+
- if (rdev->saved_raid_disk >= 0 &&
-+ rdev->saved_raid_disk >= first &&
- conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
- mirror = rdev->saved_raid_disk;
- else
-- mirror = 0;
-- for ( ; mirror < mddev->raid_disks; mirror++)
-+ mirror = first;
-+ for ( ; mirror <= last ; mirror++)
- if ( !(p=conf->mirrors+mirror)->rdev) {
-
- blk_queue_stack_limits(mddev->queue,
-
-diff .prev/drivers/md/raid1.c ./drivers/md/raid1.c
---- .prev/drivers/md/raid1.c 2008-05-30 14:49:31.000000000 +1000
-+++ ./drivers/md/raid1.c 2008-06-10 10:41:00.000000000 +1000
-@@ -1103,8 +1103,13 @@ static int raid1_add_disk(mddev_t *mddev
- int found = 0;
- int mirror = 0;
- mirror_info_t *p;
-+ int first = 0;
-+ int last = mddev->raid_disks - 1;
-
-- for (mirror=0; mirror < mddev->raid_disks; mirror++)
-+ if (rdev->raid_disk >= 0)
-+ first = last = rdev->raid_disk;
-+
-+ for (mirror = first; mirror <= last; mirror++)
- if ( !(p=conf->mirrors+mirror)->rdev) {
-
- blk_queue_stack_limits(mddev->queue,
-
-diff .prev/drivers/md/raid5.c ./drivers/md/raid5.c
---- .prev/drivers/md/raid5.c 2008-05-30 14:49:35.000000000 +1000
-+++ ./drivers/md/raid5.c 2008-06-10 10:27:51.000000000 +1000
-@@ -4399,21 +4399,27 @@ static int raid5_add_disk(mddev_t *mddev
- int found = 0;
- int disk;
- struct disk_info *p;
-+ int first = 0;
-+ int last = conf->raid_disks - 1;
-
- if (mddev->degraded > conf->max_degraded)
- /* no point adding a device */
- return 0;
-
-+ if (rdev->raid_disk >= 0)
-+ first = last = rdev->raid_disk;
-+
- /*
- * find the disk ... but prefer rdev->saved_raid_disk
- * if possible.
- */
- if (rdev->saved_raid_disk >= 0 &&
-+ rdev->saved_raid_disk >= first &&
- conf->disks[rdev->saved_raid_disk].rdev == NULL)
- disk = rdev->saved_raid_disk;
- else
-- disk = 0;
-- for ( ; disk < conf->raid_disks; disk++)
-+ disk = first;
-+ for ( ; disk <= last ; disk++)
- if ((p=conf->disks + disk)->rdev == NULL) {
- clear_bit(In_sync, &rdev->flags);
- rdev->raid_disk = disk;
diff --git a/kernel-patch-2.6.27 b/kernel-patch-2.6.27
deleted file mode 100644
index 8d0785d..0000000
--- a/kernel-patch-2.6.27
+++ /dev/null
@@ -1,36 +0,0 @@
-touch_mnt_namespace when the mount flags change
-
-From: Dan Williams
-
-Daemons that need to be launched while the rootfs is read-only can now
-poll /proc/mounts to be notified when their O_RDWR requests may no
-longer end in EROFS.
-
-Cc: Kay Sievers
-Cc: Neil Brown
-Signed-off-by: Dan Williams
----
-
- fs/namespace.c | 7 ++++++-
- 1 files changed, 6 insertions(+), 1 deletions(-)
-
-
-diff --git a/fs/namespace.c b/fs/namespace.c
-index 6e283c9..1bd5ba2 100644
---- a/fs/namespace.c
-+++ b/fs/namespace.c
-@@ -1553,8 +1553,13 @@ static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
- if (!err)
- nd->path.mnt->mnt_flags = mnt_flags;
- up_write(&sb->s_umount);
-- if (!err)
-+ if (!err) {
- security_sb_post_remount(nd->path.mnt, flags, data);
-+
-+ spin_lock(&vfsmount_lock);
-+ touch_mnt_namespace(nd->path.mnt->mnt_ns);
-+ spin_unlock(&vfsmount_lock);
-+ }
- return err;
- }
-
--
2.13.6
++++++ 0111-mdassemble-Kill-off-the-last-remains.patch ++++++
From 935795398d52a589598fa13e6cb6272619c5d134 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 4 May 2017 11:57:41 -0400
Subject: [PATCH] mdassemble: Kill off the last remains
Git-commit: 935795398d52a589598fa13e6cb6272619c5d134
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Having gotten rid of mdassemble, lets get rid of the man page too
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
README.initramfs | 9 ++++----
mdassemble.8 | 65 --------------------------------------------------------
2 files changed, 4 insertions(+), 70 deletions(-)
delete mode 100644 mdassemble.8
diff --git a/README.initramfs b/README.initramfs
index 8f9b8dd..c5fa668 100644
--- a/README.initramfs
+++ b/README.initramfs
@@ -16,11 +16,10 @@ devices.
These mechanisms, while useful, do not provide complete functionality
and are unlikely to be extended. The preferred way to assemble md
-arrays at boot time is using 'mdadm' or 'mdassemble' (which is a
-trimmed-down mdadm). To assemble an array which contains the root
-filesystem, mdadm needs to be run before that filesystem is mounted,
-and so needs to be run from an initial-ram-fs. It is how this can
-work that is the primary focus of this document.
+arrays at boot time is using 'mdadm'. To assemble an array which
+contains the root filesystem, mdadm needs to be run before that
+filesystem is mounted, and so needs to be run from an initial-ram-fs.
+It is how this can work that is the primary focus of this document.
It should be noted up front that only the array containing the root
filesystem should be assembled from the initramfs. Any other arrays
diff --git a/mdassemble.8 b/mdassemble.8
deleted file mode 100644
index 33aa977..0000000
--- a/mdassemble.8
+++ /dev/null
@@ -1,65 +0,0 @@
-.\" -*- nroff -*-
-.TH MDASSEMBLE 8 "" v4.0
-.SH NAME
-mdassemble \- assemble MD devices
-.I aka
-Linux Software RAID
-
-.SH SYNOPSIS
-
-.BI mdassemble
-
-.SH DESCRIPTION
-.B mdassemble
-is a tiny program that can be used to assemble MD devices inside an
-initial ramdisk (initrd) or initramfs; it is meant to replace the in-kernel
-automatic RAID detection and activation.
-It can be built statically and linked against lightweight libc alternatives, like
-.B dietlibc,
-.B klibc
-or
-.B uClibc.
-
-.SH USAGE
-Invoking
-.B mdassemble
-has the same effect as invoking
-.B mdadm \-\-assemble \-\-scan.
-.PP
-Invoking
-.B mdassemble
-a second time will make all defined arrays readwrite, this is useful if
-using the
-.B start_ro
-module parameter.
-
-.SH OPTIONS
-
-There are no options to
-.B mdassemble.
-
-.SH FILES
-
-.SS /etc/mdadm.conf
-
-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
-.BR mdadm.conf (5)
-for more details.
-
-.B mdassemble
-supports all configuration parameters defined in
-.B mdadm.conf
-with the exception of
-.B auto=
-which is supported only if mdadm was built with the
-.B \-DMDASSEMBLE_AUTO
-define.
-
-.SH SEE ALSO
-.PP
-.BR mdadm (8),
-.BR mdadm.conf (5),
-.BR md (4),
-.BR diet (1).
--
2.13.6
++++++ 0112-mdadm-util-unify-fstat-checking-blkdev-into-function.patch ++++++
From 0a6bff09d41650f27136d56a0604c9af46b6f583 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Thu, 4 May 2017 20:16:21 +0800
Subject: [PATCH] mdadm/util: unify fstat checking blkdev into function
Git-commit: 0a6bff09d41650f27136d56a0604c9af46b6f583
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
declare function fstat_is_blkdev() to integrate repeated fstat
checking block device operations, it returns true/1 when it is
a block device, and returns false/0 when it isn't.
The fd and devname are necessary parameters, *rdev is optional,
parse the pointer of dev_t *rdev, if valid, assigned the device
number to dev_t *rdev, if NULL, ignores.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 19 +++++++------------
Build.c | 5 +++--
Create.c | 23 ++++++++++-------------
Grow.c | 10 ++++------
Incremental.c | 33 ++++++++++++---------------------
Manage.c | 2 +-
bitmap.c | 13 ++++---------
mdadm.h | 1 +
super-intel.c | 13 +++----------
util.c | 17 +++++++++++++++++
10 files changed, 62 insertions(+), 74 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index a9442c8..9d0a89f 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -149,6 +149,7 @@ static int select_devices(struct mddev_dev *devlist,
struct mdinfo *content = NULL;
int report_mismatch = ((inargv && c->verbose >= 0) || c->verbose > 0);
struct domainlist *domains = NULL;
+ dev_t rdev;
tmpdev = devlist; num_devs = 0;
while (tmpdev) {
@@ -169,7 +170,6 @@ static int select_devices(struct mddev_dev *devlist,
tmpdev = tmpdev ? tmpdev->next : NULL) {
char *devname = tmpdev->devname;
int dfd;
- struct stat stb;
struct supertype *tst;
struct dev_policy *pol = NULL;
int found_container = 0;
@@ -204,14 +204,7 @@ static int select_devices(struct mddev_dev *devlist,
pr_err("cannot open device %s: %s\n",
devname, strerror(errno));
tmpdev->used = 2;
- } else if (fstat(dfd, &stb)< 0) {
- /* Impossible! */
- pr_err("fstat failed for %s: %s\n",
- devname, strerror(errno));
- tmpdev->used = 2;
- } else if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- pr_err("%s is not a block device.\n",
- devname);
+ } else if (!fstat_is_blkdev(dfd, devname, &rdev)) {
tmpdev->used = 2;
} else if (must_be_container(dfd)) {
if (st) {
@@ -234,7 +227,8 @@ static int select_devices(struct mddev_dev *devlist,
devname);
tmpdev->used = 2;
} else if (auto_assem &&
- !conf_test_metadata(tst->ss->name, (pol = devid_policy(stb.st_rdev)),
+ !conf_test_metadata(tst->ss->name,
+ (pol = devid_policy(rdev)),
tst->ss->match_home(tst, c->homehost) == 1)) {
if (report_mismatch)
pr_err("%s has metadata type %s for which auto-assembly is disabled\n",
@@ -261,7 +255,8 @@ static int select_devices(struct mddev_dev *devlist,
tst->ss->name, devname);
tmpdev->used = 2;
} else if (auto_assem && st == NULL &&
- !conf_test_metadata(tst->ss->name, (pol = devid_policy(stb.st_rdev)),
+ !conf_test_metadata(tst->ss->name,
+ (pol = devid_policy(rdev)),
tst->ss->match_home(tst, c->homehost) == 1)) {
if (report_mismatch)
pr_err("%s has metadata type %s for which auto-assembly is disabled\n",
@@ -484,7 +479,7 @@ static int select_devices(struct mddev_dev *devlist,
/* Collect domain information from members only */
if (tmpdev && tmpdev->used == 1) {
if (!pol)
- pol = devid_policy(stb.st_rdev);
+ pol = devid_policy(rdev);
domain_merge(&domains, pol, tst?tst->ss->name:NULL);
}
dev_policy_free(pol);
diff --git a/Build.c b/Build.c
index 665d906..2d84b96 100644
--- a/Build.c
+++ b/Build.c
@@ -42,6 +42,7 @@ int Build(char *mddev, struct mddev_dev *devlist,
*/
int i;
struct stat stb;
+ dev_t rdev;
int subdevs = 0, missing_disks = 0;
struct mddev_dev *dv;
int bitmap_fd;
@@ -126,8 +127,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
array.nr_disks = s->raiddisks;
array.raid_disks = s->raiddisks;
array.md_minor = 0;
- if (fstat(mdfd, &stb) == 0)
- array.md_minor = minor(stb.st_rdev);
+ if (fstat_is_blkdev(mdfd, mddev, &rdev))
+ array.md_minor = minor(rdev);
array.not_persistent = 1;
array.state = 0; /* not clean, but no errors */
if (s->assume_clean)
diff --git a/Create.c b/Create.c
index df1bc20..239545f 100644
--- a/Create.c
+++ b/Create.c
@@ -89,8 +89,8 @@ int Create(struct supertype *st, char *mddev,
char *maxdisc = NULL;
int dnum, raid_disk_num;
struct mddev_dev *dv;
+ dev_t rdev;
int fail = 0, warn = 0;
- struct stat stb;
int first_missing = subdevs * 2;
int second_missing = subdevs * 2;
int missing_disks = 0;
@@ -325,11 +325,8 @@ int Create(struct supertype *st, char *mddev,
dname, strerror(errno));
exit(2);
}
- if (fstat(dfd, &stb) != 0 ||
- (stb.st_mode & S_IFMT) != S_IFBLK) {
+ if (!fstat_is_blkdev(dfd, dname, NULL)) {
close(dfd);
- pr_err("%s is not a block device\n",
- dname);
exit(2);
}
close(dfd);
@@ -641,8 +638,8 @@ int Create(struct supertype *st, char *mddev,
* with, but it chooses to trust me instead. Sigh
*/
info.array.md_minor = 0;
- if (fstat(mdfd, &stb) == 0)
- info.array.md_minor = minor(stb.st_rdev);
+ if (fstat_is_blkdev(mdfd, mddev, &rdev))
+ info.array.md_minor = minor(rdev);
info.array.not_persistent = 0;
if (((s->level == 4 || s->level == 5) &&
@@ -841,7 +838,6 @@ int Create(struct supertype *st, char *mddev,
for (dnum = 0, raid_disk_num = 0, dv = devlist; dv;
dv = (dv->next) ? (dv->next) : moved_disk, dnum++) {
int fd;
- struct stat stb2;
struct mdinfo *inf = &infos[dnum];
if (dnum >= total_slots)
@@ -897,9 +893,10 @@ int Create(struct supertype *st, char *mddev,
dv->devname);
goto abort_locked;
}
- fstat(fd, &stb2);
- inf->disk.major = major(stb2.st_rdev);
- inf->disk.minor = minor(stb2.st_rdev);
+ if (!fstat_is_blkdev(fd, dv->devname, &rdev))
+ return 1;
+ inf->disk.major = major(rdev);
+ inf->disk.minor = minor(rdev);
}
if (fd >= 0)
remove_partitions(fd);
@@ -920,8 +917,8 @@ int Create(struct supertype *st, char *mddev,
if (!have_container) {
/* getinfo_super might have lost these ... */
- inf->disk.major = major(stb2.st_rdev);
- inf->disk.minor = minor(stb2.st_rdev);
+ inf->disk.major = major(rdev);
+ inf->disk.minor = minor(rdev);
}
break;
case 2:
diff --git a/Grow.c b/Grow.c
index f4bd301..a527436 100644
--- a/Grow.c
+++ b/Grow.c
@@ -109,7 +109,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
*/
struct mdinfo info;
- struct stat stb;
+ dev_t rdev;
int nfd, fd2;
int d, nd;
struct supertype *st = NULL;
@@ -145,9 +145,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
free(st);
return 1;
}
- fstat(nfd, &stb);
- if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- pr_err("%s is not a block device!\n", newdev);
+ if (!fstat_is_blkdev(nfd, newdev, &rdev)) {
close(nfd);
free(st);
return 1;
@@ -198,8 +196,8 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
*/
info.disk.number = d;
- info.disk.major = major(stb.st_rdev);
- info.disk.minor = minor(stb.st_rdev);
+ info.disk.major = major(rdev);
+ 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,
diff --git a/Incremental.c b/Incremental.c
index 8909f2f..11a34e7 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -87,6 +87,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
* start the array (auto-readonly).
*/
struct stat stb;
+ dev_t rdev;
struct mdinfo info, dinfo;
struct mdinfo *sra = NULL, *d;
struct mddev_ident *match;
@@ -174,21 +175,11 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
/* 2/ Find metadata, reject if none appropriate (check
* version/name from args) */
- if (fstat(dfd, &stb) < 0) {
- if (c->verbose >= 0)
- pr_err("fstat failed for %s: %s.\n",
- devname, strerror(errno));
- goto out;
- }
- if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- if (c->verbose >= 0)
- pr_err("%s is not a block device.\n",
- devname);
+ if (!fstat_is_blkdev(dfd, devname, &rdev))
goto out;
- }
- dinfo.disk.major = major(stb.st_rdev);
- dinfo.disk.minor = minor(stb.st_rdev);
+ dinfo.disk.major = major(rdev);
+ dinfo.disk.minor = minor(rdev);
policy = disk_policy(&dinfo);
have_target = policy_check_path(&dinfo, &target_array);
@@ -339,8 +330,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
}
dinfo = info;
- dinfo.disk.major = major(stb.st_rdev);
- dinfo.disk.minor = minor(stb.st_rdev);
+ dinfo.disk.major = major(rdev);
+ dinfo.disk.minor = minor(rdev);
if (add_disk(mdfd, st, &info, &dinfo) != 0) {
pr_err("failed to add %s to new array %s: %s.\n",
devname, chosen_name, strerror(errno));
@@ -441,8 +432,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
goto out_unlock;
}
}
- info.disk.major = major(stb.st_rdev);
- info.disk.minor = minor(stb.st_rdev);
+ info.disk.major = major(rdev);
+ info.disk.minor = minor(rdev);
/* add disk needs to know about containers */
if (st->ss->external)
sra->array.level = LEVEL_CONTAINER;
@@ -863,12 +854,12 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
* Return 0 on success, or some exit code on failure, probably 1.
*/
int rv = 1;
- struct stat stb;
+ dev_t rdev;
struct map_ent *mp, *map = NULL;
struct mdinfo *chosen = NULL;
int dfd = *dfdp;
- if (fstat(dfd, &stb) != 0)
+ if (!fstat_is_blkdev(dfd, devname, &rdev))
return 1;
/*
@@ -1038,8 +1029,8 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
devlist.writemostly = FlagDefault;
devlist.failfast = FlagDefault;
devlist.devname = chosen_devname;
- sprintf(chosen_devname, "%d:%d", major(stb.st_rdev),
- minor(stb.st_rdev));
+ sprintf(chosen_devname, "%d:%d", major(rdev),
+ minor(rdev));
devlist.disposition = 'a';
close(dfd);
*dfdp = -1;
diff --git a/Manage.c b/Manage.c
index 230309b..af55266 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1513,7 +1513,7 @@ int Manage_subdevs(char *devname, int fd,
struct stat stb;
tfd = dev_open(dv->devname, O_RDONLY);
if (tfd >= 0) {
- fstat(tfd, &stb);
+ fstat_is_blkdev(tfd, dv->devname, &rdev);
close(tfd);
} else {
int open_err = errno;
diff --git a/bitmap.c b/bitmap.c
index 16a6b73..3653660 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -183,7 +183,6 @@ static int
bitmap_file_open(char *filename, struct supertype **stp, int node_num)
{
int fd;
- struct stat stb;
struct supertype *st = *stp;
fd = open(filename, O_RDONLY|O_DIRECT);
@@ -193,14 +192,7 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
return -1;
}
- if (fstat(fd, &stb) < 0) {
- pr_err("failed to determine bitmap file/device type: %s\n",
- strerror(errno));
- close(fd);
- return -1;
- }
-
- if ((stb.st_mode & S_IFMT) == S_IFBLK) {
+ if (fstat_is_blkdev(fd, filename, NULL)) {
/* block device, so we are probably after an internal bitmap */
if (!st)
st = guess_super(fd);
@@ -221,6 +213,9 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
}
*stp = st;
+ } else {
+ close(fd);
+ return -1;
}
return fd;
diff --git a/mdadm.h b/mdadm.h
index 07ee963..4adb840 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1434,6 +1434,7 @@ extern int check_raid(int fd, char *name);
extern int check_partitions(int fd, char *dname,
unsigned long long freesize,
unsigned long long size);
+extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev);
extern int get_mdp_major(void);
extern int get_maj_min(char *dev, int *major, int *minor);
diff --git a/super-intel.c b/super-intel.c
index 36f77d3..c4196ea 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6562,7 +6562,7 @@ count_volumes_list(struct md_list *devlist, char *homehost,
for (tmpdev = devlist; tmpdev; tmpdev = tmpdev->next) {
char *devname = tmpdev->devname;
- struct stat stb;
+ dev_t rdev;
struct supertype *tst;
int dfd;
if (tmpdev->used > 1)
@@ -6578,14 +6578,7 @@ count_volumes_list(struct md_list *devlist, char *homehost,
dprintf("cannot open device %s: %s\n",
devname, strerror(errno));
tmpdev->used = 2;
- } else if (fstat(dfd, &stb)< 0) {
- /* Impossible! */
- dprintf("fstat failed for %s: %s\n",
- devname, strerror(errno));
- tmpdev->used = 2;
- } else if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- dprintf("%s is not a block device.\n",
- devname);
+ } else if (!fstat_is_blkdev(dfd, devname, &rdev)) {
tmpdev->used = 2;
} else if (must_be_container(dfd)) {
struct supertype *cst;
@@ -6607,7 +6600,7 @@ count_volumes_list(struct md_list *devlist, char *homehost,
if (cst)
cst->ss->free_super(cst);
} else {
- tmpdev->st_rdev = stb.st_rdev;
+ tmpdev->st_rdev = rdev;
if (tst->ss->load_super(tst,dfd, NULL)) {
dprintf("no RAID superblock on %s\n",
devname);
diff --git a/util.c b/util.c
index c7585ac..a92faf8 100644
--- a/util.c
+++ b/util.c
@@ -730,6 +730,23 @@ int check_raid(int fd, char *name)
return 1;
}
+int fstat_is_blkdev(int fd, char *devname, dev_t *rdev)
+{
+ struct stat stb;
+
+ if (fstat(fd, &stb) != 0) {
+ pr_err("fstat failed for %s: %s\n", devname, strerror(errno));
+ return 0;
+ }
+ if ((S_IFMT & stb.st_mode) != S_IFBLK) {
+ pr_err("%s is not a block device.\n", devname);
+ return 0;
+ }
+ if (rdev)
+ *rdev = stb.st_rdev;
+ return 1;
+}
+
int ask(char *mesg)
{
char *add = "";
--
2.13.6
++++++ 0113-mdadm-util-unify-stat-checking-blkdev-into-function.patch ++++++
From 9e04ac1c43e63eccb68eb196174069e5c23d0270 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Fri, 5 May 2017 11:09:41 +0800
Subject: [PATCH] mdadm/util: unify stat checking blkdev into function
Git-commit: 9e04ac1c43e63eccb68eb196174069e5c23d0270
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
declare function stat_is_blkdev() to integrate repeated stat
checking blkdev operations, it returns 'true/1' when it is a
block device, and returns 'false/0' when it isn't.
The devname is necessary parameter, *rdev is optional, parse
the pointer of dev_t *rdev, if valid, assigned device number
to dev_t *rdev, if NULL, ignores.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 7 ++-----
Build.c | 25 ++++---------------------
Incremental.c | 21 ++++-----------------
Manage.c | 11 +----------
Monitor.c | 16 ++++------------
mdadm.h | 1 +
super-ddf.c | 10 ++++------
super-intel.c | 10 ++++------
util.c | 17 +++++++++++++++++
9 files changed, 41 insertions(+), 77 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 9d0a89f..30d5838 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -512,15 +512,12 @@ static int select_devices(struct mddev_dev *devlist,
/* Now reject spares that don't match domains of identified members */
for (tmpdev = devlist; tmpdev; tmpdev = tmpdev->next) {
- struct stat stb;
if (tmpdev->used != 3)
continue;
- if (stat(tmpdev->devname, &stb)< 0) {
- pr_err("fstat failed for %s: %s\n",
- tmpdev->devname, strerror(errno));
+ if (!stat_is_blkdev(tmpdev->devname, &rdev)) {
tmpdev->used = 2;
} else {
- struct dev_policy *pol = devid_policy(stb.st_rdev);
+ struct dev_policy *pol = devid_policy(rdev);
int dt = domain_test(domains, pol, NULL);
if (inargv && dt != 0)
/* take this spare as domains match
diff --git a/Build.c b/Build.c
index 2d84b96..ad59867 100644
--- a/Build.c
+++ b/Build.c
@@ -41,7 +41,6 @@ int Build(char *mddev, struct mddev_dev *devlist,
* cc = chunk size factor: 0==4k, 1==8k etc.
*/
int i;
- struct stat stb;
dev_t rdev;
int subdevs = 0, missing_disks = 0;
struct mddev_dev *dv;
@@ -65,16 +64,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
missing_disks++;
continue;
}
- if (stat(dv->devname, &stb)) {
- pr_err("Cannot find %s: %s\n",
- dv->devname, strerror(errno));
- return 1;
- }
- if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- pr_err("%s is not a block device.\n",
- dv->devname);
+ if (!stat_is_blkdev(dv->devname, NULL))
return 1;
- }
}
if (s->raiddisks != subdevs) {
@@ -162,16 +153,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
if (strcmp("missing", dv->devname) == 0)
continue;
- if (stat(dv->devname, &stb)) {
- pr_err("Weird: %s has disappeared.\n",
- dv->devname);
+ if (!stat_is_blkdev(dv->devname, &rdev))
goto abort;
- }
- if ((stb.st_mode & S_IFMT)!= S_IFBLK) {
- pr_err("Weird: %s is no longer a block device.\n",
- dv->devname);
- goto abort;
- }
fd = open(dv->devname, O_RDONLY|O_EXCL);
if (fd < 0) {
pr_err("Cannot open %s: %s\n",
@@ -187,8 +170,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
disk.state = (1<writemostly == FlagSet)
disk.state |= 1<devname, strerror(errno));
diff --git a/Incremental.c b/Incremental.c
index 11a34e7..97b2e99 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -86,8 +86,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
* - if number of OK devices match expected, or -R and there are enough,
* start the array (auto-readonly).
*/
- struct stat stb;
- dev_t rdev;
+ dev_t rdev, rdev2;
struct mdinfo info, dinfo;
struct mdinfo *sra = NULL, *d;
struct mddev_ident *match;
@@ -108,18 +107,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
struct createinfo *ci = conf_get_create_info();
- if (stat(devname, &stb) < 0) {
- if (c->verbose >= 0)
- pr_err("stat failed for %s: %s.\n",
- devname, strerror(errno));
- return rv;
- }
- if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- if (c->verbose >= 0)
- pr_err("%s is not a block device.\n",
- devname);
+ if (!stat_is_blkdev(devname, &rdev))
return rv;
- }
dfd = dev_open(devname, O_RDONLY);
if (dfd < 0) {
if (c->verbose >= 0)
@@ -158,10 +147,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
if (!devlist) {
devlist = conf_get_devs();
for (;devlist; devlist = devlist->next) {
- struct stat st2;
- if (stat(devlist->devname, &st2) == 0 &&
- (st2.st_mode & S_IFMT) == S_IFBLK &&
- st2.st_rdev == stb.st_rdev)
+ if (stat_is_blkdev(devlist->devname, &rdev2) &&
+ rdev2 == rdev)
break;
}
}
diff --git a/Manage.c b/Manage.c
index af55266..14276b7 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1510,24 +1510,16 @@ int Manage_subdevs(char *devname, int fd,
*/
rdev = makedev(mj, mn);
} else {
- struct stat stb;
tfd = dev_open(dv->devname, O_RDONLY);
if (tfd >= 0) {
fstat_is_blkdev(tfd, dv->devname, &rdev);
close(tfd);
} else {
int open_err = errno;
- if (stat(dv->devname, &stb) != 0) {
- pr_err("Cannot find %s: %s\n",
- dv->devname, strerror(errno));
- goto abort;
- }
- if ((stb.st_mode & S_IFMT) != S_IFBLK) {
+ if (!stat_is_blkdev(dv->devname, &rdev)) {
if (dv->disposition == 'M')
/* non-fatal. Also improbable */
continue;
- pr_err("%s is not a block device.\n",
- dv->devname);
goto abort;
}
if (dv->disposition == 'r')
@@ -1544,7 +1536,6 @@ int Manage_subdevs(char *devname, int fd,
goto abort;
}
}
- rdev = stb.st_rdev;
}
switch(dv->disposition){
default:
diff --git a/Monitor.c b/Monitor.c
index 1f15377..e2b36ff 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -993,23 +993,13 @@ static void link_containers_with_subarrays(struct state *list)
/* Not really Monitor but ... */
int Wait(char *dev)
{
- struct stat stb;
char devnm[32];
- char *tmp;
int rv = 1;
int frozen_remaining = 3;
- if (stat(dev, &stb) != 0) {
- pr_err("Cannot find %s: %s\n", dev,
- strerror(errno));
+ if (!stat_is_blkdev(dev, NULL))
return 2;
- }
- tmp = stat2devnm(&stb);
- if (!tmp) {
- pr_err("%s is not a block device.\n", dev);
- return 2;
- }
- strcpy(devnm, tmp);
+ strcpy(devnm, dev);
while(1) {
struct mdstat_ent *ms = mdstat_read(1, 0);
@@ -1068,6 +1058,8 @@ int WaitClean(char *dev, int sock, int verbose)
int rv = 1;
char devnm[32];
+ if (!stat_is_blkdev(dev, NULL))
+ return 2;
fd = open(dev, O_RDONLY);
if (fd < 0) {
if (verbose)
diff --git a/mdadm.h b/mdadm.h
index 4adb840..a92feb2 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1435,6 +1435,7 @@ extern int check_partitions(int fd, char *dname,
unsigned long long freesize,
unsigned long long size);
extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev);
+extern int stat_is_blkdev(char *devname, dev_t *rdev);
extern int get_mdp_major(void);
extern int get_maj_min(char *dev, int *major, int *minor);
diff --git a/super-ddf.c b/super-ddf.c
index 796eaa5..9c82f4f 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3490,7 +3490,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
char *dev, unsigned long long *freesize,
int verbose)
{
- struct stat stb;
+ dev_t rdev;
struct ddf_super *ddf = st->sb;
struct dl *dl;
unsigned long long maxsize;
@@ -3526,13 +3526,11 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
return 1;
}
/* This device must be a member of the set */
- if (stat(dev, &stb) < 0)
- return 0;
- if ((S_IFMT & stb.st_mode) != S_IFBLK)
+ if (!stat_is_blkdev(dev, NULL))
return 0;
for (dl = ddf->dlist ; dl ; dl = dl->next) {
- if (dl->major == (int)major(stb.st_rdev) &&
- dl->minor == (int)minor(stb.st_rdev))
+ if (dl->major == (int)major(rdev) &&
+ dl->minor == (int)minor(rdev))
break;
}
if (!dl) {
diff --git a/super-intel.c b/super-intel.c
index c4196ea..e13c940 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6855,7 +6855,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level,
unsigned long long *freesize,
int verbose)
{
- struct stat stb;
+ dev_t rdev;
struct intel_super *super = st->sb;
struct imsm_super *mpb;
struct dl *dl;
@@ -6920,13 +6920,11 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level,
}
/* This device must be a member of the set */
- if (stat(dev, &stb) < 0)
- return 0;
- if ((S_IFMT & stb.st_mode) != S_IFBLK)
+ if (!stat_is_blkdev(dev, &rdev))
return 0;
for (dl = super->disks ; dl ; dl = dl->next) {
- if (dl->major == (int)major(stb.st_rdev) &&
- dl->minor == (int)minor(stb.st_rdev))
+ if (dl->major == (int)major(rdev) &&
+ dl->minor == (int)minor(rdev))
break;
}
if (!dl) {
diff --git a/util.c b/util.c
index a92faf8..11ff2cc 100644
--- a/util.c
+++ b/util.c
@@ -747,6 +747,23 @@ int fstat_is_blkdev(int fd, char *devname, dev_t *rdev)
return 1;
}
+int stat_is_blkdev(char *devname, dev_t *rdev)
+{
+ struct stat stb;
+
+ if (stat(devname, &stb) != 0) {
+ pr_err("stat failed for %s: %s\n", devname, strerror(errno));
+ return 0;
+ }
+ if ((S_IFMT & stb.st_mode) != S_IFBLK) {
+ pr_err("%s is not a block device.\n", devname);
+ return 0;
+ }
+ if (rdev)
+ *rdev = stb.st_rdev;
+ return 1;
+}
+
int ask(char *mesg)
{
char *add = "";
--
2.13.6
++++++ 0114-Fix-typo-in-new-udev-rule.patch ++++++
From dd180cb136d6b2193a58ea0de23b8a7942ca6f36 Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 5 May 2017 15:16:15 +1000
Subject: [PATCH] Fix typo in new udev rule.
Git-commit: dd180cb136d6b2193a58ea0de23b8a7942ca6f36
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
As pointed out by Peter Rajnoha, the correct usage in udev is
TEST=="file", not TEST="file".
Also improve a related comment which was a bit informal.
Reported-by: Peter Rajnoha
Fixes: cd6cbb08c458 ("Create: tell udev md device is not ready when first created.")
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
lib.c | 2 +-
udev-md-raid-creating.rules | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib.c b/lib.c
index 7e44b1f..be093e8 100644
--- a/lib.c
+++ b/lib.c
@@ -165,7 +165,7 @@ char *fd2devnm(int fd)
/* When we create a new array, we don't want the content to
* be immediately examined by udev - it is probably meaningless.
- * So create /run/mdadm/creating-FOO and expect that a udev
+ * So create /run/mdadm/creating-mdXXX and expect that a udev
* rule will noticed this and act accordingly.
*/
static char block_path[] = "/run/mdadm/creating-%s";
diff --git a/udev-md-raid-creating.rules b/udev-md-raid-creating.rules
index 2be466b..9bef8d1 100644
--- a/udev-md-raid-creating.rules
+++ b/udev-md-raid-creating.rules
@@ -4,4 +4,4 @@
# the array is not "ready" and we should make sure the
# content is ignored.
-KERNEL=="md*", TEST="/run/mdadm/creating-$kernel", ENV{SYSTEMD_READY}="0"
+KERNEL=="md*", TEST=="/run/mdadm/creating-$kernel", ENV{SYSTEMD_READY}="0"
--
2.13.6
++++++ 0115-Incremental-return-is-not-a-function.patch ++++++
From c2d1a6ec6b94385e64e721b733bd44d1d704b530 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 5 May 2017 11:39:58 -0400
Subject: [PATCH] Incremental: return is not a function
Git-commit: c2d1a6ec6b94385e64e721b733bd44d1d704b530
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Incremental.c b/Incremental.c
index 97b2e99..c00a43d 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -823,7 +823,7 @@ static int container_members_max_degradation(struct map_ent *map, struct map_ent
}
close(afd);
}
- return (max_degraded);
+ return max_degraded;
}
static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
--
2.13.6
++++++ 0116-sysfs-sysfs_read-Count-active_disks-and-failed_disks.patch ++++++
From 64ec81da7a70adcdc0dbccaacc69aaf90edb4011 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 5 May 2017 11:51:43 -0400
Subject: [PATCH] sysfs/sysfs_read: Count active_disks and failed_disks
Git-commit: 64ec81da7a70adcdc0dbccaacc69aaf90edb4011
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Cound active_disks as drives mark 'in_sync' and failed_disks as
disks marked 'faulty', in the same way ioctl(GET_ARRAY_INFO) does.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
sysfs.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sysfs.c b/sysfs.c
index aa30de5..f7967e8 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -270,6 +270,8 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
if (!dir)
goto abort;
sra->array.spare_disks = 0;
+ sra->array.active_disks = 0;
+ sra->array.failed_disks = 0;
devp = &sra->devs;
sra->devs = NULL;
@@ -356,10 +358,14 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
strcpy(dbase, "state");
if (load_sys(fname, buf, sizeof(buf)))
goto abort;
- if (strstr(buf, "in_sync"))
+ if (strstr(buf, "in_sync")) {
dev->disk.state |= (1<array.active_disks++;
+ }
+ if (strstr(buf, "faulty")) {
dev->disk.state |= (1<array.failed_disks++;
+ }
if (dev->disk.state == 0)
sra->array.spare_disks++;
}
--
2.13.6
++++++ 0117-container_members_max_degradation-Switch-to-using-sy.patch ++++++
From 74d293a2535ef8726a9d43577dad4a908f471a0e Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 5 May 2017 12:06:57 -0400
Subject: [PATCH] container_members_max_degradation: Switch to using syfs for
disk info
Git-commit: 74d293a2535ef8726a9d43577dad4a908f471a0e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
With sysfs now providing the necessary active_disks info, switch to
sysfs and eliminate one more use of md_get_array_info(). We can do
this unconditionally since we wouldn't get here witout sysfs being
available.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index c00a43d..b73eabd 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -802,27 +802,27 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
}
/* test if container has degraded member(s) */
-static int container_members_max_degradation(struct map_ent *map, struct map_ent *me)
+static int
+container_members_max_degradation(struct map_ent *map, struct map_ent *me)
{
- mdu_array_info_t array;
- int afd;
- int max_degraded = 0;
+ struct mdinfo *sra;
+ int degraded, max_degraded = 0;
for(; map; map = map->next) {
if (!metadata_container_matches(map->metadata, me->devnm))
continue;
- afd = open_dev(map->devnm);
- if (afd < 0)
- continue;
/* most accurate information regarding array degradation */
- if (md_get_array_info(afd, &array) >= 0) {
- int degraded = array.raid_disks - array.active_disks -
- array.spare_disks;
- if (degraded > max_degraded)
- max_degraded = degraded;
- }
- close(afd);
+ sra = sysfs_read(-1, map->devnm,
+ GET_DISKS | GET_DEVS | GET_STATE);
+ if (!sra)
+ continue;
+ degraded = sra->array.raid_disks - sra->array.active_disks -
+ sra->array.spare_disks;
+ if (degraded > max_degraded)
+ max_degraded = degraded;
+ sysfs_free(sra);
}
+
return max_degraded;
}
--
2.13.6
++++++ 0118-IncrementalScan-Use-md_array_active-instead-of-md_ge.patch ++++++
From 00e56fd9537e1f69583d8b0f60faf02026f24d1b Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 5 May 2017 12:18:29 -0400
Subject: [PATCH] IncrementalScan: Use md_array_active() instead of
md_get_array_info()
Git-commit: 00e56fd9537e1f69583d8b0f60faf02026f24d1b
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This eliminates yet another case where GET_ARRAY_INFO was used to
indicate whether the array was active.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index b73eabd..680d318 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1317,7 +1317,6 @@ int IncrementalScan(struct context *c, char *devnm)
restart:
for (me = mapl ; me ; me = me->next) {
- mdu_array_info_t array;
struct mdinfo *sra;
int mdfd;
@@ -1362,7 +1361,7 @@ restart:
rv = 1;
continue;
}
- if (md_get_array_info(mdfd, &array) == 0 || errno != ENODEV) {
+ if (md_array_active(mdfd)) {
close(mdfd);
continue;
}
--
2.13.6
++++++ 0119-Mention-endian-in-documentation-for-update-byte-orde.patch ++++++
From 4224685fe9baf1df4c42bcb950c9a593efa0585f Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Mon, 8 May 2017 09:40:09 +1000
Subject: [PATCH] Mention "endian" in documentation for --update=byte-order
Git-commit: 4224685fe9baf1df4c42bcb950c9a593efa0585f
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This makes it easier to find as "endian" is a commonly used term.
Reported-by: Trevor Cordes
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.8.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mdadm.8.in b/mdadm.8.in
index fb99a5c..388e0ed 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -1264,7 +1264,8 @@ is correct.
The
.B byteorder
option allows arrays to be moved between machines with different
-byte-order.
+byte-order, such as from a big-endian machine like a Sparc or some
+MIPS machines, to a little-endian x86_64 machine.
When assembling such an array for the first time after a move, giving
.B "\-\-update=byteorder"
will cause
--
2.13.6
++++++ 0120-Monitor-Use-md_array_active-instead-of-manually-fidd.patch ++++++
From b9a0309c7fc3e6c1607d51ab3c3f8486478a65ef Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Mon, 8 May 2017 17:34:08 -0400
Subject: [PATCH] Monitor: Use md_array_active() instead of manually fiddling
in sysfs
Git-commit: b9a0309c7fc3e6c1607d51ab3c3f8486478a65ef
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This removes a pile of clutter that can easily behandled with a simple
check of array_state.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index e2b36ff..b5231d2 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -454,7 +454,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
mdu_array_info_t array;
struct mdstat_ent *mse = NULL, *mse2;
char *dev = st->devname;
- int fd = -1;
+ int fd;
int i;
int remaining_disks;
int last_disk;
@@ -462,33 +462,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (test)
alert("TestMessage", dev, NULL, ainfo);
- if (st->devnm[0])
- fd = open("/sys/block", O_RDONLY|O_DIRECTORY);
- if (fd >= 0) {
- /* Don't open the device unless it is present and
- * active in sysfs.
- */
- char buf[10];
- close(fd);
- fd = sysfs_open(st->devnm, NULL, "array_state");
- if (fd < 0 ||
- read(fd, buf, 10) < 5 ||
- strncmp(buf,"clear",5) == 0 ||
- strncmp(buf,"inact",5) == 0) {
- if (fd >= 0)
- close(fd);
- fd = sysfs_open(st->devnm, NULL, "level");
- if (fd < 0 || read(fd, buf, 10) != 0) {
- if (fd >= 0)
- close(fd);
- if (!st->err)
- alert("DeviceDisappeared", dev, NULL, ainfo);
- st->err++;
- return 0;
- }
- }
- close(fd);
- }
+
fd = open(dev, O_RDONLY);
if (fd < 0) {
if (!st->err)
@@ -496,6 +470,15 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->err++;
return 0;
}
+
+ if (!md_array_active(fd)) {
+ close(fd);
+ if (!st->err)
+ alert("DeviceDisappeared", dev, NULL, ainfo);
+ st->err++;
+ return 0;
+ }
+
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (md_get_array_info(fd, &array) < 0) {
if (!st->err)
--
2.13.6
++++++ 0121-Monitor-Code-is-80-characters-per-line.patch ++++++
From f27904a53b586e5507b442d7f321177e3dfb5a1a Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Mon, 8 May 2017 17:52:10 -0400
Subject: [PATCH] Monitor: Code is 80 characters per line
Git-commit: f27904a53b586e5507b442d7f321177e3dfb5a1a
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Fix up some lines that are too long for no reason, and some that have
silly line breaks.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 61 +++++++++++++++++++++++++++----------------------------------
1 file changed, 27 insertions(+), 34 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index b5231d2..ec643d4 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -527,13 +527,10 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
alert("NewArray", st->devname, NULL, ainfo);
}
- if (st->utime == array.utime &&
- st->failed == array.failed_disks &&
+ if (st->utime == array.utime && st->failed == array.failed_disks &&
st->working == array.working_disks &&
st->spare == array.spare_disks &&
- (mse == NULL || (
- mse->percent == st->percent
- ))) {
+ (mse == NULL || (mse->percent == st->percent))) {
close(fd);
if ((st->active < st->raid) && st->spare == 0)
return 1;
@@ -541,32 +538,33 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
return 0;
}
if (st->utime == 0 && /* new array */
- mse->pattern && strchr(mse->pattern, '_') /* degraded */
- )
+ mse->pattern && strchr(mse->pattern, '_') /* degraded */)
alert("DegradedArray", dev, NULL, ainfo);
if (st->utime == 0 && /* new array */
- st->expected_spares > 0 &&
- array.spare_disks < st->expected_spares)
+ st->expected_spares > 0 && array.spare_disks < st->expected_spares)
alert("SparesMissing", dev, NULL, ainfo);
if (st->percent < 0 && st->percent != RESYNC_UNKNOWN &&
mse->percent >= 0)
alert("RebuildStarted", dev, NULL, ainfo);
- if (st->percent >= 0 &&
- mse->percent >= 0 &&
+ if (st->percent >= 0 && mse->percent >= 0 &&
(mse->percent / increments) > (st->percent / increments)) {
- char percentalert[15]; // "RebuildNN" (10 chars) or "RebuildStarted" (15 chars)
+ char percentalert[15];
+ /*
+ * "RebuildNN" (10 chars) or "RebuildStarted" (15 chars)
+ */
if((mse->percent / increments) == 0)
- snprintf(percentalert, sizeof(percentalert), "RebuildStarted");
+ snprintf(percentalert, sizeof(percentalert),
+ "RebuildStarted");
else
- snprintf(percentalert, sizeof(percentalert), "Rebuild%02d", mse->percent);
+ snprintf(percentalert, sizeof(percentalert),
+ "Rebuild%02d", mse->percent);
alert(percentalert, dev, NULL, ainfo);
}
- if (mse->percent == RESYNC_NONE &&
- st->percent >= 0) {
+ if (mse->percent == RESYNC_NONE && st->percent >= 0) {
/* Rebuild/sync/whatever just finished.
* If there is a number in /mismatch_cnt,
* we should report that.
@@ -587,8 +585,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->percent = mse->percent;
remaining_disks = array.nr_disks;
- for (i=0; i 0;
- i++) {
+ for (i = 0; i < MAX_DISKS && remaining_disks > 0; i++) {
mdu_disk_info_t disc;
disc.number = i;
if (md_get_disk_info(fd, &disc) >= 0) {
@@ -606,15 +603,13 @@ 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);
+ strcpy(st->parent_devnm, mse->metadata_version+10);
sl = strchr(st->parent_devnm, '/');
if (sl)
*sl = 0;
} else
st->parent_devnm[0] = 0;
- if (st->metadata == NULL &&
- st->parent_devnm[0] == 0)
+ if (st->metadata == NULL && st->parent_devnm[0] == 0)
st->metadata = super_by_fd(fd, NULL);
close(fd);
@@ -625,12 +620,10 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int change;
char *dv = NULL;
disc.number = i;
- if (i < last_disk &&
- (info[i].major || info[i].minor)) {
+ if (i < last_disk && (info[i].major || info[i].minor)) {
newstate = info[i].state;
- dv = map_dev_preferred(
- info[i].major, info[i].minor, 1,
- prefer);
+ dv = map_dev_preferred(info[i].major, info[i].minor, 1,
+ prefer);
disc.state = newstate;
disc.major = info[i].major;
disc.minor = info[i].minor;
@@ -638,18 +631,18 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
newstate = (1 << MD_DISK_REMOVED);
if (dv == NULL && st->devid[i])
- dv = map_dev_preferred(
- major(st->devid[i]),
- minor(st->devid[i]), 1, prefer);
+ dv = map_dev_preferred(major(st->devid[i]),
+ minor(st->devid[i]), 1, prefer);
change = newstate ^ st->devstate[i];
if (st->utime && change && !st->err && !new_array) {
- if ((st->devstate[i]&change)&(1<devstate[i]&change) & (1 << MD_DISK_SYNC))
alert("Fail", dev, dv, ainfo);
- else if ((newstate & (1<devid[i] == makedev(disc.major, disc.minor))
+ st->devid[i] == makedev(disc.major,
+ disc.minor))
alert("FailSpare", dev, dv, ainfo);
- else if ((newstate&change)&(1<devstate[i] = newstate;
--
2.13.6
++++++ 0122-mdadm-md.4-set-page-length-as-1000-to-avoid-warnings.patch ++++++
From 17645275ca30a8ca8024f03672aae45d455bbc4b Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Tue, 9 May 2017 14:25:17 +0800
Subject: [PATCH] mdadm/md.4: set page-length as 1000 to avoid warnings from
grotty
Git-commit: 17645275ca30a8ca8024f03672aae45d455bbc4b
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
"nroff" ("man") or ("tbl") needs a long page to avoid warnings
from "grotty", set 'pl' as 1000 to fix the following issue.
This command invokes by Makefile rule.
linux-tjrh:~/mdadm # man -l md.4 > test
grotty:<standard input> (<standard input>):5967:
character above first line discarded
... ...
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
md.4 | 1 +
1 file changed, 1 insertion(+)
diff --git a/md.4 b/md.4
index 5bdf7a7..3a1d677 100644
--- a/md.4
+++ b/md.4
@@ -4,6 +4,7 @@
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\" See file COPYING in distribution for details.
+.if n .pl 1000v
.TH MD 4
.SH NAME
md \- Multiple Device driver aka Linux Software RAID
--
2.13.6
++++++ 0055-Allow-more-spare-selection-criteria.patch -> 0123-Allow-more-spare-selection-criteria.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0055-Allow-more-spare-selection-criteria.patch 2017-08-24 18:18:07.415077886 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0123-Allow-more-spare-selection-criteria.patch 2017-12-08 12:54:40.787553676 +0100
@@ -2,6 +2,9 @@
From: Alexey Obitotskiy
Date: Tue, 9 May 2017 12:25:46 +0200
Subject: [PATCH] Allow more spare selection criteria
+Git-commit: fbfdcb06dc5b1dcb227b0394f174faa2df734700
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Disks can be moved across containers in order to be used as a spare
drive for reubild. At the moment the only requirement checked for such
@@ -14,6 +17,8 @@
Signed-off-by: Alexey Obitotskiy
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Incremental.c | 18 +++++++++++-------
Monitor.c | 30 ++++++++++++++++--------------
@@ -22,11 +27,11 @@
util.c | 6 +++---
5 files changed, 62 insertions(+), 41 deletions(-)
-Index: mdadm/Incremental.c
-===================================================================
---- mdadm.orig/Incremental.c
-+++ mdadm/Incremental.c
-@@ -889,7 +889,7 @@ static int array_try_spare(char *devname
+diff --git a/Incremental.c b/Incremental.c
+index 680d318..fe9d644 100644
+--- a/Incremental.c
++++ b/Incremental.c
+@@ -867,7 +867,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
struct domainlist *dl = NULL;
struct mdinfo *sra;
unsigned long long devsize;
@@ -35,7 +40,7 @@
if (is_subarray(mp->metadata))
continue;
-@@ -958,7 +958,8 @@ static int array_try_spare(char *devname
+@@ -936,7 +936,8 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
}
if (st3->ss->load_container &&
!st3->ss->load_container(st3, mdfd, mp->path)) {
@@ -45,19 +50,16 @@
st3->ss->free_super(st3);
}
free(st3);
-@@ -969,9 +970,8 @@ static int array_try_spare(char *devname
- sra->devs
- ? sra->devs->data_offset
- : INVALID_SECTORS)
-- < sra->component_size)
-- ||
+@@ -947,7 +948,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
+ sra->devs ? sra->devs->data_offset :
+ INVALID_SECTORS) <
+ sra->component_size) ||
- (sra->component_size == 0 && devsize < component_size)) {
-+ < sra->component_size) ||
+ (sra->component_size == 0 && devsize < sc.min_size)) {
if (verbose > 1)
pr_err("not adding %s to %s as it is too small\n",
devname, mp->path);
-@@ -1655,12 +1655,15 @@ static int Incremental_container(struct
+@@ -1624,12 +1625,15 @@ static int Incremental_container(struct supertype *st, char *devname,
struct supertype *sst =
super_imsm.match_metadata_desc("imsm");
struct mdinfo *sinfo;
@@ -77,11 +79,11 @@
domains, NULL,
st->ss->name, 0);
sst->ss->free_super(sst);
-Index: mdadm/Monitor.c
-===================================================================
---- mdadm.orig/Monitor.c
-+++ mdadm/Monitor.c
-@@ -746,13 +746,14 @@ static int add_new_arrays(struct mdstat_
+diff --git a/Monitor.c b/Monitor.c
+index ec643d4..9a2baad 100644
+--- a/Monitor.c
++++ b/Monitor.c
+@@ -723,13 +723,14 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
return new_found;
}
@@ -99,7 +101,7 @@
return 0;
}
-@@ -766,7 +767,8 @@ static int get_min_spare_size_required(s
+@@ -743,7 +744,8 @@ static int get_min_spare_size_required(struct state *st, unsigned long long *siz
close(fd);
if (!st->metadata->sb)
return 1;
@@ -109,7 +111,7 @@
st->metadata->ss->free_super(st->metadata);
return 0;
-@@ -798,7 +800,7 @@ static int check_donor(struct state *fro
+@@ -775,7 +777,7 @@ static int check_donor(struct state *from, struct state *to)
}
static dev_t choose_spare(struct state *from, struct state *to,
@@ -118,7 +120,7 @@
{
int d;
dev_t dev = 0;
-@@ -813,9 +815,9 @@ static dev_t choose_spare(struct state *
+@@ -790,9 +792,9 @@ static dev_t choose_spare(struct state *from, struct state *to,
test_partition_from_id(from->devid[d]))
continue;
@@ -130,7 +132,7 @@
continue;
pol = devid_policy(from->devid[d]);
-@@ -832,7 +834,7 @@ static dev_t choose_spare(struct state *
+@@ -809,7 +811,7 @@ static dev_t choose_spare(struct state *from, struct state *to,
static dev_t container_choose_spare(struct state *from, struct state *to,
struct domainlist *domlist,
@@ -139,7 +141,7 @@
{
/* This is similar to choose_spare, but we cannot trust devstate,
* so we need to read the metadata instead
-@@ -883,7 +885,7 @@ static dev_t container_choose_spare(stru
+@@ -860,7 +862,7 @@ static dev_t container_choose_spare(struct state *from, struct state *to,
}
/* We only need one spare so full list not needed */
@@ -148,7 +150,7 @@
to->metadata->ss->name, 1);
if (list) {
struct mdinfo *disks = list->devs;
-@@ -899,6 +901,7 @@ static void try_spare_migration(struct s
+@@ -876,6 +878,7 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
{
struct state *from;
struct state *st;
@@ -156,7 +158,7 @@
link_containers_with_subarrays(statelist);
for (st = statelist; st; st = st->next)
-@@ -907,7 +910,6 @@ static void try_spare_migration(struct s
+@@ -884,7 +887,6 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
struct domainlist *domlist = NULL;
int d;
struct state *to = st;
@@ -164,7 +166,7 @@
if (to->parent_devnm[0] && !to->parent)
/* subarray monitored without parent container
-@@ -918,14 +920,14 @@ static void try_spare_migration(struct s
+@@ -895,14 +897,14 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
/* member of a container */
to = to->parent;
@@ -181,7 +183,7 @@
if (devid > 0)
continue;
}
-@@ -948,10 +950,10 @@ static void try_spare_migration(struct s
+@@ -925,10 +927,10 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
continue;
if (from->metadata->ss->external)
devid = container_choose_spare(
@@ -194,11 +196,11 @@
if (devid > 0
&& move_spare(from->devname, to->devname, devid)) {
alert("MoveSpare", to->devname, from->devname, info);
-Index: mdadm/mdadm.h
-===================================================================
---- mdadm.orig/mdadm.h
-+++ mdadm/mdadm.h
-@@ -351,6 +351,10 @@ struct createinfo {
+diff --git a/mdadm.h b/mdadm.h
+index a92feb2..8da7fd3 100644
+--- a/mdadm.h
++++ b/mdadm.h
+@@ -361,6 +361,10 @@ struct createinfo {
struct supertype *supertype;
};
@@ -209,7 +211,7 @@
enum mode {
ASSEMBLE=1,
BUILD,
-@@ -929,11 +933,13 @@ extern struct superswitch {
+@@ -940,11 +944,13 @@ extern struct superswitch {
*/
__u64 (*avail_size)(struct supertype *st, __u64 size,
unsigned long long data_offset);
@@ -227,7 +229,7 @@
/* Find somewhere to put a bitmap - possibly auto-size it - and
* update the metadata to record this. The array may be newly
* created, in which case data_size may be updated, or it might
-@@ -1491,7 +1497,7 @@ extern int assemble_container_content(st
+@@ -1507,7 +1513,7 @@ extern int assemble_container_content(struct supertype *st, int mdfd,
#define INCR_ALREADY 4
#define INCR_YES 8
extern struct mdinfo *container_choose_spares(struct supertype *st,
@@ -236,11 +238,11 @@
struct domainlist *domlist,
char *spare_group,
const char *metadata, int get_one);
-Index: mdadm/super-intel.c
-===================================================================
---- mdadm.orig/super-intel.c
-+++ mdadm/super-intel.c
-@@ -1386,37 +1386,44 @@ static __u32 imsm_min_reserved_sectors(s
+diff --git a/super-intel.c b/super-intel.c
+index e88fe82..be973f8 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -1383,37 +1383,44 @@ static __u32 imsm_min_reserved_sectors(struct intel_super *super)
return (remainder < rv) ? remainder : rv;
}
@@ -294,7 +296,7 @@
}
static int is_gen_migration(struct imsm_dev *dev);
-@@ -10868,8 +10875,10 @@ static int imsm_reshape_is_allowed_on_co
+@@ -10817,8 +10824,10 @@ static int imsm_reshape_is_allowed_on_container(struct supertype *st,
*/
static struct mdinfo *get_spares_for_grow(struct supertype *st)
{
@@ -307,7 +309,7 @@
}
/******************************************************************************
-@@ -11908,7 +11917,7 @@ struct superswitch super_imsm = {
+@@ -11853,7 +11862,7 @@ struct superswitch super_imsm = {
.update_super = update_super_imsm,
.avail_size = avail_size_imsm,
@@ -316,11 +318,11 @@
.compare_super = compare_super_imsm,
-Index: mdadm/util.c
-===================================================================
---- mdadm.orig/util.c
-+++ mdadm/util.c
-@@ -2083,7 +2083,7 @@ int experimental(void)
+diff --git a/util.c b/util.c
+index 11ff2cc..8b3c67d 100644
+--- a/util.c
++++ b/util.c
+@@ -2107,7 +2107,7 @@ int experimental(void)
* if spare_group given add it to domains of each spare
* metadata allows to test domains using metadata of destination array */
struct mdinfo *container_choose_spares(struct supertype *st,
@@ -329,7 +331,7 @@
struct domainlist *domlist,
char *spare_group,
const char *metadata, int get_one)
-@@ -2107,9 +2107,9 @@ struct mdinfo *container_choose_spares(s
+@@ -2131,9 +2131,9 @@ struct mdinfo *container_choose_spares(struct supertype *st,
unsigned long long dev_size;
dev_t dev = makedev(d->disk.major,d->disk.minor);
@@ -341,3 +343,6 @@
found = 1;
/* check if domain matches */
if (found && domlist) {
+--
+2.13.6
+
++++++ 0056-Add-sector-size-as-spare-selection-criterion.patch -> 0124-Add-sector-size-as-spare-selection-criterion.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0056-Add-sector-size-as-spare-selection-criterion.patch 2017-08-24 18:18:07.447073381 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0124-Add-sector-size-as-spare-selection-criterion.patch 2017-12-08 12:54:40.807552954 +0100
@@ -2,6 +2,9 @@
From: Alexey Obitotskiy
Date: Tue, 9 May 2017 12:25:47 +0200
Subject: [PATCH] Add sector size as spare selection criterion
+Git-commit: 4b57ecf6cea134edff75a2f3a87ee48d52715c70
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
Add sector size as new spare selection criterion. Assume that 0 means
there is no requirement for the sector size in the array. Skip disks
@@ -11,6 +14,8 @@
Signed-off-by: Alexey Obitotskiy
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Incremental.c | 4 ++--
Monitor.c | 8 ++++++++
++++++ 0125-Monitor-check_array-Centralize-exit-path.patch ++++++
From 1830e74b4cbde28279f341bc80b68e9d82df32c6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:25:23 -0400
Subject: [PATCH] Monitor/check_array: Centralize exit path
Git-commit: 1830e74b4cbde28279f341bc80b68e9d82df32c6
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Improve exit handling to make it easier to share error handling and free
sysfs entries later.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index c96f8e8..f404009 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -459,16 +459,19 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int remaining_disks;
int last_disk;
int new_array = 0;
+ int retval;
if (test)
alert("TestMessage", dev, NULL, ainfo);
+ retval = 0;
+
fd = open(dev, O_RDONLY);
if (fd < 0) {
if (!st->err)
alert("DeviceDisappeared", dev, NULL, ainfo);
st->err++;
- return 0;
+ goto out;
}
if (!md_array_active(fd)) {
@@ -476,7 +479,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (!st->err)
alert("DeviceDisappeared", dev, NULL, ainfo);
st->err++;
- return 0;
+ goto out;
}
fcntl(fd, F_SETFD, FD_CLOEXEC);
@@ -485,7 +488,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
alert("DeviceDisappeared", dev, NULL, ainfo);
st->err++;
close(fd);
- return 0;
+ goto out;
}
/* It's much easier to list what array levels can't
* have a device disappear than all of them that can
@@ -495,7 +498,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
alert("DeviceDisappeared", dev, " Wrong-Level", ainfo);
st->err++;
close(fd);
- return 0;
+ goto out;
}
if (st->devnm[0] == 0)
strcpy(st->devnm, fd2devnm(fd));
@@ -511,7 +514,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
* or re-created after reading mdstat*/
st->err++;
close(fd);
- return 0;
+ goto out;
}
/* this array is in /proc/mdstat */
if (array.utime == 0)
@@ -533,9 +536,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
(mse == NULL || (mse->percent == st->percent))) {
close(fd);
if ((st->active < st->raid) && st->spare == 0)
- return 1;
- else
- return 0;
+ retval = 1;
+ goto out;
}
if (st->utime == 0 && /* new array */
mse->pattern && strchr(mse->pattern, '_') /* degraded */)
@@ -656,8 +658,10 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->raid = array.raid_disks;
st->err = 0;
if ((st->active < st->raid) && st->spare == 0)
- return 1;
- return 0;
+ retval = 1;
+
+ out:
+ return retval;
}
static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
--
2.13.6
++++++ 0126-Monitor-check_array-Reduce-duplicated-error-handling.patch ++++++
From 13e5d8455c22d4db420ead9fde3ee0c1536b73a3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:38:06 -0400
Subject: [PATCH] Monitor/check_array: Reduce duplicated error handling
Git-commit: 13e5d8455c22d4db420ead9fde3ee0c1536b73a3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Avoid closing fd in multiple places, and duplicating the error message
for when a device disappeared.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index f404009..c519877 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -467,29 +467,16 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
retval = 0;
fd = open(dev, O_RDONLY);
- if (fd < 0) {
- if (!st->err)
- alert("DeviceDisappeared", dev, NULL, ainfo);
- st->err++;
- goto out;
- }
+ if (fd < 0)
+ goto disappeared;
- if (!md_array_active(fd)) {
- close(fd);
- if (!st->err)
- alert("DeviceDisappeared", dev, NULL, ainfo);
- st->err++;
- goto out;
- }
+ if (!md_array_active(fd))
+ goto disappeared;
fcntl(fd, F_SETFD, FD_CLOEXEC);
- if (md_get_array_info(fd, &array) < 0) {
- if (!st->err)
- alert("DeviceDisappeared", dev, NULL, ainfo);
- st->err++;
- close(fd);
- goto out;
- }
+ if (md_get_array_info(fd, &array) < 0)
+ goto disappeared;
+
/* It's much easier to list what array levels can't
* have a device disappear than all of them that can
*/
@@ -497,7 +484,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (!st->err && !st->from_config)
alert("DeviceDisappeared", dev, " Wrong-Level", ainfo);
st->err++;
- close(fd);
goto out;
}
if (st->devnm[0] == 0)
@@ -534,7 +520,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->working == array.working_disks &&
st->spare == array.spare_disks &&
(mse == NULL || (mse->percent == st->percent))) {
- close(fd);
if ((st->active < st->raid) && st->spare == 0)
retval = 1;
goto out;
@@ -614,8 +599,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->metadata == NULL && st->parent_devnm[0] == 0)
st->metadata = super_by_fd(fd, NULL);
- close(fd);
-
for (i=0; i 0)
+ close(fd);
return retval;
+
+ disappeared:
+ if (!st->err)
+ alert("DeviceDisappeared", dev, NULL, ainfo);
+ st->err++;
+ goto out;
}
static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
--
2.13.6
++++++ 0127-Monitor-check_array-Declate-mdinfo-instance-globally.patch ++++++
From 826522f0dc86d31cc7207b01957b5c4243f49dc8 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:41:06 -0400
Subject: [PATCH] Monitor/check_array: Declate mdinfo instance globally
Git-commit: 826522f0dc86d31cc7207b01957b5c4243f49dc8
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
We can pull in more information from sysfs earlier, so move sra to the top.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index c519877..bb3a2c4 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -451,6 +451,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
* '1' if the array is degraded, or '0' if it is optimal (or dead).
*/
struct { int state, major, minor; } info[MAX_DISKS];
+ struct mdinfo *sra;
mdu_array_info_t array;
struct mdstat_ent *mse = NULL, *mse2;
char *dev = st->devname;
@@ -556,8 +557,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
* If there is a number in /mismatch_cnt,
* we should report that.
*/
- struct mdinfo *sra =
- sysfs_read(-1, st->devnm, GET_MISMATCH);
+ sra = sysfs_read(-1, st->devnm, GET_MISMATCH);
if (sra && sra->mismatch_cnt > 0) {
char cnt[80];
snprintf(cnt, sizeof(cnt),
--
2.13.6
++++++ 0128-Monitor-check_array-Read-sysfs-entry-earlier.patch ++++++
From aed5f5c34c2b248876b874898d0b3bf65b6cca53 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:49:33 -0400
Subject: [PATCH] Monitor/check_array: Read sysfs entry earlier
Git-commit: aed5f5c34c2b248876b874898d0b3bf65b6cca53
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This will allow us to pull additional info from sysfs, such as level
and device info.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index bb3a2c4..75aea91 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -451,7 +451,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
* '1' if the array is degraded, or '0' if it is optimal (or dead).
*/
struct { int state, major, minor; } info[MAX_DISKS];
- struct mdinfo *sra;
+ struct mdinfo *sra = NULL;
mdu_array_info_t array;
struct mdstat_ent *mse = NULL, *mse2;
char *dev = st->devname;
@@ -478,6 +478,13 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (md_get_array_info(fd, &array) < 0)
goto disappeared;
+ if (st->devnm[0] == 0)
+ strcpy(st->devnm, fd2devnm(fd));
+
+ sra = sysfs_read(-1, st->devnm, GET_MISMATCH);
+ if (!sra)
+ goto disappeared;
+
/* It's much easier to list what array levels can't
* have a device disappear than all of them that can
*/
@@ -487,8 +494,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->err++;
goto out;
}
- if (st->devnm[0] == 0)
- strcpy(st->devnm, fd2devnm(fd));
for (mse2 = mdstat ; mse2 ; mse2=mse2->next)
if (strcmp(mse2->devnm, st->devnm) == 0) {
@@ -557,7 +562,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
* If there is a number in /mismatch_cnt,
* we should report that.
*/
- sra = sysfs_read(-1, st->devnm, GET_MISMATCH);
if (sra && sra->mismatch_cnt > 0) {
char cnt[80];
snprintf(cnt, sizeof(cnt),
@@ -566,8 +570,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
alert("RebuildFinished", dev, cnt, ainfo);
} else
alert("RebuildFinished", dev, NULL, ainfo);
- if (sra)
- sysfs_free(sra);
}
st->percent = mse->percent;
@@ -644,6 +646,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
retval = 1;
out:
+ if (sra)
+ sysfs_free(sra);
if (fd > 0)
close(fd);
return retval;
--
2.13.6
++++++ 0129-Monitor-check_array-Obtain-RAID-level-from-syfs.patch ++++++
From 48bc2ade86db576036375184774a3ebadf6a22e3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:52:44 -0400
Subject: [PATCH] Monitor/check_array: Obtain RAID level from syfs
Git-commit: 48bc2ade86db576036375184774a3ebadf6a22e3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 75aea91..b94fd7c 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -481,14 +481,14 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->devnm[0] == 0)
strcpy(st->devnm, fd2devnm(fd));
- sra = sysfs_read(-1, st->devnm, GET_MISMATCH);
+ sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_MISMATCH);
if (!sra)
goto disappeared;
/* It's much easier to list what array levels can't
* have a device disappear than all of them that can
*/
- if (array.level == 0 || array.level == -1) {
+ if (sra->array.level == 0 || sra->array.level == -1) {
if (!st->err && !st->from_config)
alert("DeviceDisappeared", dev, " Wrong-Level", ainfo);
st->err++;
@@ -566,7 +566,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
char cnt[80];
snprintf(cnt, sizeof(cnt),
" mismatches found: %d (on raid level %d)",
- sra->mismatch_cnt, array.level);
+ sra->mismatch_cnt, sra->array.level);
alert("RebuildFinished", dev, cnt, ainfo);
} else
alert("RebuildFinished", dev, NULL, ainfo);
--
2.13.6
++++++ 0130-Monitor-check_array-Get-failed_disks-from-sysfs.patch ++++++
From b8e5713c74901862b96bf599ab6fd227addc1498 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:54:19 -0400
Subject: [PATCH] Monitor/check_array: Get 'failed_disks' from sysfs
Git-commit: b8e5713c74901862b96bf599ab6fd227addc1498
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index b94fd7c..9456efd 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -481,7 +481,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->devnm[0] == 0)
strcpy(st->devnm, fd2devnm(fd));
- sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_MISMATCH);
+ sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DEGRADED |
+ GET_MISMATCH);
if (!sra)
goto disappeared;
@@ -522,7 +523,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
alert("NewArray", st->devname, NULL, ainfo);
}
- if (st->utime == array.utime && st->failed == array.failed_disks &&
+ if (st->utime == array.utime && st->failed == sra->array.failed_disks &&
st->working == array.working_disks &&
st->spare == array.spare_disks &&
(mse == NULL || (mse->percent == st->percent))) {
@@ -638,7 +639,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->active = array.active_disks;
st->working = array.working_disks;
st->spare = array.spare_disks;
- st->failed = array.failed_disks;
+ st->failed = sra->array.failed_disks;
st->utime = array.utime;
st->raid = array.raid_disks;
st->err = 0;
--
2.13.6
++++++ 0131-Monitor-check_array-Get-array_disks-from-sysfs.patch ++++++
From 12a9d21f4e9fd4d3a14129407f1e8da6d6444cd6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 16:58:55 -0400
Subject: [PATCH] Monitor/check_array: Get array_disks from sysfs
Git-commit: 12a9d21f4e9fd4d3a14129407f1e8da6d6444cd6
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 9456efd..fe6f2b4 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -481,7 +481,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->devnm[0] == 0)
strcpy(st->devnm, fd2devnm(fd));
- sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DEGRADED |
+ sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEGRADED |
GET_MISMATCH);
if (!sra)
goto disappeared;
@@ -641,7 +641,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->spare = array.spare_disks;
st->failed = sra->array.failed_disks;
st->utime = array.utime;
- st->raid = array.raid_disks;
+ st->raid = sra->array.raid_disks;
st->err = 0;
if ((st->active < st->raid) && st->spare == 0)
retval = 1;
--
2.13.6
++++++ 0132-Monitor-check_array-Get-nr_disks-active_disks-and-sp.patch ++++++
From b98943a4f889b466a3d07264068042b18c620d33 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 17:03:03 -0400
Subject: [PATCH] Monitor/check_array: Get nr_disks, active_disks and
spare_disks from sysfs
Git-commit: b98943a4f889b466a3d07264068042b18c620d33
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This leaves working_disks and utime missing before we can eliminate
check_array()'s call to md_get_array_info()
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index fe6f2b4..2204528 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -482,7 +482,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
strcpy(st->devnm, fd2devnm(fd));
sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEGRADED |
- GET_MISMATCH);
+ GET_MISMATCH | GET_DEVS | GET_STATE);
if (!sra)
goto disappeared;
@@ -525,7 +525,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->utime == array.utime && st->failed == sra->array.failed_disks &&
st->working == array.working_disks &&
- st->spare == array.spare_disks &&
+ st->spare == sra->array.spare_disks &&
(mse == NULL || (mse->percent == st->percent))) {
if ((st->active < st->raid) && st->spare == 0)
retval = 1;
@@ -535,8 +535,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
mse->pattern && strchr(mse->pattern, '_') /* degraded */)
alert("DegradedArray", dev, NULL, ainfo);
- if (st->utime == 0 && /* new array */
- st->expected_spares > 0 && array.spare_disks < st->expected_spares)
+ if (st->utime == 0 && /* new array */ st->expected_spares > 0 &&
+ sra->array.spare_disks < st->expected_spares)
alert("SparesMissing", dev, NULL, ainfo);
if (st->percent < 0 && st->percent != RESYNC_UNKNOWN &&
mse->percent >= 0)
@@ -574,7 +574,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
}
st->percent = mse->percent;
- remaining_disks = array.nr_disks;
+ remaining_disks = sra->array.nr_disks;
for (i = 0; i < MAX_DISKS && remaining_disks > 0; i++) {
mdu_disk_info_t disc;
disc.number = i;
@@ -636,9 +636,9 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->devstate[i] = newstate;
st->devid[i] = makedev(disc.major, disc.minor);
}
- st->active = array.active_disks;
+ st->active = sra->array.active_disks;
st->working = array.working_disks;
- st->spare = array.spare_disks;
+ st->spare = sra->array.spare_disks;
st->failed = sra->array.failed_disks;
st->utime = array.utime;
st->raid = sra->array.raid_disks;
--
2.13.6
++++++ 0133-sysfs-sysfs_read-Count-working_disks.patch ++++++
From 8b0ebd645202b627982eb3ed9fc72583c4f245d3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 17:09:40 -0400
Subject: [PATCH] sysfs/sysfs_read: Count working_disks
Git-commit: 8b0ebd645202b627982eb3ed9fc72583c4f245d3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This counts working_disks the same way as get_array_info counts it in
the kernel.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
sysfs.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/sysfs.c b/sysfs.c
index f7967e8..e47f5e4 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -272,6 +272,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
sra->array.spare_disks = 0;
sra->array.active_disks = 0;
sra->array.failed_disks = 0;
+ sra->array.working_disks = 0;
devp = &sra->devs;
sra->devs = NULL;
@@ -358,16 +359,18 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
strcpy(dbase, "state");
if (load_sys(fname, buf, sizeof(buf)))
goto abort;
- if (strstr(buf, "in_sync")) {
- dev->disk.state |= (1<array.active_disks++;
- }
if (strstr(buf, "faulty")) {
dev->disk.state |= (1<array.failed_disks++;
+ } else {
+ sra->array.working_disks++;
+ if (strstr(buf, "in_sync")) {
+ dev->disk.state |= (1<array.active_disks++;
+ }
+ if (dev->disk.state == 0)
+ sra->array.spare_disks++;
}
- if (dev->disk.state == 0)
- sra->array.spare_disks++;
}
if (options & GET_ERROR) {
strcpy(buf, "errors");
--
2.13.6
++++++ 0134-Monitor-check_array-Use-working_disks-from-sysfs.patch ++++++
From e5eb6857cde0a6a44684dcc7ea0fb196546cf56c Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 9 May 2017 17:15:14 -0400
Subject: [PATCH] Monitor/check_array: Use working_disks from sysfs
Git-commit: e5eb6857cde0a6a44684dcc7ea0fb196546cf56c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
sysfs now provides working_disks information, so lets use it too.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 2204528..5b95847 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -524,7 +524,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
}
if (st->utime == array.utime && st->failed == sra->array.failed_disks &&
- st->working == array.working_disks &&
+ st->working == sra->array.working_disks &&
st->spare == sra->array.spare_disks &&
(mse == NULL || (mse->percent == st->percent))) {
if ((st->active < st->raid) && st->spare == 0)
@@ -637,7 +637,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
st->devid[i] = makedev(disc.major, disc.minor);
}
st->active = sra->array.active_disks;
- st->working = array.working_disks;
+ st->working = sra->array.working_disks;
st->spare = sra->array.spare_disks;
st->failed = sra->array.failed_disks;
st->utime = array.utime;
--
2.13.6
++++++ 0135-retire-the-APIs-that-driver-no-longer-supports.patch ++++++
From e644902ddbc66d58a3fd4353c9539276ee1fabd7 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Thu, 11 May 2017 16:52:41 +0800
Subject: [PATCH] retire the APIs that driver no longer supports
Git-commit: e644902ddbc66d58a3fd4353c9539276ee1fabd7
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
refer to commit: e6e5f8f1267d ("Build: Stop
bothering about supporting md driver ...")
continue to retire the APIs that md driver
wasn't supported for very long period of time.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Build.c | 4 ----
Manage.c | 4 ----
2 files changed, 8 deletions(-)
diff --git a/Build.c b/Build.c
index ad59867..70ba068 100644
--- a/Build.c
+++ b/Build.c
@@ -24,10 +24,6 @@
#include "mdadm.h"
-#define REGISTER_DEV _IO (MD_MAJOR, 1)
-#define START_MD _IO (MD_MAJOR, 2)
-#define STOP_MD _IO (MD_MAJOR, 3)
-
int Build(char *mddev, struct mddev_dev *devlist,
struct shape *s, struct context *c)
{
diff --git a/Manage.c b/Manage.c
index 14276b7..467efb7 100644
--- a/Manage.c
+++ b/Manage.c
@@ -27,10 +27,6 @@
#include "md_p.h"
#include
-#define REGISTER_DEV _IO (MD_MAJOR, 1)
-#define START_MD _IO (MD_MAJOR, 2)
-#define STOP_MD _IO (MD_MAJOR, 3)
-
int Manage_ro(char *devname, int fd, int readonly)
{
/* switch to readonly or rw
--
2.13.6
++++++ 0136-Monitor-Not-much-point-declaring-mdlist-in-both-fork.patch ++++++
From 9f3dd4549b2b904d343b79a8a7ba40c547e71d5d Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 11 May 2017 16:40:16 -0400
Subject: [PATCH] Monitor: Not much point declaring mdlist in both forks of the
if() statement
Git-commit: 9f3dd4549b2b904d343b79a8a7ba40c547e71d5d
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 5b95847..a4afe75 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -127,6 +127,7 @@ int Monitor(struct mddev_dev *devlist,
struct mdstat_ent *mdstat = NULL;
char *mailfrom = NULL;
struct alert_info info;
+ struct mddev_ident *mdlist;
if (!mailaddr) {
mailaddr = conf_get_mailaddr();
@@ -162,7 +163,7 @@ int Monitor(struct mddev_dev *devlist,
return 1;
if (devlist == NULL) {
- struct mddev_ident *mdlist = conf_get_ident(NULL);
+ mdlist = conf_get_ident(NULL);
for (; mdlist; mdlist=mdlist->next) {
struct state *st;
if (mdlist->devname == NULL)
@@ -189,8 +190,8 @@ int Monitor(struct mddev_dev *devlist,
} else {
struct mddev_dev *dv;
for (dv=devlist ; dv; dv=dv->next) {
- struct mddev_ident *mdlist = conf_get_ident(dv->devname);
struct state *st = xcalloc(1, sizeof *st);
+ mdlist = conf_get_ident(dv->devname);
st->devname = xstrdup(dv->devname);
st->next = statelist;
st->devnm[0] = 0;
--
2.13.6
++++++ 0137-Monitor-mailfrom-is-initialized-correctly.patch ++++++
From 72362f18aee5adedb405fe61c324604184d74555 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 11 May 2017 16:44:19 -0400
Subject: [PATCH] Monitor: mailfrom is initialized correctly
Git-commit: 72362f18aee5adedb405fe61c324604184d74555
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Remove gratituous variable initialization.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Monitor.c b/Monitor.c
index a4afe75..83a6d10 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -125,7 +125,7 @@ int Monitor(struct mddev_dev *devlist,
struct state *st2;
int finished = 0;
struct mdstat_ent *mdstat = NULL;
- char *mailfrom = NULL;
+ char *mailfrom;
struct alert_info info;
struct mddev_ident *mdlist;
--
2.13.6
++++++ 0138-Monitor-Fixup-a-pile-of-whitespace-issues.patch ++++++
From f566ef45d356f6dcd4ec54d294be8664770d8b84 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Thu, 11 May 2017 16:56:55 -0400
Subject: [PATCH] Monitor: Fixup a pile of whitespace issues
Git-commit: f566ef45d356f6dcd4ec54d294be8664770d8b84
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
No code was hurt in this event
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 110 +++++++++++++++++++++++++++++++-------------------------------
1 file changed, 55 insertions(+), 55 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 83a6d10..0198a34 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -139,7 +139,7 @@ int Monitor(struct mddev_dev *devlist,
if (!alert_cmd) {
alert_cmd = conf_get_program();
- if (alert_cmd && ! c->scan)
+ if (alert_cmd && !c->scan)
pr_err("Monitor using program \"%s\" from config file\n",
alert_cmd);
}
@@ -164,8 +164,9 @@ int Monitor(struct mddev_dev *devlist,
if (devlist == NULL) {
mdlist = conf_get_ident(NULL);
- for (; mdlist; mdlist=mdlist->next) {
+ for (; mdlist; mdlist = mdlist->next) {
struct state *st;
+
if (mdlist->devname == NULL)
continue;
if (strcasecmp(mdlist->devname, "<ignore>") == 0)
@@ -189,7 +190,8 @@ int Monitor(struct mddev_dev *devlist,
}
} else {
struct mddev_dev *dv;
- for (dv=devlist ; dv; dv=dv->next) {
+
+ for (dv = devlist; dv; dv = dv->next) {
struct state *st = xcalloc(1, sizeof *st);
mdlist = conf_get_ident(dv->devname);
st->devname = xstrdup(dv->devname);
@@ -206,18 +208,18 @@ int Monitor(struct mddev_dev *devlist,
}
}
- while (! finished) {
+ while (!finished) {
int new_found = 0;
struct state *st, **stp;
int anydegraded = 0;
if (mdstat)
free_mdstat(mdstat);
- mdstat = mdstat_read(oneshot?0:1, 0);
+ mdstat = mdstat_read(oneshot ? 0 : 1, 0);
if (!mdstat)
mdstat_close();
- 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;
@@ -291,8 +293,8 @@ static int make_daemon(char *pidfile)
}
close(0);
open("/dev/null", O_RDWR);
- dup2(0,1);
- dup2(0,2);
+ dup2(0, 1);
+ dup2(0, 2);
setsid();
return -1;
}
@@ -323,8 +325,7 @@ static int check_one_sharer(int scan)
fclose(fp);
}
if (scan) {
- if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
- errno != EEXIST) {
+ if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) {
pr_err("Can't create autorebuild.pid file\n");
} else {
fp = fopen(path, "w");
@@ -347,7 +348,8 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
if (!info->alert_cmd && !info->mailaddr && !info->dosyslog) {
time_t now = time(0);
- printf("%1.15s: %s on %s %s\n", ctime(&now)+4, event, dev, disc?disc:"unknown device");
+ printf("%1.15s: %s on %s %s\n", ctime(&now) + 4,
+ event, dev, disc?disc:"unknown device");
}
if (info->alert_cmd) {
int pid = fork();
@@ -363,11 +365,10 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
exit(2);
}
}
- if (info->mailaddr &&
- (strncmp(event, "Fail", 4)==0 ||
- strncmp(event, "Test", 4)==0 ||
- strncmp(event, "Spares", 6)==0 ||
- strncmp(event, "Degrade", 7)==0)) {
+ if (info->mailaddr && (strncmp(event, "Fail", 4) == 0 ||
+ strncmp(event, "Test", 4) == 0 ||
+ strncmp(event, "Spares", 6) == 0 ||
+ strncmp(event, "Degrade", 7) == 0)) {
FILE *mp = popen(Sendmail, "w");
if (mp) {
FILE *mdstat;
@@ -377,7 +378,8 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
if (info->mailfrom)
fprintf(mp, "From: %s\n", info->mailfrom);
else
- fprintf(mp, "From: %s monitoring <root>\n", Name);
+ fprintf(mp, "From: %s monitoring <root>\n",
+ Name);
fprintf(mp, "To: %s\n", info->mailaddr);
fprintf(mp, "Subject: %s event on %s:%s\n\n",
event, dev, hname);
@@ -403,8 +405,9 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
int n;
fprintf(mp,
"\nP.S. The /proc/mdstat file currently contains the following:\n\n");
- while ( (n=fread(buf, 1, sizeof(buf), mdstat)) > 0)
- n=fwrite(buf, 1, n, mp);
+ while ((n = fread(buf, 1, sizeof(buf),
+ mdstat)) > 0)
+ n = fwrite(buf, 1, n, mp);
fclose(mdstat);
}
pclose(mp);
@@ -416,13 +419,13 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
/* Log at a different severity depending on the event.
*
* These are the critical events: */
- if (strncmp(event, "Fail", 4)==0 ||
- strncmp(event, "Degrade", 7)==0 ||
- strncmp(event, "DeviceDisappeared", 17)==0)
+ if (strncmp(event, "Fail", 4) == 0 ||
+ strncmp(event, "Degrade", 7) == 0 ||
+ strncmp(event, "DeviceDisappeared", 17) == 0)
priority = LOG_CRIT;
/* Good to know about, but are not failures: */
- else if (strncmp(event, "Rebuild", 7)==0 ||
- strncmp(event, "MoveSpare", 9)==0 ||
+ else if (strncmp(event, "Rebuild", 7) == 0 ||
+ strncmp(event, "MoveSpare", 9) == 0 ||
strncmp(event, "Spares", 6) != 0)
priority = LOG_WARNING;
/* Everything else: */
@@ -497,7 +500,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
goto out;
}
- for (mse2 = mdstat ; mse2 ; mse2=mse2->next)
+ for (mse2 = mdstat; mse2; mse2 = mse2->next)
if (strcmp(mse2->devnm, st->devnm) == 0) {
mse2->devnm[0] = 0; /* flag it as "used" */
mse = mse2;
@@ -568,7 +571,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
char cnt[80];
snprintf(cnt, sizeof(cnt),
" mismatches found: %d (on raid level %d)",
- sra->mismatch_cnt, sra->array.level);
+ sra->mismatch_cnt, sra->array.level);
alert("RebuildFinished", dev, cnt, ainfo);
} else
alert("RebuildFinished", dev, NULL, ainfo);
@@ -594,7 +597,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);
+ strcpy(st->parent_devnm, mse->metadata_version + 10);
sl = strchr(st->parent_devnm, '/');
if (sl)
*sl = 0;
@@ -603,9 +606,9 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->metadata == NULL && st->parent_devnm[0] == 0)
st->metadata = super_by_fd(fd, NULL);
- for (i=0; inext)
- if (mse->devnm[0] &&
- (!mse->level || /* retrieve containers */
- (strcmp(mse->level, "raid0") != 0 &&
- strcmp(mse->level, "linear") != 0))
- ) {
+ for (mse = mdstat; mse; mse = mse->next)
+ if (mse->devnm[0] && (!mse->level || /* retrieve containers */
+ (strcmp(mse->level, "raid0") != 0 &&
+ strcmp(mse->level, "linear") != 0))) {
struct state *st = xcalloc(1, sizeof *st);
mdu_array_info_t array;
int fd;
@@ -707,7 +708,8 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
st->percent = RESYNC_UNKNOWN;
st->expected_spares = -1;
if (mse->metadata_version &&
- strncmp(mse->metadata_version, "external:", 9) == 0 &&
+ strncmp(mse->metadata_version,
+ "external:", 9) == 0 &&
is_subarray(mse->metadata_version+9)) {
char *sl;
strcpy(st->parent_devnm,
@@ -729,8 +731,7 @@ static int get_required_spare_criteria(struct state *st,
{
int fd;
- if (!st->metadata ||
- !st->metadata->ss->get_spare_criteria) {
+ if (!st->metadata || !st->metadata->ss->get_spare_criteria) {
sc->min_size = 0;
sc->sector_size = 0;
return 0;
@@ -779,14 +780,13 @@ static int check_donor(struct state *from, struct state *to)
}
static dev_t choose_spare(struct state *from, struct state *to,
- struct domainlist *domlist, struct spare_criteria *sc)
+ struct domainlist *domlist, struct spare_criteria *sc)
{
int d;
dev_t dev = 0;
for (d = from->raid; !dev && d < MAX_DISKS; d++) {
- if (from->devid[d] > 0 &&
- from->devstate[d] == 0) {
+ if (from->devid[d] > 0 && from->devstate[d] == 0) {
struct dev_policy *pol;
unsigned long long dev_size;
unsigned int dev_sector_size;
@@ -810,7 +810,8 @@ static dev_t choose_spare(struct state *from, struct state *to,
if (from->spare_group)
pol_add(&pol, pol_domain,
from->spare_group, NULL);
- if (domain_test(domlist, pol, to->metadata->ss->name) == 1)
+ if (domain_test(domlist, pol,
+ to->metadata->ss->name) == 1)
dev = from->devid[d];
dev_policy_free(pol);
}
@@ -857,8 +858,8 @@ static dev_t container_choose_spare(struct state *from, struct state *to,
}
dp = list->devs;
while (dp) {
- if (dp->disk.state & (1<disk.state & (1<disk.state & (1 << MD_DISK_SYNC) &&
+ !(dp->disk.state & (1 << MD_DISK_FAULTY)))
active_cnt++;
dp = dp->next;
}
@@ -891,8 +892,7 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
link_containers_with_subarrays(statelist);
for (st = statelist; st; st = st->next)
- if (st->active < st->raid &&
- st->spare == 0 && !st->err) {
+ if (st->active < st->raid && st->spare == 0 && !st->err) {
struct domainlist *domlist = NULL;
int d;
struct state *to = st;
@@ -940,9 +940,11 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
else
devid = choose_spare(from, to, domlist,
&sc);
- if (devid > 0
- && move_spare(from->devname, to->devname, devid)) {
- alert("MoveSpare", to->devname, from->devname, info);
+ if (devid > 0 &&
+ move_spare(from->devname, to->devname,
+ devid)) {
+ alert("MoveSpare", to->devname,
+ from->devname, info);
break;
}
}
@@ -967,8 +969,7 @@ static void link_containers_with_subarrays(struct state *list)
for (st = list; st; st = st->next)
if (st->parent_devnm[0])
for (cont = list; cont; cont = cont->next)
- if (!cont->err &&
- cont->parent_devnm[0] == 0 &&
+ if (!cont->err && cont->parent_devnm[0] == 0 &&
strcmp(cont->devnm, st->parent_devnm) == 0) {
st->parent = cont;
st->subarray = cont->subarray;
@@ -992,7 +993,7 @@ int Wait(char *dev)
struct mdstat_ent *ms = mdstat_read(1, 0);
struct mdstat_ent *e;
- for (e=ms ; e; e=e->next)
+ for (e = ms; e; e = e->next)
if (strcmp(e->devnm, devnm) == 0)
break;
@@ -1115,8 +1116,7 @@ int WaitClean(char *dev, int sock, int verbose)
} else
rv = 1;
if (rv && verbose)
- pr_err("Error waiting for %s to be clean\n",
- dev);
+ pr_err("Error waiting for %s to be clean\n", dev);
/* restore the original safe_mode_delay */
sysfs_set_safemode(mdi, mdi->safe_mode_delay);
--
2.13.6
++++++ 0139-mdadm-Uninitialized-variable-rdev.patch ++++++
From a3476c9223e55ebb6063e7c5ee057647c70da0d2 Mon Sep 17 00:00:00 2001
From: James Puthukattukaran
Date: Tue, 16 May 2017 11:57:00 -0400
Subject: [PATCH] mdadm: Uninitialized variable rdev
Git-commit: a3476c9223e55ebb6063e7c5ee057647c70da0d2
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
rdev is not initialized properly causing compiler complaint.
Signed-off-by: James Puthukattukaran
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-ddf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/super-ddf.c b/super-ddf.c
index 9c82f4f..ac14017 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3526,7 +3526,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
return 1;
}
/* This device must be a member of the set */
- if (!stat_is_blkdev(dev, NULL))
+ if (!stat_is_blkdev(dev, &rdev))
return 0;
for (dl = ddf->dlist ; dl ; dl = dl->next) {
if (dl->major == (int)major(rdev) &&
--
2.13.6
++++++ 0140-super-ddf-sysfs_read-takes-a-pointer-as-device-name-.patch ++++++
From a0628abf2bf87c69bec3384f90aae2398a8e64aa Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 16 May 2017 13:29:46 -0400
Subject: [PATCH] super-ddf: sysfs_read() takes a pointer as device name
argument
Git-commit: a0628abf2bf87c69bec3384f90aae2398a8e64aa
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-ddf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/super-ddf.c b/super-ddf.c
index ac14017..50197a8 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3557,7 +3557,7 @@ static int load_super_ddf_all(struct supertype *st, int fd,
char nm[20];
int dfd;
- sra = sysfs_read(fd, 0, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE);
+ sra = sysfs_read(fd, NULL, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE);
if (!sra)
return 1;
if (sra->array.major_version != -1 ||
--
2.13.6
++++++ 0141-mdadm-Fixup-a-large-number-of-bad-formatting-of-logi.patch ++++++
From fc54fe7a7e77fdb6316d332d4d41d0ed2293d6be Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 16 May 2017 13:52:15 -0400
Subject: [PATCH] mdadm: Fixup a large number of bad formatting of logical
operators
Git-commit: fc54fe7a7e77fdb6316d332d4d41d0ed2293d6be
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Logical oprators never belong at the beginning of a line.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 23 ++++++++++-------------
Grow.c | 34 ++++++++++++++++------------------
Manage.c | 29 +++++++++++++----------------
managemon.c | 10 +++++-----
mdadm.c | 3 +--
monitor.c | 4 ++--
super-ddf.c | 33 ++++++++++++++++-----------------
super-intel.c | 10 +++++-----
util.c | 20 ++++++++------------
9 files changed, 76 insertions(+), 90 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 30d5838..1b1905c 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -753,12 +753,12 @@ static int load_devices(struct devs *devices, char *devmap,
bestcnt = newbestcnt;
}
if (best[i] >=0 &&
- devices[best[i]].i.events
- == devices[devcnt].i.events
- && (devices[best[i]].i.disk.minor
- != devices[devcnt].i.disk.minor)
- && st->ss == &super0
- && content->array.level != LEVEL_MULTIPATH) {
+ devices[best[i]].i.events ==
+ devices[devcnt].i.events &&
+ (devices[best[i]].i.disk.minor
+ != devices[devcnt].i.disk.minor) &&
+ st->ss == &super0 &&
+ content->array.level != LEVEL_MULTIPATH) {
/* two different devices with identical superblock.
* Could be a mis-detection caused by overlapping
* partitions. fail-safe.
@@ -801,14 +801,11 @@ static int force_array(struct mdinfo *content,
int okcnt = 0;
while (!enough(content->array.level, content->array.raid_disks,
content->array.layout, 1,
- avail)
- ||
+ avail) ||
(content->reshape_active && content->delta_disks > 0 &&
!enough(content->array.level, (content->array.raid_disks
- content->delta_disks),
- content->new_layout, 1,
- avail)
- )) {
+ content->new_layout, 1, avail))) {
/* Choose the newest best drive which is
* not up-to-date, update the superblock
* and add it.
@@ -1303,8 +1300,8 @@ int Assemble(struct supertype *st, char *mddev,
int mdfd;
int clean;
int auto_assem = (mddev == NULL && !ident->uuid_set &&
- ident->super_minor == UnSet && ident->name[0] == 0
- && (ident->container == NULL || ident->member == NULL));
+ ident->super_minor == UnSet && ident->name[0] == 0 &&
+ (ident->container == NULL || ident->member == NULL));
struct devs *devices;
char *devmap;
int *best = NULL; /* indexed by raid_disk */
diff --git a/Grow.c b/Grow.c
index a527436..39110b8 100644
--- a/Grow.c
+++ b/Grow.c
@@ -813,8 +813,8 @@ static void unfreeze(struct supertype *st)
char buf[20];
if (sra &&
- sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0
- && strcmp(buf, "frozen\n") == 0)
+ sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
+ strcmp(buf, "frozen\n") == 0)
sysfs_set_str(sra, NULL, "sync_action", "idle");
sysfs_free(sra);
}
@@ -2902,8 +2902,8 @@ static int impose_level(int fd, int level, char *devname, int verbose)
if (disk.major == 0 && disk.minor == 0)
continue;
found++;
- if ((disk.state & (1 << MD_DISK_ACTIVE))
- && disk.raid_disk < data_disks)
+ if ((disk.state & (1 << MD_DISK_ACTIVE)) &&
+ disk.raid_disk < data_disks)
/* keep this */
continue;
ioctl(fd, HOT_REMOVE_DISK,
@@ -2921,8 +2921,8 @@ static int impose_level(int fd, int level, char *devname, int verbose)
if (disk.major == 0 && disk.minor == 0)
continue;
found++;
- if ((disk.state & (1 << MD_DISK_ACTIVE))
- && disk.raid_disk < data_disks)
+ if ((disk.state & (1 << MD_DISK_ACTIVE)) &&
+ disk.raid_disk < data_disks)
/* keep this */
continue;
ioctl(fd, SET_DISK_FAULTY,
@@ -3597,9 +3597,8 @@ started:
}
if (!st->ss->external &&
- !(reshape.before.data_disks != reshape.after.data_disks
- && info->custom_array_size) &&
- info->new_level == reshape.level &&
+ !(reshape.before.data_disks != reshape.after.data_disks &&
+ info->custom_array_size) && info->new_level == reshape.level &&
!forked) {
/* no need to wait for the reshape to finish as
* there is nothing more to do.
@@ -4092,14 +4091,14 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
* before setting 'sync_action' to 'idle'.
* So we need these extra tests.
*/
- if (completed == 0 && advancing
- && strncmp(action, "idle", 4) == 0
- && info->reshape_progress > 0)
+ if (completed == 0 && advancing &&
+ strncmp(action, "idle", 4) == 0 &&
+ info->reshape_progress > 0)
break;
- if (completed == 0 && !advancing
- && strncmp(action, "idle", 4) == 0
- && info->reshape_progress < (info->component_size
- * reshape->after.data_disks))
+ if (completed == 0 && !advancing &&
+ strncmp(action, "idle", 4) == 0 &&
+ info->reshape_progress < (info->component_size
+ * reshape->after.data_disks))
break;
sysfs_wait(fd, NULL);
if (sysfs_fd_get_ll(fd, &completed) < 0)
@@ -4787,8 +4786,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
/* reshape_progress is increasing */
if ((__le64_to_cpu(bsb.arraystart)
+ __le64_to_cpu(bsb.length)
- < info->reshape_progress)
- &&
+ < info->reshape_progress) &&
(__le64_to_cpu(bsb.arraystart2)
+ __le64_to_cpu(bsb.length2)
< info->reshape_progress))
diff --git a/Manage.c b/Manage.c
index 467efb7..cee5dad 100644
--- a/Manage.c
+++ b/Manage.c
@@ -204,11 +204,9 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
count = 5;
while (((fd = ((devname[0] == '/')
?open(devname, O_RDONLY|O_EXCL)
- :open_dev_flags(devnm, O_RDONLY|O_EXCL))) < 0
- || strcmp(fd2devnm(fd), devnm) != 0)
- && container[0]
- && mdmon_running(container)
- && count) {
+ :open_dev_flags(devnm, O_RDONLY|O_EXCL))) < 0 ||
+ strcmp(fd2devnm(fd), devnm) != 0) && container[0] &&
+ mdmon_running(container) && count) {
/* Can't open, so something might be wrong. However it
* is a container, so we might be racing with mdmon, so
* retry for a bit.
@@ -244,8 +242,8 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry)
while (count &&
(err = sysfs_set_str(mdi, NULL,
"array_state",
- "inactive")) < 0
- && errno == EBUSY) {
+ "inactive")) < 0 &&
+ errno == EBUSY) {
usleep(200000);
count--;
}
@@ -447,9 +445,8 @@ done:
* so it is reasonable to retry for a while - 5 seconds.
*/
count = 25; err = 0;
- while (count && fd >= 0
- && (err = ioctl(fd, STOP_ARRAY, NULL)) < 0
- && errno == EBUSY) {
+ while (count && fd >= 0 &&
+ (err = ioctl(fd, STOP_ARRAY, NULL)) < 0 && errno == EBUSY) {
usleep(200000);
count --;
}
@@ -795,8 +792,8 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
break;
}
/* FIXME this is a bad test to be using */
- if (!tst->sb && (dv->disposition != 'a'
- && dv->disposition != 'S')) {
+ if (!tst->sb && (dv->disposition != 'a' &&
+ dv->disposition != 'S')) {
/* we are re-adding a device to a
* completely dead array - have to depend
* on kernel to check
@@ -1393,8 +1390,7 @@ int Manage_subdevs(char *devname, int fd,
if (strcmp(dv->devname, "failed") == 0 ||
strcmp(dv->devname, "faulty") == 0) {
- if (dv->disposition != 'A'
- && dv->disposition != 'r') {
+ if (dv->disposition != 'A' && dv->disposition != 'r') {
pr_err("%s only meaningful with -r or --re-add, not -%c\n",
dv->devname, dv->disposition);
goto abort;
@@ -1499,8 +1495,9 @@ int Manage_subdevs(char *devname, int fd,
goto abort;
}
}
- } else if ((dv->disposition == 'r' || dv->disposition == 'f')
- && get_maj_min(dv->devname, &mj, &mn)) {
+ } else if ((dv->disposition == 'r' ||
+ dv->disposition == 'f') &&
+ get_maj_min(dv->devname, &mj, &mn)) {
/* for 'fail' and 'remove', the device might
* not exist.
*/
diff --git a/managemon.c b/managemon.c
index 3c1d4cb..0a33fc9 100644
--- a/managemon.c
+++ b/managemon.c
@@ -499,9 +499,9 @@ static void manage_member(struct mdstat_ent *mdstat,
frozen = 1; /* can't read metadata_version assume the worst */
/* If sync_action is not 'idle' then don't try recovery now */
- if (!frozen
- && sysfs_get_str(&a->info, NULL, "sync_action", buf, sizeof(buf)) > 0
- && strncmp(buf, "idle", 4) != 0)
+ if (!frozen &&
+ sysfs_get_str(&a->info, NULL, "sync_action",
+ buf, sizeof(buf)) > 0 && strncmp(buf, "idle", 4) != 0)
frozen = 1;
if (mdstat->level) {
@@ -626,8 +626,8 @@ static void manage_member(struct mdstat_ent *mdstat,
newd = xmalloc(sizeof(*newd));
disk_init_and_add(newd, d, newa);
}
- if (sysfs_get_ll(info, NULL, "array_size", &array_size) == 0
- && a->info.custom_array_size > array_size*2) {
+ if (sysfs_get_ll(info, NULL, "array_size", &array_size) == 0 &&
+ a->info.custom_array_size > array_size*2) {
sysfs_set_num(info, NULL, "array_size",
a->info.custom_array_size/2);
}
diff --git a/mdadm.c b/mdadm.c
index b689e32..70b16f2 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1843,8 +1843,7 @@ static int misc_scan(char devmode, struct context *c)
if (members != member)
continue;
me = map_by_devnm(&map, e->devnm);
- if (me && me->path
- && strcmp(me->path, "/unknown") != 0)
+ if (me && me->path && strcmp(me->path, "/unknown") != 0)
name = me->path;
if (name == NULL || stat(name, &stb) != 0)
name = get_md_name(e->devnm);
diff --git a/monitor.c b/monitor.c
index 00b7c68..81537ed 100644
--- a/monitor.c
+++ b/monitor.c
@@ -576,8 +576,8 @@ static int read_and_act(struct active_array *a, fd_set *fds)
a->last_checkpoint = sync_completed;
a->container->ss->set_array_state(a, a->curr_state <= clean);
} else if ((a->curr_action == idle && a->prev_action == reshape) ||
- (a->curr_action == reshape
- && sync_completed > a->last_checkpoint) ) {
+ (a->curr_action == reshape &&
+ sync_completed > a->last_checkpoint)) {
/* Reshape has progressed or completed so we need to
* update the array state - and possibly the array size
*/
diff --git a/super-ddf.c b/super-ddf.c
index 50197a8..769eded 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -670,8 +670,8 @@ static int layout_md2ddf(const mdu_array_info_t *array,
sec_elmnt_count = array->raid_disks / 2;
srl = DDF_2SPANNED;
prl = DDF_RAID1;
- } else if (array->raid_disks % 3 == 0
- && array->layout == 0x103) {
+ } else if (array->raid_disks % 3 == 0 &&
+ array->layout == 0x103) {
rlq = DDF_RAID1_MULTI;
prim_elmnt_count = cpu_to_be16(3);
sec_elmnt_count = array->raid_disks / 3;
@@ -853,8 +853,8 @@ static void *load_section(int fd, struct ddf_super *super, void *buf,
int dofree = (buf == NULL);
if (check)
- if (len != 2 && len != 8 && len != 32
- && len != 128 && len != 512)
+ if (len != 2 && len != 8 && len != 32 &&
+ len != 128 && len != 512)
return NULL;
if (len > 1024)
@@ -2028,8 +2028,8 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
be32_to_cpu(ddf->phys->entries[e].refnum) == 0xffffffff)
e++;
if (i < info->array.raid_disks && e < max &&
- !(be16_to_cpu(ddf->phys->entries[e].state)
- & DDF_Failed))
+ !(be16_to_cpu(ddf->phys->entries[e].state) &
+ DDF_Failed))
map[i] = 1;
else
map[i] = 0;
@@ -2114,11 +2114,10 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
info->resync_start = 0;
info->reshape_active = 0;
info->recovery_blocked = 0;
- if (!(ddf->virt->entries[info->container_member].state
- & DDF_state_inconsistent) &&
- (ddf->virt->entries[info->container_member].init_state
- & DDF_initstate_mask)
- == DDF_init_full)
+ if (!(ddf->virt->entries[info->container_member].state &
+ DDF_state_inconsistent) &&
+ (ddf->virt->entries[info->container_member].init_state &
+ DDF_initstate_mask) == DDF_init_full)
info->resync_start = MaxSector;
uuid_from_super_ddf(st, info->uuid);
@@ -2135,7 +2134,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
if (map)
for (j = 0; j < map_disks; j++) {
map[j] = 0;
- if (j < info->array.raid_disks) {
+ if (j < info->array.raid_disks) {
int i = find_phys(ddf, vc->conf.phys_refnum[j]);
if (i >= 0 &&
(be16_to_cpu(ddf->phys->entries[i].state)
@@ -4618,9 +4617,9 @@ static void ddf_remove_failed(struct ddf_super *ddf)
0xFFFFFFFF)
continue;
if (be16_and(ddf->phys->entries[pdnum].state,
- cpu_to_be16(DDF_Failed))
- && be16_and(ddf->phys->entries[pdnum].state,
- cpu_to_be16(DDF_Transition))) {
+ cpu_to_be16(DDF_Failed)) &&
+ be16_and(ddf->phys->entries[pdnum].state,
+ cpu_to_be16(DDF_Transition))) {
/* skip this one unless in dlist*/
for (dl = ddf->dlist; dl; dl = dl->next)
if (dl->pdnum == (int)pdnum)
@@ -5151,8 +5150,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
vc = (struct vd_config *)(mu->buf
+ i_sec * ddf->conf_rec_len * 512);
for (dl = ddf->dlist; dl; dl = dl->next)
- if (dl->major == di->disk.major
- && dl->minor == di->disk.minor)
+ if (dl->major == di->disk.major &&
+ dl->minor == di->disk.minor)
break;
if (!dl || dl->pdnum < 0) {
pr_err("BUG: can't find disk %d (%d/%d)\n",
diff --git a/super-intel.c b/super-intel.c
index 8ca80d3..c84e755 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4165,8 +4165,8 @@ int check_mpb_migr_compatibility(struct intel_super *super)
if (pba_of_lba0(map0) != pba_of_lba0(map1))
/* migration optimization area was used */
return -1;
- if (migr_rec->ascending_migr == 0
- && migr_rec->dest_depth_per_unit > 0)
+ if (migr_rec->ascending_migr == 0 &&
+ migr_rec->dest_depth_per_unit > 0)
/* descending reshape not supported yet */
return -1;
}
@@ -6442,7 +6442,7 @@ active_arrays_by_format(char *name, char* hba, struct md_list **devlist,
for (memb = mdstat ; memb ; memb = memb->next) {
if (memb->metadata_version &&
- (strncmp(memb->metadata_version, "external:", 9) == 0) &&
+ (strncmp(memb->metadata_version, "external:", 9) == 0) &&
(strcmp(&memb->metadata_version[9], name) == 0) &&
!is_subarray(memb->metadata_version+9) &&
memb->members) {
@@ -11640,8 +11640,8 @@ static int imsm_manage_reshape(
/* Find volume during the reshape */
for (dv = super->devlist; dv; dv = dv->next) {
- if (dv->dev->vol.migr_type == MIGR_GEN_MIGR
- && dv->dev->vol.migr_state == 1) {
+ if (dv->dev->vol.migr_type == MIGR_GEN_MIGR &&
+ dv->dev->vol.migr_state == 1) {
dev = dv->dev;
migr_vol_qan++;
}
diff --git a/util.c b/util.c
index fc9cd3f..0564c0b 100644
--- a/util.c
+++ b/util.c
@@ -1014,21 +1014,18 @@ char *get_md_name(char *devnm)
if (strncmp(devnm, "md_", 3) == 0) {
snprintf(devname, sizeof(devname), "/dev/md/%s",
devnm + 3);
- if (stat(devname, &stb) == 0
- && (S_IFMT&stb.st_mode) == S_IFBLK
- && (stb.st_rdev == rdev))
+ if (stat(devname, &stb) == 0 &&
+ (S_IFMT&stb.st_mode) == S_IFBLK && (stb.st_rdev == rdev))
return devname;
}
snprintf(devname, sizeof(devname), "/dev/%s", devnm);
- if (stat(devname, &stb) == 0
- && (S_IFMT&stb.st_mode) == S_IFBLK
- && (stb.st_rdev == rdev))
+ if (stat(devname, &stb) == 0 && (S_IFMT&stb.st_mode) == S_IFBLK &&
+ (stb.st_rdev == rdev))
return devname;
snprintf(devname, sizeof(devname), "/dev/md/%s", devnm+2);
- if (stat(devname, &stb) == 0
- && (S_IFMT&stb.st_mode) == S_IFBLK
- && (stb.st_rdev == rdev))
+ if (stat(devname, &stb) == 0 && (S_IFMT&stb.st_mode) == S_IFBLK &&
+ (stb.st_rdev == rdev))
return devname;
dn = map_dev(major(rdev), minor(rdev), 0);
@@ -1039,9 +1036,8 @@ char *get_md_name(char *devnm)
if (errno != EEXIST)
return NULL;
- if (stat(devname, &stb) == 0
- && (S_IFMT&stb.st_mode) == S_IFBLK
- && (stb.st_rdev == rdev))
+ if (stat(devname, &stb) == 0 && (S_IFMT&stb.st_mode) == S_IFBLK &&
+ (stb.st_rdev == rdev))
return devname;
unlink(devname);
return NULL;
--
2.13.6
++++++ 0142-mdadm-Fixup-more-broken-logical-operator-formatting.patch ++++++
From d7be7d87366a7f9b190bc4e41ea06f7c9984028e Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 16 May 2017 13:59:43 -0400
Subject: [PATCH] mdadm: Fixup more broken logical operator formatting
Git-commit: d7be7d87366a7f9b190bc4e41ea06f7c9984028e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 9 ++++-----
Grow.c | 16 +++++++++-------
Manage.c | 4 ++--
Monitor.c | 4 ++--
mapfile.c | 4 ++--
mdstat.c | 10 ++++++----
platform-intel.c | 4 ++--
restripe.c | 4 ++--
super-ddf.c | 15 +++++++--------
super-intel.c | 3 +--
util.c | 3 +--
11 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 1b1905c..afc6d9c 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -220,8 +220,8 @@ static int select_devices(struct mddev_dev *devlist,
pr_err("not a recognisable container: %s\n",
devname);
tmpdev->used = 2;
- } else if (!tst->ss->load_container
- || tst->ss->load_container(tst, dfd, NULL)) {
+ } else if (!tst->ss->load_container ||
+ tst->ss->load_container(tst, dfd, NULL)) {
if (report_mismatch)
pr_err("no correct container type: %s\n",
devname);
@@ -776,9 +776,8 @@ static int load_devices(struct devs *devices, char *devmap,
*stp = st;
return -1;
}
- if (best[i] == -1
- || (devices[best[i]].i.events
- < devices[devcnt].i.events))
+ if (best[i] == -1 || (devices[best[i]].i.events
+ < devices[devcnt].i.events))
best[i] = devcnt;
}
devcnt++;
diff --git a/Grow.c b/Grow.c
index 39110b8..db3f18b 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3995,8 +3995,8 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
* a backup.
*/
if (advancing) {
- if ((need_backup > info->reshape_progress
- || info->array.major_version < 0) &&
+ if ((need_backup > info->reshape_progress ||
+ info->array.major_version < 0) &&
*suspend_point < info->reshape_progress + target) {
if (need_backup < *suspend_point + 2 * target)
*suspend_point = need_backup;
@@ -4149,8 +4149,9 @@ check_progress:
* it was just a device failure that leaves us degraded but
* functioning.
*/
- if (sysfs_get_str(info, NULL, "reshape_position", buf, sizeof(buf)) < 0
- || strncmp(buf, "none", 4) != 0) {
+ if (sysfs_get_str(info, NULL, "reshape_position", buf,
+ sizeof(buf)) < 0 ||
+ strncmp(buf, "none", 4) != 0) {
/* The abort might only be temporary. Wait up to 10
* seconds for fd to contain a valid number again.
*/
@@ -4182,9 +4183,10 @@ check_progress:
/* Maybe racing with array shutdown - check state */
if (fd >= 0)
close(fd);
- if (sysfs_get_str(info, NULL, "array_state", buf, sizeof(buf)) < 0
- || strncmp(buf, "inactive", 8) == 0
- || strncmp(buf, "clear",5) == 0)
+ if (sysfs_get_str(info, NULL, "array_state", buf,
+ sizeof(buf)) < 0 ||
+ strncmp(buf, "inactive", 8) == 0 ||
+ strncmp(buf, "clear",5) == 0)
return -2; /* abort */
return -1; /* complete */
}
diff --git a/Manage.c b/Manage.c
index cee5dad..04b9398 100644
--- a/Manage.c
+++ b/Manage.c
@@ -655,8 +655,8 @@ int attempt_re_add(int fd, int tfd, struct mddev_dev *dv,
if (dv->failfast == FlagClear)
disc.state &= ~(1 << MD_DISK_FAILFAST);
remove_partitions(tfd);
- if (update || dv->writemostly != FlagDefault
- || dv->failfast != FlagDefault) {
+ if (update || dv->writemostly != FlagDefault ||
+ dv->failfast != FlagDefault) {
int rv = -1;
tfd = dev_open(dv->devname, O_RDWR);
if (tfd < 0) {
diff --git a/Monitor.c b/Monitor.c
index 0198a34..725f47d 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -530,7 +530,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->utime == array.utime && st->failed == sra->array.failed_disks &&
st->working == sra->array.working_disks &&
st->spare == sra->array.spare_disks &&
- (mse == NULL || (mse->percent == st->percent))) {
+ (mse == NULL || (mse->percent == st->percent))) {
if ((st->active < st->raid) && st->spare == 0)
retval = 1;
goto out;
@@ -672,7 +672,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
char *name;
for (mse = mdstat; mse; mse = mse->next)
- if (mse->devnm[0] && (!mse->level || /* retrieve containers */
+ if (mse->devnm[0] && (!mse->level || /* retrieve containers */
(strcmp(mse->level, "raid0") != 0 &&
strcmp(mse->level, "linear") != 0))) {
struct state *st = xcalloc(1, sizeof *st);
diff --git a/mapfile.c b/mapfile.c
index c89d403..f3c8191 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -439,8 +439,8 @@ void RebuildMap(void)
if ((homehost == NULL ||
st->ss->match_home(st, homehost) != 1) &&
st->ss->match_home(st, "any") != 1 &&
- (require_homehost
- || ! conf_name_is_free(info->name)))
+ (require_homehost ||
+ !conf_name_is_free(info->name)))
/* require a numeric suffix */
unum = 0;
else
diff --git a/mdstat.c b/mdstat.c
index 3962896..0d44050 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -166,8 +166,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
continue;
insert_here = NULL;
/* Better be an md line.. */
- if (strncmp(line, "md", 2)!= 0 || strlen(line) >= 32
- || (line[2] != '_' && !isdigit(line[2])))
+ if (strncmp(line, "md", 2)!= 0 || strlen(line) >= 32 ||
+ (line[2] != '_' && !isdigit(line[2])))
continue;
strcpy(devnm, line);
@@ -212,8 +212,10 @@ struct mdstat_ent *mdstat_read(int hold, int start)
struct mdstat_ent **ih;
ih = &all;
while (ih != insert_here && *ih &&
- ((int)strlen((*ih)->devnm) != ep-w
- || strncmp((*ih)->devnm, w, ep-w) != 0))
+ ((int)strlen((*ih)->devnm) !=
+ ep-w ||
+ strncmp((*ih)->devnm, w,
+ ep-w) != 0))
ih = & (*ih)->next;
insert_here = ih;
}
diff --git a/platform-intel.c b/platform-intel.c
index 9867697..a11101d 100644
--- a/platform-intel.c
+++ b/platform-intel.c
@@ -548,8 +548,8 @@ static int read_efi_variable(void *buffer, ssize_t buf_size, char *variable_name
errno = 0;
var_data_len = strtoul(buf, NULL, 16);
- if ((errno == ERANGE && (var_data_len == LONG_MAX))
- || (errno != 0 && var_data_len == 0))
+ if ((errno == ERANGE && (var_data_len == LONG_MAX)) ||
+ (errno != 0 && var_data_len == 0))
return 1;
/* get data */
diff --git a/restripe.c b/restripe.c
index de85ee4..6b31695 100644
--- a/restripe.c
+++ b/restripe.c
@@ -731,8 +731,8 @@ int restore_stripes(int *dest, unsigned long long *offsets,
zero_size = chunk_size;
}
- if (stripe_buf == NULL || stripes == NULL || blocks == NULL
- || zero == NULL) {
+ if (stripe_buf == NULL || stripes == NULL || blocks == NULL ||
+ zero == NULL) {
rv = -2;
goto abort;
}
diff --git a/super-ddf.c b/super-ddf.c
index 769eded..4da7c09 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -932,14 +932,13 @@ static int load_ddf_headers(int fd, struct ddf_super *super, char *devname)
if (load_ddf_header(fd, be64_to_cpu(super->anchor.secondary_lba),
dsize >> 9, 2,
&super->secondary, &super->anchor)) {
- if (super->active == NULL
- || (be32_to_cpu(super->primary.seq)
- < be32_to_cpu(super->secondary.seq) &&
- !super->secondary.openflag)
- || (be32_to_cpu(super->primary.seq)
- == be32_to_cpu(super->secondary.seq) &&
- super->primary.openflag && !super->secondary.openflag)
- )
+ if (super->active == NULL ||
+ (be32_to_cpu(super->primary.seq)
+ < be32_to_cpu(super->secondary.seq) &&
+ !super->secondary.openflag) ||
+ (be32_to_cpu(super->primary.seq) ==
+ be32_to_cpu(super->secondary.seq) &&
+ super->primary.openflag && !super->secondary.openflag))
super->active = &super->secondary;
} else if (devname &&
be64_to_cpu(super->anchor.secondary_lba) != ~(__u64)0)
diff --git a/super-intel.c b/super-intel.c
index c84e755..3d0a37c 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -10874,8 +10874,7 @@ static int imsm_create_metadata_update_for_reshape(
*/
spares = get_spares_for_grow(st);
- if (spares == NULL
- || delta_disks > spares->array.spare_disks) {
+ if (spares == NULL || delta_disks > spares->array.spare_disks) {
pr_err("imsm: ERROR: Cannot get spare devices for %s.\n", geo->dev_name);
i = -1;
goto abort;
diff --git a/util.c b/util.c
index 0564c0b..d89438c 100644
--- a/util.c
+++ b/util.c
@@ -2213,8 +2213,7 @@ void enable_fds(int devices)
{
unsigned int fds = 20 + devices;
struct rlimit lim;
- if (getrlimit(RLIMIT_NOFILE, &lim) != 0
- || lim.rlim_cur >= fds)
+ if (getrlimit(RLIMIT_NOFILE, &lim) != 0 || lim.rlim_cur >= fds)
return;
if (lim.rlim_max < fds)
lim.rlim_max = fds;
--
2.13.6
++++++ 0143-mdadm-Fix-broken-formatting.patch ++++++
From b831b299e864224b389743d8a435d6629ee674e3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 16 May 2017 14:04:22 -0400
Subject: [PATCH] mdadm: Fix '==' broken formatting
Git-commit: b831b299e864224b389743d8a435d6629ee674e3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 6 +++---
config.c | 4 ++--
managemon.c | 4 ++--
super-ddf.c | 16 ++++++++--------
super-intel.c | 2 +-
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/Detail.c b/Detail.c
index ef2370c..bf881ff 100644
--- a/Detail.c
+++ b/Detail.c
@@ -714,9 +714,9 @@ This is pretty boring
if (disk.state & (1 << MD_DISK_JOURNAL))
printf(" journal");
if ((disk.state &
- ((1<= 0)
diff --git a/config.c b/config.c
index 9b008e3..48e0278 100644
--- a/config.c
+++ b/config.c
@@ -1118,8 +1118,8 @@ struct mddev_ident *conf_match(struct supertype *st,
match = NULL;
for (; array_list; array_list = array_list->next) {
if (array_list->uuid_set &&
- same_uuid(array_list->uuid, info->uuid, st->ss->swapuuid)
- == 0) {
+ same_uuid(array_list->uuid, info->uuid,
+ st->ss->swapuuid) == 0) {
if (verbose >= 2 && array_list->devname)
pr_err("UUID differs from %s.\n",
array_list->devname);
diff --git a/managemon.c b/managemon.c
index 0a33fc9..a8df666 100644
--- a/managemon.c
+++ b/managemon.c
@@ -580,8 +580,8 @@ static void manage_member(struct mdstat_ent *mdstat,
usleep(15*1000);
}
replace_array(container, a, newa);
- if (sysfs_set_str(&a->info, NULL, "sync_action", "recover")
- == 0)
+ if (sysfs_set_str(&a->info, NULL,
+ "sync_action", "recover") == 0)
newa->prev_action = recover;
dprintf("recovery started on %s\n", a->info.sys_name);
out:
diff --git a/super-ddf.c b/super-ddf.c
index 4da7c09..c233601 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -1883,8 +1883,8 @@ static struct vd_config *find_vdcr(struct ddf_super *ddf, unsigned int inst,
nsec = n / be16_to_cpu(conf->prim_elmnt_count);
if (conf->sec_elmnt_seq != nsec) {
for (ibvd = 1; ibvd < conf->sec_elmnt_count; ibvd++) {
- if (v->other_bvds[ibvd-1]->sec_elmnt_seq
- == nsec)
+ if (v->other_bvds[ibvd-1]->sec_elmnt_seq ==
+ nsec)
break;
}
if (ibvd == conf->sec_elmnt_count)
@@ -3814,13 +3814,13 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray
unsigned int iphys;
int stt;
- if (be32_to_cpu(ddf->phys->entries[pd].refnum)
- == 0xFFFFFFFF)
+ if (be32_to_cpu(ddf->phys->entries[pd].refnum) ==
+ 0xffffffff)
continue;
stt = be16_to_cpu(ddf->phys->entries[pd].state);
- if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding))
- != DDF_Online)
+ if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding)) !=
+ DDF_Online)
continue;
i = get_pd_index_from_refnum(
@@ -4205,8 +4205,8 @@ static int get_bvd_state(const struct ddf_super *ddf,
if (pd < 0)
continue;
st = be16_to_cpu(ddf->phys->entries[pd].state);
- if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding))
- == DDF_Online) {
+ if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding)) ==
+ DDF_Online) {
working++;
avail[i] = 1;
}
diff --git a/super-intel.c b/super-intel.c
index 3d0a37c..51b7cc3 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4023,7 +4023,7 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super,
/* duplicate and then set the target end state in map[0] */
memcpy(dest, src, sizeof_imsm_map(src));
- if (migr_type == MIGR_REBUILD || migr_type == MIGR_GEN_MIGR) {
+ if (migr_type == MIGR_REBUILD || migr_type == MIGR_GEN_MIGR) {
__u32 ord;
int i;
--
2.13.6
++++++ 0144-mdadm-Fixup-broken-formatting.patch ++++++
From d16a749444251c12689fa93d398149025a9c2398 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Tue, 16 May 2017 14:09:57 -0400
Subject: [PATCH] mdadm: Fixup != broken formatting
Git-commit: d16a749444251c12689fa93d398149025a9c2398
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Assemble.c | 4 ++--
Grow.c | 13 +++++++------
policy.c | 5 ++---
restripe.c | 8 +++++---
super-ddf.c | 8 ++++----
super0.c | 8 ++++----
6 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index afc6d9c..3c10b6c 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -755,8 +755,8 @@ static int load_devices(struct devs *devices, char *devmap,
if (best[i] >=0 &&
devices[best[i]].i.events ==
devices[devcnt].i.events &&
- (devices[best[i]].i.disk.minor
- != devices[devcnt].i.disk.minor) &&
+ (devices[best[i]].i.disk.minor !=
+ devices[devcnt].i.disk.minor) &&
st->ss == &super0 &&
content->array.level != LEVEL_MULTIPATH) {
/* two different devices with identical superblock.
diff --git a/Grow.c b/Grow.c
index db3f18b..ecf5ca0 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1403,8 +1403,8 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
if (info->new_layout == UnSet) {
int copies = 1 + (info->delta_disks
/ info->array.raid_disks);
- if (info->array.raid_disks * (copies-1)
- != info->delta_disks)
+ if (info->array.raid_disks * (copies-1) !=
+ info->delta_disks)
return "Impossible number of devices for RAID0->RAID10";
info->new_layout = 0x100 + copies;
}
@@ -3067,8 +3067,8 @@ static int reshape_array(char *container, int fd, char *devname,
if (restart &&
(reshape.level != info->array.level ||
reshape.before.layout != info->array.layout ||
- reshape.before.data_disks + reshape.parity
- != info->array.raid_disks - max(0, info->delta_disks))) {
+ reshape.before.data_disks + reshape.parity !=
+ info->array.raid_disks - max(0, info->delta_disks))) {
pr_err("reshape info is not in native format - cannot continue.\n");
goto release;
}
@@ -4281,8 +4281,9 @@ static int grow_backup(struct mdinfo *sra,
((char*)&bsb.sb_csum2)-((char*)&bsb));
rv = -1;
- if ((unsigned long long)lseek64(destfd[i], destoffsets[i] - 4096, 0)
- != destoffsets[i] - 4096)
+ if ((unsigned long long)lseek64(destfd[i],
+ destoffsets[i] - 4096, 0) !=
+ destoffsets[i] - 4096)
break;
if (write(destfd[i], &bsb, 512) != 512)
break;
diff --git a/policy.c b/policy.c
index 064d349..b17585a 100644
--- a/policy.c
+++ b/policy.c
@@ -887,9 +887,8 @@ int Write_rules(char *rule_name)
fd = 1;
/* write static invocation */
- if (write(fd, udev_template_start,
- sizeof(udev_template_start) - 1)
- != (int)sizeof(udev_template_start)-1)
+ if (write(fd, udev_template_start, sizeof(udev_template_start) - 1) !=
+ (int)sizeof(udev_template_start) - 1)
goto abort;
/* iterate, if none created or error occurred, remove file */
diff --git a/restripe.c b/restripe.c
index 6b31695..31b07e8 100644
--- a/restripe.c
+++ b/restripe.c
@@ -581,14 +581,16 @@ int save_stripes(int *source, unsigned long long *offsets,
raid_disks, level, layout);
if (dnum < 0) abort();
if (source[dnum] < 0 ||
- lseek64(source[dnum], offsets[dnum]+offset, 0) < 0 ||
- read(source[dnum], buf+disk * chunk_size, chunk_size)
- != chunk_size)
+ lseek64(source[dnum],
+ offsets[dnum] + offset, 0) < 0 ||
+ read(source[dnum], buf+disk * chunk_size,
+ chunk_size) != chunk_size) {
if (failed <= 2) {
fdisk[failed] = dnum;
fblock[failed] = disk;
failed++;
}
+ }
}
if (failed == 0 || fblock[0] >= data_disks)
/* all data disks are good */
diff --git a/super-ddf.c b/super-ddf.c
index c233601..d02a19a 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -3511,8 +3511,8 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
if (minsize == 0)
minsize = 8;
for (dl = ddf->dlist; dl ; dl = dl->next) {
- if (find_space(ddf, dl, data_offset, &minsize)
- != INVALID_SECTORS)
+ if (find_space(ddf, dl, data_offset, &minsize) !=
+ INVALID_SECTORS)
dcnt++;
}
if (dcnt < raiddisks) {
@@ -4004,8 +4004,8 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
continue;
if (posix_memalign((void **)&dl1, 512,
- sizeof(*dl1) + (first->max_part) * sizeof(dl1->vlist[0]))
- != 0) {
+ sizeof(*dl1) + (first->max_part) *
+ sizeof(dl1->vlist[0])) != 0) {
pr_err("could not allocate disk info buffer\n");
return 3;
}
diff --git a/super0.c b/super0.c
index dc13efb..756cab5 100644
--- a/super0.c
+++ b/super0.c
@@ -589,8 +589,8 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
* being marked 'sync'
*/
add = (1<disks[d].state & ~mask) | add)
- != (unsigned)info->disk.state) {
+ if (((sb->disks[d].state & ~mask) | add) !=
+ (unsigned)info->disk.state) {
sb->disks[d].state = info->disk.state | wonly |failfast;
rv = 1;
}
@@ -1058,8 +1058,8 @@ static int load_super0(struct supertype *st, int fd, char *devname)
* valid. If it doesn't clear the bit. An --assemble --force
* should get that written out.
*/
- if (read(fd, super+1, ROUND_UP(sizeof(struct bitmap_super_s),4096))
- != ROUND_UP(sizeof(struct bitmap_super_s),4096))
+ if (read(fd, super+1, ROUND_UP(sizeof(struct bitmap_super_s),4096)) !=
+ ROUND_UP(sizeof(struct bitmap_super_s), 4096))
goto no_bitmap;
uuid_from_super0(st, uuid);
--
2.13.6
++++++ 0145-Detail-don-t-exit-if-ioctl-has-been-successful.patch ++++++
From 9b8fea914f82281c440cdce9dee6a3775265861c Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak
Date: Wed, 24 May 2017 11:34:22 +0200
Subject: [PATCH] Detail: don't exit if ioctl has been successful
Git-commit: 9b8fea914f82281c440cdce9dee6a3775265861c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
When GET_ARRAY_INFO ioctl is successful, mdadm exits with an error.
It breaks udev and no links in /dev/md are created.
Also change debug print to error print in the message indicating lack
of the link to facilitate debugging similar issues in the future.
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 27 +++++++++++++++------------
util.c | 2 +-
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/Detail.c b/Detail.c
index bf881ff..2332b85 100644
--- a/Detail.c
+++ b/Detail.c
@@ -99,21 +99,24 @@ int Detail(char *dev, struct context *c)
inactive = (sra->array_state == ARRAY_ACTIVE ||
sra->array_state == ARRAY_CLEAR);
st = super_by_fd(fd, &subarray);
- if (md_get_array_info(fd, &array) && errno == ENODEV) {
- if (sra->array.major_version == -1 &&
- sra->array.minor_version == -1 &&
- sra->devs == NULL) {
- pr_err("Array associated with md device %s does not exist.\n", dev);
+ if (md_get_array_info(fd, &array)) {
+ if (errno == ENODEV) {
+ if (sra->array.major_version == -1 &&
+ sra->array.minor_version == -1 &&
+ sra->devs == NULL) {
+ pr_err("Array associated with md device %s does not exist.\n",
+ dev);
+ close(fd);
+ sysfs_free(sra);
+ return rv;
+ }
+ array = sra->array;
+ } else {
+ pr_err("cannot get array detail for %s: %s\n",
+ dev, strerror(errno));
close(fd);
- sysfs_free(sra);
return rv;
}
- array = sra->array;
- } else {
- pr_err("cannot get array detail for %s: %s\n",
- dev, strerror(errno));
- close(fd);
- return rv;
}
if (fstat(fd, &stb) != 0 && !S_ISBLK(stb.st_mode))
diff --git a/util.c b/util.c
index d89438c..8eeb509 100644
--- a/util.c
+++ b/util.c
@@ -1169,7 +1169,7 @@ void wait_for(char *dev, int fd)
delay *= 2;
}
if (i == 25)
- dprintf("timeout waiting for %s\n", dev);
+ pr_err("timeout waiting for %s\n", dev);
}
struct superswitch *superlist[] =
--
2.13.6
++++++ 0057-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch -> 0146-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0057-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch 2017-08-24 18:18:07.707036778 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0146-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch 2017-12-08 12:54:41.247537064 +0100
@@ -2,7 +2,6 @@
Date: Thu, 25 May 2017 17:28:11 +0800
Subject: [PATCH] super1: fix sb->max_dev when adding a new disk in linear array
Git-commit: 68fee4af1703dc0bc0d1c9c99fd750e8dca3a131
-Patch-mainline: v4.0-148
References: bsc#1032802
The value of sb->max_dev will always be increased by 1 when adding
@@ -22,6 +21,7 @@
Signed-off-by: Lidong Zhong
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
+
---
super1.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
++++++ 0147-md_u-Remove-unused-ioctl-declaration-of-START_ARRAY.patch ++++++
From ea1c4a8722605da9c2ce5dd1a8324b4f23a34b7a Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Wed, 31 May 2017 19:38:36 +0800
Subject: [PATCH] md_u: Remove unused ioctl declaration of START_ARRAY
Git-commit: ea1c4a8722605da9c2ce5dd1a8324b4f23a34b7a
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
START_ARRAY is no longer used in the code, so get rid of it.
MD commit: fbedac04fa11 ("[PATCH] md: the scheduled removal
of the START_ARRAY ioctl for md") merged in the year 2006.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
md_u.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/md_u.h b/md_u.h
index d59aa2d..2d66d52 100644
--- a/md_u.h
+++ b/md_u.h
@@ -34,7 +34,6 @@
/* usage */
#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
-#define START_ARRAY _IO (MD_MAJOR, 0x31)
#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
--
2.13.6
++++++ 0148-Get-failed-disk-count-from-array-state.patch ++++++
From b13b52c80f3d9e3184ea1d6d39aa7053ef7bae49 Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak
Date: Wed, 31 May 2017 12:46:57 +0200
Subject: [PATCH] Get failed disk count from array state
Git-commit: b13b52c80f3d9e3184ea1d6d39aa7053ef7bae49
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Recent commit has changed the way failed disks are counted. It breaks
recovery for external metadata arrays as failed disks are not part of
the array and have no corresponding entries is sysfs (they are only
reported for containers) so degraded arrays show no failed disks.
Recent commit overwrites GET_DEGRADED result prior to GET_STATE and it
is not set again if GET_STATE has not been requested. As GET_STATE
provides the same information as GET_DEGRADED, the latter is not needed
anymore. Remove GET_DEGRADED option and replace it with GET_STATE
option.
Don't count number of failed disks looking at sysfs entries but
calculate it at the end. Do it only for arrays as containers report
no disks, just spares.
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 14 ++++----------
Monitor.c | 4 ++--
managemon.c | 4 ++--
mdadm.h | 1 -
raid6check.c | 2 +-
sysfs.c | 18 ++++++++----------
6 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 30dc7a2..6cf2174 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -886,16 +886,10 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
}
sra = sysfs_read(-1, mp->devnm,
GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
- GET_DEGRADED|GET_COMPONENT|GET_VERSION);
- if (!sra) {
- /* Probably a container - no degraded info */
- sra = sysfs_read(-1, mp->devnm,
- GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
- GET_COMPONENT|GET_VERSION);
- if (sra)
- sra->array.failed_disks = -1;
- }
- if (!sra)
+ GET_COMPONENT|GET_VERSION);
+ if (sra)
+ sra->array.failed_disks = -1;
+ else
continue;
if (st == NULL) {
int i;
diff --git a/Monitor.c b/Monitor.c
index 725f47d..bef2f1b 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -485,8 +485,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (st->devnm[0] == 0)
strcpy(st->devnm, fd2devnm(fd));
- sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEGRADED |
- GET_MISMATCH | GET_DEVS | GET_STATE);
+ sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_MISMATCH |
+ GET_DEVS | GET_STATE);
if (!sra)
goto disappeared;
diff --git a/managemon.c b/managemon.c
index a8df666..68f0c2d 100644
--- a/managemon.c
+++ b/managemon.c
@@ -685,8 +685,8 @@ static void manage_new(struct mdstat_ent *mdstat,
mdi = sysfs_read(-1, mdstat->devnm,
GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
- GET_DEGRADED|GET_SAFEMODE|
- GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|GET_LAYOUT);
+ GET_SAFEMODE|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
+ GET_LAYOUT);
if (!mdi)
return;
diff --git a/mdadm.h b/mdadm.h
index ec0a39e..ee9b837 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -637,7 +637,6 @@ enum sysfs_read_flags {
GET_MISMATCH = (1 << 5),
GET_VERSION = (1 << 6),
GET_DISKS = (1 << 7),
- GET_DEGRADED = (1 << 8),
GET_SAFEMODE = (1 << 9),
GET_BITMAP_LOCATION = (1 << 10),
diff --git a/raid6check.c b/raid6check.c
index 551f835..a8e6005 100644
--- a/raid6check.c
+++ b/raid6check.c
@@ -562,7 +562,7 @@ int main(int argc, char *argv[])
GET_LEVEL|
GET_LAYOUT|
GET_DISKS|
- GET_DEGRADED |
+ GET_STATE |
GET_COMPONENT|
GET_CHUNK|
GET_DEVS|
diff --git a/sysfs.c b/sysfs.c
index e47f5e4..78d2b52 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -162,18 +162,12 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
goto abort;
sra->array.layout = strtoul(buf, NULL, 0);
}
- if (options & GET_DISKS) {
+ if (options & (GET_DISKS|GET_STATE)) {
strcpy(base, "raid_disks");
if (load_sys(fname, buf, sizeof(buf)))
goto abort;
sra->array.raid_disks = strtoul(buf, NULL, 0);
}
- if (options & GET_DEGRADED) {
- strcpy(base, "degraded");
- if (load_sys(fname, buf, sizeof(buf)))
- goto abort;
- sra->array.failed_disks = strtoul(buf, NULL, 0);
- }
if (options & GET_COMPONENT) {
strcpy(base, "component_size");
if (load_sys(fname, buf, sizeof(buf)))
@@ -359,10 +353,9 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
strcpy(dbase, "state");
if (load_sys(fname, buf, sizeof(buf)))
goto abort;
- if (strstr(buf, "faulty")) {
+ if (strstr(buf, "faulty"))
dev->disk.state |= (1<array.failed_disks++;
- } else {
+ else {
sra->array.working_disks++;
if (strstr(buf, "in_sync")) {
dev->disk.state |= (1<errors = strtoul(buf, NULL, 0);
}
}
+
+ if ((options & GET_STATE) && sra->array.raid_disks)
+ sra->array.failed_disks = sra->array.raid_disks -
+ sra->array.active_disks - sra->array.spare_disks;
+
closedir(dir);
return sra;
--
2.13.6
++++++ 0149-Monitor-don-t-assume-mdadm-parameter-is-a-block-devi.patch ++++++
From cb91230c87e02bf885759e9218abea629ab9f4b9 Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak
Date: Mon, 19 Jun 2017 11:19:53 +0200
Subject: [PATCH] Monitor: don't assume mdadm parameter is a block device
Git-commit: cb91230c87e02bf885759e9218abea629ab9f4b9
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If symlink (e.g. /dev/md/raid) is passed as a parameter to mdadm --wait,
it fails as it's not able to find a corresponding entry in /proc/mdstat
output. Get parameter file major:minor and look for block device name in
sysfs. This commit is partial revert of commit 9e04ac1c43e6
("mdadm/util: unify stat checking blkdev into function").
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index bef2f1b..48c451c 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -982,12 +982,21 @@ static void link_containers_with_subarrays(struct state *list)
int Wait(char *dev)
{
char devnm[32];
+ dev_t rdev;
+ char *tmp;
int rv = 1;
int frozen_remaining = 3;
- if (!stat_is_blkdev(dev, NULL))
+ if (!stat_is_blkdev(dev, &rdev))
+ return 2;
+
+ tmp = devid2devnm(rdev);
+ if (!tmp) {
+ pr_err("Cannot get md device name.\n");
return 2;
- strcpy(devnm, dev);
+ }
+
+ strcpy(devnm, tmp);
while(1) {
struct mdstat_ent *ms = mdstat_read(1, 0);
--
2.13.6
++++++ 0150-super1-Always-round-data-offset-to-1M.patch ++++++
From 795bd44ed11aafbed2628ba21216c667371e79a5 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Wed, 26 Jul 2017 16:41:54 +0200
Subject: [PATCH] super1: Always round data offset to 1M
Git-commit: 795bd44ed11aafbed2628ba21216c667371e79a5
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Currently if metadata requires more then 1M,
data offset will be rounded down to closest MB.
This is not correct, since less then required space is reserved.
Always round data offset up to multiple of 1M.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super1.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/super1.c b/super1.c
index 86ec850..b15a1c7 100644
--- a/super1.c
+++ b/super1.c
@@ -2796,8 +2796,7 @@ static int validate_geometry1(struct supertype *st, int level,
headroom >>= 1;
data_offset = 12*2 + bmspace + headroom;
#define ONE_MEG (2*1024)
- if (data_offset > ONE_MEG)
- data_offset = (data_offset / ONE_MEG) * ONE_MEG;
+ data_offset = ROUND_UP(data_offset, ONE_MEG);
break;
}
if (st->data_offset == INVALID_SECTORS)
--
2.13.6
++++++ 0151-mdadm-r5cache-allow-adding-journal-to-array-without-.patch ++++++
From 3373d49f32b2bd8149f633727eba453708a9bf9c Mon Sep 17 00:00:00 2001
From: Song Liu
Date: Tue, 28 Mar 2017 11:04:44 -0700
Subject: [PATCH] mdadm/r5cache: allow adding journal to array without journal
Git-commit: 3373d49f32b2bd8149f633727eba453708a9bf9c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Currently, --add-journal can be only used to recreate broken journal
for arrays with journal since creation. As the kernel code getting
more mature, this constraint is no longer necessary.
This patch allows --add-journal to add journal to array without
journal.
Signed-off-by: Song Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Manage.c | 6 ------
mdadm.8.in | 5 ++---
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/Manage.c b/Manage.c
index 04b9398..b82a729 100644
--- a/Manage.c
+++ b/Manage.c
@@ -911,7 +911,6 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
/* only add journal to array that supports journaling */
if (dv->disposition == 'j') {
- struct mdinfo mdi;
struct mdinfo *mdp;
mdp = sysfs_read(fd, NULL, GET_ARRAY_STATE);
@@ -928,11 +927,6 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
sysfs_free(mdp);
- tst->ss->getinfo_super(tst, &mdi, NULL);
- if (mdi.journal_device_required == 0) {
- pr_err("%s does not support journal device.\n", devname);
- return -1;
- }
disc.raid_disk = 0;
}
diff --git a/mdadm.8.in b/mdadm.8.in
index ecfe9da..461c5de 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -1526,9 +1526,8 @@ the device is found or <slot>:missing in case the device is not found.
.TP
.BR \-\-add-journal
-Recreate journal for RAID-4/5/6 array that lost a journal device. In the
-current implementation, this command cannot add a journal to an array
-that had a failed journal. To avoid interrupting on-going write opertions,
+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,
.B \-\-add-journal
only works for array in Read-Only state.
--
2.13.6
++++++ 0060-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch -> 0152-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0060-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch 2017-11-25 08:40:37.378708577 +0100
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0152-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch 2017-12-08 12:54:41.335533885 +0100
@@ -1,7 +1,10 @@
-From 7a717ada3297bef83c1f70c6baa50ea15ed10fd1 Mon Sep 17 00:00:00 2001
+From 0e23c597188a65bdf6cd39fafbf596f2317344da Mon Sep 17 00:00:00 2001
From: Guoqing Jiang
-Date: Wed, 22 Nov 2017 12:59:15 +0800
+Date: Wed, 2 Aug 2017 10:05:41 +0800
Subject: [PATCH] udev rules: introduce rules for cluster-md to confirm device
+Git-commit: 0e23c597188a65bdf6cd39fafbf596f2317344da
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
For cluster scenario, add device is different with native raid.
When a node issues adds a device, then the node will broadcast
@@ -9,10 +12,10 @@
node can find the device with the specific UUID, it must confirm
the device, otherwise reports it is missing.
-[gqjiang: changed a little bit since difference context in Makefile]
-
Signed-off-by: Guoqing Jiang
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Makefile | 6 ++++--
udev-md-clustered-confirm-device.rules | 21 +++++++++++++++++++++
@@ -20,25 +23,25 @@
create mode 100644 udev-md-clustered-confirm-device.rules
diff --git a/Makefile b/Makefile
-index 5fd7f166e7e1..70df31267982 100644
+index 021d3ad..0977f27 100644
--- a/Makefile
+++ b/Makefile
-@@ -291,8 +291,10 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
+@@ -256,8 +256,10 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
$(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
$(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
--install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules
-- @for file in 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \
-+install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules \
-+ udev-md-clustered-confirm-device.rules
-+ @for file in 63-md-raid-arrays.rules 64-md-raid-assembly.rules \
-+ 69-md-clustered-confirm-device.rules; \
+-install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid-creating.rules
+- @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \
++install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid-creating.rules \
++ udev-md-clustered-confirm-device.rules
++ @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-assembly.rules \
++ 69-md-clustered-confirm-device.rules ; \
do sed -e 's,BINDIR,$(BINDIR),g' udev-$${file#??-} > .install.tmp.1 && \
$(ECHO) $(INSTALL) -D -m 644 udev-$${file#??-} $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \
$(INSTALL) -D -m 644 .install.tmp.1 $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \
diff --git a/udev-md-clustered-confirm-device.rules b/udev-md-clustered-confirm-device.rules
new file mode 100644
-index 000000000000..3e5381e19315
+index 0000000..3e5381e
--- /dev/null
+++ b/udev-md-clustered-confirm-device.rules
@@ -0,0 +1,21 @@
@@ -64,5 +67,5 @@
+
+LABEL="clustermd_end"
--
-2.10.0
+2.13.6
++++++ 0153-Detail-correct-output-for-active-arrays.patch ++++++
From a822017f30e0dadc60a687900c2aa4da32e09a93 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Thu, 10 Aug 2017 11:43:48 +0200
Subject: [PATCH] Detail: correct output for active arrays
Git-commit: a822017f30e0dadc60a687900c2aa4da32e09a93
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
The check for inactive array is incorrect as it compares it against
active array. Introduce a new function md_is_array_active so the check
is consistent across the code.
As the output contains list of disks in the array include this
information in sysfs read.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 15 +++++++--------
mdadm.h | 1 +
util.c | 15 +++++++++------
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/Detail.c b/Detail.c
index 2332b85..2c9fb24 100644
--- a/Detail.c
+++ b/Detail.c
@@ -86,7 +86,8 @@ int Detail(char *dev, struct context *c)
dev, strerror(errno));
return rv;
}
- sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS | GET_ARRAY_STATE);
+ sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS |
+ GET_ARRAY_STATE | GET_STATE);
if (!sra) {
if (md_get_array_info(fd, &array)) {
pr_err("%s does not appear to be an md device\n", dev);
@@ -96,8 +97,7 @@ int Detail(char *dev, struct context *c)
}
external = (sra != NULL && sra->array.major_version == -1 &&
sra->array.minor_version == -2);
- inactive = (sra->array_state == ARRAY_ACTIVE ||
- sra->array_state == ARRAY_CLEAR);
+ inactive = (sra != NULL && !md_array_is_active(sra));
st = super_by_fd(fd, &subarray);
if (md_get_array_info(fd, &array)) {
if (errno == ENODEV) {
@@ -314,11 +314,10 @@ int Detail(char *dev, struct context *c)
next = array.raid_disks * 2;
if (inactive) {
struct mdinfo *mdi;
- if (sra != NULL)
- for (mdi = sra->devs; mdi; mdi = mdi->next) {
- disks[next++] = mdi->disk;
- disks[next - 1].number = -1;
- }
+ for (mdi = sra->devs; mdi; mdi = mdi->next) {
+ disks[next++] = mdi->disk;
+ disks[next - 1].number = -1;
+ }
} else for (d = 0; d < max_disks; d++) {
mdu_disk_info_t disk;
disk.number = d;
diff --git a/mdadm.h b/mdadm.h
index ee9b837..191ae8f 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1425,6 +1425,7 @@ extern int Restore_metadata(char *dev, char *dir, struct context *c,
int md_array_valid(int fd);
int md_array_active(int fd);
+int md_array_is_active(struct mdinfo *info);
int md_get_array_info(int fd, struct mdu_array_info_s *array);
int md_set_array_info(int fd, struct mdu_array_info_s *array);
int md_get_disk_info(int fd, struct mdu_disk_info_s *disk);
diff --git a/util.c b/util.c
index 8eeb509..c1c8509 100644
--- a/util.c
+++ b/util.c
@@ -228,15 +228,11 @@ int md_array_active(int fd)
{
struct mdinfo *sra;
struct mdu_array_info_s array;
- int ret;
+ int ret = 0;
sra = sysfs_read(fd, NULL, GET_ARRAY_STATE);
if (sra) {
- if (sra->array_state != ARRAY_CLEAR &&
- sra->array_state != ARRAY_INACTIVE &&
- sra->array_state != ARRAY_UNKNOWN_STATE)
- ret = 0;
- else
+ if (!md_array_is_active(sra))
ret = -ENODEV;
free(sra);
@@ -251,6 +247,13 @@ int md_array_active(int fd)
return !ret;
}
+int md_array_is_active(struct mdinfo *info)
+{
+ return (info->array_state != ARRAY_CLEAR &&
+ info->array_state != ARRAY_INACTIVE &&
+ info->array_state != ARRAY_UNKNOWN_STATE);
+}
+
/*
* Get array info from the kernel. Longer term we want to deprecate the
* ioctl and get it from sysfs.
--
2.13.6
++++++ 0154-imsm-rebuild-from-2-disk-RAID10.patch ++++++
From fb12a7454000c56aa0439c5bc07fb29de2f3f2a1 Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak
Date: Thu, 10 Aug 2017 15:47:22 +0200
Subject: [PATCH] imsm: rebuild from 2-disk RAID10
Git-commit: fb12a7454000c56aa0439c5bc07fb29de2f3f2a1
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
When RAID10 loses 2 disks and it is still operational, it cannot be
rebuilt. The rebuild process starts for the first disk and completes,
however completion is not recorded in metadata. There is an assumption
that rebuild completion corresponds to transition from degraded to
normal state. It's not the case for 2-disk RAID10 as it's still degraded
after rebuild to first disk completes.
Check if disk rebuild flag is set in the second map and clear it. So far it
has been checked only in the first map (where it was not set). The flag in
the second map has not been cleared but rebuild completion dropped second
map so the problem was not visible.
If rebuild completion is notified and array still has failed disks and is in
degraded state, check first if rebuild position is really unset (the same
check as for array in normal state). If so, mark migration as done but don't
change array state (it should remain degraded). Update failed disk number.
On rebuild start don't clear the rebuild flag in the destination map for all
the drives because failed state is lost for one of them. Just do a copy of
a map and clear the flag in the destination map for the disk that goes into
rebuild. Similarily preserve the rebuild flag in the map during disk removal.
If the disk is missing on array start and migration has been in progress,
don't just cancel it. Check first if maybe one of the disks was not under
rebuild (rebuild flag present both in source and destination map). If so,
rebuild was running despite of failed disk so there is no need to cancel
migration.
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 67 insertions(+), 10 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 51b7cc3..125c3a9 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4023,7 +4023,7 @@ static void migrate(struct imsm_dev *dev, struct intel_super *super,
/* duplicate and then set the target end state in map[0] */
memcpy(dest, src, sizeof_imsm_map(src));
- if (migr_type == MIGR_REBUILD || migr_type == MIGR_GEN_MIGR) {
+ if (migr_type == MIGR_GEN_MIGR) {
__u32 ord;
int i;
@@ -7936,14 +7936,35 @@ static void handle_missing(struct intel_super *super, struct imsm_dev *dev)
/* end process for initialization and rebuild only
*/
if (is_gen_migration(dev) == 0) {
- __u8 map_state;
- int failed;
+ int failed = imsm_count_failed(super, dev, MAP_0);
- failed = imsm_count_failed(super, dev, MAP_0);
- map_state = imsm_check_degraded(super, dev, failed, MAP_0);
+ if (failed) {
+ __u8 map_state;
+ struct imsm_map *map = get_imsm_map(dev, MAP_0);
+ struct imsm_map *map1;
+ int i, ord, ord_map1;
+ int rebuilt = 1;
- if (failed)
- end_migration(dev, super, map_state);
+ for (i = 0; i < map->num_members; i++) {
+ ord = get_imsm_ord_tbl_ent(dev, i, MAP_0);
+ if (!(ord & IMSM_ORD_REBUILD))
+ continue;
+
+ map1 = get_imsm_map(dev, MAP_1);
+ if (!map1)
+ continue;
+
+ ord_map1 = __le32_to_cpu(map1->disk_ord_tbl[i]);
+ if (ord_map1 & IMSM_ORD_REBUILD)
+ rebuilt = 0;
+ }
+
+ if (rebuilt) {
+ map_state = imsm_check_degraded(super, dev,
+ failed, MAP_0);
+ end_migration(dev, super, map_state);
+ }
+ }
}
for (dl = super->missing; dl; dl = dl->next)
mark_missing(super, dev, &dl->disk, dl->index);
@@ -8225,8 +8246,10 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
int failed;
int ord;
__u8 map_state;
+ int rebuild_done = 0;
+ int i;
- ord = imsm_disk_slot_to_ord(a, n);
+ ord = get_imsm_ord_tbl_ent(dev, n, MAP_X);
if (ord < 0)
return;
@@ -8244,6 +8267,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
struct imsm_map *migr_map = get_imsm_map(dev, MAP_1);
set_imsm_ord_tbl_ent(migr_map, n, ord_to_idx(ord));
+ rebuild_done = 1;
super->updates_pending++;
}
@@ -8306,7 +8330,39 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
dprintf_cont(" Map state change");
end_migration(dev, super, map_state);
super->updates_pending++;
+ } else if (!rebuild_done) {
+ break;
+ }
+
+ /* check if recovery is really finished */
+ for (mdi = a->info.devs; mdi ; mdi = mdi->next)
+ if (mdi->recovery_start != MaxSector) {
+ recovery_not_finished = 1;
+ break;
+ }
+ if (recovery_not_finished) {
+ dprintf_cont("\n");
+ dprintf("Rebuild has not finished yet, state not changed");
+ if (a->last_checkpoint < mdi->recovery_start) {
+ a->last_checkpoint =
+ mdi->recovery_start;
+ super->updates_pending++;
+ }
+ break;
}
+
+ dprintf_cont(" Rebuild done, still degraded");
+ dev->vol.migr_state = 0;
+ set_migr_type(dev, 0);
+ dev->vol.curr_migr_unit = 0;
+
+ for (i = 0; i < map->num_members; i++) {
+ int idx = get_imsm_ord_tbl_ent(dev, i, MAP_0);
+
+ if (idx & IMSM_ORD_REBUILD)
+ map->failed_disk_num = i;
+ }
+ super->updates_pending++;
break;
}
if (is_gen_migration(dev)) {
@@ -9936,7 +9992,7 @@ static void imsm_delete(struct intel_super *super, struct dl **dlp, unsigned ind
struct imsm_dev *dev;
struct imsm_map *map;
unsigned int i, j, num_members;
- __u32 ord;
+ __u32 ord, ord_map0;
struct bbm_log *log = super->bbm_log;
dprintf("deleting device[%d] from imsm_super\n", index);
@@ -9958,12 +10014,13 @@ static void imsm_delete(struct intel_super *super, struct dl **dlp, unsigned ind
* ord-flags to the first map
*/
ord = get_imsm_ord_tbl_ent(dev, j, MAP_X);
+ ord_map0 = get_imsm_ord_tbl_ent(dev, j, MAP_0);
if (ord_to_idx(ord) <= index)
continue;
map = get_imsm_map(dev, MAP_0);
- set_imsm_ord_tbl_ent(map, j, ord_to_idx(ord - 1));
+ set_imsm_ord_tbl_ent(map, j, ord_map0 - 1);
map = get_imsm_map(dev, MAP_1);
if (map)
set_imsm_ord_tbl_ent(map, j, ord - 1);
--
2.13.6
++++++ 0155-Error-messages-should-end-with-a-newline-character.patch ++++++
From 8e5b52cdda95965787e2a289c855a4ab7099f00d Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 4 Aug 2017 15:30:02 +1000
Subject: [PATCH] Error messages should end with a newline character.
Git-commit: 8e5b52cdda95965787e2a289c855a4ab7099f00d
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Add "\n" to the end of error messages which don't already
have one. Also spell "opened" correctly.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Build.c | 4 ++--
Grow.c | 4 ++--
Manage.c | 2 +-
mdopen.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Build.c b/Build.c
index 70ba068..962c2e3 100644
--- a/Build.c
+++ b/Build.c
@@ -181,7 +181,7 @@ int Build(char *mddev, struct mddev_dev *devlist,
int major = BITMAP_MAJOR_HI;
#if 0
if (s->bitmap_chunk == UnSet) {
- pr_err("%s cannot be openned.", s->bitmap_file);
+ pr_err("%s cannot be opened.\n", s->bitmap_file);
goto abort;
}
#endif
@@ -193,7 +193,7 @@ int Build(char *mddev, struct mddev_dev *devlist,
}
bitmap_fd = open(s->bitmap_file, O_RDWR);
if (bitmap_fd < 0) {
- pr_err("%s cannot be openned.", s->bitmap_file);
+ pr_err("%s cannot be opened.\n", s->bitmap_file);
goto abort;
}
}
diff --git a/Grow.c b/Grow.c
index b1cb306..534ba80 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3202,7 +3202,7 @@ static int reshape_array(char *container, int fd, char *devname,
if (info2) {
if (sysfs_init(info2, fd, st->devnm)) {
- pr_err("unable to initialize sysfs for %s",
+ pr_err("unable to initialize sysfs for %s\n",
st->devnm);
free(info2);
goto release;
@@ -5146,7 +5146,7 @@ int Grow_continue_command(char *devname, int fd,
}
if (sysfs_init(content, fd2, mdstat->devnm)) {
- pr_err("Unable to initialize sysfs for %s, Grow cannot continue",
+ pr_err("Unable to initialize sysfs for %s, Grow cannot continue.\n",
mdstat->devnm);
ret_val = 1;
close(fd2);
diff --git a/Manage.c b/Manage.c
index b82a729..871d342 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1417,7 +1417,7 @@ int Manage_subdevs(char *devname, int fd,
}
add_devlist = conf_get_devs();
if (add_devlist == NULL) {
- pr_err("no devices to scan for missing members.");
+ pr_err("no devices to scan for missing members.\n");
continue;
}
for (dp = &add_devlist; *dp; dp = & (*dp)->next)
diff --git a/mdopen.c b/mdopen.c
index c4f1c12..3c0052f 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -198,7 +198,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
return -1;
}
if (cname[0] == 0) {
- pr_err("%s is an invalid name for an md device (empty!).", dev);
+ pr_err("%s is an invalid name for an md device (empty!).\n", dev);
return -1;
}
if (num < 0) {
--
2.13.6
++++++ 0156-Use-correct-syntax-for-passing-DEVLINKS-to-mdadm-fro.patch ++++++
From ceb5f8ef92c97d1f44c75a3b74f64aa12a3303ef Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 4 Aug 2017 15:30:02 +1000
Subject: [PATCH] Use correct syntax for passing DEVLINKS to mdadm from udev
Git-commit: ceb5f8ef92c97d1f44c75a3b74f64aa12a3303ef
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
${DEVLINKS}
is not valid udev syntax, and is passed through uninterpreted.
$env{DEVLINKS}
or
%e{DEVLINKS}
is correct.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.8.in | 2 +-
udev-md-raid-assembly.rules | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mdadm.8.in b/mdadm.8.in
index 461c5de..e0747fb 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -2947,7 +2947,7 @@ This is the only context where the aliases are used. They are
usually provided by a
.I udev
rules mentioning
-.BR ${DEVLINKS} .
+.BR $env{DEVLINKS} .
.IP +
Does the device have a valid md superblock? If a specific metadata
diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules
index 8ca232a..9f055ed 100644
--- a/udev-md-raid-assembly.rules
+++ b/udev-md-raid-assembly.rules
@@ -30,7 +30,7 @@ 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 ${DEVLINKS}"
+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", ENV{ID_PATH}=="?*", RUN+="BINDIR/mdadm -If $name --path $env{ID_PATH}"
ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="BINDIR/mdadm -If $name"
--
2.13.6
++++++ 0058-super1-only-set-clustered-flag-when-bitmap-is-presen.patch -> 0157-super1-only-set-clustered-flag-when-bitmap-is-presen.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0058-super1-only-set-clustered-flag-when-bitmap-is-presen.patch 2017-08-24 18:18:08.730892617 +0200
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0157-super1-only-set-clustered-flag-when-bitmap-is-presen.patch 2017-12-08 12:54:41.415530996 +0100
@@ -2,8 +2,9 @@
From: NeilBrown
Date: Fri, 4 Aug 2017 15:30:02 +1000
Subject: [PATCH] super1: only set clustered flag when bitmap is present
-Patch-mainline: mdadm-4.0
-References: bsc#1047314
+Git-commit: 6438c249c4fed92cf6e5fb492d19f4c4f516ff6f
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
If no bitmap is present, then the test
@@ -12,23 +13,22 @@
accesses uninitialised memory. So move that test inside
a test for a bitmap being present.
-Note by Coly Li: this patch is modified for SLE12-SP3.
-
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
+
---
super1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
-Index: mdadm-4.0/super1.c
-===================================================================
---- mdadm-4.0.orig/super1.c
-+++ mdadm-4.0/super1.c
-@@ -950,14 +950,14 @@ static void getinfo_super1(struct supert
+diff --git a/super1.c b/super1.c
+index b15a1c7..f6a1045 100644
+--- a/super1.c
++++ b/super1.c
+@@ -977,14 +977,14 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
+ info->array.chunk_size = __le32_to_cpu(sb->chunksize)*512;
info->array.state =
- (__le64_to_cpu(sb->resync_offset) == MaxSector)
- ? 1 : 0;
+ (__le64_to_cpu(sb->resync_offset) == MaxSector) ? 1 : 0;
- if (__le32_to_cpu(bsb->nodes) > 1)
- info->array.state |= (1 << MD_SB_CLUSTERED);
@@ -42,3 +42,6 @@
} else if (sb->feature_map & __le32_to_cpu(MD_FEATURE_PPL)) {
info->ppl_offset = __le16_to_cpu(sb->ppl.offset);
info->ppl_size = __le16_to_cpu(sb->ppl.size);
+--
+2.13.6
+
++++++ 0158-Don-t-use-exit-ERANGE.patch ++++++
From dcd24efcfab50c3c298d9b1c941edb6954c2677e Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 4 Aug 2017 15:30:02 +1000
Subject: [PATCH] Don't use exit(ERANGE)
Git-commit: dcd24efcfab50c3c298d9b1c941edb6954c2677e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
mdadm uses smaller exit codes like 0,1,2,3,4.
Using ERANGE is inconsistent and not helpful.
So change it to a more consistent number.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mdadm.c b/mdadm.c
index 70b16f2..d80aab3 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -619,7 +619,7 @@ int main(int argc, char *argv[])
c.homecluster = optarg;
if (strlen(c.homecluster) > 64) {
pr_err("Cluster name too big.\n");
- exit(ERANGE);
+ exit(2);
}
continue;
case O(CREATE,'x'): /* number of spare (eXtra) disks */
--
2.13.6
++++++ 0159-Monitor-containers-don-t-have-the-same-sysfs-propert.patch ++++++
From 802961a2396d342b7bb3d548d412be26acbd7fa8 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Wed, 16 Aug 2017 14:22:32 +0200
Subject: [PATCH] Monitor: containers don't have the same sysfs properties as
arrays
Git-commit: 802961a2396d342b7bb3d548d412be26acbd7fa8
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
GET_MISMATCH option doesn't exist for containers so sysfs_read fails if
this information is requested. Set options according to the device using
information from /proc/mdstat.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 48c451c..f70e5b5 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -465,6 +465,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int last_disk;
int new_array = 0;
int retval;
+ int is_container = 0;
+ unsigned long array_only_flags = 0;
if (test)
alert("TestMessage", dev, NULL, ainfo);
@@ -475,6 +477,26 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (fd < 0)
goto disappeared;
+ if (st->devnm[0] == 0)
+ strcpy(st->devnm, fd2devnm(fd));
+
+ for (mse2 = mdstat; mse2; mse2 = mse2->next)
+ if (strcmp(mse2->devnm, st->devnm) == 0) {
+ mse2->devnm[0] = 0; /* flag it as "used" */
+ mse = mse2;
+ }
+
+ if (!mse) {
+ /* duplicated array in statelist
+ * or re-created after reading mdstat
+ */
+ st->err++;
+ goto out;
+ }
+
+ if (mse->level == NULL)
+ is_container = 1;
+
if (!md_array_active(fd))
goto disappeared;
@@ -482,11 +504,12 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (md_get_array_info(fd, &array) < 0)
goto disappeared;
- if (st->devnm[0] == 0)
- strcpy(st->devnm, fd2devnm(fd));
+ if (!is_container)
+ array_only_flags |= GET_MISMATCH;
+
+ sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEVS |
+ GET_STATE | array_only_flags);
- sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_MISMATCH |
- GET_DEVS | GET_STATE);
if (!sra)
goto disappeared;
@@ -500,19 +523,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
goto out;
}
- for (mse2 = mdstat; mse2; mse2 = mse2->next)
- if (strcmp(mse2->devnm, st->devnm) == 0) {
- mse2->devnm[0] = 0; /* flag it as "used" */
- mse = mse2;
- }
-
- if (!mse) {
- /* duplicated array in statelist
- * or re-created after reading mdstat*/
- st->err++;
- close(fd);
- goto out;
- }
/* this array is in /proc/mdstat */
if (array.utime == 0)
/* external arrays don't update utime, so
@@ -653,7 +663,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
out:
if (sra)
sysfs_free(sra);
- if (fd > 0)
+ if (fd >= 0)
close(fd);
return retval;
--
2.13.6
++++++ 0160-Monitor-Include-containers-in-spare-migration.patch ++++++
From 2dab69c9e3acace828bbb6a00514fa820f8ca64f Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Wed, 16 Aug 2017 14:59:46 +0200
Subject: [PATCH] Monitor: Include containers in spare migration
Git-commit: 2dab69c9e3acace828bbb6a00514fa820f8ca64f
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Spare migration doesn't work for external metadata. mdadm skips
a container with spare device because it is inactive. It used to work
because GET_ARRAY_INFO ioctl returned valid structure for a container
and mdadm treated such response as active container. Current
implementation checks it in sysfs where container is shown as inactive.
Adapt sysfs implementation to work the same way as ioctl.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Monitor.c b/Monitor.c
index f70e5b5..497e364 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -497,7 +497,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (mse->level == NULL)
is_container = 1;
- if (!md_array_active(fd))
+ if (!is_container && !md_array_active(fd))
goto disappeared;
fcntl(fd, F_SETFD, FD_CLOEXEC);
--
2.13.6
++++++ 0161-Detail-differentiate-between-container-and-inactive-.patch ++++++
From bb8354598676428af01f23bfb1876c7356d61147 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Fri, 18 Aug 2017 12:00:23 +0200
Subject: [PATCH] Detail: differentiate between container and inactive arrays
Git-commit: bb8354598676428af01f23bfb1876c7356d61147
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Containers used to be handled as active arrays because GET_ARRAY_INFO
ioctl returns valid structure for them. As containers appear as inactive
in sysfs, the output for detail command has changed.
Stop relying on inactive state for containers. Make the output look the
same as in mdadm 4.0.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Detail.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/Detail.c b/Detail.c
index 2c9fb24..4dcf81d 100644
--- a/Detail.c
+++ b/Detail.c
@@ -80,6 +80,7 @@ int Detail(char *dev, struct context *c)
char *avail = NULL;
int external;
int inactive;
+ int is_container = 0;
if (fd < 0) {
pr_err("cannot open %s: %s\n",
@@ -119,6 +120,8 @@ int Detail(char *dev, struct context *c)
}
}
+ if (array.raid_disks == 0 && external)
+ is_container = 1;
if (fstat(fd, &stb) != 0 && !S_ISBLK(stb.st_mode))
stb.st_rdev = 0;
rv = 0;
@@ -228,7 +231,7 @@ int Detail(char *dev, struct context *c)
printf("MD_LEVEL=%s\n", str);
printf("MD_DEVICES=%d\n", array.raid_disks);
} else {
- if (!inactive)
+ if (is_container)
printf("MD_LEVEL=container\n");
printf("MD_DEVICES=%d\n", array.nr_disks);
}
@@ -357,13 +360,16 @@ int Detail(char *dev, struct context *c)
if (c->brief) {
mdu_bitmap_file_t bmf;
- printf("%sARRAY %s", inactive ? "INACTIVE-":"", dev);
+ if (inactive && !is_container)
+ printf("INACTIVE-ARRAY %s", dev);
+ else
+ printf("ARRAY %s", dev);
if (c->verbose > 0) {
if (array.raid_disks)
printf(" level=%s num-devices=%d",
str ? str : "-unknown-",
array.raid_disks);
- else if (!inactive)
+ else if (is_container)
printf(" level=container num-devices=%d",
array.nr_disks);
else
@@ -416,7 +422,7 @@ int Detail(char *dev, struct context *c)
atime = array.ctime;
if (atime)
printf(" Creation Time : %.24s\n", ctime(&atime));
- if (array.raid_disks == 0 && external)
+ if (is_container)
str = "container";
if (str)
printf(" Raid Level : %s\n", str);
@@ -489,7 +495,7 @@ int Detail(char *dev, struct context *c)
" (DELAYED)": "",
(e && e->percent == RESYNC_PENDING) ?
" (PENDING)": "");
- } else if (inactive) {
+ } else if (inactive && !is_container) {
printf(" State : inactive\n");
}
if (array.raid_disks)
--
2.13.6
++++++ 0162-mdadm-install-two-more-udev-rules-in-mdadm.spec.patch ++++++
From 52f6a11ec800114164a5b6866548109e0cbf8578 Mon Sep 17 00:00:00 2001
From: Song Liu
Date: Mon, 28 Aug 2017 15:20:35 -0700
Subject: [PATCH] mdadm: install two more udev rules in mdadm.spec
Git-commit: 52f6a11ec800114164a5b6866548109e0cbf8578
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
To avoid rpmbuild error.
Signed-off-by: Song Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.spec | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mdadm.spec b/mdadm.spec
index 4e97efb..4e6f870 100644
--- a/mdadm.spec
+++ b/mdadm.spec
@@ -37,8 +37,10 @@ rm -rf $RPM_BUILD_ROOT
%doc TODO ChangeLog mdadm.conf-example COPYING
%{_sbindir}/mdadm
%{_sbindir}/mdmon
+/usr/lib/udev/rules.d/01-md-raid-creating.rules
/usr/lib/udev/rules.d/63-md-raid-arrays.rules
/usr/lib/udev/rules.d/64-md-raid-assembly.rules
+/usr/lib/udev/rules.d/69-md-clustered-confirm-device.rules
%config(noreplace,missingok)/%{_sysconfdir}/mdadm.conf
%{_mandir}/man*/md*
--
2.13.6
++++++ 0163-mdadm-set-journal_clean-after-scanning-all-disks.patch ++++++
From 3b8c7127558bad386c8350e039061107c9cf6cde Mon Sep 17 00:00:00 2001
From: Song Liu
Date: Tue, 29 Aug 2017 09:53:02 -0700
Subject: [PATCH] mdadm: set journal_clean after scanning all disks
Git-commit: 3b8c7127558bad386c8350e039061107c9cf6cde
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Summary:
In Incremental.c:count_active(), max_events is tracked to show to
which devices are up to date. If a device has events==max_events+1,
getinfo_super() is called to reload the superblock from this
device. getinfo_super1() blindly set journal_clean to 0, which is
wrong.
This patch fixes this by tracking max_journal_events for all the
disks. After scanning all disks, journal_clean is set if
max_journal_events >= max_events-1.
Signed-off-by: Song Liu
Reviewed-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 6cf2174..91301eb 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -684,6 +684,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
int cnt = 0;
int replcnt = 0;
__u64 max_events = 0;
+ __u64 max_journal_events = 0;
char *avail = NULL;
int *best = NULL;
char *devmap = NULL;
@@ -714,8 +715,9 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
info.array.raid_disks = raid_disks;
st->ss->getinfo_super(st, &info, devmap + raid_disks * devnum);
- if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL)
- bestinfo->journal_clean = 1;
+ if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL &&
+ info.events > max_journal_events)
+ max_journal_events = info.events;
if (!avail) {
raid_disks = info.array.raid_disks;
avail = xcalloc(raid_disks, 1);
@@ -765,6 +767,8 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
replcnt++;
st->ss->free_super(st);
}
+ if (max_journal_events >= max_events - 1)
+ bestinfo->journal_clean = 1;
if (!avail)
return 0;
--
2.13.6
++++++ 0164-mdadm-bitmap-examine-bitmap-failed-when-bitmap-is-ex.patch ++++++
From 8cc56e8b3269305ec5483527d853464eac3bf690 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Mon, 28 Aug 2017 17:24:27 +0800
Subject: [PATCH] mdadm/bitmap: examine-bitmap failed when bitmap is external
mode
Git-commit: 8cc56e8b3269305ec5483527d853464eac3bf690
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
--examine-bitmap: the bitmap_file_open() shouldn't omit the
regular file descriptor when the bitmap is external mode.
Such as: ./mdadm -X /mnt/3
This commit is partial revert of commit 0a6bff09d416
(mdadm/util: unify fstat checking blkdev into function)
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
bitmap.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/bitmap.c b/bitmap.c
index 3653660..e38cb96 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -183,6 +183,7 @@ static int
bitmap_file_open(char *filename, struct supertype **stp, int node_num)
{
int fd;
+ struct stat stb;
struct supertype *st = *stp;
fd = open(filename, O_RDONLY|O_DIRECT);
@@ -192,7 +193,12 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
return -1;
}
- if (fstat_is_blkdev(fd, filename, NULL)) {
+ if (fstat(fd, &stb) < 0) {
+ pr_err("fstat failed for %s: %s\n", filename, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ if ((stb.st_mode & S_IFMT) == S_IFBLK) {
/* block device, so we are probably after an internal bitmap */
if (!st)
st = guess_super(fd);
@@ -211,11 +217,7 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
fd = -1;
}
}
-
*stp = st;
- } else {
- close(fd);
- return -1;
}
return fd;
--
2.13.6
++++++ 0165-mdopen-call-modprobe-md_mod-if-it-might-be-needed.patch ++++++
From fdbf7aaa19564520055971724b70ae1652e35788 Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Mon, 25 Sep 2017 15:52:19 +1000
Subject: [PATCH] mdopen: call "modprobe md_mod" if it might be needed.
Git-commit: fdbf7aaa19564520055971724b70ae1652e35788
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Creating an array by opening a block-device with major number of 9
will transparently load the md module if needed.
Creating an array by opening
/sys/module/md_mod/parameters/new_array
and writing to it won't, it will just fail if md_mod isn't loaded.
So when opening that file fails with ENOENT, run "modprobe md_mod" and
try again.
This fixes a bug whereby if you have "CREATE names=yes" in mdadm.conf,
and the md modules isn't loaded, then creating or assembling an
array will not honor the "names=yes" configuration.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdopen.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mdopen.c b/mdopen.c
index 3c0052f..dcdc6f2 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -312,6 +312,10 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
if (block_udev)
udev_block(devnm);
fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
+ if (fd < 0 && errno == ENOENT) {
+ system("modprobe md_mod");
+ fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
+ }
if (fd >= 0) {
n = write(fd, devnm, strlen(devnm));
close(fd);
--
2.13.6
++++++ 0166-lib-devid2kname-should-take-a-dev_t.patch ++++++
From d3c40faba807e3c7a63c5fe34de52bf753c88b2d Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 29 Sep 2017 17:54:12 -0400
Subject: [PATCH] lib: devid2kname() should take a dev_t
Git-commit: d3c40faba807e3c7a63c5fe34de52bf753c88b2d
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Make devid2kname() and devid2devnm() consistent in their APIs
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
lib.c | 5 ++---
mdadm.h | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib.c b/lib.c
index be093e8..60890b9 100644
--- a/lib.c
+++ b/lib.c
@@ -61,7 +61,7 @@ int get_mdp_major(void)
return mdp_major;
}
-char *devid2kname(int devid)
+char *devid2kname(dev_t devid)
{
char path[30];
char link[PATH_MAX];
@@ -73,8 +73,7 @@ char *devid2kname(int devid)
* /sys/dev/block/%d:%d link which must look like
* and take the last component.
*/
- sprintf(path, "/sys/dev/block/%d:%d", major(devid),
- minor(devid));
+ sprintf(path, "/sys/dev/block/%d:%d", major(devid), minor(devid));
n = readlink(path, link, sizeof(link) - 1);
if (n > 0) {
link[n] = 0;
diff --git a/mdadm.h b/mdadm.h
index 191ae8f..db08188 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1537,7 +1537,7 @@ extern void print_r10_layout(int layout);
extern char *find_free_devnm(int use_partitions);
extern void put_md_name(char *name);
-extern char *devid2kname(int devid);
+extern char *devid2kname(dev_t devid);
extern char *devid2devnm(dev_t devid);
extern dev_t devnm2devid(char *devnm);
extern char *get_md_name(char *devnm);
--
2.13.6
++++++ 0167-sysfs_init_dev-take-a-dev_t-argument.patch ++++++
From a37563c91386a0c53d2d46aad00fe89ee28bd0da Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 29 Sep 2017 18:04:06 -0400
Subject: [PATCH] sysfs_init_dev - take a dev_t argument
Git-commit: a37563c91386a0c53d2d46aad00fe89ee28bd0da
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Be consistent and use the correct type.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.h | 2 +-
sysfs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index db08188..3fc8a4f 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -654,7 +654,7 @@ enum sysfs_read_flags {
*/
extern int sysfs_open(char *devnm, char *devname, char *attr);
extern int sysfs_init(struct mdinfo *mdi, int fd, char *devnm);
-extern void sysfs_init_dev(struct mdinfo *mdi, unsigned long devid);
+extern void sysfs_init_dev(struct mdinfo *mdi, dev_t devid);
extern void sysfs_free(struct mdinfo *sra);
extern struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options);
extern int sysfs_attr_match(const char *attr, const char *str);
diff --git a/sysfs.c b/sysfs.c
index 78d2b52..68ddd5f 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -78,7 +78,7 @@ int sysfs_open(char *devnm, char *devname, char *attr)
return fd;
}
-void sysfs_init_dev(struct mdinfo *mdi, unsigned long devid)
+void sysfs_init_dev(struct mdinfo *mdi, dev_t devid)
{
snprintf(mdi->sys_name,
sizeof(mdi->sys_name), "dev-%s", devid2kname(devid));
--
2.13.6
++++++ 0168-Manage_subdevs-Use-a-dev_t.patch ++++++
From ffaf1a7eefc6167d7457d649e628c04ccee9a4dd Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 29 Sep 2017 18:08:01 -0400
Subject: [PATCH] Manage_subdevs(): Use a dev_t
Git-commit: ffaf1a7eefc6167d7457d649e628c04ccee9a4dd
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Use the correct type for rdev
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Manage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Manage.c b/Manage.c
index 871d342..21536f5 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1367,7 +1367,7 @@ int Manage_subdevs(char *devname, int fd,
}
for (dv = devlist; dv; dv = dv->next) {
- unsigned long rdev = 0; /* device to add/remove etc */
+ dev_t rdev = 0; /* device to add/remove etc */
int rv;
int mj,mn;
--
2.13.6
++++++ 0169-util-Code-is-80-characters-wide.patch ++++++
From b7a462e56135e38dfd9e53aeed6f425c28b1bbc7 Mon Sep 17 00:00:00 2001
From: Jes Sorensen
Date: Fri, 29 Sep 2017 18:15:23 -0400
Subject: [PATCH] util: Code is 80 characters wide
Git-commit: b7a462e56135e38dfd9e53aeed6f425c28b1bbc7
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Lets not make things uglier than they need to be.
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
util.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/util.c b/util.c
index c1c8509..68af381 100644
--- a/util.c
+++ b/util.c
@@ -147,9 +147,9 @@ int cluster_get_dlmlock(int *lockid)
}
snprintf(str, 64, "bitmap%s", cluster_name);
- ret = dlm_hooks->ls_lock(dlm_lock_res->ls, LKM_PWMODE, &dlm_lock_res->lksb,
- flags, str, strlen(str), 0, dlm_ast,
- dlm_lock_res, NULL, NULL);
+ ret = dlm_hooks->ls_lock(dlm_lock_res->ls, LKM_PWMODE,
+ &dlm_lock_res->lksb, flags, str, strlen(str),
+ 0, dlm_ast, dlm_lock_res, NULL, NULL);
if (ret) {
pr_err("error %d when get PW mode on lock %s\n", errno, str);
dlm_hooks->release_lockspace(cluster_name, dlm_lock_res->ls, 1);
@@ -183,7 +183,8 @@ int cluster_release_dlmlock(int lockid)
errno = dlm_lock_res->lksb.sb_status;
if (errno != EUNLOCK) {
- pr_err("error %d happened in ast when unlock lockspace\n", errno);
+ pr_err("error %d happened in ast when unlock lockspace\n",
+ errno);
/* XXX make sure the lockspace is unlocked eventually */
goto out;
}
@@ -639,14 +640,16 @@ char *__fname_from_uuid(int id[4], int swap, char *buf, char sep)
}
-char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf, char sep)
+char *fname_from_uuid(struct supertype *st, struct mdinfo *info,
+ char *buf, char sep)
{
// dirty hack to work around an issue with super1 superblocks...
// super1 superblocks need swapuuid set in order for assembly to
// work, but can't have it set if we want this printout to match
// all the other uuid printouts in super1.c, so we force swapuuid
// to 1 to make our printout match the rest of super1
- return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 : st->ss->swapuuid, buf, sep);
+ return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 :
+ st->ss->swapuuid, buf, sep);
}
int check_ext2(int fd, char *name)
@@ -1084,9 +1087,11 @@ int dev_open(char *dev, int flags)
}
if (fd < 0) {
/* Try /tmp as /dev appear to be read-only */
- snprintf(devname, sizeof(devname), "/tmp/.tmp.md.%d:%d:%d",
+ snprintf(devname, sizeof(devname),
+ "/tmp/.tmp.md.%d:%d:%d",
(int)getpid(), major, minor);
- if (mknod(devname, S_IFBLK|0600, makedev(major, minor)) == 0) {
+ if (mknod(devname, S_IFBLK|0600,
+ makedev(major, minor)) == 0) {
fd = open(devname, flags);
unlink(devname);
}
@@ -2261,8 +2266,10 @@ void set_cmap_hooks(void)
if (!cmap_hooks->cmap_handle)
return;
- cmap_hooks->initialize = dlsym(cmap_hooks->cmap_handle, "cmap_initialize");
- cmap_hooks->get_string = dlsym(cmap_hooks->cmap_handle, "cmap_get_string");
+ cmap_hooks->initialize =
+ dlsym(cmap_hooks->cmap_handle, "cmap_initialize");
+ cmap_hooks->get_string =
+ dlsym(cmap_hooks->cmap_handle, "cmap_get_string");
cmap_hooks->finalize = dlsym(cmap_hooks->cmap_handle, "cmap_finalize");
if (!cmap_hooks->initialize || !cmap_hooks->get_string ||
@@ -2305,8 +2312,10 @@ void set_dlm_hooks(void)
if (!dlm_hooks->dlm_handle)
return;
- dlm_hooks->create_lockspace = dlsym(dlm_hooks->dlm_handle, "dlm_create_lockspace");
- dlm_hooks->release_lockspace = dlsym(dlm_hooks->dlm_handle, "dlm_release_lockspace");
+ dlm_hooks->create_lockspace =
+ dlsym(dlm_hooks->dlm_handle, "dlm_create_lockspace");
+ dlm_hooks->release_lockspace =
+ dlsym(dlm_hooks->dlm_handle, "dlm_release_lockspace");
dlm_hooks->ls_lock = dlsym(dlm_hooks->dlm_handle, "dlm_ls_lock");
dlm_hooks->ls_unlock = dlsym(dlm_hooks->dlm_handle, "dlm_ls_unlock");
dlm_hooks->ls_get_fd = dlsym(dlm_hooks->dlm_handle, "dlm_ls_get_fd");
--
2.13.6
++++++ 0170-Close-mdfd-before-returning-main-function.patch ++++++
From 4dba4bd48f45a8df850ba3b37f3c2a5f178b163e Mon Sep 17 00:00:00 2001
From: Xiao Ni
Date: Tue, 19 Sep 2017 14:06:46 +0800
Subject: [PATCH] Close mdfd before returning main function
Git-commit: 4dba4bd48f45a8df850ba3b37f3c2a5f178b163e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Signed-off-by: Xiao Ni
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mdadm.c b/mdadm.c
index d80aab3..7cdcdba 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1734,6 +1734,8 @@ int main(int argc, char *argv[])
autodetect();
break;
}
+ if (mdfd > 0)
+ close(mdfd);
exit(rv);
}
--
2.13.6
++++++ 0171-Grow-stop-previous-reshape-process-first.patch ++++++
From e1b942b9afa9f3310ea19c57caea896af97b557e Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak
Date: Thu, 7 Sep 2017 13:01:16 +0200
Subject: [PATCH] Grow: stop previous reshape process first
Git-commit: e1b942b9afa9f3310ea19c57caea896af97b557e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If array is stopped during reshape and assembled again straight away,
reshape process in a background might still be running. systemd doesn't
start a new service if one already exists. If there is a race, previous
process might terminate and new one is not created. Reshape doesn't
continue after assemble.
Tell systemd to restart the service rather than just start it. It will
assure previous service is stopped first. If it's not running, stopping
has no effect and only new process is started.
Signed-off-by: Tomasz Majchrzak
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 534ba80..267b06f 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3003,9 +3003,9 @@ static int continue_via_systemd(char *devnm)
snprintf(pathbuf, sizeof(pathbuf), "mdadm-grow-continue@%s.service",
devnm);
status = execl("/usr/bin/systemctl", "systemctl",
- "start",
+ "restart",
pathbuf, NULL);
- status = execl("/bin/systemctl", "systemctl", "start",
+ status = execl("/bin/systemctl", "systemctl", "restart",
pathbuf, NULL);
exit(1);
case -1: /* Just do it ourselves. */
--
2.13.6
++++++ 0172-imsm-New-disk-controller-domains.patch ++++++
From c6839718190d7418aadc858edafb8fb4b67287b0 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Thu, 7 Sep 2017 16:05:09 +0200
Subject: [PATCH] imsm: New disk controller domains
Git-commit: c6839718190d7418aadc858edafb8fb4b67287b0
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Add disk controller domain for nvme and vmd devices to prevent moving
spares between different domains.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/super-intel.c b/super-intel.c
index 125c3a9..bbe7bc7 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -10749,6 +10749,10 @@ static const char *imsm_get_disk_controller_domain(const char *path)
drv = "isci";
else if (hba && hba->type == SYS_DEV_SATA)
drv = "ahci";
+ else if (hba && hba->type == SYS_DEV_VMD)
+ drv = "vmd";
+ else if (hba && hba->type == SYS_DEV_NVME)
+ drv = "nvme";
else
drv = "unknown";
dprintf("path: %s hba: %s attached: %s\n",
--
2.13.6
++++++ 0173-Monitor-Check-redundancy-for-arrays.patch ++++++
From b3ab4e4dd78668f58deb87a04eebda62d1090b49 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Mon, 4 Sep 2017 12:52:46 +0200
Subject: [PATCH] Monitor: Check redundancy for arrays
Git-commit: b3ab4e4dd78668f58deb87a04eebda62d1090b49
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
GET_MISMATCH option doesn't exist for RAID arrays without redundancy
so sysfs_read fails if this information is requested. Set options
according to the device using information from /proc/mdstat.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 497e364..b60996b 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -466,7 +466,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int new_array = 0;
int retval;
int is_container = 0;
- unsigned long array_only_flags = 0;
+ unsigned long redundancy_only_flags = 0;
if (test)
alert("TestMessage", dev, NULL, ainfo);
@@ -504,11 +504,11 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (md_get_array_info(fd, &array) < 0)
goto disappeared;
- if (!is_container)
- array_only_flags |= GET_MISMATCH;
+ if (!is_container && map_name(pers, mse->level) > 0)
+ redundancy_only_flags |= GET_MISMATCH;
sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEVS |
- GET_STATE | array_only_flags);
+ GET_STATE | redundancy_only_flags);
if (!sra)
goto disappeared;
--
2.13.6
++++++ 0174-mdadm-grow-Component-size-must-be-larger-than-chunk-.patch ++++++
From 4b74a905a67e0587ffa6f75d76eb8112e6aa8eed Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Tue, 5 Sep 2017 17:41:36 +0800
Subject: [PATCH] mdadm/grow: Component size must be larger than chunk size
Git-commit: 4b74a905a67e0587ffa6f75d76eb8112e6aa8eed
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Grow: Changing component size must be larger than current
chunk size against stripe raids, otherwise Grow_reshape()
would set s->size to '0'.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Grow.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Grow.c b/Grow.c
index 267b06f..bab1eec 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1816,6 +1816,12 @@ int Grow_reshape(char *devname, int fd,
return 1;
}
+ if (array.level > 1 &&
+ (array.chunk_size / 1024) > (int)s->size) {
+ pr_err("component size must be larger than chunk size.\n");
+ return 1;
+ }
+
st = super_by_fd(fd, &subarray);
if (!st) {
pr_err("Unable to determine metadata format for %s\n", devname);
--
2.13.6
++++++ 0175-mdadm-manpage-disable-bitmap_resize-for-external-fil.patch ++++++
From 7fa9af4c384d269dd461152a011441415a26828a Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Tue, 5 Sep 2017 17:41:37 +0800
Subject: [PATCH] mdadm/manpage: disable bitmap_resize for external file bitmap
Git-commit: 7fa9af4c384d269dd461152a011441415a26828a
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Update the manpage in "SIZE CHANGES" against the md commit.
Commit: e8a27f836f165c26f867ece7f31eb5c811692319
(md/bitmap: disable bitmap_resize for file-backed bitmaps.)
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.8.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mdadm.8.in b/mdadm.8.in
index e0747fb..f0fd1fc 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -2758,6 +2758,11 @@ Also the size of an array cannot be changed while it has an active
bitmap. If an array has a bitmap, it must be removed before the size
can be changed. Once the change is complete a new bitmap can be created.
+.PP
+Note:
+.B "--grow --size"
+is not yet supported for external file bitmap.
+
.SS RAID\-DEVICES CHANGES
A RAID1 array can work with any number of devices from 1 upwards
--
2.13.6
++++++ 0176-mdadm-fixes-some-trivial-typos-in-comments.patch ++++++
From 5c1dec3e3e85f98c82c8253bf7e7ef5d6ce94268 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Tue, 5 Sep 2017 17:41:38 +0800
Subject: [PATCH] mdadm: fixes some trivial typos in comments
Git-commit: 5c1dec3e3e85f98c82c8253bf7e7ef5d6ce94268
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
fix some trivial typos in comments.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
ReadMe.c | 2 +-
super1.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/ReadMe.c b/ReadMe.c
index eb8fb4b..4d871e9 100644
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -342,7 +342,7 @@ char OptionHelp[] =
*/
char Help_create[] =
-"Usage: mdadm --create device -chunk=X --level=Y --raid-devices=Z devices\n"
+"Usage: mdadm --create device --chunk=X --level=Y --raid-devices=Z devices\n"
"\n"
" This usage will initialise a new md array, associate some\n"
" devices with it, and activate the array. In order to create an\n"
diff --git a/super1.c b/super1.c
index f6a1045..3cfbbc0 100644
--- a/super1.c
+++ b/super1.c
@@ -89,12 +89,12 @@ struct mdp_superblock_1 {
/* bad block log. If there are any bad blocks the feature flag is set.
* if offset and size are non-zero, that space is reserved and available.
*/
- __u8 bblog_shift; /* shift from sectors to block size for badblocklist */
- __u16 bblog_size; /* number of sectors reserved for badblocklist */
+ __u8 bblog_shift; /* shift from sectors to block size for badblock list */
+ __u16 bblog_size; /* number of sectors reserved for badblock list */
__u32 bblog_offset; /* sector offset from superblock to bblog, signed */
/* array state information - 64 bytes */
- __u64 utime; /* 40 bits second, 24 btes microseconds */
+ __u64 utime; /* 40 bits second, 24 bits microseconds */
__u64 events; /* incremented when superblock updated */
__u64 resync_offset; /* data before this offset (from data_offset) known to be in sync */
__u32 sb_csum; /* checksum upto dev_roles[max_dev] */
@@ -2396,7 +2396,7 @@ add_internal_bitmap1(struct supertype *st,
/*
* If not may_change, then this is a 'Grow' without sysfs support for
* bitmaps, and the bitmap must fit after the superblock at 1K offset.
- * If may_change, then this is create or a Grow with sysfs syupport,
+ * If may_change, then this is create or a Grow with sysfs support,
* and we can put the bitmap wherever we like.
*
* size is in sectors, chunk is in bytes !!!
--
2.13.6
++++++ 0177-Don-t-abort-starting-the-array-if-kernel-does-not-su.patch ++++++
From 2c8890e926a4c7f9169b5054e3dbf84426fe1025 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Thu, 28 Sep 2017 14:41:07 +0200
Subject: [PATCH] Don't abort starting the array if kernel does not support ppl
Git-commit: 2c8890e926a4c7f9169b5054e3dbf84426fe1025
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Change the behavior of assemble and create for consistency-policy=ppl
for external metadata arrays. If the kernel does not support ppl, don't
abort but print a warning and start the array without ppl
(consistency-policy=resync). No change for native md arrays because the
kernel will not allow starting the array if it finds an unsupported
feature bit in the superblock.
In sysfs_add_disk() check consistency_policy in the mdinfo structure
that represents the array, not the disk and read the current consistency
policy from sysfs in mdmon's manage_member(). This is necessary to make
sysfs_add_disk() honor the actual consistency policy and not what is in
the metadata. Also remove all the places where consistency_policy is set
for a disk's mdinfo - it is a property of the array, not the disk.
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
managemon.c | 11 ++++++++---
super-intel.c | 4 +---
sysfs.c | 6 +++---
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/managemon.c b/managemon.c
index 68f0c2d..cc3c6f1 100644
--- a/managemon.c
+++ b/managemon.c
@@ -477,7 +477,7 @@ static void manage_member(struct mdstat_ent *mdstat,
char buf[64];
int frozen;
struct supertype *container = a->container;
- unsigned long long int component_size = 0;
+ struct mdinfo *mdi;
if (container == NULL)
/* Raced with something */
@@ -489,8 +489,13 @@ static void manage_member(struct mdstat_ent *mdstat,
// MORE
}
- if (sysfs_get_ll(&a->info, NULL, "component_size", &component_size) >= 0)
- a->info.component_size = component_size << 1;
+ mdi = sysfs_read(-1, mdstat->devnm,
+ GET_COMPONENT|GET_CONSISTENCY_POLICY);
+ if (mdi) {
+ a->info.component_size = mdi->component_size;
+ a->info.consistency_policy = mdi->consistency_policy;
+ sysfs_free(mdi);
+ }
/* honor 'frozen' */
if (sysfs_get_str(&a->info, NULL, "metadata_version", buf, sizeof(buf)) > 0)
diff --git a/super-intel.c b/super-intel.c
index bbe7bc7..e3dcd3d 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7669,7 +7669,6 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
} else {
info_d->component_size = blocks_per_member(map);
}
- info_d->consistency_policy = this->consistency_policy;
info_d->bb.supported = 1;
get_volume_badblocks(super->bbm_log, ord_to_idx(ord),
@@ -8758,8 +8757,7 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
di->component_size = a->info.component_size;
di->container_member = inst;
di->bb.supported = 1;
- if (dev->rwh_policy == RWH_DISTRIBUTED) {
- di->consistency_policy = CONSISTENCY_POLICY_PPL;
+ if (a->info.consistency_policy == CONSISTENCY_POLICY_PPL) {
di->ppl_sector = get_ppl_sector(super, inst);
di->ppl_size = (PPL_HEADER_SIZE + PPL_ENTRY_SPACE) >> 9;
}
diff --git a/sysfs.c b/sysfs.c
index 68ddd5f..bf5c8c5 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -709,8 +709,8 @@ int sysfs_set_array(struct mdinfo *info, int vers)
if (sysfs_set_str(info, NULL, "consistency_policy",
map_num(consistency_policies,
info->consistency_policy))) {
- pr_err("This kernel does not support PPL\n");
- return 1;
+ pr_err("This kernel does not support PPL. Falling back to consistency-policy=resync.\n");
+ info->consistency_policy = CONSISTENCY_POLICY_RESYNC;
}
}
@@ -745,7 +745,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 (sd->consistency_policy == CONSISTENCY_POLICY_PPL) {
+ 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.13.6
++++++ 0178-super1-Add-support-for-multiple-ppls.patch ++++++
From fa601c2e897adfb3d2316377354269ffdeb824c3 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:08 +0200
Subject: [PATCH] super1: Add support for multiple-ppls
Git-commit: fa601c2e897adfb3d2316377354269ffdeb824c3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Add support for super1 with multiple ppls. Extend ppl area size to 1MB.
Use 1MB as default during creation. Always start array as single ppl -
if kernel is capable of multiple ppls and there is enough space reserved -
it will switch the policy during first metadata update.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super1.c | 65 ++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 37 insertions(+), 28 deletions(-)
diff --git a/super1.c b/super1.c
index 3cfbbc0..f80e38a 100644
--- a/super1.c
+++ b/super1.c
@@ -121,6 +121,9 @@ struct misc_dev_info {
__u64 device_size;
};
+#define MULTIPLE_PPL_AREA_SIZE_SUPER1 (1024 * 1024) /* Size of the whole
+ * mutliple PPL area
+ */
/* feature_map bits */
#define MD_FEATURE_BITMAP_OFFSET 1
#define MD_FEATURE_RECOVERY_OFFSET 2 /* recovery_offset is present and
@@ -140,6 +143,7 @@ struct misc_dev_info {
#define MD_FEATURE_BITMAP_VERSIONED 256 /* bitmap version number checked properly */
#define MD_FEATURE_JOURNAL 512 /* support write journal */
#define MD_FEATURE_PPL 1024 /* support PPL */
+#define MD_FEATURE_MUTLIPLE_PPLS 2048 /* support for multiple PPLs */
#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \
|MD_FEATURE_RECOVERY_OFFSET \
|MD_FEATURE_RESHAPE_ACTIVE \
@@ -150,6 +154,7 @@ struct misc_dev_info {
|MD_FEATURE_BITMAP_VERSIONED \
|MD_FEATURE_JOURNAL \
|MD_FEATURE_PPL \
+ |MD_FEATURE_MULTIPLE_PPLS \
)
static int role_from_sb(struct mdp_superblock_1 *sb)
@@ -298,6 +303,12 @@ static int awrite(struct align_fd *afd, void *buf, int len)
return len;
}
+static inline unsigned int md_feature_any_ppl_on(__u32 feature_map)
+{
+ return ((__cpu_to_le32(feature_map) &
+ (MD_FEATURE_PPL | MD_FEATURE_MUTLIPLE_PPLS)));
+}
+
static inline unsigned int choose_ppl_space(int chunk)
{
return (PPL_HEADER_SIZE >> 9) + (chunk > 128*2 ? chunk : 128*2);
@@ -409,7 +420,7 @@ static void examine_super1(struct supertype *st, char *homehost)
if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
printf("Internal Bitmap : %ld sectors from superblock\n",
(long)(int32_t)__le32_to_cpu(sb->bitmap_offset));
- } else if (sb->feature_map & __cpu_to_le32(MD_FEATURE_PPL)) {
+ } else if (md_feature_any_ppl_on(sb->feature_map)) {
printf(" PPL : %u sectors at offset %d sectors from superblock\n",
__le16_to_cpu(sb->ppl.size),
__le16_to_cpu(sb->ppl.offset));
@@ -985,7 +996,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
info->bitmap_offset = (int32_t)__le32_to_cpu(sb->bitmap_offset);
if (__le32_to_cpu(bsb->nodes) > 1)
info->array.state |= (1 << MD_SB_CLUSTERED);
- } else if (sb->feature_map & __le32_to_cpu(MD_FEATURE_PPL)) {
+ } else if (md_feature_any_ppl_on(sb->feature_map)) {
info->ppl_offset = __le16_to_cpu(sb->ppl.offset);
info->ppl_size = __le16_to_cpu(sb->ppl.size);
info->ppl_sector = super_offset + info->ppl_offset;
@@ -1140,7 +1151,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
if (sb->feature_map & __le32_to_cpu(MD_FEATURE_JOURNAL)) {
info->journal_device_required = 1;
info->consistency_policy = CONSISTENCY_POLICY_JOURNAL;
- } else if (sb->feature_map & __le32_to_cpu(MD_FEATURE_PPL)) {
+ } else if (md_feature_any_ppl_on(sb->feature_map)) {
info->consistency_policy = CONSISTENCY_POLICY_PPL;
} else if (sb->feature_map & __le32_to_cpu(MD_FEATURE_BITMAP_OFFSET)) {
info->consistency_policy = CONSISTENCY_POLICY_BITMAP;
@@ -1324,7 +1335,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
bitmap_offset = (long)__le32_to_cpu(sb->bitmap_offset);
bm_sectors = calc_bitmap_size(bms, 4096) >> 9;
- } else if (sb->feature_map & __cpu_to_le32(MD_FEATURE_PPL)) {
+ } else if (md_feature_any_ppl_on(sb->feature_map)) {
bitmap_offset = (long)__le16_to_cpu(sb->ppl.offset);
bm_sectors = (long)__le16_to_cpu(sb->ppl.size);
}
@@ -1377,7 +1388,6 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
unsigned long long data_size = __le64_to_cpu(sb->data_size);
long bb_offset = __le32_to_cpu(sb->bblog_offset);
int space;
- int optimal_space;
int offset;
if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
@@ -1408,18 +1418,23 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
return -2;
}
- optimal_space = choose_ppl_space(__le32_to_cpu(sb->chunksize));
-
- if (space > optimal_space)
- space = optimal_space;
- if (space > UINT16_MAX)
- space = UINT16_MAX;
+ if (space >= (MULTIPLE_PPL_AREA_SIZE_SUPER1 >> 9)) {
+ space = (MULTIPLE_PPL_AREA_SIZE_SUPER1 >> 9);
+ } else {
+ int optimal_space = choose_ppl_space(
+ __le32_to_cpu(sb->chunksize));
+ if (space > optimal_space)
+ space = optimal_space;
+ if (space > UINT16_MAX)
+ space = UINT16_MAX;
+ }
sb->ppl.offset = __cpu_to_le16(offset);
sb->ppl.size = __cpu_to_le16(space);
sb->feature_map |= __cpu_to_le32(MD_FEATURE_PPL);
} else if (strcmp(update, "no-ppl") == 0) {
- sb->feature_map &= ~ __cpu_to_le32(MD_FEATURE_PPL);
+ sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_PPL |
+ MD_FEATURE_MUTLIPLE_PPLS);
} else if (strcmp(update, "name") == 0) {
if (info->name[0] == 0)
sprintf(info->name, "%d", info->array.md_minor);
@@ -1974,20 +1989,12 @@ static int write_init_super1(struct supertype *st)
(((char *)sb) + MAX_SB_SIZE);
bm_space = calc_bitmap_size(bms, 4096) >> 9;
bm_offset = (long)__le32_to_cpu(sb->bitmap_offset);
- } else if (sb->feature_map & __cpu_to_le32(MD_FEATURE_PPL)) {
- bm_space =
- choose_ppl_space(__le32_to_cpu(sb->chunksize));
- if (bm_space > UINT16_MAX)
- bm_space = UINT16_MAX;
- if (st->minor_version == 0) {
+ } else if (md_feature_any_ppl_on(sb->feature_map)) {
+ bm_space = MULTIPLE_PPL_AREA_SIZE_SUPER1 >> 9;
+ if (st->minor_version == 0)
bm_offset = -bm_space - 8;
- if (bm_offset < INT16_MIN) {
- bm_offset = INT16_MIN;
- bm_space = -bm_offset - 8;
- }
- } else {
+ else
bm_offset = 8;
- }
sb->ppl.offset = __cpu_to_le16(bm_offset);
sb->ppl.size = __cpu_to_le16(bm_space);
} else {
@@ -2069,7 +2076,7 @@ static int write_init_super1(struct supertype *st)
MD_FEATURE_BITMAP_OFFSET)) {
rv = st->ss->write_bitmap(st, di->fd, NodeNumUpdate);
} else if (rv == 0 &&
- (__le32_to_cpu(sb->feature_map) & MD_FEATURE_PPL)) {
+ md_feature_any_ppl_on(sb->feature_map)) {
struct mdinfo info;
st->ss->getinfo_super(st, &info, NULL);
@@ -2345,7 +2352,7 @@ static __u64 avail_size1(struct supertype *st, __u64 devsize,
struct bitmap_super_s *bsb;
bsb = (struct bitmap_super_s *)(((char*)super)+MAX_SB_SIZE);
bmspace = calc_bitmap_size(bsb, 4096) >> 9;
- } else if (__le32_to_cpu(super->feature_map) & MD_FEATURE_PPL) {
+ } else if (md_feature_any_ppl_on(super->feature_map)) {
bmspace = __le16_to_cpu(super->ppl.size);
}
@@ -2769,8 +2776,10 @@ static int validate_geometry1(struct supertype *st, int level,
}
/* creating: allow suitable space for bitmap or PPL */
- bmspace = consistency_policy == CONSISTENCY_POLICY_PPL ?
- choose_ppl_space((*chunk)*2) : choose_bm_space(devsize);
+ if (consistency_policy == CONSISTENCY_POLICY_PPL)
+ bmspace = MULTIPLE_PPL_AREA_SIZE_SUPER1 >> 9;
+ else
+ bmspace = choose_bm_space(devsize);
if (data_offset == INVALID_SECTORS)
data_offset = st->data_offset;
--
2.13.6
++++++ 0179-imsm-Add-support-for-multiple-ppls.patch ++++++
From c24620685185eb7a159a8563b60a5e062b03b12e Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:09 +0200
Subject: [PATCH] imsm: Add support for multiple ppls
Git-commit: c24620685185eb7a159a8563b60a5e062b03b12e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Add interpreting new rwh_policy bits. Set PPL size as 1MB.
If new array with ppl is created - use new implementation of ppl by
default.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index e3dcd3d..347838e 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -92,6 +92,9 @@
#define NUM_BLOCKS_DIRTY_STRIPE_REGION 2056
#define SECT_PER_MB_SHIFT 11
#define MAX_SECTOR_SIZE 4096
+#define MULTIPLE_PPL_AREA_SIZE_IMSM (1024 * 1024) /* Size of the whole
+ * mutliple PPL area
+ */
/* Disk configuration info. */
#define IMSM_MAX_DEVICES 255
@@ -207,6 +210,9 @@ struct imsm_dev {
#define RWH_OFF 0
#define RWH_DISTRIBUTED 1
#define RWH_JOURNALING_DRIVE 2
+#define RWH_MULTIPLE_DISTRIBUTED 3
+#define RWH_MULTIPLE_PPLS_JOURNALING_DRIVE 4
+#define RWH_MULTIPLE_OFF 5
__u8 rwh_policy; /* Raid Write Hole Policy */
__u8 jd_serial[MAX_RAID_SERIAL_LEN]; /* Journal Drive serial number */
__u8 filler1;
@@ -284,7 +290,7 @@ static char *map_state_str[] = { "normal", "uninitialized", "degraded", "failed"
* already been migrated and must
* be recovered from checkpoint area */
-#define PPL_ENTRY_SPACE (128 * 1024) /* Size of the PPL, without the header */
+#define PPL_ENTRY_SPACE (128 * 1024) /* Size of single PPL, without the header */
struct migr_record {
__u32 rec_status; /* Status used to determine how to restart
@@ -1539,12 +1545,16 @@ static void print_imsm_dev(struct intel_super *super,
printf(" Dirty State : %s\n", (dev->vol.dirty & RAIDVOL_DIRTY) ?
"dirty" : "clean");
printf(" RWH Policy : ");
- if (dev->rwh_policy == RWH_OFF)
+ if (dev->rwh_policy == RWH_OFF || dev->rwh_policy == RWH_MULTIPLE_OFF)
printf("off\n");
else if (dev->rwh_policy == RWH_DISTRIBUTED)
printf("PPL distributed\n");
else if (dev->rwh_policy == RWH_JOURNALING_DRIVE)
printf("PPL journaling drive\n");
+ else if (dev->rwh_policy == RWH_MULTIPLE_DISTRIBUTED)
+ printf("Multiple distributed PPLs\n");
+ else if (dev->rwh_policy == RWH_MULTIPLE_PPLS_JOURNALING_DRIVE)
+ printf("Multiple PPLs on journaling drive\n");
else
printf("unknown:%d\n", dev->rwh_policy);
}
@@ -3294,10 +3304,16 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
memset(info->uuid, 0, sizeof(info->uuid));
info->recovery_start = MaxSector;
- if (info->array.level == 5 && dev->rwh_policy == RWH_DISTRIBUTED) {
+ if (info->array.level == 5 &&
+ (dev->rwh_policy == RWH_DISTRIBUTED ||
+ dev->rwh_policy == RWH_MULTIPLE_DISTRIBUTED)) {
info->consistency_policy = CONSISTENCY_POLICY_PPL;
info->ppl_sector = get_ppl_sector(super, super->current_vol);
- info->ppl_size = (PPL_HEADER_SIZE + PPL_ENTRY_SPACE) >> 9;
+ if (dev->rwh_policy == RWH_MULTIPLE_DISTRIBUTED)
+ info->ppl_size = MULTIPLE_PPL_AREA_SIZE_IMSM >> 9;
+ else
+ info->ppl_size = (PPL_HEADER_SIZE + PPL_ENTRY_SPACE)
+ >> 9;
} else if (info->array.level <= 0) {
info->consistency_policy = CONSISTENCY_POLICY_NONE;
} else {
@@ -5390,9 +5406,9 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
dev->my_vol_raid_dev_num = mpb->num_raid_devs_created;
if (s->consistency_policy <= CONSISTENCY_POLICY_RESYNC) {
- dev->rwh_policy = RWH_OFF;
+ dev->rwh_policy = RWH_MULTIPLE_OFF;
} else if (s->consistency_policy == CONSISTENCY_POLICY_PPL) {
- dev->rwh_policy = RWH_DISTRIBUTED;
+ dev->rwh_policy = RWH_MULTIPLE_DISTRIBUTED;
} else {
free(dev);
free(dv);
@@ -7403,9 +7419,9 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
return 2;
if (strcmp(update, "ppl") == 0)
- new_policy = RWH_DISTRIBUTED;
+ new_policy = RWH_MULTIPLE_DISTRIBUTED;
else
- new_policy = RWH_OFF;
+ new_policy = RWH_MULTIPLE_OFF;
if (st->update_tail) {
struct imsm_update_rwh_policy *u = xmalloc(sizeof(*u));
@@ -8205,7 +8221,8 @@ skip_mark_checkpoint:
dev->vol.dirty = RAIDVOL_CLEAN;
} else {
dev->vol.dirty = RAIDVOL_DIRTY;
- if (dev->rwh_policy == RWH_DISTRIBUTED)
+ if (dev->rwh_policy == RWH_DISTRIBUTED ||
+ dev->rwh_policy == RWH_MULTIPLE_DISTRIBUTED)
dev->vol.dirty |= RAIDVOL_DSRECORD_VALID;
}
super->updates_pending++;
@@ -8759,7 +8776,7 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
di->bb.supported = 1;
if (a->info.consistency_policy == CONSISTENCY_POLICY_PPL) {
di->ppl_sector = get_ppl_sector(super, inst);
- di->ppl_size = (PPL_HEADER_SIZE + PPL_ENTRY_SPACE) >> 9;
+ di->ppl_size = MULTIPLE_PPL_AREA_SIZE_IMSM >> 9;
}
super->random = random32();
di->next = rv;
--
2.13.6
++++++ 0180-imsm-validate-multiple-ppls-during-assemble.patch ++++++
From 44b6b87610281a4add36a1addd7630095dc8a545 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:10 +0200
Subject: [PATCH] imsm: validate multiple ppls during assemble
Git-commit: 44b6b87610281a4add36a1addd7630095dc8a545
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Change validation algorithm to check validity of multiple ppls that
are stored in PPL area.
If read error occurs during - treat the all PPLs as invalid -
there is no guarantee that this one was not latest. If the header CRC is
incorrect - assume that there are no further PPLs in PPL area.
If whole PPL area was written at least once - there is a possibility that
old PPL (with lower generation number) will follow the recent one
(with higest generation number). Compare those generation numbers to check
which PPL is latest.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 71 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 47 insertions(+), 24 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 347838e..56dec36 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6106,11 +6106,14 @@ static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info,
struct imsm_dev *dev;
struct imsm_map *map;
__u32 idx;
+ unsigned int i;
+ unsigned long long ppl_offset = 0;
+ unsigned long long prev_gen_num = 0;
if (disk->disk.raid_disk < 0)
return 0;
- if (posix_memalign(&buf, 4096, PPL_HEADER_SIZE)) {
+ if (posix_memalign(&buf, MAX_SECTOR_SIZE, PPL_HEADER_SIZE)) {
pr_err("Failed to allocate PPL header buffer\n");
return -1;
}
@@ -6123,34 +6126,54 @@ static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info,
if (!d || d->index < 0 || is_failed(&d->disk))
goto out;
- if (lseek64(d->fd, info->ppl_sector * 512, SEEK_SET) < 0) {
- perror("Failed to seek to PPL header location");
- ret = -1;
- goto out;
- }
+ ret = 1;
+ while (ppl_offset < MULTIPLE_PPL_AREA_SIZE_IMSM) {
+ dprintf("Checking potential PPL at offset: %llu\n", ppl_offset);
- if (read(d->fd, buf, PPL_HEADER_SIZE) != PPL_HEADER_SIZE) {
- perror("Read PPL header failed");
- ret = -1;
- goto out;
- }
+ if (lseek64(d->fd, info->ppl_sector * 512 + ppl_offset,
+ SEEK_SET) < 0) {
+ perror("Failed to seek to PPL header location");
+ ret = -1;
+ goto out;
+ }
- ppl_hdr = buf;
+ if (read(d->fd, buf, PPL_HEADER_SIZE) != PPL_HEADER_SIZE) {
+ perror("Read PPL header failed");
+ ret = -1;
+ goto out;
+ }
- crc = __le32_to_cpu(ppl_hdr->checksum);
- ppl_hdr->checksum = 0;
+ ppl_hdr = buf;
- if (crc != ~crc32c_le(~0, buf, PPL_HEADER_SIZE)) {
- dprintf("Wrong PPL header checksum on %s\n",
- d->devname);
- ret = 1;
- }
+ crc = __le32_to_cpu(ppl_hdr->checksum);
+ ppl_hdr->checksum = 0;
+
+ if (crc != ~crc32c_le(~0, buf, PPL_HEADER_SIZE)) {
+ dprintf("Wrong PPL header checksum on %s\n",
+ d->devname);
+ goto out;
+ }
+
+ if (prev_gen_num > __le64_to_cpu(ppl_hdr->generation)) {
+ /* previous was newest, it was already checked */
+ goto out;
+ }
+
+ if ((__le32_to_cpu(ppl_hdr->signature) !=
+ super->anchor->orig_family_num)) {
+ dprintf("Wrong PPL header signature on %s\n",
+ d->devname);
+ ret = 1;
+ goto out;
+ }
+
+ ret = 0;
+ prev_gen_num = __le64_to_cpu(ppl_hdr->generation);
- if (!ret && (__le32_to_cpu(ppl_hdr->signature) !=
- super->anchor->orig_family_num)) {
- dprintf("Wrong PPL header signature on %s\n",
- d->devname);
- ret = 1;
+ ppl_offset += PPL_HEADER_SIZE;
+ for (i = 0; i < __le32_to_cpu(ppl_hdr->entries_count); i++)
+ ppl_offset +=
+ __le32_to_cpu(ppl_hdr->entries[i].pp_size);
}
out:
--
2.13.6
++++++ 0181-Zeroout-whole-ppl-space-during-creation-force-assemb.patch ++++++
From b251424242b46d62f666829c0e7a7550768fc8de Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:11 +0200
Subject: [PATCH] Zeroout whole ppl space during creation/force assemble
Git-commit: b251424242b46d62f666829c0e7a7550768fc8de
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
PPL area should be cleared before creation/force assemble.
If the drive was used in other RAID array, it might contains PPL from it.
There is a risk that mdadm recognizes those PPLs and
refuses to assemble the RAID due to PPL conflict with created
array.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdadm.h | 1 +
super-intel.c | 7 ++++++-
super1.c | 5 +++++
util.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/mdadm.h b/mdadm.h
index 3fc8a4f..85947bf 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -687,6 +687,7 @@ extern int sysfs_unique_holder(char *devnm, long rdev);
extern int sysfs_freeze_array(struct mdinfo *sra);
extern int sysfs_wait(int fd, int *msec);
extern int load_sys(char *path, char *buf, int len);
+extern int zero_disk_range(int fd, unsigned long long sector, size_t count);
extern int reshape_prepare_fdlist(char *devname,
struct mdinfo *sra,
int raid_disks,
diff --git a/super-intel.c b/super-intel.c
index 56dec36..65cdc92 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6065,7 +6065,12 @@ static int write_init_ppl_imsm(struct supertype *st, struct mdinfo *info, int fd
struct ppl_header *ppl_hdr;
int ret;
- ret = posix_memalign(&buf, 4096, PPL_HEADER_SIZE);
+ /* first clear entire ppl space */
+ ret = zero_disk_range(fd, info->ppl_sector, info->ppl_size);
+ if (ret)
+ return ret;
+
+ ret = posix_memalign(&buf, MAX_SECTOR_SIZE, PPL_HEADER_SIZE);
if (ret) {
pr_err("Failed to allocate PPL header buffer\n");
return ret;
diff --git a/super1.c b/super1.c
index f80e38a..7ae6dc3 100644
--- a/super1.c
+++ b/super1.c
@@ -1823,6 +1823,11 @@ static int write_init_ppl1(struct supertype *st, struct mdinfo *info, int fd)
struct ppl_header *ppl_hdr;
int ret;
+ /* first clear entire ppl space */
+ ret = zero_disk_range(fd, info->ppl_sector, info->ppl_size);
+ if (ret)
+ return ret;
+
ret = posix_memalign(&buf, 4096, PPL_HEADER_SIZE);
if (ret) {
pr_err("Failed to allocate PPL header buffer\n");
diff --git a/util.c b/util.c
index 68af381..c11729e 100644
--- a/util.c
+++ b/util.c
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -2334,3 +2335,51 @@ void set_hooks(void)
set_dlm_hooks();
set_cmap_hooks();
}
+
+int zero_disk_range(int fd, unsigned long long sector, size_t count)
+{
+ int ret = 0;
+ int fd_zero;
+ void *addr = NULL;
+ size_t written = 0;
+ size_t len = count * 512;
+ ssize_t n;
+
+ fd_zero = open("/dev/zero", O_RDONLY);
+ if (fd_zero < 0) {
+ pr_err("Cannot open /dev/zero\n");
+ return -1;
+ }
+
+ if (lseek64(fd, sector * 512, SEEK_SET) < 0) {
+ ret = -errno;
+ pr_err("Failed to seek offset for zeroing\n");
+ goto out;
+ }
+
+ addr = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd_zero, 0);
+
+ if (addr == MAP_FAILED) {
+ ret = -errno;
+ pr_err("Mapping /dev/zero failed\n");
+ goto out;
+ }
+
+ do {
+ n = write(fd, addr + written, len - written);
+ if (n < 0) {
+ if (errno == EINTR)
+ continue;
+ ret = -errno;
+ pr_err("Zeroing disk range failed\n");
+ break;
+ }
+ written += n;
+ } while (written != len);
+
+ munmap(addr, len);
+
+out:
+ close(fd_zero);
+ return ret;
+}
--
2.13.6
++++++ 0182-imsm-switch-to-multiple-ppls-automatically-during-as.patch ++++++
From 54148aba7c1a02bf018ae777bebc7f16e6cd3195 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:12 +0200
Subject: [PATCH] imsm: switch to multiple ppls automatically during assemble
Git-commit: 54148aba7c1a02bf018ae777bebc7f16e6cd3195
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If user has array with single ppl -
update the metadata to use multiple ppls.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/super-intel.c b/super-intel.c
index 65cdc92..630fb6e 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6184,6 +6184,36 @@ static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info,
out:
free(buf);
+ /*
+ * Update metadata to use mutliple PPLs area (1MB).
+ * This is done once for all RAID members
+ */
+ if (info->consistency_policy == CONSISTENCY_POLICY_PPL &&
+ info->ppl_size != (MULTIPLE_PPL_AREA_SIZE_IMSM >> 9)) {
+ char subarray[20];
+ struct mdinfo *member_dev;
+
+ sprintf(subarray, "%d", info->container_member);
+
+ if (mdmon_running(st->container_devnm))
+ st->update_tail = &st->updates;
+
+ if (st->ss->update_subarray(st, subarray, "ppl", NULL)) {
+ pr_err("Failed to update subarray %s\n",
+ subarray);
+ } else {
+ if (st->update_tail)
+ flush_metadata_updates(st);
+ else
+ st->ss->sync_metadata(st);
+ info->ppl_size = (MULTIPLE_PPL_AREA_SIZE_IMSM >> 9);
+ for (member_dev = info->devs; member_dev;
+ member_dev = member_dev->next)
+ member_dev->ppl_size =
+ (MULTIPLE_PPL_AREA_SIZE_IMSM >> 9);
+ }
+ }
+
if (ret == 1 && map->map_state == IMSM_T_STATE_UNINITIALIZED)
return st->ss->write_init_ppl(st, info, d->fd);
--
2.13.6
++++++ 0183-Grow-fix-switching-on-PPL-during-recovery.patch ++++++
From 41b25549f080ebac1269689f942f722368ed28b1 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:13 +0200
Subject: [PATCH] Grow: fix switching on PPL during recovery
Git-commit: 41b25549f080ebac1269689f942f722368ed28b1
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If raid memeber is not in sync - it is skipped during
enablement of PPL. This is not correct, since the drive that
we are currently recovering to does not have ppl_size and ppl_sector
properly set in sysfs.
Remove this skipping, so all drives are updated during turning on the PPL.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Grow.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Grow.c b/Grow.c
index bab1eec..1149753 100644
--- a/Grow.c
+++ b/Grow.c
@@ -637,9 +637,6 @@ int Grow_consistency_policy(char *devname, int fd, struct context *c, struct sha
int dfd;
char *devpath;
- if ((sd->disk.state & (1 << MD_DISK_SYNC)) == 0)
- continue;
-
devpath = map_dev(sd->disk.major, sd->disk.minor, 0);
dfd = dev_open(devpath, O_RDWR);
if (dfd < 0) {
--
2.13.6
++++++ 0184-imsm-don-t-skip-resync-when-an-invalid-ppl-header-is.patch ++++++
From b23d07503d5940086ea0884d09a737ccb0a9e435 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Thu, 28 Sep 2017 14:41:14 +0200
Subject: [PATCH] imsm: don't skip resync when an invalid ppl header is found
Git-commit: b23d07503d5940086ea0884d09a737ccb0a9e435
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If validate_ppl_imsm() detects an invalid ppl header it will be
overwritten with a valid, empty ppl header. But if we are assembling an
array after unclean shutdown this will cause the kernel to skip resync
after ppl recovery. We don't want that because if there was an invalid
ppl it's best to assume that the ppl recovery is not enough to make the
array consistent and a full resync should be performed. So when
overwriting the invalid ppl add one ppl_header_entry with a wrong
checksum. This will prevent the kernel from skipping resync after ppl
recovery.
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 630fb6e..7b2327b 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6080,6 +6080,16 @@ static int write_init_ppl_imsm(struct supertype *st, struct mdinfo *info, int fd
ppl_hdr = buf;
memset(ppl_hdr->reserved, 0xff, PPL_HDR_RESERVED);
ppl_hdr->signature = __cpu_to_le32(super->anchor->orig_family_num);
+
+ if (info->mismatch_cnt) {
+ /*
+ * We are overwriting an invalid ppl. Make one entry with wrong
+ * checksum to prevent the kernel from skipping resync.
+ */
+ ppl_hdr->entries_count = __cpu_to_le32(1);
+ ppl_hdr->entries[0].checksum = ~0;
+ }
+
ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
if (lseek64(fd, info->ppl_sector * 512, SEEK_SET) < 0) {
@@ -6214,8 +6224,12 @@ out:
}
}
- if (ret == 1 && map->map_state == IMSM_T_STATE_UNINITIALIZED)
- return st->ss->write_init_ppl(st, info, d->fd);
+ if (ret == 1) {
+ if (map->map_state == IMSM_T_STATE_UNINITIALIZED)
+ ret = st->ss->write_init_ppl(st, info, d->fd);
+ else
+ info->mismatch_cnt++;
+ }
return ret;
}
--
2.13.6
++++++ 0185-imsm-Write-empty-PPL-header-if-assembling-regular-cl.patch ++++++
From 50b9c10da0e7c153744b548680147dc8cc7c4c72 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak
Date: Thu, 28 Sep 2017 14:41:15 +0200
Subject: [PATCH] imsm: Write empty PPL header if assembling regular clean
array.
Git-commit: 50b9c10da0e7c153744b548680147dc8cc7c4c72
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If array was initially assembled with kernel without PPL support -
initial header was never written to the drive.
If initial resync was completed and system is rebooted to kernel with
PPL support - mdadm prevents from assembling normal clean array
due to lack of valid PPL.
Write empty header when assemble normal clean array, so the
its assamble is no longer blocked.
Signed-off-by: Pawel Baldysiak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/super-intel.c b/super-intel.c
index 7b2327b..501d0c3 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6225,7 +6225,9 @@ out:
}
if (ret == 1) {
- if (map->map_state == IMSM_T_STATE_UNINITIALIZED)
+ if (map->map_state == IMSM_T_STATE_UNINITIALIZED ||
+ (map->map_state == IMSM_T_STATE_NORMAL &&
+ !(dev->vol.dirty & RAIDVOL_DIRTY)))
ret = st->ss->write_init_ppl(st, info, d->fd);
else
info->mismatch_cnt++;
--
2.13.6
++++++ 0186-imsm-always-do-ppl-recovery-when-starting-a-rebuildi.patch ++++++
From 98e96bdbefaf0bf1c3d4161862af1ab6d03da1db Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Thu, 28 Sep 2017 14:41:16 +0200
Subject: [PATCH] imsm: always do ppl recovery when starting a rebuilding array
Git-commit: 98e96bdbefaf0bf1c3d4161862af1ab6d03da1db
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Set resync_start to 0 when starting a rebuilding array to make the
kernel perform ppl recovery before the rebuild.
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 501d0c3..996d133 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7756,6 +7756,9 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
map->blocks_per_strip;
info_d->ppl_sector = this->ppl_sector;
info_d->ppl_size = this->ppl_size;
+ if (this->consistency_policy == CONSISTENCY_POLICY_PPL &&
+ recovery_start == 0)
+ this->resync_start = 0;
} else {
info_d->component_size = blocks_per_member(map);
}
--
2.13.6
++++++ 0187-imsm-use-correct-map-when-validating-ppl.patch ++++++
From 2fc0fc63a9dbf31a3e333492bc1df80c21fdb10c Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Thu, 28 Sep 2017 14:41:17 +0200
Subject: [PATCH] imsm: use correct map when validating ppl
Git-commit: 2fc0fc63a9dbf31a3e333492bc1df80c21fdb10c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Use the first map to get the correct disk when rebuilding and not the
failed disk from the second map.
Signed-off-by: Artur Paszkiewicz
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 996d133..cf5d822 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6119,7 +6119,6 @@ static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info,
struct ppl_header *ppl_hdr;
__u32 crc;
struct imsm_dev *dev;
- struct imsm_map *map;
__u32 idx;
unsigned int i;
unsigned long long ppl_offset = 0;
@@ -6134,8 +6133,7 @@ static int validate_ppl_imsm(struct supertype *st, struct mdinfo *info,
}
dev = get_imsm_dev(super, info->container_member);
- map = get_imsm_map(dev, MAP_X);
- idx = get_imsm_disk_idx(dev, disk->disk.raid_disk, MAP_X);
+ idx = get_imsm_disk_idx(dev, disk->disk.raid_disk, MAP_0);
d = get_imsm_dl_disk(super, idx);
if (!d || d->index < 0 || is_failed(&d->disk))
@@ -6225,6 +6223,8 @@ out:
}
if (ret == 1) {
+ struct imsm_map *map = get_imsm_map(dev, MAP_X);
+
if (map->map_state == IMSM_T_STATE_UNINITIALIZED ||
(map->map_state == IMSM_T_STATE_NORMAL &&
!(dev->vol.dirty & RAIDVOL_DIRTY)))
--
2.13.6
++++++ 0188-imsm-write-initial-ppl-on-a-disk-added-for-rebuild.patch ++++++
From 2ec9d182ea5821ec2f7234ff3c0cf07ae9f43cb4 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Thu, 28 Sep 2017 14:41:18 +0200
Subject: [PATCH] imsm: write initial ppl on a disk added for rebuild
Git-commit: 2ec9d182ea5821ec2f7234ff3c0cf07ae9f43cb4
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
When rebuild is initiated by the UEFI driver it is possible that the new
disk will not contain a valid ppl header. Just write the initial ppl
and don't abort assembly.
Signed-off-by: Artur Paszkiewicz
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 cf5d822..536cb61 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6227,7 +6227,10 @@ out:
if (map->map_state == IMSM_T_STATE_UNINITIALIZED ||
(map->map_state == IMSM_T_STATE_NORMAL &&
- !(dev->vol.dirty & RAIDVOL_DIRTY)))
+ !(dev->vol.dirty & RAIDVOL_DIRTY)) ||
+ (dev->vol.migr_state == MIGR_REBUILD &&
+ dev->vol.curr_migr_unit == 0 &&
+ get_imsm_disk_idx(dev, disk->disk.raid_disk, MAP_1) != idx))
ret = st->ss->write_init_ppl(st, info, d->fd);
else
info->mismatch_cnt++;
--
2.13.6
++++++ 0189-Grow-Use-all-80-characters.patch ++++++
++++ 1104 lines (skipped)
++++++ 0190-imsm-Set-disk-slot-number.patch ++++++
From 20dc76d15b40c17b4ccdc3d6283af8ecb513707f Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Tue, 3 Oct 2017 14:49:49 +0200
Subject: [PATCH] imsm: Set disk slot number
Git-commit: 20dc76d15b40c17b4ccdc3d6283af8ecb513707f
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If first disk of IMSM RAID1 is failed but still present in the system,
the array is not auto-assembled. Auto-assemble uses raid disk slot from
metadata to index disks. As it's not set, the valid disk is seen as a
replacement disk and its metadata is ignored. The problem is not
observed for other RAID levels as they have more than 2 disks -
replacement disks are only stored under uneven indexes so third disk
metadata is used in such scenario.
Signed-off-by: Mariusz Tkaczyk
Reviewed-by: Tomasz Majchrzak
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 536cb61..b561fe2 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -3502,6 +3502,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
__u32 ord = get_imsm_ord_tbl_ent(dev, j, MAP_0);
__u32 idx = ord_to_idx(ord);
+ if (super->disks && super->disks->index == (int)idx)
+ info->disk.raid_disk = j;
+
if (!(ord & IMSM_ORD_REBUILD) &&
get_imsm_missing(super, idx)) {
missing = 1;
--
2.13.6
++++++ 0191-mdmon-get-safe-mode-delay-file-descriptor-early.patch ++++++
From c76242c56efb4d799bb15af1035a5f503cb4b8f3 Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak
Date: Wed, 4 Oct 2017 10:18:21 +0200
Subject: [PATCH] mdmon: get safe mode delay file descriptor early
Git-commit: c76242c56efb4d799bb15af1035a5f503cb4b8f3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
After switch root new mdmon is started. It sends initrd mdmon a signal
to terminate. initrd mdmon receives it and switches the safe mode delay
to 1 ms in order to get array to clean state and flush last version of
metadata. The problem is sysfs filesystem is not available to initrd mdmon
after switch root so the original safe mode delay is unchanged. The delay
is set to few seconds - if there is a lot of traffic on the filesystem,
initrd mdmon doesn't terminate for a long time (no clean state). There
are 2 instances of mdmon. initrd mdmon flushes metadata when array goes
to clean state but this metadata might be already outdated.
Use file descriptor obtained on mdmon start to change safe mode delay.
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
managemon.c | 16 +++++++++++++---
mdmon.h | 1 +
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/managemon.c b/managemon.c
index cc3c6f1..4e85398 100644
--- a/managemon.c
+++ b/managemon.c
@@ -129,6 +129,8 @@ static void close_aa(struct active_array *aa)
close(aa->metadata_fd);
if (aa->sync_completed_fd >= 0)
close(aa->sync_completed_fd);
+ if (aa->safe_mode_delay_fd >= 0)
+ close(aa->safe_mode_delay_fd);
}
static void free_aa(struct active_array *aa)
@@ -532,9 +534,15 @@ static void manage_member(struct mdstat_ent *mdstat,
if (a->container == NULL)
return;
- if (sigterm && a->info.safe_mode_delay != 1) {
- sysfs_set_safemode(&a->info, 1);
- a->info.safe_mode_delay = 1;
+ if (sigterm && a->info.safe_mode_delay != 1 &&
+ a->safe_mode_delay_fd >= 0) {
+ long int new_delay = 1;
+ char delay[10];
+ ssize_t len;
+
+ len = snprintf(delay, sizeof(delay), "0.%03ld\n", new_delay);
+ if (write(a->safe_mode_delay_fd, delay, len) == len)
+ a->info.safe_mode_delay = new_delay;
}
/* We don't check the array while any update is pending, as it
@@ -734,6 +742,8 @@ static void manage_new(struct mdstat_ent *mdstat,
new->resync_start_fd = sysfs_open2(new->info.sys_name, NULL, "resync_start");
new->metadata_fd = sysfs_open2(new->info.sys_name, NULL, "metadata_version");
new->sync_completed_fd = sysfs_open2(new->info.sys_name, NULL, "sync_completed");
+ new->safe_mode_delay_fd = sysfs_open2(new->info.sys_name, NULL,
+ "safe_mode_delay");
dprintf("inst: %s action: %d state: %d\n", inst,
new->action_fd, new->info.state_fd);
diff --git a/mdmon.h b/mdmon.h
index 0b08c3d..818367c 100644
--- a/mdmon.h
+++ b/mdmon.h
@@ -35,6 +35,7 @@ struct active_array {
int resync_start_fd;
int metadata_fd; /* for monitoring rw/ro status */
int sync_completed_fd; /* for checkpoint notification events */
+ int safe_mode_delay_fd;
unsigned long long last_checkpoint; /* sync_completed fires for many
* reasons this field makes sure the
* kernel has made progress before
--
2.13.6
++++++ 0192-mdadm-mdstat-fixup-a-number-of-broken-formatting.patch ++++++
From a9db89956e6f1a8b870df95dba9bf75f8f869d42 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Mon, 9 Oct 2017 16:21:13 +0800
Subject: [PATCH] mdadm/mdstat: fixup a number of '==' broken formatting
Git-commit: a9db89956e6f1a8b870df95dba9bf75f8f869d42
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
This commit doesn't change any codes, just tidy up the
code formatting.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdstat.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/mdstat.c b/mdstat.c
index 0d44050..6c906a7 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -158,11 +158,11 @@ struct mdstat_ent *mdstat_read(int hold, int start)
char devnm[32];
int in_devs = 0;
- if (strcmp(line, "Personalities")==0)
+ if (strcmp(line, "Personalities") == 0)
continue;
- if (strcmp(line, "read_ahead")==0)
+ if (strcmp(line, "read_ahead") == 0)
continue;
- if (strcmp(line, "unused")==0)
+ if (strcmp(line, "unused") == 0)
continue;
insert_here = NULL;
/* Better be an md line.. */
@@ -187,9 +187,9 @@ struct mdstat_ent *mdstat_read(int hold, int start)
for (w=dl_next(line); w!= line ; w=dl_next(w)) {
int l = strlen(w);
char *eq;
- if (strcmp(w, "active")==0)
+ if (strcmp(w, "active") == 0)
ent->active = 1;
- else if (strcmp(w, "inactive")==0) {
+ else if (strcmp(w, "inactive") == 0) {
ent->active = 0;
in_devs = 1;
} else if (ent->active > 0 &&
@@ -197,13 +197,13 @@ struct mdstat_ent *mdstat_read(int hold, int start)
w[0] != '(' /*readonly*/) {
ent->level = xstrdup(w);
in_devs = 1;
- } else if (in_devs && strcmp(w, "blocks")==0)
+ } else if (in_devs && strcmp(w, "blocks") == 0)
in_devs = 0;
else if (in_devs) {
char *ep = strchr(w, '[');
ent->devcnt +=
add_member_devname(&ent->members, w);
- if (ep && strncmp(w, "md", 2)==0) {
+ if (ep && strncmp(w, "md", 2) == 0) {
/* This has an md device as a component.
* If that device is already in the
* list, make sure we insert before
@@ -226,31 +226,31 @@ struct mdstat_ent *mdstat_read(int hold, int start)
} else if (w[0] == '[' && isdigit(w[1])) {
ent->raid_disks = atoi(w+1);
} else if (!ent->pattern &&
- w[0] == '[' &&
- (w[1] == 'U' || w[1] == '_')) {
+ w[0] == '[' &&
+ (w[1] == 'U' || w[1] == '_')) {
ent->pattern = xstrdup(w+1);
- if (ent->pattern[l-2]==']')
+ if (ent->pattern[l-2] == ']')
ent->pattern[l-2] = '\0';
} else if (ent->percent == RESYNC_NONE &&
- strncmp(w, "re", 2)== 0 &&
+ strncmp(w, "re", 2) == 0 &&
w[l-1] == '%' &&
- (eq=strchr(w, '=')) != NULL ) {
+ (eq = strchr(w, '=')) != NULL ) {
ent->percent = atoi(eq+1);
- if (strncmp(w,"resync", 6)==0)
+ if (strncmp(w,"resync", 6) == 0)
ent->resync = 1;
- else if (strncmp(w, "reshape", 7)==0)
+ else if (strncmp(w, "reshape", 7) == 0)
ent->resync = 2;
else
ent->resync = 0;
} else if (ent->percent == RESYNC_NONE &&
(w[0] == 'r' || w[0] == 'c')) {
- if (strncmp(w, "resync", 4)==0)
+ if (strncmp(w, "resync", 4) == 0)
ent->resync = 1;
- if (strncmp(w, "reshape", 7)==0)
+ if (strncmp(w, "reshape", 7) == 0)
ent->resync = 2;
- if (strncmp(w, "recovery", 8)==0)
+ if (strncmp(w, "recovery", 8) == 0)
ent->resync = 0;
- if (strncmp(w, "check", 5)==0)
+ if (strncmp(w, "check", 5) == 0)
ent->resync = 3;
if (l > 8 && strcmp(w+l-8, "=DELAYED") == 0)
@@ -289,7 +289,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
e->next = rv;
rv = e;
}
- } else rv = all;
+ } else
+ rv = all;
return rv;
}
--
2.13.6
++++++ 0193-mdadm-mdstat-correct-the-strncmp-number-4-as-6.patch ++++++
From 35c34037b55aaa36bdda5b1f01e69a1c84c8f408 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Mon, 9 Oct 2017 16:21:14 +0800
Subject: [PATCH] mdadm/mdstat: correct the strncmp number 4 as 6
Git-commit: 35c34037b55aaa36bdda5b1f01e69a1c84c8f408
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Mdstat: it should be corrected as 6 when strncmp 'resync'.
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdstat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mdstat.c b/mdstat.c
index 6c906a7..7e600d0 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -244,7 +244,7 @@ struct mdstat_ent *mdstat_read(int hold, int start)
ent->resync = 0;
} else if (ent->percent == RESYNC_NONE &&
(w[0] == 'r' || w[0] == 'c')) {
- if (strncmp(w, "resync", 4) == 0)
+ if (strncmp(w, "resync", 6) == 0)
ent->resync = 1;
if (strncmp(w, "reshape", 7) == 0)
ent->resync = 2;
--
2.13.6
++++++ 0194-mdcheck-add-some-logging.patch ++++++
From ea835492b6fffdb5ede879e461c8635b1e412a27 Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 6 Oct 2017 12:33:36 +1100
Subject: [PATCH] mdcheck: add some logging.
Git-commit: ea835492b6fffdb5ede879e461c8635b1e412a27
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Use 'logger' to report when mdcheck starts, stops, or continues
the check on an array.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
misc/mdcheck | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/misc/mdcheck b/misc/mdcheck
index 2c8f54d..589d038 100644
--- a/misc/mdcheck
+++ b/misc/mdcheck
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (C) 2014 Neil Brown
+# Copyright (C) 2014-2017 Neil Brown
#
#
# This program is free software; you can redistribute it and/or modify
@@ -14,7 +14,7 @@
# GNU General Public License for more details.
#
# Author: Neil Brown
-# Email:
+# Email:
# This script should be run periodically to automatically
# perform a 'check' on any md arrays.
@@ -94,17 +94,20 @@ do
if [ -z "$cont" ]
then
start=0
+ logger -p daemon.info mdcheck start checking $dev
elif [ -z "$MD_UUID" -o ! -f "$fl" ]
then
# Nothing to continue here
continue
else
start=`cat "$fl"`
+ logger -p daemon.info mdcheck continue checking $dev from $start
fi
cnt=$[cnt+1]
eval MD_${cnt}_fl=\$fl
eval MD_${cnt}_sys=\$sys
+ eval MD_${cnt}_dev=\$dev
echo $start > $fl
echo $start > $sys/md/sync_min
echo check > $sys/md/sync_action
@@ -145,6 +148,7 @@ for i in `eval echo {1..$cnt}`
do
eval fl=\$MD_${i}_fl
eval sys=\$MD_${i}_sys
+ eval dev=\$MD_${i}_dev
if [ -z "$fl" ]; then continue; fi
@@ -156,4 +160,5 @@ do
fi
echo idle > $sys/md/sync_action
cat $sys/md/sync_min > $fl
+ logger -p daemon.info pause checking $dev at `cat $fl`
done
--
2.13.6
++++++ 0195-mdcheck-improve-cleanup.patch ++++++
From f258a5e3911c4d8074c4f9578cccebf2a638a6e4 Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Fri, 6 Oct 2017 12:34:40 +1100
Subject: [PATCH] mdcheck: improve cleanup
Git-commit: f258a5e3911c4d8074c4f9578cccebf2a638a6e4
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
We should remove the tmp file on signals as well as on exit.
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
misc/mdcheck | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/mdcheck b/misc/mdcheck
index 589d038..42d4094 100644
--- a/misc/mdcheck
+++ b/misc/mdcheck
@@ -66,7 +66,7 @@ shift
# We need a temp file occasionally...
tmp=/var/lib/mdcheck/.md-check-$$
-trap 'rm -f "$tmp"' 0
+trap 'rm -f "$tmp"' 0 2 3 15
# firstly, clean out really old state files
--
2.13.6
++++++ 0197-mdadm-grow-adding-a-test-to-ensure-resize-was-requir.patch ++++++
From 1b21c449e6f2c81eb75cc0a6fc81b3edbefae5a3 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Wed, 11 Oct 2017 16:53:12 +0800
Subject: [PATCH] mdadm/grow: adding a test to ensure resize was required
Git-commit: 1b21c449e6f2c81eb75cc0a6fc81b3edbefae5a3
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
To fix the commit: 4b74a905a67e
(mdadm/grow: Component size must be larger than chunk size)
array.level > 1 : against the raids which chunk_size is meaningful.
s->size > 0 : ensure that changing component size has required.
array.chunk_size / 1024 > s->size : ensure component size should
be always >= current chunk_size when requires resize, otherwise,
mddev->pers->resize would be set mddev->dev_sectors as '0'.
Reported-by: Tomasz Majchrzak
Suggested-by: NeilBrown
Signed-off-by: Zhilong Liu
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 4d79d83..0f9e89b 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1809,8 +1809,8 @@ int Grow_reshape(char *devname, int fd,
return 1;
}
- if (array.level > 1 &&
- (array.chunk_size / 1024) > (int)s->size) {
+ if (array.level > 1 && s->size > 0 &&
+ (array.chunk_size / 1024) > (int)s->size) {
pr_err("component size must be larger than chunk size.\n");
return 1;
}
--
2.13.6
++++++ 0198-mdadm-mdopen-create-new-function-create_named_array-.patch ++++++
From 7105228e190870505b1d9163c104da9bdb42aa59 Mon Sep 17 00:00:00 2001
From: Zhilong Liu
Date: Mon, 16 Oct 2017 15:54:18 +0800
Subject: [PATCH] mdadm/mdopen: create new function create_named_array for
writing to new_array
Git-commit: 7105228e190870505b1d9163c104da9bdb42aa59
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Split 'write to new_array' out into a function named create_named_array.
And fixed a trivial compiling warning 'warn_unused_result' against commit:
fdbf7aaa1956 (mdopen: call "modprobe md_mod" if it might be needed.)
Suggested-by: NeilBrown
Signed-off-by: Zhilong Liu
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
mdopen.c | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/mdopen.c b/mdopen.c
index dcdc6f2..4ec13f5 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -100,6 +100,31 @@ void make_parts(char *dev, int cnt)
free(name);
}
+int create_named_array(char *devnm)
+{
+ int fd;
+ int n = -1;
+ static const char new_array_file[] = {
+ "/sys/module/md_mod/parameters/new_array"
+ };
+
+ fd = open(new_array_file, O_WRONLY);
+ if (fd < 0 && errno == ENOENT) {
+ if (system("modprobe md_mod") == 0)
+ fd = open(new_array_file, O_WRONLY);
+ }
+ if (fd >= 0) {
+ n = write(fd, devnm, strlen(devnm));
+ close(fd);
+ }
+ if (fd < 0 || n != (int)strlen(devnm)) {
+ pr_err("Fail create %s when using %s\n", devnm, new_array_file);
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* We need a new md device to assemble/build/create an array.
* 'dev' is a name given us by the user (command line or mdadm.conf)
@@ -306,37 +331,19 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
devnm[0] = 0;
if (num < 0 && cname && ci->names) {
- int fd;
- int n = -1;
sprintf(devnm, "md_%s", cname);
if (block_udev)
udev_block(devnm);
- fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
- if (fd < 0 && errno == ENOENT) {
- system("modprobe md_mod");
- fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
- }
- if (fd >= 0) {
- n = write(fd, devnm, strlen(devnm));
- close(fd);
- }
- if (n < 0) {
+ if (!create_named_array(devnm)) {
devnm[0] = 0;
udev_unblock();
}
}
if (num >= 0) {
- int fd;
- int n = -1;
sprintf(devnm, "md%d", num);
if (block_udev)
udev_block(devnm);
- fd = open("/sys/module/md_mod/parameters/new_array", O_WRONLY);
- if (fd >= 0) {
- n = write(fd, devnm, strlen(devnm));
- close(fd);
- }
- if (n < 0) {
+ if (!create_named_array(devnm)) {
devnm[0] = 0;
udev_unblock();
}
--
2.13.6
++++++ 0199-systemd-add-I-to-description-of-mdadm-last-resort-se.patch ++++++
From 3d6a7c8472497c076702b76f63d0f84af1a3105e Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Mon, 30 Oct 2017 11:42:15 +1100
Subject: [PATCH] systemd: add %I to description of mdadm-last-resort services.
Git-commit: 3d6a7c8472497c076702b76f63d0f84af1a3105e
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Just like the other template services, include the instance
name (I%) in the description of
mdadm-last-resort@.service
mdadm-last-resort@.timer
so that it is clear from the logs which array is affected.
Reported-by: Andrei Borzenkov
Link: http://bugzilla.opensuse.org/show_bug.cgi?id=1064915
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
systemd/mdadm-last-resort@.service | 2 +-
systemd/mdadm-last-resort@.timer | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/systemd/mdadm-last-resort@.service b/systemd/mdadm-last-resort@.service
index f9d4d12..efeb3f6 100644
--- a/systemd/mdadm-last-resort@.service
+++ b/systemd/mdadm-last-resort@.service
@@ -1,5 +1,5 @@
[Unit]
-Description=Activate md array even though degraded
+Description=Activate md array %I even though degraded
DefaultDependencies=no
ConditionPathExists=!/sys/devices/virtual/block/%i/md/sync_action
diff --git a/systemd/mdadm-last-resort@.timer b/systemd/mdadm-last-resort@.timer
index 52b3f22..45ad223 100644
--- a/systemd/mdadm-last-resort@.timer
+++ b/systemd/mdadm-last-resort@.timer
@@ -1,5 +1,5 @@
[Unit]
-Description=Timer to wait for more drives before activating degraded array.
+Description=Timer to wait for more drives before activating degraded array %I.
DefaultDependencies=no
Conflicts=sys-devices-virtual-block-%i.device
--
2.13.6
++++++ 0200-Incremental-Use-validate_geometry-instead-of-avail_s.patch ++++++
From 3bc6f786e1156d12ee466d732930bf71f6a8083a Mon Sep 17 00:00:00 2001
From: NeilBrown
Date: Mon, 30 Oct 2017 15:43:41 +1100
Subject: [PATCH] Incremental: Use ->validate_geometry instead of ->avail_size
Git-commit: 3bc6f786e1156d12ee466d732930bf71f6a8083a
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Since mdadm 3.3 is has not been correct to call ->avail_size if
metadata hasn't been read from the device. ->validate_geometry
should be used instead.
Unfortunately array_try_spare() didn't get the memo, and it can crash
when adding a spare with no metdata.
So change it to use ->validate_geometry().
Only one place remains that uses ->avail_size(), and that is safe.
Also fix a comment with a typo.
Reported-and-tested-by: Bjørnar Ness
Fixes: 641da7459192 ("super1: separate to version of _avail_space1().")
Signed-off-by: NeilBrown
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Incremental.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 91301eb..0beab16 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -870,7 +870,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
struct supertype *st2;
struct domainlist *dl = NULL;
struct mdinfo *sra;
- unsigned long long devsize;
+ unsigned long long devsize, freesize = 0;
struct spare_criteria sc = {0, 0};
if (is_subarray(mp->metadata))
@@ -942,10 +942,13 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
close(mdfd);
}
if ((sra->component_size > 0 &&
- st2->ss->avail_size(st2, devsize,
- sra->devs ? sra->devs->data_offset :
- INVALID_SECTORS) <
- sra->component_size) ||
+ st2->ss->validate_geometry(st2, sra->array.level, sra->array.layout,
+ sra->array.raid_disks, &sra->array.chunk_size,
+ sra->component_size,
+ sra->devs ? sra->devs->data_offset : INVALID_SECTORS,
+ devname, &freesize, sra->consistency_policy,
+ 0) &&
+ freesize < sra->component_size) ||
(sra->component_size == 0 && devsize < sc.min_size)) {
if (verbose > 1)
pr_err("not adding %s to %s as it is too small\n",
@@ -1265,7 +1268,7 @@ static int try_spare(char *devname, int *dfdp, struct dev_policy *pol,
* what arrays might be candidates.
*/
if (st) {
- /* just try try 'array' or 'partition' based on this metadata */
+ /* just try to add 'array' or 'partition' based on this metadata */
if (st->ss->add_to_super)
return array_try_spare(devname, dfdp, pol, target, bare,
st, verbose);
--
2.13.6
++++++ 0201-imsm-fix-reading-scsi-serial.patch ++++++
From 01a052b9c1c6bdc7307a3f8e8d12db262d9b258c Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz
Date: Thu, 2 Nov 2017 16:10:57 +0100
Subject: [PATCH] imsm: fix reading scsi serial
Git-commit: 01a052b9c1c6bdc7307a3f8e8d12db262d9b258c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Improve error detection after SG_IO ioctl. Checking only the return
value and response length is insufficient and leads to anomalies if a
drive does not have a serial number.
Reported-by: NeilBrown
Tested-by: NeilBrown
Signed-off-by: Artur Paszkiewicz
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
sg_io.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sg_io.c b/sg_io.c
index 42c91e1..7889a95 100644
--- a/sg_io.c
+++ b/sg_io.c
@@ -46,6 +46,9 @@ int scsi_get_serial(int fd, void *buf, size_t buf_len)
if (rv)
return rv;
+ if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK)
+ return -1;
+
rsp_len = rsp_buf[3];
if (!rsp_len || buf_len < rsp_len)
--
2.13.6
++++++ 0059-To-support-clustered-raid10.patch -> 0202-To-support-clustered-raid10.patch ++++++
--- /work/SRC/openSUSE:Factory/mdadm/0059-To-support-clustered-raid10.patch 2017-11-25 08:40:37.310711054 +0100
+++ /work/SRC/openSUSE:Factory/.mdadm.new/0202-To-support-clustered-raid10.patch 2017-12-08 12:54:42.211502250 +0100
@@ -2,6 +2,9 @@
From: Guoqing Jiang
Date: Mon, 30 Oct 2017 17:09:51 +0800
Subject: [PATCH] To support clustered raid10
+Git-commit: 5339f99606f19ce1eeadebf3c0849933dc0c6fd5
+Patch-mainline: mdadm-4.0+
+References: bsc#1069165, bsc#1069167, bsc#1068030
We are now considering to extend clustered raid to
support raid10. But only near layout is supported,
@@ -10,6 +13,8 @@
Signed-off-by: Guoqing Jiang
Signed-off-by: Jes Sorensen
+Signed-off-by: Coly Li
+
---
Grow.c | 6 ++++++
mdadm.c | 9 +++++++--
@@ -18,7 +23,7 @@
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/Grow.c b/Grow.c
-index 0f9e89bcc5ba..80176e32c52f 100644
+index 0f9e89b..80176e3 100644
--- a/Grow.c
+++ b/Grow.c
@@ -359,6 +359,12 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
@@ -35,7 +40,7 @@
st = super_by_fd(fd, &subarray);
diff --git a/mdadm.c b/mdadm.c
-index 7cdcdba7c652..87cb33f84ac2 100644
+index 7cdcdba..87cb33f 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1542,8 +1542,13 @@ int main(int argc, char *argv[])
@@ -55,7 +60,7 @@
break;
}
diff --git a/mdadm.h b/mdadm.h
-index 85947bf62ff0..3cbf82f18d9e 100644
+index 85947bf..3cbf82f 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1434,6 +1434,7 @@ extern int get_linux_version(void);
@@ -67,7 +72,7 @@
extern int parse_layout_faulty(char *layout);
extern long parse_num(char *num);
diff --git a/util.c b/util.c
-index c11729e3260e..543ec6cf46ef 100644
+index c11729e..543ec6c 100644
--- a/util.c
+++ b/util.c
@@ -397,6 +397,17 @@ unsigned long long parse_size(char *size)
@@ -89,5 +94,5 @@
{
int copies, rv;
--
-2.10.0
+2.13.6
++++++ 0203-imsm-More-precise-message-when-spanned-raid-is-creat.patch ++++++
From cca672081e7f03d2763fdc7915379d37d581ad8b Mon Sep 17 00:00:00 2001
From: Michal Zylowski
Date: Wed, 8 Nov 2017 15:43:41 +0100
Subject: [PATCH] imsm: More precise message when spanned raid is created
Git-commit: cca672081e7f03d2763fdc7915379d37d581ad8b
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
When RAID is created between VMD and SATA disks, printed message is
"Mixing devices attached to different VMD domains is not allowed". This message
is unclear and misleading because creating spanned containers between different
VMD domains is allowed. Set error message to more precise text.
Signed-off-by: Michal Zylowski
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 b561fe2..2f912f2 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4500,8 +4500,7 @@ static int find_intel_hba_capability(int fd, struct intel_super *super, char *de
hba = hba->next;
}
fprintf(stderr, ").\n"
- " Mixing devices attached to different %s is not allowed.\n",
- hba_name->type == SYS_DEV_VMD ? "VMD domains" : "controllers");
+ " Mixing devices attached to different controllers is not allowed.\n");
}
return 2;
}
--
2.13.6
++++++ 0204-sysfs-include-faulty-drive-in-disk-count.patch ++++++
From fe05dc43d81e0c91cc84498e7229008748986b71 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Tue, 7 Nov 2017 16:49:56 +0100
Subject: [PATCH] sysfs: include faulty drive in disk count
Git-commit: fe05dc43d81e0c91cc84498e7229008748986b71
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
When the disk fails, it goes into faulty state first and it is removed
from the array in a while. It gives mdadm monitor a chance to see the disk
has failed and notify an event (e.g. FailSpare). It doesn't work when
sysfs is used to get a number of disks in the array as it skips faulty
disk. ioctl implementation doesn't differentiate between active and
faulty disk. Do the same for sysfs then. It should not matter that number
of disks reported is greater than list of disk structures returned by the
call because the same approach already takes place for offline disks.
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysfs.c b/sysfs.c
index bf5c8c5..df6fdda 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -307,6 +307,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
dev->disk.raid_disk = strtoul(buf, &ep, 10);
if (*ep) dev->disk.raid_disk = -1;
+ sra->array.nr_disks++;
strcpy(dbase, "block/dev");
if (load_sys(fname, buf, sizeof(buf))) {
/* assume this is a stale reference to a hot
@@ -315,7 +316,6 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
free(dev);
continue;
}
- sra->array.nr_disks++;
sscanf(buf, "%d:%d", &dev->disk.major, &dev->disk.minor);
/* special case check for block devices that can go 'offline' */
--
2.13.6
++++++ 0205-Monitor-msg-Don-t-print-error-message-if-mdmon-doesn.patch ++++++
From 1ea0462990c466d9ffd25d149fa6e983b8834b30 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk
Date: Tue, 21 Nov 2017 11:30:20 +0100
Subject: [PATCH] Monitor/msg: Don't print error message if mdmon doesn't run
Git-commit: 1ea0462990c466d9ffd25d149fa6e983b8834b30
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Commit 4515fb28a53a ("Add detail information when can not connect
monitor") was added to warn about failed connection to monitor in
WaitClean function (see link below).
Mdmon runs for IMSM containers when they have array with redundancy so
if mdmon doesn't run, mdadm prints this error. This is misleading and
unnecessary. Just print it in WaitClean function.
The sock in WaitClean is deprecated so it is removed.
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1375002
Signed-off-by: Mariusz Tkaczyk
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
Monitor.c | 9 +++++----
mdadm.c | 4 ++--
mdadm.h | 2 +-
msg.c | 2 --
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index b60996b..c7c05d2 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1058,7 +1058,7 @@ int Wait(char *dev)
static char *clean_states[] = {
"clear", "inactive", "readonly", "read-auto", "clean", NULL };
-int WaitClean(char *dev, int sock, int verbose)
+int WaitClean(char *dev, int verbose)
{
int fd;
struct mdinfo *mdi;
@@ -1125,15 +1125,16 @@ int WaitClean(char *dev, int sock, int verbose)
}
if (rv < 0)
rv = 1;
- else if (fping_monitor(sock) == 0 ||
- ping_monitor(mdi->text_version) == 0) {
+ else if (ping_monitor(mdi->text_version) == 0) {
/* we need to ping to close the window between array
* state transitioning to clean and the metadata being
* marked clean
*/
rv = 0;
- } else
+ } else {
rv = 1;
+ pr_err("Error connecting monitor with %s\n", dev);
+ }
if (rv && verbose)
pr_err("Error waiting for %s to be clean\n", dev);
diff --git a/mdadm.c b/mdadm.c
index 87cb33f..62d7ec3 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1863,7 +1863,7 @@ static int misc_scan(char devmode, struct context *c)
if (devmode == 'D')
rv |= Detail(name, c);
else
- rv |= WaitClean(name, -1, c->verbose);
+ rv |= WaitClean(name, c->verbose);
put_md_name(name);
}
}
@@ -1954,7 +1954,7 @@ static int misc_list(struct mddev_dev *devlist,
rv |= Wait(dv->devname);
continue;
case Waitclean:
- rv |= WaitClean(dv->devname, -1, c->verbose);
+ rv |= WaitClean(dv->devname, c->verbose);
continue;
case KillSubarray:
rv |= Kill_subarray(dv->devname, c->subarray, c->verbose);
diff --git a/mdadm.h b/mdadm.h
index 3cbf82f..cf4721a 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1395,7 +1395,7 @@ extern int Kill(char *dev, struct supertype *st, int force, int verbose, int noe
extern int Kill_subarray(char *dev, char *subarray, int verbose);
extern int Update_subarray(char *dev, char *subarray, char *update, struct mddev_ident *ident, int quiet);
extern int Wait(char *dev);
-extern int WaitClean(char *dev, int sock, int verbose);
+extern int WaitClean(char *dev, int verbose);
extern int SetAction(char *dev, char *action);
extern int Incremental(struct mddev_dev *devlist, struct context *c,
diff --git a/msg.c b/msg.c
index c66b0a1..45cd450 100644
--- a/msg.c
+++ b/msg.c
@@ -171,8 +171,6 @@ int connect_monitor(char *devname)
addr.sun_family = PF_LOCAL;
strcpy(addr.sun_path, path);
if (connect(sfd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
- pr_err("Error connecting monitor with %s: %s\n",
- addr.sun_path, strerror(errno));
close(sfd);
return -1;
}
--
2.13.6
++++++ 0206-imsm-continue-resync-on-3-disk-RAID10.patch ++++++
From 8b9cd157dc030924afaeb1dd1a4d3306f5bda118 Mon Sep 17 00:00:00 2001
From: Maksymilian Kunt
Date: Mon, 13 Nov 2017 12:30:49 +0100
Subject: [PATCH] imsm: continue resync on 3-disk RAID10
Git-commit: 8b9cd157dc030924afaeb1dd1a4d3306f5bda118
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
If RAID10 gets degraded during resync and is stopped, it doesn't continue
resync after automatic assemble and it is reported to be in sync. Resync
is blocked because the disk is missing. It should not happen for RAID10 as
it can still continue with 3 disks.
Count missing disks. Block resync only if number of missing disks exceeds
limit for given RAID level (only different for RAID10). Check if the
disk under recovery is present. If not, resync should be allowed to run.
Signed-off-by: Maksymilian Kunt
Signed-off-by: Tomasz Majchrzak
Signed-off-by: Jes Sorensen
Signed-off-by: Coly Li
---
super-intel.c | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 2f912f2..c55802f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1342,6 +1342,20 @@ static unsigned long long round_size_to_mb(unsigned long long size, unsigned int
return size;
}
+static int able_to_resync(int raid_level, int missing_disks)
+{
+ int max_missing_disks = 0;
+
+ switch (raid_level) {
+ case 10:
+ max_missing_disks = 1;
+ break;
+ default:
+ max_missing_disks = 0;
+ }
+ return missing_disks <= max_missing_disks;
+}
+
/* try to determine how much space is reserved for metadata from
* the last get_extents() entry on the smallest active disk,
* otherwise fallback to the default
@@ -7645,6 +7659,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
int slot;
int chunk;
char *ep;
+ int level;
if (subarray &&
(i != strtoul(subarray, &ep, 10) || *ep != '\0'))
@@ -7653,6 +7668,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
dev = get_imsm_dev(super, i);
map = get_imsm_map(dev, MAP_0);
map2 = get_imsm_map(dev, MAP_1);
+ level = get_imsm_raid_level(map);
/* do not publish arrays that are in the middle of an
* unsupported migration
@@ -7675,8 +7691,8 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
chunk = __le16_to_cpu(map->blocks_per_strip) >> 1;
/* mdadm does not support all metadata features- set the bit in all arrays state */
if (!validate_geometry_imsm_orom(super,
- get_imsm_raid_level(map), /* RAID level */
- imsm_level_to_layout(get_imsm_raid_level(map)),
+ level, /* RAID level */
+ imsm_level_to_layout(level),
map->num_members, /* raid disks */
&chunk, join_u32(dev->size_low, dev->size_high),
1 /* verbose */)) {
@@ -7700,6 +7716,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
int idx;
int skip;
__u32 ord;
+ int missing = 0;
skip = 0;
idx = get_imsm_disk_idx(dev, slot, MAP_0);
@@ -7713,19 +7730,27 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
skip = 1;
if (d && is_failed(&d->disk))
skip = 1;
- if (ord & IMSM_ORD_REBUILD)
+ if (!skip && (ord & IMSM_ORD_REBUILD))
recovery_start = 0;
/*
* if we skip some disks the array will be assmebled degraded;
* reset resync start to avoid a dirty-degraded
* situation when performing the intial sync
- *
- * FIXME handle dirty degraded
*/
- if ((skip || recovery_start == 0) &&
- !(dev->vol.dirty & RAIDVOL_DIRTY))
- this->resync_start = MaxSector;
+ if (skip)
+ missing++;
+
+ if (!(dev->vol.dirty & RAIDVOL_DIRTY)) {
+ if ((!able_to_resync(level, missing) ||
+ recovery_start == 0))
+ this->resync_start = MaxSector;
+ } else {
+ /*
+ * FIXME handle dirty degraded
+ */
+ }
+
if (skip)
continue;
--
2.13.6