5563a724f6
- There are some important fixes merged in mdadm upstream which should go with jsc#SLE-13700. This is the update from upstream mdadm including the important fixes we should have. - Detail: show correct raid level when the array is inactive (jsc#SLE-13700) 0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch - Don't create bitmap for raid5 with journal disk (jsc#SLE-13700) 0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch - Monitor: refresh mdstat fd after select (jsc#SLE-13700) 0097-Monitor-refresh-mdstat-fd-after-select.patch - Monitor: stop notifing about containers. (jsc#SLE-13700) 0098-Monitor-stop-notifing-about-containers.patch - mdmonitor: set small delay once (jsc#SLE-13700) 0099-mdmonitor-set-small-delay-once.patch - Check if other Monitor instance running before fork. (jsc#SLE-13700) 0100-Check-if-other-Monitor-instance-running-before-fork.patch - Super1: allow RAID0 layout setting to be removed. (jsc#SLE-13700) 0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch - Detail: fix segfault during IMSM raid creation (jsc#SLE-13700) 0102-Detail-fix-segfault-during-IMSM-raid-creation.patch - Create.c: close mdfd and generate uevent (jsc#SLE-13700) 0103-Create.c-close-mdfd-and-generate-uevent.patch - imsm: update num_data_stripes according to dev_size (jsc#SLE-13700) 0104-imsm-update-num_data_stripes-according-to-dev_size.patch - imsm: remove redundant calls to imsm_get_map (jsc#SLE-13700) OBS-URL: https://build.opensuse.org/request/show/853269 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=191
104 lines
2.6 KiB
Diff
104 lines
2.6 KiB
Diff
From 7f3b2d1d1621cbdc60b5af4a41445391010fe9e1 Mon Sep 17 00:00:00 2001
|
|
From: Blazej Kucman <blazej.kucman@intel.com>
|
|
Date: Wed, 9 Sep 2020 10:31:20 +0200
|
|
Subject: [PATCH 06/17] Check if other Monitor instance running before fork.
|
|
|
|
Make error message visible to the user.
|
|
|
|
Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
|
|
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
|
|
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
---
|
|
Monitor.c | 44 ++++++++++++++++++++++++++++----------------
|
|
1 file changed, 28 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/Monitor.c b/Monitor.c
|
|
index 0fb4f77..7fd4808 100644
|
|
--- a/Monitor.c
|
|
+++ b/Monitor.c
|
|
@@ -63,6 +63,7 @@ struct alert_info {
|
|
};
|
|
static int make_daemon(char *pidfile);
|
|
static int check_one_sharer(int scan);
|
|
+static void write_autorebuild_pid(void);
|
|
static void alert(char *event, char *dev, char *disc, struct alert_info *info);
|
|
static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
int test, struct alert_info *info,
|
|
@@ -153,6 +154,11 @@ int Monitor(struct mddev_dev *devlist,
|
|
info.mailfrom = mailfrom;
|
|
info.dosyslog = dosyslog;
|
|
|
|
+ if (share){
|
|
+ if (check_one_sharer(c->scan))
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
if (daemonise) {
|
|
int rv = make_daemon(pidfile);
|
|
if (rv >= 0)
|
|
@@ -160,8 +166,7 @@ int Monitor(struct mddev_dev *devlist,
|
|
}
|
|
|
|
if (share)
|
|
- if (check_one_sharer(c->scan))
|
|
- return 1;
|
|
+ write_autorebuild_pid();
|
|
|
|
if (devlist == NULL) {
|
|
mdlist = conf_get_ident(NULL);
|
|
@@ -328,8 +333,8 @@ static int check_one_sharer(int scan)
|
|
int pid;
|
|
FILE *comm_fp;
|
|
FILE *fp;
|
|
- char comm_path[100];
|
|
- char path[100];
|
|
+ char comm_path[PATH_MAX];
|
|
+ char path[PATH_MAX];
|
|
char comm[20];
|
|
|
|
sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
|
|
@@ -356,21 +361,28 @@ static int check_one_sharer(int scan)
|
|
}
|
|
fclose(fp);
|
|
}
|
|
- if (scan) {
|
|
- if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) {
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static void write_autorebuild_pid()
|
|
+{
|
|
+ char path[PATH_MAX];
|
|
+ int pid;
|
|
+ FILE *fp;
|
|
+ sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
|
|
+
|
|
+ if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) {
|
|
+ pr_err("Can't create autorebuild.pid file\n");
|
|
+ } else {
|
|
+ fp = fopen(path, "w");
|
|
+ if (!fp)
|
|
pr_err("Can't create autorebuild.pid file\n");
|
|
- } else {
|
|
- fp = fopen(path, "w");
|
|
- if (!fp)
|
|
- pr_err("Cannot create autorebuild.pidfile\n");
|
|
- else {
|
|
- pid = getpid();
|
|
- fprintf(fp, "%d\n", pid);
|
|
- fclose(fp);
|
|
- }
|
|
+ else {
|
|
+ pid = getpid();
|
|
+ fprintf(fp, "%d\n", pid);
|
|
+ fclose(fp);
|
|
}
|
|
}
|
|
- return 0;
|
|
}
|
|
|
|
static void alert(char *event, char *dev, char *disc, struct alert_info *info)
|
|
--
|
|
2.26.2
|
|
|