Commit 8b1afc3d authored by NeilBrown's avatar NeilBrown

md: Just use RCU when checking for overlap between arrays.

We don't really need the full mddev_lock here, and having to
drop it is messy.
RCU is enough to protect these lists.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 50bd3774
...@@ -2963,20 +2963,20 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2963,20 +2963,20 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len)
rdev->sectors = sectors; rdev->sectors = sectors;
if (sectors > oldsectors && my_mddev->external) { if (sectors > oldsectors && my_mddev->external) {
/* need to check that all other rdevs with the same ->bdev /* Need to check that all other rdevs with the same
* do not overlap. We need to unlock the mddev to avoid * ->bdev do not overlap. 'rcu' is sufficient to walk
* a deadlock. We have already changed rdev->sectors, and if * the rdev lists safely.
* we have to change it back, we will have the lock again. * This check does not provide a hard guarantee, it
* just helps avoid dangerous mistakes.
*/ */
struct mddev *mddev; struct mddev *mddev;
int overlap = 0; int overlap = 0;
struct list_head *tmp; struct list_head *tmp;
mddev_unlock(my_mddev); rcu_read_lock();
for_each_mddev(mddev, tmp) { for_each_mddev(mddev, tmp) {
struct md_rdev *rdev2; struct md_rdev *rdev2;
mddev_lock_nointr(mddev);
rdev_for_each(rdev2, mddev) rdev_for_each(rdev2, mddev)
if (rdev->bdev == rdev2->bdev && if (rdev->bdev == rdev2->bdev &&
rdev != rdev2 && rdev != rdev2 &&
...@@ -2986,13 +2986,12 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2986,13 +2986,12 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len)
overlap = 1; overlap = 1;
break; break;
} }
mddev_unlock(mddev);
if (overlap) { if (overlap) {
mddev_put(mddev); mddev_put(mddev);
break; break;
} }
} }
mddev_lock_nointr(my_mddev); rcu_read_unlock();
if (overlap) { if (overlap) {
/* Someone else could have slipped in a size /* Someone else could have slipped in a size
* change here, but doing so is just silly. * change here, but doing so is just silly.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment