From: NeilBrown <neilb@suse.de>

This shouldn't be a BUG.  We should cope.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/md/raid10.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)

diff -puN drivers/md/raid10.c~md-fix-bug-when-raid10-rebuilds-without-enough-drives drivers/md/raid10.c
--- devel/drivers/md/raid10.c~md-fix-bug-when-raid10-rebuilds-without-enough-drives	2005-09-06 17:10:31.000000000 -0700
+++ devel-akpm/drivers/md/raid10.c	2005-09-06 17:10:31.000000000 -0700
@@ -1474,7 +1474,13 @@ static sector_t sync_request(mddev_t *md
 					}
 				}
 				if (j == conf->copies) {
-					BUG();
+					/* Cannot recover, so abort the recovery */
+					put_buf(r10_bio);
+					r10_bio = rb2;
+					if (!test_and_set_bit(MD_RECOVERY_ERR, &mddev->recovery))
+						printk(KERN_INFO "raid10: %s: insufficient working devices for recovery.\n",
+						       mdname(mddev));
+					break;
 				}
 			}
 		if (biolist == NULL) {
_