summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-07-31 17:11:41 -0700
committerDan Williams <dan.j.williams@intel.com>2009-07-31 17:11:41 -0700
commit148acb7baaa810b68d55df4c1784d6bd0dfd1b78 (patch)
treec3b39f9c4961296d88de6761a55d33eb423743e2 /util.c
parent329c82786932b2fbc56cd57ac0bfc185d83a04c9 (diff)
downloadmdadm-148acb7baaa810b68d55df4c1784d6bd0dfd1b78.tar.gz
mdadm-148acb7baaa810b68d55df4c1784d6bd0dfd1b78.tar.xz
mdadm-148acb7baaa810b68d55df4c1784d6bd0dfd1b78.zip
imsm: fix family number handling
The family_number field can change. The option-rom will change the family number when it starts a rebuild process (flags a container for rebuild). This was not seen previously as mdadm would usually start the rebuild process, preserving the family number. This is the mechanism that helps to prevent a prodigal array member from being returned to its original system and cause a rebuild to go in the wrong direction. With the change we will end up with a container that will fail to assemble unless the device with the incompatible family number is left out of the assembly. So, take several actions: 1/ Convert uuid generation to use orig_family_num, being careful to preserve the existing uuid in the case where orig_family_num is not set (i.e. previous mdadm created imsm arrays) 2/ Set orig_family_num at Create. For arrays created by mdadm prior to this release orig_family_num will be zero, so set it to family_num at the first metadata write. 3/ Add checks for orig_family_num to compare_super_imsm 4/ Update the family number when initiating rebuild 5/ The option-rom mixes some random data into the family number, add this functionality to the mdadm implementation. Reported-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/util.c b/util.c
index 00bf803..2543971 100644
--- a/util.c
+++ b/util.c
@@ -1298,6 +1298,17 @@ int check_env(char *name)
return 0;
}
+__u32 random32(void)
+{
+ __u32 rv;
+ int rfd = open("/dev/urandom", O_RDONLY);
+ if (rfd < 0 || read(rfd, &rv, 4) != 4)
+ rv = random();
+ if (rfd >= 0)
+ close(rfd);
+ return rv;
+}
+
#ifndef MDASSEMBLE
int flush_metadata_updates(struct supertype *st)
{