Accepting request 86854 from Base:System

Fix for bnc#721905 - for Factory and 12.1

- mkinitrd-setup.sh -- add "AUTO -all" to initrd mdadm.conf
  so that only arrays needed for boot are auto-assembled.
- auto-line.fix -- fix handling of "AUTO" line
  in mdadm.conf so it actually works.
  (bnc#721905)

OBS-URL: https://build.opensuse.org/request/show/86854
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mdadm?expand=0&rev=62
This commit is contained in:
Ruediger Oertel 2011-10-06 14:43:46 +00:00 committed by Git OBS Bridge
commit 3a05a92ae8
5 changed files with 138 additions and 1 deletions

125
auto-line.fix Normal file
View File

@ -0,0 +1,125 @@
From b451aa4846c5ccca5447a6b6d45e5623b8c8e961 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Thu, 6 Oct 2011 13:00:28 +1100
Subject: [PATCH] Fix handling for "auto" line in mdadm.conf
Two problems.
1/ pol_merge was ignoring the pol_auto tag so any 'auto' information
was lost
2/ If a device had not path (e.g. loop devices) or if there were no
path-based policies, we didn't bother looking for policy at all.
So path-independant policies were ignored.
Reported-by: Christian Boltz <suse-beta@cboltz.de>
Signed-off-by: NeilBrown <neilb@suse.de>
---
policy.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/policy.c b/policy.c
index 4a6ef82..ef48353 100644
--- a/policy.c
+++ b/policy.c
@@ -195,7 +195,9 @@ static char *disk_path(struct mdinfo *disk)
int prefix_len;
DIR *by_path;
char symlink[PATH_MAX] = "/dev/disk/by-path/";
+ char nm[PATH_MAX];
struct dirent *ent;
+ int rv;
by_path = opendir(symlink);
if (!by_path)
@@ -218,7 +220,17 @@ static char *disk_path(struct mdinfo *disk)
return strdup(ent->d_name);
}
closedir(by_path);
- return NULL;
+ /* A NULL path isn't really acceptable - use the devname.. */
+ sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor);
+ rv = readlink(symlink, nm, sizeof(nm));
+ if (rv > 0) {
+ char *dname;
+ nm[rv] = 0;
+ dname = strrchr(nm, '/');
+ if (dname)
+ return strdup(dname + 1);
+ }
+ return strdup("unknown");
}
char type_part[] = "part";
@@ -245,13 +257,13 @@ static int pol_match(struct rule *rule, char *path, char *type)
if (rule->name == rule_path) {
if (pathok == 0)
pathok = -1;
- if (fnmatch(rule->value, path, 0) == 0)
+ if (path && fnmatch(rule->value, path, 0) == 0)
pathok = 1;
}
if (rule->name == rule_type) {
if (typeok == 0)
typeok = -1;
- if (strcmp(rule->value, type) == 0)
+ if (type && strcmp(rule->value, type) == 0)
typeok = 1;
}
rule = rule->next;
@@ -270,7 +282,8 @@ static void pol_merge(struct dev_policy **pol, struct rule *rule)
for (r = rule; r ; r = r->next)
if (r->name == pol_act ||
- r->name == pol_domain)
+ r->name == pol_domain ||
+ r->name == pol_auto)
pol_new(pol, r->name, r->value, metadata);
}
@@ -280,7 +293,10 @@ static int path_has_part(char *path, char **part)
* if it does, place a pointer to "-pathNN"
* in 'part'.
*/
- int l = strlen(path);
+ int l;
+ if (!path)
+ return 0;
+ l = strlen(path);
while (l > 1 && isdigit(path[l-1]))
l--;
if (l < 5 || strncmp(path+l-5, "-part", 5) != 0)
@@ -343,9 +359,6 @@ struct dev_policy *path_policy(char *path, char *type)
struct dev_policy *pol = NULL;
int i;
- if (!type)
- return NULL;
-
rules = config_rules;
while (rules) {
@@ -366,7 +379,7 @@ struct dev_policy *path_policy(char *path, char *type)
/* Now add any metadata-specific internal knowledge
* about this path
*/
- for (i=0; superlist[i]; i++)
+ for (i=0; path && superlist[i]; i++)
if (superlist[i]->get_disk_controller_domain) {
const char *d =
superlist[i]->get_disk_controller_domain(path);
@@ -399,12 +412,8 @@ struct dev_policy *disk_policy(struct mdinfo *disk)
char *type = disk_type(disk);
struct dev_policy *pol = NULL;
- if (!type)
- return NULL;
if (config_rules_has_path)
path = disk_path(disk);
- if (!path)
- return NULL;
pol = path_policy(path, type);
--
1.7.6.4

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Thu Oct 6 02:16:35 UTC 2011 - nfbrown@suse.com
- mkinitrd-setup.sh -- add "AUTO -all" to initrd mdadm.conf
so that only arrays needed for boot are auto-assembled.
- auto-line.fix -- fix handling of "AUTO" line
in mdadm.conf so it actually works.
(bnc#721905)
-------------------------------------------------------------------
Fri Sep 30 15:35:39 UTC 2011 - uli@suse.com

View File

@ -38,6 +38,7 @@ Source4: boot.md
Source5: mkinitrd-setup.sh
Source6: mkinitrd-boot.sh
Patch0: mdadm-3.2.2_git3b1dab1bdbda0
Patch1: auto-line.fix
%description
Mdadm is a program that can be used to control Linux md devices. It is
@ -53,6 +54,7 @@ Authors:
%prep
%setup -q -a1
%patch0 -p1
%patch1 -p1
%build
%{suse_update_config -f}

View File

@ -1,5 +1,6 @@
#!/bin/bash
#%stage: softraid
# grep needed for udev rules file.
#%programs: /sbin/mdadm /sbin/mdmon
#%modules: raid0 raid1 raid10 raid456
#%if: -n "$need_mdadm"

View File

@ -82,7 +82,7 @@ blockdev="$mdblockdev"
if [ -n "$root_md" ] ; then
need_mdadm=1
echo -n "" > $tmp_mnt/etc/mdadm.conf
echo "AUTO -all" > $tmp_mnt/etc/mdadm.conf
for md in $md_devs; do
eval echo -e \"\$md_conf_$md\" >> $tmp_mnt/etc/mdadm.conf
done