!13 mdadm: backport upstream patches

Merge pull request !13 from liuzhiqiang/master
This commit is contained in:
openeuler-ci-bot 2020-07-14 09:10:23 +08:00 committed by Gitee
commit 8fa476d0fe
28 changed files with 758 additions and 71 deletions

View File

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

View File

@ -1,7 +1,7 @@
From 5b8c69383de07be82e44dd7b2cbb9488699192c5 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 10 Apr 2019 21:37:33 +0800
Subject: [PATCH 3/6] Document PART-POLICY lines
From 3a5189df04c3bfa74e59014de1bf7b4d1acd2c10 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Fri, 9 Nov 2018 17:12:33 +1100
Subject: [PATCH 02/27] Document PART-POLICY lines
PART-POLICY has been accepted in mdadm.conf since the same
time that POLICY was accepted, but it was never documented.
@ -9,6 +9,9 @@ So add the missing documentation.
Also fix a bug which would have stopped it from working if
anyone had ever tried to use it.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
mdadm.conf.5 | 24 +++++++++++++++++++++++-
policy.c | 2 +-
@ -70,5 +73,5 @@ index c0d18a7..258f393 100644
}
--
2.19.1
2.21.1 (Apple Git-122.3)

View File

@ -1,12 +1,16 @@
From b3d9d18abdf2c7963bb8bfcdd402cdb717c6b3a2 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 10 Apr 2019 21:40:46 +0800
Subject: [PATCH 4/6] Grow: avoid overflow in compute_backup_blocks()
From 488555f211b2bae7f54670e6f3fc3aef14215f44 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Thu, 6 Dec 2018 10:35:41 +1100
Subject: [PATCH 03/27] Grow: avoid overflow in compute_backup_blocks()
With a chunk size of 16Meg and data drive count of 8,
this calculate can easily overflow the 'int' type that
is used for the multiplications.
So force it to use "long" instead.
Reported-and-tested-by: Ed Spiridonov <edo.rus@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Grow.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@ -26,5 +30,5 @@ index 4436a4d..76f82c0 100644
return blocks;
}
--
2.19.1
2.21.1 (Apple Git-122.3)

View File

@ -1,10 +1,13 @@
From 51561342479a4469a9257562de6289cf4bd2cf1a Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 10 Apr 2019 21:43:29 +0800
Subject: [PATCH 5/6] Grow: report correct new chunk size.
From a3afc5af0cdf29652c8350d03b6d7fbb28f4ccf9 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Thu, 6 Dec 2018 10:36:28 +1100
Subject: [PATCH 04/27] Grow: report correct new chunk size.
When using "--grow --chunk=" to change chunk
size, the old chunksize is reported instead of the new.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Grow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@ -23,5 +26,5 @@ index 76f82c0..363b209 100644
unfreeze(st);
return 0;
--
2.19.1
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,7 @@
From ebf3be9931f31df54df52b1821479e6a80a4d9c6 Mon Sep 17 00:00:00 2001
From 73b33b805f386c1aee582b2579d82ae5cbbd0f98 Mon Sep 17 00:00:00 2001
From: Dimitri John Ledkov <xnox@ubuntu.com>
Date: Tue, 15 Jan 2019 19:08:37 +0000
Subject: Fix spelling typos.
Subject: [PATCH 05/27] Fix spelling typos.
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
@ -14,10 +14,10 @@ Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 23892a3..816056d 100644
index f39c9e1..3fa996f 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -873,7 +873,7 @@ static int force_array(struct mdinfo *content,
@@ -876,7 +876,7 @@ static int force_array(struct mdinfo *content,
current_events = devices[chosen_drive].i.events;
add_another:
if (c->verbose >= 0)
@ -40,7 +40,7 @@ index 04b1dfc..6f1b228 100644
goto abort_locked;
}
diff --git a/Grow.c b/Grow.c
index 4436a4d..7388123 100644
index 363b209..6d32661 100644
--- a/Grow.c
+++ b/Grow.c
@@ -446,7 +446,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
@ -52,7 +52,7 @@ index 4436a4d..7388123 100644
free(mdi);
}
rv = sysfs_set_num_signed(mdi, NULL, "bitmap/location",
@@ -2177,7 +2177,7 @@ size_change_error:
@@ -2178,7 +2178,7 @@ size_change_error:
memset(&info, 0, sizeof(info));
info.array = array;
if (sysfs_init(&info, fd, NULL)) {
@ -61,7 +61,7 @@ index 4436a4d..7388123 100644
rv = 1;
goto release;
}
@@ -2902,7 +2902,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
@@ -2903,7 +2903,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
struct mdinfo info;
if (sysfs_init(&info, fd, NULL)) {
@ -84,10 +84,10 @@ index 618542c..c095e8a 100644
}
diff --git a/super-intel.c b/super-intel.c
index f011a31..add6f2b 100644
index 6438987..401a3ea 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -9939,7 +9939,7 @@ static void imsm_process_update(struct supertype *st,
@@ -9956,7 +9956,7 @@ static void imsm_process_update(struct supertype *st,
break;
}
default:
@ -97,5 +97,5 @@ index f011a31..add6f2b 100644
}
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,8 +1,8 @@
From e3615ecb5b6ad8eb408296878aad5628e0e27166 Mon Sep 17 00:00:00 2001
From 3f772cd2f7c81f7475b425f0128e97f2cc142490 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Tue, 12 Feb 2019 12:53:18 +0800
Subject: Detail.c: do not skip first character when calling xstrdup in
Detail()
Subject: [PATCH 06/27] Detail.c: do not skip first character when calling
xstrdup in Detail()
'Commit b9c9bd9bacaa ("Detail: ensure --export names are acceptable as
shell variables")' duplicates mdi->sys_name to sysdev string by,
@ -42,5 +42,5 @@ index b3e857a..20ea03a 100644
path = map_dev(mdi->disk.major,
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,7 @@
From cab114c5ca870e5f1b57fb2602cd9a038271c2e0 Mon Sep 17 00:00:00 2001
From 896bd7389840921f586bb52d9d6b73a5cae13f52 Mon Sep 17 00:00:00 2001
From: Corey Hickey <bugfood-c@fatooh.org>
Date: Mon, 11 Feb 2019 17:18:38 -0800
Subject: Fix reshape for decreasing data offset
Subject: [PATCH 07/27] Fix reshape for decreasing data offset
...when not changing the number of disks.
@ -51,10 +51,10 @@ Signed-off-by: Jes Sorensen <jsorensen@fb.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Grow.c b/Grow.c
index 7388123..72b731e 100644
index 6d32661..764374f 100644
--- a/Grow.c
+++ b/Grow.c
@@ -2612,8 +2612,8 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
@@ -2613,8 +2613,8 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
goto release;
}
if (data_offset != INVALID_SECTORS &&
@ -66,5 +66,5 @@ index 7388123..72b731e 100644
goto release;
}
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,8 @@
From 69d084784de196acec8ab703cd1b379af211d624 Mon Sep 17 00:00:00 2001
From 195b937685f1076d9e418d01b77e3274dffb29dc Mon Sep 17 00:00:00 2001
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Date: Fri, 22 Feb 2019 10:15:45 +0100
Subject: mdmon: don't attempt to manage new arrays when terminating
Subject: [PATCH 08/27] mdmon: don't attempt to manage new arrays when
terminating
When mdmon gets a SIGTERM, it stops managing arrays that are clean. If
there is more that one array in the container and one of them is dirty
@ -45,5 +46,5 @@ index 101231c..29b91ba 100644
}
}
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,7 @@
From d2e11da4b7fd0453e942f43e4196dc63b3dbd708 Mon Sep 17 00:00:00 2001
From ba21bae7f771a7e1ac9b9eaa0e0357fa597447e8 Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
Date: Fri, 22 Feb 2019 13:30:27 +0100
Subject: mdmon: wait for previous mdmon to exit during takeover
Subject: [PATCH 09/27] mdmon: wait for previous mdmon to exit during takeover
Since the patch c76242c5("mdmon: get safe mode delay file descriptor
early"), safe_mode_dalay is set properly by initrd mdmon. But in some
@ -53,5 +53,5 @@ index 0955fcc..ff985d2 100644
void remove_pidfile(char *devname)
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,8 @@
From 2b57e4fe041d52ae29866c93a878a11c07223cff Mon Sep 17 00:00:00 2001
From 428f76d7aa74c7980cf4dbda3714a25b0d4b48ee Mon Sep 17 00:00:00 2001
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
Date: Fri, 22 Feb 2019 12:56:27 +0100
Subject: Assemble: Fix starting array with initial reshape checkpoint
Subject: [PATCH 10/27] Assemble: Fix starting array with initial reshape
checkpoint
If array was stopped during reshape initialization,
there might be a "0" checkpoint recorded in metadata.
@ -18,10 +19,10 @@ Signed-off-by: Jes Sorensen <jsorensen@fb.com>
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 816056d..3ddfa85 100644
index 3fa996f..bcf6487 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -2047,8 +2047,22 @@ int assemble_container_content(struct supertype *st, int mdfd,
@@ -2058,8 +2058,22 @@ int assemble_container_content(struct supertype *st, int mdfd,
spare, &c->backup_file, c->verbose) == 1)
return 1;
@ -47,5 +48,5 @@ index 816056d..3ddfa85 100644
return 1;
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,7 @@
From 227aeaa872d4898273cf87a4253898823d556c43 Mon Sep 17 00:00:00 2001
From 4e01454a7f340e09559f3c229f9a67381906119d Mon Sep 17 00:00:00 2001
From: Corey Hickey <bugfood-c@fatooh.org>
Date: Mon, 11 Feb 2019 17:42:27 -0800
Subject: add missing units to --examine
Subject: [PATCH 11/27] add missing units to --examine
Within the output of "mdadm --examine", there are three sizes reported
on adjacent lines. For example:
@ -28,7 +28,7 @@ Signed-off-by: Jes Sorensen <jsorensen@fb.com>
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/super1.c b/super1.c
index 636a286..7178e62 100644
index 636a286..b85dc20 100644
--- a/super1.c
+++ b/super1.c
@@ -360,7 +360,7 @@ static void examine_super1(struct supertype *st, char *homehost)
@ -55,5 +55,5 @@ index 636a286..7178e62 100644
human_size(__le64_to_cpu(sb->size)<<9));
}
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -1,7 +1,7 @@
From 22dc741f63e6403d59c2c14f56fd4791265f9bbb Mon Sep 17 00:00:00 2001
From a03332b6f634b9c504a5bef920141fa63335aeb8 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Date: Mon, 1 Apr 2019 16:53:41 +0200
Subject: Create: Block rounding size to max
Subject: [PATCH 12/27] Create: Block rounding size to max
When passed size is smaller than chunk, mdadm rounds it to 0 but 0 there
means max available space.
@ -74,10 +74,10 @@ index 6f1b228..292f92a 100644
}
}
diff --git a/super-intel.c b/super-intel.c
index add6f2b..0c54737 100644
index 401a3ea..5c3f9cb 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7368,9 +7368,8 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
@@ -7385,9 +7385,8 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
verbose);
}
@ -90,5 +90,5 @@ index add6f2b..0c54737 100644
* if container was given (dev == NULL) return -1,
* if block device was given ( dev != NULL) return 0.
--
1.7.12.4
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,38 @@
From 5d494b2e4a4fc1208e56a78cfdc8bfb20c6ffa83 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
Date: Tue, 9 Jul 2019 13:26:08 -0400
Subject: [PATCH 13/27] super-intel: Fix issue with abs() being irrelevant
gcc9 complains about subtracting unsigned from unsigned and code
assuming the result can be negative.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 5c3f9cb..988883e 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2805,7 +2805,7 @@ static unsigned long long calc_component_size(struct imsm_map *map,
{
unsigned long long component_size;
unsigned long long dev_size = imsm_dev_size(dev);
- unsigned long long calc_dev_size = 0;
+ long long calc_dev_size = 0;
unsigned int member_disks = imsm_num_data_members(map);
if (member_disks == 0)
@@ -2819,7 +2819,7 @@ static unsigned long long calc_component_size(struct imsm_map *map,
* 2048 blocks per each device. If the difference is higher it means
* that array size was expanded and num_data_stripes was not updated.
*/
- if ((unsigned int)abs(calc_dev_size - dev_size) >
+ if (llabs(calc_dev_size - (long long)dev_size) >
(1 << SECT_PER_MB_SHIFT) * member_disks) {
component_size = dev_size / member_disks;
dprintf("Invalid num_data_stripes in metadata; expected=%llu, found=%llu\n",
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,44 @@
From 055124106fe3c77db639fd7d315b099c5d52f517 Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Date: Mon, 15 Jul 2019 09:25:35 +0200
Subject: [PATCH 14/27] imsm: close removed drive fd.
When member drive fails, managemon prepares metadata update and adds
the drive to disk_mgmt_list with DISK_REMOVE flag. It fills only
minor and major. It is enough to recognize the device later.
Monitor thread while processing this update will remove the drive from
super only if it is a spare. It never removes failed member from
disks list. As a result, it still keeps opened descriptor to
non-existing device.
If removed drive is not a spare fill fd in disk_cfg structure
(prepared by managemon), monitor will close fd during freeing it.
Also set this drive fd to -1 in super to avoid double closing because
monitor will close the fd (if needed) while replacing removed drive
in array.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/super-intel.c b/super-intel.c
index 988883e..8b7709f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -9121,6 +9121,9 @@ static int add_remove_disk_update(struct intel_super *super)
remove_disk_super(super,
disk_cfg->major,
disk_cfg->minor);
+ } else {
+ disk_cfg->fd = disk->fd;
+ disk->fd = -1;
}
}
/* release allocate disk structure */
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,40 @@
From dac0e65954e43bdf93a8cfccc73108c97d060254 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Tue, 24 Sep 2019 11:39:24 -0400
Subject: [PATCH 15/27] mdadm: force a uuid swap on big endian
The code path for metadata 0.90 calls a common routine
fname_from_uuid that uses metadata 1.2. The code expects member
swapuuid to be setup and usable. But it is only setup when using
metadata 1.2. Since the metadata 0.90 did not create swapuuid
and set it. The test (st->ss == &super1) ? 1 : st->ss->swapuuid
fails. The swapuuid is set at compile time based on byte order.
Any call based on metadata 0.90 and on big endian processors,
the --export uuid will be incorrect.
Signed-Off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
util.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/util.c b/util.c
index c26cf5f..64dd409 100644
--- a/util.c
+++ b/util.c
@@ -685,8 +685,12 @@ char *fname_from_uuid(struct supertype *st, struct mdinfo *info,
// work, but can't have it set if we want this printout to match
// all the other uuid printouts in super1.c, so we force swapuuid
// to 1 to make our printout match the rest of super1
+#if __BYTE_ORDER == BIG_ENDIAN
+ return __fname_from_uuid(info->uuid, 1, buf, sep);
+#else
return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 :
st->ss->swapuuid, buf, sep);
+#endif
}
int check_ext2(int fd, char *name)
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,35 @@
From 13a018075abb72609288d865565ac4f8be34a335 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Mon, 30 Sep 2019 19:47:59 +0800
Subject: [PATCH 16/27] Init devlist as an array
devlist is an string. It will change to an array if there is disk that
is sbd disk. If one device is sbd, it runs devlist=().
This line code changes devlist from a string to an array. If there is
no sbd device, it can't run this line code. So it will still be a string.
The later codes need an array, rather than an string. So init devlist
as an array to fix this problem.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
clustermd_tests/func.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clustermd_tests/func.sh b/clustermd_tests/func.sh
index 642cc96..801d604 100644
--- a/clustermd_tests/func.sh
+++ b/clustermd_tests/func.sh
@@ -39,6 +39,9 @@ fetch_devlist()
devlist=($(ls /dev/disk/by-path/*$ISCSI_ID*))
fi
# sbd disk cannot use in testing
+ # Init devlist as an array
+ i=''
+ devlist=(${devlist[@]#$i})
for i in ${devlist[@]}
do
sbd -d $i dump &> /dev/null
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,31 @@
From 3bf7f0b83339a8b76983bbc9b806f4dffa890092 Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Mon, 30 Sep 2019 19:48:00 +0800
Subject: [PATCH 17/27] Don't need to check recovery after re-add when no I/O
writes to raid
If there is no write I/O between removing member disk and re-add it, there is no
recovery after re-adding member disk.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
clustermd_tests/02r1_Manage_re-add | 2 --
1 file changed, 2 deletions(-)
diff --git a/clustermd_tests/02r1_Manage_re-add b/clustermd_tests/02r1_Manage_re-add
index dd9c416..d0d13e5 100644
--- a/clustermd_tests/02r1_Manage_re-add
+++ b/clustermd_tests/02r1_Manage_re-add
@@ -9,8 +9,6 @@ check all state UU
check all dmesg
mdadm --manage $md0 --fail $dev0 --remove $dev0
mdadm --manage $md0 --re-add $dev0
-check $NODE1 recovery
-check all wait
check all state UU
check all dmesg
stop_md all $md0
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,52 @@
From 5983db9ecae579c1acd7a32e785ecfda5a659f9f Mon Sep 17 00:00:00 2001
From: Xiao Yang <ice_yangxiao@163.com>
Date: Wed, 27 Nov 2019 11:59:24 +0800
Subject: [PATCH 18/27] Manage: Remove the legacy code for md driver prior to
0.90.03
Previous re-add operation only calls ioctl(HOT_ADD_DISK) for array without
metadata(e.g. mdadm -B/--build) when md driver is less than 0.90.02, but
commit 091e8e6 breaks the logic and current re-add operation can call
ioctl(HOT_ADD_DISK) even if md driver is 0.90.03.
This issue is reproduced by 05r1-re-add-nosuper:
------------------------------------------------
++ die 'resync or recovery is happening!'
++ echo -e '\n\tERROR: resync or recovery is happening! \n'
ERROR: resync or recovery is happening!
------------------------------------------------
Fixes: 091e8e6("Manage: Remove all references to md_get_version()")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Manage.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/Manage.c b/Manage.c
index 21536f5..ffe55f8 100644
--- a/Manage.c
+++ b/Manage.c
@@ -741,18 +741,6 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
" Adding anyway as --force was given.\n",
dv->devname, devname);
}
- if (!tst->ss->external && array->major_version == 0) {
- if (ioctl(fd, HOT_ADD_DISK, rdev)==0) {
- if (verbose >= 0)
- pr_err("hot added %s\n",
- dv->devname);
- return 1;
- }
-
- pr_err("hot add failed for %s: %s\n",
- dv->devname, strerror(errno));
- return -1;
- }
if (array->not_persistent == 0 || tst->ss->external) {
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,32 @@
From fd91a74b58cecc99872a17883289b12e8cd1f163 Mon Sep 17 00:00:00 2001
From: Blazej Kucman <blazej.kucman@intel.com>
Date: Wed, 11 Mar 2020 15:40:13 +0100
Subject: [PATCH 19/27] imsm: Correct minimal device size.
Check if given size of member drive is not less than 1 MibiByte.
Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/super-intel.c b/super-intel.c
index 8b7709f..5da99d5 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7385,7 +7385,10 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
verbose);
}
- if (size && (size < 1024)) {
+ /*
+ * Size is given in sectors.
+ */
+ if (size && (size < 2048)) {
pr_err("Given size must be greater than 1M.\n");
/* Depends on algorithm in Create.c :
* if container was given (dev == NULL) return -1,
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,30 @@
From d4f8d99b03fb4f3da105e7f3e52d712a0dea45b7 Mon Sep 17 00:00:00 2001
From: Lidong Zhong <lidong.zhong@suse.com>
Date: Mon, 16 Mar 2020 10:16:49 +0800
Subject: [PATCH 20/27] Detail: show correct bitmap info for cluster raid
device
Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Detail.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Detail.c b/Detail.c
index 20ea03a..dadcafe 100644
--- a/Detail.c
+++ b/Detail.c
@@ -467,7 +467,9 @@ int Detail(char *dev, struct context *c)
if (ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 && bmf.pathname[0]) {
printf(" Intent Bitmap : %s\n", bmf.pathname);
printf("\n");
- } else if (array.state & (1<<MD_SB_BITMAP_PRESENT))
+ } else if (array.state & (1<<MD_SB_CLUSTERED))
+ printf(" Intent Bitmap : Internal(Clustered)\n\n");
+ else if (array.state & (1<<MD_SB_BITMAP_PRESENT))
printf(" Intent Bitmap : Internal\n\n");
atime = array.utime;
if (atime)
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,57 @@
From 0efef9d4c7dae39d01b173bb8aedddd50fc93e49 Mon Sep 17 00:00:00 2001
From: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Date: Tue, 16 Apr 2019 18:08:17 +0200
Subject: [PATCH 21/27] Assemble: print error message if mdadm fails assembling
with --uuid option
When mdadm tries to assemble one working device and one zeroed-out device,
it failed but print successful message because there is --uuid option.
Following script always reproduce it.
dd if=/dev/zero of=/dev/ram0 oflag=direct
dd if=/dev/zero of=/dev/ram1 oflag=direct
./mdadm -C /dev/md111 -e 1.2 --uuid="12345678:12345678:12345678:12345678" \
-l1 -n2 /dev/ram0 /dev/ram1
./mdadm -S /dev/md111
dd if=/dev/zero of=/dev/ram1 oflag=direct
./mdadm -A /dev/md111 --uuid="12345678:12345678:12345678:12345678" \
/dev/ram0 /dev/ram1
Following is message from mdadm.
mdadm: No super block found on /dev/ram1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/ram1
mdadm: /dev/md111 assembled from 1 drive - need all 2 to start it (use --run to insist).
The mdadm say that it assembled but mdadm does not create /dev/md111.
The message is wrong.
After applying this patch, mdadm reports error correctly as following.
mdadm: No super block found on /dev/ram1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/ram1
mdadm: /dev/ram1 has no superblock - assembly aborted
Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Assemble.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Assemble.c b/Assemble.c
index bcf6487..f302deb 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -269,7 +269,7 @@ static int select_devices(struct mddev_dev *devlist,
if (auto_assem || !inargv)
/* Ignore unrecognised devices during auto-assembly */
goto loop;
- if (ident->uuid_set || ident->name[0] ||
+ if (ident->name[0] ||
ident->super_minor != UnSet)
/* Ignore unrecognised device if looking for
* specific array */
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,34 @@
From d62151dfb6ec7f9ede978097421eeba82928710f Mon Sep 17 00:00:00 2001
From: Jes Sorensen <jsorensen@fb.com>
Date: Mon, 18 May 2020 20:19:53 -0400
Subject: [PATCH 22/27] Include count for \0 character when using strncpy to
implement strdup.
We have to include the \0 character in the length when copying a
string with strncpy() for which length was found with strlen().
Otherwise the destination will not get null terminated - except that
we explicitly zeroed it out earlier.
This quiets down the compiler's warnings.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
dlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlink.c b/dlink.c
index 3efa94b..69aa7aa 100644
--- a/dlink.c
+++ b/dlink.c
@@ -63,7 +63,7 @@ char *dl_strndup(char *s, int l)
if (s == NULL)
return NULL;
n = dl_newv(char, l+1);
- strncpy(n, s, l);
+ strncpy(n, s, l+1);
n[l] = 0;
return n;
}
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,53 @@
From 0a0051cb0e573d76a1ebd99d4ac0932fc45460d3 Mon Sep 17 00:00:00 2001
From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Date: Mon, 18 May 2020 23:53:36 +0200
Subject: [PATCH 23/27] =?UTF-8?q?restripe:=20fix=20ignoring=20return=20val?=
=?UTF-8?q?ue=20of=20=E2=80=98read=E2=80=99=20and=20lseek?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Got below error when run "make everything".
restripe.c: In function test_stripes:
restripe.c:870:4: error: ignoring return value of read, declared with attribute warn_unused_result [-Werror=unused-result]
read(source[i], stripes[i], chunk_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix it by check the return value of read, and free memory
in the failure case.
And check the return value of lseek as well per Jes's comment.
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
restripe.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/restripe.c b/restripe.c
index 31b07e8..86e1d00 100644
--- a/restripe.c
+++ b/restripe.c
@@ -866,8 +866,16 @@ int test_stripes(int *source, unsigned long long *offsets,
int disk;
for (i = 0 ; i < raid_disks ; i++) {
- lseek64(source[i], offsets[i]+start, 0);
- read(source[i], stripes[i], chunk_size);
+ if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
+ (read(source[i], stripes[i], chunk_size) !=
+ chunk_size)) {
+ free(q);
+ free(p);
+ free(blocks);
+ free(stripes);
+ free(stripe_buf);
+ return -1;
+ }
}
for (i = 0 ; i < data_disks ; i++) {
int disk = geo_map(i, start/chunk_size, raid_disks,
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,32 @@
From 5d11bd766ee17d3b9a7d96e184704723c11a99d1 Mon Sep 17 00:00:00 2001
From: Kinga Tanska <kinga.tanska@intel.com>
Date: Fri, 29 May 2020 08:31:36 +0200
Subject: [PATCH 24/27] Block overwriting existing links while manual assembly
Manual assembly with existing link caused overwriting
this link. Add checking link and block this situation.
Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Assemble.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Assemble.c b/Assemble.c
index f302deb..914c193 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1467,6 +1467,10 @@ try_again:
name = content->name;
break;
}
+ if (mddev && map_by_name(&map, mddev) != NULL) {
+ pr_err("Cannot create device with %s because is in use\n", mddev);
+ goto out;
+ }
if (!auto_assem)
/* If the array is listed in mdadm.conf or on
* command line, then we trust the name
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,76 @@
From bcc3a5ea9c631645b792f151e1beb9a4b1a4e34e Mon Sep 17 00:00:00 2001
From: David Favro <dfavro@meta-dynamic.com>
Date: Sat, 23 May 2020 08:24:59 -0400
Subject: [PATCH 25/27] Detect too-small device: error rather than
underflow/crash
For 1.x metadata, when the user requested creation of an array on
component devices that were too small even to hold the superblock,
an undetected integer wraparound (underflow) resulted in an enormous
computed size which resulted in various follow-on errors such as
floating-point exception.
This patch detects this condition, prints a reasonable diagnostic
message, and refuses to continue.
Signed-off-by: David Favro <dfavro@meta-dynamic.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super1.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/super1.c b/super1.c
index b85dc20..06bc145 100644
--- a/super1.c
+++ b/super1.c
@@ -2715,6 +2715,7 @@ static int validate_geometry1(struct supertype *st, int level,
unsigned long long ldsize, devsize;
int bmspace;
unsigned long long headroom;
+ unsigned long long overhead;
int fd;
if (level == LEVEL_CONTAINER) {
@@ -2747,10 +2748,6 @@ static int validate_geometry1(struct supertype *st, int level,
close(fd);
devsize = ldsize >> 9;
- if (devsize < 24) {
- *freesize = 0;
- return 0;
- }
/* creating: allow suitable space for bitmap or PPL */
if (consistency_policy == CONSISTENCY_POLICY_PPL)
@@ -2791,15 +2788,27 @@ static int validate_geometry1(struct supertype *st, int level,
case 0: /* metadata at end. Round down and subtract space to reserve */
devsize = (devsize & ~(4ULL*2-1));
/* space for metadata, bblog, bitmap/ppl */
- devsize -= 8*2 + 8 + bmspace;
+ overhead = 8*2 + 8 + bmspace;
+ if (devsize < overhead) /* detect underflow */
+ goto dev_too_small_err;
+ devsize -= overhead;
break;
case 1:
case 2:
+ if (devsize < data_offset) /* detect underflow */
+ goto dev_too_small_err;
devsize -= data_offset;
break;
}
*freesize = devsize;
return 1;
+
+/* Error condition, device cannot even hold the overhead. */
+dev_too_small_err:
+ fprintf(stderr, "device %s is too small (%lluK) for "
+ "required metadata!\n", subdev, devsize>>1);
+ *freesize = 0;
+ return 0;
}
void *super1_make_v0(struct supertype *st, struct mdinfo *info, mdp_super_t *sb0)
--
2.21.1 (Apple Git-122.3)

View File

@ -0,0 +1,64 @@
From 17ee1b8ebaf51b117e17578f48ffb1ad293ff117 Mon Sep 17 00:00:00 2001
From: allenpeng <allenpeng@synology.com>
Date: Fri, 12 Jun 2020 17:00:39 +0800
Subject: [PATCH 26/27] mdadm/Grow: prevent md's fd from being occupied during
delayed time
If we start reshaping on md which shares sub-devices with another
resyncing md, it may be forced to wait for others to complete. mdadm
occupies the md's fd during this time, which causes the md can not be
stopped and the filesystem can not be mounted on the md. We can close
md's fd earlier to solve this problem.
Reproducible Steps:
1. create two partitions on sda, sdb, sdc, sdd
2. create raid1 with sda1, sdb1
mdadm -C /dev/md1 --assume-clean -l1 -n2 /dev/sda1 /dev/sdb1
3. create raid5 with sda2, sdb2, sdc2
mdadm -C /dev/md2 --assume-clean -l5 -n3 /dev/sda2 /dev/sdb2 /dev/sdc2
4. start resync at md1
echo repair > /sys/block/md1/md/sync_action
5. reshape raid5 to raid6
mdadm -a /dev/md2 /dev/sdd2
mdadm --grow /dev/md2 -n4 -l6 --backup-file=/root/md2-backup
Now mdadm is occupying the fd of md2, causing md2 unable to be stopped
6.Try to stop md2, an error message shows
mdadm -S /dev/md2
mdadm: Cannot get exclusive access to /dev/md3:Perhaps a running process,
mounted filesystem or active volume group?
Reviewed-by: Alex Wu <alexwu@synology.com>
Reviewed-by: BingJing Chang <bingjingc@synology.com>
Reviewed-by: Danny Shih <dannyshih@synology.com>
Signed-off-by: ChangSyun Peng <allenpeng@synology.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Grow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index 764374f..57db7d4 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3517,6 +3517,7 @@ started:
return 0;
}
+ close(fd);
/* Now we just need to kick off the reshape and watch, while
* handling backups of the data...
* This is all done by a forked background process.
@@ -3569,7 +3570,6 @@ started:
mdstat_wait(30 - (delayed-1) * 25);
} while (delayed);
mdstat_close();
- close(fd);
if (check_env("MDADM_GROW_VERIFY"))
fd = open(devname, O_RDONLY | O_DIRECT);
else
--
2.21.1 (Apple Git-122.3)

View File

@ -1,11 +1,11 @@
From f64c9a6a28487c39704b09067e147563218f64be Mon Sep 17 00:00:00 2001
From 1cb13d072393b6f9ff51d678a2e5de8ada33c471 Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Mon, 29 Jun 2020 21:33:22 +0800
Subject: [PATCH] mdadm: remove -Werror to fix
Subject: [PATCH 27/27] mdadm: remove -Werror to fix
[-Werror=address-of-packed-member] problem
gcc reports [-Werror=address-of-packed-member] error when building
mdadm package. Here, we remove -Werror to fix
mdadm package. Here, we remove -Werror to fix
[-Werror=address-of-packed-member] problem.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
@ -27,5 +27,5 @@ index 2767ac6..5e24cbd 100644
CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O3
endif
--
2.24.0.windows.2
2.21.1 (Apple Git-122.3)

View File

@ -1,6 +1,6 @@
Name: mdadm
Version: 4.1
Release: 2
Release: 3
Summary: The software RAID arrays user manage tools
License: GPLv2+
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
@ -10,18 +10,33 @@ Source1: mdcheck-cron
Source2: mdmonitor.service
Source3: mdadm.conf
Patch0: 0000-Document-PART-POLICY-lines.patch
Patch1: 0001-Grow-avoid-overflow-in-compute_backup_blocks.patch
Patch2: 0002-Grow-report-correct-new-chunk-size.patch
Patch3: 0003-Fix-spelling-typos.patch
Patch4: 0004-Detail.c-do-not-skip-first-character-when-calling-xs.patch
Patch5: 0005-Fix-reshape-for-decreasing-data-offset.patch
Patch6: 0006-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch
Patch7: 0007-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch
Patch8: 0008-Assemble-Fix-starting-array-with-initial-reshape-che.patch
Patch9: 0009-add-missing-units-to-examine.patch
Patch10: 0010-Create-Block-rounding-size-to-max.patch
Patch11: 0011-mdadm-remove-Werror-to-fix-Werror-address-of-packed-.patch
Patch1: 0001-Assemble-keep-MD_DISK_FAILFAST-and-MD_DISK_WRITEMOST.patch
Patch2: 0002-Document-PART-POLICY-lines.patch
Patch3: 0003-Grow-avoid-overflow-in-compute_backup_blocks.patch
Patch4: 0004-Grow-report-correct-new-chunk-size.patch
Patch5: 0005-Fix-spelling-typos.patch
Patch6: 0006-Detail.c-do-not-skip-first-character-when-calling-xs.patch
Patch7: 0007-Fix-reshape-for-decreasing-data-offset.patch
Patch8: 0008-mdmon-don-t-attempt-to-manage-new-arrays-when-termin.patch
Patch9: 0009-mdmon-wait-for-previous-mdmon-to-exit-during-takeove.patch
Patch10: 0010-Assemble-Fix-starting-array-with-initial-reshape-che.patch
Patch11: 0011-add-missing-units-to-examine.patch
Patch12: 0012-Create-Block-rounding-size-to-max.patch
Patch13: 0013-super-intel-Fix-issue-with-abs-being-irrelevant.patch
Patch14: 0014-imsm-close-removed-drive-fd.patch
Patch15: 0015-mdadm-force-a-uuid-swap-on-big-endian.patch
Patch16: 0016-Init-devlist-as-an-array.patch
Patch17: 0017-Don-t-need-to-check-recovery-after-re-add-when-no-I-.patch
Patch18: 0018-Manage-Remove-the-legacy-code-for-md-driver-prior-to.patch
Patch19: 0019-imsm-Correct-minimal-device-size.patch
Patch20: 0020-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch
Patch21: 0021-Assemble-print-error-message-if-mdadm-fails-assembli.patch
Patch22: 0022-Include-count-for-0-character-when-using-strncpy-to-.patch
Patch23: 0023-restripe-fix-ignoring-return-value-of-read-and-lseek.patch
Patch24: 0024-Block-overwriting-existing-links-while-manual-assemb.patch
Patch25: 0025-Detect-too-small-device-error-rather-than-underflow-.patch
Patch26: 0026-mdadm-Grow-prevent-md-s-fd-from-being-occupied-durin.patch
Patch27: 0027-mdadm-remove-Werror-to-fix-Werror-address-of-packed-.patch
BuildRequires: systemd gcc binutils
Requires(post): systemd coreutils
@ -84,6 +99,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/
%{_mandir}/man*/*
%changelog
* Mon Jul 13 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 4.1-3
- backport upstream bugfix patches
* Sun Jul 5 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 4.1-2
- remove useless readme files.