Auto sync2gitlab import of mdadm-4.2-2.el8.src.rpm
This commit is contained in:
parent
ede7355496
commit
cdaed002d2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/mdadm-4.2.tar.xz
|
38
0001-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch
Normal file
38
0001-Revert-mdadm-fix-coredump-of-mdadm-monitor-r.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From 7e92ef334af165a5e50b33ddff98e18f1c8a18d0 Mon Sep 17 00:00:00 2001
|
||||
From: Xiao Ni <xni@redhat.com>
|
||||
Date: Thu, 24 Feb 2022 11:37:34 +0800
|
||||
Subject: [PATCH 1/1] Revert "mdadm: fix coredump of mdadm --monitor -r"
|
||||
|
||||
This reverts commit 546047688e1c64638f462147c755b58119cabdc8.
|
||||
|
||||
This is a rhel ony patch. We have sent patch to upstream. But
|
||||
it hasn't been merged. We will remove this patch once upstream
|
||||
merges our patch.
|
||||
|
||||
Signed-off-by: Xiao Ni <xni@redhat.com>
|
||||
---
|
||||
ReadMe.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/ReadMe.c b/ReadMe.c
|
||||
index 81399765..ee457a54 100644
|
||||
--- a/ReadMe.c
|
||||
+++ b/ReadMe.c
|
||||
@@ -81,11 +81,11 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n";
|
||||
* found, it is started.
|
||||
*/
|
||||
|
||||
-char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k";
|
||||
+char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||
char short_bitmap_options[]=
|
||||
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:";
|
||||
char short_bitmap_auto_options[]=
|
||||
- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:";
|
||||
+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:";
|
||||
|
||||
struct option long_options[] = {
|
||||
{"manage", 0, 0, ManageOpt},
|
||||
--
|
||||
2.31.1
|
||||
|
11
disable-Werror.patch
Normal file
11
disable-Werror.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- mdadm/Makefile.orig 2021-07-28 21:39:23.887433859 +0800
|
||||
+++ mdadm/Makefile 2021-07-28 21:39:37.989432841 +0800
|
||||
@@ -50,7 +50,7 @@
|
||||
CC := $(CROSS_COMPILE)gcc
|
||||
endif
|
||||
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
|
23
mdadm-2.5.2-static.patch
Normal file
23
mdadm-2.5.2-static.patch
Normal file
@ -0,0 +1,23 @@
|
||||
--- 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
|
||||
|
||||
install-static : mdadm.static install-man
|
||||
- $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
|
||||
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm.static
|
||||
|
||||
install-tcc : mdadm.tcc install-man
|
||||
- $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
|
||||
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm.tcc
|
||||
|
||||
install-uclibc : mdadm.uclibc install-man
|
||||
- $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
|
||||
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm.uclibc
|
||||
|
||||
install-klibc : mdadm.klibc install-man
|
||||
- $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
|
||||
+ $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm.klibc
|
||||
|
||||
install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
|
||||
$(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
|
13
mdadm-3.3-udev.patch
Normal file
13
mdadm-3.3-udev.patch
Normal file
@ -0,0 +1,13 @@
|
||||
--- mdadm-4.1_rc1/udev-md-raid-assembly.rules~ 2018-06-22 13:10:58.196250086 +0800
|
||||
+++ mdadm-4.1_rc1/udev-md-raid-assembly.rules 2018-06-22 13:11:37.761241080 +0800
|
||||
@@ -5,6 +5,10 @@
|
||||
ENV{ANACONDA}=="?*", GOTO="md_inc_end"
|
||||
# assemble md arrays
|
||||
|
||||
+# In Fedora we handle the raid components in 65-md-incremental.rules so that
|
||||
+# we can do things like honor anaconda command line options and such
|
||||
+GOTO="md_inc_end"
|
||||
+
|
||||
SUBSYSTEM!="block", GOTO="md_inc_end"
|
||||
|
||||
# skip non-initialized devices
|
3
mdadm-cron
Normal file
3
mdadm-cron
Normal 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
|
||||
|
60
mdadm-raid-check-sysconfig
Normal file
60
mdadm-raid-check-sysconfig
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Configuration file for /etc/cron.weekly/raid-check
|
||||
#
|
||||
# options:
|
||||
# ENABLED - must be yes in order for the raid check to proceed
|
||||
# CHECK - can be either check or repair depending on the type of
|
||||
# operation the user desires. A check operation will scan
|
||||
# the drives looking for bad sectors and automatically
|
||||
# repairing only bad sectors. If it finds good sectors that
|
||||
# contain bad data (meaning that the data in a sector does
|
||||
# not agree with what the data from another disk indicates
|
||||
# the data should be, for example the parity block + the other
|
||||
# data blocks would cause us to think that this data block
|
||||
# is incorrect), then it does nothing but increments the
|
||||
# counter in the file /sys/block/$dev/md/mismatch_count.
|
||||
# This allows the sysadmin to inspect the data in the sector
|
||||
# and the data that would be produced by rebuilding the
|
||||
# sector from redundant information and pick the correct
|
||||
# data to keep. The repair option does the same thing, but
|
||||
# when it encounters a mismatch in the data, it automatically
|
||||
# updates the data to be consistent. However, since we really
|
||||
# don't know whether it's the parity or the data block that's
|
||||
# correct (or which data block in the case of raid1), it's
|
||||
# luck of the draw whether or not the user gets the right
|
||||
# data instead of the bad data. This option is the default
|
||||
# option for devices not listed in either CHECK_DEVS or
|
||||
# REPAIR_DEVS.
|
||||
# CHECK_DEVS - a space delimited list of devs that the user specifically
|
||||
# wants to run a check operation on.
|
||||
# REPAIR_DEVS - a space delimited list of devs that the user
|
||||
# specifically wants to run a repair on.
|
||||
# SKIP_DEVS - a space delimited list of devs that should be skipped
|
||||
# NICE - Change the raid check CPU and IO priority in order to make
|
||||
# the system more responsive during lengthy checks. Valid
|
||||
# values are high, normal, low, idle.
|
||||
# MAXCONCURENT - Limit the number of devices to be checked at a time.
|
||||
# By default all devices will be checked at the same time.
|
||||
#
|
||||
# Note: the raid-check script intentionaly runs last in the cron.weekly
|
||||
# sequence. This is so we can wait for all the resync operations to complete
|
||||
# and then check the mismatch_count on each array without unduly delaying
|
||||
# other weekly cron jobs. If any arrays have a non-0 mismatch_count after
|
||||
# the check completes, we echo a warning to stdout which will then me emailed
|
||||
# to the admin as long as mails from cron jobs have not been redirected to
|
||||
# /dev/null. We do not wait for repair operations to complete as the
|
||||
# md stack will correct any mismatch_cnts automatically.
|
||||
#
|
||||
# Note2: you can not use symbolic names for the raid devices, such as you
|
||||
# /dev/md/root. The names used in this file must match the names seen in
|
||||
# /proc/mdstat and in /sys/block.
|
||||
|
||||
ENABLED=yes
|
||||
CHECK=check
|
||||
NICE=low
|
||||
# To check devs /dev/md0 and /dev/md3, use "md0 md3"
|
||||
CHECK_DEVS=""
|
||||
REPAIR_DEVS=""
|
||||
SKIP_DEVS=""
|
||||
MAXCONCURRENT=
|
1
mdadm.conf
Normal file
1
mdadm.conf
Normal file
@ -0,0 +1 @@
|
||||
d /run/mdadm 0710 root root -
|
69
mdadm.rules
Normal file
69
mdadm.rules
Normal file
@ -0,0 +1,69 @@
|
||||
# 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}=="1", 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 $env{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=="add", ENV{ID_FS_TYPE}=="ddf_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"
|
1154
mdadm.spec
Normal file
1154
mdadm.spec
Normal file
File diff suppressed because it is too large
Load Diff
48
mdadm_env.sh
Normal file
48
mdadm_env.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
# extract configuration from /etc/sysconfig/mdadm and write
|
||||
# environment to /run/sysconfig/mdadm to be used by
|
||||
# systemd unit files.
|
||||
|
||||
MDADM_SCAN="yes"
|
||||
|
||||
# Following adapted from /etc/init.d/mdadmd on openSUSE
|
||||
|
||||
mdadmd_CONFIG=/etc/sysconfig/mdadm
|
||||
if test -r $mdadmd_CONFIG; then
|
||||
. $mdadmd_CONFIG
|
||||
fi
|
||||
|
||||
if [ x$MDADM_DELAY != x"" ]; then
|
||||
MDADM_DELAY="-d "$MDADM_DELAY;
|
||||
fi
|
||||
|
||||
if [ x$MDADM_MAIL != x"" ]; then
|
||||
MDADM_MAIL="-m \"$MDADM_MAIL\""
|
||||
fi
|
||||
|
||||
if [ x$MDADM_PROGRAM != x"" ]; then
|
||||
MDADM_PROGRAM="-p \"$MDADM_PROGRAM\""
|
||||
fi
|
||||
|
||||
if [ x$MDADM_SCAN = x"yes" ]; then
|
||||
MDADM_SCAN="--scan"
|
||||
else
|
||||
MDADM_SCAN=""
|
||||
fi
|
||||
|
||||
if [ x$MDADM_SEND_MAIL_ON_START = x"yes" ]; then
|
||||
MDADM_SEND_MAIL="-t"
|
||||
else
|
||||
MDADM_SEND_MAIL=""
|
||||
fi
|
||||
|
||||
if [ x$MDADM_CONFIG != x"" ]; then
|
||||
MDADM_CONFIG="-c \"$MDADM_CONFIG\""
|
||||
fi
|
||||
|
||||
mkdir -p /run/sysconfig
|
||||
echo "MDADM_MONITOR_ARGS=$MDADM_RAIDDEVICES $MDADM_DELAY $MDADM_MAIL $MDADM_PROGRAM $MDADM_SCAN $MDADM_SEND_MAIL $MDADM_CONFIG" > /run/sysconfig/mdadm
|
||||
if [ -n "$MDADM_CHECK_DURATION" ]; then
|
||||
echo "MDADM_CHECK_DURATION=$MDADM_CHECK_DURATION" >> /run/sysconfig/mdadm
|
||||
fi
|
5
mdadm_event.conf
Normal file
5
mdadm_event.conf
Normal file
@ -0,0 +1,5 @@
|
||||
# Save /proc/mdstat in case of crash in mdadm/mdmon
|
||||
|
||||
EVENT=post-create component=mdadm
|
||||
cat /proc/mdstat >> mdstat_data
|
||||
echo "Saved output of /proc/mdstat"
|
164
mdcheck
Normal file
164
mdcheck
Normal file
@ -0,0 +1,164 @@
|
||||
#!/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
|
||||
|
||||
if [ -z "$fl" ]; then continue; fi
|
||||
|
||||
if [ "`cat $sys/md/sync_action`" != 'check' ]
|
||||
then
|
||||
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
118
mdmonitor.init
Executable 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
|
12
mdmonitor.service
Normal file
12
mdmonitor.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Software RAID monitoring and management
|
||||
ConditionPathExists=/etc/mdadm.conf
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/var/run/mdadm/mdadm.pid
|
||||
EnvironmentFile=-/etc/sysconfig/mdmonitor
|
||||
ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/var/run/mdadm/mdadm.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
135
raid-check
Normal file
135
raid-check
Normal file
@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script reads it's configuration from /etc/sysconfig/raid-check
|
||||
# Please use that file to enable/disable this script or to set the
|
||||
# type of check you wish performed.
|
||||
|
||||
# We might be on a kernel with no raid support at all, exit if so
|
||||
[ -f /proc/mdstat ] || exit 0
|
||||
|
||||
# and exit if we haven't been set up properly
|
||||
[ -f /etc/sysconfig/raid-check ] || exit 0
|
||||
. /etc/sysconfig/raid-check
|
||||
|
||||
# Wait until no more than arg1 arrays in arg2 list are busy
|
||||
waitbusy() {
|
||||
local threshold=$(($1 + 1))
|
||||
local dev_list="$2"
|
||||
while true
|
||||
do
|
||||
local busy=0
|
||||
local dev=""
|
||||
for dev in $dev_list; do
|
||||
local sync_action=`cat /sys/block/$dev/md/sync_action`
|
||||
if [ "$sync_action" != "idle" ]; then
|
||||
let busy++
|
||||
fi
|
||||
done
|
||||
[ $busy -lt $threshold ] && break
|
||||
sleep 60
|
||||
done
|
||||
}
|
||||
|
||||
[ "$ENABLED" != "yes" ] && exit 0
|
||||
|
||||
case "$CHECK" in
|
||||
check) ;;
|
||||
repair) ;;
|
||||
*) exit 0;;
|
||||
esac
|
||||
|
||||
ionice=""
|
||||
renice=""
|
||||
case $NICE in
|
||||
high)
|
||||
renice="-n -5"
|
||||
;;
|
||||
low)
|
||||
renice="-n 5"
|
||||
ionice="-c2 -n7"
|
||||
;;
|
||||
idle)
|
||||
renice="-n 15"
|
||||
ionice="-c3"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
active_list=`grep "^md.*: active" /proc/mdstat | cut -f 1 -d ' '`
|
||||
[ -z "$active_list" ] && exit 0
|
||||
|
||||
declare -A check
|
||||
dev_list=""
|
||||
check_list=""
|
||||
for dev in $active_list; do
|
||||
echo $SKIP_DEVS | grep -w $dev >&/dev/null && continue
|
||||
if [ -f /sys/block/$dev/md/sync_action ]; then
|
||||
# Only perform the checks on idle, healthy arrays, but delay
|
||||
# actually writing the check field until the next loop so we
|
||||
# don't switch currently idle arrays to active, which happens
|
||||
# when two or more arrays are on the same physical disk
|
||||
array_state=`cat /sys/block/$dev/md/array_state`
|
||||
if [ "$array_state" != "clean" -a "$array_state" != "active" ]; then
|
||||
continue
|
||||
fi
|
||||
sync_action=`cat /sys/block/$dev/md/sync_action`
|
||||
if [ "$sync_action" != idle ]; then
|
||||
continue
|
||||
fi
|
||||
ck=""
|
||||
echo $REPAIR_DEVS | grep -w $dev >&/dev/null && ck="repair"
|
||||
echo $CHECK_DEVS | grep -w $dev >&/dev/null && ck="check"
|
||||
[ -z "$ck" ] && ck=$CHECK
|
||||
dev_list="$dev_list $dev"
|
||||
check[$dev]=$ck
|
||||
[ "$ck" = "check" ] && check_list="$check_list $dev"
|
||||
fi
|
||||
done
|
||||
[ -z "$dev_list" ] && exit 0
|
||||
|
||||
for dev in $dev_list; do
|
||||
#Only run $MAXCONCURRENT checks at a time
|
||||
if [ -n "$MAXCONCURRENT" ]; then
|
||||
waitbusy $((MAXCONCURRENT - 1)) "$dev_list"
|
||||
fi
|
||||
echo "${check[$dev]}" > /sys/block/$dev/md/sync_action
|
||||
|
||||
resync_pid=""
|
||||
wait=10
|
||||
while [ $wait -gt 0 -a -z "$resync_pid" ]; do
|
||||
sleep 6
|
||||
let wait--
|
||||
resync_pid=$(ps -ef | awk -v mddev=$dev 'BEGIN { pattern = "^\\[" mddev "_resync]$" } $8 ~ pattern { print $2 }')
|
||||
done
|
||||
[ -n "$resync_pid" -a -n "$renice" ] &&
|
||||
renice $renice -p $resync_pid >&/dev/null
|
||||
[ -n "$resync_pid" -a -n "$ionice" ] &&
|
||||
ionice $ionice -p $resync_pid >&/dev/null
|
||||
done
|
||||
[ -z "$check_list" ] && exit 0
|
||||
|
||||
waitbusy 0 "$check_list"
|
||||
|
||||
for dev in $check_list; do
|
||||
mismatch_cnt=`cat /sys/block/$dev/md/mismatch_cnt`
|
||||
# Due to the fact that raid1/10 writes in the kernel are unbuffered,
|
||||
# a raid1 array can have non-0 mismatch counts even when the
|
||||
# array is healthy. These non-0 counts will only exist in
|
||||
# transient data areas where they don't pose a problem. However,
|
||||
# since we can't tell the difference between a non-0 count that
|
||||
# is just in transient data or a non-0 count that signifies a
|
||||
# real problem, simply don't check the mismatch_cnt on raid1
|
||||
# devices as it's providing far too many false positives. But by
|
||||
# leaving the raid1 device in the check list and performing the
|
||||
# check, we still catch and correct any bad sectors there might
|
||||
# be in the device.
|
||||
raid_lvl=`cat /sys/block/$dev/md/level`
|
||||
if [ "$raid_lvl" = "raid1" -o "$raid_lvl" = "raid10" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$mismatch_cnt" -ne 0 ]; then
|
||||
echo "WARNING: mismatch_cnt is not 0 on /dev/$dev"
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user