Compare commits

..

1 commit

Author SHA1 Message Date
Xiao Ni
fed819fee9 Update to upstream 4.1-rc1
There are some patches after version 4.1-rc1 and I add them in
this backport too. So I update mdadm to the latest upstream version

Resolves: bz#1556591

Signed-off-by: Xiao Ni <xni@redhat.com>
2018-07-10 10:27:14 +08:00
43 changed files with 2035 additions and 990 deletions

22
.gitignore vendored
View file

@ -1,6 +1,24 @@
mdadm-3.0.3.tar.bz2
mdadm-3.1.1-gcd9a8b5.tar.bz2
mdadm-3.1.2.tar.bz2
mdadm-3.1.3-git07202010.tar.bz2
mdadm-3.1.3-git20100722.tar.bz2
mdadm-3.1.3-git20100804.tar.bz2
mdadm-3.1.5.tar.bz2
.build*
clog
*.src.rpm
*/
/mdadm-4.*.tar.xz
/mdadm-4.3.tar.sign
/mdadm-3.2.1.tar.bz2
/mdadm-3.2.2.tar.bz2
/mdadm-3.2.3.tar.bz2
/mdadm-3.2.4.tar.xz
/mdadm-3.2.5.tar.xz
/mdadm-3.2.6.tar.xz
/mdadm-3.3.tar.xz
/mdadm-3.3.1.tar.xz
/mdadm-3.3.2.tar.xz
/mdadm-3.3.4.tar.xz
/mdadm-3.4.tar.xz
/mdadm-4.0.tar.xz
/mdadm-4.1-rc1.tar.xz

View file

@ -1,428 +0,0 @@
From 857ad175fe025f026a1173e38de0b482110fdce5 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Sun, 6 Apr 2025 14:13:45 -0700
Subject: [PATCH] Revert "mdadm: Follow POSIX Portable Character Set"
This reverts commit e2eb503bd797908f515b58428b274f1ba6a05349.
---
Detail.c | 17 +++++++-----
config.c | 13 +++------
lib.c | 58 +++++++++++-----------------------------
mdadm.8.in | 70 ++++++++++++++++++++++++++++---------------------
mdadm.conf.5.in | 4 +++
mdadm.h | 2 +-
super-intel.c | 47 +++++++++++++++++----------------
7 files changed, 100 insertions(+), 111 deletions(-)
diff --git a/Detail.c b/Detail.c
index aaa3dd6e..6d675152 100644
--- a/Detail.c
+++ b/Detail.c
@@ -254,9 +254,11 @@ int Detail(char *dev, struct context *c)
fname_from_uuid(st, info, nbuf, ':');
printf("MD_UUID=%s\n", nbuf + 5);
mp = map_by_uuid(&map, info->uuid);
-
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
+ if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) {
+ printf("MD_DEVNAME=");
+ print_escape(mp->path + DEV_MD_DIR_LEN);
+ putchar('\n');
+ }
if (st->ss->export_detail_super)
st->ss->export_detail_super(st);
@@ -269,9 +271,12 @@ int Detail(char *dev, struct context *c)
__fname_from_uuid(mp->uuid, 0, nbuf, ':');
printf("MD_UUID=%s\n", nbuf+5);
}
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
-
+ if (mp && mp->path &&
+ strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) {
+ printf("MD_DEVNAME=");
+ print_escape(mp->path + DEV_MD_DIR_LEN);
+ putchar('\n');
+ }
map_free(map);
}
if (!c->no_devices && sra) {
diff --git a/config.c b/config.c
index 44f7dd2f..0a80eedb 100644
--- a/config.c
+++ b/config.c
@@ -199,9 +199,9 @@ inline void ident_init(struct mddev_ident *ident)
* /dev/md_d{number} (legacy)
* /dev/md_{name}
* /dev/md/{name}
- * {name}
+ * {name} - anything that doesn't start from '/' or '<'.
*
- * {name} must follow name's criteria and be POSIX compatible.
+ * {name} must follow name's criteria.
* If criteria passed, duplicate memory and set devname in @ident.
*
* Return: %MDADM_STATUS_SUCCESS or %MDADM_STATUS_ERROR.
@@ -241,8 +241,8 @@ mdadm_status_t _ident_set_devname(struct mddev_ident *ident, const char *devname
else
name = devname;
- if (is_name_posix_compatible(name) == false) {
- ident_log(prop_name, name, "Not POSIX compatible", cmdline);
+ if (*name == '/' || *name == '<') {
+ ident_log(prop_name, devname, "Cannot be started from \'/\' or \'<\'", cmdline);
return MDADM_STATUS_ERROR;
}
@@ -284,11 +284,6 @@ static mdadm_status_t _ident_set_name(struct mddev_ident *ident, const char *nam
return MDADM_STATUS_ERROR;
}
- if (is_name_posix_compatible(name) == false) {
- ident_log(prop_name, name, "Not POSIX compatible", cmdline);
- return MDADM_STATUS_ERROR;
- }
-
snprintf(ident->name, MD_NAME_MAX + 1, "%s", name);
return MDADM_STATUS_SUCCESS;
}
diff --git a/lib.c b/lib.c
index 2b09293c..95e3511f 100644
--- a/lib.c
+++ b/lib.c
@@ -454,50 +454,24 @@ void print_quoted(char *str)
putchar(q);
}
-/**
- * is_alphanum() - Check if sign is letter or digit.
- * @c: char to analyze.
- *
- * Similar to isalnum() but additional locales are excluded.
- *
- * Return: %true on success, %false otherwise.
- */
-bool is_alphanum(const char c)
-{
- if (isupper(c) || islower(c) || isdigit(c) != 0)
- return true;
- return false;
-}
-
-/**
- * is_name_posix_compatible() - Check if name is POSIX compatible.
- * @name: name to check.
- *
- * POSIX portable file name character set contains ASCII letters,
- * digits, '_', '.', and '-'. Also forbid leading '-'.
- * The length of the name cannot exceed NAME_MAX - 1 (ensure NULL ending).
- *
- * Return: %true on success, %false otherwise.
- */
-bool is_name_posix_compatible(const char * const name)
+void print_escape(char *str)
{
- assert(name);
-
- char allowed_symbols[] = "-_.";
- const char *n = name;
-
- if (!is_string_lq(name, NAME_MAX))
- return false;
-
- if (*n == '-')
- return false;
-
- while (*n != '\0') {
- if (!is_alphanum(*n) && !strchr(allowed_symbols, *n))
- return false;
- n++;
+ /* print str, but change space and tab to '_'
+ * as is suitable for device names
+ */
+ for (; *str; str++) {
+ switch (*str) {
+ case ' ':
+ case '\t':
+ putchar('_');
+ break;
+ case '/':
+ putchar('-');
+ break;
+ default:
+ putchar(*str);
+ }
}
- return true;
}
int check_env(char *name)
diff --git a/mdadm.8.in b/mdadm.8.in
index 96a4a08e..4af90c48 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -364,7 +364,7 @@ Use the Intel(R) Matrix Storage Manager metadata format. This creates a
which is managed in a similar manner to DDF, and is supported by an
option-rom on some platforms:
.IP
-.B https://www.intel.com/content/www/us/en/support/products/122484
+.B https://www.intel.com/content/www/us/en/support/products/122484/memory-and-storage/ssd-software/intel-virtual-raid-on-cpu-intel-vroc.html
.PP
.RE
@@ -932,14 +932,17 @@ option will be ignored.
.BR \-N ", " \-\-name=
Set a
.B name
-for the array. It must be
-.BR "POSIX PORTABLE NAME"
-compatible and cannot be longer than 32 chars. This is effective when creating an array
-with a v1 metadata, or an external array.
-
-If name is needed but not specified, it is taken from the basename of the device
-that is being created. See
-.BR "DEVICE NAMES"
+for the array. This is currently only effective when creating an
+array with a version-1 superblock, or an array in a DDF container.
+The name is a simple textual string that can be used to identify array
+components when assembling. If name is needed but not specified, it
+is taken from the basename of the device that is being created.
+e.g. when creating
+.I /dev/md/home
+the
+.B name
+will default to
+.IR home .
.TP
.BR \-R ", " \-\-run
@@ -1129,10 +1132,8 @@ is much safer.
.TP
.BR \-N ", " \-\-name=
-Specify the name of the array to assemble. It must be
-.BR "POSIX PORTABLE NAME"
-compatible and cannot be longer than 32 chars. This must be the name
-that was specified when creating the array. It must either match
+Specify the name of the array to assemble. This must be the name
+that was specified when creating the array. It must either match
the name stored in the superblock exactly, or it must match
with the current
.I homehost
@@ -2178,17 +2179,14 @@ Usage:
.I md-device
.BI \-\-chunk= X
.BI \-\-level= Y
+.br
.BI \-\-raid\-devices= Z
.I devices
.PP
-This usage will initialize a new md array, associate some devices with
+This usage will initialise a new md array, associate some devices with
it, and activate the array.
-.I md-device
-is a new device. This could be standard name or chosen name. For details see:
-.BR "DEVICE NAMES"
-
The named device will normally not exist when
.I "mdadm \-\-create"
is run, but will be created by
@@ -2229,6 +2227,24 @@ array. This feature can be overridden with the
.B \-\-force
option.
+When creating an array with version-1 metadata a name for the array is
+required.
+If this is not given with the
+.B \-\-name
+option,
+.I mdadm
+will choose a name based on the last component of the name of the
+device being created. So if
+.B /dev/md3
+is being created, then the name
+.B 3
+will be chosen.
+If
+.B /dev/md/home
+is being created, then the name
+.B home
+will be used.
+
When creating a partition based array, using
.I mdadm
with version-1.x metadata, the partition type should be set to
@@ -2413,10 +2429,12 @@ and
The
.B name
-option updates the subarray name in the metadata. It must be
-.BR "POSIX PORTABLE NAME"
-compatible and cannot be longer than 32 chars. If successes, new value will be respected after
-next assembly.
+option updates the subarray name in the metadata, it may not affect the
+device node name or the device node symlink until the subarray is
+re\-assembled. If updating
+.B name
+would change the UUID of an active subarray this operation is blocked,
+and the command will end in an error.
The
.B ppl
@@ -3377,10 +3395,6 @@ When
.B \-\-incremental
mode is used, this file gets a list of arrays currently being created.
-.SH POSIX PORTABLE NAME
-A valid name can only consist of characters "A-Za-z0-9.-_".
-The name cannot start with a leading "-" and cannot exceed 255 chars.
-
.SH DEVICE NAMES
.I mdadm
@@ -3402,10 +3416,6 @@ can be given, or just the suffix of the second sort of name, such as
.I home
can be given.
-In every style, raw name must be compatible with
-.BR "POSIX PORTABLE NAME"
-and has to be no longer than 32 chars.
-
When
.I mdadm
chooses device names during auto-assembly or incremental assembly, it
diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in
index 787e51e9..032b8010 100644
--- a/mdadm.conf.5.in
+++ b/mdadm.conf.5.in
@@ -710,6 +710,10 @@ ARRAY /dev/md/home UUID=9187a482:5dde19d9:eea3cc4a:d646ab8b
.br
auto=part
.br
+# The name of this array contains a space.
+.br
+ARRAY /dev/md9 name='Data Storage'
+.sp
POLICY domain=domain1 metadata=imsm path=pci-0000:00:1f.2-scsi-*
.br
action=spare
diff --git a/mdadm.h b/mdadm.h
index 1f28b3e7..3b3168d4 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1623,7 +1623,6 @@ extern int check_raid(int fd, char *name);
extern int check_partitions(int fd, char *dname,
unsigned long long freesize,
unsigned long long size);
-extern bool is_name_posix_compatible(const char *path);
extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev);
extern int stat_is_blkdev(char *devname, dev_t *rdev);
@@ -1664,6 +1663,7 @@ extern int conf_get_monitor_delay(void);
extern char *conf_line(FILE *file);
extern char *conf_word(FILE *file, int allow_key);
extern void print_quoted(char *str);
+extern void print_escape(char *str);
extern int use_udev(void);
extern void print_escape(char *str);
extern unsigned long GCD(unsigned long a, unsigned long b);
diff --git a/super-intel.c b/super-intel.c
index dbea235d..33f1469f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5533,37 +5533,40 @@ static void imsm_update_version_info(struct intel_super *super)
}
}
-/**
- * imsm_check_name() - check imsm naming criteria.
- * @super: &intel_super pointer, not NULL.
- * @name: name to check.
- * @verbose: verbose level.
- *
- * Name must be no longer than &MAX_RAID_SERIAL_LEN and must be unique across volumes.
- *
- * Returns: &true if @name matches, &false otherwise.
- */
-static bool imsm_is_name_allowed(struct intel_super *super, const char * const name,
- const int verbose)
+static int check_name(struct intel_super *super, char *name, int quiet)
{
struct imsm_super *mpb = super->anchor;
+ char *reason = NULL;
+ char *start = name;
+ size_t len = strlen(name);
int i;
- if (is_string_lq(name, MAX_RAID_SERIAL_LEN + 1) == false) {
- pr_vrb("imsm: Name \"%s\" is too long\n", name);
- return false;
+ if (len > 0) {
+ while (isspace(start[len - 1]))
+ start[--len] = 0;
+ while (*start && isspace(*start))
+ ++start, --len;
+ memmove(name, start, len + 1);
}
+ if (len > MAX_RAID_SERIAL_LEN)
+ reason = "must be 16 characters or less";
+ else if (len == 0)
+ reason = "must be a non-empty string";
+
for (i = 0; i < mpb->num_raid_devs; i++) {
struct imsm_dev *dev = get_imsm_dev(super, i);
if (strncmp((char *) dev->volume, name, MAX_RAID_SERIAL_LEN) == 0) {
- pr_vrb("imsm: Name \"%s\" already exists\n", name);
- return false;
+ reason = "already exists";
+ break;
}
}
- return true;
+ if (reason && !quiet)
+ pr_err("imsm volume name %s\n", reason);
+
+ return !reason;
}
static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
@@ -5658,9 +5661,8 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
}
}
- if (imsm_is_name_allowed(super, name, 1) == false)
+ if (!check_name(super, name, 0))
return 0;
-
dv = xmalloc(sizeof(*dv));
dev = xcalloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1));
/*
@@ -7988,7 +7990,7 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
char *ep;
int vol;
- if (imsm_is_name_allowed(super, name, 1) == false)
+ if (!check_name(super, name, 0))
return 2;
vol = strtoul(subarray, &ep, 10);
@@ -10298,8 +10300,7 @@ static void imsm_process_update(struct supertype *st,
if (a->info.container_member == target)
break;
dev = get_imsm_dev(super, u->dev_idx);
-
- if (a || !dev || imsm_is_name_allowed(super, name, 0) == false) {
+ if (a || !check_name(super, name, 1)) {
dprintf("failed to rename subarray-%d\n", target);
break;
}
--
2.49.0

View file

@ -0,0 +1,37 @@
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: [RHEL7.5 PATCH 01/26] mdadm: fix use-after-free after free_mdstat
e->percent access the mdstat_ent which was already freed in free_mdstat
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Detail.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Detail.c b/Detail.c
index 4dcf81d..860241c 100644
--- a/Detail.c
+++ b/Detail.c
@@ -561,7 +561,6 @@ int Detail(char *dev, struct context *c)
printf(" %7s Status : %d%% complete\n",
sync_action[e->resync], e->percent);
}
- free_mdstat(ms);
if ((st && st->sb) && (info && info->reshape_active)) {
#if 0
@@ -609,6 +608,8 @@ This is pretty boring
printf("\n");
} else if (e && e->percent >= 0)
printf("\n");
+ free_mdstat(ms);
+
if (st && st->sb)
st->ss->detail_super(st, c->homehost);
--
2.7.4

View file

@ -1,11 +0,0 @@
--- a/Assemble.c~ 2025-08-13 22:05:00.416132027 -0400
+++ b/Assemble.c 2025-08-13 22:13:16.650837070 -0400
@@ -1597,8 +1597,6 @@
goto try_again;
goto out;
}
- /* just incase it was started but has no content */
- ioctl(mdfd, STOP_ARRAY, NULL);
}
if (content != &info) {

View file

@ -0,0 +1,36 @@
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: [RHEL7.5 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
not be blocked in Create function. IMSM code forbids creation of
container with missing disk, so case like all dev's missing is already
handled.
Permit IMSM volume creation when devices are given as link to container.
Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Create.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Create.c b/Create.c
index 50142d8..04b1dfc 100644
--- a/Create.c
+++ b/Create.c
@@ -475,7 +475,7 @@ int Create(struct supertype *st, char *mddev,
close(fd);
}
}
- if (missing_disks == dnum) {
+ if (missing_disks == dnum && !have_container) {
pr_err("Subdevs can't be all missing\n");
return 1;
}
--
2.7.4

View file

@ -0,0 +1,80 @@
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: [RHEL7.5 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
running the test suite, nor should the test version of mdadm be
installed on the system for the tests to be run.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Fixes: 20d10b4be873ba ("mdadm/test: Refactor and revamp 'test' script")
---
test | 2 +-
tests/func.sh | 22 +++-------------------
2 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/test b/test
index 111a2e7..711a3c7 100755
--- a/test
+++ b/test
@@ -5,7 +5,7 @@ mdadm=$PWD/mdadm
targetdir="/var/tmp"
logdir="$targetdir"
config=/tmp/mdadm.conf
-testdir=
+testdir=$PWD/tests
devlist=
savelogs=0
diff --git a/tests/func.sh b/tests/func.sh
index a6995f1..9710a53 100644
--- a/tests/func.sh
+++ b/tests/func.sh
@@ -101,8 +101,8 @@ check_env() {
echo "test: testing can only be done as 'root'."
exit 1
}
- [ -x "raid6check" -a -x $mdadm ] || {
- echo "test: please run 'make everything' before perform testing."
+ [ \! -x $mdadm ] && {
+ echo "test: please run make everything before perform testing."
exit 1
}
cmds=(mdadm lsblk df udevadm losetup mkfs.ext3 fsck seq)
@@ -113,23 +113,6 @@ check_env() {
exit 1
}
done
- mdadm_src_ver="$($mdadm -V 2>&1)"
- mdadm_sbin_ver="$($(which mdadm) -V 2>&1)"
- if [ "$mdadm_src_ver" != "$mdadm_sbin_ver" ]
- then
- # it's nessesary to 'make install' mdadm to /SBIN/DIR,
- # such as systemd/mdadm-grow-continue@.service, would
- # run as an instance by systemd when reshape happens,
- # thus ensure that the correct mdadm is in testing.
- echo "test: please run 'make install' before testing."
- exit 1
- fi
- if ! $(df -T . | grep -iq ext)
- then
- # 'external file' bitmap only supports with ext[2-4] file system
- echo "test: please run test suite with ext[2-4] file system."
- exit 1
- fi
if $(lsblk -a | grep -iq raid)
then
# donot run mdadm -Ss directly if there are RAIDs working.
@@ -231,6 +214,7 @@ check() {
if [ $? -eq 0 ]; then
die "This command shouldn't run successfully"
fi
+ ;;
spares )
spares=$(tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0)
[ $spares -ne $2 ] &&
--
2.7.4

View file

@ -0,0 +1,32 @@
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: [RHEL7.5 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.
Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index fb1b693..52011e5 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -88,8 +88,8 @@
#define MPB_ATTRIB_IGNORED (MPB_ATTRIB_NEVER_USE)
#define MPB_SECTOR_CNT 2210
-#define IMSM_RESERVED_SECTORS 4096
-#define NUM_BLOCKS_DIRTY_STRIPE_REGION 2056
+#define IMSM_RESERVED_SECTORS 8192
+#define NUM_BLOCKS_DIRTY_STRIPE_REGION 2048
#define SECT_PER_MB_SHIFT 11
#define MAX_SECTOR_SIZE 4096
#define MULTIPLE_PPL_AREA_SIZE_IMSM (1024 * 1024) /* Size of the whole
--
2.7.4

View file

@ -0,0 +1,137 @@
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: [RHEL7.5 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>
---
super-intel.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 52011e5..fe2a705 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1201,6 +1201,13 @@ static unsigned long long num_data_stripes(struct imsm_map *map)
return join_u32(map->num_data_stripes_lo, map->num_data_stripes_hi);
}
+static unsigned long long imsm_dev_size(struct imsm_dev *dev)
+{
+ if (dev == NULL)
+ return 0;
+ return join_u32(dev->size_low, dev->size_high);
+}
+
static void set_total_blocks(struct imsm_disk *disk, unsigned long long n)
{
split_ull(n, &disk->total_blocks_lo, &disk->total_blocks_hi);
@@ -1221,6 +1228,11 @@ static void set_num_data_stripes(struct imsm_map *map, unsigned long long n)
split_ull(n, &map->num_data_stripes_lo, &map->num_data_stripes_hi);
}
+static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n)
+{
+ split_ull(n, &dev->size_low, &dev->size_high);
+}
+
static struct extent *get_extents(struct intel_super *super, struct dl *dl)
{
/* find a list of used extents on the given physical device */
@@ -1503,9 +1515,7 @@ static void print_imsm_dev(struct intel_super *super,
} else
printf(" This Slot : ?\n");
printf(" Sector Size : %u\n", super->sector_size);
- sz = __le32_to_cpu(dev->size_high);
- sz <<= 32;
- sz += __le32_to_cpu(dev->size_low);
+ sz = imsm_dev_size(dev);
printf(" Array Size : %llu%s\n",
(unsigned long long)sz * 512 / super->sector_size,
human_size(sz * 512));
@@ -1634,8 +1644,7 @@ void convert_to_4k(struct intel_super *super)
struct imsm_dev *dev = __get_imsm_dev(mpb, i);
struct imsm_map *map = get_imsm_map(dev, MAP_0);
/* dev */
- split_ull((join_u32(dev->size_low, dev->size_high)/IMSM_4K_DIV),
- &dev->size_low, &dev->size_high);
+ set_imsm_dev_size(dev, imsm_dev_size(dev)/IMSM_4K_DIV);
dev->vol.curr_migr_unit /= IMSM_4K_DIV;
/* map0 */
@@ -1762,8 +1771,7 @@ void convert_from_4k(struct intel_super *super)
struct imsm_dev *dev = __get_imsm_dev(mpb, i);
struct imsm_map *map = get_imsm_map(dev, MAP_0);
/* dev */
- split_ull((join_u32(dev->size_low, dev->size_high)*IMSM_4K_DIV),
- &dev->size_low, &dev->size_high);
+ set_imsm_dev_size(dev, imsm_dev_size(dev)*IMSM_4K_DIV);
dev->vol.curr_migr_unit *= IMSM_4K_DIV;
/* map0 */
@@ -3240,9 +3248,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
info->array.chunk_size =
__le16_to_cpu(map_to_analyse->blocks_per_strip) << 9;
info->array.state = !(dev->vol.dirty & RAIDVOL_DIRTY);
- info->custom_array_size = __le32_to_cpu(dev->size_high);
- info->custom_array_size <<= 32;
- info->custom_array_size |= __le32_to_cpu(dev->size_low);
+ info->custom_array_size = imsm_dev_size(dev);
info->recovery_blocked = imsm_reshape_blocks_arrays_changes(st->sb);
if (is_gen_migration(dev)) {
@@ -5370,8 +5376,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
array_blocks = round_size_to_mb(array_blocks, data_disks);
size_per_member = array_blocks / data_disks;
- dev->size_low = __cpu_to_le32((__u32) array_blocks);
- dev->size_high = __cpu_to_le32((__u32) (array_blocks >> 32));
+ set_imsm_dev_size(dev, array_blocks);
dev->status = (DEV_READ_COALESCING | DEV_WRITE_COALESCING);
vol = &dev->vol;
vol->migr_state = 0;
@@ -7733,7 +7738,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
level, /* RAID level */
imsm_level_to_layout(level),
map->num_members, /* raid disks */
- &chunk, join_u32(dev->size_low, dev->size_high),
+ &chunk, imsm_dev_size(dev),
1 /* verbose */)) {
pr_err("IMSM RAID geometry validation failed. Array %s activation is blocked.\n",
dev->volume);
@@ -8143,9 +8148,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
/* when problems occures
* return current array_blocks value
*/
- array_blocks = __le32_to_cpu(dev->size_high);
- array_blocks = array_blocks << 32;
- array_blocks += __le32_to_cpu(dev->size_low);
+ array_blocks = imsm_dev_size(dev);
return array_blocks;
}
@@ -8165,8 +8168,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
}
array_blocks = round_size_to_mb(array_blocks, used_disks);
- dev->size_low = __cpu_to_le32((__u32)array_blocks);
- dev->size_high = __cpu_to_le32((__u32)(array_blocks >> 32));
+ set_imsm_dev_size(dev, array_blocks);
return array_blocks;
}
@@ -9139,8 +9141,7 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
map->blocks_per_strip =
__cpu_to_le16(u->new_chunksize * 2);
num_data_stripes =
- (join_u32(dev->size_low, dev->size_high)
- / used_disks);
+ imsm_dev_size(dev) / used_disks;
num_data_stripes /= map->blocks_per_strip;
num_data_stripes /= map->num_domains;
set_num_data_stripes(map, num_data_stripes);
--
2.7.4

View file

@ -0,0 +1,179 @@
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: [RHEL7.5 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
map for imsm_num_data_members.
Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index fe2a705..3fc3cf4 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2767,13 +2767,11 @@ static __u32 num_stripes_per_unit_rebuild(struct imsm_dev *dev)
return num_stripes_per_unit_resync(dev);
}
-static __u8 imsm_num_data_members(struct imsm_dev *dev, int second_map)
+static __u8 imsm_num_data_members(struct imsm_map *map)
{
/* named 'imsm_' because raid0, raid1 and raid10
* counter-intuitively have the same number of data disks
*/
- struct imsm_map *map = get_imsm_map(dev, second_map);
-
switch (get_imsm_raid_level(map)) {
case 0:
return map->num_members;
@@ -2862,7 +2860,7 @@ static __u64 blocks_per_migr_unit(struct intel_super *super,
*/
stripes_per_unit = num_stripes_per_unit_resync(dev);
migr_chunk = migr_strip_blocks_resync(dev);
- disks = imsm_num_data_members(dev, MAP_0);
+ disks = imsm_num_data_members(map);
blocks_per_unit = stripes_per_unit * migr_chunk * disks;
stripe = __le16_to_cpu(map->blocks_per_strip) * disks;
segment = blocks_per_unit / stripe;
@@ -3381,7 +3379,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
(unsigned long long)blocks_per_unit,
info->reshape_progress);
- used_disks = imsm_num_data_members(dev, MAP_1);
+ used_disks = imsm_num_data_members(prev_map);
if (used_disks > 0) {
array_blocks = blocks_per_member(map) *
used_disks;
@@ -8140,9 +8138,9 @@ static void handle_missing(struct intel_super *super, struct imsm_dev *dev)
static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
long long new_size)
{
- int used_disks = imsm_num_data_members(dev, MAP_0);
unsigned long long array_blocks;
- struct imsm_map *map;
+ struct imsm_map *map = get_imsm_map(dev, MAP_0);
+ int used_disks = imsm_num_data_members(map);
if (used_disks == 0) {
/* when problems occures
@@ -8155,17 +8153,15 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
/* set array size in metadata
*/
- if (new_size <= 0) {
+ if (new_size <= 0)
/* OLCE size change is caused by added disks
*/
- map = get_imsm_map(dev, MAP_0);
array_blocks = blocks_per_member(map) * used_disks;
- } else {
+ else
/* Online Volume Size Change
* Using available free space
*/
array_blocks = new_size;
- }
array_blocks = round_size_to_mb(array_blocks, used_disks);
set_imsm_dev_size(dev, array_blocks);
@@ -8274,7 +8270,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
int used_disks;
struct mdinfo *mdi;
- used_disks = imsm_num_data_members(dev, MAP_0);
+ used_disks = imsm_num_data_members(map);
if (used_disks > 0) {
array_blocks =
blocks_per_member(map) *
@@ -9132,8 +9128,10 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
*/
if (u->new_chunksize > 0) {
unsigned long long num_data_stripes;
+ struct imsm_map *dest_map =
+ get_imsm_map(dev, MAP_0);
int used_disks =
- imsm_num_data_members(dev, MAP_0);
+ imsm_num_data_members(dest_map);
if (used_disks == 0)
return ret_val;
@@ -9210,7 +9208,7 @@ static int apply_size_change_update(struct imsm_update_size_change *u,
if (id->index == (unsigned)u->subdev) {
struct imsm_dev *dev = get_imsm_dev(super, u->subdev);
struct imsm_map *map = get_imsm_map(dev, MAP_0);
- int used_disks = imsm_num_data_members(dev, MAP_0);
+ int used_disks = imsm_num_data_members(map);
unsigned long long blocks_per_member;
unsigned long long num_data_stripes;
@@ -10589,7 +10587,7 @@ void init_migr_record_imsm(struct supertype *st, struct imsm_dev *dev,
max(map_dest->blocks_per_strip, map_src->blocks_per_strip);
migr_rec->dest_depth_per_unit *=
max(map_dest->blocks_per_strip, map_src->blocks_per_strip);
- new_data_disks = imsm_num_data_members(dev, MAP_0);
+ new_data_disks = imsm_num_data_members(map_dest);
migr_rec->blocks_per_unit =
__cpu_to_le32(migr_rec->dest_depth_per_unit * new_data_disks);
migr_rec->dest_depth_per_unit =
@@ -10657,7 +10655,7 @@ int save_backup_imsm(struct supertype *st,
int dest_layout = 0;
int dest_chunk;
unsigned long long start;
- int data_disks = imsm_num_data_members(dev, MAP_0);
+ int data_disks = imsm_num_data_members(map_dest);
targets = xmalloc(new_disks * sizeof(int));
@@ -11279,6 +11277,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
int imsm_layout = -1;
int data_disks;
struct imsm_dev *dev;
+ struct imsm_map *map;
struct intel_super *super;
unsigned long long current_size;
unsigned long long free_size;
@@ -11369,7 +11368,8 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
super = st->sb;
dev = get_imsm_dev(super, super->current_vol);
- data_disks = imsm_num_data_members(dev , MAP_0);
+ map = get_imsm_map(dev, MAP_0);
+ data_disks = imsm_num_data_members(map);
/* compute current size per disk member
*/
current_size = info.custom_array_size / data_disks;
@@ -11838,7 +11838,7 @@ static int imsm_manage_reshape(
struct intel_dev *dv;
unsigned int sector_size = super->sector_size;
struct imsm_dev *dev = NULL;
- struct imsm_map *map_src;
+ struct imsm_map *map_src, *map_dest;
int migr_vol_qan = 0;
int ndata, odata; /* [bytes] */
int chunk; /* [bytes] */
@@ -11876,12 +11876,13 @@ static int imsm_manage_reshape(
goto abort;
}
+ map_dest = get_imsm_map(dev, MAP_0);
map_src = get_imsm_map(dev, MAP_1);
if (map_src == NULL)
goto abort;
- ndata = imsm_num_data_members(dev, MAP_0);
- odata = imsm_num_data_members(dev, MAP_1);
+ ndata = imsm_num_data_members(map_dest);
+ odata = imsm_num_data_members(map_src);
chunk = __le16_to_cpu(map_src->blocks_per_strip) * 512;
old_data_stripe_length = odata * chunk;
--
2.7.4

View file

@ -0,0 +1,266 @@
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: [RHEL7.5 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 *
blocks_per_stripe but it is not true. For IMSM arrays created in OROM
NUM_BLOCKS_DIRTY_STRIPE_REGION sectors are added up to this value. Because
of this mdadm shows invalid size of arrays created in OROM and to fix this
we need to use array size calculation based on num data stripes and blocks
per stripe.
Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 105 ++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 76 insertions(+), 29 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 3fc3cf4..c55c85f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1233,6 +1233,20 @@ static void set_imsm_dev_size(struct imsm_dev *dev, unsigned long long n)
split_ull(n, &dev->size_low, &dev->size_high);
}
+static unsigned long long per_dev_array_size(struct imsm_map *map)
+{
+ unsigned long long array_size = 0;
+
+ if (map == NULL)
+ return array_size;
+
+ array_size = num_data_stripes(map) * map->blocks_per_strip;
+ if (get_imsm_raid_level(map) == 1 || get_imsm_raid_level(map) == 10)
+ array_size *= 2;
+
+ return array_size;
+}
+
static struct extent *get_extents(struct intel_super *super, struct dl *dl)
{
/* find a list of used extents on the given physical device */
@@ -1259,7 +1273,7 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl)
if (get_imsm_disk_slot(map, dl->index) >= 0) {
e->start = pba_of_lba0(map);
- e->size = blocks_per_member(map);
+ e->size = per_dev_array_size(map);
e++;
}
}
@@ -2787,6 +2801,36 @@ static __u8 imsm_num_data_members(struct imsm_map *map)
}
}
+static unsigned long long calc_component_size(struct imsm_map *map,
+ struct imsm_dev *dev)
+{
+ unsigned long long component_size;
+ unsigned long long dev_size = imsm_dev_size(dev);
+ unsigned long long calc_dev_size = 0;
+ unsigned int member_disks = imsm_num_data_members(map);
+
+ if (member_disks == 0)
+ return 0;
+
+ component_size = per_dev_array_size(map);
+ calc_dev_size = component_size * member_disks;
+
+ /* Component size is rounded to 1MB so difference between size from
+ * metadata and size calculated from num_data_stripes equals up to
+ * 2048 blocks per each device. If the difference is higher it means
+ * that array size was expanded and num_data_stripes was not updated.
+ */
+ if ((unsigned int)abs(calc_dev_size - dev_size) >
+ (1 << SECT_PER_MB_SHIFT) * member_disks) {
+ component_size = dev_size / member_disks;
+ dprintf("Invalid num_data_stripes in metadata; expected=%llu, found=%llu\n",
+ component_size / map->blocks_per_strip,
+ num_data_stripes(map));
+ }
+
+ return component_size;
+}
+
static __u32 parity_segment_depth(struct imsm_dev *dev)
{
struct imsm_map *map = get_imsm_map(dev, MAP_0);
@@ -3306,14 +3350,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
}
info->data_offset = pba_of_lba0(map_to_analyse);
-
- if (info->array.level == 5) {
- info->component_size = num_data_stripes(map_to_analyse) *
- map_to_analyse->blocks_per_strip;
- } else {
- info->component_size = blocks_per_member(map_to_analyse);
- }
-
+ info->component_size = calc_component_size(map, dev);
info->component_size = imsm_component_size_aligment_check(
info->array.level,
info->array.chunk_size,
@@ -3381,7 +3418,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
used_disks = imsm_num_data_members(prev_map);
if (used_disks > 0) {
- array_blocks = blocks_per_member(map) *
+ array_blocks = per_dev_array_size(map) *
used_disks;
info->custom_array_size =
round_size_to_mb(array_blocks,
@@ -5383,9 +5420,6 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
vol->curr_migr_unit = 0;
map = get_imsm_map(dev, MAP_0);
set_pba_of_lba0(map, super->create_offset);
- set_blocks_per_member(map, info_to_blocks_per_member(info,
- size_per_member /
- BLOCKS_PER_KB));
map->blocks_per_strip = __cpu_to_le16(info_to_blocks_per_strip(info));
map->failed_disk_num = ~0;
if (info->level > 0)
@@ -5417,6 +5451,11 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
num_data_stripes /= map->num_domains;
set_num_data_stripes(map, num_data_stripes);
+ size_per_member += NUM_BLOCKS_DIRTY_STRIPE_REGION;
+ set_blocks_per_member(map, info_to_blocks_per_member(info,
+ size_per_member /
+ BLOCKS_PER_KB));
+
map->num_members = info->raid_disks;
for (i = 0; i < map->num_members; i++) {
/* initialized in add_to_super */
@@ -7821,18 +7860,14 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
info_d->events = __le32_to_cpu(mpb->generation_num);
info_d->data_offset = pba_of_lba0(map);
+ info_d->component_size = calc_component_size(map, dev);
if (map->raid_level == 5) {
- info_d->component_size =
- num_data_stripes(map) *
- map->blocks_per_strip;
info_d->ppl_sector = this->ppl_sector;
info_d->ppl_size = this->ppl_size;
if (this->consistency_policy == CONSISTENCY_POLICY_PPL &&
recovery_start == 0)
this->resync_start = 0;
- } else {
- info_d->component_size = blocks_per_member(map);
}
info_d->bb.supported = 1;
@@ -8156,7 +8191,7 @@ static unsigned long long imsm_set_array_size(struct imsm_dev *dev,
if (new_size <= 0)
/* OLCE size change is caused by added disks
*/
- array_blocks = blocks_per_member(map) * used_disks;
+ array_blocks = per_dev_array_size(map) * used_disks;
else
/* Online Volume Size Change
* Using available free space
@@ -8273,7 +8308,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
used_disks = imsm_num_data_members(map);
if (used_disks > 0) {
array_blocks =
- blocks_per_member(map) *
+ per_dev_array_size(map) *
used_disks;
array_blocks =
round_size_to_mb(array_blocks,
@@ -8715,11 +8750,11 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot,
pos = 0;
array_start = pba_of_lba0(map);
array_end = array_start +
- blocks_per_member(map) - 1;
+ per_dev_array_size(map) - 1;
do {
/* check that we can start at pba_of_lba0 with
- * blocks_per_member of space
+ * num_data_stripes*blocks_per_stripe of space
*/
if (array_start >= pos && array_end < ex[j].start) {
found = 1;
@@ -9145,6 +9180,12 @@ static int apply_reshape_migration_update(struct imsm_update_reshape_migration *
set_num_data_stripes(map, num_data_stripes);
}
+ /* ensure blocks_per_member has valid value
+ */
+ set_blocks_per_member(map,
+ per_dev_array_size(map) +
+ NUM_BLOCKS_DIRTY_STRIPE_REGION);
+
/* add disk
*/
if (u->new_level != 5 || migr_map->raid_level != 0 ||
@@ -9211,15 +9252,21 @@ static int apply_size_change_update(struct imsm_update_size_change *u,
int used_disks = imsm_num_data_members(map);
unsigned long long blocks_per_member;
unsigned long long num_data_stripes;
+ unsigned long long new_size_per_disk;
+
+ if (used_disks == 0)
+ return 0;
/* calculate new size
*/
- blocks_per_member = u->new_size / used_disks;
- num_data_stripes = blocks_per_member /
+ new_size_per_disk = u->new_size / used_disks;
+ blocks_per_member = new_size_per_disk +
+ NUM_BLOCKS_DIRTY_STRIPE_REGION;
+ num_data_stripes = new_size_per_disk /
map->blocks_per_strip;
num_data_stripes /= map->num_domains;
dprintf("(size: %llu, blocks per member: %llu, num_data_stipes: %llu)\n",
- u->new_size, blocks_per_member,
+ u->new_size, new_size_per_disk,
num_data_stripes);
set_blocks_per_member(map, blocks_per_member);
set_num_data_stripes(map, num_data_stripes);
@@ -9476,7 +9523,7 @@ static int apply_takeover_update(struct imsm_update_takeover *u,
unsigned long long num_data_stripes;
map->num_domains = 1;
- num_data_stripes = blocks_per_member(map);
+ num_data_stripes = imsm_dev_size(dev) / 2;
num_data_stripes /= map->blocks_per_strip;
num_data_stripes /= map->num_domains;
set_num_data_stripes(map, num_data_stripes);
@@ -9692,7 +9739,7 @@ static void imsm_process_update(struct supertype *st,
new_map = get_imsm_map(&u->dev, MAP_0);
new_start = pba_of_lba0(new_map);
- new_end = new_start + blocks_per_member(new_map);
+ new_end = new_start + per_dev_array_size(new_map);
inf = get_disk_info(u);
/* handle activate_spare versus create race:
@@ -9703,7 +9750,7 @@ static void imsm_process_update(struct supertype *st,
dev = get_imsm_dev(super, i);
map = get_imsm_map(dev, MAP_0);
start = pba_of_lba0(map);
- end = start + blocks_per_member(map);
+ end = start + per_dev_array_size(map);
if ((new_start >= start && new_start <= end) ||
(start >= new_start && start <= new_end))
/* overlap */;
@@ -10492,7 +10539,7 @@ static struct md_bb *imsm_get_badblocks(struct active_array *a, int slot)
return NULL;
get_volume_badblocks(super->bbm_log, ord_to_idx(ord), pba_of_lba0(map),
- blocks_per_member(map), &super->bb);
+ per_dev_array_size(map), &super->bb);
return &super->bb;
}
--
2.7.4

View file

@ -0,0 +1,57 @@
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: [RHEL7.5 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
print appropriate message.
Commit b53bfba6119d3f6f56eb9e10e5a59da6901af159
(imsm: use rounded size for metadata initialization) introduces issue with
rounding volume sizes smaller than 1M to 0. There is an inconsistency when
size smaller than 1M was given depends of what we give as target device:
1) When block devices was given created volume has maximum available size.
2) When container symlink was given created volume has size 0. Additionally
it causes below call trace:
[69587.891556] WARNING: CPU: 28 PID: 22485 at ../drivers/md/md.c:7582 md_seq_show+0x764/0x770 [md_mod]
[69588.066405] Call Trace:
[69588.066409] seq_read+0x336/0x430
[69588.066411] proc_reg_read+0x40/0x70
[69588.066412] __vfs_read+0x26/0x140
[69588.066414] vfs_read+0x89/0x130
[69588.066415] SyS_read+0x42/0x90
[69588.066417] do_syscall_64+0x74/0x140
[69588.066419] entry_SYSCALL_64_after_hwframe+0x3d/0xa2
Signed-off-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
super-intel.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/super-intel.c b/super-intel.c
index c55c85f..520abf5 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7358,6 +7358,16 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout,
verbose);
}
+ if (size && ((size < 1024) || (*chunk != UnSet &&
+ size < (unsigned long long) *chunk))) {
+ pr_err("Given size must be greater than 1M and chunk size.\n");
+ /* Depends on algorithm in Create.c :
+ * if container was given (dev == NULL) return -1,
+ * if block device was given ( dev != NULL) return 0.
+ */
+ return dev ? -1 : 0;
+ }
+
if (!dev) {
if (st->sb) {
struct intel_super *super = st->sb;
--
2.7.4

View file

@ -0,0 +1,32 @@
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: [RHEL7.5 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
incorrect message if size given to grow was greater than 2 147 483 647 K.
Cast chunk_size to "unsigned long long" instead of casting size to "int".
Signed-off-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Grow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index 8722969..a4be7e7 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1821,7 +1821,7 @@ int Grow_reshape(char *devname, int fd,
}
if (array.level > 1 && s->size > 1 &&
- (array.chunk_size / 1024) > (int)s->size) {
+ (unsigned long long) (array.chunk_size / 1024) > s->size) {
pr_err("component size must be larger than chunk size.\n");
return 1;
}
--
2.7.4

View file

@ -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: [RHEL7.5 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 520abf5..ce08af4 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.7.4

View file

@ -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: [RHEL7.5 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 ce08af4..449da1d 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.7.4

View file

@ -0,0 +1,31 @@
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: [RHEL7.5 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 449da1d..ec7683d 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.7.4

View file

@ -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: [RHEL7.5 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 ec7683d..cc53f0f 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.7.4

View file

@ -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: [RHEL7.5 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 cc53f0f..520d292 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.7.4

View file

@ -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: [RHEL7.5 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 520d292..aa93a9e 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.7.4

View file

@ -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: [RHEL7.5 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 aa93a9e..12f60f6 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.7.4

View file

@ -0,0 +1,125 @@
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: [RHEL7.5 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 ea45bbc..d6bb3fa 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/super-intel.c b/super-intel.c
index 12f60f6..a01be13 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 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
--
2.7.4

View file

@ -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: [RHEL7.5 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 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)
*/
--
2.7.4

View file

@ -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: [RHEL7.5 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 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]);
--
2.7.4

View file

@ -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: [RHEL7.5 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 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);
--
2.7.4

View file

@ -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: [RHEL7.5 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 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);
--
2.7.4

View file

@ -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: [RHEL7.5 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 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();
--
2.7.4

View file

@ -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: [RHEL7.5 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 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),
--
2.7.4

View file

@ -0,0 +1,54 @@
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: [RHEL7.5 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 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
--
2.7.4

View file

@ -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: [RHEL7.5 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 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
--
2.7.4

View file

@ -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: [RHEL7.5 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 188a218..2767ac6 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 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
--
2.7.4

View file

@ -1,72 +0,0 @@
pub rsa2048 2023-11-03 [SC]
EED84966493AEEAF4B466F696F9E3E9D4EDEBB11
uid Mariusz Tkaczyk (First Key) <mariusz.tkaczyk@linux.intel.com>
sub rsa2048 2023-11-03 [E]
F07BC7F109D51D72E3A4B8779CF5038718DB4BA7
sub ed25519 2023-11-03 [S]
A2320B82F9D51E3BB0E2B3B201C8BB2357D15E24
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBGVE65YBCADQsm/xGlWh9vid1zLH4fGNA74rlvlE3X7Lbq8KLzufFOpV7+y0
E0btNHs8ur0lt+3Emj3T9rh0lDC1ikYrEzQiwtGGSFoo30MRE6dqHyZPPzXVeI9c
8SAcz2LNwTPP3WQYv3b+ZxJrhOMyIqXD+upAZYRHVI02GpixJa8XavUtD5GglfIU
yRnF3KNkZRnYeJ1qRMe0WoaAl2W9IAM4rKWJq+xDNZCeGEX5zqAeHO/aNgA2m1Oo
2kDZz+GO0+W1zeMOiHJwWyGMD3KFx+00TBf5n2ULq6+9JwfATi9wxB8E/btQmSl9
T9QU1wCHSM3Y92uqXbrEFNUdxZDLD9n7xnbFABEBAAG0PU1hcml1c3ogVGthY3p5
ayAoRmlyc3QgS2V5KSA8bWFyaXVzei50a2FjenlrQGxpbnV4LmludGVsLmNvbT6J
AU4EEwEIADgCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AWIQTu2ElmSTrur0tG
b2lvnj6dTt67EQUCZUpG+QAKCRBvnj6dTt67Ed+yCACayli/kd5f9YljcVfEo0xU
BXBDsEny2NbE3yICE13DvHT0Yg5YdwWBeKCf5Qt3d5GgFSt7PzEaOlNuRaIruSXQ
L0Xa91ZOi6rDQsaIfQtk3mps7ABrMK9h0EUIwDD7AWhN5DmoG4rd73wppkst+VG6
nP4VUyuyQJV+tMb5p5BirGYVU2Hi5noWRXNHLWGzq1QwHu2enzp8b+UqO0FQX0zi
UsPDNnQ6LV7Jnl9gg4bkWWzTXw5Of0kDdHBAATPW3sdZCj90CSGniMsa6CzFwvEf
YUN3CHkNDTSPu3ZPkE080xuPnC+WkKgPs38KLwMsM+Ys0gL6dk/AJ2tBR3RKrA8n
iQIzBBIBCAAdFiEE5DAy15EJMCV1R6v9YGjFFmlTOEoFAmVKZgkACgkQYGjFFmlT
OEpdNBAAkOaWbs7TV2AdZ8tLGTnrbUo7U/a4/gpKq2yetcmxWelLUnI1bfiv+hAx
pqrhmsbIoffxJIEeHulzQonM3USNdXRf3RnvMx/6oUlkf1t05lPuf6odEaZMJbiC
kVRU9/6AjfhktJAuSgQAepqlHU6ie/5hvn1+UxDZ9+A4NxoqSFpW8rywntUkGPcv
x6GZpoTiUx8dw0ULgrL2ZayE3Ul+N9by3FP8CGfh7+TJmTOdDWvgpfh02pvVQKHw
S6Jvfe8cua3jPALhM7+r08AT/X4z3A8FI8GAKUxhkTSNpU/xVeBWCDrr0gQ+LNzk
Mu8YDUzWQZH0oIvUoezxDMvZHaA6xHRcK4Z4gZlyB5US9vI0WkxG2vJ8CE+0Qj6z
eI53UWK3viM4yYOubtb9X1MUB0BFXaSIs7WlvWlHCwUoA9HXtaJf0kXV36usqBta
ZQ/6JZat8fRcYLDC438RW5TStT2LXtv/2XY2dBtNLtrHRA008nkurZBswct/Okws
E9CZLAy/PkwgYvpVSHS3NsiSScpFL4sz9Cwxk2HbPJxcxfxcFqi1ULQZhCJezKWz
4WKUJV/OiLUzNg3p+PIlomZ9jlxgq6IqMnXYLtrsOOSklJxNeWNgMP8SSBXXPcTm
6YNrScKabhbchJqjIDSIh8uMIX/b4tXVTz5Pd6XWwvkERKQOj/SJAjMEEAEIAB0W
IQT4aCvhNMZ6EjMqLtB6+mG+o7hN/wUCZVPVAQAKCRB6+mG+o7hN/9yuD/4pzZ+N
rqVsB7XoDBdPK+8kRo/ktd0Hp4N0H2pk1728Vu/MB/aGrH3Vv/wKyGO6EgQP+BPh
ofetMtSGPFDOcNkBg+OgzfuUjf6Wm87Ti+hStehsh6VTGEEnFQ8gCKPXB+cZnbLm
pLetBwsd20/C+8FofihYXu6eYPnrpanvnwR8atJMV1zAqtv44D/ANFi32chZjdIN
49EFYwroIEcs3Wbrm+hF9ntpzxFjtHPp44wkrFACS7WRmpbW6Fm6wExzKnHvvArX
GpfAOPGUvkWb1QGgWQ6yc74I6D56M6vGGiTgqz7A+YXaaErWq/j3YtShrNFiMs+Z
NOgTy2luLXOSttB9z9WzVrlAaHumKd9KCqQgMTt1FycVEtIm28XqIHkA9te6f767
HVic90UI+INp4aH1c4xZYUZdmR6HrN3rfredACFxD32TRZSf9rvuFKt6qM10iMfa
CXYc56m9ihsFm0XhQqBaQ3cCEAr5AYpqoNoEip1CSUdCSP7jub1v7qEJYLyVueSK
0yW9FwmA/cw0KBGmmZwgfQfZHWnzO5kU4przT99IUPAKRjip/6pltKSznHRX9bIf
PE3edcBYkk5JXnPGBkx5EuOHZKN5lPqtq4k6Tg0xL/OGdnMuWAvZksnCIiD44Gyg
Ro1YGeSsExdyeNF10UX4Zt39ZEm5cKvEasWqc7kBDQRlROuWAQgA1DEoJH8CEZFW
EoO3roijbv1jyGI9BvvFDNTpkaL3UpDX4FQOFrGOoz+UBUCHQVxBFGARlc2NpG3i
yDa2HwW0UeQbsUb3ge8xDySF8S//vZuSEDwwOTDA1+EEpFSUrjkkn9I8rhF/y+qx
22ExuzSEGBmVsAd11JuYQi7AZR4SWya6hFizrUMusnhcj1WZcG2YBZ8M6rL+WRki
tWLrzob0mY4OEXeH3/qarZB1XYtUKHQ1g/W0SqNczbPIf4u6n/GpGTIquq/qB2kW
5kONsAFJKQEGrs+wXfFICQhcHBYPJVRopt9JRu/HLHIshlZ+gyVlRHfuEli3nNV0
ZDoedNlnqQARAQABiQE2BBgBCAAgAhsMFiEE7thJZkk67q9LRm9pb54+nU7euxEF
AmVKRzwACgkQb54+nU7euxEgUggAqMvUugVsSn6AJ2gokyJrtEfjXicEci1u2RBU
5+HtzqRYXaPBnjhfBZT9iDZnu/H8KSGH3eJ+QqiB7nBJLSkzyrn07yuIvy2/KBOh
v1kXz4MfKg2vQjrFgoGQkaUmnDDKPl/Qda+yuI8RzDItHRTN0mHnDT+4wNCPEzzi
hHKtcbxEdS+5SVnMC+8mnUPqOUp74lMh56I22+Gnf0BdHHDKN8of2B/QmfWegZLC
qO+YsDSG0GcAv8u+ZMls6EdIhO+STJAMZpbM7Gx0XuJ08IhN+OglVp6WJ3vfCX4B
O9P2KYQE/8TF386HaNMq1CranRihHGaz1YOOV0Skxe2stP5UsbgzBGVE72IWCSsG
AQQB2kcPAQEHQKRrcOlY4p7NVvwJD+vnKwUtvmSAKuK1UrsXcBrBKDaWiQGtBBgB
CAAgFiEE7thJZkk67q9LRm9pb54+nU7euxEFAmVE72ICGwIAgQkQb54+nU7euxF2
IAQZFggAHRYhBKIyC4L51R47sOKzsgHIuyNX0V4kBQJlRO9iAAoJEAHIuyNX0V4k
f7kBAKzN7tapBxMbORYyONkYv7hSbu08b3DEDZxJgV27dUSkAP49HZEfFwFR7IGL
Rmvpq3F+RBALah9F0YuTTU4Ixz1qBUvPCACFwmg8zxoqd2nf2t05vjtdeFbahRqu
3Gu5b5QqzCRB4zGBNVSX110SvDOtCJ0xNUAHU0Gh0o2meCREc9xg/qCujs7CKD5u
OzukbPpIZ++cXg5gPJ7+H1L20VrbFjiz/wdzV0iNBPfQ7mP+CeqjmpNyZKUqGF1t
xTHbJ99Ls2/hS1o1P1aktfOj2WBTND3Xx2oysczhqyGpaciDR30A2SEhcutjcPUl
mUPaTp7+nP/5+v8u2drlkyhzxCyQbcIwNQEaIWxQq5pKrq8HpQ8u/SUW6ERKZISV
Y6o0MdrugFPqAmerHvL2hCrMelqHCCVInJIXBL0SSCgHZyh9NTuo2OUQ
=PmkW
-----END PGP PUBLIC KEY BLOCK-----

View file

@ -1,7 +1,7 @@
--- mdadm-3.2.1/Makefile.static 2021-01-11 15:46:47.292126848 +0800
+++ mdadm-3.2.1/Makefile 2021-01-11 15:46:10.720192519 +0800
@@ -248,16 +248,16 @@
install : install-bin install-man install-udev
--- mdadm-3.2.1/Makefile.static 2011-03-27 22:31:20.000000000 -0400
+++ mdadm-3.2.1/Makefile 2011-03-28 10:16:55.277900184 -0400
@@ -238,16 +238,16 @@ install : mdadm mdmon install-man instal
$(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
install-static : mdadm.static install-man
- $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm

View file

@ -1,26 +0,0 @@
From: martin f. krafft <madduck@debian.org>
Subject: Remove -Werror from compiler flags
-Werror seems like a bad idea on released/packaged code because a toolchain
update (introducing new warnings) could break the build. We'll let upstream
use it to beautify the code, but remove it for out builds.
Signed-off-by: martin f. krafft <madduck@debian.org>
---
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Index: mdadm-4.1/Makefile
===================================================================
--- mdadm-4.1.orig/Makefile
+++ mdadm-4.1/Makefile
@@ -48,7 +48,7 @@ endif
CC ?= $(CROSS_COMPILE)gcc
CXFLAGS ?= -ggdb
-CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter
+CWFLAGS = -Wall -Wstrict-prototypes -Wextra -Wno-unused-parameter
ifdef WARN_UNUSED
CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O3
endif

3
mdadm-cron Normal file
View file

@ -0,0 +1,3 @@
# Run system wide raid-check once a week on Sunday at 1am by default
0 1 * * Sun root /usr/sbin/raid-check

View file

@ -1,26 +0,0 @@
--- mdadm/udev-md-raid-assembly.rules.orig 2023-01-06 16:37:03.780756100 +0800
+++ mdadm/udev-md-raid-assembly.rules 2023-01-06 17:04:09.536159980 +0800
@@ -5,6 +5,9 @@
ENV{ANACONDA}=="?*", GOTO="md_inc_end"
# assemble md arrays
+# Also don't process disks that are slated to be a multipath device
+ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="md_inc_end"
+
SUBSYSTEM!="block", GOTO="md_inc_end"
# skip non-initialized devices
@@ -33,6 +36,13 @@
LABEL="md_inc"
+# Make sure we don't handle dm devices when some limits are set.
+# And linux_raid_member only be set when change/remove event happen.
+# So we don't need to consider add event here.
+KERNEL=="dm-*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="md_inc_end"
+KERNEL=="dm-*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="md_inc_end"
+KERNEL=="dm-*", ENV{DM_SUSPENDED}=="1", GOTO="md_inc_end"
+
# Bare disks are ready when add event happens, the raid can be assembled.
ACTION=="change", KERNEL!="dm-*|md*", GOTO="md_inc_end"

View file

@ -1 +1 @@
d /run/mdadm 0710 root root -
d /var/run/mdadm 0710 root root -

67
mdadm.rules Normal file
View file

@ -0,0 +1,67 @@
# This file causes block devices with Linux RAID (mdadm) signatures to
# automatically cause mdadm to be run.
# See udev(8) for syntax
# Don't process any events if anaconda is running as anaconda brings up
# raid devices manually
ENV{ANACONDA}=="?*", GOTO="md_end"
# Also don't process disks that are slated to be a multipath device
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="md_end"
# We process add events on block devices (since they are ready as soon as
# they are added to the system), but we must process change events as well
# on any dm devices (like LUKS partitions or LVM logical volumes) and on
# md devices because both of these first get added, then get brought live
# and trigger a change event. The reason we don't process change events
# on bare hard disks is because if you stop all arrays on a disk, then
# run fdisk on the disk to change the partitions, when fdisk exits it
# triggers a change event, and we want to wait until all the fdisks on
# all member disks are done before we do anything. Unfortunately, we have
# no way of knowing that, so we just have to let those arrays be brought
# up manually after fdisk has been run on all of the disks.
# First, process all add events (md and dm devices will not really do
# anything here, just regular disks, and this also won't get any imsm
# array members either)
SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="linux_raid_member", \
IMPORT{program}="/sbin/mdadm -I $env{DEVNAME} --export $devnode --offroot ${DEVLINKS}"
SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="linux_raid_member", \
ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}=="?*", \
ENV{ID_FS_TYPE}=="linux_raid_member", \
RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}!="?*", \
ENV{ID_FS_TYPE}=="linux_raid_member", \
RUN+="/sbin/mdadm -If $name"
# Next, check to make sure the BIOS raid stuff wasn't turned off via cmdline
IMPORT{cmdline}="noiswmd"
IMPORT{cmdline}="nodmraid"
ENV{noiswmd}=="?*", GOTO="md_imsm_inc_end"
ENV{nodmraid}=="?*", GOTO="md_imsm_inc_end"
SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="isw_raid_member", \
RUN+="/sbin/mdadm -I $env{DEVNAME}"
SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}=="?*", \
ENV{ID_FS_TYPE}=="isw_raid_member", \
RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}!="?*", \
ENV{ID_FS_TYPE}=="isw_raid_member", \
RUN+="/sbin/mdadm -If $name"
LABEL="md_imsm_inc_end"
# Next make sure that this isn't a dm device we should skip for some reason
ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_change_end"
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_change_end"
ENV{DM_SUSPENDED}=="1", GOTO="dm_change_end"
KERNEL=="dm-*", SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="linux_raid_member", \
ACTION=="change", RUN+="/sbin/mdadm -I $env{DEVNAME}"
LABEL="dm_change_end"
# Finally catch any nested md raid arrays. If we brought up an md raid
# array that's part of another md raid array, it won't be ready to be used
# until the change event that occurs when it becomes live
KERNEL=="md*", SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="linux_raid_member", \
ACTION=="change", RUN+="/sbin/mdadm -I $env{DEVNAME}"
LABEL="md_end"

View file

@ -1,277 +1,163 @@
%bcond abrt %{undefined rhel}
Name: mdadm
Version: 4.3
Release: 9%{?dist}
Summary: The mdadm program controls Linux md devices (software RAID arrays)
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
License: GPL-2.0-or-later
Name: mdadm
Version: 4.1
%define subversion rc1
Release: rc1_1%{?dist}
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}-%{subversion}.tar.xz
Source1: mdmonitor.init
Source2: raid-check
Source3: mdadm.rules
Source4: mdadm-raid-check-sysconfig
Source5: mdadm-cron
Source6: mdmonitor.service
Source7: mdadm.conf
Source8: mdadm_event.conf
Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.xz
Source1: raid-check
Source2: mdadm-raid-check-sysconfig
Source3: mdmonitor.service
Source4: mdadm.conf
Source5: mdadm_event.conf
Source6: raid-check.timer
Source7: raid-check.service
Source8: mdcheck
Source10: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.sign
Source11: https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys/6F9E3E9D4EDEBB11.asc
# https://bugzilla.redhat.com/show_bug.cgi?id=2325906
# see: https://github.com/md-raid-utilities/mdadm/pull/165
# https://github.com/md-raid-utilities/mdadm/pull/160
# https://github.com/md-raid-utilities/mdadm/pull/159
# this is a reversion of the initial 'posix check' patch
# that causes all the trouble
Patch: 0001-Revert-mdadm-Follow-POSIX-Portable-Character-Set.patch
Patch: 0002-dont-stop-in-assemble.patch
Patch1: 0001-mdadm-fix-use-after-free-after-free_mdstat.patch
Patch2: 0002-imsm-Allow-create-RAID-volume-with-link-to-container.patch
Patch3: 0003-tests-func.sh-Fix-some-total-breakage-in-the-test-sc.patch
Patch4: 0004-imsm-change-reserved-space-to-4MB.patch
Patch5: 0005-imsm-add-functions-to-get-and-set-imsm-dev-size.patch
Patch6: 0006-imsm-pass-already-existing-map-to-imsm_num_data_memb.patch
Patch7: 0007-imsm-do-not-use-blocks_per_member-in-array-size-calc.patch
Patch8: 0008-Prevent-create-IMSM-volume-with-size-smaller-than-1M.patch
Patch9: 0009-mdadm-grow-correct-size-and-chunk_size-casting.patch
Patch10: 0010-Fix-misspelling-of-alignment-and-geometry.patch
Patch11: 0011-Do-not-confuse-gcc.patch
Patch12: 0012-super-intel-Use-memcpy-to-avoid-confusing-gcc.patch
Patch13: 0013-super-intel-Get-rid-of-unnused-string.patch
Patch14: 0014-super-intel-Avoid-gcc-8.1-complaining-about-truncati.patch
Patch15: 0015-super-intel-Do-not-truncate-last-character-of-volume.patch
Patch16: 0016-imsm-Do-not-block-volume-creation-when-container-has.patch
Patch17: 0017-imsm-Do-not-require-MDADM_EXPERIMENTAL-flag-anymore.patch
Patch18: 0018-Monitor-Increase-size-of-percentalert-to-avoid-gcc-w.patch
Patch19: 0019-mdopen-fix-gcc-8.1-string-overflow-error.patch
Patch20: 0020-super0-Use-memmove-when-adjusting-sparc2.2-superbloc.patch
Patch21: 0021-super1-Fix-cases-triggering-gcc-8.1-strncpy-truncate.patch
Patch22: 0022-super-ddf-Fix-gcc-8.1-overflow-warnings.patch
Patch23: 0023-Check-major-number-of-block-device-when-querying-md-.patch
Patch24: 0024-mdadm-test-mdadm-needn-t-make-install-on-the-system.patch
Patch25: 0025-mdadm-test-correct-tests-testdev-as-testdev-in-02r5g.patch
Patch26: 0026-gcc-8-coverity-hack.patch
# Fedora customization patches
Patch: mdadm-udev.patch
Patch: mdadm-2.5.2-static.patch
Patch97: mdadm-3.3-udev.patch
Patch98: mdadm-2.5.2-static.patch
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
License: GPLv2+
Group: System Environment/Base
Obsoletes: mdctl,raidtools
Obsoletes: mdadm-sysvinit
Conflicts: dracut < 034-1
Requires(post): systemd-units chkconfig coreutils
BuildRequires: systemd-units binutils-devel
Requires(preun): systemd-units
Requires(postun): systemd-units coreutils
Requires: libreport-filesystem
BuildRequires: make
BuildRequires: systemd-rpm-macros
BuildRequires: binutils-devel
BuildRequires: gcc
BuildRequires: systemd-devel
BuildRequires: gnupg2
BuildRequires: mandoc
%if %{with abrt}
Requires: libreport-filesystem
%endif
Requires(post): coreutils
Requires(postun): coreutils
%define _hardened_build 1
%description
%description
The mdadm program is used to create, manage, and monitor Linux MD (software
RAID) devices. As such, it provides similar functionality to the raidtools
package. However, mdadm is a single program, and it can perform
almost all functions without a configuration file, though a configuration
file can be used to help with some common tasks.
%prep
# because the tarball is what is signed, not the compressed tarball
# keyring should be one from https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys
# which will vary depending on who did the release
%{_bindir}/xz -dcT0 %{SOURCE0} | %{gpgverify} --keyring='%{SOURCE11}' --signature='%{SOURCE10}' --data=-
%autosetup -p1
%setup -q -n %{name}-%{version}_%{subversion}
%patch1 -p1 -b .0001
%patch2 -p1 -b .0002
%patch3 -p1 -b .0003
%patch4 -p1 -b .0004
%patch5 -p1 -b .0005
%patch6 -p1 -b .0006
%patch7 -p1 -b .0007
%patch8 -p1 -b .0008
%patch9 -p1 -b .0009
%patch10 -p1 -b .0010
%patch11 -p1 -b .0011
%patch12 -p1 -b .0012
%patch13 -p1 -b .0013
%patch14 -p1 -b .0014
%patch15 -p1 -b .0015
%patch16 -p1 -b .0016
%patch17 -p1 -b .0017
%patch18 -p1 -b .0018
%patch19 -p1 -b .0019
%patch20 -p1 -b .0020
%patch21 -p1 -b .0021
%patch22 -p1 -b .0022
%patch23 -p1 -b .0023
%patch24 -p1 -b .0024
%patch25 -p1 -b .0025
%patch26 -p1 -b .0026
# Fedora customization patches
%patch97 -p1 -b .udev
%patch98 -p1 -b .static
%build
# CXFLAGS is NOT a typo, it's baked into the makefile, not to be confused with CXXFLAGS
%make_build CXFLAGS="%{optflags} -std=gnu17 -Wno-error=unterminated-string-initialization" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon raid6check raid6check.man
make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon
%install
%make_install MANDIR=%{_mandir} BINDIR=%{_sbindir} SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_prefix}/lib/udev/ install install-systemd
install -Dp -m 755 %{SOURCE1} %{buildroot}%{_sbindir}/raid-check
install -Dp -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
mkdir -p -m 710 %{buildroot}/run/%{name}
mkdir -p -m 755 %{buildroot}%{_datadir}/%{name}
install -Dp -m 755 %{SOURCE8} %{buildroot}%{_datadir}/%{name}/mdcheck
rm -rf %{buildroot}
make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=%{_sbindir} SYSTEMD_DIR=%{_unitdir} install install-systemd
install -Dp -m 755 %{SOURCE2} %{buildroot}%{_sbindir}/raid-check
install -Dp -m 644 %{SOURCE3} %{buildroot}%{_udevrulesdir}/65-md-incremental.rules
install -Dp -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
install -Dp -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/cron.d/raid-check
mkdir -p -m 710 %{buildroot}/var/run/mdadm
# systemd
install -Dm644 %{SOURCE3} %{buildroot}%{_unitdir}
install -Dm644 %{SOURCE6} %{buildroot}%{_unitdir}
install -Dm644 %{SOURCE7} %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_unitdir}
install -m644 %{SOURCE6} %{buildroot}%{_unitdir}
# tmpfile
install -Dm 0644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/%{name}.conf
mkdir -p %{buildroot}%{_tmpfilesdir}
install -m 0644 %{SOURCE7} %{buildroot}%{_tmpfilesdir}/%{name}.conf
mkdir -p %{buildroot}%{_localstatedir}/run/
install -d -m 0710 %{buildroot}/run/%{name}/
install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/
# abrt
%if %{with abrt}
install -Dm644 %{SOURCE5} %{buildroot}%{_sysconfdir}/libreport/events.d/%{name}_event.conf
%endif
# raid6check
install -Dm755 raid6check %{buildroot}/%{_sbindir}/raid6check
install -Dm644 raid6check.man %{buildroot}/%{_mandir}/man8/raid6check.man
mkdir -p %{buildroot}/etc/libreport/events.d
install -m644 %{SOURCE8} %{buildroot}/etc/libreport/events.d
%post
%systemd_post mdmonitor.service raid-check.timer
# leftover from this service removal years ago (f18 era).
# we probably don't really need this anymore.
# https://bugzilla.redhat.com/show_bug.cgi?id=901651
%{_bindir}/systemctl disable mdmonitor-takeover.service >/dev/null 2>&1 || :
%systemd_post mdmonitor.service
/usr/bin/systemctl disable mdmonitor-takeover.service >/dev/null 2>&1 || :
%preun
%systemd_preun mdmonitor.service raid-check.timer
%systemd_preun mdmonitor.service
%postun
%systemd_postun_with_restart mdmonitor.service
%triggerun -- %{name} < 3.2.2-3
%{_bindir}/systemd-sysv-convert --save mdmonitor >/dev/null 2>&1 || :
/bin/systemctl --no-reload enable mdmonitor.service >/dev/null 2>&1 || :
/sbin/chkconfig --del mdmonitor >/dev/null 2>&1 || :
/bin/systemctl try-restart mdmonitor.service >/dev/null 2>&1 || :
%files
%license COPYING
%doc mdadm.conf-example misc/*
%{_udevrulesdir}/*-md-*
%{_sbindir}/%{name}
%{_sbindir}/mdmon
%{_sbindir}/raid-check
%{_sbindir}/raid6check
%{_unitdir}/md*
%{_unitdir}/raid-check.*
%defattr(-,root,root,-)
%doc TODO ChangeLog mdadm.conf-example COPYING misc/*
%{_udevrulesdir}/*
%{_sbindir}/*
%{_unitdir}/*
%{_mandir}/man*/md*
%{_mandir}/man8/raid6check*
%{_prefix}/lib/systemd/system-shutdown/mdadm.shutdown
%config(noreplace) %{_sysconfdir}/sysconfig/raid-check
%{_rundir}/%{name}/
/usr/lib/systemd/system-shutdown/*
%config(noreplace) %{_sysconfdir}/cron.d/*
%config(noreplace) %{_sysconfdir}/sysconfig/*
%dir %{_localstatedir}/run/%{name}/
%config(noreplace) %{_tmpfilesdir}/%{name}.conf
%if %{with abrt}
%{_sysconfdir}/libreport/events.d/mdadm_event.conf
%endif
%{_datadir}/%{name}/
/etc/libreport/events.d/*
%changelog
* Thu Aug 14 2025 Xiao Ni <xni@redhat.com> - 4.3-9
- Don't submit stop ioctl in assemble
- Resolves bz#2388480
* Thu Jul 24 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Sun Apr 06 2025 Adam Williamson <awilliam@redhat.com> - 4.3-7
- revert 'posix' name check to fix rhbz#2325906
* Thu Jan 23 2025 Jonathan Wright <jonathan@almalinux.org> - 4.3-6
- fix FTBFS on gcc15 rhbz#2340833
- fix permissions on /usr/share/mdadm to be world-readable rhbz#2322402
* Fri Jan 17 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Wed May 08 2024 Jonathan Wright <jonathan@almalinux.org> - 4.3-3
- use URLs for signature and pub key
- build and install raid6check and man page rhbz#2264741
* Wed May 08 2024 Jonathan Wright <jonathan@almalinux.org> - 4.3-2
- add source signature verification
- change source URL to https
* Wed May 08 2024 Jonathan Wright <jonathan@almalinux.org> - 4.3-1
- update to 4.3 rhbz#2267100
- modernize spec
* Wed May 08 2024 Jonathan Wright <jonathan@almalinux.org> - 4.2-9
- Fixes rhbz#2279743
- Use more macros in %files definitions
* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Wed Apr 12 2023 Xiao Ni <xni@redhat.com> - 4.2-5
- Update to latest upstream for rawhide(f39) and fix mdcheck service bug
- Resolves bz#2175540
* Mon Jan 30 2023 Xiao Ni <xni@redhat.com> - 4.2-4
- Update to latest upstream for f38
- Resolves bz#2163711
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Mon Mar 21 2022 Xiao Ni <xni@redhat.com> - 4.2-1
- Update to mdadm-4.2
- Resolves bz#2066150
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.2-rc2.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Mon Aug 09 2021 Xiao Ni <xni@redhat.com> - 4.2-rc2
- Update to mdadm-4.2-rc2
- Resolves bz#1988236
* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 4.1-8
- Rebuilt for updated systemd-rpm-macros
See https://pagure.io/fesco/issue/2583.
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed May 27 2020 Xiao Ni <xni@redhat.com> - 4.1-5
- Don't enable raid-check.service to avoid raid check after every boot
- Resolves bz1838409
* Sun Mar 08 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 4.1-4
- Fix install location of udev rules (rhbz 1809117)
* Fri Feb 07 2020 Alejandro Domínguez Muñoz <adomu@net-c.com> - 4.1-3
- Replace raid-check cron job with systemd timer
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Jan 13 2020 Peter Robinson <pbrobinson@fedoraproject.org> 4.1-1
- Update to 4.1 GA
- Spec cleanups and updates
- Update mdadm.pid location (rhbz 1701114, rhbz 1557623, rhbz 1557623)
* Sun Dec 15 2019 Julian Sikorski <belegdol@fedoraproject.org> - 4.1-rc2.0.5.2
- Fix invalid substitution type error
- Resolves bz1740662, bz1749859
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-rc2.0.5.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Jun 04 2019 Xiao Ni <xni@redhat.com> - 4.1-rc2.0.5
- Update tmpfiles directory to non-legacy location
- Resolves bz1704517
* Wed Apr 17 2019 Xiao Ni <xni@redhat.com> - 4.1-rc2.0.4
- Change tmpfiles directory to /run/mdadm
- Resovles bz1701821
* Sat Mar 16 2019 Björn Esser <besser82@fedoraproject.org> - 4.1-rc2.0.3
- Add patch to build without -Werror, fixes FTBFS (#1675363)
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-rc2.0.2.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Sep 13 2018 Adam Williamson <awilliam@redhat.com> - 4.1-rc2.0.2
- Fix multipath check in udev rule, broke array init in F29
- Resolves bz1628192
* Sun Aug 26 2018 Peter Robinson <pbrobinson@fedoraproject.org> 4.1-rc2.0.1
- Update to 4.1 rc2
* Fri Jul 20 2018 Xiao Ni <xni@redhat.com> - 4.1-rc1_1.2
- Add gcc into BuildRequires
- Resolves bz1604811
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-rc1_1.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Mon Jul 09 2018 Xiao Ni <xni@redhat.com> 4.1-rc1-1
- Update to latest upstream version 4.1-rc1
* Tue Jul 10 2018 Xiao Ni <xni@redhat.com> - 4.1-rc1-1
- Update to 4.1-rc1
- Resolves bz1556591
* Wed Jul 4 2018 Peter Robinson <pbrobinson@fedoraproject.org> 4.0-7
- Cleanup spec, use %%licenece, drop old sys-v migration bits
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

166
mdcheck
View file

@ -1,166 +0,0 @@
#!/bin/bash
# Copyright (C) 2014-2017 Neil Brown <neilb@suse.de>
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Author: Neil Brown
# Email: <neilb@suse.com>
# This script should be run periodically to automatically
# perform a 'check' on any md arrays.
#
# It supports a 'time budget' such that any incomplete 'check'
# will be checkpointed when that time has expired.
# A subsequent invocation can allow the 'check' to continue.
#
# Options are:
# --continue Don't start new checks, only continue old ones.
# --duration This is passed to "date --date=$duration" to find out
# when to finish
#
# To support '--continue', arrays are identified by UUID and the 'sync_completed'
# value is stored in /var/lib/mdcheck/$UUID
# convert a /dev/md name into /sys/.../md equivalent
sysname() {
set `ls -lLd $1`
maj=${5%,}
min=$6
readlink -f /sys/dev/block/$maj:$min
}
args=$(getopt -o hcd: -l help,continue,duration: -n mdcheck -- "$@")
rv=$?
if [ $rv -ne 0 ]; then exit $rv; fi
eval set -- $args
cont=
endtime=
while [ " $1" != " --" ]
do
case $1 in
--help )
echo >&2 'Usage: mdcheck [--continue] [--duration time-offset]'
echo >&2 ' time-offset must be understood by "date --date"'
exit 0
;;
--continue ) cont=yes ;;
--duration ) shift; dur=$1
endtime=$(date --date "$dur" "+%s")
;;
esac
shift
done
shift
# We need a temp file occasionally...
tmp=/var/lib/mdcheck/.md-check-$$
trap 'rm -f "$tmp"' 0 2 3 15
# firstly, clean out really old state files
mkdir -p /var/lib/mdcheck
find /var/lib/mdcheck -name "MD_UUID*" -type f -mtime +180 -exec rm {} \;
# Now look at each md device.
cnt=0
for dev in /dev/md?*
do
[ -e "$dev" ] || continue
sys=`sysname $dev`
if [ ! -f "$sys/md/sync_action" ]
then # cannot check this array
continue
fi
if [ "`cat $sys/md/sync_action`" != 'idle' ]
then # This array is busy
continue
fi
mdadm --detail --export "$dev" | grep '^MD_UUID=' > $tmp || continue
source $tmp
fl="/var/lib/mdcheck/MD_UUID_$MD_UUID"
if [ -z "$cont" ]
then
start=0
logger -p daemon.info mdcheck start checking $dev
elif [ -z "$MD_UUID" -o ! -f "$fl" ]
then
# Nothing to continue here
continue
else
start=`cat "$fl"`
logger -p daemon.info mdcheck continue checking $dev from $start
fi
cnt=$[cnt+1]
eval MD_${cnt}_fl=\$fl
eval MD_${cnt}_sys=\$sys
eval MD_${cnt}_dev=\$dev
echo $start > $fl
echo $start > $sys/md/sync_min
echo check > $sys/md/sync_action
done
if [ -z "$endtime" ]
then
exit 0
fi
while [ `date +%s` -lt $endtime ]
do
any=
for i in `eval echo {1..$cnt}`
do
eval fl=\$MD_${i}_fl
eval sys=\$MD_${i}_sys
eval dev=\$MD_${i}_dev
if [ -z "$fl" ]; then continue; fi
if [ "`cat $sys/md/sync_action`" != 'check' ]
then
logger -p daemon.info mdcheck finished checking $dev
eval MD_${i}_fl=
rm -f $fl
continue;
fi
read a rest < $sys/md/sync_completed
echo $a > $fl
any=yes
done
if [ -z "$any" ]; then exit 0; fi
sleep 120
done
# We've waited, and there are still checks running.
# Time to stop them.
for i in `eval echo {1..$cnt}`
do
eval fl=\$MD_${i}_fl
eval sys=\$MD_${i}_sys
eval dev=\$MD_${i}_dev
if [ -z "$fl" ]; then continue; fi
if [ "`cat $sys/md/sync_action`" != 'check' ]
then
eval MD_${i}_fl=
rm -f $fl
continue;
fi
echo idle > $sys/md/sync_action
cat $sys/md/sync_min > $fl
logger -p daemon.info pause checking $dev at `cat $fl`
done

118
mdmonitor.init Executable file
View file

@ -0,0 +1,118 @@
#!/bin/bash
#
# mdmonitor This starts, stops, and reloads the mdadm-based
# software RAID monitoring and management facility
#
# chkconfig: 2345 15 85
# description: software RAID monitoring and management
# config: /etc/mdadm.conf
#
# Copyright 2002 Red Hat, Inc.
#
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the MD software RAID monitor
# Description: The mdmonitor service checks the status of all software
# RAID arrays on the system. In the event that any of the arrays
# transition into a degraded state, it notifies the system
# administrator. Other options are available, see the mdadm.conf
# and mdadm man pages for possible ways to configure this service.
### END INIT INFO
PIDPATH=/var/run/mdadm
PIDFILE=/var/run/mdadm/mdadm.pid
PATH=/sbin:/usr/sbin:$PATH
RETVAL=0
OPTIONS="--monitor --scan -f --pid-file=$PIDFILE"
prog=mdmonitor
# Source function library.
. /etc/rc.d/init.d/functions
usage ()
{
echo "Usage: service $prog {start|stop|status|restart|try-restart|force-reload}"
RETVAL=1
}
start ()
{
# (Re)start mdmon to take over monitoring of mdmon started from the initrd
for i in /dev/md/*.pid; do
if [ -r $i ]; then
origprog="$prog"; prog="mdmon"
action $"Starting $prog: " /sbin/mdmon --takeover --all
prog="$origprog"
break
fi
done
# Make sure configuration file exists and has information we can use
# MAILADDR or PROGRAM or both must be set in order to run mdadm --monitor
[ -f /etc/mdadm.conf ] || return 6
grep '^\(MAILADDR\|PROGRAM\) .' /etc/mdadm.conf >/dev/null 2>&1 || return 6
# Create our directory if it isn't there yet
if [ ! -d $PIDPATH ]; then
mkdir -m 0700 $PIDPATH >&/dev/null
RC=$?
[ -x /sbin/restorecon ] && /sbin/restorecon $PIDPATH
if [ $RC -ne 0 ]; then
echo -n "Failed to create /var/run/mdadm"
failure
echo
return 1
fi
fi
if [ -f "$PIDFILE" ]; then
checkpid `cat $PIDFILE` && return 0
fi
echo -n $"Starting $prog: "
cd /
daemon --user=root mdadm ${OPTIONS}
ret=$?
[ $ret -eq "0" ] && touch /var/lock/subsys/$prog
echo
return $ret
}
stop ()
{
[ -f /var/lock/subsys/$prog ] || return 0
echo -n "Killing $prog: "
killproc mdadm
echo
rm -f $PIDFILE
rm -f /var/lock/subsys/$prog
}
restart ()
{
stop
start
}
condrestart ()
{
[ -e /var/lock/subsys/$prog ] && restart || return 0
}
case "$1" in
start|stop|restart|condrestart|try-restart|force-reload)
[ `id -u` != "0" ] && exit 4 ;;
esac
case "$1" in
start) start; RETVAL=$? ;;
stop) stop; RETVAL=$? ;;
status) status -p $PIDFILE $prog ; RETVAL=$? ;;
restart) restart; RETVAL=$? ;;
reload) RETVAL=3 ;;
condrestart|try-restart|force-reload) condrestart; RETVAL=$? ;;
*) usage ; RETVAL=2 ;;
esac
exit $RETVAL

View file

@ -4,9 +4,9 @@ ConditionPathExists=/etc/mdadm.conf
[Service]
Type=forking
PIDFile=/run/mdadm/mdadm.pid
PIDFile=/var/run/mdadm/mdadm.pid
EnvironmentFile=-/etc/sysconfig/mdmonitor
ExecStart=/sbin/mdadm --monitor --scan --syslog -f --pid-file=/run/mdadm/mdadm.pid
ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.pid
[Install]
WantedBy=multi-user.target

View file

@ -1,6 +0,0 @@
[Unit]
Description=RAID setup health check
[Service]
Type=oneshot
ExecStart=/usr/sbin/raid-check

View file

@ -1,10 +0,0 @@
[Unit]
Description=Weekly RAID setup health check
[Timer]
OnCalendar=Sun *-*-* 01:00:00
Persistent=true
AccuracySec=24h
[Install]
WantedBy=timers.target

View file

@ -1,2 +1 @@
SHA512 (mdadm-4.3.tar.xz) = e44977f2f80d2471cb313803a60c92dafe8282ac06bbbfd41ae90ca493c64a3da94db924538788d045fd7f0667333912dabedb0b070f9abf5c0540b32e0fa08f
SHA512 (mdadm-4.3.tar.sign) = c0ae042399974c360ffbf4f15928e59591eb88f97faac1d7892066fefb8f8c525fe0948a4fd6ddd3781d0b27d8891e1bd2e0cd9e6a2dbf17b9f8d8c4879dc6b1
SHA512 (mdadm-4.1-rc1.tar.xz) = 07d75ba511a252de95356bc63e480b3c196ad0715d719f75599d1fa2995d649ea86a63f74aee7558316d728ebaae2c87d86806089cba735532e1c39641baf727