Accepting request 816923 from Base:System

OBS-URL: https://build.opensuse.org/request/show/816923
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mdadm?expand=0&rev=122
This commit is contained in:
Dominique Leuenberger 2020-06-26 19:45:28 +00:00 committed by Git OBS Bridge
commit 76ee963662
5 changed files with 247 additions and 0 deletions

View File

@ -0,0 +1,112 @@
From 185ec4397e61ad00dd68c841e15eaa8629eb9514 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Sat, 11 Apr 2020 00:24:46 +0800
Subject: [PATCH] Monitor: improve check_one_sharer() for checking duplicated
process
Git-commit: 185ec4397e61ad00dd68c841e15eaa8629eb9514
Patch-mainline: mdadm-4.1+
References: bsc#1168953
When running mdadm monitor with scan mode, only one autorebuild process
is allowed. check_one_sharer() checks duplicated process by following
steps,
1) Read autorebuild.pid file,
- if file does not exist, no duplicated process, go to 3).
- if file exists, continue to next step.
2) Read pid number from autorebuild.pid file, then check procfs pid
directory /proc/<PID>,
- if the directory does not exist, no duplicated process, go to 3)
- if the directory exists, print error message for duplicated process
and exit this mdadm.
3) Write current pid into autorebuild.pid file, continue to monitor in
scan mode.
The problem for the above step 2) is, if after system reboots and
another different process happens to have exact same pid number which
autorebuild.pid file records, check_one_sharer() will treat it as a
duplicated mdadm process and returns error with message "Only one
autorebuild process allowed in scan mode, aborting".
This patch tries to fix the above same-pid-but-different-process issue
by one more step to check the process command name,
1) Read autorebuild.pid file
- if file does not exist, no duplicated process, go to 4).
- if file exists, continue to next step.
2) Read pid number from autorebuild.pid file, then check procfs file
comm with the specific pid directory /proc/<PID>/comm
- if the file does not exit, it means the directory /proc/<PID> does
not exist, go to 4)
- if the file exits, continue next step
3) Read process command name from /proc/<PIC>/comm, compare the command
name with "mdadm" process name,
- if not equal, no duplicated process, goto 4)
- if strings are equal, print error message for duplicated process
and exit this mdadm.
4) Write current pid into autorebuild.pid file, continue to monitor in
scan mode.
Now check_one_sharer() returns error for duplicated process only when
the recorded pid from autorebuild.pid exists, and the process has exact
same command name as "mdadm".
Reported-by: Shinkichi Yamazaki <shinkichi.yamazaki@suse.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Monitor.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index b527165..2d6b3b9 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -301,26 +301,34 @@ static int make_daemon(char *pidfile)
static int check_one_sharer(int scan)
{
- int pid, rv;
+ int pid;
+ FILE *comm_fp;
FILE *fp;
- char dir[20];
+ char comm_path[100];
char path[100];
- struct stat buf;
+ char comm[20];
+
sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
fp = fopen(path, "r");
if (fp) {
if (fscanf(fp, "%d", &pid) != 1)
pid = -1;
- sprintf(dir, "/proc/%d", pid);
- rv = stat(dir, &buf);
- if (rv != -1) {
- if (scan) {
- pr_err("Only one autorebuild process allowed in scan mode, aborting\n");
- fclose(fp);
- return 1;
- } else {
- pr_err("Warning: One autorebuild process already running.\n");
+ snprintf(comm_path, sizeof(comm_path),
+ "/proc/%d/comm", pid);
+ comm_fp = fopen(comm_path, "r");
+ if (comm_fp) {
+ if (fscanf(comm_fp, "%s", comm) &&
+ strncmp(basename(comm), Name, strlen(Name)) == 0) {
+ if (scan) {
+ pr_err("Only one autorebuild process allowed in scan mode, aborting\n");
+ fclose(comm_fp);
+ fclose(fp);
+ return 1;
+ } else {
+ pr_err("Warning: One autorebuild process already running.\n");
+ }
}
+ fclose(comm_fp);
}
fclose(fp);
}
--
2.25.0

View File

@ -0,0 +1,88 @@
From 1c294b5d960abeeb9e0f188af294d019bc82b20e Mon Sep 17 00:00:00 2001
From: Lidong Zhong <lidong.zhong@suse.com>
Date: Tue, 14 Apr 2020 16:19:41 +0800
Subject: [PATCH] Detail: adding sync status for cluster device
Git-commit: 1c294b5d960abeeb9e0f188af294d019bc82b20e
Patch-mainline: mdadm-4.1+
References: bsc#1163727
On the node with /proc/mdstat is
Personalities : [raid1]
md0 : active raid1 sdb[4] sdc[3] sdd[2]
1046528 blocks super 1.2 [3/2] [UU_]
recover=REMOTE
bitmap: 1/1 pages [4KB], 65536KB chunk
Let's change the 'State' of 'mdadm -Q -D' accordingly
State : clean, degraded
With this patch, it will be
State : clean, degraded, recovering (REMOTE)
Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
Acked-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
---
Detail.c | 9 ++++++---
mdadm.h | 3 ++-
mdstat.c | 2 ++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Detail.c b/Detail.c
index daec4f1..24eeba0 100644
--- a/Detail.c
+++ b/Detail.c
@@ -498,17 +498,20 @@ int Detail(char *dev, struct context *c)
} else
arrayst = "active";
- printf(" State : %s%s%s%s%s%s \n",
+ printf(" State : %s%s%s%s%s%s%s \n",
arrayst, st,
(!e || (e->percent < 0 &&
e->percent != RESYNC_PENDING &&
- e->percent != RESYNC_DELAYED)) ?
+ e->percent != RESYNC_DELAYED &&
+ e->percent != RESYNC_REMOTE)) ?
"" : sync_action[e->resync],
larray_size ? "": ", Not Started",
(e && e->percent == RESYNC_DELAYED) ?
" (DELAYED)": "",
(e && e->percent == RESYNC_PENDING) ?
- " (PENDING)": "");
+ " (PENDING)": "",
+ (e && e->percent == RESYNC_REMOTE) ?
+ " (REMOTE)": "");
} else if (inactive && !is_container) {
printf(" State : inactive\n");
}
diff --git a/mdadm.h b/mdadm.h
index d94569f..399478b 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1815,7 +1815,8 @@ enum r0layout {
#define RESYNC_NONE -1
#define RESYNC_DELAYED -2
#define RESYNC_PENDING -3
-#define RESYNC_UNKNOWN -4
+#define RESYNC_REMOTE -4
+#define RESYNC_UNKNOWN -5
/* When using "GET_DISK_INFO" it isn't certain how high
* we need to check. So we impose an absolute limit of
diff --git a/mdstat.c b/mdstat.c
index 7e600d0..20577a3 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -257,6 +257,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
ent->percent = RESYNC_DELAYED;
if (l > 8 && strcmp(w+l-8, "=PENDING") == 0)
ent->percent = RESYNC_PENDING;
+ if (l > 7 && strcmp(w+l-7, "=REMOTE") == 0)
+ ent->percent = RESYNC_REMOTE;
} else if (ent->percent == RESYNC_NONE &&
w[0] >= '0' &&
w[0] <= '9' &&
--
2.25.0

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

@ -1,3 +1,19 @@
-------------------------------------------------------------------
Mon Jun 22 16:12:47 UTC 2020 - Coly Li <colyli@suse.com>
- OnCalendar format fix of mdcheck_start.timer (bsc#1173137)
1002-OnCalendar-format-fix-of-mdcheck_start-timer.patch
-------------------------------------------------------------------
Mon Jun 22 15:33:44 UTC 2020 - Coly Li <colyli@suse.com>
- Detail: adding sync status for cluster device
(bsc#1163727)
0072-Detail-adding-sync-status-for-cluster-device.patch
- Monitor: improve check_one_sharer() for checking duplicated process
(bsc#1168953)
0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch
-------------------------------------------------------------------
Fri Mar 27 03:52:47 UTC 2020 - Neil Brown <nfbrown@suse.com>

View File

@ -107,7 +107,10 @@ Patch62: 0067-mdadm.8-add-note-information-for-raid0-growing-opera.patch
Patch63: 0068-Remove-the-legacy-whitespace.patch
Patch64: 0069-imsm-pass-subarray-id-to-kill_subarray-function.patch
Patch65: 0070-imsm-Remove-dump-restore-implementation.patch
Patch66: 0071-Monitor-improve-check_one_sharer-for-checking-duplic.patch
Patch67: 0072-Detail-adding-sync-status-for-cluster-device.patch
Patch1001: 1001-display-timeout-status.patch
Patch1002: 1002-OnCalendar-format-fix-of-mdcheck_start-timer.patch
%define _udevdir %(pkg-config --variable=udevdir udev)
%define _systemdshutdowndir %{_unitdir}/../system-shutdown
@ -182,7 +185,10 @@ mdadm is a program that can be used to control Linux md devices.
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch1001 -p1
%patch1002 -p1
%build
make %{?_smp_mflags} CC="%__cc" CXFLAGS="%{optflags} -Wno-error" SUSE=yes