SHA256
1
0
forked from pool/mdadm

Accepting request 548207 from home:colyli:branches:Base:System

- 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
  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

OBS-URL: https://build.opensuse.org/request/show/548207
OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=156
This commit is contained in:
Neil Brown 2017-12-04 21:26:22 +00:00 committed by Git OBS Bridge
parent 81b5777cbc
commit 849a39cd07
171 changed files with 17256 additions and 171 deletions

View File

@ -0,0 +1,61 @@
From 230a0dde0926125b8895e02a669b4701f79c0f07 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -3,10 +3,15 @@ From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Create.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)

View File

@ -2,17 +2,22 @@ From 98dbf73cba81cd846f9c706f37edc22e21038cf4 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
/* 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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
(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 @@ Index: mdadm/Create.c
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 @@ Index: mdadm/Create.c
+ 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 @@ Index: mdadm/Create.c
raid_disk_num += 1;
continue;
}
--
2.13.6

View File

@ -2,6 +2,9 @@ From 5fbc1f1527ec86ae904739a27c0af4e3bc89084e Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 @@ For example, gcc version 4.8.5(SUSE Linux).
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
mdadm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

View File

@ -3,6 +3,9 @@ From: NeilBrown <neilb@suse.com>
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 @@ have mdadm disable create_on_open automatically.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
mdopen.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

View File

@ -2,6 +2,9 @@ From 8a70632fc2f9026e0f4895f5348cc7cd20d9fbb3 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 @@ Fixes: af8d8e6f0315 ("md: changes for MD_STILL_CLOSED flag")
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
mdadm.8.in | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

View File

@ -2,12 +2,17 @@ From e39c76b9b72db00d32780e9f30dfba25f58922d2 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
mdadm.8.in | 2 ++
1 file changed, 2 insertions(+)

View File

@ -2,11 +2,16 @@ From e47781fcea24778a16e4be53e5b84eab8db9413c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
maps.c | 1 +
1 file changed, 1 insertion(+)

View File

@ -3,6 +3,9 @@ From: NeilBrown <neilb@suse.com>
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 @@ verify_reshape_position() will not do the right thing.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Grow.c | 1 +
1 file changed, 1 insertion(+)

View File

@ -3,6 +3,9 @@ From: NeilBrown <neilb@suse.com>
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 @@ to rely on it to determine if the last-resort is really needed.
Fixes: cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
systemd/mdadm-last-resort@.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

View File

@ -3,6 +3,9 @@ From: NeilBrown <neilb@suse.com>
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 @@ change all non-alphanumerics to '_'.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Detail.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

View File

@ -2,6 +2,9 @@ From 07c45a1871df0a70beb8da80d11601d33c7a5de2 Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
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 @@ not updated prior to array size update, the grow operation fails.
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Grow.c | 2 ++
1 file changed, 2 insertions(+)

View File

@ -2,12 +2,17 @@ From 922a58292fafa4efcfcd44fbc46b0665681c955a Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
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 <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Grow.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

View File

@ -2,6 +2,9 @@ From b208f817ec538e56df7280f0353e6bda532b9432 Mon Sep 17 00:00:00 2001
From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
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 @@ reshape is taking place.
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Grow.c | 7 +++++++
1 file changed, 7 insertions(+)

View File

@ -2,6 +2,9 @@ From 84918897ee8bb450ea09f7c95b9da44df8e925e4 Mon Sep 17 00:00:00 2001
From: Maksymilian Kunt <maksymilian.kunt@intel.com>
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 @@ print "Sector Size".
Signed-off-by: Maksymilian Kunt <maksymilian.kunt@intel.com>
Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super-intel.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

View File

@ -2,6 +2,9 @@ From 5c5ea85b4deedf5e7491a905bbb4f4a3bc284f2c Mon Sep 17 00:00:00 2001
From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
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 @@ to the container.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super-intel.c | 6 ------
1 file changed, 6 deletions(-)

View File

@ -2,6 +2,9 @@ From 853375734edcfd70ba64b444b9e69f7e336a30b7 Mon Sep 17 00:00:00 2001
From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
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 @@ array) as they might not match.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super-intel.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

View File

@ -3,6 +3,9 @@ From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
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 @@ container.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super-intel.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

View File

@ -0,0 +1,38 @@
From e81070a69bf0c6e20f95806b6c60f6ec5c952a20 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,421 @@
From 9cd39f015558dba82c293a4433b481b921ceec87 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,58 @@
From 5b13d2e1fb8abecddd4e28e67facac5d7ef2cef3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,273 @@
From d97572f5a59ca1ddde9971a79d47c9ea4db5891b Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,158 @@
From 018a488238e2ff55d7c2fd29333c1f7305354318 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_SB_BITMAP_PRESENT)) &&
!(array.state & (1<<MD_SB_CLUSTERED))) {
array.state &= ~(1<<MD_SB_BITMAP_PRESENT);
- if (ioctl(fd, SET_ARRAY_INFO, &array)!= 0) {
+ if (md_set_array_info(fd, &array)!= 0) {
pr_err("failed to remove internal bitmap.\n");
return 1;
}
@@ -2056,7 +2056,7 @@ int Grow_reshape(char *devname, int fd,
else
rv = -1;
} else {
- rv = ioctl(fd, SET_ARRAY_INFO, &array);
+ rv = md_set_array_info(fd, &array);
/* manage array size when it is managed externally
*/
@@ -2272,7 +2272,7 @@ size_change_error:
goto release;
}
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");
rv = 1;
} else if (c->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

View File

@ -0,0 +1,44 @@
From b0ba6a1dee995b3cd7331b4df92d115e51d8ac0c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,42 @@
From 5b2846684ef5172eccc432e3520b79efbc2abba5 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,56 @@
From 67a02d520085b01a1b9e6ea59fb30e79c5649c9c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,336 @@
From dae131379f9fd82e2867aed25a3ff719f957e9a3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,42 @@
From f5c924f441cedce2a13c48b12be35250560ee575 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,57 @@
From 700483a22340f2f25a761acd08e6db87e92d90e9 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,35 @@
From 6142741d144824c31b733f9d6e6e240b159effc0 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,271 @@
From e6e5f8f1267de4f310415231b3434fce2d25f02a Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_SYNC) | (1<<MD_DISK_ACTIVE);
- if (dv->writemostly == FlagSet)
- disk.state |= 1<<MD_DISK_WRITEMOSTLY;
- disk.major = major(stb.st_rdev);
- disk.minor = minor(stb.st_rdev);
- if (ioctl(mdfd, ADD_NEW_DISK, &disk)) {
- pr_err("ADD_NEW_DISK failed for %s: %s\n",
- dv->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<<MD_DISK_SYNC) | (1<<MD_DISK_ACTIVE);
+ if (dv->writemostly == FlagSet)
+ disk.state |= 1<<MD_DISK_WRITEMOSTLY;
+ disk.major = major(stb.st_rdev);
+ disk.minor = minor(stb.st_rdev);
+ if (ioctl(mdfd, ADD_NEW_DISK, &disk)) {
+ pr_err("ADD_NEW_DISK failed for %s: %s\n",
+ dv->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, &param)) {
- 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, &param)) {
+ 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

View File

@ -0,0 +1,40 @@
From 6ae8b2b3140475b1a70485052454210aba4065a6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,82 @@
From 901d5ee6da145033ac30fee68f4fec0e8af9eddc Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_SB_BITMAP_PRESENT))
--
2.13.6

View File

@ -0,0 +1,93 @@
From 5f4cc2392689528a9234fae1935cd442f7917738 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,73 @@
From 091e8e6e061a5739be68d214bbd4a25e38bec65c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,69 @@
From 5cb859962febacba3bb9257fc6ed9553ecc16752 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,31 @@
From 5d89b18da805cb9ce2b0f726cd534bcbf4dce8c6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,36 @@
From 15d924d363a2bc02aa4a489241333be3d7820978 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,51 @@
From 40b054e1dc9e334621fd2081bf6fc46b01dd7ef4 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,42 @@
From 1c9591115d577841522acd245cd2445cb77ee204 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,35 @@
From b6e60be6281a2a4ec326a72de114867797a42d7f Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,71 @@
From 303949f6f00b750a88bcdfc39ffdfe9f0463f6f2 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,37 @@
From dcf3d4de95d1a4cbc65b24a844173ba1c1300b55 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,37 @@
From 2cfe6f7c646ebc25043f7607f5756edad0bc3071 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

1401
0082-Retire-mdassemble.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,914 @@
From 46a533a90c01b0492577c61d4e65de2ac4bf220c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
Date: Tue, 11 Apr 2017 14:25:24 -0400
Subject: [PATCH] super1: Clean up various style abuses
Git-commit: 46a533a90c01b0492577c61d4e65de2ac4bf220c
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Code is 80 characters wide, so lets try to respect that. In addition, we
should never have one-line 'if () action()' statements. Fixup various
whitespace abuse.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super1.c | 363 +++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 223 insertions(+), 140 deletions(-)
diff --git a/super1.c b/super1.c
index 4db4dff..2fcb814 100644
--- a/super1.c
+++ b/super1.c
@@ -227,6 +227,7 @@ static void init_afd(struct align_fd *afd, int fd)
}
static char abuf[4096+4096];
+
static int aread(struct align_fd *afd, void *buf, int len)
{
/* aligned read.
@@ -339,7 +340,8 @@ static void examine_super1(struct supertype *st, char *homehost)
strncmp(sb->set_name, homehost, l) == 0)
printf(" (local to host %s)", homehost);
printf("\n");
- if (bms->nodes > 0 && (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
+ if (bms->nodes > 0 &&
+ (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
printf(" Cluster Name : %-64s\n", bms->cluster_name);
atime = __le64_to_cpu(sb->ctime) & 0xFFFFFFFFFFULL;
printf(" Creation Time : %.24s\n", ctime(&atime));
@@ -385,7 +387,8 @@ static void examine_super1(struct supertype *st, char *homehost)
printf(" Super Offset : %llu sectors\n",
(unsigned long long)__le64_to_cpu(sb->super_offset));
if (__le32_to_cpu(sb->feature_map) & MD_FEATURE_RECOVERY_OFFSET)
- printf("Recovery Offset : %llu sectors\n", (unsigned long long)__le64_to_cpu(sb->recovery_offset));
+ printf("Recovery Offset : %llu sectors\n",
+ (unsigned long long)__le64_to_cpu(sb->recovery_offset));
st->ss->getinfo_super(st, &info, NULL);
if (info.space_after != 1 &&
@@ -393,10 +396,12 @@ static void examine_super1(struct supertype *st, char *homehost)
printf(" Unused Space : before=%llu sectors, after=%llu sectors\n",
info.space_before, info.space_after);
- printf(" State : %s\n", (__le64_to_cpu(sb->resync_offset)+1)? "active":"clean");
+ printf(" State : %s\n",
+ (__le64_to_cpu(sb->resync_offset)+1)? "active":"clean");
printf(" Device UUID : ");
for (i=0; i<16; i++) {
- if ((i&3)==0 && i != 0) printf(":");
+ if ((i&3)==0 && i != 0)
+ printf(":");
printf("%02x", sb->device_uuid[i]);
}
printf("\n");
@@ -410,12 +415,15 @@ static void examine_super1(struct supertype *st, char *homehost)
__le16_to_cpu(sb->ppl.offset));
}
if (sb->feature_map & __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE)) {
- printf(" Reshape pos'n : %llu%s\n", (unsigned long long)__le64_to_cpu(sb->reshape_position)/2,
+ printf(" Reshape pos'n : %llu%s\n", (unsigned long long)
+ __le64_to_cpu(sb->reshape_position)/2,
human_size(__le64_to_cpu(sb->reshape_position)<<9));
if (__le32_to_cpu(sb->delta_disks)) {
- printf(" Delta Devices : %d", __le32_to_cpu(sb->delta_disks));
+ printf(" Delta Devices : %d",
+ __le32_to_cpu(sb->delta_disks));
printf(" (%d->%d)\n",
- __le32_to_cpu(sb->raid_disks)-__le32_to_cpu(sb->delta_disks),
+ __le32_to_cpu(sb->raid_disks) -
+ __le32_to_cpu(sb->delta_disks),
__le32_to_cpu(sb->raid_disks));
if ((int)__le32_to_cpu(sb->delta_disks) < 0)
delta_extra = -__le32_to_cpu(sb->delta_disks);
@@ -424,13 +432,16 @@ static void examine_super1(struct supertype *st, char *homehost)
c = map_num(pers, __le32_to_cpu(sb->new_level));
printf(" New Level : %s\n", c?c:"-unknown-");
}
- if (__le32_to_cpu(sb->new_layout) != __le32_to_cpu(sb->layout)) {
+ if (__le32_to_cpu(sb->new_layout) !=
+ __le32_to_cpu(sb->layout)) {
if (__le32_to_cpu(sb->level) == 5) {
- c = map_num(r5layout, __le32_to_cpu(sb->new_layout));
+ c = map_num(r5layout,
+ __le32_to_cpu(sb->new_layout));
printf(" New Layout : %s\n", c?c:"-unknown-");
}
if (__le32_to_cpu(sb->level) == 6) {
- c = map_num(r6layout, __le32_to_cpu(sb->new_layout));
+ c = map_num(r6layout,
+ __le32_to_cpu(sb->new_layout));
printf(" New Layout : %s\n", c?c:"-unknown-");
}
if (__le32_to_cpu(sb->level) == 10) {
@@ -439,8 +450,10 @@ static void examine_super1(struct supertype *st, char *homehost)
printf("\n");
}
}
- if (__le32_to_cpu(sb->new_chunk) != __le32_to_cpu(sb->chunksize))
- printf(" New Chunksize : %dK\n", __le32_to_cpu(sb->new_chunk)/2);
+ if (__le32_to_cpu(sb->new_chunk) !=
+ __le32_to_cpu(sb->chunksize))
+ printf(" New Chunksize : %dK\n",
+ __le32_to_cpu(sb->new_chunk)/2);
printf("\n");
}
if (sb->devflags) {
@@ -459,18 +472,20 @@ static void examine_super1(struct supertype *st, char *homehost)
printf(" Bad Block Log : %d entries available at offset %ld sectors",
__le16_to_cpu(sb->bblog_size)*512/8,
(long)(int32_t)__le32_to_cpu(sb->bblog_offset));
- if (sb->feature_map &
- __cpu_to_le32(MD_FEATURE_BAD_BLOCKS))
+ if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BAD_BLOCKS))
printf(" - bad blocks present.");
printf("\n");
}
if (calc_sb_1_csum(sb) == sb->sb_csum)
- printf(" Checksum : %x - correct\n", __le32_to_cpu(sb->sb_csum));
+ printf(" Checksum : %x - correct\n",
+ __le32_to_cpu(sb->sb_csum));
else
- printf(" Checksum : %x - expected %x\n", __le32_to_cpu(sb->sb_csum),
+ printf(" Checksum : %x - expected %x\n",
+ __le32_to_cpu(sb->sb_csum),
__le32_to_cpu(calc_sb_1_csum(sb)));
- printf(" Events : %llu\n", (unsigned long long)__le64_to_cpu(sb->events));
+ printf(" Events : %llu\n",
+ (unsigned long long)__le64_to_cpu(sb->events));
printf("\n");
if (__le32_to_cpu(sb->level) == 5) {
c = map_num(r5layout, __le32_to_cpu(sb->layout));
@@ -492,26 +507,34 @@ static void examine_super1(struct supertype *st, char *homehost)
case 5:
case 6:
case 10:
- printf(" Chunk Size : %dK\n", __le32_to_cpu(sb->chunksize)/2);
+ printf(" Chunk Size : %dK\n",
+ __le32_to_cpu(sb->chunksize)/2);
break;
case -1:
- printf(" Rounding : %dK\n", __le32_to_cpu(sb->chunksize)/2);
+ printf(" Rounding : %dK\n",
+ __le32_to_cpu(sb->chunksize)/2);
+ break;
+ default:
break;
- default: break;
}
printf("\n");
#if 0
/* This turns out to just be confusing */
printf(" Array Slot : %d (", __le32_to_cpu(sb->dev_number));
- for (i= __le32_to_cpu(sb->max_dev); i> 0 ; i--)
+ for (i = __le32_to_cpu(sb->max_dev); i> 0 ; i--)
if (__le16_to_cpu(sb->dev_roles[i-1]) != MD_DISK_ROLE_SPARE)
break;
- for (d=0; d < i; d++) {
+ for (d = 0; d < i; d++) {
int role = __le16_to_cpu(sb->dev_roles[d]);
- if (d) printf(", ");
- if (role == MD_DISK_ROLE_SPARE) printf("empty");
- else if(role == MD_DISK_ROLE_FAULTY) printf("failed");
- else printf("%d", role);
+ if (d)
+ printf(", ");
+ if (role == MD_DISK_ROLE_SPARE)
+ printf("empty");
+ else
+ if(role == MD_DISK_ROLE_FAULTY)
+ printf("failed");
+ else
+ printf("%d", role);
}
printf(")\n");
#endif
@@ -527,10 +550,10 @@ static void examine_super1(struct supertype *st, char *homehost)
printf("Active device %d\n", role);
printf(" Array State : ");
- for (d=0; d<__le32_to_cpu(sb->raid_disks) + delta_extra; d++) {
+ for (d = 0; d < __le32_to_cpu(sb->raid_disks) + delta_extra; d++) {
int cnt = 0;
unsigned int i;
- for (i=0; i< __le32_to_cpu(sb->max_dev); i++) {
+ for (i = 0; i < __le32_to_cpu(sb->max_dev); i++) {
unsigned int role = __le16_to_cpu(sb->dev_roles[i]);
if (role == d)
cnt++;
@@ -547,12 +570,13 @@ static void examine_super1(struct supertype *st, char *homehost)
#if 0
/* This is confusing too */
faulty = 0;
- for (i=0; i< __le32_to_cpu(sb->max_dev); i++) {
+ for (i = 0; i< __le32_to_cpu(sb->max_dev); i++) {
int role = __le16_to_cpu(sb->dev_roles[i]);
if (role == MD_DISK_ROLE_FAULTY)
faulty++;
}
- if (faulty) printf(" %d failed", faulty);
+ if (faulty)
+ printf(" %d failed", faulty);
#endif
printf(" ('A' == active, '.' == missing, 'R' == replacing)");
printf("\n");
@@ -564,7 +588,7 @@ static void brief_examine_super1(struct supertype *st, int verbose)
int i;
unsigned long long sb_offset;
char *nm;
- char *c=map_num(pers, __le32_to_cpu(sb->level));
+ char *c = map_num(pers, __le32_to_cpu(sb->level));
nm = strchr(sb->set_name, ':');
if (nm)
@@ -592,8 +616,9 @@ static void brief_examine_super1(struct supertype *st, int verbose)
if (verbose)
printf("num-devices=%d ", __le32_to_cpu(sb->raid_disks));
printf("UUID=");
- for (i=0; i<16; i++) {
- if ((i&3)==0 && i != 0) printf(":");
+ for (i = 0; i < 16; i++) {
+ if ((i&3)==0 && i != 0)
+ printf(":");
printf("%02x", sb->set_uuid[i]);
}
if (sb->set_name[0]) {
@@ -612,9 +637,8 @@ static void export_examine_super1(struct supertype *st)
printf("MD_LEVEL=%s\n", map_num(pers, __le32_to_cpu(sb->level)));
printf("MD_DEVICES=%d\n", __le32_to_cpu(sb->raid_disks));
- for (i=0; i<32; i++)
- if (sb->set_name[i] == '\n' ||
- sb->set_name[i] == '\0') {
+ for (i = 0; i < 32; i++)
+ if (sb->set_name[i] == '\n' || sb->set_name[i] == '\0') {
len = i;
break;
}
@@ -623,10 +647,16 @@ static void export_examine_super1(struct supertype *st)
if (__le32_to_cpu(sb->level) > 0) {
int ddsks = 0, ddsks_denom = 1;
switch(__le32_to_cpu(sb->level)) {
- case 1: ddsks=1;break;
+ case 1:
+ ddsks = 1;
+ break;
case 4:
- case 5: ddsks = __le32_to_cpu(sb->raid_disks)-1; break;
- case 6: ddsks = __le32_to_cpu(sb->raid_disks)-2; break;
+ case 5:
+ ddsks = __le32_to_cpu(sb->raid_disks)-1;
+ break;
+ case 6:
+ ddsks = __le32_to_cpu(sb->raid_disks)-2;
+ break;
case 10:
layout = __le32_to_cpu(sb->layout);
ddsks = __le32_to_cpu(sb->raid_disks);
@@ -635,20 +665,23 @@ static void export_examine_super1(struct supertype *st)
if (ddsks) {
long long asize = __le64_to_cpu(sb->size);
asize = (asize << 9) * ddsks / ddsks_denom;
- printf("MD_ARRAY_SIZE=%s\n",human_size_brief(asize,JEDEC));
+ printf("MD_ARRAY_SIZE=%s\n",
+ human_size_brief(asize, JEDEC));
}
}
printf("MD_UUID=");
- for (i=0; i<16; i++) {
- if ((i&3)==0 && i != 0) printf(":");
+ for (i = 0; i < 16; i++) {
+ if ((i&3) == 0 && i != 0)
+ printf(":");
printf("%02x", sb->set_uuid[i]);
}
printf("\n");
printf("MD_UPDATE_TIME=%llu\n",
__le64_to_cpu(sb->utime) & 0xFFFFFFFFFFULL);
printf("MD_DEV_UUID=");
- for (i=0; i<16; i++) {
- if ((i&3)==0 && i != 0) printf(":");
+ for (i = 0; i < 16; i++) {
+ if ((i&3) == 0 && i != 0)
+ printf(":");
printf("%02x", sb->device_uuid[i]);
}
printf("\n");
@@ -797,15 +830,16 @@ static void detail_super1(struct supertype *st, char *homehost)
int l = homehost ? strlen(homehost) : 0;
printf(" Name : %.32s", sb->set_name);
- if (l > 0 && l < 32 &&
- sb->set_name[l] == ':' &&
+ if (l > 0 && l < 32 && sb->set_name[l] == ':' &&
strncmp(sb->set_name, homehost, l) == 0)
printf(" (local to host %s)", homehost);
- if (bms->nodes > 0 && (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
- printf("\n Cluster Name : %-64s", bms->cluster_name);
+ if (bms->nodes > 0 &&
+ (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
+ printf("\n Cluster Name : %-64s", bms->cluster_name);
printf("\n UUID : ");
- for (i=0; i<16; i++) {
- if ((i&3)==0 && i != 0) printf(":");
+ for (i = 0; i < 16; i++) {
+ if ((i&3) == 0 && i != 0)
+ printf(":");
printf("%02x", sb->set_uuid[i]);
}
printf("\n Events : %llu\n\n",
@@ -822,8 +856,9 @@ static void brief_detail_super1(struct supertype *st)
print_quoted(sb->set_name);
}
printf(" UUID=");
- for (i=0; i<16; i++) {
- if ((i&3)==0 && i != 0) printf(":");
+ for (i = 0; i < 16; i++) {
+ if ((i & 3) == 0 && i != 0)
+ printf(":");
printf("%02x", sb->set_uuid[i]);
}
}
@@ -834,9 +869,8 @@ static void export_detail_super1(struct supertype *st)
int i;
int len = 32;
- for (i=0; i<32; i++)
- if (sb->set_name[i] == '\n' ||
- sb->set_name[i] == '\0') {
+ for (i = 0; i < 32; i++)
+ if (sb->set_name[i] == '\n' || sb->set_name[i] == '\0') {
len = i;
break;
}
@@ -852,13 +886,12 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
__u64 *bbl, *bbp;
int i;
- if (!sb->bblog_size || __le16_to_cpu(sb->bblog_size) > 100
- || !sb->bblog_offset){
+ if (!sb->bblog_size || __le16_to_cpu(sb->bblog_size) > 100 ||
+ !sb->bblog_offset){
printf("No bad-blocks list configured on %s\n", devname);
return 0;
}
- if ((sb->feature_map & __cpu_to_le32(MD_FEATURE_BAD_BLOCKS))
- == 0) {
+ if ((sb->feature_map & __cpu_to_le32(MD_FEATURE_BAD_BLOCKS)) == 0) {
printf("Bad-blocks list is empty in %s\n", devname);
return 0;
}
@@ -905,8 +938,7 @@ static int match_home1(struct supertype *st, char *homehost)
struct mdp_superblock_1 *sb = st->sb;
int l = homehost ? strlen(homehost) : 0;
- return (l > 0 && l < 32 &&
- sb->set_name[l] == ':' &&
+ return (l > 0 && l < 32 && sb->set_name[l] == ':' &&
strncmp(sb->set_name, homehost, l) == 0);
}
@@ -915,7 +947,7 @@ static void uuid_from_super1(struct supertype *st, int uuid[4])
struct mdp_superblock_1 *super = st->sb;
char *cuuid = (char*)uuid;
int i;
- for (i=0; i<16; i++)
+ for (i = 0; i < 16; i++)
cuuid[i] = super->set_uuid[i];
}
@@ -923,7 +955,8 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
{
struct mdp_superblock_1 *sb = st->sb;
struct bitmap_super_s *bsb = (void*)(((char*)sb)+MAX_SB_SIZE);
- struct misc_dev_info *misc = (void*)(((char*)sb)+MAX_SB_SIZE+BM_SUPER_SIZE);
+ struct misc_dev_info *misc =
+ (void*)(((char*)sb)+MAX_SB_SIZE+BM_SUPER_SIZE);
int working = 0;
unsigned int i;
unsigned int role;
@@ -943,8 +976,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
info->array.utime = __le64_to_cpu(sb->utime);
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);
@@ -985,7 +1017,8 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
}
if (super_offset + info->bitmap_offset + info->ppl_offset < end)
- end = super_offset + info->bitmap_offset + info->ppl_offset;
+ end = super_offset + info->bitmap_offset +
+ info->ppl_offset;
if (info->data_offset + data_size < end)
info->space_after = end - data_size - info->data_offset;
@@ -1002,8 +1035,9 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
if (bmend > earliest)
earliest = bmend;
} else if (info->ppl_offset > 0) {
- unsigned long long pplend = info->ppl_offset +
- info->ppl_size;
+ unsigned long long pplend;
+
+ pplend = info->ppl_offset + info->ppl_size;
if (pplend > earliest)
earliest = pplend;
}
@@ -1018,7 +1052,8 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
info->space_before = info->data_offset - earliest;
else
info->space_before = 0;
- info->space_after = misc->device_size - data_size - info->data_offset;
+ info->space_after = misc->device_size - data_size -
+ info->data_offset;
}
if (info->space_before == 0 && info->space_after == 0) {
/* It will look like we don't support data_offset changes,
@@ -1032,7 +1067,8 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
info->disk.raid_disk = -1;
switch(role) {
case MD_DISK_ROLE_SPARE:
- info->disk.state = 0; /* spare: not active, not sync, not faulty */
+ /* spare: not active, not sync, not faulty */
+ info->disk.state = 0;
break;
case MD_DISK_ROLE_FAULTY:
info->disk.state = (1 << MD_DISK_FAULTY); /* faulty */
@@ -1040,7 +1076,8 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
case MD_DISK_ROLE_JOURNAL:
info->disk.state = (1 << MD_DISK_JOURNAL);
info->disk.raid_disk = role;
- info->space_after = (misc->device_size - info->data_offset) % 8; /* journal uses all 4kB blocks*/
+ /* journal uses all 4kB blocks*/
+ info->space_after = (misc->device_size - info->data_offset) % 8;
break;
default:
info->disk.state = 6; /* active and in sync */
@@ -1129,8 +1166,7 @@ static struct mdinfo *container_content1(struct supertype *st, char *subarray)
}
static int update_super1(struct supertype *st, struct mdinfo *info,
- char *update,
- char *devname, int verbose,
+ char *update, char *devname, int verbose,
int uuid_set, char *homehost)
{
/* NOTE: for 'assemble' and 'force' we need to return non-zero
@@ -1145,7 +1181,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready()) {
rv = cluster_get_dlmlock(&lockid);
if (rv) {
- pr_err("Cannot get dlmlock in %s return %d\n", __func__, rv);
+ pr_err("Cannot get dlmlock in %s return %d\n",
+ __func__, rv);
cluster_release_dlmlock(lockid);
return rv;
}
@@ -1178,7 +1215,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
* maybe need to mark it 'clean'.
*/
switch(__le32_to_cpu(sb->level)) {
- case 5: case 4: case 6:
+ case 4:
+ case 5:
+ case 6:
/* need to force clean */
if (sb->resync_offset != MaxSector)
rv = 1;
@@ -1198,17 +1237,23 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
rv = 1;
}
if (info->reshape_active &&
- sb->feature_map & __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE) &&
+ sb->feature_map &
+ __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE) &&
info->delta_disks >= 0 &&
- info->reshape_progress < __le64_to_cpu(sb->reshape_position)) {
- sb->reshape_position = __cpu_to_le64(info->reshape_progress);
+ info->reshape_progress <
+ __le64_to_cpu(sb->reshape_position)) {
+ sb->reshape_position =
+ __cpu_to_le64(info->reshape_progress);
rv = 1;
}
if (info->reshape_active &&
- sb->feature_map & __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE) &&
+ sb->feature_map &
+ __le32_to_cpu(MD_FEATURE_RESHAPE_ACTIVE) &&
info->delta_disks < 0 &&
- info->reshape_progress > __le64_to_cpu(sb->reshape_position)) {
- sb->reshape_position = __cpu_to_le64(info->reshape_progress);
+ info->reshape_progress >
+ __le64_to_cpu(sb->reshape_position)) {
+ sb->reshape_position =
+ __cpu_to_le64(info->reshape_progress);
rv = 1;
}
} else if (strcmp(update, "linear-grow-new") == 0) {
@@ -1216,8 +1261,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
int fd;
unsigned int max = __le32_to_cpu(sb->max_dev);
- for (i=0 ; i < max ; i++)
- if (__le16_to_cpu(sb->dev_roles[i]) >= MD_DISK_ROLE_FAULTY)
+ for (i = 0; i < max; i++)
+ if (__le16_to_cpu(sb->dev_roles[i]) >=
+ MD_DISK_ROLE_FAULTY)
break;
sb->dev_number = __cpu_to_le32(i);
info->disk.number = i;
@@ -1226,8 +1272,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
random_uuid(sb->device_uuid);
- sb->dev_roles[i] =
- __cpu_to_le16(info->disk.raid_disk);
+ sb->dev_roles[i] = __cpu_to_le16(info->disk.raid_disk);
fd = open(devname, O_RDONLY);
if (fd >= 0) {
@@ -1280,14 +1325,16 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
}
if (sb_offset < data_offset) {
- /* 1.1 or 1.2. Put bbl after bitmap leaving at least 32K
+ /*
+ * 1.1 or 1.2. Put bbl after bitmap leaving
+ * at least 32K
*/
long bb_offset;
bb_offset = sb_offset + 8;
if (bm_sectors && bitmap_offset > 0)
bb_offset = bitmap_offset + bm_sectors;
- while (bb_offset < (long)sb_offset + 8 + 32*2
- && bb_offset + 8+8 <= (long)data_offset)
+ while (bb_offset < (long)sb_offset + 8 + 32*2 &&
+ bb_offset + 8+8 <= (long)data_offset)
/* too close to bitmap, and room to grow */
bb_offset += 8;
if (bb_offset + 8 <= (long)data_offset) {
@@ -1381,8 +1428,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
} else
strncpy(sb->set_name, info->name, sizeof(sb->set_name));
} else if (strcmp(update, "devicesize") == 0 &&
- __le64_to_cpu(sb->super_offset) <
- __le64_to_cpu(sb->data_offset)) {
+ __le64_to_cpu(sb->super_offset) <
+ __le64_to_cpu(sb->data_offset)) {
/* set data_size to device size less data_offset */
struct misc_dev_info *misc = (struct misc_dev_info*)
(st->sb + MAX_SB_SIZE + BM_SUPER_SIZE);
@@ -1390,7 +1437,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
misc->device_size - __le64_to_cpu(sb->data_offset));
} else if (strncmp(update, "revert-reshape", 14) == 0) {
rv = -2;
- if (!(sb->feature_map & __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE)))
+ if (!(sb->feature_map &
+ __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE)))
pr_err("No active reshape to revert on %s\n",
devname);
else {
@@ -1431,9 +1479,11 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
*/
if (__le32_to_cpu(sb->level) >= 4 &&
__le32_to_cpu(sb->level) <= 6) {
- reshape_sectors = __le64_to_cpu(sb->reshape_position);
+ reshape_sectors =
+ __le64_to_cpu(sb->reshape_position);
reshape_chunk = __le32_to_cpu(sb->new_chunk);
- reshape_chunk *= __le32_to_cpu(sb->raid_disks) - __le32_to_cpu(sb->delta_disks) -
+ reshape_chunk *= __le32_to_cpu(sb->raid_disks) -
+ __le32_to_cpu(sb->delta_disks) -
(__le32_to_cpu(sb->level)==6 ? 2 : 1);
if (reshape_sectors % reshape_chunk) {
pr_err("Reshape position is not suitably aligned.\n");
@@ -1441,8 +1491,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
return -2;
}
}
- sb->raid_disks = __cpu_to_le32(__le32_to_cpu(sb->raid_disks) -
- __le32_to_cpu(sb->delta_disks));
+ sb->raid_disks =
+ __cpu_to_le32(__le32_to_cpu(sb->raid_disks) -
+ __le32_to_cpu(sb->delta_disks));
if (sb->delta_disks == 0)
sb->feature_map ^= __cpu_to_le32(MD_FEATURE_RESHAPE_BACKWARDS);
else
@@ -1456,19 +1507,21 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
sb->new_chunk = sb->chunksize;
sb->chunksize = temp;
- if (sb->feature_map & __cpu_to_le32(MD_FEATURE_NEW_OFFSET)) {
- long offset_delta = (int32_t)__le32_to_cpu(sb->new_offset);
+ if (sb->feature_map &
+ __cpu_to_le32(MD_FEATURE_NEW_OFFSET)) {
+ long offset_delta =
+ (int32_t)__le32_to_cpu(sb->new_offset);
sb->data_offset = __cpu_to_le64(__le64_to_cpu(sb->data_offset) + offset_delta);
sb->new_offset = __cpu_to_le32(-offset_delta);
sb->data_size = __cpu_to_le64(__le64_to_cpu(sb->data_size) - offset_delta);
}
done:;
}
- } else if (strcmp(update, "_reshape_progress")==0)
+ } else if (strcmp(update, "_reshape_progress") == 0)
sb->reshape_position = __cpu_to_le64(info->reshape_progress);
- else if (strcmp(update, "writemostly")==0)
+ else if (strcmp(update, "writemostly") == 0)
sb->devflags |= WriteMostly1;
- else if (strcmp(update, "readwrite")==0)
+ else if (strcmp(update, "readwrite") == 0)
sb->devflags &= ~WriteMostly1;
else if (strcmp(update, "failfast") == 0)
sb->devflags |= FailFast1;
@@ -1553,11 +1606,14 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info,
sb->resync_offset = MaxSector;
else
sb->resync_offset = 0;
- sbsize = sizeof(struct mdp_superblock_1) + 2 * (info->raid_disks + spares);
+ sbsize = sizeof(struct mdp_superblock_1) +
+ 2 * (info->raid_disks + spares);
sbsize = ROUND_UP(sbsize, 512);
- sb->max_dev = __cpu_to_le32((sbsize - sizeof(struct mdp_superblock_1)) / 2);
+ sb->max_dev =
+ __cpu_to_le32((sbsize - sizeof(struct mdp_superblock_1)) / 2);
- memset(sb->dev_roles, 0xff, MAX_SB_SIZE - sizeof(struct mdp_superblock_1));
+ memset(sb->dev_roles, 0xff,
+ MAX_SB_SIZE - sizeof(struct mdp_superblock_1));
if (s->consistency_policy == CONSISTENCY_POLICY_PPL)
sb->feature_map |= __cpu_to_le32(MD_FEATURE_PPL);
@@ -1587,7 +1643,8 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready()) {
rv = cluster_get_dlmlock(&lockid);
if (rv) {
- pr_err("Cannot get dlmlock in %s return %d\n", __func__, rv);
+ pr_err("Cannot get dlmlock in %s return %d\n",
+ __func__, rv);
cluster_release_dlmlock(lockid);
return rv;
}
@@ -1599,7 +1656,8 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
*rp = __cpu_to_le16(dk->raid_disk);
else if (dk_state & (1<<MD_DISK_JOURNAL))
*rp = MD_DISK_ROLE_JOURNAL;
- else if ((dk_state & ~(1<<MD_DISK_ACTIVE)) == 0) /* active or idle -> spare */
+ else if ((dk_state & ~(1<<MD_DISK_ACTIVE)) == 0)
+ /* active or idle -> spare */
*rp = MD_DISK_ROLE_SPARE;
else
*rp = MD_DISK_ROLE_FAULTY;
@@ -1644,7 +1702,8 @@ static int store_super1(struct supertype *st, int fd)
if (bms->version == BITMAP_MAJOR_CLUSTERED && dlm_funs_ready()) {
rv = cluster_get_dlmlock(&lockid);
if (rv) {
- pr_err("Cannot get dlmlock in %s return %d\n", __func__, rv);
+ pr_err("Cannot get dlmlock in %s return %d\n",
+ __func__, rv);
cluster_release_dlmlock(lockid);
return rv;
}
@@ -1911,7 +1970,8 @@ static int write_init_super1(struct supertype *st)
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));
+ bm_space =
+ choose_ppl_space(__le32_to_cpu(sb->chunksize));
if (bm_space > UINT16_MAX)
bm_space = UINT16_MAX;
if (st->minor_version == 0) {
@@ -1981,7 +2041,10 @@ static int write_init_super1(struct supertype *st)
rv = -EINVAL;
goto out;
}
- /* Disable badblock log on clusters, or when explicitly requested */
+ /*
+ * Disable badblock log on clusters, or when
+ * explicitly requested
+ */
if (st->nodes > 0 || conf_get_create_info()->bblist == 0) {
sb->bblog_size = 0;
sb->bblog_offset = 0;
@@ -1997,7 +2060,8 @@ static int write_init_super1(struct supertype *st)
}
if (rv == 0 &&
- (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET)) {
+ (__le32_to_cpu(sb->feature_map) &
+ 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)) {
@@ -2014,8 +2078,7 @@ static int write_init_super1(struct supertype *st)
}
error_out:
if (rv)
- pr_err("Failed to write metadata to %s\n",
- di->devname);
+ pr_err("Failed to write metadata to %s\n", di->devname);
out:
return rv;
}
@@ -2080,7 +2143,8 @@ static int load_super1(struct supertype *st, int fd, char *devname)
/* guess... choose latest ctime */
memset(&tst, 0, sizeof(tst));
tst.ss = &super1;
- for (tst.minor_version = 0; tst.minor_version <= 2 ; tst.minor_version++) {
+ for (tst.minor_version = 0; tst.minor_version <= 2;
+ tst.minor_version++) {
switch(load_super1(&tst, fd, devname)) {
case 0: super = tst.sb;
if (bestvers == -1 ||
@@ -2167,7 +2231,8 @@ static int load_super1(struct supertype *st, int fd, char *devname)
if (__le32_to_cpu(super->magic) != MD_SB_MAGIC) {
if (devname)
pr_err("No super block found on %s (Expected magic %08x, got %08x)\n",
- devname, MD_SB_MAGIC, __le32_to_cpu(super->magic));
+ devname, MD_SB_MAGIC,
+ __le32_to_cpu(super->magic));
free(super);
return 2;
}
@@ -2190,7 +2255,8 @@ static int load_super1(struct supertype *st, int fd, char *devname)
bsb = (struct bitmap_super_s *)(((char*)super)+MAX_SB_SIZE);
- misc = (struct misc_dev_info*) (((char*)super)+MAX_SB_SIZE+BM_SUPER_SIZE);
+ misc = (struct misc_dev_info*)
+ (((char*)super)+MAX_SB_SIZE+BM_SUPER_SIZE);
misc->device_size = dsize;
if (st->data_offset == INVALID_SECTORS)
st->data_offset = __le64_to_cpu(super->data_offset);
@@ -2230,13 +2296,11 @@ static struct supertype *match_metadata_desc1(char *arg)
/* leading zeros can be safely ignored. --detail generates them. */
while (*arg == '0')
arg++;
- if (strcmp(arg, "1.0") == 0 ||
- strcmp(arg, "1.00") == 0) {
+ if (strcmp(arg, "1.0") == 0 || strcmp(arg, "1.00") == 0) {
st->minor_version = 0;
return st;
}
- if (strcmp(arg, "1.1") == 0 ||
- strcmp(arg, "1.01") == 0
+ if (strcmp(arg, "1.1") == 0 || strcmp(arg, "1.01") == 0
) {
st->minor_version = 1;
return st;
@@ -2249,8 +2313,7 @@ static struct supertype *match_metadata_desc1(char *arg)
st->minor_version = 2;
return st;
}
- if (strcmp(arg, "1") == 0 ||
- strcmp(arg, "default") == 0) {
+ if (strcmp(arg, "1") == 0 || strcmp(arg, "default") == 0) {
st->minor_version = -1;
return st;
}
@@ -2348,20 +2411,26 @@ add_internal_bitmap1(struct supertype *st,
int uuid[4];
if (__le64_to_cpu(sb->data_size) == 0)
- /* Must be creating the array, else data_size would be non-zero */
+ /*
+ * Must be creating the array, else data_size
+ * would be non-zero
+ */
creating = 1;
switch(st->minor_version) {
case 0:
- /* either 3K after the superblock (when hot-add),
+ /*
+ * either 3K after the superblock (when hot-add),
* or some amount of space before.
*/
if (creating) {
- /* We are creating array, so we *know* how much room has
+ /*
+ * We are creating array, so we *know* how much room has
* been left.
*/
offset = 0;
bbl_size = 8;
- room = choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size;
+ room =
+ choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size;
} else {
room = __le64_to_cpu(sb->super_offset)
- __le64_to_cpu(sb->data_offset)
@@ -2373,8 +2442,8 @@ add_internal_bitmap1(struct supertype *st,
if (bbl_size < -bbl_offset)
bbl_size = -bbl_offset;
- if (!may_change || (room < 3*2 &&
- __le32_to_cpu(sb->max_dev) <= 384)) {
+ if (!may_change ||
+ (room < 3*2 && __le32_to_cpu(sb->max_dev) <= 384)) {
room = 3*2;
offset = 1*2;
bbl_size = 0;
@@ -2388,13 +2457,15 @@ add_internal_bitmap1(struct supertype *st,
if (creating) {
offset = 4*2;
bbl_size = 8;
- room = choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size;
+ room =
+ choose_bm_space(__le64_to_cpu(sb->size)) + bbl_size;
} else {
room = __le64_to_cpu(sb->data_offset)
- __le64_to_cpu(sb->super_offset);
bbl_size = __le16_to_cpu(sb->bblog_size);
if (bbl_size)
- room = __le32_to_cpu(sb->bblog_offset) + bbl_size;
+ room =
+ __le32_to_cpu(sb->bblog_offset) + bbl_size;
else
bbl_size = 8;
@@ -2453,8 +2524,8 @@ add_internal_bitmap1(struct supertype *st,
sb->bitmap_offset = (int32_t)__cpu_to_le32(offset);
- sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map)
- | MD_FEATURE_BITMAP_OFFSET);
+ sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map) |
+ MD_FEATURE_BITMAP_OFFSET);
memset(bms, 0, sizeof(*bms));
bms->magic = __cpu_to_le32(BITMAP_MAGIC);
bms->version = __cpu_to_le32(major);
@@ -2466,8 +2537,8 @@ add_internal_bitmap1(struct supertype *st,
bms->write_behind = __cpu_to_le32(write_behind);
bms->nodes = __cpu_to_le32(st->nodes);
if (st->nodes)
- sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map)
- | MD_FEATURE_BITMAP_VERSIONED);
+ sb->feature_map = __cpu_to_le32(__le32_to_cpu(sb->feature_map) |
+ MD_FEATURE_BITMAP_VERSIONED);
if (st->cluster_name) {
len = sizeof(bms->cluster_name);
strncpy((char *)bms->cluster_name, st->cluster_name, len);
@@ -2528,31 +2599,43 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
break;
case NodeNumUpdate:
/* cluster md only supports superblock 1.2 now */
- if (st->minor_version != 2 && bms->version == BITMAP_MAJOR_CLUSTERED) {
+ if (st->minor_version != 2 &&
+ bms->version == BITMAP_MAJOR_CLUSTERED) {
pr_err("Warning: cluster md only works with superblock 1.2\n");
return -EINVAL;
}
if (bms->version == BITMAP_MAJOR_CLUSTERED) {
if (__cpu_to_le32(st->nodes) < bms->nodes) {
- /* Since the nodes num is not increased, no need to check the space
- * is enough or not, just update bms->nodes */
+ /*
+ * Since the nodes num is not increased, no
+ * need to check the space enough or not,
+ * just update bms->nodes
+ */
bms->nodes = __cpu_to_le32(st->nodes);
break;
}
} else {
- /* no need to change bms->nodes for other bitmap types */
+ /*
+ * no need to change bms->nodes for other
+ * bitmap types
+ */
if (st->nodes)
pr_err("Warning: --nodes option is only suitable for clustered bitmap\n");
break;
}
- /* Each node has an independent bitmap, it is necessary to calculate the
- * space is enough or not, first get how many bytes for the total bitmap */
+ /*
+ * Each node has an independent bitmap, it is necessary to
+ * calculate the space is enough or not, first get how many
+ * bytes for the total bitmap
+ */
bm_space_per_node = calc_bitmap_size(bms, 4096);
- total_bm_space = 512 * (__le64_to_cpu(sb->data_offset) - __le64_to_cpu(sb->super_offset));
- total_bm_space = total_bm_space - 4096; /* leave another 4k for superblock */
+ total_bm_space = 512 * (__le64_to_cpu(sb->data_offset) -
+ __le64_to_cpu(sb->super_offset));
+ /* leave another 4k for superblock */
+ total_bm_space = total_bm_space - 4096;
if (bm_space_per_node * st->nodes > total_bm_space) {
pr_err("Warning: The max num of nodes can't exceed %llu\n",
--
2.13.6

View File

@ -0,0 +1,65 @@
From 5e13ef714df4734c455b5e4389352c8ab7902038 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_REMOVED)|(1<<MD_DISK_FAULTY)|(1<<MD_DISK_JOURNAL)))
== 0) {
printf(" spare");
- if (is_26) {
- if (disk.raid_disk < array.raid_disks && disk.raid_disk >= 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

View File

@ -0,0 +1,38 @@
From 0ef1043ce8dd3f36c7227aa4a260819c4c17c78d Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,43 @@
From 776b199e41d10e344efc47008366ca46715c5acc Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,77 @@
From 8d0cd09d73a9a9d57ee73b7a79114e881dad1507 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,84 @@
From f22d6cde7c7e4be38230ac4c51c3af850ed1614e Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,121 @@
From 5e4ca8bb82e98400c9258cb3d7e4d030576f21df Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,104 @@
From 3ab8f4bf33d906cb1084f7b4036556bfb4bb73ec Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,111 @@
From 5e8e35fb7e17495032e144f319517dcae38d1b56 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,75 @@
From 44356754ec8d7c38720db6c9916fef8f24921831 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_SYNC)))
- continue;
- if (disk.raid_disk < 0 || disk.raid_disk >= 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

View File

@ -0,0 +1,61 @@
From b63804583e25fbc00b96c7f37f97d568b5b1ba9c Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
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 <colyli@suse.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
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

View File

@ -0,0 +1,32 @@
From 0dfff0f24355ad4b5c1776f7f19a404ffae25415 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,30 @@
From 17d80e6eb64230593ee8d599b94005d303eb58ae Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,36 @@
From 4a4379b054a72b3c4abd93dd6e1283d6aa992ee2 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,127 @@
From b75805662e7208799207a8e5f8a61f69a44888f0 Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
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 <Jes.Sorensen@gmail.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,59 @@
From a4dcdb23ea639d14e92d1c86336de7ad505b2f7d Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,525 @@
From 5737086ed7a39e4d940ed1459d1afad359c3182c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_REMOVED);
+ disks[d].state = (1 << MD_DISK_REMOVED);
disks[d].major = disks[d].minor = 0;
disks[d].number = -1;
- disks[d].raid_disk = d/2;
+ disks[d].raid_disk = d / 2;
}
- next = array.raid_disks*2;
+ 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;
+ 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<<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)
+ if (disk.raid_disk >= 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<<MD_DISK_SYNC)) ||
(disks[d*2+1].state & (1<<MD_DISK_SYNC))) {
@@ -354,8 +357,8 @@ int Detail(char *dev, struct context *c)
if (c->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<<MD_SB_CLEAN))?"clean":"active", st,
- (!e || (e->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<<MD_DISK_JOURNAL))
+ else if (disk.raid_disk < 0 ||
+ disk.state & (1 << MD_DISK_JOURNAL))
printf(" %5d %5d %5d - ",
disk.number, disk.major, disk.minor);
else if (disk.number < 0)
@@ -647,34 +673,44 @@ This is pretty boring
disk.major, disk.minor, disk.raid_disk);
else
printf(" %5d %5d %5d %5d ",
- disk.number, disk.major, disk.minor, disk.raid_disk);
+ disk.number, disk.major, disk.minor,
+ disk.raid_disk);
}
if (!c->brief && array.raid_disks) {
-
- if (disk.state & (1<<MD_DISK_FAULTY)) {
+ if (disk.state & (1 << MD_DISK_FAULTY)) {
printf(" faulty");
if (disk.raid_disk < array.raid_disks &&
disk.raid_disk >= 0)
failed++;
}
- if (disk.state & (1<<MD_DISK_ACTIVE)) printf(" active");
- if (disk.state & (1<<MD_DISK_SYNC)) {
+ if (disk.state & (1 << MD_DISK_ACTIVE))
+ printf(" active");
+ if (disk.state & (1 << MD_DISK_SYNC)) {
printf(" sync");
- if (array.level == 10 && (array.layout & ~0x1FFFF) == 0) {
+ if (array.level == 10 &&
+ (array.layout & ~0x1FFFF) == 0) {
int nc = array.layout & 0xff;
int fc = (array.layout >> 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<<MD_DISK_REMOVED)) printf(" removed");
- if (disk.state & (1<<MD_DISK_WRITEMOSTLY)) printf(" writemostly");
- if (disk.state & (1<<MD_DISK_FAILFAST)) printf(" failfast");
- if (disk.state & (1<<MD_DISK_JOURNAL)) printf(" journal");
+ if (disk.state & (1 << MD_DISK_REMOVED))
+ printf(" removed");
+ if (disk.state & (1 << MD_DISK_WRITEMOSTLY))
+ printf(" writemostly");
+ if (disk.state & (1 << MD_DISK_FAILFAST))
+ printf(" failfast");
+ if (disk.state & (1 << MD_DISK_JOURNAL))
+ printf(" journal");
if ((disk.state &
((1<<MD_DISK_ACTIVE)|(1<<MD_DISK_SYNC)
|(1<<MD_DISK_REMOVED)|(1<<MD_DISK_FAULTY)|(1<<MD_DISK_JOURNAL)))
@@ -685,19 +721,21 @@ This is pretty boring
printf(" rebuilding");
}
}
- if (disk.state == 0) spares++;
- dv=map_dev_preferred(disk.major, disk.minor, 0, c->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

View File

@ -0,0 +1,41 @@
From 0885b942b3575c7f2a8290087751d83902587371 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,45 @@
From ff4ad24b1c261ab4d286cbe54157d7c588191692 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,156 @@
From f8c432bfc9929dbbcb659b2d11552dc9fc76ad24 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_SYNC)) != 0
- && ! policy_action_allows(policy, st->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<<MD_DISK_REMOVED))
remove_disk(mdfd, st, sra, d);
- if ((sra == NULL || active_disks >= 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

View File

@ -0,0 +1,315 @@
From cd6cbb08c458cee07acb1d854e04532b29ec87bf Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
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 <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,42 @@
From 6921010d95dbc32c812aa8ffdbfa28e78b54b342 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,45 @@
From 80223cb4db3358a24c41a76414a3804c26d5ea3a Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,51 @@
From 2a24dc1b0988a7d924de6339754d4160762a61f7 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
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 <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,45 @@
From 9e4524df1c6c85c362278a08fd4425888d27581f Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,26 @@
From 99148c19bd9149bb938309ffb6b4dcde20b67934 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,95 @@
From 9db2ab4e9b1ad79b9364b6e03bdd675716a688a5 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,399 @@
From 2b7bddf06c30da08f8d6270b40f0d382c1c5fc6e Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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 <neilb@suse.de>
-
-### 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 <neilb@suse.de>
-
-### 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 <dan.j.williams@intel.com>
-
-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 <kay.sievers@vrfy.org>
-Cc: Neil Brown <neilb@suse.de>
-Signed-off-by: Dan Williams <dan.j.williams@intel.com>
----
-
- 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

View File

@ -0,0 +1,113 @@
From 935795398d52a589598fa13e6cb6272619c5d134 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,443 @@
From 0a6bff09d41650f27136d56a0604c9af46b6f583 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,339 @@
From 9e04ac1c43e63eccb68eb196174069e5c23d0270 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_SYNC) | (1<<MD_DISK_ACTIVE);
if (dv->writemostly == FlagSet)
disk.state |= 1<<MD_DISK_WRITEMOSTLY;
- disk.major = major(stb.st_rdev);
- disk.minor = minor(stb.st_rdev);
+ disk.major = major(rdev);
+ disk.minor = minor(rdev);
if (ioctl(mdfd, ADD_NEW_DISK, &disk)) {
pr_err("ADD_NEW_DISK failed for %s: %s\n",
dv->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

View File

@ -0,0 +1,50 @@
From dd180cb136d6b2193a58ea0de23b8a7942ca6f36 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
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 <prajnoha@redhat.com>
Fixes: cd6cbb08c458 ("Create: tell udev md device is not ready when first created.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,31 @@
From c2d1a6ec6b94385e64e721b733bd44d1d704b530 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,51 @@
From 64ec81da7a70adcdc0dbccaacc69aaf90edb4011 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_SYNC);
- if (strstr(buf, "faulty"))
+ sra->array.active_disks++;
+ }
+ if (strstr(buf, "faulty")) {
dev->disk.state |= (1<<MD_DISK_FAULTY);
+ sra->array.failed_disks++;
+ }
if (dev->disk.state == 0)
sra->array.spare_disks++;
}
--
2.13.6

View File

@ -0,0 +1,70 @@
From 74d293a2535ef8726a9d43577dad4a908f471a0e Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,43 @@
From 00e56fd9537e1f69583d8b0f60faf02026f24d1b Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,36 @@
From 4224685fe9baf1df4c42bcb950c9a593efa0585f Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
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 <trevor@tecnopolis.ca>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,86 @@
From b9a0309c7fc3e6c1607d51ab3c3f8486478a65ef Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,156 @@
From f27904a53b586e5507b442d7f321177e3dfb5a1a Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<MAX_DISKS && remaining_disks > 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<<MD_DISK_SYNC))
+ if ((st->devstate[i]&change) & (1 << MD_DISK_SYNC))
alert("Fail", dev, dv, ainfo);
- else if ((newstate & (1<<MD_DISK_FAULTY)) &&
+ else if ((newstate & (1 << MD_DISK_FAULTY)) &&
(disc.major || disc.minor) &&
- st->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<<MD_DISK_SYNC))
+ else if ((newstate&change) & (1 << MD_DISK_SYNC))
alert("SpareActive", dev, dv, ainfo);
}
st->devstate[i] = newstate;
--
2.13.6

View File

@ -0,0 +1,41 @@
From 17645275ca30a8ca8024f03672aae45d455bbc4b Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -2,6 +2,9 @@ From fbfdcb06dc5b1dcb227b0394f174faa2df734700 Mon Sep 17 00:00:00 2001
From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
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 @@ updates function naming and parameters.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Incremental.c | 18 +++++++++++-------
Monitor.c | 30 ++++++++++++++++--------------
@ -22,11 +27,11 @@ Signed-off-by: Jes Sorensen <jsorensen@fb.com>
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 @@ Index: mdadm/Incremental.c
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 @@ Index: mdadm/Incremental.c
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 @@ Index: mdadm/Incremental.c
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
{
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
{
/* 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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/Monitor.c
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 @@ Index: mdadm/mdadm.h
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 @@ Index: mdadm/mdadm.h
/* 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 @@ Index: mdadm/mdadm.h
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 @@ Index: mdadm/super-intel.c
}
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 @@ Index: mdadm/super-intel.c
}
/******************************************************************************
@@ -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 @@ Index: mdadm/super-intel.c
.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 @@ Index: mdadm/util.c
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 @@ Index: mdadm/util.c
found = 1;
/* check if domain matches */
if (found && domlist) {
--
2.13.6

View File

@ -2,6 +2,9 @@ From 4b57ecf6cea134edff75a2f3a87ee48d52715c70 Mon Sep 17 00:00:00 2001
From: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
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 @@ containers.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Incremental.c | 4 ++--
Monitor.c | 8 ++++++++

View File

@ -0,0 +1,107 @@
From 1830e74b4cbde28279f341bc80b68e9d82df32c6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,103 @@
From 13e5d8455c22d4db420ead9fde3ee0c1536b73a3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<MAX_DISKS; i++) {
mdu_disk_info_t disc = {0,0,0,0,0};
int newstate=0;
@@ -661,7 +644,15 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
retval = 1;
out:
+ if (fd > 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

View File

@ -0,0 +1,42 @@
From 826522f0dc86d31cc7207b01957b5c4243f49dc8 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,83 @@
From aed5f5c34c2b248876b874898d0b3bf65b6cca53 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,48 @@
From 48bc2ade86db576036375184774a3ebadf6a22e3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,50 @@
From b8e5713c74901862b96bf599ab6fd227addc1498 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,40 @@
From 12a9d21f4e9fd4d3a14129407f1e8da6d6444cd6 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,76 @@
From b98943a4f889b466a3d07264068042b18c620d33 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,58 @@
From 8b0ebd645202b627982eb3ed9fc72583c4f245d3 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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<<MD_DISK_SYNC);
- sra->array.active_disks++;
- }
if (strstr(buf, "faulty")) {
dev->disk.state |= (1<<MD_DISK_FAULTY);
sra->array.failed_disks++;
+ } else {
+ sra->array.working_disks++;
+ if (strstr(buf, "in_sync")) {
+ dev->disk.state |= (1<<MD_DISK_SYNC);
+ sra->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

View File

@ -0,0 +1,42 @@
From e5eb6857cde0a6a44684dcc7ea0fb196546cf56c Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,55 @@
From e644902ddbc66d58a3fd4353c9539276ee1fabd7 Mon Sep 17 00:00:00 2001
From: Zhilong Liu <zlliu@suse.com>
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 <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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 <ctype.h>
-#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

View File

@ -0,0 +1,50 @@
From 9f3dd4549b2b904d343b79a8a7ba40c547e71d5d Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

View File

@ -0,0 +1,33 @@
From 72362f18aee5adedb405fe61c324604184d74555 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
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 <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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

Some files were not shown because too many files have changed in this diff Show More