You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.8 KiB
62 lines
1.8 KiB
From 344690313ae4e66f760b14afafda663ec750dfe0 Mon Sep 17 00:00:00 2001
|
|
From: Anna Sztukowska <anna.sztukowska@intel.com>
|
|
Date: Tue, 3 Sep 2024 13:01:04 +0200
|
|
Subject: [PATCH 188/201] Mdmonitor: Fix startup with missing directory
|
|
|
|
Commit 0a07dea8d3b78 ("Mdmonitor: Refactor check_one_sharer() for
|
|
better error handling") introduced an issue, if directory /run/mdadm
|
|
is missing, monitor fails to start. Move the directory creation
|
|
earlier to ensure it is always created.
|
|
|
|
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
|
|
---
|
|
Monitor.c | 14 +++++++-------
|
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/Monitor.c b/Monitor.c
|
|
index cf14fbb3..d260b0f1 100644
|
|
--- a/Monitor.c
|
|
+++ b/Monitor.c
|
|
@@ -225,6 +225,11 @@ int Monitor(struct mddev_dev *devlist,
|
|
return 1;
|
|
}
|
|
|
|
+ if (mkdir(MDMON_DIR, 0700) < 0 && errno != EEXIST) {
|
|
+ pr_err("Failed to create directory " MDMON_DIR ": %s\n", strerror(errno));
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
if (share){
|
|
if (check_one_sharer(c->scan) == 2)
|
|
return 1;
|
|
@@ -432,12 +437,12 @@ static int make_daemon(char *pidfile)
|
|
}
|
|
|
|
/*
|
|
- * check_one_sharer() - Checks for other mdmon processes running.
|
|
+ * check_one_sharer() - Checks for other mdmonitor processes running.
|
|
*
|
|
* Return:
|
|
* 0 - no other processes running,
|
|
* 1 - warning,
|
|
- * 2 - error, or when scan mode is enabled, and one mdmon process already exists
|
|
+ * 2 - error, or when scan mode is enabled, and one mdmonitor process already exists
|
|
*/
|
|
static int check_one_sharer(int scan)
|
|
{
|
|
@@ -513,11 +518,6 @@ static int write_autorebuild_pid(void)
|
|
FILE *fp;
|
|
int fd;
|
|
|
|
- if (mkdir(MDMON_DIR, 0700) < 0 && errno != EEXIST) {
|
|
- pr_err("%s: %s\n", strerror(errno), MDMON_DIR);
|
|
- return 1;
|
|
- }
|
|
-
|
|
if (!is_directory(MDMON_DIR)) {
|
|
pr_err("%s is not a regular directory.\n", MDMON_DIR);
|
|
return 1;
|
|
--
|
|
2.41.0
|
|
|