dmraid.spec
Łukasz
qra at sidzina.homelinux.net
Sun Apr 18 22:42:22 CEST 2010
dmraid nie obsługuje za bardzo fakeraidu intela na Intel Matrix storage
#dmraid
-r
ERROR: isw: Could not find disk /dev/sda in the metadata
ERROR: isw: Could not find disk /dev/sdb in the metadata
no raid disks
w załączeniu patche na to plus poprawki do dmraid-initramfs, żeby
initramfs wogóle zaczął działać z dmraidem czyli plik dmraid-activate,
którego wogóle nie było (wydłubałem z jakiegoś debiana) i drobne szlify
w dmraid-initramfs-hook
Używam tego i wygląda, że działa bez problemu
# dmraid
-r
/dev/sda: isw, "isw_dbeiaajihb", GROUP, ok, 488397166 sectors, data@ 0
/dev/sdb: isw, "isw_dbeiaajihb", GROUP, ok, 488397166 sectors, data@ 0
Pozdrawiam
Łukasz
-------------- next part --------------
diff -up 1.0.0.rc15/lib/format/ataraid/isw.c~ 1.0.0.rc15/lib/format/ataraid/isw.c
--- 1.0.0.rc15/lib/format/ataraid/isw.c~ 2008-09-17 08:58:52.000000000 -0400
+++ 1.0.0.rc15/lib/format/ataraid/isw.c 2009-02-05 07:04:35.576126020 -0500
@@ -155,7 +155,7 @@ name(struct lib_context *lc, struct raid
while (i--) {
if (disk == isw->disk + i) {
- id = i % 2;
+ id = i / 2;
goto ok;
}
}
-------------- next part --------------
diff -up 1.0.0.rc15/lib/format/ataraid/isw.c~ 1.0.0.rc15/lib/format/ataraid/isw.c
--- 1.0.0.rc15/lib/format/ataraid/isw.c~ 2009-04-10 14:12:14.000000000 +0200
+++ 1.0.0.rc15/lib/format/ataraid/isw.c 2009-04-10 14:38:56.000000000 +0200
@@ -81,15 +81,43 @@ is_raid10(struct isw_dev *dev)
}
/* Find a disk table slot by serial number. */
+static const char *dev_info_serial_to_isw(const char *di_serial)
+{
+ static char isw_serial[1024];
+
+ int i, isw_serial_len = 0;
+
+ for (i = 0; di_serial[i] && isw_serial_len < 1023; i++) {
+ if (((unsigned char)di_serial[i]) > 0x20) {
+ /* ':' is reserved for use in placeholder serial
+ * numbers for missing disks */
+ if (di_serial[i] == ':')
+ isw_serial[isw_serial_len] = ';';
+ else
+ isw_serial[isw_serial_len] = di_serial[i];
+ isw_serial_len++;
+ }
+ }
+ isw_serial[isw_serial_len] = 0;
+
+ if (isw_serial_len > MAX_RAID_SERIAL_LEN)
+ memmove(isw_serial,
+ isw_serial + (isw_serial_len - MAX_RAID_SERIAL_LEN),
+ MAX_RAID_SERIAL_LEN);
+
+ return isw_serial;
+}
+
static struct isw_disk *
_get_disk(struct isw *isw, struct dev_info *di)
{
if (di->serial) {
int i = isw->num_disks;
struct isw_disk *disk = isw->disk;
+ const char *isw_serial = dev_info_serial_to_isw(di->serial);
while (i--) {
- if (!strncmp(di->serial, (const char *) disk[i].serial,
+ if (!strncmp(isw_serial, (const char *) disk[i].serial,
MAX_RAID_SERIAL_LEN))
return disk + i;
}
@@ -866,7 +894,8 @@ rd_by_serial(struct raid_set *rs, const
list_for_each_entry(rd, &rs->devs, devs) {
if (rd->di &&
- !strncmp(rd->di->serial, serial, MAX_RAID_SERIAL_LEN))
+ !strncmp(dev_info_serial_to_isw(rd->di->serial), serial,
+ MAX_RAID_SERIAL_LEN))
return rd;
}
@@ -1297,7 +1326,8 @@ isw_config_disks(struct lib_context *lc,
struct raid_dev *rd;
list_for_each_entry(rd, &rs->devs, devs) {
- strncpy((char *) disk[i].serial, rd->di->serial,
+ strncpy((char *) disk[i].serial,
+ dev_info_serial_to_isw(rd->di->serial),
MAX_RAID_SERIAL_LEN);
disk[i].totalBlocks = rd->di->sectors;
@@ -2421,7 +2451,8 @@ update_metadata(struct lib_context *lc,
while (i--) {
/* Check if the disk is listed. */
list_for_each_entry(di, LC_DI(lc), list) {
- if (!strncmp(di->serial, (const char *) disk[i].serial,
+ if (!strncmp(dev_info_serial_to_isw(di->serial),
+ (const char *) disk[i].serial,
MAX_RAID_SERIAL_LEN))
goto goon;
}
@@ -2517,7 +2548,8 @@ update_metadata(struct lib_context *lc,
new_disk->status = CONFIG_ON_DISK |
DISK_SMART_EVENT_SUPPORTED |
CLAIMED_DISK | DETECTED_DISK | USABLE_DISK | CONFIGURED_DISK;
- strncpy((char *) new_disk->serial, di->serial, MAX_RAID_SERIAL_LEN);
+ strncpy((char *) new_disk->serial, dev_info_serial_to_isw(di->serial),
+ MAX_RAID_SERIAL_LEN);
/* build new isw_disk array */
for (i = 0; i < isw->num_disks; i++) {
-------------- next part --------------
--- dmraid.spec 2009-04-06 15:08:40.000000000 +0000
+++ ../dmraid-new/dmraid.spec 2010-04-18 19:18:43.702591189 +0000
@@ -17,12 +17,16 @@
# Source0-md5: 2602887205a35f89b59eeba3a868150f
Source1: %{name}-initramfs-hook
Source2: %{name}-initramfs-local-top
+Source3: %{name}-activate
Patch0: %{name}-selinux-static.patch
Patch1: %{name}-fix.patch
Patch2: %{name}-optflags.patch
Patch3: %{name}-as-needed.patch
Patch4: %{name}-unsigned.patch
Patch5: %{name}-diet.patch
+Patch6: %{name}-isw-raid10.patch
+Patch7: %{name}-isw-serial.patch
+
URL: http://people.redhat.com/~heinzm/sw/dmraid/
BuildRequires: autoconf
BuildRequires: automake
@@ -122,6 +126,9 @@
%patch3 -p1
%patch4 -p1
%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+
%build
cp -f /usr/share/automake/config.sub autoconf
@@ -172,6 +179,7 @@
install %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/hooks/dmraid
install %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/initramfs-tools/scripts/local-top/dmraid
+install %{SOURCE3} $RPM_BUILD_ROOT%{_sbindir}/dmraid-activate
%clean
rm -rf $RPM_BUILD_ROOT
@@ -205,6 +213,7 @@
%defattr(644,root,root,755)
%attr(755,root,root) %{_datadir}/initramfs-tools/hooks/dmraid
%attr(755,root,root) %{_datadir}/initramfs-tools/scripts/local-top/dmraid
+%attr(755,root,root) %{_sbindir}/dmraid-activate
%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
%changelog
-------------- next part --------------
--- dmraid-initramfs-hook 2009-02-26 14:25:32.000000000 +0000
+++ ../dmraid-new/dmraid-initramfs-hook 2010-04-18 20:16:02.054197872 +0000
@@ -23,6 +23,8 @@
force_load dm-raid45
copy_exec /sbin/dmraid sbin
copy_exec /sbin/dmraid-activate sbin
+ copy_exec /bin/grep bin
+ copy_exec /bin/sed bin
if [ -f /etc/udev/rules.d/85_dmraid.rules ]; then
mkdir -p ${DESTDIR}/etc/udev/rules.d
cp -p /etc/udev/rules.d/85_dmraid.rules ${DESTDIR}/etc/udev/rules.d
-------------- next part --------------
#!/bin/sh
#
# dmraid-activate: Script to reformat the output of dmraid to be useful with
# udev.
#
# (c) 2008 Canonical Ltd.
#
# 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.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Arguments: $1 = Name of array you want activated.
activate_array ()
{
Raid_Setinfo=$(dmraid -i -si "$1")
if [ -z "$Raid_Setinfo" ]; then
log_error "Cannot retrieve RAID set information for $1"
return 1
fi
Raid_Type=$(dmraid -i -si -ct "$1")
Raid_Nodevs=$(dmraid -i -si -cd "$1")
case "$Raid_Type" in
stripe)
if [ "$Raid_Nodevs" -lt 2 ]; then
if [ -n "$Degraded" ]; then
log_error "Cannot bring up a RAID0 array in degraded mode, not all devices present."
fi
return 2
fi
;;
mirror)
if [ "$Raid_Nodevs" -lt 2 ]; then
if [ -z "$Degraded" ]; then
log_error "Raid set $Raid_Name is degraded. Not activating"
return 2
else
log_warning "Activating $Raid_Name in degraded mode"
Return_Val=3
fi
fi
;;
raid5_*)
modprobe -q dm_raid45
if [ "$Raid_Nodevs" -lt 3 ]; then
if [ -z "$Degraded" ]; then
log_error "Raid set $Raid_Name is degraded. Not activating"
return 2
else
log_warning "Activating $Raid_Name in degraded mode"
Return_Val=3
fi
fi
;;
esac
# At this point we have the required number of devs, or the user wants the
# array brought up in degraded mode, except in the case of striped arrays.
# We need to know the root device for determining if the -Z flag can be used
# (see #533848 and LP: 392510)
if [ -z "$ROOT" ]; then
for x in $(cat /proc/cmdline); do
case $x in
root=*)
ROOT=${x#root=}
;;
esac
done
case "$ROOT" in
LABEL=*)
ROOT=$(readlink -f /dev/disk/by-uuid/${ROOT#LABEL=})
;;
UUID=*)
ROOT=$(readlink -f /dev/disk/by-uuid/${ROOT#UUID=})
;;
esac
else
ROOT=$(readlink -f $ROOT)
fi
if (echo $ROOT | grep -q $1) ; then
dmraid -i -ay -Z "$1"
else
dmraid -i -ay "$1"
fi
return $Return_Val
}
log_warning()
{
if type logger > /dev/null ; then
logger -t dmraid-activate "WARNING: $1"
else
echo "dmraid-activate: WARNING: $1"
fi
}
log_error()
{
if type logger > /dev/null ; then
logger -t dmraid-activate "ERROR: $1"
else
echo "dmraid-activate: ERROR: $1"
fi
}
if grep -qs "\<nodmraid\>" /proc/cmdline; then
log_warning "dmraid disabled by boot option"
exit 0
fi
modprobe -q dm_mod
if [ -z "$1" ] || [ "$1" = "--degraded" ] && [ "$#" -lt 2 ]; then
echo "Node name not specified." >&2
exit 1
fi
if [ "$1" = "--degraded" ]; then
Degraded=1
Node_Name=$2
else
Node_Name=$1
fi
Raid_Name=$(dmraid -i -r -cr /dev/$Node_Name | grep -vi "No RAID disks" | grep -vi "formats discovered")
if [ -z "$Raid_Name" ]; then
exit 0
fi
# We need a special case for isw arrays, since it is possible to have several
# subsets of a RAID group, of varying RAID types.
case "$Raid_Name" in
isw_*)
Isw_Group_Name=$Raid_Name
Isw_Subsets=$(dmraid -i -n "/dev/$Node_Name" | grep volume | sed 's/.*volume: " *\(.*\)"$/\1/')
for isw_subset in $Isw_Subsets
do
activate_array "${Isw_Group_Name}_${isw_subset}"
done
break
;;
*)
activate_array "$Raid_Name"
break
;;
esac
exit $Return_Val
More information about the pld-devel-pl
mailing list