aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2013-10-10 13:37:29 -0400
committerChris Mason <chris.mason@fusionio.com>2013-11-11 22:00:24 -0500
commitf747cab7b75ba298df3ac234de9f1655957786cc (patch)
treed9a0eb6f78abfd82615aadeee1747622a1a48b01
parent03b2f08b5f96db5d07dba54ae008e9fdf1396e05 (diff)
Btrfs: nuke a bogus rw_devices decrement in __btrfs_close_devices
On mount failures, __btrfs_close_devices can be called well before dev-replace state is read and ->is_tgtdev_for_dev_replace is set. This leads to a bogus decrement of ->rw_devices and sets off a WARN_ON in __btrfs_close_devices if replace target device happens to be on the lists and we fail early in the mount sequence. Fix this by checking the devid instead of ->is_tgtdev_for_dev_replace before the decrement: for replace targets devid is always equal to BTRFS_DEV_REPLACE_DEVID. Cc: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--fs/btrfs/volumes.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c846cc8eb32c..9dfe038015f7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -666,7 +666,8 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
666 if (device->bdev) 666 if (device->bdev)
667 fs_devices->open_devices--; 667 fs_devices->open_devices--;
668 668
669 if (device->writeable && !device->is_tgtdev_for_dev_replace) { 669 if (device->writeable &&
670 device->devid != BTRFS_DEV_REPLACE_DEVID) {
670 list_del_init(&device->dev_alloc_list); 671 list_del_init(&device->dev_alloc_list);
671 fs_devices->rw_devices--; 672 fs_devices->rw_devices--;
672 } 673 }