diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2019-01-15 18:40:20 +0000 |
---|---|---|
committer | Dimitri John Ledkov <xnox@ubuntu.com> | 2019-01-15 18:41:08 +0000 |
commit | ada795fa8e7b1e27c134fe7d5aedf4517cd082f5 (patch) | |
tree | 5717f98c75f6b1a9fbae50b88c35f13d07993226 | |
parent | 88ee7cfa1e00aabcfc8f48b57f4b226e7b5c2158 (diff) |
New upstream release
* New upstream release
* Cherrypick patches from master up to 757e55435997e355ee9b03e5d913b5496a3c39a8.
79 files changed, 1313 insertions, 2898 deletions
diff --git a/ANNOUNCE-4.1-rc1 b/ANNOUNCE-4.1 index 54e2beb2..a273b9a0 100644 --- a/ANNOUNCE-4.1-rc1 +++ b/ANNOUNCE-4.1 @@ -10,6 +10,7 @@ and via git at http://git.kernel.org/cgit/utils/mdadm/ The update constitutes more than one year of enhancements and bug fixes -including for IMSM RAID, Partial Parity Log, and clustered RAID support. +including for IMSM RAID, Partial Parity Log, clustered RAID support, +improved testing, and gcc-8 support. -Jes Sorensen, 2018-xx-xx +Jes Sorensen, 2018-10-01 @@ -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; @@ -594,6 +595,9 @@ static int load_devices(struct devs *devices, char *devmap, if (strcmp(c->update, "ppl") == 0 && ident->bitmap_fd >= 0) { pr_err("PPL is not compatible with bitmap\n"); + close(mdfd); + free(devices); + free(devmap); return -1; } @@ -708,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) { @@ -1536,6 +1542,11 @@ try_again: &most_recent, &bestcnt, &best, inargv); if (devcnt < 0) { mdfd = -3; + /* + * devices is already freed in load_devices, so set devices + * to NULL to avoid double free devices. + */ + devices = NULL; goto out; } @@ -1696,6 +1707,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; @@ -754,7 +754,8 @@ static int check_idle(struct supertype *st) for (e = ent ; e; e = e->next) { if (!is_container_member(e, container)) continue; - if (e->percent >= 0) { + /* frozen array is not idle*/ + if (e->percent >= 0 || e->metadata_version[9] == '-') { is_idle = 0; break; } @@ -1195,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; } @@ -3284,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; diff --git a/Incremental.c b/Incremental.c index 0c5698ee..d4d3c353 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) @@ -1683,6 +1686,44 @@ static void run_udisks(char *arg1, char *arg2) ; } +static int force_remove(char *devnm, int fd, struct mdinfo *mdi, int verbose) +{ + int rv; + int devid = devnm2devid(devnm); + + run_udisks("--unmount", map_dev(major(devid), minor(devid), 0)); + rv = Manage_stop(devnm, fd, verbose, 1); + if (rv) { + /* At least we can try to trigger a 'remove' */ + sysfs_uevent(mdi, "remove"); + if (verbose) + pr_err("Fail to stop %s too.\n", devnm); + } + return rv; +} + +static void remove_from_member_array(struct mdstat_ent *memb, + struct mddev_dev *devlist, int verbose) +{ + int rv; + struct mdinfo mmdi; + int subfd = open_dev(memb->devnm); + + if (subfd >= 0) { + rv = Manage_subdevs(memb->devnm, subfd, devlist, verbose, + 0, NULL, 0); + if (rv & 2) { + if (sysfs_init(&mmdi, -1, memb->devnm)) + pr_err("unable to initialize sysfs for: %s\n", + memb->devnm); + else + force_remove(memb->devnm, subfd, &mmdi, + verbose); + } + close(subfd); + } +} + /* * IncrementalRemove - Attempt to see if the passed in device belongs to any * raid arrays, and if so first fail (if needed) and then remove the device. @@ -1754,40 +1795,28 @@ int IncrementalRemove(char *devname, char *id_path, int verbose) strncmp(ent->metadata_version, "external:", 9) == 0) { struct mdstat_ent *mdstat = mdstat_read(0, 0); struct mdstat_ent *memb; - for (memb = mdstat ; memb ; memb = memb->next) - if (is_container_member(memb, ent->devnm)) { - int subfd = open_dev(memb->devnm); - if (subfd >= 0) { - rv |= Manage_subdevs( - memb->devnm, subfd, - &devlist, verbose, 0, - NULL, 0); - close(subfd); - } - } + for (memb = mdstat ; memb ; memb = memb->next) { + if (is_container_member(memb, ent->devnm)) + remove_from_member_array(memb, + &devlist, verbose); + } free_mdstat(mdstat); - } else + } else { rv |= Manage_subdevs(ent->devnm, mdfd, &devlist, verbose, 0, NULL, 0); - if (rv & 2) { + if (rv & 2) { /* Failed due to EBUSY, try to stop the array. * Give udisks a chance to unmount it first. */ - int devid = devnm2devid(ent->devnm); - run_udisks("--unmount", map_dev(major(devid),minor(devid), 0)); - rv = Manage_stop(ent->devnm, mdfd, verbose, 1); - if (rv) - /* At least we can try to trigger a 'remove' */ - sysfs_uevent(&mdi, "remove"); - if (verbose) { - if (rv) - pr_err("Fail to stop %s too.\n", ent->devnm); + rv = force_remove(ent->devnm, mdfd, &mdi, verbose); + goto end; } - } else { - devlist.disposition = 'r'; - rv = Manage_subdevs(ent->devnm, mdfd, &devlist, - verbose, 0, NULL, 0); } + + devlist.disposition = 'r'; + rv = Manage_subdevs(ent->devnm, mdfd, &devlist, + verbose, 0, NULL, 0); +end: close(mdfd); free_mdstat(ent); return rv; @@ -37,7 +37,8 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl) * Returns: * 0 - a zero superblock was successfully written out * 1 - failed to write the zero superblock - * 2 - failed to open the device or find a superblock. + * 2 - failed to open the device. + * 4 - failed to find a superblock. */ int fd, rv = 0; @@ -57,7 +58,7 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl) if (verbose >= 0) pr_err("Unrecognised md component device - %s\n", dev); close(fd); - return 2; + return 4; } st->ignore_hw_compat = 1; rv = st->ss->load_super(st, fd, dev); @@ -276,7 +276,11 @@ 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 \ + 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 ; \ $(INSTALL) -D -m 644 .install.tmp.2 $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \ @@ -28,10 +28,10 @@ #include "mdadm.h" #ifndef VERSION -#define VERSION "4.1-rc1" +#define VERSION "4.1" #endif #ifndef VERS_DATE -#define VERS_DATE "2018-03-22" +#define VERS_DATE "2018-10-01" #endif char Version[] = "mdadm - v" VERSION " - " VERS_DATE "\n"; diff --git a/debian/changelog b/debian/changelog index b5110866..f05cc9e5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +mdadm (4.1-1) unstable; urgency=medium + + * New upstream release + * Cherrypick patches from master up to 757e55435997e355ee9b03e5d913b5496a3c39a8. + + -- Dimitri John Ledkov <xnox@ubuntu.com> Tue, 15 Jan 2019 18:23:53 +0000 + mdadm (4.1~rc1-4) unstable; urgency=medium * Cherrypick master patches up to 20th of July 2018. LP: #1781427 diff --git a/debian/patches/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch b/debian/patches/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch new file mode 100644 index 00000000..cb0ca89a --- /dev/null +++ b/debian/patches/0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch @@ -0,0 +1,39 @@ +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: [PATCH 01/11] 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 a79466c6..f39c9e1c 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.19.1 + diff --git a/debian/patches/0001-mdadm-fix-use-after-free-after-free_mdstat.patch b/debian/patches/0001-mdadm-fix-use-after-free-after-free_mdstat.patch deleted file mode 100644 index 2e395e89..00000000 --- a/debian/patches/0001-mdadm-fix-use-after-free-after-free_mdstat.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 1c7c65a3e5d3e5f6d32bfa4cf0d872f87c654eb2 Mon Sep 17 00:00:00 2001 -From: Zhipeng Xie <xiezhipeng1@huawei.com> -Date: Tue, 10 Apr 2018 09:25:39 +0800 -Subject: [PATCH 01/40] mdadm: fix use-after-free after free_mdstat - -e->percent access the mdstat_ent which was already freed in free_mdstat - -Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Detail.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Detail.c b/Detail.c -index 4dcf81dd..860241ce 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -561,7 +561,6 @@ int Detail(char *dev, struct context *c) - printf(" %7s Status : %d%% complete\n", - sync_action[e->resync], e->percent); - } -- free_mdstat(ms); - - if ((st && st->sb) && (info && info->reshape_active)) { - #if 0 -@@ -609,6 +608,8 @@ This is pretty boring - printf("\n"); - } else if (e && e->percent >= 0) - printf("\n"); -+ free_mdstat(ms); -+ - if (st && st->sb) - st->ss->detail_super(st, c->homehost); - --- -2.17.1 - diff --git a/debian/patches/0001-udev.rules-make-safe-timeouts-compatible-with-split-.patch b/debian/patches/0001-udev.rules-make-safe-timeouts-compatible-with-split-.patch deleted file mode 100644 index 13613eff..00000000 --- a/debian/patches/0001-udev.rules-make-safe-timeouts-compatible-with-split-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 5ebc0b0d96e740bfaa0b514ad25425f84868328a Mon Sep 17 00:00:00 2001 -From: Dimitri John Ledkov <xnox@ubuntu.com> -Date: Mon, 23 Jul 2018 11:43:04 +0100 -Subject: [PATCH] udev.rules: make safe timeouts compatible with split-usr - systems. - -Instead of /usr/bin/sh, and /usr/bin/echo, use /bin/sh and shell -built-in echo respectively. This makes -udev-md-raid-safe-timeouts.rules to be compatible with both usr-merged -and split-usr systems alike. - -Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com> ---- - udev-md-raid-safe-timeouts.rules | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/udev-md-raid-safe-timeouts.rules b/udev-md-raid-safe-timeouts.rules -index 420c8626..13c23d84 100644 ---- a/udev-md-raid-safe-timeouts.rules -+++ b/udev-md-raid-safe-timeouts.rules -@@ -55,7 +55,7 @@ ACTION=="add|change", \ - ENV{MD_LEVEL}=="raid[1-9]*", \ - TEST=="/sys/block/$parent/device/timeout", \ - TEST=="/usr/sbin/smartctl", \ -- PROGRAM!="/usr/bin/sh -c '/usr/sbin/smartctl -l scterc /dev/$parent | grep -q seconds && exit 0 || exit 1'", \ -- RUN+="/usr/bin/sh -c '/usr/bin/echo 180 > /sys/block/$parent/device/timeout && /usr/bin/logger timeout for /dev/$parent set to 180 secs'" -+ PROGRAM!="/bin/sh -c '/usr/sbin/smartctl -l scterc /dev/$parent | grep -q seconds && exit 0 || exit 1'", \ -+ RUN+="/bin/sh -c 'echo 180 > /sys/block/$parent/device/timeout && /usr/bin/logger timeout for /dev/$parent set to 180 secs'" - - LABEL="md_timeouts_end" --- -2.17.1 - diff --git a/debian/patches/0002-Document-PART-POLICY-lines.patch b/debian/patches/0002-Document-PART-POLICY-lines.patch new file mode 100644 index 00000000..e25b1603 --- /dev/null +++ b/debian/patches/0002-Document-PART-POLICY-lines.patch @@ -0,0 +1,77 @@ +From 6b6112842030309c297a521918d1a2e982426fa3 Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.com> +Date: Fri, 9 Nov 2018 17:12:33 +1100 +Subject: [PATCH 02/11] 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 18512cb0..47c962ab 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 c0d18a7e..258f3931 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.19.1 + diff --git a/debian/patches/0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch b/debian/patches/0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch deleted file mode 100644 index 453460bb..00000000 --- a/debian/patches/0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch +++ /dev/null @@ -1,35 +0,0 @@ -From b91ad097d6eecb85cf28915836370288709fbda8 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Wed, 4 Apr 2018 14:20:17 +0200 -Subject: [PATCH 02/40] imsm: Allow create RAID volume with link to container - -After 1db03765("Subdevs can't be all missing when create raid device") -raid volume can't be created with link to container. This feature should -not be blocked in Create function. IMSM code forbids creation of -container with missing disk, so case like all dev's missing is already -handled. - -Permit IMSM volume creation when devices are given as link to container. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Create.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Create.c b/Create.c -index 50142d81..04b1dfc9 100644 ---- a/Create.c -+++ b/Create.c -@@ -475,7 +475,7 @@ int Create(struct supertype *st, char *mddev, - close(fd); - } - } -- if (missing_disks == dnum) { -+ if (missing_disks == dnum && !have_container) { - pr_err("Subdevs can't be all missing\n"); - return 1; - } --- -2.17.1 - diff --git a/debian/patches/0003-policy-support-devices-with-multiple-paths.patch b/debian/patches/0003-policy-support-devices-with-multiple-paths.patch new file mode 100644 index 00000000..a3776382 --- /dev/null +++ b/debian/patches/0003-policy-support-devices-with-multiple-paths.patch @@ -0,0 +1,334 @@ +From cd72f9d114da206baa01fd56ff2d8ffcc08f3239 Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.com> +Date: Fri, 9 Nov 2018 17:12:33 +1100 +Subject: [PATCH 03/11] 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 a4ff7d4b..d4d3c353 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 387e681a..705bd9b5 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 258f3931..fa67d559 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.19.1 + diff --git a/debian/patches/0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch b/debian/patches/0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch deleted file mode 100644 index c4ceadf6..00000000 --- a/debian/patches/0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 59416da78fc66084f721163b914913dc1da37b44 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Wed, 11 Apr 2018 17:01:50 -0400 -Subject: [PATCH 03/40] tests/func.sh: Fix some total breakage in the test - scripts - -We will never mandate an obsolete file system such as ext[2-4] for -running the test suite, nor should the test version of mdadm be -installed on the system for the tests to be run. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> -Fixes: 20d10b4be873ba ("mdadm/test: Refactor and revamp 'test' script") ---- - test | 2 +- - tests/func.sh | 22 +++------------------- - 2 files changed, 4 insertions(+), 20 deletions(-) - -diff --git a/test b/test -index 111a2e74..711a3c7a 100755 ---- a/test -+++ b/test -@@ -5,7 +5,7 @@ mdadm=$PWD/mdadm - targetdir="/var/tmp" - logdir="$targetdir" - config=/tmp/mdadm.conf --testdir= -+testdir=$PWD/tests - devlist= - - savelogs=0 -diff --git a/tests/func.sh b/tests/func.sh -index a6995f1b..9710a53b 100644 ---- a/tests/func.sh -+++ b/tests/func.sh -@@ -101,8 +101,8 @@ check_env() { - echo "test: testing can only be done as 'root'." - exit 1 - } -- [ -x "raid6check" -a -x $mdadm ] || { -- echo "test: please run 'make everything' before perform testing." -+ [ \! -x $mdadm ] && { -+ echo "test: please run make everything before perform testing." - exit 1 - } - cmds=(mdadm lsblk df udevadm losetup mkfs.ext3 fsck seq) -@@ -113,23 +113,6 @@ check_env() { - exit 1 - } - done -- mdadm_src_ver="$($mdadm -V 2>&1)" -- mdadm_sbin_ver="$($(which mdadm) -V 2>&1)" -- if [ "$mdadm_src_ver" != "$mdadm_sbin_ver" ] -- then -- # it's nessesary to 'make install' mdadm to /SBIN/DIR, -- # such as systemd/mdadm-grow-continue@.service, would -- # run as an instance by systemd when reshape happens, -- # thus ensure that the correct mdadm is in testing. -- echo "test: please run 'make install' before testing." -- exit 1 -- fi -- if ! $(df -T . | grep -iq ext) -- then -- # 'external file' bitmap only supports with ext[2-4] file system -- echo "test: please run test suite with ext[2-4] file system." -- exit 1 -- fi - if $(lsblk -a | grep -iq raid) - then - # donot run mdadm -Ss directly if there are RAIDs working. -@@ -231,6 +214,7 @@ check() { - if [ $? -eq 0 ]; then - die "This command shouldn't run successfully" - fi -+ ;; - spares ) - spares=$(tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0) - [ $spares -ne $2 ] && --- -2.17.1 - diff --git a/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch b/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch deleted file mode 100644 index 22e3d216..00000000 --- a/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 611d95290dd41d73bd8f9cc06f7ec293a40b819e Mon Sep 17 00:00:00 2001 -From: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Date: Thu, 5 Apr 2018 13:38:35 +0200 -Subject: [PATCH 04/40] imsm: change reserved space to 4MB - -Due to compatibility to the newest OROM, imsm reserved space has to be -expanded to 4MB. - -Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index fb1b6936..52011e5b 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -88,8 +88,8 @@ - #define MPB_ATTRIB_IGNORED (MPB_ATTRIB_NEVER_USE) - - #define MPB_SECTOR_CNT 2210 --#define IMSM_RESERVED_SECTORS 4096 --#define NUM_BLOCKS_DIRTY_STRIPE_REGION 2056 -+#define IMSM_RESERVED_SECTORS 8192 -+#define NUM_BLOCKS_DIRTY_STRIPE_REGION 2048 - #define SECT_PER_MB_SHIFT 11 - #define MAX_SECTOR_SIZE 4096 - #define MULTIPLE_PPL_AREA_SIZE_IMSM (1024 * 1024) /* Size of the whole --- -2.17.1 - diff --git a/debian/patches/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch b/debian/patches/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch new file mode 100644 index 00000000..69dc281a --- /dev/null +++ b/debian/patches/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch @@ -0,0 +1,137 @@ +From 4199d3c629c14866505923d19fa50017ee92d2e1 Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.com> +Date: Wed, 5 Dec 2018 16:35:00 +1100 +Subject: [PATCH 04/11] 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 2767ac68..afb62cc6 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 00000000..592c6079 +--- /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 00000000..3ccfd785 +--- /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 00000000..812141bb +--- /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 00000000..64807362 +--- /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.19.1 + diff --git a/debian/patches/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch b/debian/patches/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch new file mode 100644 index 00000000..fe63bd77 --- /dev/null +++ b/debian/patches/0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch @@ -0,0 +1,82 @@ +From 7cd7e91ab3de5aa75dc963cb08b0618c1885cf0d Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.com> +Date: Wed, 5 Dec 2018 16:35:00 +1100 +Subject: [PATCH 05/11] 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 afb62cc6..dfe00b0a 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 00000000..fd469b12 +--- /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 00000000..cb54bdaa +--- /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.19.1 + diff --git a/debian/patches/0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch b/debian/patches/0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch deleted file mode 100644 index 8e36bce5..00000000 --- a/debian/patches/0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch +++ /dev/null @@ -1,136 +0,0 @@ -From fcc2c9daede11fcc67e4032fd6fa8da198aaa319 Mon Sep 17 00:00:00 2001 -From: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Date: Thu, 5 Apr 2018 13:38:36 +0200 -Subject: [PATCH 05/40] imsm: add functions to get and set imsm dev size - -Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 41 +++++++++++++++++++++-------------------- - 1 file changed, 21 insertions(+), 20 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 52011e5b..fe2a705b 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1201,6 +1201,13 @@ static unsigned long long num_data_stripes(struct imsm_map *map) - return join_u32(map->num_data_stripes_lo, map->num_data_stripes_hi); - } - -+static unsigned long long imsm_dev_size(struct imsm_dev *dev) -+{ -+ if (dev == NULL) -+ return 0; -+ return join_u32(dev->size_low, dev->size_high); -+} -+ - static void set_total_blocks(struct imsm_disk *disk, unsigned long long n) - { - split_ull(n, &disk->total_blocks_lo, &disk->total_blocks_hi); -@@ -1221,6 +1228,11 @@ static void set_num_data_stripes(struct imsm_map *map, unsigned long long n) - split_ull(n, &map->num_data_stripes_lo, &map->num_data_stripes_hi); - } - -+static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n) -+{ -+ split_ull(n, &dev->size_low, &dev->size_high); -+} -+ - static struct extent *get_extents(struct intel_super *super, struct dl *dl) - { - /* find a list of used extents on the given physical device */ -@@ -1503,9 +1515,7 @@ static void print_imsm_dev(struct intel_super *super, - } else - printf(" This Slot : ?\n"); - printf(" Sector Size : %u\n", super->sector_size); -- sz = __le32_to_cpu(dev->size_high); -- sz <<= 32; -- sz += __le32_to_cpu(dev->size_low); -+ sz = imsm_dev_size(dev); - printf(" Array Size : %llu%s\n", - (unsigned long long)sz * 512 / super->sector_size, - human_size(sz * 512)); -@@ -1634,8 +1644,7 @@ void convert_to_4k(struct intel_super *super) - struct imsm_dev *dev = __get_imsm_dev(mpb, i); - struct imsm_map *map = get_imsm_map(dev, MAP_0); - /* dev */ -- split_ull((join_u32(dev->size_low, dev->size_high)/IMSM_4K_DIV), -- &dev->size_low, &dev->size_high); -+ set_imsm_dev_size(dev, imsm_dev_size(dev)/IMSM_4K_DIV); - dev->vol.curr_migr_unit /= IMSM_4K_DIV; - - /* map0 */ -@@ -1762,8 +1771,7 @@ void convert_from_4k(struct intel_super *super) - struct imsm_dev *dev = __get_imsm_dev(mpb, i); - struct imsm_map *map = get_imsm_map(dev, MAP_0); - /* dev */ -- split_ull((join_u32(dev->size_low, dev->size_high)*IMSM_4K_DIV), -- &dev->size_low, &dev->size_high); -+ set_imsm_dev_size(dev, imsm_dev_size(dev)*IMSM_4K_DIV); - dev->vol.curr_migr_unit *= IMSM_4K_DIV; - - /* map0 */ -@@ -3240,9 +3248,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - info->array.chunk_size = - __le16_to_cpu(map_to_analyse->blocks_per_strip) << 9; - info->array.state = !(dev->vol.dirty & RAIDVOL_DIRTY); -- info->custom_array_size = __le32_to_cpu(dev->size_high); -- info->custom_array_size <<= 32; -- info->custom_array_size |= __le32_to_cpu(dev->size_low); -+ info->custom_array_size = imsm_dev_size(dev); - info->recovery_blocked = imsm_reshape_blocks_arrays_changes(st->sb); - - if (is_gen_migration(dev)) { -@@ -5370,8 +5376,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - array_blocks = round_size_to_mb(array_blocks, data_disks); - size_per_member = array_blocks / data_disks; - -- dev->size_low = __cpu_to_le32((__u32) array_blocks); -- dev->size_high = __cpu_to_le32((__u32) (array_blocks >> 32)); -+ set_imsm_dev_size(dev, array_blocks); - dev->status = (DEV_READ_COALESCING | DEV_WRITE_COALESCING); - vol = &dev->vol; - vol->migr_state = 0; -@@ -7733,7 +7738,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - level, /* RAID level */ - imsm_level_to_layout(level), - map->num_members, /* raid disks */ -- &chunk, join_u32(dev->size_low, dev->size_high), -+ &chunk, imsm_dev_size(dev), - 1 /* verbose */)) { - pr_err("IMSM RAID geometry validation failed. Array %s activation is blocked.\n", - dev->volume); -@@ -8143,9 +8148,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev, - /* when problems occures - * return current array_blocks value - */ -- array_blocks = __le32_to_cpu(dev->size_high); -- array_blocks = array_blocks << 32; -- array_blocks += __le32_to_cpu(dev->size_low); -+ array_blocks = imsm_dev_size(dev); - - return array_blocks; - } -@@ -8165,8 +8168,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev, - } - - array_blocks = round_size_to_mb(array_blocks, used_disks); -- dev->size_low = __cpu_to_le32((__u32)array_blocks); -- dev->size_high = __cpu_to_le32((__u32)(array_blocks >> 32)); -+ set_imsm_dev_size(dev, array_blocks); - - return array_blocks; - } -@@ -9139,8 +9141,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration * - map->blocks_per_strip = - __cpu_to_le16(u->new_chunksize * 2); - num_data_stripes = -- (join_u32(dev->size_low, dev->size_high) -- / used_disks); -+ imsm_dev_size(dev) / used_disks; - num_data_stripes /= map->blocks_per_strip; - num_data_stripes /= map->num_domains; - set_num_data_stripes(map, num_data_stripes); --- -2.17.1 - diff --git a/debian/patches/0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch b/debian/patches/0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch deleted file mode 100644 index 1a642698..00000000 --- a/debian/patches/0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch +++ /dev/null @@ -1,179 +0,0 @@ -From 9529d3436771d9f38884861683dee3b40ab9d180 Mon Sep 17 00:00:00 2001 -From: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Date: Thu, 5 Apr 2018 13:38:37 +0200 -Subject: [PATCH 06/40] imsm: pass already existing map to - imsm_num_data_members - -In almost every place where imsm_num_data_members is called there is -already existing map so it can be used it to avoid mistake when specifying -map for imsm_num_data_members. - -Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 41 +++++++++++++++++++++-------------------- - 1 file changed, 21 insertions(+), 20 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index fe2a705b..3fc3cf4c 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -2767,13 +2767,11 @@ static __u32 num_stripes_per_unit_rebuild(struct imsm_dev *dev) - return num_stripes_per_unit_resync(dev); - } - --static __u8 imsm_num_data_members(struct imsm_dev *dev, int second_map) -+static __u8 imsm_num_data_members(struct imsm_map *map) - { - /* named 'imsm_' because raid0, raid1 and raid10 - * counter-intuitively have the same number of data disks - */ -- struct imsm_map *map = get_imsm_map(dev, second_map); -- - switch (get_imsm_raid_level(map)) { - case 0: - return map->num_members; -@@ -2862,7 +2860,7 @@ static __u64 blocks_per_migr_unit(struct intel_super *super, - */ - stripes_per_unit = num_stripes_per_unit_resync(dev); - migr_chunk = migr_strip_blocks_resync(dev); -- disks = imsm_num_data_members(dev, MAP_0); -+ disks = imsm_num_data_members(map); - blocks_per_unit = stripes_per_unit * migr_chunk * disks; - stripe = __le16_to_cpu(map->blocks_per_strip) * disks; - segment = blocks_per_unit / stripe; -@@ -3381,7 +3379,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - (unsigned long long)blocks_per_unit, - info->reshape_progress); - -- used_disks = imsm_num_data_members(dev, MAP_1); -+ used_disks = imsm_num_data_members(prev_map); - if (used_disks > 0) { - array_blocks = blocks_per_member(map) * - used_disks; -@@ -8140,9 +8138,9 @@ static void handle_missing(struct intel_super *super, struct imsm_dev *dev) - static unsigned long long imsm_set_array_size(struct imsm_dev *dev, - long long new_size) - { -- int used_disks = imsm_num_data_members(dev, MAP_0); - unsigned long long array_blocks; -- struct imsm_map *map; -+ struct imsm_map *map = get_imsm_map(dev, MAP_0); -+ int used_disks = imsm_num_data_members(map); - - if (used_disks == 0) { - /* when problems occures -@@ -8155,17 +8153,15 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev, - - /* set array size in metadata - */ -- if (new_size <= 0) { -+ if (new_size <= 0) - /* OLCE size change is caused by added disks - */ -- map = get_imsm_map(dev, MAP_0); - array_blocks = blocks_per_member(map) * used_disks; -- } else { -+ else - /* Online Volume Size Change - * Using available free space - */ - array_blocks = new_size; -- } - - array_blocks = round_size_to_mb(array_blocks, used_disks); - set_imsm_dev_size(dev, array_blocks); -@@ -8274,7 +8270,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent) - int used_disks; - struct mdinfo *mdi; - -- used_disks = imsm_num_data_members(dev, MAP_0); -+ used_disks = imsm_num_data_members(map); - if (used_disks > 0) { - array_blocks = - blocks_per_member(map) * -@@ -9132,8 +9128,10 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration * - */ - if (u->new_chunksize > 0) { - unsigned long long num_data_stripes; -+ struct imsm_map *dest_map = -+ get_imsm_map(dev, MAP_0); - int used_disks = -- imsm_num_data_members(dev, MAP_0); -+ imsm_num_data_members(dest_map); - - if (used_disks == 0) - return ret_val; -@@ -9210,7 +9208,7 @@ static int apply_size_change_update(struct imsm_update_size_change *u, - if (id->index == (unsigned)u->subdev) { - struct imsm_dev *dev = get_imsm_dev(super, u->subdev); - struct imsm_map *map = get_imsm_map(dev, MAP_0); -- int used_disks = imsm_num_data_members(dev, MAP_0); -+ int used_disks = imsm_num_data_members(map); - unsigned long long blocks_per_member; - unsigned long long num_data_stripes; - -@@ -10589,7 +10587,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev, - max(map_dest->blocks_per_strip, map_src->blocks_per_strip); - migr_rec->dest_depth_per_unit *= - max(map_dest->blocks_per_strip, map_src->blocks_per_strip); -- new_data_disks = imsm_num_data_members(dev, MAP_0); -+ new_data_disks = imsm_num_data_members(map_dest); - migr_rec->blocks_per_unit = - __cpu_to_le32(migr_rec->dest_depth_per_unit * new_data_disks); - migr_rec->dest_depth_per_unit = -@@ -10657,7 +10655,7 @@ int save_backup_imsm(struct supertype *st, - int dest_layout = 0; - int dest_chunk; - unsigned long long start; -- int data_disks = imsm_num_data_members(dev, MAP_0); -+ int data_disks = imsm_num_data_members(map_dest); - - targets = xmalloc(new_disks * sizeof(int)); - -@@ -11279,6 +11277,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - int imsm_layout = -1; - int data_disks; - struct imsm_dev *dev; -+ struct imsm_map *map; - struct intel_super *super; - unsigned long long current_size; - unsigned long long free_size; -@@ -11369,7 +11368,8 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - - super = st->sb; - dev = get_imsm_dev(super, super->current_vol); -- data_disks = imsm_num_data_members(dev , MAP_0); -+ map = get_imsm_map(dev, MAP_0); -+ data_disks = imsm_num_data_members(map); - /* compute current size per disk member - */ - current_size = info.custom_array_size / data_disks; -@@ -11838,7 +11838,7 @@ static int imsm_manage_reshape( - struct intel_dev *dv; - unsigned int sector_size = super->sector_size; - struct imsm_dev *dev = NULL; -- struct imsm_map *map_src; -+ struct imsm_map *map_src, *map_dest; - int migr_vol_qan = 0; - int ndata, odata; /* [bytes] */ - int chunk; /* [bytes] */ -@@ -11876,12 +11876,13 @@ static int imsm_manage_reshape( - goto abort; - } - -+ map_dest = get_imsm_map(dev, MAP_0); - map_src = get_imsm_map(dev, MAP_1); - if (map_src == NULL) - goto abort; - -- ndata = imsm_num_data_members(dev, MAP_0); -- odata = imsm_num_data_members(dev, MAP_1); -+ ndata = imsm_num_data_members(map_dest); -+ odata = imsm_num_data_members(map_src); - - chunk = __le16_to_cpu(map_src->blocks_per_strip) * 512; - old_data_stripe_length = odata * chunk; --- -2.17.1 - diff --git a/debian/patches/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch b/debian/patches/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch new file mode 100644 index 00000000..903d082d --- /dev/null +++ b/debian/patches/0006-imsm-update-metadata-correctly-while-raid10-double-d.patch @@ -0,0 +1,83 @@ +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: [PATCH 06/11] 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 6438987b..d2035ccd 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.19.1 + diff --git a/debian/patches/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch b/debian/patches/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch new file mode 100644 index 00000000..22489a55 --- /dev/null +++ b/debian/patches/0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch @@ -0,0 +1,43 @@ +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: [PATCH 07/11] 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 f39c9e1c..9f75c68c 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.19.1 + diff --git a/debian/patches/0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch b/debian/patches/0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch deleted file mode 100644 index 76b81a9b..00000000 --- a/debian/patches/0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch +++ /dev/null @@ -1,266 +0,0 @@ -From 444909385fdaccf961308c4319d7029b82bf8bb1 Mon Sep 17 00:00:00 2001 -From: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Date: Thu, 5 Apr 2018 13:38:38 +0200 -Subject: [PATCH 07/40] imsm: do not use blocks_per_member in array size - calculations - -mdadm assumes that blocks_per_member value is equal to num_data_stripes * -blocks_per_stripe but it is not true. For IMSM arrays created in OROM -NUM_BLOCKS_DIRTY_STRIPE_REGION sectors are added up to this value. Because -of this mdadm shows invalid size of arrays created in OROM and to fix this -we need to use array size calculation based on num data stripes and blocks -per stripe. - -Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 105 ++++++++++++++++++++++++++++++++++++-------------- - 1 file changed, 76 insertions(+), 29 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 3fc3cf4c..c55c85f1 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1233,6 +1233,20 @@ static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n) - split_ull(n, &dev->size_low, &dev->size_high); - } - -+static unsigned long long per_dev_array_size(struct imsm_map *map) -+{ -+ unsigned long long array_size = 0; -+ -+ if (map == NULL) -+ return array_size; -+ -+ array_size = num_data_stripes(map) * map->blocks_per_strip; -+ if (get_imsm_raid_level(map) == 1 || get_imsm_raid_level(map) == 10) -+ array_size *= 2; -+ -+ return array_size; -+} -+ - static struct extent *get_extents(struct intel_super *super, struct dl *dl) - { - /* find a list of used extents on the given physical device */ -@@ -1259,7 +1273,7 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl) - - if (get_imsm_disk_slot(map, dl->index) >= 0) { - e->start = pba_of_lba0(map); -- e->size = blocks_per_member(map); -+ e->size = per_dev_array_size(map); - e++; - } - } -@@ -2787,6 +2801,36 @@ static __u8 imsm_num_data_members(struct imsm_map *map) - } - } - -+static unsigned long long calc_component_size(struct imsm_map *map, -+ struct imsm_dev *dev) -+{ -+ unsigned long long component_size; -+ unsigned long long dev_size = imsm_dev_size(dev); -+ unsigned long long calc_dev_size = 0; -+ unsigned int member_disks = imsm_num_data_members(map); -+ -+ if (member_disks == 0) -+ return 0; -+ -+ component_size = per_dev_array_size(map); -+ calc_dev_size = component_size * member_disks; -+ -+ /* Component size is rounded to 1MB so difference between size from -+ * metadata and size calculated from num_data_stripes equals up to -+ * 2048 blocks per each device. If the difference is higher it means -+ * that array size was expanded and num_data_stripes was not updated. -+ */ -+ if ((unsigned int)abs(calc_dev_size - dev_size) > -+ (1 << SECT_PER_MB_SHIFT) * member_disks) { -+ component_size = dev_size / member_disks; -+ dprintf("Invalid num_data_stripes in metadata; expected=%llu, found=%llu\n", -+ component_size / map->blocks_per_strip, -+ num_data_stripes(map)); -+ } -+ -+ return component_size; -+} -+ - static __u32 parity_segment_depth(struct imsm_dev *dev) - { - struct imsm_map *map = get_imsm_map(dev, MAP_0); -@@ -3306,14 +3350,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - } - - info->data_offset = pba_of_lba0(map_to_analyse); -- -- if (info->array.level == 5) { -- info->component_size = num_data_stripes(map_to_analyse) * -- map_to_analyse->blocks_per_strip; -- } else { -- info->component_size = blocks_per_member(map_to_analyse); -- } -- -+ info->component_size = calc_component_size(map, dev); - info->component_size = imsm_component_size_aligment_check( - info->array.level, - info->array.chunk_size, -@@ -3381,7 +3418,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - - used_disks = imsm_num_data_members(prev_map); - if (used_disks > 0) { -- array_blocks = blocks_per_member(map) * -+ array_blocks = per_dev_array_size(map) * - used_disks; - info->custom_array_size = - round_size_to_mb(array_blocks, -@@ -5383,9 +5420,6 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - vol->curr_migr_unit = 0; - map = get_imsm_map(dev, MAP_0); - set_pba_of_lba0(map, super->create_offset); -- set_blocks_per_member(map, info_to_blocks_per_member(info, -- size_per_member / -- BLOCKS_PER_KB)); - map->blocks_per_strip = __cpu_to_le16(info_to_blocks_per_strip(info)); - map->failed_disk_num = ~0; - if (info->level > 0) -@@ -5417,6 +5451,11 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - num_data_stripes /= map->num_domains; - set_num_data_stripes(map, num_data_stripes); - -+ size_per_member += NUM_BLOCKS_DIRTY_STRIPE_REGION; -+ set_blocks_per_member(map, info_to_blocks_per_member(info, -+ size_per_member / -+ BLOCKS_PER_KB)); -+ - map->num_members = info->raid_disks; - for (i = 0; i < map->num_members; i++) { - /* initialized in add_to_super */ -@@ -7821,18 +7860,14 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra - - info_d->events = __le32_to_cpu(mpb->generation_num); - info_d->data_offset = pba_of_lba0(map); -+ info_d->component_size = calc_component_size(map, dev); - - if (map->raid_level == 5) { -- info_d->component_size = -- num_data_stripes(map) * -- map->blocks_per_strip; - info_d->ppl_sector = this->ppl_sector; - info_d->ppl_size = this->ppl_size; - if (this->consistency_policy == CONSISTENCY_POLICY_PPL && - recovery_start == 0) - this->resync_start = 0; -- } else { -- info_d->component_size = blocks_per_member(map); - } - - info_d->bb.supported = 1; -@@ -8156,7 +8191,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev, - if (new_size <= 0) - /* OLCE size change is caused by added disks - */ -- array_blocks = blocks_per_member(map) * used_disks; -+ array_blocks = per_dev_array_size(map) * used_disks; - else - /* Online Volume Size Change - * Using available free space -@@ -8273,7 +8308,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent) - used_disks = imsm_num_data_members(map); - if (used_disks > 0) { - array_blocks = -- blocks_per_member(map) * -+ per_dev_array_size(map) * - used_disks; - array_blocks = - round_size_to_mb(array_blocks, -@@ -8715,11 +8750,11 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot, - pos = 0; - array_start = pba_of_lba0(map); - array_end = array_start + -- blocks_per_member(map) - 1; -+ per_dev_array_size(map) - 1; - - do { - /* check that we can start at pba_of_lba0 with -- * blocks_per_member of space -+ * num_data_stripes*blocks_per_stripe of space - */ - if (array_start >= pos && array_end < ex[j].start) { - found = 1; -@@ -9145,6 +9180,12 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration * - set_num_data_stripes(map, num_data_stripes); - } - -+ /* ensure blocks_per_member has valid value -+ */ -+ set_blocks_per_member(map, -+ per_dev_array_size(map) + -+ NUM_BLOCKS_DIRTY_STRIPE_REGION); -+ - /* add disk - */ - if (u->new_level != 5 || migr_map->raid_level != 0 || -@@ -9211,15 +9252,21 @@ static int apply_size_change_update(struct imsm_update_size_change *u, - int used_disks = imsm_num_data_members(map); - unsigned long long blocks_per_member; - unsigned long long num_data_stripes; -+ unsigned long long new_size_per_disk; -+ -+ if (used_disks == 0) -+ return 0; - - /* calculate new size - */ -- blocks_per_member = u->new_size / used_disks; -- num_data_stripes = blocks_per_member / -+ new_size_per_disk = u->new_size / used_disks; -+ blocks_per_member = new_size_per_disk + -+ NUM_BLOCKS_DIRTY_STRIPE_REGION; -+ num_data_stripes = new_size_per_disk / - map->blocks_per_strip; - num_data_stripes /= map->num_domains; - dprintf("(size: %llu, blocks per member: %llu, num_data_stipes: %llu)\n", -- u->new_size, blocks_per_member, -+ u->new_size, new_size_per_disk, - num_data_stripes); - set_blocks_per_member(map, blocks_per_member); - set_num_data_stripes(map, num_data_stripes); -@@ -9476,7 +9523,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u, - unsigned long long num_data_stripes; - - map->num_domains = 1; -- num_data_stripes = blocks_per_member(map); -+ num_data_stripes = imsm_dev_size(dev) / 2; - num_data_stripes /= map->blocks_per_strip; - num_data_stripes /= map->num_domains; - set_num_data_stripes(map, num_data_stripes); -@@ -9692,7 +9739,7 @@ static void imsm_process_update(struct supertype *st, - - new_map = get_imsm_map(&u->dev, MAP_0); - new_start = pba_of_lba0(new_map); -- new_end = new_start + blocks_per_member(new_map); -+ new_end = new_start + per_dev_array_size(new_map); - inf = get_disk_info(u); - - /* handle activate_spare versus create race: -@@ -9703,7 +9750,7 @@ static void imsm_process_update(struct supertype *st, - dev = get_imsm_dev(super, i); - map = get_imsm_map(dev, MAP_0); - start = pba_of_lba0(map); -- end = start + blocks_per_member(map); -+ end = start + per_dev_array_size(map); - if ((new_start >= start && new_start <= end) || - (start >= new_start && start <= new_end)) - /* overlap */; -@@ -10492,7 +10539,7 @@ static struct md_bb *imsm_get_badblocks(struct active_array *a, int slot) - return NULL; - - get_volume_badblocks(super->bbm_log, ord_to_idx(ord), pba_of_lba0(map), -- blocks_per_member(map), &super->bb); -+ per_dev_array_size(map), &super->bb); - - return &super->bb; - } --- -2.17.1 - diff --git a/debian/patches/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch b/debian/patches/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch new file mode 100644 index 00000000..37029c1d --- /dev/null +++ b/debian/patches/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch @@ -0,0 +1,34 @@ +From 085df42259cba7863cd6ebe5cd0d8492ac5b869e Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.com> +Date: Thu, 6 Dec 2018 10:35:41 +1100 +Subject: [PATCH 08/11] 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 4436a4d6..76f82c07 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.19.1 + diff --git a/debian/patches/0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch b/debian/patches/0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch deleted file mode 100644 index 690d05a6..00000000 --- a/debian/patches/0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 54865c30d5b94920318950e29a4f6c1ce075cae8 Mon Sep 17 00:00:00 2001 -From: Roman Sobanski <roman.sobanski@intel.com> -Date: Wed, 25 Apr 2018 11:25:06 +0200 -Subject: [PATCH 08/40] Prevent create IMSM volume with size smaller than 1M or - chunk - -Block creation of the imsm volume when given size is smaller than 1M and -print appropriate message. - -Commit b53bfba6119d3f6f56eb9e10e5a59da6901af159 -(imsm: use rounded size for metadata initialization) introduces issue with -rounding volume sizes smaller than 1M to 0. There is an inconsistency when -size smaller than 1M was given depends of what we give as target device: -1) When block devices was given created volume has maximum available size. -2) When container symlink was given created volume has size 0. Additionally -it causes below call trace: - -[69587.891556] WARNING: CPU: 28 PID: 22485 at ../drivers/md/md.c:7582 md_seq_show+0x764/0x770 [md_mod] -[69588.066405] Call Trace: -[69588.066409] seq_read+0x336/0x430 -[69588.066411] proc_reg_read+0x40/0x70 -[69588.066412] __vfs_read+0x26/0x140 -[69588.066414] vfs_read+0x89/0x130 -[69588.066415] SyS_read+0x42/0x90 -[69588.066417] do_syscall_64+0x74/0x140 -[69588.066419] entry_SYSCALL_64_after_hwframe+0x3d/0xa2 - -Signed-off-by: Roman Sobanski <roman.sobanski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index c55c85f1..520abf5d 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7358,6 +7358,16 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, - verbose); - } - -+ if (size && ((size < 1024) || (*chunk != UnSet && -+ size < (unsigned long long) *chunk))) { -+ pr_err("Given size must be greater than 1M and chunk size.\n"); -+ /* Depends on algorithm in Create.c : -+ * if container was given (dev == NULL) return -1, -+ * if block device was given ( dev != NULL) return 0. -+ */ -+ return dev ? -1 : 0; -+ } -+ - if (!dev) { - if (st->sb) { - struct intel_super *super = st->sb; --- -2.17.1 - diff --git a/debian/patches/0009-Grow-report-correct-new-chunk-size.patch b/debian/patches/0009-Grow-report-correct-new-chunk-size.patch new file mode 100644 index 00000000..26733488 --- /dev/null +++ b/debian/patches/0009-Grow-report-correct-new-chunk-size.patch @@ -0,0 +1,30 @@ +From 76d505dec6c9f92564553596fc8350324be82463 Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.com> +Date: Thu, 6 Dec 2018 10:36:28 +1100 +Subject: [PATCH 09/11] 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 76f82c07..363b209d 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.19.1 + diff --git a/debian/patches/0009-mdadm-grow-correct-size-and-chunk_size-casting.patch b/debian/patches/0009-mdadm-grow-correct-size-and-chunk_size-casting.patch deleted file mode 100644 index cdaed497..00000000 --- a/debian/patches/0009-mdadm-grow-correct-size-and-chunk_size-casting.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 5d518de84e7cd3382b4984cc1243ddb4102aa4f4 Mon Sep 17 00:00:00 2001 -From: Roman Sobanski <roman.sobanski@intel.com> -Date: Fri, 27 Apr 2018 12:12:21 +0200 -Subject: [PATCH 09/40] mdadm/grow: correct size and chunk_size casting - -With commit 4b74a905a67e -("mdadm/grow: Component size must be larger than chunk size") mdadm returns -incorrect message if size given to grow was greater than 2 147 483 647 K. -Cast chunk_size to "unsigned long long" instead of casting size to "int". - -Signed-off-by: Roman Sobanski <roman.sobanski@intel.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 87229692..a4be7e7b 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -1821,7 +1821,7 @@ int Grow_reshape(char *devname, int fd, - } - - if (array.level > 1 && s->size > 1 && -- (array.chunk_size / 1024) > (int)s->size) { -+ (unsigned long long) (array.chunk_size / 1024) > s->size) { - pr_err("component size must be larger than chunk size.\n"); - return 1; - } --- -2.17.1 - diff --git a/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch b/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch deleted file mode 100644 index 0c410e62..00000000 --- a/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 3e684231ebe10c08e7cf23743d4516f707e605a2 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Tue, 29 May 2018 15:46:40 +0200 -Subject: [PATCH 10/40] Fix misspelling of 'alignment' and 'geometry' - -Set gemetry to geometry in error message about geometry validation failed. -Fix misspelled 'alignment' word in imsm_component_size_alignment_check -function. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 30 +++++++++++++++--------------- - 1 file changed, 15 insertions(+), 15 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 520abf5d..ce08af47 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -3228,27 +3228,27 @@ int imsm_reshape_blocks_arrays_changes(struct intel_super *super) - } - return rv; - } --static unsigned long long imsm_component_size_aligment_check(int level, -+static unsigned long long imsm_component_size_alignment_check(int level, - int chunk_size, - unsigned int sector_size, - unsigned long long component_size) - { -- unsigned int component_size_alligment; -+ unsigned int component_size_alignment; - -- /* check component size aligment -+ /* check component size alignment - */ -- component_size_alligment = component_size % (chunk_size/sector_size); -+ component_size_alignment = component_size % (chunk_size/sector_size); - -- dprintf("(Level: %i, chunk_size = %i, component_size = %llu), component_size_alligment = %u\n", -+ dprintf("(Level: %i, chunk_size = %i, component_size = %llu), component_size_alignment = %u\n", - level, chunk_size, component_size, -- component_size_alligment); -+ component_size_alignment); - -- if (component_size_alligment && (level != 1) && (level != UnSet)) { -- dprintf("imsm: reported component size alligned from %llu ", -+ if (component_size_alignment && (level != 1) && (level != UnSet)) { -+ dprintf("imsm: reported component size aligned from %llu ", - component_size); -- component_size -= component_size_alligment; -+ component_size -= component_size_alignment; - dprintf_cont("to %llu (%i).\n", -- component_size, component_size_alligment); -+ component_size, component_size_alignment); - } - - return component_size; -@@ -3351,7 +3351,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, - - info->data_offset = pba_of_lba0(map_to_analyse); - info->component_size = calc_component_size(map, dev); -- info->component_size = imsm_component_size_aligment_check( -+ info->component_size = imsm_component_size_alignment_check( - info->array.level, - info->array.chunk_size, - super->sector_size, -@@ -7089,7 +7089,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, - mpb = super->anchor; - - if (!validate_geometry_imsm_orom(super, level, layout, raiddisks, chunk, size, verbose)) { -- pr_err("RAID gemetry validation failed. Cannot proceed with the action(s).\n"); -+ pr_err("RAID geometry validation failed. Cannot proceed with the action(s).\n"); - return 0; - } - if (!dev) { -@@ -11434,7 +11434,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - if (geo->size > 0 && geo->size != MAX_SIZE) { - /* align component size - */ -- geo->size = imsm_component_size_aligment_check( -+ geo->size = imsm_component_size_alignment_check( - get_imsm_raid_level(dev->vol.map), - chunk * 1024, super->sector_size, - geo->size * 2); -@@ -11468,7 +11468,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, - max_size = free_size + current_size; - /* align component size - */ -- max_size = imsm_component_size_aligment_check( -+ max_size = imsm_component_size_alignment_check( - get_imsm_raid_level(dev->vol.map), - chunk * 1024, super->sector_size, - max_size); -@@ -11970,7 +11970,7 @@ static int imsm_manage_reshape( - buf_size = __le32_to_cpu(migr_rec->blocks_per_unit) * 512; - /* extend buffer size for parity disk */ - buf_size += __le32_to_cpu(migr_rec->dest_depth_per_unit) * 512; -- /* add space for stripe aligment */ -+ /* add space for stripe alignment */ - buf_size += old_data_stripe_length; - if (posix_memalign((void **)&buf, MAX_SECTOR_SIZE, buf_size)) { - dprintf("imsm: Cannot allocate checkpoint buffer\n"); --- -2.17.1 - diff --git a/debian/patches/0010-policy.c-prevent-NULL-pointer-referencing.patch b/debian/patches/0010-policy.c-prevent-NULL-pointer-referencing.patch new file mode 100644 index 00000000..090e6597 --- /dev/null +++ b/debian/patches/0010-policy.c-prevent-NULL-pointer-referencing.patch @@ -0,0 +1,31 @@ +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: [PATCH 10/11] 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 fa67d559..e3a0671f 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.19.1 + diff --git a/debian/patches/0011-Do-not-confuse-gcc.patch b/debian/patches/0011-Do-not-confuse-gcc.patch deleted file mode 100644 index 5e288fd5..00000000 --- a/debian/patches/0011-Do-not-confuse-gcc.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 760365f94409ccccbcb54d55070f0f422bee44a1 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Tue, 29 May 2018 15:52:48 -0400 -Subject: [PATCH 11/40] Do not confuse gcc - -gcc-8.1's -Werror=stringop-truncation is easily confused. Rather than -disabling the check, make it explicit we are OK truncating here. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index ce08af47..449da1dd 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -5323,6 +5323,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - struct imsm_map *map; - int idx = mpb->num_raid_devs; - int i; -+ int namelen; - unsigned long long array_blocks; - size_t size_old, size_new; - unsigned long long num_data_stripes; -@@ -5402,7 +5403,12 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, - return 0; - dv = xmalloc(sizeof(*dv)); - dev = xcalloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1)); -- strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN); -+ /* -+ * Explicitly allow truncating to not confuse gcc's -+ * -Werror=stringop-truncation -+ */ -+ namelen = min((int) strlen(name), MAX_RAID_SERIAL_LEN); -+ memcpy(dev->volume, name, namelen); - array_blocks = calc_array_size(info->level, info->raid_disks, - info->layout, info->chunk_size, - s->size * BLOCKS_PER_KB); --- -2.17.1 - diff --git a/debian/patches/0011-policy.c-Fix-for-compiler-error.patch b/debian/patches/0011-policy.c-Fix-for-compiler-error.patch new file mode 100644 index 00000000..08301935 --- /dev/null +++ b/debian/patches/0011-policy.c-Fix-for-compiler-error.patch @@ -0,0 +1,36 @@ +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: [PATCH 11/11] 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 e3a0671f..3c53bd35 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.19.1 + diff --git a/debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch b/debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch deleted file mode 100644 index 1bea6c6a..00000000 --- a/debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 167d8bb8302170676f0e15123738e333383fec7b Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Tue, 29 May 2018 16:09:47 -0400 -Subject: [PATCH 12/40] super-intel: Use memcpy() to avoid confusing gcc - -When added :0 to serial number and copying it back, use memcpy() -instead of strncpy() as we know the actual length. This stops gcc -from complaining with -Werror=stringop-truncation enabled - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index 449da1dd..ec7683d9 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -8098,7 +8098,7 @@ static int mark_failure(struct intel_super *super, - strcat(buf, ":0"); - if ((len = strlen(buf)) >= MAX_RAID_SERIAL_LEN) - shift = len - MAX_RAID_SERIAL_LEN + 1; -- strncpy((char *)disk->serial, &buf[shift], MAX_RAID_SERIAL_LEN); -+ memcpy(disk->serial, &buf[shift], len + 1 - shift); - - disk->status |= FAILED_DISK; - set_imsm_ord_tbl_ent(map, slot, idx | IMSM_ORD_REBUILD); --- -2.17.1 - diff --git a/debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch b/debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch deleted file mode 100644 index 5cf13758..00000000 --- a/debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 1cdc06dfda62775647b81e2753fc7908e1bbffc2 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Tue, 29 May 2018 16:55:41 -0400 -Subject: [PATCH 13/40] super-intel: Get rid of unnused string - -No need to snprintf() into the string when we don't use it afterards - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index ec7683d9..cc53f0fc 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -1928,7 +1928,6 @@ static void examine_super_imsm(struct supertype *st, char *homehost) - strncpy(str, (char *)mpb->sig, MPB_SIG_LEN); - str[MPB_SIG_LEN-1] = '\0'; - printf(" Magic : %s\n", str); -- snprintf(str, strlen(MPB_VERSION_RAID0), "%s", get_imsm_version(mpb)); - printf(" Version : %s\n", get_imsm_version(mpb)); - printf(" Orig Family : %08x\n", __le32_to_cpu(mpb->orig_family_num)); - printf(" Family : %08x\n", __le32_to_cpu(mpb->family_num)); --- -2.17.1 - diff --git a/debian/patches/0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch b/debian/patches/0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch deleted file mode 100644 index 4966b013..00000000 --- a/debian/patches/0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 40659392ff90fc9c2861ec18c34ed1bdb54f92ca Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Wed, 30 May 2018 11:56:37 -0400 -Subject: [PATCH 14/40] super-intel: Avoid gcc-8.1 complaining about truncating - snprintf() - -We know the max size of the volume name, so no need to play the -snprintf() game. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/super-intel.c b/super-intel.c -index cc53f0fc..520d2921 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -9881,6 +9881,7 @@ static void imsm_process_update(struct supertype *st, - /* sanity check that we are not affecting the uuid of - * an active array - */ -+ memset(name, 0, sizeof(name)); - snprintf(name, MAX_RAID_SERIAL_LEN, "%s", (char *) u->name); - name[MAX_RAID_SERIAL_LEN] = '\0'; - for (a = st->arrays; a; a = a->next) -@@ -9892,7 +9893,7 @@ static void imsm_process_update(struct supertype *st, - break; - } - -- snprintf((char *) dev->volume, MAX_RAID_SERIAL_LEN, "%s", name); -+ memcpy(dev->volume, name, MAX_RAID_SERIAL_LEN); - super->updates_pending++; - break; - } --- -2.17.1 - diff --git a/debian/patches/0015-super-intel-Do-not-truncate-last-character-of-volume.patch b/debian/patches/0015-super-intel-Do-not-truncate-last-character-of-volume.patch deleted file mode 100644 index c4d68e7c..00000000 --- a/debian/patches/0015-super-intel-Do-not-truncate-last-character-of-volume.patch +++ /dev/null @@ -1,37 +0,0 @@ -From ebad3af29b401dec7203e8fa5a77bcf16532f49c Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Wed, 30 May 2018 12:10:13 -0400 -Subject: [PATCH 15/40] super-intel: Do not truncate last character of volume - name - -Clear up strncpy abuse to avoid gcc-8.1 complaining about truncating -the string. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index 520d2921..aa93a9e9 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -7587,11 +7587,12 @@ static int update_subarray_imsm(struct supertype *st, char *subarray, - append_metadata_update(st, u, sizeof(*u)); - } else { - struct imsm_dev *dev; -- int i; -+ int i, namelen; - - dev = get_imsm_dev(super, vol); -- strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN); -- dev->volume[MAX_RAID_SERIAL_LEN-1] = '\0'; -+ memset(dev->volume, '\0', MAX_RAID_SERIAL_LEN); -+ namelen = min((int)strlen(name), MAX_RAID_SERIAL_LEN); -+ memcpy(dev->volume, name, namelen); - for (i = 0; i < mpb->num_raid_devs; i++) { - dev = get_imsm_dev(super, i); - handle_missing(super, dev); --- -2.17.1 - diff --git a/debian/patches/0016-imsm-Do-not-block-volume-creation-when-container-has.patch b/debian/patches/0016-imsm-Do-not-block-volume-creation-when-container-has.patch deleted file mode 100644 index 75b74394..00000000 --- a/debian/patches/0016-imsm-Do-not-block-volume-creation-when-container-has.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 59632db96bdd09b44e9927f63a67cccbe8b15cdf Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Tue, 29 May 2018 15:47:09 +0200 -Subject: [PATCH 16/40] imsm: Do not block volume creation when container has - disks with mixed sector size - -Currently when created container keeps disks with mixed sector size (few -4K disks and some 512 disks) there is no possibility to create volume from -disks with one sector size. -Allow volume creation when given disks are related with mixed container. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/super-intel.c b/super-intel.c -index aa93a9e9..12f60f65 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -5616,6 +5616,11 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, - return 1; - } - -+ if (mpb->num_disks == 0) -+ if (!get_dev_sector_size(dl->fd, dl->devname, -+ &super->sector_size)) -+ return 1; -+ - if (!drive_validate_sector_size(super, dl)) { - pr_err("Combining drives of different sector size in one volume is not allowed\n"); - return 1; --- -2.17.1 - diff --git a/debian/patches/0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch b/debian/patches/0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch deleted file mode 100644 index 134d6c90..00000000 --- a/debian/patches/0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 5a5b3a6725ded07697f03ddd05ee537ce289e951 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Tue, 29 May 2018 15:47:25 +0200 -Subject: [PATCH 17/40] imsm: Do not require MDADM_EXPERIMENTAL flag anymore - -Grow feature for IMSM metadata is currently fully supported and tested. -Reshape operation is not in experimental state anymore, so usage of this -flag is unnecessary. - -Do not require MDADM_EXPERIMENTAL flag and remove obsolete information -from manual. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Acked-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com> -Acked-by: Roman Sobanski <roman.sobanski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - mdadm.8.in | 24 ++++++------------------ - mdadm.h | 1 - - super-intel.c | 3 --- - tests/env-imsm-template | 1 - - util.c | 10 ---------- - 5 files changed, 6 insertions(+), 33 deletions(-) - -diff --git a/mdadm.8.in b/mdadm.8.in -index ea45bbc8..d6bb3fae 100644 ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -2718,27 +2718,15 @@ above. Resizing arrays in an IMSM container with - .B "--grow --size" - is not yet supported. - --Grow functionality (e.g. expand a number of raid devices) for Intel's --IMSM container format has an experimental status. It is guarded by the --.B MDADM_EXPERIMENTAL --environment variable which must be set to '1' for a GROW command to --succeed. --This is for the following reasons: -- --.IP 1. --Intel's native IMSM check-pointing is not fully tested yet. --This can causes IMSM incompatibility during the grow process: an array --which is growing cannot roam between Microsoft Windows(R) and Linux --systems. -- --.IP 2. --Interrupting a grow operation is not recommended, because it --has not been fully tested for Intel's IMSM container format yet. -- - .PP --Note: Intel's native checkpointing doesn't use -+Notes: -+.IP \(bu 4 -+Intel's native checkpointing doesn't use - .B --backup-file - option and it is transparent for assembly feature. -+.IP \(bu 4 -+Roaming between Windows(R) and Linux systems for IMSM metadata is not -+supported during grow process. - - .SS SIZE CHANGES - Normally when an array is built the "size" is taken from the smallest -diff --git a/mdadm.h b/mdadm.h -index 61bc7afe..387e681a 100644 ---- a/mdadm.h -+++ b/mdadm.h -@@ -1485,7 +1485,6 @@ extern struct mddev_ident *conf_match(struct supertype *st, - struct mdinfo *info, - char *devname, - int verbose, int *rvp); --extern int experimental(void); - - extern void free_line(char *line); - extern int match_oneof(char *devices, char *devname); -diff --git a/super-intel.c b/super-intel.c -index 12f60f65..a01be132 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -11607,9 +11607,6 @@ static int imsm_reshape_super(struct supertype *st, unsigned long long size, - dprintf("for level : %i\n", geo.level); - dprintf("for raid_disks : %i\n", geo.raid_disks); - -- if (experimental() == 0) -- return ret_val; -- - if (strcmp(st->container_devnm, st->devnm) == 0) { - /* On container level we can only increase number of devices. */ - dprintf("imsm: info: Container operation\n"); -diff --git a/tests/env-imsm-template b/tests/env-imsm-template -index bc5f5852..ea45bae9 100644 ---- a/tests/env-imsm-template -+++ b/tests/env-imsm-template -@@ -65,7 +65,6 @@ imsm_check() { - export IMSM_NO_PLATFORM=1 - export IMSM_DEVNAME_AS_SERIAL=1 - export IMSM_TEST_OROM=1 --export MDADM_EXPERIMENTAL=1 - container=/dev/md/container - member0=/dev/md/vol0 - member1=/dev/md/vol1 -diff --git a/util.c b/util.c -index 4adbbff0..c26cf5f3 100644 ---- a/util.c -+++ b/util.c -@@ -2149,16 +2149,6 @@ void append_metadata_update(struct supertype *st, void *buf, int len) - unsigned int __invalid_size_argument_for_IOC = 0; - #endif - --int experimental(void) --{ -- if (check_env("MDADM_EXPERIMENTAL")) -- return 1; -- else { -- pr_err("To use this feature MDADM_EXPERIMENTAL environment variable has to be defined.\n"); -- return 0; -- } --} -- - /* Pick all spares matching given criteria from a container - * if min_size == 0 do not check size - * if domlist == NULL do not check domains --- -2.17.1 - diff --git a/debian/patches/0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch b/debian/patches/0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch deleted file mode 100644 index d5973f80..00000000 --- a/debian/patches/0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 975898395951835f5a8051441af21cc995921f8c Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Thu, 31 May 2018 11:45:21 -0400 -Subject: [PATCH 18/40] Monitor: Increase size of percentalert to avoid gcc - warning - -gcc-8.1 complains about truncated string operations. While we know -percent will never grow larger than 100, it doesn't cost us anything -to increase the size of 'percentalert' on the stack like this. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Monitor.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Monitor.c b/Monitor.c -index c7c05d27..036103fb 100644 ---- a/Monitor.c -+++ b/Monitor.c -@@ -557,7 +557,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, - alert("RebuildStarted", dev, NULL, ainfo); - if (st->percent >= 0 && mse->percent >= 0 && - (mse->percent / increments) > (st->percent / increments)) { -- char percentalert[15]; -+ char percentalert[18]; - /* - * "RebuildNN" (10 chars) or "RebuildStarted" (15 chars) - */ --- -2.17.1 - diff --git a/debian/patches/0019-mdopen-fix-gcc-8.1-string-overflow-error.patch b/debian/patches/0019-mdopen-fix-gcc-8.1-string-overflow-error.patch deleted file mode 100644 index 3431d245..00000000 --- a/debian/patches/0019-mdopen-fix-gcc-8.1-string-overflow-error.patch +++ /dev/null @@ -1,42 +0,0 @@ -From c1b78589cf042221e22a014332b195b2309cb178 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Thu, 31 May 2018 13:11:21 -0400 -Subject: [PATCH 19/40] mdopen: fix gcc 8.1 string overflow error - -We already cut symlinks longer than 1000, so rely on this calling -readlink and error out if we are able to read more than 1000 bytes. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - mdopen.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/mdopen.c b/mdopen.c -index 4ec13f5e..98c54e43 100644 ---- a/mdopen.c -+++ b/mdopen.c -@@ -44,7 +44,7 @@ void make_parts(char *dev, int cnt) - int nlen = strlen(dev) + 20; - char *name; - int dig = isdigit(dev[strlen(dev)-1]); -- char orig[1024]; -+ char orig[1001]; - char sym[1024]; - int err; - -@@ -58,8 +58,10 @@ void make_parts(char *dev, int cnt) - minor_num = minor(stb.st_rdev); - odig = -1; - } else if (S_ISLNK(stb.st_mode)) { -- int len = readlink(dev, orig, sizeof(orig)); -- if (len < 0 || len > 1000) -+ int len; -+ -+ len = readlink(dev, orig, sizeof(orig)); -+ if (len < 0 || len >= (int)sizeof(orig)) - return; - orig[len] = 0; - odig = isdigit(orig[len-1]); --- -2.17.1 - diff --git a/debian/patches/0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch b/debian/patches/0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch deleted file mode 100644 index 0a31b16e..00000000 --- a/debian/patches/0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 2dcd6492718c2921feac993aa71ed3a7c2522077 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Thu, 31 May 2018 13:17:46 -0400 -Subject: [PATCH 20/40] super0: Use memmove() when adjusting sparc2.2 - superblock data - -memcpy() does not allow overlapping copies, switch to memmove() - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super0.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/super0.c b/super0.c -index 756cab5e..42989b9f 100644 ---- a/super0.c -+++ b/super0.c -@@ -520,9 +520,10 @@ static int update_super0(struct supertype *st, struct mdinfo *info, - * up 4 bytes before continuing - */ - __u32 *sb32 = (__u32*)sb; -- memcpy(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7, -- sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1, -- (MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4); -+ -+ memmove(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7, -+ sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1, -+ (MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4); - if (verbose >= 0) - pr_err("adjusting superblock of %s for 2.2/sparc compatibility.\n", - devname); --- -2.17.1 - diff --git a/debian/patches/0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch b/debian/patches/0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch deleted file mode 100644 index 47b0296a..00000000 --- a/debian/patches/0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 4d061b02b61d5e6d4186e0118166fdd40ea8b55f Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Thu, 31 May 2018 13:38:08 -0400 -Subject: [PATCH 21/40] super1: Fix cases triggering gcc-8.1 strncpy truncate - warning - -Find the string length, copy it, and zero out the rest, instead of -relying on strncpy cleaning up for us. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super1.c | 22 ++++++++++++++++++---- - 1 file changed, 18 insertions(+), 4 deletions(-) - -diff --git a/super1.c b/super1.c -index 6774fbd2..636a2866 100644 ---- a/super1.c -+++ b/super1.c -@@ -1434,8 +1434,15 @@ static int update_super1(struct supertype *st, struct mdinfo *info, - strcpy(sb->set_name, homehost); - strcat(sb->set_name, ":"); - strcat(sb->set_name, info->name); -- } else -- strncpy(sb->set_name, info->name, sizeof(sb->set_name)); -+ } else { -+ int namelen; -+ -+ namelen = min((int)strlen(info->name), -+ (int)sizeof(sb->set_name) - 1); -+ memcpy(sb->set_name, info->name, namelen); -+ memset(&sb->set_name[namelen], '\0', -+ sizeof(sb->set_name) - namelen); -+ } - } else if (strcmp(update, "devicesize") == 0 && - __le64_to_cpu(sb->super_offset) < - __le64_to_cpu(sb->data_offset)) { -@@ -1592,8 +1599,15 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info, - strcpy(sb->set_name, homehost); - strcat(sb->set_name, ":"); - strcat(sb->set_name, name); -- } else -- strncpy(sb->set_name, name, sizeof(sb->set_name)); -+ } else { -+ int namelen; -+ -+ namelen = min((int)strlen(name), -+ (int)sizeof(sb->set_name) - 1); -+ memcpy(sb->set_name, name, namelen); -+ memset(&sb->set_name[namelen], '\0', -+ sizeof(sb->set_name) - namelen); -+ } - - sb->ctime = __cpu_to_le64((unsigned long long)time(0)); - sb->level = __cpu_to_le32(info->level); --- -2.17.1 - diff --git a/debian/patches/0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch b/debian/patches/0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch deleted file mode 100644 index 0269abe1..00000000 --- a/debian/patches/0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 002a5978f015a77ecc48487006b1030f9dbe1394 Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Thu, 31 May 2018 16:07:33 -0400 -Subject: [PATCH 22/40] super-ddf: Fix gcc-8.1 overflow warnings - -Cast to types that are big enough to hold the values, but also guarantee -no overflow of the buffer keepts gcc happy. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-ddf.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/super-ddf.c b/super-ddf.c -index d02a19a2..618542c4 100644 ---- a/super-ddf.c -+++ b/super-ddf.c -@@ -2881,8 +2881,9 @@ static int add_to_super_ddf(struct supertype *st, - dd->disk.magic = DDF_PHYS_DATA_MAGIC; - now = time(0); - tm = localtime(&now); -- sprintf(dd->disk.guid, "%8s%04d%02d%02d", -- T10, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday); -+ sprintf(dd->disk.guid, "%8s%04d%02d%02d", T10, -+ (__u16)tm->tm_year+1900, -+ (__u8)tm->tm_mon+1, (__u8)tm->tm_mday); - tptr = (__u32 *)(dd->disk.guid + 16); - *tptr++ = random32(); - *tptr = random32(); --- -2.17.1 - diff --git a/debian/patches/0023-Check-major-number-of-block-device-when-querying-md-.patch b/debian/patches/0023-Check-major-number-of-block-device-when-querying-md-.patch deleted file mode 100644 index 72dbe799..00000000 --- a/debian/patches/0023-Check-major-number-of-block-device-when-querying-md-.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 27e39ad31cbdfe516f9f390cc860a4f681750ef0 Mon Sep 17 00:00:00 2001 -From: Xiao Ni <xni@redhat.com> -Date: Wed, 30 May 2018 13:49:41 +0800 -Subject: [PATCH 23/40] Check major number of block device when querying md - device - -It give error message when query a non md device. -mdadm /dev/null -/dev/null: is an md device, but gives "Inappropriate ioctl for device" when queried - -It's introduced by commit 5cb8599 and 8d0cd09 -At first it checks whether a block is md device by function md_get_version. -In this function it does mainly two jobs: -1. send request by ioctl. (now it can be replace by argument ioctlerr) -2. check the block device major number which we don't do this. - -We add the second judgement in this patch. - -Fixes: 5cb8599 and 8d0cd09 -Reported-by: Karsten Weiss <karsten.weiss@atos.net> -Signed-off-by: Xiao Ni <xni@redhat.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Query.c | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/Query.c b/Query.c -index 2bd0e2a0..23fbf8aa 100644 ---- a/Query.c -+++ b/Query.c -@@ -85,12 +85,11 @@ int Query(char *dev) - - if (ioctlerr == ENODEV) - printf("%s: is an md device which is not active\n", dev); -+ else if (ioctlerr && major(stb.st_rdev) != MD_MAJOR) -+ printf("%s: is not an md array\n", 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, human_size_brief(larray_size,IEC), --- -2.17.1 - diff --git a/debian/patches/0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch b/debian/patches/0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch deleted file mode 100644 index df0e38a9..00000000 --- a/debian/patches/0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 38e955cbf030bc9e564bd87bc9f02f949884a83f Mon Sep 17 00:00:00 2001 -From: Zhilong Liu <zlliu@suse.com> -Date: Wed, 30 May 2018 15:04:05 +0800 -Subject: [PATCH 24/40] mdadm/test: mdadm needn't make install on the system - -Fixes: beb71de04d31 ("mdadm/test: enable clustermd testing under clustermd_tests/") -clustermd_tests/func.sh: -remove unnecessary 'make install', just ensure 'make everything' has done. -the original idea is to make the /sbin/mdadm version same as ./mdadm, and -this breakage has pointed out by commit: -59416da78fc6 ("tests/func.sh: Fix some total breakage in the test scripts") - -Signed-off-by: Zhilong Liu <zlliu@suse.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - clustermd_tests/func.sh | 11 ++++------- - 1 file changed, 4 insertions(+), 7 deletions(-) - -diff --git a/clustermd_tests/func.sh b/clustermd_tests/func.sh -index c2be0e59..642cc966 100644 ---- a/clustermd_tests/func.sh -+++ b/clustermd_tests/func.sh -@@ -86,10 +86,13 @@ check_env() - echo "testing can only be done as 'root'." - exit 1 - } -+ [ \! -x $mdadm ] && { -+ echo "test: please run make everything before perform testing." -+ exit 1 -+ } - check_ssh - commands=(mdadm iscsiadm bc modinfo dlm_controld - udevadm crm crm_mon lsblk pgrep sbd) -- mdadm_src_ver="$($mdadm -V 2>&1)" - for ip in $NODE1 $NODE2 - do - for cmd in ${commands[@]} -@@ -99,12 +102,6 @@ check_env() - exit 1 - } - done -- mdadm_sbin_ver="$(ssh $ip "mdadm -V 2>&1")" -- if [ "$mdadm_src_ver" != "$mdadm_sbin_ver" ] -- then -- echo "$ip: please run 'make install' before testing." -- exit 1 -- fi - mods=(raid1 raid10 md_mod dlm md-cluster) - for mod in ${mods[@]} - do --- -2.17.1 - diff --git a/debian/patches/0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch b/debian/patches/0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch deleted file mode 100644 index d265bc1d..00000000 --- a/debian/patches/0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 7d4815f84cba133ee7439db5348ce554779f8342 Mon Sep 17 00:00:00 2001 -From: Zhilong Liu <zlliu@suse.com> -Date: Wed, 30 May 2018 15:04:41 +0800 -Subject: [PATCH 25/40] mdadm/test: correct tests/testdev as testdev in - 02r5grow - -Fixes: a6994ccc230b ("mdadm/test: get rid of the tests/testdev") - -Signed-off-by: Zhilong Liu <zlliu@suse.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/02r5grow | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/02r5grow b/tests/02r5grow -index bb9bd6da..2da78ee6 100644 ---- a/tests/02r5grow -+++ b/tests/02r5grow -@@ -31,7 +31,7 @@ testdev $md0 3 $[mdsize1_l] 128 - - mdadm --grow $md0 --size $[size/2] - check nosync --sh tests/testdev $md0 3 $[size/2] 128 -+testdev $md0 3 $[size/2] 128 - - mdadm -S $md0 - --- -2.17.1 - diff --git a/debian/patches/0026-gcc-8-coverity-hack.patch b/debian/patches/0026-gcc-8-coverity-hack.patch deleted file mode 100644 index 6cf6f6a4..00000000 --- a/debian/patches/0026-gcc-8-coverity-hack.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 28156667e5c7dc3c7b978f2d58c2a427038fedda Mon Sep 17 00:00:00 2001 -From: Jes Sorensen <jsorensen@fb.com> -Date: Mon, 4 Jun 2018 14:49:59 -0400 -Subject: [PATCH 26/40] gcc-8 coverity hack - -Coverity still has issues with gcc-7, not to mention gcc-8. Hack around -it, until they fix it. - -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Makefile | 15 +++++++++++---- - coverity-gcc-hack.h | 10 ++++++++++ - 2 files changed, 21 insertions(+), 4 deletions(-) - create mode 100644 coverity-gcc-hack.h - -diff --git a/Makefile b/Makefile -index 188a2180..2767ac68 100644 ---- a/Makefile -+++ b/Makefile -@@ -42,6 +42,10 @@ KLIBC=/home/src/klibc/klibc-0.77 - - KLIBC_GCC = gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 - -+ifdef COVERITY -+COVERITY_FLAGS=-include coverity-gcc-hack.h -+endif -+ - CC ?= $(CROSS_COMPILE)gcc - CXFLAGS ?= -ggdb - CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -@@ -177,6 +181,9 @@ everything-test: all mdadm.static swap_super test_stripe \ - # mdadm.uclibc doesn't work on x86-64 - # mdadm.tcc doesn't work.. - -+%.o: %.c -+ $(CC) $(CFLAGS) $(CPPFLAGS) $(COVERITY_FLAGS) -o $@ -c $< -+ - mdadm : $(OBJS) | check_rundir - $(CC) $(CFLAGS) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS) - -@@ -291,10 +298,10 @@ test: mdadm mdmon test_stripe swap_super raid6check - - clean : - rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \ -- mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt .merge_file_* \ -- mdadm.Os mdadm.O2 mdmon.O2 swap_super \ -- init.cpio.gz mdadm.uclibc.static test_stripe raid6check raid6check.o mdmon \ -- mdadm.8 -+ mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \ -+ .merge_file_* mdadm.Os mdadm.O2 mdmon.O2 swap_super init.cpio.gz \ -+ mdadm.uclibc.static test_stripe raid6check raid6check.o mdmon mdadm.8 -+ rm -rf cov-int - - dist : clean - ./makedist -diff --git a/coverity-gcc-hack.h b/coverity-gcc-hack.h -new file mode 100644 -index 00000000..2d94a8b7 ---- /dev/null -+++ b/coverity-gcc-hack.h -@@ -0,0 +1,10 @@ -+#if !defined(__KERNEL__) && defined(__x86_64__) && defined(__COVERITY_GCC_VERSION_AT_LEAST) -+#if __COVERITY_GCC_VERSION_AT_LEAST(7, 0) -+typedef float _Float128 __attribute__((__vector_size__(128))); -+typedef float _Float64 __attribute__((__vector_size__(64))); -+typedef float _Float32 __attribute__((__vector_size__(32))); -+typedef float _Float128x __attribute__((__vector_size__(128))); -+typedef float _Float64x __attribute__((__vector_size__(64))); -+typedef float _Float32x __attribute__((__vector_size__(32))); -+#endif -+#endif --- -2.17.1 - diff --git a/debian/patches/0027-Assemble.c-Don-t-ignore-faulty-disk-when-array-is-au.patch b/debian/patches/0027-Assemble.c-Don-t-ignore-faulty-disk-when-array-is-au.patch deleted file mode 100644 index 76f4b27d..00000000 --- a/debian/patches/0027-Assemble.c-Don-t-ignore-faulty-disk-when-array-is-au.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 7298c9a6facea469d9e7ed55a7a0806500096415 Mon Sep 17 00:00:00 2001 -From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> -Date: Thu, 7 Jun 2018 14:47:47 +0200 -Subject: [PATCH 27/40] Assemble.c Don't ignore faulty disk when array is auto - assembled. - -Since commit 20dc76d15b40 ("imsm: Set disk slot number") mdadm -sets slot number for each disk in imsm array. Now auto-assemble determines -devices using slot number and ignores devices on the same slot that have -older generation number. -It causes infinit loop if failed device is still visible in system -(it has metadata, but it is not merged with exisiting array). - -To avoid it, out-of-sync device should be added to the best[]. Later -mdadm adds it as spare to the container. - -Imsm doesn't support disk replacement feature, so it can use rooms for -replacements. - -Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Assemble.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Assemble.c b/Assemble.c -index e83d550b..32e6f6ff 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -779,6 +779,8 @@ static int load_devices(struct devs *devices, char *devmap, - if (best[i] == -1 || (devices[best[i]].i.events - < devices[devcnt].i.events)) - best[i] = devcnt; -+ else if (st->ss == &super_imsm) -+ best[i+1] = devcnt; - } - devcnt++; - } --- -2.17.1 - diff --git a/debian/patches/0028-imsm-correct-num_data_stripes-in-metadata-map-for-mi.patch b/debian/patches/0028-imsm-correct-num_data_stripes-in-metadata-map-for-mi.patch deleted file mode 100644 index 57b4b366..00000000 --- a/debian/patches/0028-imsm-correct-num_data_stripes-in-metadata-map-for-mi.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 4a353e6ec48e35437b27978add6cd2cd015f2cfe Mon Sep 17 00:00:00 2001 -From: Roman Sobanski <roman.sobanski@intel.com> -Date: Fri, 8 Jun 2018 12:34:18 +0200 -Subject: [PATCH 28/40] imsm: correct num_data_stripes in metadata map for - migration - -When migrating an array from R0 to R10 num_data_stripes in metadata map -will not be updated. Update it to allow correct migration process. -Changes in R10 to R0 migration for clarity of code. - -Signed-off-by: Roman Sobanski <roman.sobanski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - super-intel.c | 16 ++++++++++------ - 1 file changed, 10 insertions(+), 6 deletions(-) - -diff --git a/super-intel.c b/super-intel.c -index a01be132..f011a31f 100644 ---- a/super-intel.c -+++ b/super-intel.c -@@ -9543,12 +9543,6 @@ static int apply_takeover_update(struct imsm_update_takeover *u, - if (u->direction == R10_TO_R0) { - unsigned long long num_data_stripes; - -- map->num_domains = 1; -- num_data_stripes = imsm_dev_size(dev) / 2; -- num_data_stripes /= map->blocks_per_strip; -- num_data_stripes /= map->num_domains; -- set_num_data_stripes(map, num_data_stripes); -- - /* Number of failed disks must be half of initial disk number */ - if (imsm_count_failed(super, dev, MAP_0) != - (map->num_members / 2)) -@@ -9574,10 +9568,15 @@ static int apply_takeover_update(struct imsm_update_takeover *u, - map->num_domains = 1; - map->raid_level = 0; - map->failed_disk_num = -1; -+ num_data_stripes = imsm_dev_size(dev) / 2; -+ num_data_stripes /= map->blocks_per_strip; -+ set_num_data_stripes(map, num_data_stripes); - } - - if (u->direction == R0_TO_R10) { - void **space; -+ unsigned long long num_data_stripes; -+ - /* update slots in current disk list */ - for (dm = super->disks; dm; dm = dm->next) { - if (dm->index >= 0) -@@ -9615,6 +9614,11 @@ static int apply_takeover_update(struct imsm_update_takeover *u, - map->map_state = IMSM_T_STATE_DEGRADED; - map->num_domains = 2; - map->raid_level = 1; -+ num_data_stripes = imsm_dev_size(dev) / 2; -+ num_data_stripes /= map->blocks_per_strip; -+ num_data_stripes /= map->num_domains; -+ set_num_data_stripes(map, num_data_stripes); -+ - /* replace dev<->dev_new */ - dv->dev = dev_new; - } --- -2.17.1 - diff --git a/debian/patches/0029-Free-map-to-avoid-resource-leak-issues.patch b/debian/patches/0029-Free-map-to-avoid-resource-leak-issues.patch deleted file mode 100644 index d3498b72..00000000 --- a/debian/patches/0029-Free-map-to-avoid-resource-leak-issues.patch +++ /dev/null @@ -1,142 +0,0 @@ -From 898bd1ecefe6c72102f398680dcfef80e4de21c1 Mon Sep 17 00:00:00 2001 -From: Guoqing Jiang <gqjiang@suse.com> -Date: Mon, 11 Jun 2018 17:03:44 +0800 -Subject: [PATCH 29/40] Free map to avoid resource leak issues - -1. There are some places which didn't free map as -discovered by coverity. - -CID 289661 (#1 of 1): Resource leak (RESOURCE_LEAK)12. leaked_storage: Variable mapl going out of scope leaks the storage it points to. -CID 289619 (#3 of 3): Resource leak (RESOURCE_LEAK)63. leaked_storage: Variable map going out of scope leaks the storage it points to. -CID 289618 (#1 of 1): Resource leak (RESOURCE_LEAK)26. leaked_storage: Variable map going out of scope leaks the storage it points to. -CID 289607 (#1 of 1): Resource leak (RESOURCE_LEAK)41. leaked_storage: Variable map going out of scope leaks the storage it points to. - -2. If we call map_by_* inside a loop, then map_free -should be called in the same loop, and it is better -to set map to NULL after free. - -3. And map_unlock is always called with map_lock, -if we don't call map_remove before map_unlock, -then the memory (allocated by map_lock -> map_read --> map_add -> xmalloc) could be leaked. So we -need to free it in map_unlock as well. - -Signed-off-by: Guoqing Jiang <gqjiang@suse.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Assemble.c | 2 +- - Detail.c | 2 ++ - Incremental.c | 4 ++++ - config.c | 3 ++- - mapfile.c | 2 ++ - mdadm.c | 2 ++ - 6 files changed, 13 insertions(+), 2 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 32e6f6ff..5a907c14 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1851,8 +1851,8 @@ try_again: - if (rv == 1 && !pre_exist) - ioctl(mdfd, STOP_ARRAY, NULL); - free(devices); -- map_unlock(&map); - out: -+ map_unlock(&map); - if (rv == 0) { - wait_for(chosen_name, mdfd); - close(mdfd); -diff --git a/Detail.c b/Detail.c -index 860241ce..b3e857a7 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -263,6 +263,7 @@ int Detail(char *dev, struct context *c) - - if (st->ss->export_detail_super) - st->ss->export_detail_super(st); -+ map_free(map); - } else { - struct map_ent *mp, *map = NULL; - char nbuf[64]; -@@ -277,6 +278,7 @@ int Detail(char *dev, struct context *c) - print_escape(mp->path+8); - putchar('\n'); - } -+ map_free(map); - } - if (sra) { - struct mdinfo *mdi; -diff --git a/Incremental.c b/Incremental.c -index 0beab163..0c5698ee 100644 ---- a/Incremental.c -+++ b/Incremental.c -@@ -1413,6 +1413,7 @@ restart: - sysfs_free(sra); - } - } -+ map_free(mapl); - return rv; - } - -@@ -1587,6 +1588,8 @@ static int Incremental_container(struct supertype *st, char *devname, - - assemble_container_content(st, mdfd, ra, c, - chosen_name, &result); -+ map_free(map); -+ map = NULL; - close(mdfd); - } - if (c->export && result) { -@@ -1663,6 +1666,7 @@ static int Incremental_container(struct supertype *st, char *devname, - close(sfd); - } - domain_free(domains); -+ map_free(map); - return 0; - } - -diff --git a/config.c b/config.c -index 48e02788..e14eae0c 100644 ---- a/config.c -+++ b/config.c -@@ -181,9 +181,10 @@ struct mddev_dev *load_containers(void) - } - d->next = rv; - rv = d; -+ map_free(map); -+ map = NULL; - } - free_mdstat(mdstat); -- map_free(map); - - return rv; - } -diff --git a/mapfile.c b/mapfile.c -index f3c8191e..a5025563 100644 ---- a/mapfile.c -+++ b/mapfile.c -@@ -143,6 +143,8 @@ void map_unlock(struct map_ent **melp) - unlink(mapname[2]); - fclose(lf); - } -+ if (*melp) -+ map_free(*melp); - lf = NULL; - } - -diff --git a/mdadm.c b/mdadm.c -index 5afe4155..1cf5c189 100644 ---- a/mdadm.c -+++ b/mdadm.c -@@ -1885,6 +1885,8 @@ static int misc_scan(char devmode, struct context *c) - else - rv |= WaitClean(name, c->verbose); - put_md_name(name); -+ map_free(map); -+ map = NULL; - } - } - free_mdstat(ms); --- -2.17.1 - diff --git a/debian/patches/0030-Coverity-Resource-leak-fix-return-without-free.patch b/debian/patches/0030-Coverity-Resource-leak-fix-return-without-free.patch deleted file mode 100644 index dd7a10f7..00000000 --- a/debian/patches/0030-Coverity-Resource-leak-fix-return-without-free.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 4a670aabdcf6b7870aaa0088574a62603bb22f31 Mon Sep 17 00:00:00 2001 -From: Anthony Youngman <anthony@youngman.org.uk> -Date: Fri, 15 Jun 2018 22:18:14 +0100 -Subject: [PATCH 30/40] Coverity: Resource leak: fix return without free - -Signed-off-by: Anthony Youngman <anthony@youngman.org.uk> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Assemble.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Assemble.c b/Assemble.c -index 5a907c14..0a7ab6f5 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -281,6 +281,8 @@ static int select_devices(struct mddev_dev *devlist, - st->ss->free_super(st); - dev_policy_free(pol); - domain_free(domains); -+ if (tst) -+ tst->ss->free_super(tst); - return -1; - } - --- -2.17.1 - diff --git a/debian/patches/0031-Coverity-Resource-leak-close-fds-and-free-array-befo.patch b/debian/patches/0031-Coverity-Resource-leak-close-fds-and-free-array-befo.patch deleted file mode 100644 index 1507ce4a..00000000 --- a/debian/patches/0031-Coverity-Resource-leak-close-fds-and-free-array-befo.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 29446c962f6099b9f0c22b76891ff6a0baeb673d Mon Sep 17 00:00:00 2001 -From: Anthony Youngman <anthony@youngman.org.uk> -Date: Sat, 16 Jun 2018 20:48:46 +0100 -Subject: [PATCH 31/40] Coverity: Resource leak: close fds and free array - before return - -Signed-off-by: Anthony Youngman <anthony@youngman.org.uk> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Dump.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Dump.c b/Dump.c -index 7bdbf6f7..38e8f238 100644 ---- a/Dump.c -+++ b/Dump.c -@@ -301,6 +301,9 @@ int Restore_metadata(char *dev, char *dir, struct context *c, - } - if (c->verbose >= 0) - printf("%s restored from %s.\n", dev, fname); -+ close(fl); -+ close(fd); -+ free(fname); - return 0; - - err: --- -2.17.1 - diff --git a/debian/patches/0032-Coverity-Resource-leak-close-fd-before-return.patch b/debian/patches/0032-Coverity-Resource-leak-close-fd-before-return.patch deleted file mode 100644 index 498697fc..00000000 --- a/debian/patches/0032-Coverity-Resource-leak-close-fd-before-return.patch +++ /dev/null @@ -1,26 +0,0 @@ -From d94eb07f82a7e9c086da23b31c8021107b60f884 Mon Sep 17 00:00:00 2001 -From: Anthony Youngman <anthony@youngman.org.uk> -Date: Fri, 15 Jun 2018 22:36:42 +0100 -Subject: [PATCH 32/40] Coverity: Resource leak: close fd before return - -Anthony Youngman <anthony@youngman.org.uk> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Grow.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Grow.c b/Grow.c -index a4be7e7b..30c5fa91 100644 ---- a/Grow.c -+++ b/Grow.c -@@ -242,6 +242,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev) - if (st->ss->load_super(st, fd2, NULL)) { - pr_err("cannot find super block on %s\n", dv); - close(fd); -+ close(fd2); - return 1; - } - info.array.raid_disks = nd+1; --- -2.17.1 - diff --git a/debian/patches/0033-tests-imsm-Set-correct-expected-offset-between-volum.patch b/debian/patches/0033-tests-imsm-Set-correct-expected-offset-between-volum.patch deleted file mode 100644 index acd48e3b..00000000 --- a/debian/patches/0033-tests-imsm-Set-correct-expected-offset-between-volum.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 6adfeaa7a23775a70d22b79a672a4b1a542455b4 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Fri, 22 Jun 2018 16:34:07 +0200 -Subject: [PATCH 33/40] tests, imsm: Set correct expected offset between - volumes - -Since 611d9529 (imsm: change reserved space to 4MB) gap between RAID -volumes has changed. Tests should expect correct offset in size -calulations. - -Fix expected offset for tests. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/09imsm-create-fail-rebuild | 4 ++-- - tests/09imsm-overlap | 10 ++++------ - tests/13imsm-r0_r0_2d-grow-r0_r0_4d | 2 +- - tests/13imsm-r0_r0_2d-grow-r0_r0_5d | 2 +- - tests/13imsm-r0_r0_3d-grow-r0_r0_4d | 2 +- - tests/13imsm-r0_r5_3d-grow-r0_r5_4d | 2 +- - tests/13imsm-r0_r5_3d-grow-r0_r5_5d | 2 +- - tests/13imsm-r5_r0_3d-grow-r5_r0_4d | 2 +- - tests/13imsm-r5_r0_3d-grow-r5_r0_5d | 2 +- - tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d | 2 +- - tests/14imsm-r0_r0_2d-takeover-r10_4d | 2 +- - tests/14imsm-r10_r5_4d-takeover-r0_2d | 2 +- - tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k | 2 +- - 13 files changed, 17 insertions(+), 19 deletions(-) - -diff --git a/tests/09imsm-create-fail-rebuild b/tests/09imsm-create-fail-rebuild -index de17f321..886d385a 100644 ---- a/tests/09imsm-create-fail-rebuild -+++ b/tests/09imsm-create-fail-rebuild -@@ -36,7 +36,7 @@ mdadm -CR $member0 $dev0 $dev1 -n $num_disks -l $level -z $size -c $chunk - imsm_check member $member0 $num_disks $level $size $((size*2)) $offset $chunk - testdev $member0 $num_disks $size $chunk - --offset=$(((size & ~(chunk - 1)) + 2048)) -+offset=$(((size & ~(chunk - 1)) + 4096)) - size=4000 - level=1 - chunk=0 -@@ -60,7 +60,7 @@ mdadm -CR $member0 $dev0 $dev1 $dev2 $dev3 -n $num_disks -l $level -z $size -c $ - imsm_check member $member0 $num_disks $level $size $((size*2)) $offset $chunk - testdev $member0 $((num_disks-2)) $size $chunk - --offset=$(((size & ~(chunk - 1)) + 2048)) -+offset=$(((size & ~(chunk - 1)) + 4096)) - size=4000 - level=5 - mdadm -CR $member1 $dev0 $dev1 $dev2 $dev3 -n $num_disks -l $level -z $size -c $chunk -diff --git a/tests/09imsm-overlap b/tests/09imsm-overlap -index e832257c..2d1ab692 100644 ---- a/tests/09imsm-overlap -+++ b/tests/09imsm-overlap -@@ -18,13 +18,11 @@ udevadm settle - - offset=0 - imsm_check member $member0 $num_disks $level $size 1024 $offset --offset=$((offset+size+2048)) -+offset=$((offset+size+4096)) - imsm_check member $member1 $num_disks $level $size 1024 $offset --offset=$((offset+size+2048)) -+offset=$((offset+size+4096)) - imsm_check member $member2 $num_disks $level $size 1024 $offset --# at this point there should be more freespace at the start of the disk --# than the end --offset=0 -+offset=$((offset+size+4096)) - imsm_check member $member3 $num_disks $level $size 1024 $offset --offset=$((offset+size+2048)) -+offset=$((offset+size+4096)) - imsm_check member $member4 $num_disks $level $size 1024 $offset -diff --git a/tests/13imsm-r0_r0_2d-grow-r0_r0_4d b/tests/13imsm-r0_r0_2d-grow-r0_r0_4d -index f85efa5d..66ceeb36 100644 ---- a/tests/13imsm-r0_r0_2d-grow-r0_r0_4d -+++ b/tests/13imsm-r0_r0_2d-grow-r0_r0_4d -@@ -19,7 +19,7 @@ vol1_level=0 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 - vol1_num_comps=$num_disks --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After: RAID 0 volume in slot #0, 4 disks, 128k chunk size - # RAID 0 volume in slot #1, 4 disks, 64k chunk size -diff --git a/tests/13imsm-r0_r0_2d-grow-r0_r0_5d b/tests/13imsm-r0_r0_2d-grow-r0_r0_5d -index 1b851a9b..0da9ef32 100644 ---- a/tests/13imsm-r0_r0_2d-grow-r0_r0_5d -+++ b/tests/13imsm-r0_r0_2d-grow-r0_r0_5d -@@ -19,7 +19,7 @@ vol1_level=0 - vol1_comp_size=$((6 * 1024)) - vol1_chunk=256 - vol1_num_comps=$num_disks --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After: RAID 0 volume in slot #0, 5 disks, 64k chunk size - # RAID 0 volume in slot #1, 5 disks, 256k chunk size -diff --git a/tests/13imsm-r0_r0_3d-grow-r0_r0_4d b/tests/13imsm-r0_r0_3d-grow-r0_r0_4d -index 27ba83b3..1ff60257 100644 ---- a/tests/13imsm-r0_r0_3d-grow-r0_r0_4d -+++ b/tests/13imsm-r0_r0_3d-grow-r0_r0_4d -@@ -19,7 +19,7 @@ vol1_level=0 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=128 - vol1_num_comps=$num_disks --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After: RAID0 volume in slot #0, 4 disks, 128k chunk size - # RAID0 volume in slot #1, 4 disks, 512k chunk size -diff --git a/tests/13imsm-r0_r5_3d-grow-r0_r5_4d b/tests/13imsm-r0_r5_3d-grow-r0_r5_4d -index b4bde449..2977f367 100644 ---- a/tests/13imsm-r0_r5_3d-grow-r0_r5_4d -+++ b/tests/13imsm-r0_r5_3d-grow-r0_r5_4d -@@ -19,7 +19,7 @@ vol1_level=5 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=128 - vol1_num_comps=$((num_disks - 1)) --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After: RAID 0 volume in slot #0, 4 disks, 64k chunk size - # RAID 5 volume in slot #1, 4 disks, 128k chunk size -diff --git a/tests/13imsm-r0_r5_3d-grow-r0_r5_5d b/tests/13imsm-r0_r5_3d-grow-r0_r5_5d -index d0db9aeb..ff15ad09 100644 ---- a/tests/13imsm-r0_r5_3d-grow-r0_r5_5d -+++ b/tests/13imsm-r0_r5_3d-grow-r0_r5_5d -@@ -19,7 +19,7 @@ vol1_level=5 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=128 - vol1_num_comps=$((num_disks - 1)) --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After: RAID 0 volume in slot #0, 5 disks, 256k chunk size - # RAID 5 volume in slot #1, 5 disks, 512k chunk size -diff --git a/tests/13imsm-r5_r0_3d-grow-r5_r0_4d b/tests/13imsm-r5_r0_3d-grow-r5_r0_4d -index 32ebc924..9fed88a2 100644 ---- a/tests/13imsm-r5_r0_3d-grow-r5_r0_4d -+++ b/tests/13imsm-r5_r0_3d-grow-r5_r0_4d -@@ -18,7 +18,7 @@ vol0_offset=0 - vol1_level=0 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - vol1_num_comps=$num_disks - - # After: RAID 5 volume in slot #0, 4 disks, 64k chunk size -diff --git a/tests/13imsm-r5_r0_3d-grow-r5_r0_5d b/tests/13imsm-r5_r0_3d-grow-r5_r0_5d -index a97002d0..e8beddc3 100644 ---- a/tests/13imsm-r5_r0_3d-grow-r5_r0_5d -+++ b/tests/13imsm-r5_r0_3d-grow-r5_r0_5d -@@ -18,7 +18,7 @@ vol0_offset=0 - vol1_level=0 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - vol1_num_comps=$num_disks - - # After: RAID 5 volume in slot #0, 5 disks, 128k chunk size -diff --git a/tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d b/tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d -index 386abeee..cb7328a9 100644 ---- a/tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d -+++ b/tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d -@@ -19,7 +19,7 @@ vol1_level=5 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 - vol1_num_comps=$((num_disks - 1)) --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After: RAID 5 volume, 4 disks, 64k chunk size (only member #0) - vol0_new_level=5 -diff --git a/tests/14imsm-r0_r0_2d-takeover-r10_4d b/tests/14imsm-r0_r0_2d-takeover-r10_4d -index df5b0ce3..d068abb3 100644 ---- a/tests/14imsm-r0_r0_2d-takeover-r10_4d -+++ b/tests/14imsm-r0_r0_2d-takeover-r10_4d -@@ -20,7 +20,7 @@ vol1_level=0 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 - vol1_num_comps=num_disks --vol1_offset=$(( $vol0_comp_size + 2048 )) -+vol1_offset=$(( $vol0_comp_size + 4096 )) - - # After: RAID 10, 4 disks, 64k chunk size - vol0_new_level=10 -diff --git a/tests/14imsm-r10_r5_4d-takeover-r0_2d b/tests/14imsm-r10_r5_4d-takeover-r0_2d -index 9e5205e2..720e575b 100644 ---- a/tests/14imsm-r10_r5_4d-takeover-r0_2d -+++ b/tests/14imsm-r10_r5_4d-takeover-r0_2d -@@ -20,7 +20,7 @@ vol1_level=5 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 - vol1_num_comps=$(( $num_disks - 1 )) --vol1_offset=$(( $vol0_comp_size + 2048 )) -+vol1_offset=$(( $vol0_comp_size + 4096 )) - - # After: RAID 10, 4 disks, 64k chunk size - vol0_new_level=0 -diff --git a/tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k b/tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k -index da218efa..f9369d5d 100644 ---- a/tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k -+++ b/tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k -@@ -24,7 +24,7 @@ vol1_level=0 - vol1_comp_size=$((5 * 1024)) - vol1_chunk=64 - vol1_num_comps=$num_disks --vol1_offset=$((vol0_comp_size + 2048)) -+vol1_offset=$((vol0_comp_size + 4096)) - - # After migration paramters - vol1_new_level=0 --- -2.17.1 - diff --git a/debian/patches/0034-tests-imsm-Fix-unit-inconsistency-in-tests-error-mes.patch b/debian/patches/0034-tests-imsm-Fix-unit-inconsistency-in-tests-error-mes.patch deleted file mode 100644 index db466cb2..00000000 --- a/debian/patches/0034-tests-imsm-Fix-unit-inconsistency-in-tests-error-mes.patch +++ /dev/null @@ -1,31 +0,0 @@ -From b202e322c13572078cc1285c41a8de23609e0820 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Fri, 22 Jun 2018 16:34:08 +0200 -Subject: [PATCH 34/40] tests, imsm: Fix unit inconsistency in tests error - messages - -Chunk size copied from sysfs should be divied by 1024 to compare with -expected chunk size. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/env-imsm-template | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/env-imsm-template b/tests/env-imsm-template -index ea45bae9..40479b48 100644 ---- a/tests/env-imsm-template -+++ b/tests/env-imsm-template -@@ -30,7 +30,7 @@ imsm_check() { - fi - _chunk=`cat ${sysfs}/md/chunk_size` - if [ $t_chunk -ne $((_chunk/1024)) ]; then -- echo "**Error**: Chunk size mismatch - expected $t_chunk, actual $_chunk" >&2 -+ echo "**Error**: Chunk size mismatch - expected $t_chunk, actual $(($_chunk/1024))" >&2 - err=$((err + 1)) - fi - for i in `seq 0 $((t_num_disks - 1))`; do --- -2.17.1 - diff --git a/debian/patches/0035-tests-imsm-Set-new_num_disks-value-corectly-to-perfo.patch b/debian/patches/0035-tests-imsm-Set-new_num_disks-value-corectly-to-perfo.patch deleted file mode 100644 index cddd3085..00000000 --- a/debian/patches/0035-tests-imsm-Set-new_num_disks-value-corectly-to-perfo.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 2b2ccdc04b604ef8644a0f87dc27ccfbd2159cb9 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Fri, 22 Jun 2018 16:34:09 +0200 -Subject: [PATCH 35/40] tests, imsm: Set new_num_disks value corectly to - perform expected size calculations - -In some migration tests, variable new_num_disks should be set to expected -number of disks after migration. This is required for proper expected size -calculation. - -Pass new_num_disks variable during test execution for: -- 16imsm-r0_3d-migrate-r5_4d -- 18imsm-r1_2d-takeover-r0_1d -- 16imsm-r0_5d-migrate-r5_6d - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/16imsm-r0_3d-migrate-r5_4d | 1 + - tests/16imsm-r0_5d-migrate-r5_6d | 1 + - tests/18imsm-r1_2d-takeover-r0_1d | 2 +- - 3 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/tests/16imsm-r0_3d-migrate-r5_4d b/tests/16imsm-r0_3d-migrate-r5_4d -index 4f45479a..265adf94 100644 ---- a/tests/16imsm-r0_3d-migrate-r5_4d -+++ b/tests/16imsm-r0_3d-migrate-r5_4d -@@ -15,6 +15,7 @@ vol0_offset=0 - - # After: RAID 5, 4 disks, 64k chunk size - vol0_new_level=5 -+new_num_disks=4 - vol0_new_num_comps=$num_disks - vol0_new_chunk=64 - -diff --git a/tests/16imsm-r0_5d-migrate-r5_6d b/tests/16imsm-r0_5d-migrate-r5_6d -index bee505bf..535b6099 100644 ---- a/tests/16imsm-r0_5d-migrate-r5_6d -+++ b/tests/16imsm-r0_5d-migrate-r5_6d -@@ -17,5 +17,6 @@ vol0_offset=0 - vol0_new_level=5 - vol0_new_num_comps=$num_disks - vol0_new_chunk=64 -+new_num_disks=6 - - . tests/imsm-grow-template 0 1 -diff --git a/tests/18imsm-r1_2d-takeover-r0_1d b/tests/18imsm-r1_2d-takeover-r0_1d -index cb10ec97..fd5852ed 100644 ---- a/tests/18imsm-r1_2d-takeover-r0_1d -+++ b/tests/18imsm-r1_2d-takeover-r0_1d -@@ -17,6 +17,6 @@ vol0_offset=0 - vol0_new_level=0 - vol0_new_num_comps=1 - vol0_new_chunk=64 --new_num_disks=0 -+new_num_disks=1 - - . tests/imsm-grow-template 0 1 --- -2.17.1 - diff --git a/debian/patches/0036-tests-imsm-Test-shouldn-t-call-grow-with-chunk-and-l.patch b/debian/patches/0036-tests-imsm-Test-shouldn-t-call-grow-with-chunk-and-l.patch deleted file mode 100644 index c9798909..00000000 --- a/debian/patches/0036-tests-imsm-Test-shouldn-t-call-grow-with-chunk-and-l.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 1a90fd84582757ae384c85f0c477f52eb6f66e81 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Fri, 22 Jun 2018 16:34:10 +0200 -Subject: [PATCH 36/40] tests, imsm: Test shouldn't call grow with chunk and - level in one command - -Since a3b831c9 "Grow.c: Block any level migration with chunk size change" -there is no possibility to perform migration between level and chunk in -one operation. When any test tries to do this error message is printed -and tests finishes with fail. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/imsm-grow-template | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -diff --git a/tests/imsm-grow-template b/tests/imsm-grow-template -index 71a0bbb1..428e448e 100644 ---- a/tests/imsm-grow-template -+++ b/tests/imsm-grow-template -@@ -13,10 +13,15 @@ function grow_member() { - local size=$5 - local offset=$6 - local chunk=$7 -+ local old_chunk=$8 - local array_size=$((comps * size)) - - rm -f $backup_imsm -- ( set -ex; mdadm --grow $member --chunk=$chunk --level=$level ) -+ if [ $chunk -eq $old_chunk ]; then -+ ( set -ex; mdadm --grow $member --level=$level ) -+ else -+ ( set -ex; mdadm --grow $member --chunk=$chunk ) -+ fi - local status=$? - if [ $negative_test -ne 0 ]; then - if [ $status -eq 0 ]; then -@@ -76,9 +81,9 @@ if [ $migration_test -ne 0 ]; then - if [ -z $new_num_disks ]; then - new_num_disks=$num_disks - fi -- grow_member $member0 $new_num_disks $vol0_new_num_comps $vol0_new_level $vol0_comp_size $vol0_offset $vol0_new_chunk -+ grow_member $member0 $new_num_disks $vol0_new_num_comps $vol0_new_level $vol0_comp_size $vol0_offset $vol0_new_chunk $vol0_chunk - if [[ $vol1_new_chunk -ne 0 ]] ; then -- grow_member $member1 $new_num_disks $vol1_new_num_comps $vol1_new_level $vol1_comp_size $vol1_offset $vol1_new_chunk -+ grow_member $member1 $new_num_disks $vol1_new_num_comps $vol1_new_level $vol1_comp_size $vol1_offset $vol1_new_chunk $vol1_chunk - fi - else - rm -f $backup_imsm --- -2.17.1 - diff --git a/debian/patches/0037-tests-imsm-Migration-from-RAID5-to-RAID0-is-not-supp.patch b/debian/patches/0037-tests-imsm-Migration-from-RAID5-to-RAID0-is-not-supp.patch deleted file mode 100644 index 671b8498..00000000 --- a/debian/patches/0037-tests-imsm-Migration-from-RAID5-to-RAID0-is-not-supp.patch +++ /dev/null @@ -1,60 +0,0 @@ -From f49f083e2ccfe3d0c72819cf4aa615d3dce85cda Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Fri, 22 Jun 2018 16:34:11 +0200 -Subject: [PATCH 37/40] tests, imsm: Migration from RAID5 to RAID0 is not - supported for IMSM metadata - -When test tries to change RAID level from RAID5 to RAID0 mdadm respond with -error about unsporrted operation. - -Make 16imsm-r5_3d-migrate-r0_3d and 16imsm-r5_5d-migrate-r0_5d test -negative. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/16imsm-r5_3d-migrate-r0_3d | 4 ++-- - tests/16imsm-r5_5d-migrate-r0_5d | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/tests/16imsm-r5_3d-migrate-r0_3d b/tests/16imsm-r5_3d-migrate-r0_3d -index b1459cc1..bcb57090 100644 ---- a/tests/16imsm-r5_3d-migrate-r0_3d -+++ b/tests/16imsm-r5_3d-migrate-r0_3d -@@ -1,7 +1,7 @@ - . tests/env-imsm-template - - # RAID 5 volume (3 disks) migrate to RAID 0 volume (2 disks) --# POSITIVE test -+# NEGATIVE test - - num_disks=3 - device_list="$dev0 $dev1 $dev2" -@@ -18,4 +18,4 @@ vol0_new_level=0 - vol0_new_num_comps=$((num_disks-1)) - vol0_new_chunk=64 - --. tests/imsm-grow-template 0 1 -+. tests/imsm-grow-template 1 1 -diff --git a/tests/16imsm-r5_5d-migrate-r0_5d b/tests/16imsm-r5_5d-migrate-r0_5d -index 323ca52e..ca77435f 100644 ---- a/tests/16imsm-r5_5d-migrate-r0_5d -+++ b/tests/16imsm-r5_5d-migrate-r0_5d -@@ -1,7 +1,7 @@ - . tests/env-imsm-template - - # RAID 5 volume (5 disks) migration to RAID 0 volume (4 disks) --# POSITIVE test -+# NEGATIVE test - - num_disks=5 - device_list="$dev0 $dev1 $dev2 $dev3 $dev4" -@@ -18,4 +18,4 @@ vol0_new_level=0 - vol0_new_num_comps=$((num_disks - 1)) - vol0_new_chunk=64 - --. tests/imsm-grow-template 0 1 -+. tests/imsm-grow-template 1 1 --- -2.17.1 - diff --git a/debian/patches/0038-tests-imsm-Calculate-expected-array_size-in-proper-w.patch b/debian/patches/0038-tests-imsm-Calculate-expected-array_size-in-proper-w.patch deleted file mode 100644 index 65689e3a..00000000 --- a/debian/patches/0038-tests-imsm-Calculate-expected-array_size-in-proper-w.patch +++ /dev/null @@ -1,101 +0,0 @@ -From cf42a1c7074a4f6258e6f0e4c122a93fd9c89850 Mon Sep 17 00:00:00 2001 -From: Michal Zylowski <michal.zylowski@intel.com> -Date: Fri, 22 Jun 2018 16:34:12 +0200 -Subject: [PATCH 38/40] tests, imsm: Calculate expected array_size in proper - way - -Tests should calucalte expected array_size accordingly to raid level. Also -tests should take care about runding to neares MB introduced from b53bfba6 -"imsm: use rounded size for metadata initialization". - -Expect proper size in tests. Simplify 09imsm-overlap test by creating array -with size which has not been rounded. Main purpose of this test is checking -something else. - -Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - tests/09imsm-create-fail-rebuild | 4 ++-- - tests/09imsm-overlap | 2 +- - tests/env-imsm-template | 28 +++++++++++++++++++++++----- - 3 files changed, 26 insertions(+), 8 deletions(-) - -diff --git a/tests/09imsm-create-fail-rebuild b/tests/09imsm-create-fail-rebuild -index 886d385a..f09b437b 100644 ---- a/tests/09imsm-create-fail-rebuild -+++ b/tests/09imsm-create-fail-rebuild -@@ -36,7 +36,7 @@ mdadm -CR $member0 $dev0 $dev1 -n $num_disks -l $level -z $size -c $chunk - imsm_check member $member0 $num_disks $level $size $((size*2)) $offset $chunk - testdev $member0 $num_disks $size $chunk - --offset=$(((size & ~(chunk - 1)) + 4096)) -+offset=$(((size & ~(1024 - 1)) + 4096)) - size=4000 - level=1 - chunk=0 -@@ -60,7 +60,7 @@ mdadm -CR $member0 $dev0 $dev1 $dev2 $dev3 -n $num_disks -l $level -z $size -c $ - imsm_check member $member0 $num_disks $level $size $((size*2)) $offset $chunk - testdev $member0 $((num_disks-2)) $size $chunk - --offset=$(((size & ~(chunk - 1)) + 4096)) -+offset=$(((size & ~(1024 - 1)) + 4096)) - size=4000 - level=5 - mdadm -CR $member1 $dev0 $dev1 $dev2 $dev3 -n $num_disks -l $level -z $size -c $chunk -diff --git a/tests/09imsm-overlap b/tests/09imsm-overlap -index 2d1ab692..ff5d2093 100644 ---- a/tests/09imsm-overlap -+++ b/tests/09imsm-overlap -@@ -5,7 +5,7 @@ - mdadm -CR $container -e imsm -n 6 $dev0 $dev1 $dev2 $dev3 $dev4 $dev5 - imsm_check container 6 - --size=1910 -+size=1024 - level=1 - num_disks=2 - mdadm -CR $member0 $dev0 $dev1 -n $num_disks -l $level -z $size -diff --git a/tests/env-imsm-template b/tests/env-imsm-template -index 40479b48..d5247714 100644 ---- a/tests/env-imsm-template -+++ b/tests/env-imsm-template -@@ -14,13 +14,31 @@ imsm_check() { - t_offset=$7 - t_chunk=$8 - -- if [ $t_level -ne 1 ]; then -- t_rd_size=$((t_rd_size & ~(t_chunk - 1))) -- else -+ t_rd_size=$((t_rd_size & ~(1024 - 1))) -+ -+ if [ $t_level -eq 1 ]; then - t_chunk=64 - fi -- t_size=$((t_size/1024)) -- t_size=$((t_size*1024)) -+ -+ t_num_data_disks=0 -+ -+ case $t_level in -+ 0) -+ t_num_data_disks=$t_num_disks -+ ;; -+ 1) -+ t_num_data_disks=1 -+ ;; -+ 5) -+ t_num_data_disks=$((t_num_disks-1)) -+ ;; -+ 10) -+ t_num_data_disks=$((t_num_disks/2)) -+ ;; -+ esac -+ -+ t_size=$((t_rd_size*t_num_data_disks)) -+ - err=0 - - eval `stat -L -c "let major=0x%t; let minor=0x%T;" $t_member` --- -2.17.1 - diff --git a/debian/patches/0039-mapfile-set-mapp-to-NULL-after-map_free.patch b/debian/patches/0039-mapfile-set-mapp-to-NULL-after-map_free.patch deleted file mode 100644 index f2791f44..00000000 --- a/debian/patches/0039-mapfile-set-mapp-to-NULL-after-map_free.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 531d7991476f8358a36fb7f320db93d38b0e4c8d Mon Sep 17 00:00:00 2001 -From: Guoqing Jiang <gqjiang@suse.com> -Date: Thu, 19 Jul 2018 09:40:42 +0800 -Subject: [PATCH 39/40] mapfile: set *mapp to NULL after map_free - -We can see "double free or corruption" with below steps -as reported by Mariusz: - -export IMSM_NO_PLATFORM=1 -export IMSM_DEVNAME_AS_SERIAL=1 -mdadm --zero-super /dev/sd* -mdadm -C /dev/md/imsm -n2 -eimsm /dev/sdb /dev/sdc --run -mdadm -C /dev/md/r1 -n2 -z15G -eimsm /dev/sdb /dev/sdc -l1 --run --assume-clean -mdadm -f /dev/md126 /dev/sdb -mdadm -Ss - -It is caused by Manage_stop calls map_remove and map_unlock, -but *mapp is not set to NULL after map_remove -> map_free, -so map_unlock will call map_free again. - -Reported-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com> -Tested-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com> -Signed-off-by: Guoqing Jiang <gqjiang@suse.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - mapfile.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/mapfile.c b/mapfile.c -index a5025563..8d7acb3c 100644 ---- a/mapfile.c -+++ b/mapfile.c -@@ -268,6 +268,7 @@ void map_remove(struct map_ent **mapp, char *devnm) - map_delete(mapp, devnm); - map_write(*mapp); - map_free(*mapp); -+ *mapp = NULL; - } - - struct map_ent *map_by_uuid(struct map_ent **map, int uuid[4]) --- -2.17.1 - diff --git a/debian/patches/0040-Assemble-remove-the-protection-when-clustered-raid-d.patch b/debian/patches/0040-Assemble-remove-the-protection-when-clustered-raid-d.patch deleted file mode 100644 index 22c1bc83..00000000 --- a/debian/patches/0040-Assemble-remove-the-protection-when-clustered-raid-d.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 80d1256e98b4995b0a753678f6c7e4a8bb369741 Mon Sep 17 00:00:00 2001 -From: Guoqing Jiang <gqjiang@suse.com> -Date: Fri, 20 Jul 2018 16:05:14 +0800 -Subject: [PATCH 40/40] Assemble: remove the protection when clustered raid do - assemble - -For HA product, RA (resource agent) assembles cluster raid -through call below cmd: - -$MDADM --assemble $mddev --config=$RAIDCONF $MDADM_HOMEHOST - -Sometimes node can't assemble array because all the nodes -need to contend dlm lock, which causes node fence in automatic -test. - -And in fact, we don't need the protection since the assemble -cmd called by RA doesn't change superblock, so revert the -commit 76781701a487090172d32befae07671a10ea88ad ("Assemble: -provide protection when clustered raid do assemble") to remove -unneccessary protection. - -Signed-off-by: Guoqing Jiang <gqjiang@suse.com> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - Assemble.c | 21 --------------------- - 1 file changed, 21 deletions(-) - -diff --git a/Assemble.c b/Assemble.c -index 0a7ab6f5..23892a37 100644 ---- a/Assemble.c -+++ b/Assemble.c -@@ -1348,9 +1348,6 @@ int Assemble(struct supertype *st, char *mddev, - char chosen_name[1024]; - struct map_ent *map = NULL; - struct map_ent *mp; -- int locked = 0; -- struct mdp_superblock_1 *sb; -- bitmap_super_t *bms; - - /* - * If any subdevs are listed, then any that don't -@@ -1381,12 +1378,6 @@ try_again: - * set of devices failed. Those are now marked as ->used==2 and - * we ignore them and try again - */ -- if (locked) -- /* -- * if come back try_again is called, then need to unlock first, -- * and lock again since the metadate is re-read. -- */ -- cluster_release_dlmlock(); - if (!st && ident->st) - st = ident->st; - if (c->verbose>0) -@@ -1404,14 +1395,6 @@ try_again: - if (!st || !st->sb || !content) - return 2; - -- sb = st->sb; -- bms = (bitmap_super_t*)(((char*)sb) + 4096); -- if (sb && bms->version == BITMAP_MAJOR_CLUSTERED) { -- locked = cluster_get_dlmlock(); -- if (locked != 1) -- return 1; -- } -- - /* We have a full set of devices - we now need to find the - * array device. - * However there is a risk that we are racing with "mdadm -I" -@@ -1542,8 +1525,6 @@ try_again: - err = assemble_container_content(st, mdfd, content, c, - chosen_name, NULL); - close(mdfd); -- if (locked == 1) -- cluster_release_dlmlock(); - return err; - } - -@@ -1888,8 +1869,6 @@ out: - close(mdfd); - - /* '2' means 'OK, but not started yet' */ -- if (locked == 1) -- cluster_release_dlmlock(); - if (rv == -1) { - free(devices); - return 1; --- -2.17.1 - diff --git a/debian/patches/debian-conffile-location.diff b/debian/patches/debian-conffile-location.diff index e3b3e9bf..26b9a020 100644 --- a/debian/patches/debian-conffile-location.diff +++ b/debian/patches/debian-conffile-location.diff @@ -17,9 +17,11 @@ Reviewed-by: martin f. krafft <madduck@debian.org> mdassemble.8 | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) ---- a/Makefile -+++ b/Makefile -@@ -68,8 +68,8 @@ +Index: mdadm-4.1/Makefile +=================================================================== +--- mdadm-4.1.orig/Makefile ++++ mdadm-4.1/Makefile +@@ -72,8 +72,8 @@ CPPFLAGS += -DBINDIR=\"$(BINDIR)\" PKG_CONFIG ?= pkg-config SYSCONFDIR = /etc @@ -30,9 +32,11 @@ Reviewed-by: martin f. krafft <madduck@debian.org> MAILCMD =/usr/sbin/sendmail -t CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\" # Both MAP_DIR and MDMON_DIR should be somewhere that persists across the ---- a/ReadMe.c -+++ b/ReadMe.c -@@ -609,7 +609,7 @@ +Index: mdadm-4.1/ReadMe.c +=================================================================== +--- mdadm-4.1.orig/ReadMe.c ++++ mdadm-4.1/ReadMe.c +@@ -609,7 +609,7 @@ char Help_incr[] = ; char Help_config[] = @@ -41,9 +45,11 @@ Reviewed-by: martin f. krafft <madduck@debian.org> " The config file contains, apart from blank lines and comment lines that\n" " start with a hash(#), array lines, device lines, and various\n" " configuration lines.\n" ---- a/mdadm.8.in -+++ b/mdadm.8.in -@@ -267,13 +267,13 @@ +Index: mdadm-4.1/mdadm.8.in +=================================================================== +--- mdadm-4.1.orig/mdadm.8.in ++++ mdadm-4.1/mdadm.8.in +@@ -267,13 +267,13 @@ the exact meaning of this option in diff .TP .BR \-c ", " \-\-config= Specify the config file or directory. Default is to use @@ -61,7 +67,7 @@ Reviewed-by: martin f. krafft <madduck@debian.org> If the config file given is .B "partitions" then nothing will be read, but -@@ -1952,9 +1952,9 @@ +@@ -1952,9 +1952,9 @@ The config file is only used if explicit or requested with (a possibly implicit) .BR \-\-scan . In the later case, @@ -73,7 +79,7 @@ Reviewed-by: martin f. krafft <madduck@debian.org> is used. If -@@ -3276,7 +3276,7 @@ +@@ -3264,7 +3264,7 @@ uses this to find arrays when is given in Misc mode, and to monitor array reconstruction on Monitor mode. @@ -82,7 +88,7 @@ Reviewed-by: martin f. krafft <madduck@debian.org> The config file lists which devices may be scanned to see if they contain MD super block, and gives identifying information -@@ -3284,7 +3284,7 @@ +@@ -3272,7 +3272,7 @@ they contain MD super block, and gives i .BR mdadm.conf (5) for more details. @@ -91,8 +97,10 @@ Reviewed-by: martin f. krafft <madduck@debian.org> A directory containing configuration files which are read in lexical order. ---- a/mdadm.conf.5 -+++ b/mdadm.conf.5 +Index: mdadm-4.1/mdadm.conf.5 +=================================================================== +--- mdadm-4.1.orig/mdadm.conf.5 ++++ mdadm-4.1/mdadm.conf.5 @@ -8,7 +8,7 @@ .SH NAME mdadm.conf \- configuration for management of Software RAID with mdadm diff --git a/debian/patches/debian-no-Werror.diff b/debian/patches/debian-no-Werror.diff index 6772cef3..2cdac7c1 100644 --- a/debian/patches/debian-no-Werror.diff +++ b/debian/patches/debian-no-Werror.diff @@ -11,9 +11,11 @@ Signed-off-by: martin f. krafft <madduck@debian.org> Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) ---- a/Makefile -+++ b/Makefile -@@ -44,7 +44,7 @@ +Index: mdadm-4.1/Makefile +=================================================================== +--- mdadm-4.1.orig/Makefile ++++ mdadm-4.1/Makefile +@@ -48,7 +48,7 @@ endif CC ?= $(CROSS_COMPILE)gcc CXFLAGS ?= -ggdb diff --git a/debian/patches/series b/debian/patches/series index 60f1eed3..5377d1c6 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,46 +1,16 @@ -0001-mdadm-fix-use-after-free-after-free_mdstat.patch -0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch -0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch -0004-imsm-change-reserved-space-to-4MB.patch -0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch -0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch -0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch -0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch -0009-mdadm-grow-correct-size-and-chunk_size-casting.patch -0010-Fix-misspelling-of-alignment-and-geometry.patch -0011-Do-not-confuse-gcc.patch -0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch -0013-super-intel-Get-rid-of-unnused-string.patch -0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch -0015-super-intel-Do-not-truncate-last-character-of-volume.patch -0016-imsm-Do-not-block-volume-creation-when-container-has.patch -0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch -0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch -0019-mdopen-fix-gcc-8.1-string-overflow-error.patch -0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch -0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch -0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch -0023-Check-major-number-of-block-device-when-querying-md-.patch -0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch -0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch -0026-gcc-8-coverity-hack.patch -0027-Assemble.c-Don-t-ignore-faulty-disk-when-array-is-au.patch -0028-imsm-correct-num_data_stripes-in-metadata-map-for-mi.patch -0029-Free-map-to-avoid-resource-leak-issues.patch -0030-Coverity-Resource-leak-fix-return-without-free.patch -0031-Coverity-Resource-leak-close-fds-and-free-array-befo.patch -0032-Coverity-Resource-leak-close-fd-before-return.patch -0033-tests-imsm-Set-correct-expected-offset-between-volum.patch -0034-tests-imsm-Fix-unit-inconsistency-in-tests-error-mes.patch -0035-tests-imsm-Set-new_num_disks-value-corectly-to-perfo.patch -0036-tests-imsm-Test-shouldn-t-call-grow-with-chunk-and-l.patch -0037-tests-imsm-Migration-from-RAID5-to-RAID0-is-not-supp.patch -0038-tests-imsm-Calculate-expected-array_size-in-proper-w.patch -0039-mapfile-set-mapp-to-NULL-after-map_free.patch -0040-Assemble-remove-the-protection-when-clustered-raid-d.patch +0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch +0002-Document-PART-POLICY-lines.patch +0003-policy-support-devices-with-multiple-paths.patch +0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch +0005-Monitor-add-system-timer-to-run-oneshot-periodically.patch +0006-imsm-update-metadata-correctly-while-raid10-double-d.patch +0007-Assemble-mask-FAILFAST-and-WRITEMOSTLY-flags-when-fi.patch +0008-Grow-avoid-overflow-in-compute_backup_blocks.patch +0009-Grow-report-correct-new-chunk-size.patch +0010-policy.c-prevent-NULL-pointer-referencing.patch +0011-policy.c-Fix-for-compiler-error.patch debian-conffile-location.diff debian-no-Werror.diff sha1-includes.diff readlink-path.patch mdmonitor-service-simplify.diff -0001-udev.rules-make-safe-timeouts-compatible-with-split-.patch @@ -24,7 +24,7 @@ ANNOUNCE-3.3.3 ANNOUNCE-3.3.4 ANNOUNCE-3.4 ANNOUNCE-4.0 -ANNOUNCE-4.1-rc1 +ANNOUNCE-4.1 Assemble.c Build.c COPYING @@ -67,6 +67,7 @@ clustermd_tests/03r1_switch-resync clustermd_tests/cluster_conf clustermd_tests/func.sh config.c +coverity-gcc-hack.h crc32.c crc32.h crc32c.c @@ -5,7 +5,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. -.TH MDADM 8 "" v4.1-rc1 +.TH MDADM 8 "" v4.1-rc2 .SH NAME mdadm \- manage MD devices .I aka @@ -1959,7 +1959,7 @@ static int misc_list(struct mddev_dev *devlist, rv |= Kill(dv->devname, NULL, c->force, v, 0); v = -1; } while (rv == 0); - rv &= ~2; + rv &= ~4; } continue; case 'Q': diff --git a/mdadm.conf.5 b/mdadm.conf.5 index 542e2635..36918f6f 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 @@ -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); @@ -1,6 +1,6 @@ Summary: mdadm is used for controlling Linux md devices (aka RAID arrays) Name: mdadm -Version: 4.1_rc1 +Version: 4.1 Release: 1 Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.gz URL: http://neil.brown.name/blog/mdadm @@ -1,5 +1,5 @@ .\" See file COPYING in distribution for details. -.TH MDMON 8 "" v4.1-rc1 +.TH MDMON 8 "" v4.1-rc2 .SH NAME mdmon \- monitor MD external metadata arrays diff --git a/platform-intel.c b/platform-intel.c index a11101db..04bffc57 100644 --- a/platform-intel.c +++ b/platform-intel.c @@ -371,6 +371,9 @@ static int scan(const void *start, const void *end, const void *data) if (__le16_to_cpu(ptr->vendorID) != 0x8086) return 0; + if (get_orom_by_device_id(ptr->deviceID)) + return 0; + for (offset = 0; offset < len; offset += 4) { const void *mem = start + offset; @@ -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 this rule matches on path and type */ + /* 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 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 = NULL; + 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-4; - 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 && 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; } diff --git a/super-intel.c b/super-intel.c index f011a31f..d2035ccd 100644 --- a/super-intel.c +++ b/super-intel.c @@ -4523,6 +4523,11 @@ static int find_intel_hba_capability(int fd, struct intel_super *super, char *de struct sys_dev *hba_name; int rv = 0; + if (fd >= 0 && test_partition(fd)) { + pr_err("imsm: %s is a partition, cannot be used in IMSM\n", + devname); + return 1; + } if (fd < 0 || check_env("IMSM_NO_PLATFORM")) { super->orom = NULL; super->hba = NULL; @@ -5285,10 +5290,22 @@ static int check_name(struct intel_super *super, char *name, int quiet) { struct imsm_super *mpb = super->anchor; char *reason = NULL; + char *start = name; + size_t len = strlen(name); int i; - if (strlen(name) > MAX_RAID_SERIAL_LEN) + if (len > 0) { + while (isspace(start[len - 1])) + start[--len] = 0; + while (*start && isspace(*start)) + ++start, --len; + memmove(name, start, len + 1); + } + + if (len > MAX_RAID_SERIAL_LEN) reason = "must be 16 characters or less"; + else if (len == 0) + reason = "must be a non-empty string"; for (i = 0; i < mpb->num_raid_devs; i++) { struct imsm_dev *dev = get_imsm_dev(super, i); @@ -8119,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)); @@ -8541,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 */ @@ -8558,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; diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service new file mode 100644 index 00000000..592c6079 --- /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 00000000..3ccfd785 --- /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 00000000..812141bb --- /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 00000000..64807362 --- /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 diff --git a/systemd/mdmonitor-oneshot.service b/systemd/mdmonitor-oneshot.service new file mode 100644 index 00000000..fd469b12 --- /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 00000000..cb54bdaa --- /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 |