From: NeilBrown <neilb@suse.de>
Git-commit: dc10c643e8a8d008fd16dd6706e9e0018eadf8d2
Date: Wed, 7 Mar 2012 13:59:47 +1100
Subject: [PATCH] md: allow re-add to failed arrays.
Patch-mainline: 3.4
References: bnc#746717

When an array is failed (some data inaccessible) then there is no
point attempting to add a spare as it could not possibly be recovered.

However that may be value in re-adding a recently removed device.
e.g. if there is a write-intent-bitmap and it is clear, then access
to the data could be restored by this action.

So don't reject a re-add to a failed array for RAID10 and RAID5 (the
only arrays  types that check for a failed array).

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: 

---
 drivers/md/raid10.c |    2 +-
 drivers/md/raid5.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- linux-3.0-SLE11-SP2.orig/drivers/md/raid10.c
+++ linux-3.0-SLE11-SP2/drivers/md/raid10.c
@@ -1145,7 +1145,7 @@ static int raid10_add_disk(mddev_t *mdde
 		 * very different from resync
 		 */
 		return -EBUSY;
-	if (!enough(conf, -1))
+	if (rdev->saved_raid_disk < 0 && !enough(conf, -1))
 		return -EINVAL;
 
 	if (rdev->raid_disk >= 0)
--- linux-3.0-SLE11-SP2.orig/drivers/md/raid5.c
+++ linux-3.0-SLE11-SP2/drivers/md/raid5.c
@@ -5369,7 +5369,7 @@ static int raid5_add_disk(mddev_t *mddev
 	int first = 0;
 	int last = conf->raid_disks - 1;
 
-	if (has_failed(conf))
+	if (rdev->saved_raid_disk < 0 && has_failed(conf))
 		/* no point adding a device */
 		return -EINVAL;
 
