diff options
author | Neil Brown <neilb@suse.de> | 2005-09-12 04:57:52 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2005-09-12 04:57:52 +0000 |
commit | 265e0f17317e6d23864263c04ae581b35f946b5e (patch) | |
tree | 0b368c095b4cfa6081a1d74a8ae44a288d09e511 /util.c | |
parent | 63f8c4c76bff7d45e9403908ed3591edac7a6e4f (diff) | |
download | mdadm-265e0f17317e6d23864263c04ae581b35f946b5e.tar.gz mdadm-265e0f17317e6d23864263c04ae581b35f946b5e.tar.xz mdadm-265e0f17317e6d23864263c04ae581b35f946b5e.zip |
Fix assembling of raid10 in the face of missing devices.
We now check if enough devices are present properly, so
--force can be used to good effect.
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -118,10 +118,31 @@ int get_linux_version() return (a*1000000)+(b*1000)+c; } -int enough(int level, int raid_disks, int avail_disks) +int enough(int level, int raid_disks, int layout, + char *avail, int avail_disks) { + int copies, first; switch (level) { - case 10: return 1; /* a lie, but it is hard to tell */ + case 10: + /* This is the tricky one - we need to check + * which actual disks are present. + */ + copies = (layout&255)* (layout>>8); + first=0; + do { + /* there must be one of the 'copies' form 'first' */ + int n = copies; + int cnt=0; + while (n--) { + if (avail[first]) + cnt++; + first = (first+1) % raid_disks; + } + if (cnt == 0) + return 0; + + } while (first != 0); + return 1; case -4: return avail_disks>= 1; |