Commit 29f097c4 authored by NeilBrown's avatar NeilBrown

md: fix some places where mddev_lock return value is not checked.

Sometimes we need to lock and mddev and cannot cope with
failure due to interrupt.
In these cases we should use mutex_lock, not mutex_lock_interruptible.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent edfa1f65
...@@ -602,11 +602,19 @@ static struct mddev * mddev_find(dev_t unit) ...@@ -602,11 +602,19 @@ static struct mddev * mddev_find(dev_t unit)
goto retry; goto retry;
} }
static inline int mddev_lock(struct mddev * mddev) static inline int __must_check mddev_lock(struct mddev * mddev)
{ {
return mutex_lock_interruptible(&mddev->reconfig_mutex); return mutex_lock_interruptible(&mddev->reconfig_mutex);
} }
/* Sometimes we need to take the lock in a situation where
* failure due to interrupts is not acceptable.
*/
static inline void mddev_lock_nointr(struct mddev * mddev)
{
mutex_lock(&mddev->reconfig_mutex);
}
static inline int mddev_is_locked(struct mddev *mddev) static inline int mddev_is_locked(struct mddev *mddev)
{ {
return mutex_is_locked(&mddev->reconfig_mutex); return mutex_is_locked(&mddev->reconfig_mutex);
...@@ -3018,7 +3026,7 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -3018,7 +3026,7 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len)
for_each_mddev(mddev, tmp) { for_each_mddev(mddev, tmp) {
struct md_rdev *rdev2; struct md_rdev *rdev2;
mddev_lock(mddev); 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 &&
...@@ -3034,7 +3042,7 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -3034,7 +3042,7 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len)
break; break;
} }
} }
mddev_lock(my_mddev); mddev_lock_nointr(my_mddev);
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.
...@@ -5299,7 +5307,7 @@ static void __md_stop_writes(struct mddev *mddev) ...@@ -5299,7 +5307,7 @@ static void __md_stop_writes(struct mddev *mddev)
void md_stop_writes(struct mddev *mddev) void md_stop_writes(struct mddev *mddev)
{ {
mddev_lock(mddev); mddev_lock_nointr(mddev);
__md_stop_writes(mddev); __md_stop_writes(mddev);
mddev_unlock(mddev); mddev_unlock(mddev);
} }
...@@ -6592,7 +6600,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -6592,7 +6600,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
wait_event(mddev->sb_wait, wait_event(mddev->sb_wait,
!test_bit(MD_CHANGE_DEVS, &mddev->flags) && !test_bit(MD_CHANGE_DEVS, &mddev->flags) &&
!test_bit(MD_CHANGE_PENDING, &mddev->flags)); !test_bit(MD_CHANGE_PENDING, &mddev->flags));
mddev_lock(mddev); mddev_lock_nointr(mddev);
} }
} else { } else {
err = -EROFS; err = -EROFS;
......
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