- Detail: remove duplicated code (bsc#1226413)

0008-Detail-remove-duplicated-code.patch
- mdadm: Fix native --detail --export (bsc#1226413)
  0009-mdadm-Fix-native-detail-export.patch

OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=239
This commit is contained in:
Coly Li 2024-09-23 02:32:30 +00:00 committed by Git OBS Bridge
commit ca78f33aa3
21 changed files with 4568 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,68 @@
From aec3b907de48be54106600a1ecb69d1231f4801d Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Thu, 18 Jan 2024 11:30:15 +0100
Subject: [PATCH 1/5] Remove hardcoded checkpoint interval checking
Git-commit: aec3b907de48be54106600a1ecb69d1231f4801d
Patch-mainline: mdadm-4.3+
References: jsc#PED-7542
Mdmon assumes that kernel marks checkpoint every 1/16 of the volume size
and that the checkpoints are equal in size. This is not true, kernel may
mark checkpoints more frequently depending on several factors, including
sync speed. This results in checkpoints reported by mdadm --examine
falling behind the one reported by kernel.
Remove hardcoded checkpoint interval checking.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
monitor.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/monitor.c b/monitor.c
index 4acec67..b8d9e88 100644
--- a/monitor.c
+++ b/monitor.c
@@ -564,22 +564,10 @@ static int read_and_act(struct active_array *a, fd_set *fds)
}
}
- /* Check for recovery checkpoint notifications. We need to be a
- * minimum distance away from the last checkpoint to prevent
- * over checkpointing. Note reshape checkpointing is handled
- * in the second branch.
+ /* Handle reshape checkpointing
*/
- if (sync_completed > a->last_checkpoint &&
- sync_completed - a->last_checkpoint > a->info.component_size >> 4 &&
- a->curr_action > reshape) {
- /* A (non-reshape) sync_action has reached a checkpoint.
- * Record the updated position in the metadata
- */
- a->last_checkpoint = sync_completed;
- a->container->ss->set_array_state(a, a->curr_state <= clean);
- } else if ((a->curr_action == idle && a->prev_action == reshape) ||
- (a->curr_action == reshape &&
- sync_completed > a->last_checkpoint)) {
+ if ((a->curr_action == idle && a->prev_action == reshape) ||
+ (a->curr_action == reshape && sync_completed > a->last_checkpoint)) {
/* Reshape has progressed or completed so we need to
* update the array state - and possibly the array size
*/
@@ -607,8 +595,10 @@ static int read_and_act(struct active_array *a, fd_set *fds)
a->last_checkpoint = sync_completed;
}
- if (sync_completed > a->last_checkpoint)
+ if (sync_completed > a->last_checkpoint) {
a->last_checkpoint = sync_completed;
+ a->container->ss->set_array_state(a, a->curr_state <= clean);
+ }
if (sync_completed >= a->info.component_size)
a->last_checkpoint = 0;
--
2.35.3

View File

@ -0,0 +1,100 @@
From cf87fe75fd83dac008ea116c2c52ec69783fdf6a Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Thu, 18 Jan 2024 11:30:16 +0100
Subject: [PATCH 2/5] monitor: refactor checkpoint update
Git-commit: cf87fe75fd83dac008ea116c2c52ec69783fdf6a
Patch-mainline: mdadm-4.3+
References: jsc#PED-7542
"if" statements of checkpoint updates have too many responsibilties.
This results in unclear code flow and duplicated code.
Refactor checkpoint update code and simplify "if" statements.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
monitor.c | 51 +++++++++++++++++++++++++--------------------------
1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/monitor.c b/monitor.c
index b8d9e88..be0bec7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -412,6 +412,7 @@ static int read_and_act(struct active_array *a, fd_set *fds)
int ret = 0;
int count = 0;
struct timeval tv;
+ bool write_checkpoint = false;
a->next_state = bad_word;
a->next_action = bad_action;
@@ -564,40 +565,38 @@ static int read_and_act(struct active_array *a, fd_set *fds)
}
}
- /* Handle reshape checkpointing
- */
- if ((a->curr_action == idle && a->prev_action == reshape) ||
- (a->curr_action == reshape && sync_completed > a->last_checkpoint)) {
- /* Reshape has progressed or completed so we need to
- * update the array state - and possibly the array size
- */
+ /* Update reshape checkpoint, depending if it finished or progressed */
+ if (a->curr_action == idle && a->prev_action == reshape) {
+ char buf[SYSFS_MAX_BUF_SIZE];
+
if (sync_completed != 0)
a->last_checkpoint = sync_completed;
- /* We might need to update last_checkpoint depending on
- * the reason that reshape finished.
- * if array reshape is really finished:
- * set check point to the end, this allows
- * set_array_state() to finalize reshape in metadata
- * if reshape if broken: do not set checkpoint to the end
- * this allows for reshape restart from checkpoint
+
+ /*
+ * If reshape really finished, set checkpoint to the end to finalize it.
+ * Do not set checkpoint if reshape is broken.
+ * Reshape will restart from last checkpoint.
*/
- if ((a->curr_action != reshape) &&
- (a->prev_action == reshape)) {
- char buf[SYSFS_MAX_BUF_SIZE];
- if ((sysfs_get_str(&a->info, NULL,
- "reshape_position",
- buf,
- sizeof(buf)) >= 0) &&
- str_is_none(buf) == true)
+ if (sysfs_get_str(&a->info, NULL, "reshape_position", buf, sizeof(buf)) >= 0)
+ if (str_is_none(buf) == true)
a->last_checkpoint = a->info.component_size;
- }
- a->container->ss->set_array_state(a, a->curr_state <= clean);
- a->last_checkpoint = sync_completed;
+
+ write_checkpoint = true;
}
- if (sync_completed > a->last_checkpoint) {
+ if (a->curr_action >= reshape && sync_completed > a->last_checkpoint) {
+ /* Update checkpoint if neither reshape nor idle action */
a->last_checkpoint = sync_completed;
+
+ write_checkpoint = true;
+ }
+
+ /* Save checkpoint */
+ if (write_checkpoint) {
a->container->ss->set_array_state(a, a->curr_state <= clean);
+
+ if (a->curr_action <= reshape)
+ a->last_checkpoint = sync_completed;
}
if (sync_completed >= a->info.component_size)
--
2.35.3

View File

@ -0,0 +1,51 @@
From fdb7e802f4cf64d067c3abaafa35056e2bc1ed43 Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Thu, 18 Jan 2024 11:30:17 +0100
Subject: [PATCH 3/5] Super-intel: Fix first checkpoint restart
Git-commit: fdb7e802f4cf64d067c3abaafa35056e2bc1ed43
Patch-mainline: mdadm-4.3+
References: jsc#PED-7542
When imsm based array is stopped after reaching first checkpoint and
then assembled, first checkpoint is reported as 0.
This behaviour is valid only for initial checkpoint, if the array was
stopped while performing some action.
Last checkpoint value is not taken from metadata but always starts
with 0 and it's incremented when sync_completed in sysfs changes.
In simplification, read_and_act() is responsible for checkpoint updates
and is executed each time sysfs checkpoint update happens. For first
checkpoint it is executed twice and due to marking checkpoint before
triggering any action on the array, it is impossible to read
sync_completed from sysfs in just two iterations.
The workaround to this is not marking any checkpoint for first
sysfs checkpoint after RAID assembly, to preserve checkpoint value
stored in metadata.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super-intel.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/super-intel.c b/super-intel.c
index dbea235..e61f3f6 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -8771,6 +8771,9 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
super->updates_pending++;
}
+ if (a->prev_action == idle)
+ goto skip_mark_checkpoint;
+
mark_checkpoint:
/* skip checkpointing for general migration,
* it is controlled in mdadm
--
2.35.3

View File

@ -0,0 +1,65 @@
From ea2ca7ed3dbbf881ce08d80fe371f2aaf05011c3 Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Thu, 18 Jan 2024 11:30:18 +0100
Subject: [PATCH 4/5] Grow: Move update_tail assign to Grow_reshape()
Git-commit: ea2ca7ed3dbbf881ce08d80fe371f2aaf05011c3
Patch-mainline: mdadm-4.3+
References: jsc#PED-7542
Due to e919fb0af245 ("FIX: Enable metadata updates for raid0") code
can't enter super-intel.c:3415, resulting in checkpoint not being
saved to metadata for second volume in matrix raid array.
This results in checkpoint being stuck at last value for the
first volume.
Move st->update_tail to Grow_reshape() so it is assigned for each
volume.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Grow.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Grow.c b/Grow.c
index f95dae8..5498e54 100644
--- a/Grow.c
+++ b/Grow.c
@@ -2085,9 +2085,10 @@ int Grow_reshape(char *devname, int fd,
if (!mdmon_running(st->container_devnm))
start_mdmon(st->container_devnm);
ping_monitor(container);
- if (mdmon_running(st->container_devnm) &&
- st->update_tail == NULL)
- st->update_tail = &st->updates;
+ if (mdmon_running(st->container_devnm) == false) {
+ pr_err("No mdmon found. Grow cannot continue.\n");
+ goto release;
+ }
}
if (s->size == MAX_SIZE)
@@ -3048,6 +3049,8 @@ static int reshape_array(char *container, int fd, char *devname,
dprintf("Cannot get array information.\n");
goto release;
}
+ if (st->update_tail == NULL)
+ st->update_tail = &st->updates;
if (array.level == 0 && info->component_size == 0) {
get_dev_size(fd, NULL, &array_size);
info->component_size = array_size / array.raid_disks;
@@ -5152,9 +5155,7 @@ int Grow_continue_command(char *devname, int fd,
start_mdmon(container);
ping_monitor(container);
- if (mdmon_running(container))
- st->update_tail = &st->updates;
- else {
+ if (mdmon_running(container) == false) {
pr_err("No mdmon found. Grow cannot continue.\n");
ret_val = 1;
goto Grow_continue_command_exit;
--
2.35.3

View File

@ -0,0 +1,60 @@
From 37eeae381a8ed07a1fabb64184fe45d95a861496 Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Thu, 18 Jan 2024 11:30:19 +0100
Subject: [PATCH 5/5] Add understanding output section in man
Git-commit: 37eeae381a8ed07a1fabb64184fe45d95a861496
Patch-mainline: mdadm-4.3+
References: jsc#PED-7542
Add new section in man for explaining mdadm outputs.
Describe checkpoint entry.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
mdadm.8.in | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/mdadm.8.in b/mdadm.8.in
index 96a4a08..9ba6682 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -3179,7 +3179,7 @@ environment. This can be useful for testing or for disaster
recovery. You should be aware that interoperability may be
compromised by setting this value.
-These change can also be suppressed by adding
+These change can also be suppressed by adding
.B mdadm.imsm.test=1
to the kernel command line. This makes it easy to test IMSM
code in a virtual machine that doesn't have IMSM virtual hardware.
@@ -3454,6 +3454,25 @@ is any string. These names are supported by
since version 3.3 provided they are enabled in
.IR mdadm.conf .
+.SH UNDERSTANDING OUTPUT
+
+.TP
+EXAMINE
+
+.TP
+.B checkpoint
+Checkpoint value is reported when array is performing some action including
+resync, recovery or reshape. Checkpoints allow resuming action from certain
+point if it was interrupted.
+
+Checkpoint is reported as combination of two values: current migration unit
+and number of blocks per unit. By multiplying those values and dividing by
+array size checkpoint progress percentage can be obtained in relation to
+current progress reported in /proc/mdstat. Checkpoint is also related to (and
+sometimes based on) sysfs entry sync_completed but depending on action units
+may differ. Even if units are the same, it should not be expected that
+checkpoint and sync_completed will be exact match nor updated simultaneously.
+
.SH NOTE
.I mdadm
was previously known as
--
2.35.3

View File

@ -0,0 +1,59 @@
From b0f4e8e30f38d83f7e3f53d01d72d4cb3b4d42d7 Mon Sep 17 00:00:00 2001
From: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Date: Tue, 7 May 2024 05:38:55 +0200
Subject: [PATCH] util.c: change devnm to const in mdmon functions
Git-commit: b0f4e8e30f38d83f7e3f53d01d72d4cb3b4d42d7
Patch-mainline: mdadm-4.3+
References: bsc#1225307
Devnm shall not be changed inside mdmon_running()
and mdmon_pid() functions, change this parameter to const.
Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
mdadm.h | 4 ++--
util.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index 2ff3e463..1ba541fc 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1768,8 +1768,8 @@ extern int is_subarray_active(char *subarray, char *devname);
extern int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet);
extern struct superswitch *version_to_superswitch(char *vers);
-extern int mdmon_running(char *devnm);
-extern int mdmon_pid(char *devnm);
+extern int mdmon_running(const char *devnm);
+extern int mdmon_pid(const char *devnm);
extern int check_env(char *name);
extern __u32 random32(void);
extern void random_uuid(__u8 *buf);
diff --git a/util.c b/util.c
index 4fbf11c4..e2b490e1 100644
--- a/util.c
+++ b/util.c
@@ -1902,7 +1902,7 @@ unsigned long long min_recovery_start(struct mdinfo *array)
return recovery_start;
}
-int mdmon_pid(char *devnm)
+int mdmon_pid(const char *devnm)
{
char path[100];
char pid[10];
@@ -1922,7 +1922,7 @@ int mdmon_pid(char *devnm)
return atoi(pid);
}
-int mdmon_running(char *devnm)
+int mdmon_running(const char *devnm)
{
int pid = mdmon_pid(devnm);
if (pid <= 0)
--
2.35.3

View File

@ -0,0 +1,125 @@
From aa1cc5815d2b14a8b47add18cfaa8264e19c10ce Mon Sep 17 00:00:00 2001
From: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Date: Tue, 7 May 2024 05:38:56 +0200
Subject: [PATCH] Wait for mdmon when it is stared via systemd
Git-commit: aa1cc5815d2b14a8b47add18cfaa8264e19c10ce
Patch-mainline: mdadm-4.3+
References: bsc#1225307
When mdmon is being started it may need few seconds to start.
For now, we didn't wait for it. Introduce wait_for_mdmon()
function, which waits up to 5 seconds for mdmon to start completely.
Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Assemble.c | 4 ++--
Grow.c | 7 ++++---
mdadm.h | 2 ++
util.c | 29 +++++++++++++++++++++++++++++
4 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index f5e9ab1f..83dced19 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -2173,8 +2173,8 @@ int assemble_container_content(struct supertype *st, int mdfd,
if (!mdmon_running(st->container_devnm))
start_mdmon(st->container_devnm);
ping_monitor(st->container_devnm);
- if (mdmon_running(st->container_devnm) &&
- st->update_tail == NULL)
+ if (wait_for_mdmon(st->container_devnm) == MDADM_STATUS_SUCCESS &&
+ !st->update_tail)
st->update_tail = &st->updates;
}
diff --git a/Grow.c b/Grow.c
index 87ed9214..1923c27c 100644
--- a/Grow.c
+++ b/Grow.c
@@ -2134,7 +2134,7 @@ int Grow_reshape(char *devname, int fd,
if (!mdmon_running(st->container_devnm))
start_mdmon(st->container_devnm);
ping_monitor(container);
- if (mdmon_running(st->container_devnm) == false) {
+ if (wait_for_mdmon(st->container_devnm) != MDADM_STATUS_SUCCESS) {
pr_err("No mdmon found. Grow cannot continue.\n");
goto release;
}
@@ -3218,7 +3218,8 @@ static int reshape_array(char *container, int fd, char *devname,
if (!mdmon_running(container))
start_mdmon(container);
ping_monitor(container);
- if (mdmon_running(container) && st->update_tail == NULL)
+ if (wait_for_mdmon(container) == MDADM_STATUS_SUCCESS &&
+ !st->update_tail)
st->update_tail = &st->updates;
}
}
@@ -5173,7 +5174,7 @@ int Grow_continue_command(char *devname, int fd, struct context *c)
start_mdmon(container);
ping_monitor(container);
- if (mdmon_running(container) == false) {
+ if (wait_for_mdmon(container) != MDADM_STATUS_SUCCESS) {
pr_err("No mdmon found. Grow cannot continue.\n");
ret_val = 1;
goto Grow_continue_command_exit;
diff --git a/mdadm.h b/mdadm.h
index 1ba541fc..b71d7b32 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1770,6 +1770,8 @@ extern struct superswitch *version_to_superswitch(char *vers);
extern int mdmon_running(const char *devnm);
extern int mdmon_pid(const char *devnm);
+extern mdadm_status_t wait_for_mdmon(const char *devnm);
+
extern int check_env(char *name);
extern __u32 random32(void);
extern void random_uuid(__u8 *buf);
diff --git a/util.c b/util.c
index e2b490e1..bf79742f 100644
--- a/util.c
+++ b/util.c
@@ -1932,6 +1932,35 @@ int mdmon_running(const char *devnm)
return 0;
}
+/*
+ * wait_for_mdmon() - Waits for mdmon within specified time.
+ * @devnm: Device for which mdmon should start.
+ *
+ * Function waits for mdmon to start. It may need few seconds
+ * to start, we set timeout to 5, it should be sufficient.
+ * Do not wait if mdmon has been started.
+ *
+ * Return: MDADM_STATUS_SUCCESS if mdmon is running, error code otherwise.
+ */
+mdadm_status_t wait_for_mdmon(const char *devnm)
+{
+ const time_t mdmon_timeout = 5;
+ time_t start_time = time(0);
+
+ if (mdmon_running(devnm))
+ return MDADM_STATUS_SUCCESS;
+
+ pr_info("Waiting for mdmon to start\n");
+ while (time(0) - start_time < mdmon_timeout) {
+ sleep_for(0, MSEC_TO_NSEC(200), true);
+ if (mdmon_running(devnm))
+ return MDADM_STATUS_SUCCESS;
+ };
+
+ pr_err("Timeout waiting for mdmon\n");
+ return MDADM_STATUS_ERROR;
+}
+
int start_mdmon(char *devnm)
{
int i;
--
2.35.3

View File

@ -0,0 +1,79 @@
From 60c19530dd7cc6b38a75695a0a3d004bbe60d430 Mon Sep 17 00:00:00 2001
From: Kinga Tanska <kinga.tanska@intel.com>
Date: Tue, 27 Feb 2024 03:36:14 +0100
Subject: [PATCH] Detail: remove duplicated code
Git-commit: 60c19530dd7cc6b38a75695a0a3d004bbe60d430
Patch-mainline: mdadm-4.3
References: bsc#1226413
Remove duplicated code from Detail(), where MD_UUID and MD_DEVNAME
are being set. Superblock is no longer required to print system
properties. Now it tries to obtain map in two ways.
Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Detail.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/Detail.c b/Detail.c
index aaa3dd6e..f23ec16f 100644
--- a/Detail.c
+++ b/Detail.c
@@ -226,6 +226,9 @@ int Detail(char *dev, struct context *c)
str = map_num(pers, array.level);
if (c->export) {
+ char nbuf[64];
+ struct map_ent *mp = NULL, *map = NULL;
+
if (array.raid_disks) {
if (str)
printf("MD_LEVEL=%s\n", str);
@@ -247,32 +250,22 @@ int Detail(char *dev, struct context *c)
array.minor_version);
}
- if (st && st->sb && info) {
- char nbuf[64];
- struct map_ent *mp, *map = NULL;
-
- fname_from_uuid(st, info, nbuf, ':');
- printf("MD_UUID=%s\n", nbuf + 5);
+ if (info)
mp = map_by_uuid(&map, info->uuid);
+ if (!mp)
+ mp = map_by_devnm(&map, fd2devnm(fd));
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
+ if (mp) {
+ __fname_from_uuid(mp->uuid, 0, nbuf, ':');
+ printf("MD_UUID=%s\n", nbuf + 5);
+ if (mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
+ }
+ map_free(map);
+ if (st && st->sb) {
if (st->ss->export_detail_super)
st->ss->export_detail_super(st);
- map_free(map);
- } else {
- struct map_ent *mp, *map = NULL;
- char nbuf[64];
- mp = map_by_devnm(&map, fd2devnm(fd));
- if (mp) {
- __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);
-
- map_free(map);
}
if (!c->no_devices && sra) {
struct mdinfo *mdi;
--
2.46.0

View File

@ -0,0 +1,251 @@
From ba65d917d121dfb9876053e6f62dbd4ebf2e028c Mon Sep 17 00:00:00 2001
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Date: Mon, 18 Mar 2024 16:19:30 +0100
Subject: [PATCH] mdadm: Fix native --detail --export
Git-commit: ba65d917d121dfb9876053e6f62dbd4ebf2e028c
Patch-mainline: mdadm-4.3
References: bsc#1226413
Mentioned commit (see Fixes) causes that UUID is not swapped as expected
for native superblock. Fix this problem.
For detail, we should avoid superblock calls, we can have information
about supertype from map, use that.
Simplify fname_from_uuid() by removing dependencies to metadata
handler, it is not needed. Decision is taken at compile time, expect
super1 but this function is not used by super1. Add warning about that.
Remove separator, it is always ':'.
Fixes: 60c19530dd7c ("Detail: remove duplicated code")
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Detail.c | 26 +++++++++++++++++++++++++-
mdadm.h | 3 +--
super-ddf.c | 10 +++++-----
super-intel.c | 16 ++++++++--------
util.c | 24 +++++++++++++-----------
5 files changed, 52 insertions(+), 27 deletions(-)
diff --git a/Detail.c b/Detail.c
index f23ec16f..55a086d3 100644
--- a/Detail.c
+++ b/Detail.c
@@ -49,6 +49,30 @@ static int add_device(const char *dev, char ***p_devices,
return n_devices + 1;
}
+/**
+ * detail_fname_from_uuid() - generate uuid string with special super1 handling.
+ * @mp: map entry to parse.
+ * @buf: buf to write.
+ *
+ * Hack to workaround an issue with super1 superblocks. It swapuuid set in order for assembly
+ * to work, but can't have it set if we want this printout to match all the other uuid printouts
+ * in super1.c, so we force swapuuid to 1 to make our printout match the rest of super1.
+ *
+ * Always convert uuid if host is big endian.
+ */
+char *detail_fname_from_uuid(struct map_ent *mp, char *buf)
+{
+#if __BYTE_ORDER == BIG_ENDIAN
+ bool swap = true;
+#else
+ bool swap = false;
+#endif
+ if (strncmp(mp->metadata, "1.", 2) == 0)
+ swap = true;
+
+ return __fname_from_uuid(mp->uuid, swap, buf, ':');
+}
+
int Detail(char *dev, struct context *c)
{
/*
@@ -256,7 +280,7 @@ int Detail(char *dev, struct context *c)
mp = map_by_devnm(&map, fd2devnm(fd));
if (mp) {
- __fname_from_uuid(mp->uuid, 0, nbuf, ':');
+ detail_fname_from_uuid(mp, nbuf);
printf("MD_UUID=%s\n", nbuf + 5);
if (mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
diff --git a/mdadm.h b/mdadm.h
index 3fedca48..a363708a 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1696,8 +1696,7 @@ extern const int uuid_zero[4];
extern int same_uuid(int a[4], int b[4], int swapuuid);
extern void copy_uuid(void *a, int b[4], int swapuuid);
extern char *__fname_from_uuid(int id[4], int swap, char *buf, char sep);
-extern char *fname_from_uuid(struct supertype *st,
- struct mdinfo *info, char *buf, char sep);
+extern char *fname_from_uuid(struct mdinfo *info, char *buf);
extern unsigned long calc_csum(void *super, int bytes);
extern int enough(int level, int raid_disks, int layout, int clean,
char *avail);
diff --git a/super-ddf.c b/super-ddf.c
index 94ac5ff3..21426c75 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -1617,7 +1617,7 @@ static void brief_examine_super_ddf(struct supertype *st, int verbose)
struct mdinfo info;
char nbuf[64];
getinfo_super_ddf(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf("ARRAY metadata=ddf UUID=%s\n", nbuf + 5);
}
@@ -1632,7 +1632,7 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose)
unsigned int i;
char nbuf[64];
getinfo_super_ddf(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
for (i = 0; i < be16_to_cpu(ddf->virt->max_vdes); i++) {
struct virtual_entry *ve = &ddf->virt->entries[i];
@@ -1645,7 +1645,7 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose)
ddf->currentconf =&vcl;
vcl.vcnum = i;
uuid_from_super_ddf(st, info.uuid);
- fname_from_uuid(st, &info, nbuf1, ':');
+ fname_from_uuid(&info, nbuf1);
_ddf_array_name(namebuf, ddf, i);
printf("ARRAY%s%s container=%s member=%d UUID=%s\n",
namebuf[0] == '\0' ? "" : " " DEV_MD_DIR, namebuf,
@@ -1658,7 +1658,7 @@ static void export_examine_super_ddf(struct supertype *st)
struct mdinfo info;
char nbuf[64];
getinfo_super_ddf(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf("MD_METADATA=ddf\n");
printf("MD_LEVEL=container\n");
printf("MD_UUID=%s\n", nbuf+5);
@@ -1798,7 +1798,7 @@ static void brief_detail_super_ddf(struct supertype *st, char *subarray)
return;
else
uuid_of_ddf_subarray(ddf, vcnum, info.uuid);
- fname_from_uuid(st, &info, nbuf,':');
+ fname_from_uuid(&info, nbuf);
printf(" UUID=%s", nbuf + 5);
}
diff --git a/super-intel.c b/super-intel.c
index e1754f29..ff2590fe 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2217,7 +2217,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
else
printf("not supported\n");
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf(" UUID : %s\n", nbuf + 5);
sum = __le32_to_cpu(mpb->check_sum);
printf(" Checksum : %08x %s\n", sum,
@@ -2242,7 +2242,7 @@ static void examine_super_imsm(struct supertype *st, char *homehost)
super->current_vol = i;
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
print_imsm_dev(super, dev, nbuf + 5, super->disks->index);
}
for (i = 0; i < mpb->num_disks; i++) {
@@ -2267,7 +2267,7 @@ static void brief_examine_super_imsm(struct supertype *st, int verbose)
char nbuf[64];
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf("ARRAY metadata=imsm UUID=%s\n", nbuf + 5);
}
@@ -2284,13 +2284,13 @@ static void brief_examine_subarrays_imsm(struct supertype *st, int verbose)
return;
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
for (i = 0; i < super->anchor->num_raid_devs; i++) {
struct imsm_dev *dev = get_imsm_dev(super, i);
super->current_vol = i;
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf1, ':');
+ fname_from_uuid(&info, nbuf1);
printf("ARRAY " DEV_MD_DIR "%.16s container=%s member=%d UUID=%s\n",
dev->volume, nbuf + 5, i, nbuf1 + 5);
}
@@ -2304,7 +2304,7 @@ static void export_examine_super_imsm(struct supertype *st)
char nbuf[64];
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf("MD_METADATA=imsm\n");
printf("MD_LEVEL=container\n");
printf("MD_UUID=%s\n", nbuf+5);
@@ -2324,7 +2324,7 @@ static void detail_super_imsm(struct supertype *st, char *homehost,
super->current_vol = strtoul(subarray, NULL, 10);
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf("\n UUID : %s\n", nbuf + 5);
super->current_vol = temp_vol;
@@ -2341,7 +2341,7 @@ static void brief_detail_super_imsm(struct supertype *st, char *subarray)
super->current_vol = strtoul(subarray, NULL, 10);
getinfo_super_imsm(st, &info, NULL);
- fname_from_uuid(st, &info, nbuf, ':');
+ fname_from_uuid(&info, nbuf);
printf(" UUID=%s", nbuf + 5);
super->current_vol = temp_vol;
diff --git a/util.c b/util.c
index 49a9c6e2..03336d6f 100644
--- a/util.c
+++ b/util.c
@@ -589,19 +589,21 @@ char *__fname_from_uuid(int id[4], int swap, char *buf, char sep)
}
-char *fname_from_uuid(struct supertype *st, struct mdinfo *info,
- char *buf, char sep)
-{
- // dirty hack to work around an issue with super1 superblocks...
- // super1 superblocks need swapuuid set in order for assembly to
- // work, but can't have it set if we want this printout to match
- // all the other uuid printouts in super1.c, so we force swapuuid
- // to 1 to make our printout match the rest of super1
+/**
+ * fname_from_uuid() - generate uuid string. Should not be used with super1.
+ * @info: info with uuid
+ * @buf: buf to fill.
+ *
+ * This routine should not be used with super1. See detail_fname_from_uuid() for details. It does
+ * not use superswitch swapuuid as it should be 0 but it has to do UUID conversion if host is big
+ * endian- left for backward compatibility.
+ */
+char *fname_from_uuid(struct mdinfo *info, char *buf)
+{
#if __BYTE_ORDER == BIG_ENDIAN
- return __fname_from_uuid(info->uuid, 1, buf, sep);
+ return __fname_from_uuid(info->uuid, true, buf, ':');
#else
- return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 :
- st->ss->swapuuid, buf, sep);
+ return __fname_from_uuid(info->uuid, false, buf, ':');
#endif
}
--
2.46.0

View File

@ -0,0 +1,30 @@
---
Detail.c | 1 +
md_p.h | 1 +
2 files changed, 2 insertions(+)
Index: mdadm-4.0/Detail.c
===================================================================
--- mdadm-4.0.orig/Detail.c
+++ mdadm-4.0/Detail.c
@@ -693,6 +693,8 @@ This is pretty boring
disk.raid_disk >= 0)
failed++;
}
+ if (disk.state & (1<<MD_DISK_TIMEOUT))
+ printf(" timeout");
if (disk.state & (1 << MD_DISK_ACTIVE))
printf(" active");
if (disk.state & (1 << MD_DISK_SYNC)) {
Index: mdadm-4.0/md_p.h
===================================================================
--- mdadm-4.0.orig/md_p.h
+++ mdadm-4.0/md_p.h
@@ -90,6 +90,7 @@
* dire need
*/
#define MD_DISK_FAILFAST 10 /* Fewer retries, more failures */
+#define MD_DISK_TIMEOUT 11 /* disk is faulty due to timeout */
#define MD_DISK_REPLACEMENT 17
#define MD_DISK_JOURNAL 18 /* disk is used as the write journal in RAID-5/6 */

View File

@ -0,0 +1,25 @@
From: Ali Abdallah <ali.abdallah@suse.com>
Subject: OnCalendar format fix of mdcheck_start.timer
Patch-mainline: in-house patch at this moment, will post to upstream in future
References: bsc#1173137
This patch includes the fix of the OnCalendar format, changing the format of
mdcheck_start.timer [Timer] section,
from OnCalendar=Sun *-*-1..7 1:00:00
to OnCalendar=Sun *-*-* 1:00:00
Signed-off-by: Ali Abdallah <ali.abdallah@suse.com>
Acked-by: Coly Li <colyli@suse.de>
Index: mdadm-4.1/systemd/mdcheck_start.timer
===================================================================
--- mdadm-4.1.orig/systemd/mdcheck_start.timer
+++ mdadm-4.1/systemd/mdcheck_start.timer
@@ -9,7 +9,7 @@
Description=MD array scrubbing
[Timer]
-OnCalendar=Sun *-*-1..7 1:00:00
+OnCalendar=Sun *-*-* 1:00:00
[Install]
WantedBy= mdmonitor.service

View File

@ -0,0 +1,59 @@
From 2361620a9d78a4e26ec438b5cc21fe796d411497 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 31 Aug 2020 00:02:10 +0800
Subject: [PATCH] mdadm: treat the Dell softraid array as local array
Patch-mainline: N/A, in-house usage only as a workaround to Dell's softraid bug
References: bsc#1175004
Dell softraid FW uses homehost in md raid superblock to store
its virtual disk name e.g. "VirtualDisk01". The improper usage
of md raid super block meta data from Dell softraid S150 utility
makes mdadm takes such md raid (Dell softraid Virtual Disk) as
foreign array and won't automatically assemble this array by
default. Here if an array's homehost name starts with "VirtualDisk"
then we take it as a Dell software raid and bypass the set_name
checking. This workaround makes current Dell software raid array
can be treated as local array and start automatically.
This workaround patch will be withdrawn after Dell softraid FW
fixes the improper usage problem on md raid superblock.
Signed-off-by: Coly Li <colyli@suse.de>
---
super1.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/super1.c b/super1.c
index 7664883..d15067a 100644
--- a/super1.c
+++ b/super1.c
@@ -954,8 +954,25 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
static int match_home1(struct supertype *st, char *homehost)
{
struct mdp_superblock_1 *sb = st->sb;
- int l = homehost ? strlen(homehost) : 0;
+ char *dell_softraid_header = "VirtualDisk";
+ int l = strlen(dell_softraid_header);
+
+ /*
+ * Dell softraid FW uses homehost in md raid superblock to store
+ * its virtual disk name e.g. "VirtualDisk01". The improper usage
+ * of md raid super block meta data from Dell softraid S150 utility
+ * makes mdadm takes such md raid (Dell softraid Virtual Disk) as
+ * foreign array and won't automatically assemble this array by
+ * default. Here if an array's homehost name starts with "VirtualDisk"
+ * then we take it as a Dell software raid and bypass the set_name
+ * checking. This workaround makes current Dell software raid array
+ * can be treated as local array and start automatically.
+ */
+ if (strncmp(sb->set_name, dell_softraid_header, l) == 0)
+ return 1;
+ /* Normal cases handleing */
+ l = homehost ? strlen(homehost) : 0;
return (l > 0 && l < 32 && sb->set_name[l] == ':' &&
strncmp(sb->set_name, homehost, l) == 0);
}
--
2.26.2

View File

@ -0,0 +1,61 @@
From 6e79d4bd229e5db4e435917daf4c57cd79db9265 Mon Sep 17 00:00:00 2001
From: colyli <colyli@suse.coly>
Date: Wed, 17 Oct 2018 11:08:39 +0800
Subject: [PATCH] Call mdadm_env.sh from /usr/libexec/mdadm
Patch-mainline: N/A, SUSE only patch
References: bsc#1111960, bsc#1202090
Current Makefile installs mdadm_env.sh to /usr/libexec/mdadm but the
systemd service files call it from /usr/lib/mdadm. This patch changes
the calling path in systemd service files to /usr/libexec/mdadm to
make things working.
Signed-off-by: Coly Li <colyli@suse.de>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: mdadm-4.3/systemd/mdcheck_continue.service
===================================================================
--- mdadm-4.3.orig/systemd/mdcheck_continue.service
+++ mdadm-4.3/systemd/mdcheck_continue.service
@@ -13,4 +13,6 @@ Documentation=man:mdadm(8)
[Service]
Type=oneshot
Environment="MDADM_CHECK_DURATION=6 hours"
+EnvironmentFile=-/run/sysconfig/mdadm
+ExecStartPre=-/usr/libexec/mdadm/mdadm_env.sh
ExecStart=/usr/share/mdadm/mdcheck --continue --duration ${MDADM_CHECK_DURATION}
Index: mdadm-4.3/systemd/mdcheck_start.service
===================================================================
--- mdadm-4.3.orig/systemd/mdcheck_start.service
+++ mdadm-4.3/systemd/mdcheck_start.service
@@ -13,4 +13,6 @@ Documentation=man:mdadm(8)
[Service]
Type=oneshot
Environment="MDADM_CHECK_DURATION=6 hours"
+EnvironmentFile=-/run/sysconfig/mdadm
+ExecStartPre=-/usr/libexec/mdadm/mdadm_env.sh
ExecStart=/usr/share/mdadm/mdcheck --duration ${MDADM_CHECK_DURATION}
Index: mdadm-4.3/systemd/mdmonitor-oneshot.service
===================================================================
--- mdadm-4.3.orig/systemd/mdmonitor-oneshot.service
+++ mdadm-4.3/systemd/mdmonitor-oneshot.service
@@ -12,5 +12,5 @@ Documentation=man:mdadm(8)
[Service]
Environment=MDADM_MONITOR_ARGS=--scan
EnvironmentFile=-/run/sysconfig/mdadm
-ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
+ExecStartPre=-/usr/libexec/mdadm/mdadm_env.sh
ExecStart=BINDIR/mdadm --monitor --oneshot $MDADM_MONITOR_ARGS
Index: mdadm-4.3/systemd/mdmonitor.service
===================================================================
--- mdadm-4.3.orig/systemd/mdmonitor.service
+++ mdadm-4.3/systemd/mdmonitor.service
@@ -13,5 +13,5 @@ Documentation=man:mdadm(8)
[Service]
Environment= MDADM_MONITOR_ARGS=--scan
EnvironmentFile=-/run/sysconfig/mdadm
-ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
+ExecStartPre=-/usr/libexec/mdadm/mdadm_env.sh
ExecStart=BINDIR/mdadm --monitor $MDADM_MONITOR_ARGS

View File

@ -0,0 +1,58 @@
From 449c8b62164880ab132ad6eec86a8d53f793af69 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 19 Jul 2022 13:18:23 +0800
Subject: [PATCH 19/23] mdadm: enable Intel Alderlake RSTe configuration
Patch-mainline: N/A, SUSE only patch
References: bsc#1201297
Alderlake has a slightly different RST configuration; the UEFI
variable is name 'RstVmdV', and the AHCI controller shows up as
a child device of the VMD bridge, but continues to use the 'AHCI HBA'
PCI class (and not the RAID class as RSTe would normally do).
Signed-off-by: Hannes Reinecke <hare@suse.de>
Acked-by: Coly Li <colyli@suse.de>
---
platform-intel.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: mdadm-4.2/platform-intel.c
===================================================================
--- mdadm-4.2.orig/platform-intel.c
+++ mdadm-4.2/platform-intel.c
@@ -512,6 +512,7 @@ static const struct imsm_orom *find_imsm
#define AHCI_PROP "RstSataV"
#define AHCI_SSATA_PROP "RstsSatV"
#define AHCI_TSATA_PROP "RsttSatV"
+#define AHCI_RST_PROP "RstVmdV"
#define VROC_VMD_PROP "RstUefiV"
#define RST_VMD_PROP "RstVmdV"
@@ -519,6 +520,7 @@ static const struct imsm_orom *find_imsm
EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, 0x1a, 0x04, 0xc6)
#define PCI_CLASS_RAID_CNTRL 0x010400
+#define PCI_CLASS_SATA_HBA 0x010601
static int read_efi_var(void *buffer, ssize_t buf_size,
const char *variable_name, struct efi_guid guid)
@@ -605,7 +607,8 @@ const struct imsm_orom *find_imsm_efi(st
struct imsm_orom orom;
struct orom_entry *ret;
static const char * const sata_efivars[] = {AHCI_PROP, AHCI_SSATA_PROP,
- AHCI_TSATA_PROP};
+ AHCI_TSATA_PROP,
+ AHCI_RST_PROP};
static const char * const vmd_efivars[] = {VROC_VMD_PROP, RST_VMD_PROP};
unsigned long i;
@@ -624,7 +627,8 @@ const struct imsm_orom *find_imsm_efi(st
return NULL;
case SYS_DEV_SATA:
- if (hba->class != PCI_CLASS_RAID_CNTRL)
+ if (hba->class != PCI_CLASS_RAID_CNTRL &&
+ hba->class != PCI_CLASS_SATA_HBA)
return NULL;
for (i = 0; i < ARRAY_SIZE(sata_efivars); i++) {

BIN
Software-RAID.HOWTO.tar.bz2 (Stored with Git LFS) Normal file

Binary file not shown.

3
mdadm-4.3.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7ed64ea459e464420d3489d3f1875d3083f72e281ad4cd2f9c12a9ea44a5b606
size 467024

3227
mdadm.changes Normal file

File diff suppressed because it is too large Load Diff

147
mdadm.spec Normal file
View File

@ -0,0 +1,147 @@
#
# spec file for package mdadm
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
Name: mdadm
Version: 4.3
Release: 0
BuildRequires: binutils-devel
BuildRequires: groff
BuildRequires: pkgconfig
BuildRequires: sgmltool
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(udev)
PreReq: %fillup_prereq
PreReq: coreutils
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
Summary: Utility for configuring "MD" software RAID devices
License: GPL-2.0-only
Group: System/Base
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.xz
Source1: Software-RAID.HOWTO.tar.bz2
Source2: sysconfig.mdadm
Patch1: 0001-Remove-hardcoded-checkpoint-interval-checking.patch
Patch2: 0002-monitor-refactor-checkpoint-update.patch
Patch3: 0003-Super-intel-Fix-first-checkpoint-restart.patch
Patch4: 0004-Grow-Move-update_tail-assign-to-Grow_reshape.patch
Patch5: 0005-Add-understanding-output-section-in-man.patch
Patch6: 0006-util.c-change-devnm-to-const-in-mdmon-functions.patch
Patch7: 0007-Wait-for-mdmon-when-it-is-stared-via-systemd.patch
Patch8: 0008-Detail-remove-duplicated-code.patch
Patch9: 0009-mdadm-Fix-native-detail-export.patch
Patch1001: 1001-display-timeout-status.patch
Patch1002: 1002-OnCalendar-format-fix-of-mdcheck_start-timer.patch
Patch1003: 1003-mdadm-treat-the-Dell-softraid-array-as-local-array.patch
Patch1004: 1004-call-mdadm_env.sh-from-usr-libexec-mdadm.patch
Patch1005: 1005-mdadm-enable-Intel-Alderlake-RSTe-configuration.patch
%define _udevdir %(pkg-config --variable=udevdir udev)
%define _systemdshutdowndir %{_unitdir}/../system-shutdown
%description
mdadm is a program that can be used to control Linux md devices.
%prep
%autosetup -p1 -a1
%build
make %{?_smp_mflags} CC="%__cc" CXFLAGS="%{optflags} -Wno-error" EXTRAVERSION="%{release}" SUSE=yes BINDIR=%{_sbindir}
cd Software-RAID.HOWTO
sgml2html Software-RAID.HOWTO.sgml
sgml2txt Software-RAID.HOWTO.sgml
%install
%make_install install-systemd install-udev SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_udevdir} SUSE=yes BINDIR=%{_sbindir}
rm -rf %{buildroot}/lib/udev
install -d %{buildroot}%{_fillupdir}
install -d %{buildroot}/usr/share/mdadm
install -m 755 misc/mdcheck %{buildroot}/usr/share/mdadm/mdcheck
install -m 644 %{S:2} %{buildroot}%{_fillupdir}/
install -d %{buildroot}%{_systemdshutdowndir}
install -d %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcmdmonitor
%if 0%{?suse_version} < 1550
mkdir -p %{buildroot}/sbin
ln -s %{_sbindir}/mdadm %{buildroot}/sbin/mdadm
ln -s %{_sbindir}/mdmon %{buildroot}/sbin/mdmon
%endif
%define services mdmonitor.service mdcheck_start.service mdcheck_continue.service mdmonitor-oneshot.service
%pre
%service_add_pre %services
%post
%service_add_post %services
%{?regenerate_initrd_post}
%fillup_only
%preun
%service_del_preun %services
%postun
%service_del_postun %services
%{?regenerate_initrd_post}
%posttrans
%{?regenerate_initrd_posttrans}
%files
%defattr(-,root,root)
%license COPYING
%doc ChangeLog README.initramfs TODO mdadm.conf-example mkinitramfs
%doc Software-RAID.HOWTO/Software-RAID.HOWTO*{.txt,.html}
%doc %{_mandir}/man?/*
%{_sbindir}/*
%if 0%{?suse_version} < 1550
/sbin/mdadm
/sbin/mdmon
%endif
%dir /usr/share/mdadm
/usr/share/mdadm/*
%{_fillupdir}/sysconfig.mdadm
%{_udevdir}/rules.d/01-md-raid-creating.rules
%{_udevdir}/rules.d/63-md-raid-arrays.rules
%{_udevdir}/rules.d/64-md-raid-assembly.rules
%{_udevdir}/rules.d/69-md-clustered-confirm-device.rules
# %%{_systemdshutdowndir}/ is not owned by all versions of systemd-mini.
# But we really do not want to pull in a full systemd, so we rather just own
# that directory by ourselves too. After all, this is allowed.
%dir %{_systemdshutdowndir}
%{_systemdshutdowndir}/mdadm.shutdown
%{_unitdir}/mdmon@.service
%{_unitdir}/mdmonitor.service
%{_unitdir}/mdadm-last-resort@.timer
%{_unitdir}/mdadm-last-resort@.service
%{_unitdir}/mdadm-grow-continue@.service
%{_unitdir}/mdcheck_continue.service
%{_unitdir}/mdcheck_continue.timer
%{_unitdir}/mdcheck_start.service
%{_unitdir}/mdcheck_start.timer
%{_unitdir}/mdmonitor-oneshot.service
%{_unitdir}/mdmonitor-oneshot.timer
%dir %{_prefix}/libexec/
%dir %{_prefix}/libexec/mdadm
%{_prefix}/libexec/mdadm/mdadm_env.sh
%changelog

73
sysconfig.mdadm Normal file
View File

@ -0,0 +1,73 @@
## Path: System/File systems/Mdadm
## Description: Additional options for the mdadm daemon (see man mdadm(8)).
##
## Type: integer
## Default: 60
#
# A delay in seconds between polling the md arrays.
#
MDADM_DELAY=60
## Type: string
## Default: ""
#
# A mail address (or comma-separated list of mail addresses) to send alerts to.
#
MDADM_MAIL="root@localhost"
## Type: string
## Default: ""
#
# A program to be run whenever an event is detected.
#
MDADM_PROGRAM=""
## Type: string
## Default: ""
#
# Monitoring MD devices.
#
MDADM_RAIDDEVICES=""
## Type: yesno
## Default: yes
#
# "yes" for scanning config file or /proc/mdstat for missing information.
#
MDADM_SCAN=yes
## Type: string
## Default: "/etc/mdadm.conf"
#
# The config file.
#
MDADM_CONFIG="/etc/mdadm.conf"
## Type: yesno
## Default: no
#
# "yes" for email to be sent on start
#
MDADM_SEND_MAIL_ON_START=no
## Type: integer
## Default: 60
#
# Timeout for udev device detection. This is the upper limit which the
# boot script will wait for udev to finish hotplug event processing.
# If not all devices are detected during boot this value should be
# increased. Setting this to '0' disables waiting for udev.
#
MDADM_DEVICE_TIMEOUT="60"
## Type: string
## Default: 6 hours
#
# Amount of time to spend checking md arrays each morning.
# A check will start on the first Sunday of the month and run
# for this long. If it does not complete, then it will be
# continued each subsequent morning until all arrays have
# been checked. Any string understood by "date --date="
# can be used. An empty string disables automatic checks.
#
MDADM_CHECK_DURATION="6 hours"