summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2018-07-23 11:41:17 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2018-07-23 11:41:17 +0100
commit3bed5265f9c792edfcd593eeaa93675711e5e264 (patch)
tree60fcbcc5048f276f07022b12d9b34245a6e8ae8d
parent9421e599c44cd50d3df4cd019cd3c53d9320e93d (diff)
Cherrypick master patches up to 20th of July 2018. LP: #1781427
-rw-r--r--Assemble.c27
-rw-r--r--Detail.c2
-rw-r--r--Dump.c3
-rw-r--r--Grow.c1
-rw-r--r--Incremental.c4
-rw-r--r--config.c3
-rw-r--r--debian/changelog6
-rw-r--r--debian/patches/0001-mdadm-fix-use-after-free-after-free_mdstat.patch2
-rw-r--r--debian/patches/0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch2
-rw-r--r--debian/patches/0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch2
-rw-r--r--debian/patches/0004-imsm-change-reserved-space-to-4MB.patch2
-rw-r--r--debian/patches/0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch2
-rw-r--r--debian/patches/0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch2
-rw-r--r--debian/patches/0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch2
-rw-r--r--debian/patches/0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch2
-rw-r--r--debian/patches/0009-mdadm-grow-correct-size-and-chunk_size-casting.patch2
-rw-r--r--debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch2
-rw-r--r--debian/patches/0011-Do-not-confuse-gcc.patch2
-rw-r--r--debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch2
-rw-r--r--debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch2
-rw-r--r--debian/patches/0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch2
-rw-r--r--debian/patches/0015-super-intel-Do-not-truncate-last-character-of-volume.patch2
-rw-r--r--debian/patches/0016-imsm-Do-not-block-volume-creation-when-container-has.patch2
-rw-r--r--debian/patches/0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch2
-rw-r--r--debian/patches/0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch2
-rw-r--r--debian/patches/0019-mdopen-fix-gcc-8.1-string-overflow-error.patch2
-rw-r--r--debian/patches/0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch2
-rw-r--r--debian/patches/0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch2
-rw-r--r--debian/patches/0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch2
-rw-r--r--debian/patches/0023-Check-major-number-of-block-device-when-querying-md-.patch2
-rw-r--r--debian/patches/0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch2
-rw-r--r--debian/patches/0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch2
-rw-r--r--debian/patches/0026-gcc-8-coverity-hack.patch2
-rw-r--r--debian/patches/0027-Assemble.c-Don-t-ignore-faulty-disk-when-array-is-au.patch41
-rw-r--r--debian/patches/0028-imsm-correct-num_data_stripes-in-metadata-map-for-mi.patch64
-rw-r--r--debian/patches/0029-Free-map-to-avoid-resource-leak-issues.patch142
-rw-r--r--debian/patches/0030-Coverity-Resource-leak-fix-return-without-free.patch27
-rw-r--r--debian/patches/0031-Coverity-Resource-leak-close-fds-and-free-array-befo.patch29
-rw-r--r--debian/patches/0032-Coverity-Resource-leak-close-fd-before-return.patch26
-rw-r--r--debian/patches/0033-tests-imsm-Set-correct-expected-offset-between-volum.patch220
-rw-r--r--debian/patches/0034-tests-imsm-Fix-unit-inconsistency-in-tests-error-mes.patch31
-rw-r--r--debian/patches/0035-tests-imsm-Set-new_num_disks-value-corectly-to-perfo.patch61
-rw-r--r--debian/patches/0036-tests-imsm-Test-shouldn-t-call-grow-with-chunk-and-l.patch53
-rw-r--r--debian/patches/0037-tests-imsm-Migration-from-RAID5-to-RAID0-is-not-supp.patch60
-rw-r--r--debian/patches/0038-tests-imsm-Calculate-expected-array_size-in-proper-w.patch101
-rw-r--r--debian/patches/0039-mapfile-set-mapp-to-NULL-after-map_free.patch43
-rw-r--r--debian/patches/0040-Assemble-remove-the-protection-when-clustered-raid-d.patch90
-rw-r--r--debian/patches/series14
-rw-r--r--mapfile.c3
-rw-r--r--mdadm.c2
-rw-r--r--super-intel.c16
-rw-r--r--tests/09imsm-create-fail-rebuild4
-rw-r--r--tests/09imsm-overlap12
-rw-r--r--tests/13imsm-r0_r0_2d-grow-r0_r0_4d2
-rw-r--r--tests/13imsm-r0_r0_2d-grow-r0_r0_5d2
-rw-r--r--tests/13imsm-r0_r0_3d-grow-r0_r0_4d2
-rw-r--r--tests/13imsm-r0_r5_3d-grow-r0_r5_4d2
-rw-r--r--tests/13imsm-r0_r5_3d-grow-r0_r5_5d2
-rw-r--r--tests/13imsm-r5_r0_3d-grow-r5_r0_4d2
-rw-r--r--tests/13imsm-r5_r0_3d-grow-r5_r0_5d2
-rw-r--r--tests/14imsm-r0_3d-r5_3d-migrate-r5_4d-r5_4d2
-rw-r--r--tests/14imsm-r0_r0_2d-takeover-r10_4d2
-rw-r--r--tests/14imsm-r10_r5_4d-takeover-r0_2d2
-rw-r--r--tests/15imsm-r5_r0_3d_64k-migrate-r5_r0_3d_256k2
-rw-r--r--tests/16imsm-r0_3d-migrate-r5_4d1
-rw-r--r--tests/16imsm-r0_5d-migrate-r5_6d1
-rw-r--r--tests/16imsm-r5_3d-migrate-r0_3d4
-rw-r--r--tests/16imsm-r5_5d-migrate-r0_5d4
-rw-r--r--tests/18imsm-r1_2d-takeover-r0_1d2
-rw-r--r--tests/env-imsm-template30
-rw-r--r--tests/imsm-grow-template11
71 files changed, 1123 insertions, 89 deletions
diff --git a/Assemble.c b/Assemble.c
index e83d550..23892a3 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;
}
@@ -779,6 +781,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++;
}
@@ -1344,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
@@ -1377,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)
@@ -1400,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"
@@ -1538,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;
}
@@ -1849,8 +1834,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);
@@ -1884,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;
diff --git a/Detail.c b/Detail.c
index 860241c..b3e857a 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/Dump.c b/Dump.c
index 7bdbf6f..38e8f23 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:
diff --git a/Grow.c b/Grow.c
index a4be7e7..30c5fa9 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;
diff --git a/Incremental.c b/Incremental.c
index 0beab16..0c5698e 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 48e0278..e14eae0 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/debian/changelog b/debian/changelog
index 4856fc0..bd7e75a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+mdadm (4.1~rc1-4) UNRELEASED; urgency=medium
+
+ * Cherrypick master patches up to 20th of July 2018. LP: #1781427
+
+ -- Dimitri John Ledkov <xnox@ubuntu.com> Mon, 23 Jul 2018 11:40:06 +0100
+
mdadm (4.1~rc1-3) unstable; urgency=medium
* Cherrypick master patches up to 4th of June 2018.
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
index 563a9f3..2e395e8 100644
--- 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
@@ -1,7 +1,7 @@
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/26] mdadm: fix use-after-free after free_mdstat
+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
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
index a4ef451..453460b 100644
--- 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
@@ -1,7 +1,7 @@
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/26] imsm: Allow create RAID volume with link to container
+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
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
index 0094e25..c4ceadf 100644
--- 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
@@ -1,7 +1,7 @@
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/26] tests/func.sh: Fix some total breakage in the test
+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
diff --git a/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch b/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch
index 8d00f04..22e3d21 100644
--- a/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch
+++ b/debian/patches/0004-imsm-change-reserved-space-to-4MB.patch
@@ -1,7 +1,7 @@
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/26] imsm: change reserved space to 4MB
+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.
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
index 1d7bdf7..8e36bce 100644
--- 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
@@ -1,7 +1,7 @@
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/26] imsm: add functions to get and set imsm dev size
+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>
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
index 75e706b..1a64269 100644
--- 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
@@ -1,7 +1,7 @@
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/26] imsm: pass already existing map to
+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
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
index 2435adc..76b81a9 100644
--- 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
@@ -1,7 +1,7 @@
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/26] imsm: do not use blocks_per_member in array size
+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 *
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
index 922a40c..690d05a 100644
--- 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
@@ -1,7 +1,7 @@
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/26] Prevent create IMSM volume with size smaller than 1M or
+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
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
index 1068bfc..cdaed49 100644
--- 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
@@ -1,7 +1,7 @@
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/26] mdadm/grow: correct size and chunk_size casting
+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
diff --git a/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch b/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch
index 568cdeb..0c410e6 100644
--- a/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch
+++ b/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch
@@ -1,7 +1,7 @@
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/26] Fix misspelling of 'alignment' and 'geometry'
+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
diff --git a/debian/patches/0011-Do-not-confuse-gcc.patch b/debian/patches/0011-Do-not-confuse-gcc.patch
index e0795cf..5e288fd 100644
--- a/debian/patches/0011-Do-not-confuse-gcc.patch
+++ b/debian/patches/0011-Do-not-confuse-gcc.patch
@@ -1,7 +1,7 @@
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/26] Do not confuse gcc
+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.
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
index c0d5e54..1bea6c6 100644
--- 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
@@ -1,7 +1,7 @@
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/26] super-intel: Use memcpy() to avoid confusing gcc
+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
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
index 7ba5f1b..5cf1375 100644
--- a/debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch
+++ b/debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch
@@ -1,7 +1,7 @@
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/26] super-intel: Get rid of unnused string
+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
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
index fa3b1d0..4966b01 100644
--- 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
@@ -1,7 +1,7 @@
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/26] super-intel: Avoid gcc-8.1 complaining about truncating
+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
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
index d3b621a..c4d68e7 100644
--- 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
@@ -1,7 +1,7 @@
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/26] super-intel: Do not truncate last character of volume
+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
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
index e86e4bc..75b7439 100644
--- 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
@@ -1,7 +1,7 @@
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/26] imsm: Do not block volume creation when container has
+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
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
index e664c2c..134d6c9 100644
--- 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
@@ -1,7 +1,7 @@
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/26] imsm: Do not require MDADM_EXPERIMENTAL flag anymore
+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
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
index 7dc372c..d5973f8 100644
--- 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
@@ -1,7 +1,7 @@
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/26] Monitor: Increase size of percentalert to avoid gcc
+Subject: [PATCH 18/40] Monitor: Increase size of percentalert to avoid gcc
warning
gcc-8.1 complains about truncated string operations. While we know
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
index 755459f..3431d24 100644
--- 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
@@ -1,7 +1,7 @@
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/26] mdopen: fix gcc 8.1 string overflow error
+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.
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
index 776434e..0a31b16 100644
--- 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
@@ -1,7 +1,7 @@
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/26] super0: Use memmove() when adjusting sparc2.2
+Subject: [PATCH 20/40] super0: Use memmove() when adjusting sparc2.2
superblock data
memcpy() does not allow overlapping copies, switch to memmove()
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
index 1cd2fdf..47b0296 100644
--- 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
@@ -1,7 +1,7 @@
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/26] super1: Fix cases triggering gcc-8.1 strncpy truncate
+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
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
index d31dde8..0269abe 100644
--- 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
@@ -1,7 +1,7 @@
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/26] super-ddf: Fix gcc-8.1 overflow warnings
+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.
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
index f938adb..72dbe79 100644
--- 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
@@ -1,7 +1,7 @@
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/26] Check major number of block device when querying md
+Subject: [PATCH 23/40] Check major number of block device when querying md
device
It give error message when query a non md device.
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
index 303480b..df0e38a 100644
--- 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
@@ -1,7 +1,7 @@
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/26] mdadm/test: mdadm needn't make install on the system
+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:
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
index f45238b..d265bc1 100644
--- 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
@@ -1,7 +1,7 @@
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/26] mdadm/test: correct tests/testdev as testdev in
+Subject: [PATCH 25/40] mdadm/test: correct tests/testdev as testdev in
02r5grow
Fixes: a6994ccc230b ("mdadm/test: get rid of the tests/testdev")
diff --git a/debian/patches/0026-gcc-8-coverity-hack.patch b/debian/patches/0026-gcc-8-coverity-hack.patch
index f039a5c..6cf6f6a 100644
--- a/debian/patches/0026-gcc-8-coverity-hack.patch
+++ b/debian/patches/0026-gcc-8-coverity-hack.patch
@@ -1,7 +1,7 @@
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/26] gcc-8 coverity hack
+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.
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
new file mode 100644
index 0000000..76f4b27
--- /dev/null
+++ b/debian/patches/0027-Assemble.c-Don-t-ignore-faulty-disk-when-array-is-au.patch
@@ -0,0 +1,41 @@
+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
new file mode 100644
index 0000000..57b4b36
--- /dev/null
+++ b/debian/patches/0028-imsm-correct-num_data_stripes-in-metadata-map-for-mi.patch
@@ -0,0 +1,64 @@
+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
new file mode 100644
index 0000000..d3498b7
--- /dev/null
+++ b/debian/patches/0029-Free-map-to-avoid-resource-leak-issues.patch
@@ -0,0 +1,142 @@
+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
new file mode 100644
index 0000000..dd7a10f
--- /dev/null
+++ b/debian/patches/0030-Coverity-Resource-leak-fix-return-without-free.patch
@@ -0,0 +1,27 @@
+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
new file mode 100644
index 0000000..1507ce4
--- /dev/null
+++ b/debian/patches/0031-Coverity-Resource-leak-close-fds-and-free-array-befo.patch
@@ -0,0 +1,29 @@
+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
new file mode 100644
index 0000000..498697f
--- /dev/null
+++ b/debian/patches/0032-Coverity-Resource-leak-close-fd-before-return.patch
@@ -0,0 +1,26 @@
+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
new file mode 100644
index 0000000..acd48e3
--- /dev/null
+++ b/debian/patches/0033-tests-imsm-Set-correct-expected-offset-between-volum.patch
@@ -0,0 +1,220 @@
+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
new file mode 100644
index 0000000..db466cb
--- /dev/null
+++ b/debian/patches/0034-tests-imsm-Fix-unit-inconsistency-in-tests-error-mes.patch
@@ -0,0 +1,31 @@
+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
new file mode 100644
index 0000000..cddd308
--- /dev/null
+++ b/debian/patches/0035-tests-imsm-Set-new_num_disks-value-corectly-to-perfo.patch
@@ -0,0 +1,61 @@
+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
new file mode 100644
index 0000000..c979890
--- /dev/null
+++ b/debian/patches/0036-tests-imsm-Test-shouldn-t-call-grow-with-chunk-and-l.patch
@@ -0,0 +1,53 @@
+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
new file mode 100644
index 0000000..671b849
--- /dev/null
+++ b/debian/patches/0037-tests-imsm-Migration-from-RAID5-to-RAID0-is-not-supp.patch
@@ -0,0 +1,60 @@
+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
new file mode 100644
index 0000000..65689e3
--- /dev/null
+++ b/debian/patches/0038-tests-imsm-Calculate-expected-array_size-in-proper-w.patch
@@ -0,0 +1,101 @@
+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
new file mode 100644
index 0000000..f2791f4
--- /dev/null
+++ b/debian/patches/0039-mapfile-set-mapp-to-NULL-after-map_free.patch
@@ -0,0 +1,43 @@
+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
new file mode 100644
index 0000000..22c1bc8
--- /dev/null
+++ b/debian/patches/0040-Assemble-remove-the-protection-when-clustered-raid-d.patch
@@ -0,0 +1,90 @@
+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/series b/debian/patches/series
index 50bb798..1bd818d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -24,6 +24,20 @@
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
debian-conffile-location.diff
debian-no-Werror.diff
sha1-includes.diff
diff --git a/mapfile.c b/mapfile.c
index f3c8191..8d7acb3 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;
}
@@ -266,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])
diff --git a/mdadm.c b/mdadm.c
index 5afe415..1cf5c18 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);
diff --git a/super-intel.c b/super-intel.c
index a01be13..f011a31 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;
}
diff --git a/tests/09imsm-create-fail-rebuild b/tests/09imsm-create-fail-rebuild
index de17f32..f09b437 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 & ~(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)) + 2048))
+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 e832257..ff5d209 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
@@ -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 f85efa5..66ceeb3 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 1b851a9..0da9ef3 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 27ba83b..1ff6025 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 b4bde44..2977f36 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 d0db9ae..ff15ad0 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 32ebc92..9fed88a 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 a97002d..e8beddc 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 386abee..cb7328a 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 df5b0ce..d068abb 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 9e5205e..720e575 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 da218ef..f9369d5 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
diff --git a/tests/16imsm-r0_3d-migrate-r5_4d b/tests/16imsm-r0_3d-migrate-r5_4d
index 4f45479..265adf9 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 bee505b..535b609 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/16imsm-r5_3d-migrate-r0_3d b/tests/16imsm-r5_3d-migrate-r0_3d
index b1459cc..bcb5709 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 323ca52..ca77435 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
diff --git a/tests/18imsm-r1_2d-takeover-r0_1d b/tests/18imsm-r1_2d-takeover-r0_1d
index cb10ec9..fd5852e 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
diff --git a/tests/env-imsm-template b/tests/env-imsm-template
index ea45bae..d524771 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`
@@ -30,7 +48,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
diff --git a/tests/imsm-grow-template b/tests/imsm-grow-template
index 71a0bbb..428e448 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