import mdadm-4.2-rc1_1.el8

c8 imports/c8/mdadm-4.2-rc1_1.el8
CentOS Sources 1 year ago committed by Stepan Oksanichenko
parent 88ea55ea34
commit 488abefe10
  1. 2
      .gitignore
  2. 2
      .mdadm.metadata
  3. 39
      SOURCES/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch
  4. 48
      SOURCES/0001-Fix-some-building-errors.patch
  5. 77
      SOURCES/0002-Document-PART-POLICY-lines.patch
  6. 36
      SOURCES/0002-Prevent-user-from-using-stop-with-ambiguous-args.patch
  7. 334
      SOURCES/0003-policy-support-devices-with-multiple-paths.patch
  8. 137
      SOURCES/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch
  9. 83
      SOURCES/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch
  10. 83
      SOURCES/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch
  11. 43
      SOURCES/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch
  12. 34
      SOURCES/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch
  13. 30
      SOURCES/0009-Grow-report-correct-new-chunk-size.patch
  14. 31
      SOURCES/0010-policy.c-prevent-NULL-pointer-referencing.patch
  15. 36
      SOURCES/0011-policy.c-Fix-for-compiler-error.patch
  16. 95
      SOURCES/0012-imsm-finish-recovery-when-drive-with-rebuild-fails.patch
  17. 322
      SOURCES/0013-imsm-fix-reshape-for-2TB-drives.patch
  18. 101
      SOURCES/0014-Fix-spelling-typos.patch
  19. 46
      SOURCES/0015-Detail.c-do-not-skip-first-character-when-calling-xs.patch
  20. 70
      SOURCES/0016-Fix-reshape-for-decreasing-data-offset.patch
  21. 100
      SOURCES/0017-mdadm-tests-add-one-test-case-for-failfast-of-raid1.patch
  22. 50
      SOURCES/0018-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch
  23. 58
      SOURCES/0019-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch
  24. 52
      SOURCES/0020-Assemble-Fix-starting-array-with-initial-reshape-che.patch
  25. 59
      SOURCES/0021-add-missing-units-to-examine.patch
  26. 117
      SOURCES/0022-imsm-fix-spare-activation-for-old-matrix-arrays.patch
  27. 94
      SOURCES/0023-Create-Block-rounding-size-to-max.patch
  28. 31
      SOURCES/0024-udev-Add-udev-rules-to-create-by-partuuid-for-md-dev.patch
  29. 109
      SOURCES/0025-mdmon-fix-wrong-array-state-when-disk-fails-during-m.patch
  30. 212
      SOURCES/0026-Enable-probe_roms-to-scan-more-than-6-roms.patch
  31. 39
      SOURCES/0027-super-intel-Fix-issue-with-abs-being-irrelevant.patch
  32. 57
      SOURCES/0028-mdadm.h-Introduced-unaligned-get-put-_unaligned-16-3.patch
  33. 38
      SOURCES/0029-super-intel-Use-put_unaligned-in-split_ull.patch
  34. 345
      SOURCES/0030-mdadm-load-default-sysfs-attributes-after-assemblati.patch
  35. 34
      SOURCES/0031-mdadm.h-include-sysmacros.h-unconditionally.patch
  36. 161
      SOURCES/0032-mdadm-add-no-devices-to-avoid-component-devices-deta.patch
  37. 42
      SOURCES/0033-udev-add-no-devices-option-for-calling-mdadm-detail.patch
  38. 44
      SOURCES/0034-imsm-close-removed-drive-fd.patch
  39. 46
      SOURCES/0035-mdadm-check-value-returned-by-snprintf-against-error.patch
  40. 163
      SOURCES/0036-mdadm-Introduce-new-array-state-broken-for-raid0-lin.patch
  41. 40
      SOURCES/0037-mdadm-force-a-uuid-swap-on-big-endian.patch
  42. 99
      SOURCES/0038-mdadm-md.4-add-the-descriptions-for-bitmap-sysfs-nod.patch
  43. 35
      SOURCES/0039-Init-devlist-as-an-array.patch
  44. 31
      SOURCES/0040-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch
  45. 47
      SOURCES/0041-udev-allow-for-udev-attribute-reading-bug.patch
  46. 40
      SOURCES/0042-imsm-save-current_vol-number.patch
  47. 50
      SOURCES/0043-imsm-allow-to-specify-second-volume-size.patch
  48. 45
      SOURCES/0044-mdcheck-when-mdcheck_start-is-enabled-enable-mdcheck.patch
  49. 51
      SOURCES/0045-mdcheck-use-to-pass-variable-to-mdcheck.patch
  50. 29
      SOURCES/0046-SUSE-mdadm_env.sh-handle-MDADM_CHECK_DURATION.patch
  51. 122
      SOURCES/0047-super-intel-don-t-mark-structs-packed-unnecessarily.patch
  52. 45
      SOURCES/0048-mdcheck-service-can-t-start-succesfully-because-of-s.patch
  53. 41
      SOURCES/0049-Remove-last-traces-of-HOT_ADD_DISK.patch
  54. 51
      SOURCES/0050-Fix-up-a-few-formatting-issues.patch
  55. 26
      SOURCES/0051-Remove-unused-code.patch
  56. 176
      SOURCES/0052-imsm-return-correct-uuid-for-volume-in-detail.patch
  57. 208
      SOURCES/0053-imsm-Change-the-way-of-printing-nvme-drives-in-detai.patch
  58. 342
      SOURCES/0054-Create-add-support-for-RAID0-layouts.patch
  59. 150
      SOURCES/0055-Assemble-add-support-for-RAID0-layouts.patch
  60. 36
      SOURCES/0056-Respect-CROSS_COMPILE-when-CC-is-the-default.patch
  61. 39
      SOURCES/0057-Change-warning-message.patch
  62. 52
      SOURCES/0058-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch
  63. 43
      SOURCES/0059-imsm-Update-grow-manual.patch
  64. 192
      SOURCES/0060-Add-support-for-Tebibytes.patch
  65. 65
      SOURCES/0061-imsm-fill-working_disks-according-to-metadata.patch
  66. 55
      SOURCES/0062-mdadm.8-add-note-information-for-raid0-growing-opera.patch
  67. 59
      SOURCES/0063-Remove-the-legacy-whitespace.patch
  68. 91
      SOURCES/0064-imsm-pass-subarray-id-to-kill_subarray-function.patch
  69. 91
      SOURCES/0065-imsm-Remove-dump-restore-implementation.patch
  70. 32
      SOURCES/0066-imsm-Correct-minimal-device-size.patch
  71. 30
      SOURCES/0067-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch
  72. 67
      SOURCES/0068-imsm-support-the-Array-Creation-Time-field-in-metada.patch
  73. 39
      SOURCES/0069-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch
  74. 35
      SOURCES/0070-udev-Ignore-change-event-for-imsm.patch
  75. 109
      SOURCES/0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch
  76. 85
      SOURCES/0072-Detail-adding-sync-status-for-cluster-device.patch
  77. 164
      SOURCES/0073-Manage-imsm-Write-metadata-before-add.patch
  78. 57
      SOURCES/0074-Assemble-print-error-message-if-mdadm-fails-assembli.patch
  79. 29
      SOURCES/0075-clean-up-meaning-of-small-typo.patch
  80. 95
      SOURCES/0076-Assemble.c-respect-force-flag.patch
  81. 45
      SOURCES/0077-mdcheck-Log-when-done.patch
  82. 49
      SOURCES/0078-Makefile-add-EXTRAVERSION-support.patch
  83. 284
      SOURCES/0079-uuid.c-split-uuid-stuffs-from-util.c.patch
  84. 34
      SOURCES/0080-Include-count-for-0-character-when-using-strncpy-to-.patch
  85. 53
      SOURCES/0081-restripe-fix-ignoring-return-value-of-read-and-lseek.patch
  86. 33
      SOURCES/0082-Block-overwriting-existing-links-while-manual-assemb.patch
  87. 76
      SOURCES/0083-Detect-too-small-device-error-rather-than-underflow-.patch
  88. 123
      SOURCES/0084-Use-more-secure-HTTPS-URLs.patch
  89. 28
      SOURCES/0085-Update-link-to-Intel-page-for-IMSM.patch
  90. 64
      SOURCES/0086-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch
  91. 36
      SOURCES/0087-Specify-nodes-number-when-updating-cluster-nodes.patch
  92. 32
      SOURCES/0088-mdadm-md.4-update-path-to-in-kernel-tree-documentati.patch
  93. 34
      SOURCES/0089-manual-update-examine-badblocks.patch
  94. 68
      SOURCES/0090-Detail-show-correct-raid-level-when-the-array-is-ina.patch
  95. 29
      SOURCES/0091-Don-t-create-bitmap-for-raid5-with-journal-disk.patch
  96. 70
      SOURCES/0092-Monitor-refresh-mdstat-fd-after-select.patch
  97. 78
      SOURCES/0093-Monitor-stop-notifing-about-containers.patch
  98. 103
      SOURCES/0094-mdmonitor-set-small-delay-once.patch
  99. 103
      SOURCES/0095-Check-if-other-Monitor-instance-running-before-fork.patch
  100. 136
      SOURCES/0096-Super1-allow-RAID0-layout-setting-to-be-removed.patch
  101. Some files were not shown because too many files have changed in this diff Show More

2
.gitignore vendored

@ -1 +1 @@
SOURCES/mdadm-4.1.tar.xz
SOURCES/mdadm-4.2-rc1.tar.xz

@ -1 +1 @@
4bbbd02674ac67dc9773f41aace7677aa5374c1c SOURCES/mdadm-4.1.tar.xz
cceb5f208a2d77a220a68f23d6cab5a0e8704685 SOURCES/mdadm-4.2-rc1.tar.xz

@ -1,39 +0,0 @@
From 0833f9c3dbaaee202b92ea956f9e2decc7b9593a Mon Sep 17 00:00:00 2001
From: Gioh Kim <gi-oh.kim@profitbricks.com>
Date: Tue, 6 Nov 2018 15:27:42 +0100
Subject: [RHEL7.7 PATCH 01/24] Assemble: keep MD_DISK_FAILFAST and
MD_DISK_WRITEMOSTLY flag
Before updating superblock of slave disks, desired_state value
is set for the target state of the slave disks. But it forgets
to check MD_DISK_FAILFAST and MD_DISK_WRITEMOSTLY flags. Then
start_arrays() calls ADD_NEW_DISK ioctl-call and pass the state
without MD_DISK_FAILFAST and MD_DISK_WRITEMOSTLY.
Currenlty it does not generate any problem because kernel does not
care MD_DISK_FAILFAST or MD_DISK_WRITEMOSTLY flags.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Assemble.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Assemble.c b/Assemble.c
index a79466c..f39c9e1 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1704,6 +1704,9 @@ try_again:
else
desired_state = (1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC);
+ desired_state |= devices[j].i.disk.state & ((1<<MD_DISK_FAILFAST) |
+ (1<<MD_DISK_WRITEMOSTLY));
+
if (!devices[j].uptodate)
continue;
--
2.7.5

@ -0,0 +1,48 @@
From 83b3de7795d2a421eb6ae4ab97656a250bb898ea Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Fri, 23 Apr 2021 14:01:30 +0800
Subject: [PATCH 1/2] Fix some building errors
There are some building errors if treating warning as errors.
Fix them in this patch.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index be0313d..5469912 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -3192,7 +3192,7 @@ static int imsm_create_metadata_checkpoint_update(
}
(*u)->type = update_general_migration_checkpoint;
(*u)->curr_migr_unit = current_migr_unit(super->migr_rec);
- dprintf("prepared for %llu\n", (*u)->curr_migr_unit);
+ dprintf("prepared for %llu\n", (unsigned long long)(*u)->curr_migr_unit);
return update_memory_size;
}
@@ -11127,7 +11127,7 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
skipped_disks++;
continue;
}
- if (read(dl_disk->fd, buf, unit_len) != unit_len) {
+ if (read(dl_disk->fd, buf, unit_len) != (ssize_t)unit_len) {
pr_err("Cannot read copy area block: %s\n",
strerror(errno));
skipped_disks++;
@@ -11139,7 +11139,7 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
skipped_disks++;
continue;
}
- if (write(dl_disk->fd, buf, unit_len) != unit_len) {
+ if (write(dl_disk->fd, buf, unit_len) != (ssize_t)unit_len) {
pr_err("Cannot restore block: %s\n",
strerror(errno));
skipped_disks++;
--
2.7.5

@ -1,77 +0,0 @@
From 6b6112842030309c297a521918d1a2e982426fa3 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Fri, 9 Nov 2018 17:12:33 +1100
Subject: [RHEL7.7 PATCH 02/24] Document PART-POLICY lines
PART-POLICY has been accepted in mdadm.conf since the same
time that POLICY was accepted, but it was never documented.
So add the missing documentation.
Also fix a bug which would have stopped it from working if
anyone had ever tried to use it.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
mdadm.conf.5 | 24 +++++++++++++++++++++++-
policy.c | 2 +-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/mdadm.conf.5 b/mdadm.conf.5
index 18512cb..47c962a 100644
--- a/mdadm.conf.5
+++ b/mdadm.conf.5
@@ -501,7 +501,7 @@ To update hot plug configuration it is necessary to execute
.B mdadm \-\-udev\-rules
command after changing the config file
-Key words used in the
+Keywords used in the
.I POLICY
line and supported values are:
@@ -565,6 +565,28 @@ be automatically added to that array (or it's container)
as above and the disk will become a spare in remaining cases
.RE
+.TP
+.B PART-POLICY
+This is similar to
+.B POLICY
+and accepts the same keyword assignments. It allows a consistent set
+of policies to applied to each of the partitions of a device.
+
+A
+.B PART-POLICY
+line should set
+.I type=disk
+and identify the path to one or more disk devices. Each partition on
+these disks will be treated according to the
+.I action=
+setting from this line. If a
+.I domain
+is set in the line, then the domain associated with each patition will
+be based on the domain, but with
+.RB \(dq -part N\(dq
+appended, when N is the partition number for the partition that was
+found.
+
.SH EXAMPLE
DEVICE /dev/sd[bcdjkl]1
.br
diff --git a/policy.c b/policy.c
index c0d18a7..258f393 100644
--- a/policy.c
+++ b/policy.c
@@ -300,7 +300,7 @@ static int path_has_part(char *path, char **part)
l--;
if (l < 5 || strncmp(path+l-5, "-part", 5) != 0)
return 0;
- *part = path+l-4;
+ *part = path+l-5;
return 1;
}
--
2.7.5

@ -0,0 +1,36 @@
From 0530e2e0d8c9ecb5171e70bc48e1a6566f317378 Mon Sep 17 00:00:00 2001
From: Norbert Szulc <norbert.szulc@intel.com>
Date: Wed, 5 May 2021 13:01:02 +0200
Subject: [PATCH 2/2] Prevent user from using --stop with ambiguous args
When both --scan and device name is passed to --stop action,
then is executed only for given device. Scan is ignored.
Block the operation when both --scan and device name are passed.
Signed-off-by: Norbert Szulc <norbert.szulc@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
mdadm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mdadm.c b/mdadm.c
index 9a4317d..dcc26ba 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -2041,6 +2041,11 @@ static int misc_list(struct mddev_dev *devlist,
rv |= Manage_run(dv->devname, mdfd, c);
break;
case 'S':
+ if (c->scan) {
+ pr_err("--stop not meaningful with both a --scan assembly and a device name.\n");
+ rv |= 1;
+ break;
+ }
rv |= Manage_stop(dv->devname, mdfd, c->verbose, 0);
break;
case 'o':
--
2.7.5

@ -1,334 +0,0 @@
From cd72f9d114da206baa01fd56ff2d8ffcc08f3239 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Fri, 9 Nov 2018 17:12:33 +1100
Subject: [RHEL7.7 PATCH 03/24] policy: support devices with multiple paths.
As new releases of Linux some time change the name of
a path, some distros keep "legacy" names as well. This
is useful, but confuses mdadm which assumes each device has
precisely one path.
So change this assumption: allow a disk to have several
paths, and allow any to match when looking for a policy
which matches a disk.
Reported-and-tested-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Incremental.c | 5 +-
mdadm.h | 2 +-
policy.c | 163 ++++++++++++++++++++++++++++++++--------------------------
3 files changed, 95 insertions(+), 75 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index a4ff7d4..d4d3c35 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1080,6 +1080,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
struct supertype *st2 = NULL;
char *devname = NULL;
unsigned long long devsectors;
+ char *pathlist[2];
if (de->d_ino == 0 || de->d_name[0] == '.' ||
(de->d_type != DT_LNK && de->d_type != DT_UNKNOWN))
@@ -1094,7 +1095,9 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
/* This is a partition - skip it */
goto next;
- pol2 = path_policy(de->d_name, type_disk);
+ pathlist[0] = de->d_name;
+ pathlist[1] = NULL;
+ pol2 = path_policy(pathlist, type_disk);
domain_merge(&domlist, pol2, st ? st->ss->name : NULL);
if (domain_test(domlist, pol, st ? st->ss->name : NULL) != 1)
diff --git a/mdadm.h b/mdadm.h
index 387e681..705bd9b 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1247,7 +1247,7 @@ extern void policyline(char *line, char *type);
extern void policy_add(char *type, ...);
extern void policy_free(void);
-extern struct dev_policy *path_policy(char *path, char *type);
+extern struct dev_policy *path_policy(char **paths, char *type);
extern struct dev_policy *disk_policy(struct mdinfo *disk);
extern struct dev_policy *devid_policy(int devid);
extern void dev_policy_free(struct dev_policy *p);
diff --git a/policy.c b/policy.c
index 258f393..fa67d55 100644
--- a/policy.c
+++ b/policy.c
@@ -189,15 +189,17 @@ struct dev_policy *pol_find(struct dev_policy *pol, char *name)
return pol;
}
-static char *disk_path(struct mdinfo *disk)
+static char **disk_paths(struct mdinfo *disk)
{
struct stat stb;
int prefix_len;
DIR *by_path;
char symlink[PATH_MAX] = "/dev/disk/by-path/";
- char nm[PATH_MAX];
+ char **paths;
+ int cnt = 0;
struct dirent *ent;
- int rv;
+
+ paths = xmalloc(sizeof(*paths) * (cnt+1));
by_path = opendir(symlink);
if (by_path) {
@@ -214,22 +216,13 @@ static char *disk_path(struct mdinfo *disk)
continue;
if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
continue;
- closedir(by_path);
- return xstrdup(ent->d_name);
+ paths[cnt++] = xstrdup(ent->d_name);
+ paths = xrealloc(paths, sizeof(*paths) * (cnt+1));
}
closedir(by_path);
}
- /* A NULL path isn't really acceptable - use the devname.. */
- sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor);
- rv = readlink(symlink, nm, sizeof(nm)-1);
- if (rv > 0) {
- char *dname;
- nm[rv] = 0;
- dname = strrchr(nm, '/');
- if (dname)
- return xstrdup(dname + 1);
- }
- return xstrdup("unknown");
+ paths[cnt] = NULL;
+ return paths;
}
char type_part[] = "part";
@@ -246,18 +239,53 @@ static char *disk_type(struct mdinfo *disk)
return type_disk;
}
-static int pol_match(struct rule *rule, char *path, char *type)
+static int path_has_part(char *path, char **part)
+{
+ /* check if path ends with "-partNN" and
+ * if it does, place a pointer to "-pathNN"
+ * in 'part'.
+ */
+ int l;
+ if (!path)
+ return 0;
+ l = strlen(path);
+ while (l > 1 && isdigit(path[l-1]))
+ l--;
+ if (l < 5 || strncmp(path+l-5, "-part", 5) != 0)
+ return 0;
+ *part = path+l-5;
+ return 1;
+}
+
+static int pol_match(struct rule *rule, char **paths, char *type, char **part)
{
- /* check if this rule matches on path and type */
+ /* Check if this rule matches on any path and type.
+ * If 'part' is not NULL, then 'path' must end in -partN, which
+ * we ignore for matching, and return in *part on success.
+ */
int pathok = 0; /* 0 == no path, 1 == match, -1 == no match yet */
int typeok = 0;
- while (rule) {
+ for (; rule; rule = rule->next) {
if (rule->name == rule_path) {
+ char *p;
+ int i;
if (pathok == 0)
pathok = -1;
- if (path && fnmatch(rule->value, path, 0) == 0)
- pathok = 1;
+ if (!paths)
+ continue;
+ for (i = 0; paths[i]; i++) {
+ if (part) {
+ if (!path_has_part(paths[i], &p))
+ continue;
+ *p = '\0';
+ *part = p+1;
+ }
+ if (fnmatch(rule->value, paths[i], 0) == 0)
+ pathok = 1;
+ if (part)
+ *p = '-';
+ }
}
if (rule->name == rule_type) {
if (typeok == 0)
@@ -265,7 +293,6 @@ static int pol_match(struct rule *rule, char *path, char *type)
if (type && strcmp(rule->value, type) == 0)
typeok = 1;
}
- rule = rule->next;
}
return pathok >= 0 && typeok >= 0;
}
@@ -286,24 +313,6 @@ static void pol_merge(struct dev_policy **pol, struct rule *rule)
pol_new(pol, r->name, r->value, metadata);
}
-static int path_has_part(char *path, char **part)
-{
- /* check if path ends with "-partNN" and
- * if it does, place a pointer to "-pathNN"
- * in 'part'.
- */
- int l;
- if (!path)
- return 0;
- l = strlen(path);
- while (l > 1 && isdigit(path[l-1]))
- l--;
- if (l < 5 || strncmp(path+l-5, "-part", 5) != 0)
- return 0;
- *part = path+l-5;
- return 1;
-}
-
static void pol_merge_part(struct dev_policy **pol, struct rule *rule, char *part)
{
/* copy any name assignments from rule into pol, appending
@@ -352,7 +361,7 @@ static int config_rules_has_path = 0;
* path_policy() gathers policy information for the
* disk described in the given a 'path' and a 'type'.
*/
-struct dev_policy *path_policy(char *path, char *type)
+struct dev_policy *path_policy(char **paths, char *type)
{
struct pol_rule *rules;
struct dev_policy *pol = NULL;
@@ -361,27 +370,24 @@ struct dev_policy *path_policy(char *path, char *type)
rules = config_rules;
while (rules) {
- char *part;
+ char *part = NULL;
if (rules->type == rule_policy)
- if (pol_match(rules->rule, path, type))
+ if (pol_match(rules->rule, paths, type, NULL))
pol_merge(&pol, rules->rule);
if (rules->type == rule_part && strcmp(type, type_part) == 0)
- if (path_has_part(path, &part)) {
- *part = 0;
- if (pol_match(rules->rule, path, type_disk))
- pol_merge_part(&pol, rules->rule, part+1);
- *part = '-';
- }
+ if (pol_match(rules->rule, paths, type_disk, &part))
+ pol_merge_part(&pol, rules->rule, part);
rules = rules->next;
}
/* Now add any metadata-specific internal knowledge
* about this path
*/
- for (i=0; path && superlist[i]; i++)
+ for (i=0; paths[0] && superlist[i]; i++)
if (superlist[i]->get_disk_controller_domain) {
const char *d =
- superlist[i]->get_disk_controller_domain(path);
+ superlist[i]->get_disk_controller_domain(
+ paths[0]);
if (d)
pol_new(&pol, pol_domain, d, superlist[i]->name);
}
@@ -400,22 +406,34 @@ void pol_add(struct dev_policy **pol,
pol_dedup(*pol);
}
+static void free_paths(char **paths)
+{
+ int i;
+
+ if (!paths)
+ return;
+
+ for (i = 0; paths[i]; i++)
+ free(paths[i]);
+ free(paths);
+}
+
/*
* disk_policy() gathers policy information for the
* disk described in the given mdinfo (disk.{major,minor}).
*/
struct dev_policy *disk_policy(struct mdinfo *disk)
{
- char *path = NULL;
+ char **paths = NULL;
char *type = disk_type(disk);
struct dev_policy *pol = NULL;
if (config_rules_has_path)
- path = disk_path(disk);
+ paths = disk_paths(disk);
- pol = path_policy(path, type);
+ pol = path_policy(paths, type);
- free(path);
+ free_paths(paths);
return pol;
}
@@ -756,27 +774,26 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array)
{
char path[PATH_MAX];
FILE *f = NULL;
- char *id_path = disk_path(disk);
- int rv;
+ char **id_paths = disk_paths(disk);
+ int i;
+ int rv = 0;
- if (!id_path)
- return 0;
+ for (i = 0; id_paths[i]; i++) {
+ snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_paths[i]);
+ f = fopen(path, "r");
+ if (!f)
+ continue;
- snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
- f = fopen(path, "r");
- if (!f) {
- free(id_path);
- return 0;
+ rv = fscanf(f, " %s %x:%x:%x:%x\n",
+ array->metadata,
+ array->uuid,
+ array->uuid+1,
+ array->uuid+2,
+ array->uuid+3);
+ fclose(f);
+ break;
}
-
- rv = fscanf(f, " %s %x:%x:%x:%x\n",
- array->metadata,
- array->uuid,
- array->uuid+1,
- array->uuid+2,
- array->uuid+3);
- fclose(f);
- free(id_path);
+ free_paths(id_paths);
return rv == 5;
}
--
2.7.5

@ -1,137 +0,0 @@
From 4199d3c629c14866505923d19fa50017ee92d2e1 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Wed, 5 Dec 2018 16:35:00 +1100
Subject: [RHEL7.7 PATCH 04/24] mdcheck: add systemd unit files to run mdcheck.
Having the mdcheck script is not use if is never run.
This patch adds systemd unit files so that it can easily
be run on the first Sunday of each month for 6 hours,
then on every subsequent morning until the check is
finished.
The units still need to be enabled with
systemctl enable mdcheck_start.timer
The timer will only actually be started when an array
which might need it becomes active.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Makefile | 5 ++++-
systemd/mdcheck_continue.service | 18 ++++++++++++++++++
systemd/mdcheck_continue.timer | 13 +++++++++++++
systemd/mdcheck_start.service | 17 +++++++++++++++++
systemd/mdcheck_start.timer | 15 +++++++++++++++
5 files changed, 67 insertions(+), 1 deletion(-)
create mode 100644 systemd/mdcheck_continue.service
create mode 100644 systemd/mdcheck_continue.timer
create mode 100644 systemd/mdcheck_start.service
create mode 100644 systemd/mdcheck_start.timer
diff --git a/Makefile b/Makefile
index 2767ac6..afb62cc 100644
--- a/Makefile
+++ b/Makefile
@@ -276,7 +276,10 @@ install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid
install-systemd: systemd/mdmon@.service
@for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \
- mdadm-last-resort@.service mdadm-grow-continue@.service; \
+ mdadm-last-resort@.service mdadm-grow-continue@.service \
+ mdcheck_start.timer mdcheck_start.service \
+ mdcheck_continue.timer mdcheck_continue.service \
+ ; \
do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \
$(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
$(INSTALL) -D -m 644 .install.tmp.2 $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service
new file mode 100644
index 0000000..592c607
--- /dev/null
+++ b/systemd/mdcheck_continue.service
@@ -0,0 +1,18 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=MD array scrubbing - continuation
+ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_*
+
+[Service]
+Type=oneshot
+Environment= MDADM_CHECK_DURATION='"6 hours"'
+EnvironmentFile=-/run/sysconfig/mdadm
+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
+ExecStart=/usr/share/mdadm/mdcheck --continue --duration $MDADM_CHECK_DURATION
+
diff --git a/systemd/mdcheck_continue.timer b/systemd/mdcheck_continue.timer
new file mode 100644
index 0000000..3ccfd78
--- /dev/null
+++ b/systemd/mdcheck_continue.timer
@@ -0,0 +1,13 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=MD array scrubbing - continuation
+
+[Timer]
+OnCalendar= 1:05:00
+
diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service
new file mode 100644
index 0000000..812141b
--- /dev/null
+++ b/systemd/mdcheck_start.service
@@ -0,0 +1,17 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=MD array scrubbing
+Wants=mdcheck_continue.timer
+
+[Service]
+Type=oneshot
+Environment= MDADM_CHECK_DURATION='"6 hours"'
+EnvironmentFile=-/run/sysconfig/mdadm
+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
+ExecStart=/usr/share/mdadm/mdcheck --duration $MDADM_CHECK_DURATION
diff --git a/systemd/mdcheck_start.timer b/systemd/mdcheck_start.timer
new file mode 100644
index 0000000..6480736
--- /dev/null
+++ b/systemd/mdcheck_start.timer
@@ -0,0 +1,15 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=MD array scrubbing
+
+[Timer]
+OnCalendar=Sun *-*-1..7 1:00:00
+
+[Install]
+WantedBy= mdmonitor.service
--
2.7.5

@ -1,83 +0,0 @@
From 7cd7e91ab3de5aa75dc963cb08b0618c1885cf0d Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Wed, 5 Dec 2018 16:35:00 +1100
Subject: [RHEL7.7 PATCH 05/24] Monitor: add system timer to run --oneshot
periodically
"mdadm --monitor --oneshot" can be used to get a warning
if there are any degraded arrays. It can be helpful to get
this warning periodically while the condition persists.
This patch add a systemd service and timer which can
be enabled with
systemctl enable mdmonitor-oneshot.service
and will then provide daily warnings.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Makefile | 1 +
systemd/mdmonitor-oneshot.service | 15 +++++++++++++++
systemd/mdmonitor-oneshot.timer | 15 +++++++++++++++
3 files changed, 31 insertions(+)
create mode 100644 systemd/mdmonitor-oneshot.service
create mode 100644 systemd/mdmonitor-oneshot.timer
diff --git a/Makefile b/Makefile
index afb62cc..dfe00b0 100644
--- a/Makefile
+++ b/Makefile
@@ -279,6 +279,7 @@ install-systemd: systemd/mdmon@.service
mdadm-last-resort@.service mdadm-grow-continue@.service \
mdcheck_start.timer mdcheck_start.service \
mdcheck_continue.timer mdcheck_continue.service \
+ mdmonitor-oneshot.timer mdmonitor-oneshot.service \
; \
do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \
$(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service
new file mode 100644
index 0000000..fd469b1
--- /dev/null
+++ b/systemd/mdmonitor-oneshot.service
@@ -0,0 +1,15 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Reminder for degraded MD arrays
+
+[Service]
+Environment= MDADM_MONITOR_ARGS=--scan
+EnvironmentFile=-/run/sysconfig/mdadm
+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
+ExecStart=BINDIR/mdadm --monitor --oneshot $MDADM_MONITOR_ARGS
diff --git a/systemd/mdmonitor-oneshot.timer b/systemd/mdmonitor-oneshot.timer
new file mode 100644
index 0000000..cb54bda
--- /dev/null
+++ b/systemd/mdmonitor-oneshot.timer
@@ -0,0 +1,15 @@
+# This file is part of mdadm.
+#
+# mdadm is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Reminder for degraded MD arrays
+
+[Timer]
+OnCalendar= 2:00:00
+
+[Install]
+WantedBy= mdmonitor.service
--
2.7.5

@ -1,83 +0,0 @@
From d7a1fda2769ba272d89de6caeab35d52b73a9c3c Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Date: Wed, 17 Oct 2018 12:11:41 +0200
Subject: [RHEL7.7 PATCH 06/24] imsm: update metadata correctly while raid10
double degradation
Mdmon calls end_migration() when map state changes from normal to
degraded. It is not valid because in raid 10 double degradation case
mdmon breaks checkpointing but array is still rebuilding.
In this case mdmon has to mark map as degraded and continues marking
recovery checkpoint in metadata. Migration can be finished only if newly
failed device is a rebuilding device.
Add catching double degraded to degraded transition. Migration is
finished but map state doesn't change, array is still degraded.
Update failed_disk_num correctly. If double degradation
happens rebuild will start on the lowest slot, but this variable points
to the first failed slot. If second fail happens while rebuild this
variable shouldn't be updated until rebuild is not finished.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 6438987..d2035cc 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -8136,7 +8136,8 @@ static int mark_failure(struct intel_super *super,
set_imsm_ord_tbl_ent(map2, slot2,
idx | IMSM_ORD_REBUILD);
}
- if (map->failed_disk_num == 0xff)
+ if (map->failed_disk_num == 0xff ||
+ (!is_rebuilding(dev) && map->failed_disk_num > slot))
map->failed_disk_num = slot;
clear_disk_badblocks(super->bbm_log, ord_to_idx(ord));
@@ -8558,13 +8559,25 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
break;
}
if (is_rebuilding(dev)) {
- dprintf_cont("while rebuilding.");
+ dprintf_cont("while rebuilding ");
if (map->map_state != map_state) {
- dprintf_cont(" Map state change");
- end_migration(dev, super, map_state);
+ dprintf_cont("map state change ");
+ if (n == map->failed_disk_num) {
+ dprintf_cont("end migration");
+ end_migration(dev, super, map_state);
+ } else {
+ dprintf_cont("raid10 double degradation, map state change");
+ map->map_state = map_state;
+ }
super->updates_pending++;
- } else if (!rebuild_done) {
+ } else if (!rebuild_done)
break;
+ else if (n == map->failed_disk_num) {
+ /* r10 double degraded to degraded transition */
+ dprintf_cont("raid10 double degradation end migration");
+ end_migration(dev, super, map_state);
+ a->last_checkpoint = 0;
+ super->updates_pending++;
}
/* check if recovery is really finished */
@@ -8575,7 +8588,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
}
if (recovery_not_finished) {
dprintf_cont("\n");
- dprintf("Rebuild has not finished yet, state not changed");
+ dprintf_cont("Rebuild has not finished yet, map state changes only if raid10 double degradation happens");
if (a->last_checkpoint < mdi->recovery_start) {
a->last_checkpoint =
mdi->recovery_start;
--
2.7.5

@ -1,43 +0,0 @@
From 563ac108659980b3d1e226fe416254a86656235f Mon Sep 17 00:00:00 2001
From: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Date: Tue, 6 Nov 2018 16:20:17 +0100
Subject: [RHEL7.7 PATCH 07/24] Assemble: mask FAILFAST and WRITEMOSTLY flags
when finding the most recent device
If devices[].i.disk.state has MD_DISK_FAILFAST or MD_DISK_WRITEMOSTLY
flag, it cannot be the most recent device. Both flags should be masked
before checking the state.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Assemble.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Assemble.c b/Assemble.c
index f39c9e1..9f75c68 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -578,6 +578,7 @@ static int load_devices(struct devs *devices, char *devmap,
struct supertype *tst;
int i;
int dfd;
+ int disk_state;
if (tmpdev->used != 1)
continue;
@@ -711,7 +712,9 @@ static int load_devices(struct devs *devices, char *devmap,
devices[devcnt].i.disk.major = major(stb.st_rdev);
devices[devcnt].i.disk.minor = minor(stb.st_rdev);
- if (devices[devcnt].i.disk.state == 6) {
+ disk_state = devices[devcnt].i.disk.state & ~((1<<MD_DISK_FAILFAST) |
+ (1<<MD_DISK_WRITEMOSTLY));
+ if (disk_state == ((1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC))) {
if (most_recent < 0 ||
devices[devcnt].i.events
> devices[most_recent].i.events) {
--
2.7.5

@ -1,34 +0,0 @@
From 085df42259cba7863cd6ebe5cd0d8492ac5b869e Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Thu, 6 Dec 2018 10:35:41 +1100
Subject: [RHEL7.7 PATCH 08/24] Grow: avoid overflow in compute_backup_blocks()
With a chunk size of 16Meg and data drive count of 8,
this calculate can easily overflow the 'int' type that
is used for the multiplications.
So force it to use "long" instead.
Reported-and-tested-by: Ed Spiridonov <edo.rus@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Grow.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index 4436a4d..76f82c0 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1196,7 +1196,8 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk,
/* Find GCD */
a = GCD(a, b);
/* LCM == product / GCD */
- blocks = (ochunk/512) * (nchunk/512) * odata * ndata / a;
+ blocks = (unsigned long)(ochunk/512) * (unsigned long)(nchunk/512) *
+ odata * ndata / a;
return blocks;
}
--
2.7.5

@ -1,30 +0,0 @@
From 76d505dec6c9f92564553596fc8350324be82463 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Thu, 6 Dec 2018 10:36:28 +1100
Subject: [RHEL7.7 PATCH 09/24] Grow: report correct new chunk size.
When using "--grow --chunk=" to change chunk
size, the old chunksize is reported instead of the new.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Grow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index 76f82c0..363b209 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3286,7 +3286,7 @@ static int reshape_array(char *container, int fd, char *devname,
goto release;
} else if (verbose >= 0)
printf("chunk size for %s set to %d\n",
- devname, array.chunk_size);
+ devname, info->new_chunk);
}
unfreeze(st);
return 0;
--
2.7.5

@ -1,31 +0,0 @@
From 467e6a1b4ece8e552ee638dab7f44a4d235ece1a Mon Sep 17 00:00:00 2001
From: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Date: Fri, 7 Dec 2018 12:04:44 +0100
Subject: [RHEL7.7 PATCH 10/24] policy.c: prevent NULL pointer referencing
paths could be NULL and paths[0] should be followed by NULL pointer
checking.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
policy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/policy.c b/policy.c
index fa67d55..e3a0671 100644
--- a/policy.c
+++ b/policy.c
@@ -383,7 +383,7 @@ struct dev_policy *path_policy(char **paths, char *type)
/* Now add any metadata-specific internal knowledge
* about this path
*/
- for (i=0; paths[0] && superlist[i]; i++)
+ for (i=0; paths && paths[0] && superlist[i]; i++)
if (superlist[i]->get_disk_controller_domain) {
const char *d =
superlist[i]->get_disk_controller_domain(
--
2.7.5

@ -1,36 +0,0 @@
From 757e55435997e355ee9b03e5d913b5496a3c39a8 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Date: Tue, 11 Dec 2018 15:04:07 +0100
Subject: [RHEL7.7 PATCH 11/24] policy.c: Fix for compiler error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
After cd72f9d(policy: support devices with multiple paths.) compilation
on old compilers fails because "โ€˜pโ€™ may be used uninitialized
in this function".
Initialize it with NULL to prevent this.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
policy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/policy.c b/policy.c
index e3a0671..3c53bd3 100644
--- a/policy.c
+++ b/policy.c
@@ -268,7 +268,7 @@ static int pol_match(struct rule *rule, char **paths, char *type, char **part)
for (; rule; rule = rule->next) {
if (rule->name == rule_path) {
- char *p;
+ char *p = NULL;
int i;
if (pathok == 0)
pathok = -1;
--
2.7.5

@ -1,95 +0,0 @@
From a4e96fd8f3f0b5416783237c1cb6ee87e7eff23d Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Date: Fri, 8 Feb 2019 11:07:10 +0100
Subject: [RHEL7.7 PATCH 12/24] imsm: finish recovery when drive with rebuild
fails
Commit d7a1fda2769b ("imsm: update metadata correctly while raid10 double
degradation") resolves main Imsm double degradation problems but it
omits one case. Now metadata hangs in the rebuilding state if the drive
under rebuild is removed during recovery from double degradation.
The root cause of this problem is comparing new map_state with current
and if they both are degraded assuming that nothing new happens.
Don't rely on map states, just check if device is failed. If the drive
under rebuild fails then finish migration, in other cases update map
state only (second fail means that destination map state can't be normal).
To avoid problems with reassembling move end_migration (called after
double degradation successful recovery) after check if recovery really
finished, for details see (7ce057018 "imsm: fix: rebuild does not
continue after reboot").
Remove redundant code responsible for finishing rebuild process. Function
end_migration do exactly the same. Set last_checkpoint to 0, to prepare
it for the next rebuild.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index d2035cc..38a1b6c 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -8560,26 +8560,22 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
}
if (is_rebuilding(dev)) {
dprintf_cont("while rebuilding ");
- if (map->map_state != map_state) {
- dprintf_cont("map state change ");
+ if (state & DS_FAULTY) {
+ dprintf_cont("removing failed drive ");
if (n == map->failed_disk_num) {
dprintf_cont("end migration");
end_migration(dev, super, map_state);
+ a->last_checkpoint = 0;
} else {
- dprintf_cont("raid10 double degradation, map state change");
+ dprintf_cont("fail detected during rebuild, changing map state");
map->map_state = map_state;
}
super->updates_pending++;
- } else if (!rebuild_done)
- break;
- else if (n == map->failed_disk_num) {
- /* r10 double degraded to degraded transition */
- dprintf_cont("raid10 double degradation end migration");
- end_migration(dev, super, map_state);
- a->last_checkpoint = 0;
- super->updates_pending++;
}
+ if (!rebuild_done)
+ break;
+
/* check if recovery is really finished */
for (mdi = a->info.devs; mdi ; mdi = mdi->next)
if (mdi->recovery_start != MaxSector) {
@@ -8588,7 +8584,7 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
}
if (recovery_not_finished) {
dprintf_cont("\n");
- dprintf_cont("Rebuild has not finished yet, map state changes only if raid10 double degradation happens");
+ dprintf_cont("Rebuild has not finished yet");
if (a->last_checkpoint < mdi->recovery_start) {
a->last_checkpoint =
mdi->recovery_start;
@@ -8598,9 +8594,9 @@ static void imsm_set_disk(struct active_array *a, int n, int state)
}
dprintf_cont(" Rebuild done, still degraded");
- dev->vol.migr_state = 0;
- set_migr_type(dev, 0);
- dev->vol.curr_migr_unit = 0;
+ end_migration(dev, super, map_state);
+ a->last_checkpoint = 0;
+ super->updates_pending++;
for (i = 0; i < map->num_members; i++) {
int idx = get_imsm_ord_tbl_ent(dev, i, MAP_0);
--
2.7.5

@ -1,322 +0,0 @@
From 9f4218274cd4a1e1f356a1617f9a1d09960cf255 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
Date: Mon, 28 Jan 2019 17:10:41 +0100
Subject: [RHEL7.7 PATCH 13/24] imsm: fix reshape for >2TB drives
If reshape is performed on drives larger then 2 TB,
migration checkpoint area that is calculated exeeds 32-bit value.
This checkpoint area is a reserved space threated as backup
during reshape - at the end of the drive, right before metadata.
As a result - wrong space is used and the data that may exists there
is overwritten.
Adding additional field to migration record to track high order 32-bits
of pba of this area. Three other fields that may exceed 32-bit value
for large drives are added as well.
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 149 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 107 insertions(+), 42 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 38a1b6c..1cc7d5f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -296,7 +296,7 @@ struct migr_record {
__u32 rec_status; /* Status used to determine how to restart
* migration in case it aborts
* in some fashion */
- __u32 curr_migr_unit; /* 0..numMigrUnits-1 */
+ __u32 curr_migr_unit_lo; /* 0..numMigrUnits-1 */
__u32 family_num; /* Family number of MPB
* containing the RaidDev
* that is migrating */
@@ -306,16 +306,23 @@ struct migr_record {
__u32 dest_depth_per_unit; /* Num member blocks each destMap
* member disk
* advances per unit-of-operation */
- __u32 ckpt_area_pba; /* Pba of first block of ckpt copy area */
- __u32 dest_1st_member_lba; /* First member lba on first
- * stripe of destination */
- __u32 num_migr_units; /* Total num migration units-of-op */
+ __u32 ckpt_area_pba_lo; /* Pba of first block of ckpt copy area */
+ __u32 dest_1st_member_lba_lo; /* First member lba on first
+ * stripe of destination */
+ __u32 num_migr_units_lo; /* Total num migration units-of-op */
__u32 post_migr_vol_cap; /* Size of volume after
* migration completes */
__u32 post_migr_vol_cap_hi; /* Expansion space for LBA64 */
__u32 ckpt_read_disk_num; /* Which member disk in destSubMap[0] the
* migration ckpt record was read from
* (for recovered migrations) */
+ __u32 curr_migr_unit_hi; /* 0..numMigrUnits-1 high order 32 bits */
+ __u32 ckpt_area_pba_hi; /* Pba of first block of ckpt copy area
+ * high order 32 bits */
+ __u32 dest_1st_member_lba_hi; /* First member lba on first stripe of
+ * destination - high order 32 bits */
+ __u32 num_migr_units_hi; /* Total num migration units-of-op
+ * high order 32 bits */
} __attribute__ ((__packed__));
struct md_list {
@@ -1208,6 +1215,38 @@ static unsigned long long imsm_dev_size(struct imsm_dev *dev)
return join_u32(dev->size_low, dev->size_high);
}
+static unsigned long long migr_chkp_area_pba(struct migr_record *migr_rec)
+{
+ if (migr_rec == NULL)
+ return 0;
+ return join_u32(migr_rec->ckpt_area_pba_lo,
+ migr_rec->ckpt_area_pba_hi);
+}
+
+static unsigned long long current_migr_unit(struct migr_record *migr_rec)
+{
+ if (migr_rec == NULL)
+ return 0;
+ return join_u32(migr_rec->curr_migr_unit_lo,
+ migr_rec->curr_migr_unit_hi);
+}
+
+static unsigned long long migr_dest_1st_member_lba(struct migr_record *migr_rec)
+{
+ if (migr_rec == NULL)
+ return 0;
+ return join_u32(migr_rec->dest_1st_member_lba_lo,
+ migr_rec->dest_1st_member_lba_hi);
+}
+
+static unsigned long long get_num_migr_units(struct migr_record *migr_rec)
+{
+ if (migr_rec == NULL)
+ return 0;
+ return join_u32(migr_rec->num_migr_units_lo,
+ migr_rec->num_migr_units_hi);
+}
+
static void set_total_blocks(struct imsm_disk *disk, unsigned long long n)
{
split_ull(n, &disk->total_blocks_lo, &disk->total_blocks_hi);
@@ -1233,6 +1272,33 @@ static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n)
split_ull(n, &dev->size_low, &dev->size_high);
}
+static void set_migr_chkp_area_pba(struct migr_record *migr_rec,
+ unsigned long long n)
+{
+ split_ull(n, &migr_rec->ckpt_area_pba_lo, &migr_rec->ckpt_area_pba_hi);
+}
+
+static void set_current_migr_unit(struct migr_record *migr_rec,
+ unsigned long long n)
+{
+ split_ull(n, &migr_rec->curr_migr_unit_lo,
+ &migr_rec->curr_migr_unit_hi);
+}
+
+static void set_migr_dest_1st_member_lba(struct migr_record *migr_rec,
+ unsigned long long n)
+{
+ split_ull(n, &migr_rec->dest_1st_member_lba_lo,
+ &migr_rec->dest_1st_member_lba_hi);
+}
+
+static void set_num_migr_units(struct migr_record *migr_rec,
+ unsigned long long n)
+{
+ split_ull(n, &migr_rec->num_migr_units_lo,
+ &migr_rec->num_migr_units_hi);
+}
+
static unsigned long long per_dev_array_size(struct imsm_map *map)
{
unsigned long long array_size = 0;
@@ -1629,12 +1695,14 @@ void convert_to_4k_imsm_migr_rec(struct intel_super *super)
struct migr_record *migr_rec = super->migr_rec;
migr_rec->blocks_per_unit /= IMSM_4K_DIV;
- migr_rec->ckpt_area_pba /= IMSM_4K_DIV;
- migr_rec->dest_1st_member_lba /= IMSM_4K_DIV;
migr_rec->dest_depth_per_unit /= IMSM_4K_DIV;
split_ull((join_u32(migr_rec->post_migr_vol_cap,
migr_rec->post_migr_vol_cap_hi) / IMSM_4K_DIV),
&migr_rec->post_migr_vol_cap, &migr_rec->post_migr_vol_cap_hi);
+ set_migr_chkp_area_pba(migr_rec,
+ migr_chkp_area_pba(migr_rec) / IMSM_4K_DIV);
+ set_migr_dest_1st_member_lba(migr_rec,
+ migr_dest_1st_member_lba(migr_rec) / IMSM_4K_DIV);
}
void convert_to_4k_imsm_disk(struct imsm_disk *disk)
@@ -1727,8 +1795,8 @@ void examine_migr_rec_imsm(struct intel_super *super)
printf("Normal\n");
else
printf("Contains Data\n");
- printf(" Current Unit : %u\n",
- __le32_to_cpu(migr_rec->curr_migr_unit));
+ printf(" Current Unit : %llu\n",
+ current_migr_unit(migr_rec));
printf(" Family : %u\n",
__le32_to_cpu(migr_rec->family_num));
printf(" Ascending : %u\n",
@@ -1737,16 +1805,15 @@ void examine_migr_rec_imsm(struct intel_super *super)
__le32_to_cpu(migr_rec->blocks_per_unit));
printf(" Dest. Depth Per Unit : %u\n",
__le32_to_cpu(migr_rec->dest_depth_per_unit));
- printf(" Checkpoint Area pba : %u\n",
- __le32_to_cpu(migr_rec->ckpt_area_pba));
- printf(" First member lba : %u\n",
- __le32_to_cpu(migr_rec->dest_1st_member_lba));
- printf(" Total Number of Units : %u\n",
- __le32_to_cpu(migr_rec->num_migr_units));
- printf(" Size of volume : %u\n",
- __le32_to_cpu(migr_rec->post_migr_vol_cap));
- printf(" Expansion space for LBA64 : %u\n",
- __le32_to_cpu(migr_rec->post_migr_vol_cap_hi));
+ printf(" Checkpoint Area pba : %llu\n",
+ migr_chkp_area_pba(migr_rec));
+ printf(" First member lba : %llu\n",
+ migr_dest_1st_member_lba(migr_rec));
+ printf(" Total Number of Units : %llu\n",
+ get_num_migr_units(migr_rec));
+ printf(" Size of volume : %llu\n",
+ join_u32(migr_rec->post_migr_vol_cap,
+ migr_rec->post_migr_vol_cap_hi));
printf(" Record was read from : %u\n",
__le32_to_cpu(migr_rec->ckpt_read_disk_num));
@@ -1759,13 +1826,15 @@ void convert_from_4k_imsm_migr_rec(struct intel_super *super)
struct migr_record *migr_rec = super->migr_rec;
migr_rec->blocks_per_unit *= IMSM_4K_DIV;
- migr_rec->ckpt_area_pba *= IMSM_4K_DIV;
- migr_rec->dest_1st_member_lba *= IMSM_4K_DIV;
migr_rec->dest_depth_per_unit *= IMSM_4K_DIV;
split_ull((join_u32(migr_rec->post_migr_vol_cap,
migr_rec->post_migr_vol_cap_hi) * IMSM_4K_DIV),
&migr_rec->post_migr_vol_cap,
&migr_rec->post_migr_vol_cap_hi);
+ set_migr_chkp_area_pba(migr_rec,
+ migr_chkp_area_pba(migr_rec) * IMSM_4K_DIV);
+ set_migr_dest_1st_member_lba(migr_rec,
+ migr_dest_1st_member_lba(migr_rec) * IMSM_4K_DIV);
}
void convert_from_4k(struct intel_super *super)
@@ -3096,7 +3165,7 @@ static int imsm_create_metadata_checkpoint_update(
return 0;
}
(*u)->type = update_general_migration_checkpoint;
- (*u)->curr_migr_unit = __le32_to_cpu(super->migr_rec->curr_migr_unit);
+ (*u)->curr_migr_unit = current_migr_unit(super->migr_rec);
dprintf("prepared for %u\n", (*u)->curr_migr_unit);
return update_memory_size;
@@ -3397,13 +3466,13 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
case MIGR_GEN_MIGR: {
__u64 blocks_per_unit = blocks_per_migr_unit(super,
dev);
- __u64 units = __le32_to_cpu(migr_rec->curr_migr_unit);
+ __u64 units = current_migr_unit(migr_rec);
unsigned long long array_blocks;
int used_disks;
if (__le32_to_cpu(migr_rec->ascending_migr) &&
(units <
- (__le32_to_cpu(migr_rec->num_migr_units)-1)) &&
+ (get_num_migr_units(migr_rec)-1)) &&
(super->migr_rec->rec_status ==
__cpu_to_le32(UNIT_SRC_IN_CP_AREA)))
units++;
@@ -10697,7 +10766,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev,
if (array_blocks % __le32_to_cpu(migr_rec->blocks_per_unit))
num_migr_units++;
- migr_rec->num_migr_units = __cpu_to_le32(num_migr_units);
+ set_num_migr_units(migr_rec, num_migr_units);
migr_rec->post_migr_vol_cap = dev->size_low;
migr_rec->post_migr_vol_cap_hi = dev->size_high;
@@ -10714,7 +10783,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev,
min_dev_sectors = dev_sectors;
close(fd);
}
- migr_rec->ckpt_area_pba = __cpu_to_le32(min_dev_sectors -
+ set_migr_chkp_area_pba(migr_rec, min_dev_sectors -
RAID_DISK_RESERVED_BLOCKS_IMSM_HI);
write_imsm_migr_rec(st);
@@ -10765,8 +10834,7 @@ int save_backup_imsm(struct supertype *st,
start = info->reshape_progress * 512;
for (i = 0; i < new_disks; i++) {
- target_offsets[i] = (unsigned long long)
- __le32_to_cpu(super->migr_rec->ckpt_area_pba) * 512;
+ target_offsets[i] = migr_chkp_area_pba(super->migr_rec) * 512;
/* move back copy area adderss, it will be moved forward
* in restore_stripes() using start input variable
*/
@@ -10845,12 +10913,11 @@ int save_checkpoint_imsm(struct supertype *st, struct mdinfo *info, int state)
if (info->reshape_progress % blocks_per_unit)
curr_migr_unit++;
- super->migr_rec->curr_migr_unit =
- __cpu_to_le32(curr_migr_unit);
+ set_current_migr_unit(super->migr_rec, curr_migr_unit);
super->migr_rec->rec_status = __cpu_to_le32(state);
- super->migr_rec->dest_1st_member_lba =
- __cpu_to_le32(curr_migr_unit *
- __le32_to_cpu(super->migr_rec->dest_depth_per_unit));
+ set_migr_dest_1st_member_lba(super->migr_rec,
+ super->migr_rec->dest_depth_per_unit * curr_migr_unit);
+
if (write_imsm_migr_rec(st) < 0) {
dprintf("imsm: Cannot write migration record outside backup area\n");
return 1;
@@ -10884,8 +10951,8 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
char *buf = NULL;
int retval = 1;
unsigned int sector_size = super->sector_size;
- unsigned long curr_migr_unit = __le32_to_cpu(migr_rec->curr_migr_unit);
- unsigned long num_migr_units = __le32_to_cpu(migr_rec->num_migr_units);
+ unsigned long curr_migr_unit = current_migr_unit(migr_rec);
+ unsigned long num_migr_units = get_num_migr_units(migr_rec);
char buffer[20];
int skipped_disks = 0;
@@ -10912,11 +10979,9 @@ int recover_backup_imsm(struct supertype *st, struct mdinfo *info)
map_dest = get_imsm_map(id->dev, MAP_0);
new_disks = map_dest->num_members;
- read_offset = (unsigned long long)
- __le32_to_cpu(migr_rec->ckpt_area_pba) * 512;
+ read_offset = migr_chkp_area_pba(migr_rec) * 512;
- write_offset = ((unsigned long long)
- __le32_to_cpu(migr_rec->dest_1st_member_lba) +
+ write_offset = (migr_dest_1st_member_lba(migr_rec) +
pba_of_lba0(map_dest)) * 512;
unit_len = __le32_to_cpu(migr_rec->dest_depth_per_unit) * 512;
@@ -12019,12 +12084,12 @@ static int imsm_manage_reshape(
max_position = sra->component_size * ndata;
source_layout = imsm_level_to_layout(map_src->raid_level);
- while (__le32_to_cpu(migr_rec->curr_migr_unit) <
- __le32_to_cpu(migr_rec->num_migr_units)) {
+ while (current_migr_unit(migr_rec) <
+ get_num_migr_units(migr_rec)) {
/* current reshape position [blocks] */
unsigned long long current_position =
__le32_to_cpu(migr_rec->blocks_per_unit)
- * __le32_to_cpu(migr_rec->curr_migr_unit);
+ * current_migr_unit(migr_rec);
unsigned long long border;
/* Check that array hasn't become failed.
--
2.7.5

@ -1,101 +0,0 @@
From ebf3be9931f31df54df52b1821479e6a80a4d9c6 Mon Sep 17 00:00:00 2001
From: Dimitri John Ledkov <xnox@ubuntu.com>
Date: Tue, 15 Jan 2019 19:08:37 +0000
Subject: [RHEL7.7 PATCH 14/24] Fix spelling typos.
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Assemble.c | 2 +-
Create.c | 2 +-
Grow.c | 6 +++---
super-ddf.c | 2 +-
super-intel.c | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 9f75c68..9f050c1 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -879,7 +879,7 @@ static int force_array(struct mdinfo *content,
current_events = devices[chosen_drive].i.events;
add_another:
if (c->verbose >= 0)
- pr_err("forcing event count in %s(%d) from %d upto %d\n",
+ pr_err("forcing event count in %s(%d) from %d up to %d\n",
devices[chosen_drive].devname,
devices[chosen_drive].i.disk.raid_disk,
(int)(devices[chosen_drive].i.events),
diff --git a/Create.c b/Create.c
index 04b1dfc..6f1b228 100644
--- a/Create.c
+++ b/Create.c
@@ -823,7 +823,7 @@ int Create(struct supertype *st, char *mddev,
}
bitmap_fd = open(s->bitmap_file, O_RDWR);
if (bitmap_fd < 0) {
- pr_err("weird: %s cannot be openned\n",
+ pr_err("weird: %s cannot be opened\n",
s->bitmap_file);
goto abort_locked;
}
diff --git a/Grow.c b/Grow.c
index 363b209..6d32661 100644
--- a/Grow.c
+++ b/Grow.c
@@ -446,7 +446,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
if (offset_setable) {
st->ss->getinfo_super(st, mdi, NULL);
if (sysfs_init(mdi, fd, NULL)) {
- pr_err("failed to intialize sysfs.\n");
+ pr_err("failed to initialize sysfs.\n");
free(mdi);
}
rv = sysfs_set_num_signed(mdi, NULL, "bitmap/location",
@@ -2178,7 +2178,7 @@ size_change_error:
memset(&info, 0, sizeof(info));
info.array = array;
if (sysfs_init(&info, fd, NULL)) {