diff --git a/auto-line.fix b/auto-line.fix new file mode 100644 index 0000000..8193c8f --- /dev/null +++ b/auto-line.fix @@ -0,0 +1,125 @@ +From b451aa4846c5ccca5447a6b6d45e5623b8c8e961 Mon Sep 17 00:00:00 2001 +From: NeilBrown +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 +Signed-off-by: NeilBrown +--- + 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 + diff --git a/mdadm.changes b/mdadm.changes index ddb4e33..4bf8f76 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -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 diff --git a/mdadm.spec b/mdadm.spec index d65f4a8..d070016 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -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} diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index acd141a..9c45fb9 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -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" diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 06d43c5..27837ce 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -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