Commit 9ba3b7f5 authored by NeilBrown's avatar NeilBrown

md: be more relaxed about stopping an array which isn't started.

In general we don't allow an array to be stopped if it is in use.
However if the array hasn't really been started yet, then any
apparent use is an anomily, probably due to 'udev' or similar
having a look to see what is there.

This means that if something goes wrong while assembling an array
it cannot reliably be un-assembled - STOP_ARRAY could fail.
There is no value here, so change do_md_stop() to succeed
despite concurrent opens if the array has not yet been
activated.  i.e. if ->pers is NULL.
Reported-by: default avatar"Baldysiak, Pawel" <pawel.baldysiak@intel.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent c95e6385
...@@ -5307,7 +5307,7 @@ static int md_set_readonly(struct mddev *mddev, struct block_device *bdev) ...@@ -5307,7 +5307,7 @@ static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
mddev_lock_nointr(mddev); mddev_lock_nointr(mddev);
mutex_lock(&mddev->open_mutex); mutex_lock(&mddev->open_mutex);
if (atomic_read(&mddev->openers) > !!bdev || if ((mddev->pers && atomic_read(&mddev->openers) > !!bdev) ||
mddev->sync_thread || mddev->sync_thread ||
(bdev && !test_bit(MD_STILL_CLOSED, &mddev->flags))) { (bdev && !test_bit(MD_STILL_CLOSED, &mddev->flags))) {
printk("md: %s still in use.\n",mdname(mddev)); printk("md: %s still in use.\n",mdname(mddev));
...@@ -5362,7 +5362,7 @@ static int do_md_stop(struct mddev * mddev, int mode, ...@@ -5362,7 +5362,7 @@ static int do_md_stop(struct mddev * mddev, int mode,
mddev_lock_nointr(mddev); mddev_lock_nointr(mddev);
mutex_lock(&mddev->open_mutex); mutex_lock(&mddev->open_mutex);
if (atomic_read(&mddev->openers) > !!bdev || if ((mddev->pers && atomic_read(&mddev->openers) > !!bdev) ||
mddev->sysfs_active || mddev->sysfs_active ||
mddev->sync_thread || mddev->sync_thread ||
(bdev && !test_bit(MD_STILL_CLOSED, &mddev->flags))) { (bdev && !test_bit(MD_STILL_CLOSED, &mddev->flags))) {
...@@ -6454,7 +6454,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -6454,7 +6454,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
* and writes * and writes
*/ */
mutex_lock(&mddev->open_mutex); mutex_lock(&mddev->open_mutex);
if (atomic_read(&mddev->openers) > 1) { if (mddev->pers && atomic_read(&mddev->openers) > 1) {
mutex_unlock(&mddev->open_mutex); mutex_unlock(&mddev->open_mutex);
err = -EBUSY; err = -EBUSY;
goto abort; goto abort;
......
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