Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

NeilBrown c89a8eee ac4090d2

+12 -1
+12 -1
drivers/md/md.c
··· 6003 6003 } 6004 6004 } 6005 6005 6006 - if (mddev->degraded) { 6006 + if (mddev->degraded && ! mddev->ro) { 6007 6007 rdev_for_each(rdev, rtmp, mddev) { 6008 6008 if (rdev->raid_disk >= 0 && 6009 6009 !test_bit(In_sync, &rdev->flags) && ··· 6077 6077 flush_signals(current); 6078 6078 } 6079 6079 6080 + if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) 6081 + return; 6080 6082 if ( ! ( 6081 6083 (mddev->flags && !mddev->external) || 6082 6084 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || ··· 6091 6089 6092 6090 if (mddev_trylock(mddev)) { 6093 6091 int spares = 0; 6092 + 6093 + if (mddev->ro) { 6094 + /* Only thing we do on a ro array is remove 6095 + * failed devices. 6096 + */ 6097 + remove_and_add_spares(mddev); 6098 + clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 6099 + goto unlock; 6100 + } 6094 6101 6095 6102 if (!mddev->external) { 6096 6103 int did_change = 0;