- Improved raid-check script as well as the ability to configure what
devices get checked - Endian patch for uuid generation
This commit is contained in:
parent
d395ee1418
commit
bb4afe8c1c
15
mdadm-3.0-endian-FAIL.patch
Normal file
15
mdadm-3.0-endian-FAIL.patch
Normal file
@ -0,0 +1,15 @@
|
||||
diff -up mdadm-3.0-devel3/util.c.foo mdadm-3.0-devel3/util.c
|
||||
--- mdadm-3.0-devel3/util.c.foo 2009-07-09 18:57:47.000000000 -0400
|
||||
+++ mdadm-3.0-devel3/util.c 2009-07-09 18:58:09.000000000 -0400
|
||||
@@ -282,7 +282,11 @@ char *fname_from_uuid(struct supertype *
|
||||
char *c = buf;
|
||||
strcpy(c, "UUID-");
|
||||
c += strlen(c);
|
||||
+#if __BYTE_ORDER == BIG_ENDIAN
|
||||
+ copy_uuid(uuid, info->uuid, st->ss->swapuuid || !strcmp(st->ss->name,"0.90"));
|
||||
+#else
|
||||
copy_uuid(uuid, info->uuid, st->ss->swapuuid);
|
||||
+#endif
|
||||
for (i = 0; i < 4; i++) {
|
||||
id = uuid[i];
|
||||
if (i)
|
53
mdadm-raid-check-sysconfig
Normal file
53
mdadm-raid-check-sysconfig
Normal file
@ -0,0 +1,53 @@
|
||||
#!/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
|
||||
#
|
||||
# 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
|
||||
# To check devs /dev/md0 and /dev/md3, use "md0 md3"
|
||||
CHECK_DEVS=""
|
||||
REPAIR_DEVS=""
|
||||
SKIP_DEVS=""
|
28
mdadm.spec
28
mdadm.spec
@ -1,12 +1,14 @@
|
||||
Summary: The mdadm program controls Linux md devices (software RAID arrays)
|
||||
Name: mdadm
|
||||
Version: 3.0
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.bz2
|
||||
Source1: mdmonitor.init
|
||||
Source2: raid-check
|
||||
Source3: mdadm.rules
|
||||
Source4: mdadm-raid-check-sysconfig
|
||||
Patch1: mdadm-2.5.2-static.patch
|
||||
Patch2: mdadm-3.0-endian-FAIL.patch
|
||||
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
|
||||
License: GPLv2+
|
||||
Group: System Environment/Base
|
||||
@ -28,21 +30,23 @@ file can be used to help with some common tasks.
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p1 -b .static
|
||||
%patch2 -p1 -b .endian
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" SYSCONFDIR="%{_sysconfdir}" mdadm.static mdadm mdmon
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} BINDIR=/sbin install install-static
|
||||
rm -f $RPM_BUILD_ROOT/lib/udev/rules.d/*
|
||||
install -Dp -m 755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/mdmonitor
|
||||
install -Dp -m 755 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/cron.weekly/raid-check
|
||||
install -Dp -m 644 %{SOURCE3} $RPM_BUILD_ROOT/lib/udev/rules.d/65-md-incremental.rules
|
||||
mkdir -p -m 700 $RPM_BUILD_ROOT/var/run/mdadm
|
||||
rm -rf %{buildroot}
|
||||
make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=/sbin install install-static
|
||||
rm -f %{buildroot}/lib/udev/rules.d/*
|
||||
install -Dp -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/mdmonitor
|
||||
install -Dp -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/cron.weekly/99-raid-check
|
||||
install -Dp -m 644 %{SOURCE3} %{buildroot}/lib/udev/rules.d/65-md-incremental.rules
|
||||
install -Dp -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
|
||||
mkdir -p -m 700 %{buildroot}/var/run/mdadm
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%post
|
||||
if [ "$1" = 1 ]; then
|
||||
@ -68,9 +72,15 @@ fi
|
||||
%{_initrddir}/*
|
||||
%{_mandir}/man*/md*
|
||||
%{_sysconfdir}/cron.weekly/*
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/*
|
||||
%attr(0700,root,root) %dir /var/run/mdadm
|
||||
|
||||
%changelog
|
||||
* Fri Jul 24 2009 Doug Ledford <dledford@redhat.com> - 3.0-2
|
||||
- Improved raid-check script as well as the ability to configure what devices
|
||||
get checked
|
||||
- Endian patch for uuid generation
|
||||
|
||||
* Mon Jun 29 2009 Doug Ledford <dledford@redhat.com> - 3.0-1
|
||||
- Remove stale patches already accepted by upstream
|
||||
- Fix the raid-check script to only try and check a device if it is
|
||||
|
55
raid-check
55
raid-check
@ -1,7 +1,58 @@
|
||||
#!/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.
|
||||
|
||||
[ -f /etc/sysconfig/raid-check ] || exit 0
|
||||
. /etc/sysconfig/raid-check
|
||||
|
||||
[ "$ENABLED" != "yes" ] && exit 0
|
||||
|
||||
case "$CHECK" in
|
||||
check) ;;
|
||||
repair) ;;
|
||||
*) exit 0;;
|
||||
esac
|
||||
|
||||
dev_list=""
|
||||
for dev in `grep "^md.*: active" /proc/mdstat | cut -f 1 -d ' '`; do
|
||||
[ -f /sys/block/$dev/md/sync_action ] && \
|
||||
echo "check" > /sys/block/$dev/md/sync_action
|
||||
echo $SKIP_DEVS | grep -w $dev >/dev/null 2>&1 && continue
|
||||
if [ -f /sys/block/$dev/md/sync_action ]; then
|
||||
array_state=`cat /sys/block/$dev/md/array_state`
|
||||
sync_action=`cat /sys/block/$dev/md/sync_action`
|
||||
# Only perform the checks on idle, healthy arrays
|
||||
if [ "$array_state" = "clean" -a "$sync_action" = "idle" ]; then
|
||||
check=""
|
||||
echo $REPAIR_DEVS | grep -w $dev >/dev/null 2>&1 && \
|
||||
check="repair"
|
||||
echo $CHECK_DEVS | grep -w $dev >/dev/null 2>&1 \
|
||||
&& check="check"
|
||||
[ -z "$check" ] && check=$CHECK
|
||||
echo "$check" > /sys/block/$dev/md/sync_action
|
||||
[ "$check" = "check" ] && dev_list="$dev_list $dev"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$dev_list" ]; then
|
||||
checking=1
|
||||
while [ $checking -ne 0 ]
|
||||
do
|
||||
sleep 3
|
||||
checking=0
|
||||
for dev in $dev_list; do
|
||||
sync_action=`cat /sys/block/$dev/md/sync_action`
|
||||
if [ "$sync_action" != "idle" ]; then
|
||||
checking=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
for dev in $dev_list; do
|
||||
mismatch_cnt=`cat /sys/block/$dev/md/mismatch_cnt`
|
||||
if [ "$mismatch_cnt" -ne 0 ]; then
|
||||
echo "WARNING: mismatch_cnt is not 0 on /dev/$dev"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user