Btrfs: check total number of devices when removing missing
authorJosef Bacik <josef@redhat.com>
Wed, 27 Jan 2010 02:09:38 +0000 (02:09 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 13 Aug 2010 20:20:09 +0000 (13:20 -0700)
commit95ec1a915f8c7730a5dffdd604c2b0498be15200
tree375ed56e371ab4a52e13573985fd466e926560d2
parentb618d2a8d9e044caefeeb801375b458889961a06
Btrfs: check total number of devices when removing missing

commit 035fe03a7ad56982b30ab3a522b7b08d58feccd0 upstream.

If you have a disk failure in RAID1 and then add a new disk to the
array, and then try to remove the missing volume, it will fail.  The
reason is the sanity check only looks at the total number of rw devices,
which is just 2 because we have 2 good disks and 1 bad one.  Instead
check the total number of devices in the array to make sure we can
actually remove the device.  Tested this with a failed disk setup and
with this test we can now run

btrfs-vol -r missing /mount/point

and it works fine.

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Acked-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/btrfs/volumes.c