Allow faulty devices to be removed from a readonly array.
Removing faulty devices from an array is a two stage process. First the device is moved from being a part of the active array to being similar to a spare device. Then it can be removed by a request from user space. The first step is currently not performed for read-only arrays, so the second step can never succeed. So allow readonly arrays to remove failed devices (which aren't blocked). Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
		
					parent
					
						
							
								ac4090d24c
							
						
					
				
			
			
				commit
				
					
						c89a8eee61
					
				
			
		
					 1 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
					@ -6003,7 +6003,7 @@ static int remove_and_add_spares(mddev_t *mddev)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (mddev->degraded) {
 | 
						if (mddev->degraded && ! mddev->ro) {
 | 
				
			||||||
		rdev_for_each(rdev, rtmp, mddev) {
 | 
							rdev_for_each(rdev, rtmp, mddev) {
 | 
				
			||||||
			if (rdev->raid_disk >= 0 &&
 | 
								if (rdev->raid_disk >= 0 &&
 | 
				
			||||||
			    !test_bit(In_sync, &rdev->flags) &&
 | 
								    !test_bit(In_sync, &rdev->flags) &&
 | 
				
			||||||
| 
						 | 
					@ -6077,6 +6077,8 @@ void md_check_recovery(mddev_t *mddev)
 | 
				
			||||||
		flush_signals(current);
 | 
							flush_signals(current);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	if ( ! (
 | 
						if ( ! (
 | 
				
			||||||
		(mddev->flags && !mddev->external) ||
 | 
							(mddev->flags && !mddev->external) ||
 | 
				
			||||||
		test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
 | 
							test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
 | 
				
			||||||
| 
						 | 
					@ -6090,6 +6092,15 @@ void md_check_recovery(mddev_t *mddev)
 | 
				
			||||||
	if (mddev_trylock(mddev)) {
 | 
						if (mddev_trylock(mddev)) {
 | 
				
			||||||
		int spares = 0;
 | 
							int spares = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (mddev->ro) {
 | 
				
			||||||
 | 
								/* Only thing we do on a ro array is remove
 | 
				
			||||||
 | 
								 * failed devices.
 | 
				
			||||||
 | 
								 */
 | 
				
			||||||
 | 
								remove_and_add_spares(mddev);
 | 
				
			||||||
 | 
								clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
 | 
				
			||||||
 | 
								goto unlock;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!mddev->external) {
 | 
							if (!mddev->external) {
 | 
				
			||||||
			int did_change = 0;
 | 
								int did_change = 0;
 | 
				
			||||||
			spin_lock_irq(&mddev->write_lock);
 | 
								spin_lock_irq(&mddev->write_lock);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue