summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rw-r--r--Monitor.c2
-rw-r--r--Query.c5
-rw-r--r--clustermd_tests/func.sh11
-rw-r--r--coverity-gcc-hack.h10
-rw-r--r--debian/changelog6
-rw-r--r--debian/patches/0001-mdadm-fix-use-after-free-after-free_mdstat.patch4
-rw-r--r--debian/patches/0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch4
-rw-r--r--debian/patches/0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch4
-rw-r--r--debian/patches/0004-imsm-change-reserved-space-to-4MB.patch4
-rw-r--r--debian/patches/0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch4
-rw-r--r--debian/patches/0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch5
-rw-r--r--debian/patches/0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch4
-rw-r--r--debian/patches/0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch4
-rw-r--r--debian/patches/0009-mdadm-grow-correct-size-and-chunk_size-casting.patch4
-rw-r--r--debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch105
-rw-r--r--debian/patches/0011-Do-not-confuse-gcc.patch42
-rw-r--r--debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch30
-rw-r--r--debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch27
-rw-r--r--debian/patches/0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch38
-rw-r--r--debian/patches/0015-super-intel-Do-not-truncate-last-character-of-volume.patch37
-rw-r--r--debian/patches/0016-imsm-Do-not-block-volume-creation-when-container-has.patch36
-rw-r--r--debian/patches/0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch124
-rw-r--r--debian/patches/0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch31
-rw-r--r--debian/patches/0019-mdopen-fix-gcc-8.1-string-overflow-error.patch42
-rw-r--r--debian/patches/0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch34
-rw-r--r--debian/patches/0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch57
-rw-r--r--debian/patches/0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch32
-rw-r--r--debian/patches/0023-Check-major-number-of-block-device-when-querying-md-.patch48
-rw-r--r--debian/patches/0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch53
-rw-r--r--debian/patches/0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch30
-rw-r--r--debian/patches/0026-gcc-8-coverity-hack.patch74
-rw-r--r--debian/patches/series17
-rw-r--r--mdadm.8.in24
-rw-r--r--mdadm.h1
-rw-r--r--mdopen.c8
-rw-r--r--super-ddf.c5
-rw-r--r--super-intel.c59
-rw-r--r--super0.c7
-rw-r--r--super1.c22
-rw-r--r--tests/02r5grow2
-rw-r--r--tests/env-imsm-template1
-rw-r--r--util.c10
43 files changed, 981 insertions, 101 deletions
diff --git a/Makefile b/Makefile
index 8d349d1..d440084 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 -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/Monitor.c b/Monitor.c
index c7c05d2..036103f 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)
*/
diff --git a/Query.c b/Query.c
index 2bd0e2a..23fbf8a 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),
diff --git a/clustermd_tests/func.sh b/clustermd_tests/func.sh
index c2be0e5..642cc96 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
diff --git a/coverity-gcc-hack.h b/coverity-gcc-hack.h
new file mode 100644
index 0000000..2d94a8b
--- /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
diff --git a/debian/changelog b/debian/changelog
index d1a29be..4856fc0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+mdadm (4.1~rc1-3) unstable; urgency=medium
+
+ * Cherrypick master patches up to 4th of June 2018.
+
+ -- Dimitri John Ledkov 🌈 <xnox@ubuntu.com> Tue, 26 Jun 2018 15:38:04 +0100
+
mdadm (4.1~rc1-2) unstable; urgency=medium
* Install identical udev rules into d-i installer udeb, as used in the
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 4d8ce04..563a9f3 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 1/9] mdadm: fix use-after-free after free_mdstat
+Subject: [PATCH 01/26] mdadm: fix use-after-free after free_mdstat
e->percent access the mdstat_ent which was already freed in free_mdstat
@@ -33,5 +33,5 @@ index 4dcf81dd..860241ce 100644
st->ss->detail_super(st, c->homehost);
--
-2.17.0
+2.17.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
index d23c534..a4ef451 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 2/9] imsm: Allow create RAID volume with link to container
+Subject: [PATCH 02/26] 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
@@ -31,5 +31,5 @@ index 50142d81..04b1dfc9 100644
return 1;
}
--
-2.17.0
+2.17.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
index 320d1f0..0094e25 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 3/9] tests/func.sh: Fix some total breakage in the test
+Subject: [PATCH 03/26] 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
@@ -76,5 +76,5 @@ index a6995f1b..9710a53b 100644
spares=$(tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0)
[ $spares -ne $2 ] &&
--
-2.17.0
+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
index fa5a593..8d00f04 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 4/9] imsm: change reserved space to 4MB
+Subject: [PATCH 04/26] imsm: change reserved space to 4MB
Due to compatibility to the newest OROM, imsm reserved space has to be
expanded to 4MB.
@@ -28,5 +28,5 @@ index fb1b6936..52011e5b 100644
#define MAX_SECTOR_SIZE 4096
#define MULTIPLE_PPL_AREA_SIZE_IMSM (1024 * 1024) /* Size of the whole
--
-2.17.0
+2.17.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
index dfdc7f3..1d7bdf7 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 5/9] imsm: add functions to get and set imsm dev size
+Subject: [PATCH 05/26] 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>
@@ -132,5 +132,5 @@ index 52011e5b..fe2a705b 100644
num_data_stripes /= map->num_domains;
set_num_data_stripes(map, num_data_stripes);
--
-2.17.0
+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
index 0a406e8..75e706b 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,8 @@
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 6/9] imsm: pass already existing map to imsm_num_data_members
+Subject: [PATCH 06/26] 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
@@ -174,5 +175,5 @@ index fe2a705b..3fc3cf4c 100644
chunk = __le16_to_cpu(map_src->blocks_per_strip) * 512;
old_data_stripe_length = odata * chunk;
--
-2.17.0
+2.17.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
index f0fc0c4..2435adc 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 7/9] imsm: do not use blocks_per_member in array size
+Subject: [PATCH 07/26] imsm: do not use blocks_per_member in array size
calculations
mdadm assumes that blocks_per_member value is equal to num_data_stripes *
@@ -262,5 +262,5 @@ index 3fc3cf4c..c55c85f1 100644
return &super->bb;
}
--
-2.17.0
+2.17.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
index ab36140..922a40c 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 8/9] Prevent create IMSM volume with size smaller than 1M or
+Subject: [PATCH 08/26] 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
@@ -53,5 +53,5 @@ index c55c85f1..520abf5d 100644
if (st->sb) {
struct intel_super *super = st->sb;
--
-2.17.0
+2.17.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
index 34ef5c8..1068bfc 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 9/9] mdadm/grow: correct size and chunk_size casting
+Subject: [PATCH 09/26] mdadm/grow: correct size and chunk_size casting
With commit 4b74a905a67e
("mdadm/grow: Component size must be larger than chunk size") mdadm returns
@@ -28,5 +28,5 @@ index 87229692..a4be7e7b 100644
return 1;
}
--
-2.17.0
+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
new file mode 100644
index 0000000..568cdeb
--- /dev/null
+++ b/debian/patches/0010-Fix-misspelling-of-alignment-and-geometry.patch
@@ -0,0 +1,105 @@
+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'
+
+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/0011-Do-not-confuse-gcc.patch b/debian/patches/0011-Do-not-confuse-gcc.patch
new file mode 100644
index 0000000..e0795cf
--- /dev/null
+++ b/debian/patches/0011-Do-not-confuse-gcc.patch
@@ -0,0 +1,42 @@
+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
+
+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/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch b/debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch
new file mode 100644
index 0000000..c0d5e54
--- /dev/null
+++ b/debian/patches/0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch
@@ -0,0 +1,30 @@
+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
+
+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
new file mode 100644
index 0000000..7ba5f1b
--- /dev/null
+++ b/debian/patches/0013-super-intel-Get-rid-of-unnused-string.patch
@@ -0,0 +1,27 @@
+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
+
+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
new file mode 100644
index 0000000..fa3b1d0
--- /dev/null
+++ b/debian/patches/0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch
@@ -0,0 +1,38 @@
+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
+ 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
new file mode 100644
index 0000000..d3b621a
--- /dev/null
+++ b/debian/patches/0015-super-intel-Do-not-truncate-last-character-of-volume.patch
@@ -0,0 +1,37 @@
+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
+ 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
new file mode 100644
index 0000000..e86e4bc
--- /dev/null
+++ b/debian/patches/0016-imsm-Do-not-block-volume-creation-when-container-has.patch
@@ -0,0 +1,36 @@
+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
+ 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
new file mode 100644
index 0000000..e664c2c
--- /dev/null
+++ b/debian/patches/0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch
@@ -0,0 +1,124 @@
+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
+
+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
new file mode 100644
index 0000000..7dc372c
--- /dev/null
+++ b/debian/patches/0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch
@@ -0,0 +1,31 @@
+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
+ 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
new file mode 100644
index 0000000..755459f
--- /dev/null
+++ b/debian/patches/0019-mdopen-fix-gcc-8.1-string-overflow-error.patch
@@ -0,0 +1,42 @@
+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
+
+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
new file mode 100644
index 0000000..776434e
--- /dev/null
+++ b/debian/patches/0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch
@@ -0,0 +1,34 @@
+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
+ 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
new file mode 100644
index 0000000..1cd2fdf
--- /dev/null
+++ b/debian/patches/0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch
@@ -0,0 +1,57 @@
+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
+ 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
new file mode 100644
index 0000000..d31dde8
--- /dev/null
+++ b/debian/patches/0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch
@@ -0,0 +1,32 @@
+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
+
+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
new file mode 100644
index 0000000..f938adb
--- /dev/null
+++ b/debian/patches/0023-Check-major-number-of-block-device-when-querying-md-.patch
@@ -0,0 +1,48 @@
+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
+ 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
new file mode 100644
index 0000000..303480b
--- /dev/null
+++ b/debian/patches/0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch
@@ -0,0 +1,53 @@
+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
+
+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
new file mode 100644
index 0000000..f45238b
--- /dev/null
+++ b/debian/patches/0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch
@@ -0,0 +1,30 @@
+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
+ 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
new file mode 100644
index 0000000..f039a5c
--- /dev/null
+++ b/debian/patches/0026-gcc-8-coverity-hack.patch
@@ -0,0 +1,74 @@
+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
+
+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/series b/debian/patches/series
index 5cf73e5..50bb798 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,6 +7,23 @@
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
debian-conffile-location.diff
debian-no-Werror.diff
sha1-includes.diff
diff --git a/mdadm.8.in b/mdadm.8.in
index eeea6e4..0fb5a22 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 61bc7af..387e681 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/mdopen.c b/mdopen.c
index 4ec13f5..98c54e4 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]);
diff --git a/super-ddf.c b/super-ddf.c
index d02a19a..618542c 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();
diff --git a/super-intel.c b/super-intel.c
index 520abf5..a01be13 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));
@@ -3228,27 +3227,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 +3350,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,
@@ -5323,6 +5322,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 +5402,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);
@@ -5611,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;
@@ -7089,7 +7099,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) {
@@ -7582,11 +7592,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);
@@ -8092,7 +8103,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);
@@ -9876,6 +9887,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)
@@ -9887,7 +9899,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;
}
@@ -11434,7 +11446,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 +11480,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);
@@ -11595,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");
@@ -11970,7 +11979,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");
diff --git a/super0.c b/super0.c
index 756cab5..42989b9 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);
diff --git a/super1.c b/super1.c
index 6774fbd..636a286 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);
diff --git a/tests/02r5grow b/tests/02r5grow
index bb9bd6d..2da78ee 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
diff --git a/tests/env-imsm-template b/tests/env-imsm-template
index bc5f585..ea45bae 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 4adbbff..c26cf5f 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