md: remove duplicated test on ->openers when calling do_md_stop()
authorNeilBrown <neilb@suse.de>
Tue, 31 Jul 2012 00:04:55 +0000 (10:04 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 31 Jul 2012 00:04:55 +0000 (10:04 +1000)
do_md_stop tests mddev->openers while holding ->open_mutex,
and fails if this count is too high.
So callers do not need to check mddev->openers and doing so isn't
very meaningful as they don't hold ->open_mutex so the number could
change.

So remove the unnecessary tests on mddev->openers.
These are not called often enough for there to be any gain in
an early test on ->open_mutex to avoid the need for a slightly more
costly mutex_lock call.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/md.c

index d5ab4493c8be656ecd28227994d7f7bbe06b8e2d..f6c46109b071310fdc0a28b89a916cd67cf69b9d 100644 (file)
@@ -3942,17 +3942,13 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
                break;
        case clear:
                /* stopping an active array */
-               if (atomic_read(&mddev->openers) > 0)
-                       return -EBUSY;
                err = do_md_stop(mddev, 0, NULL);
                break;
        case inactive:
                /* stopping an active array */
-               if (mddev->pers) {
-                       if (atomic_read(&mddev->openers) > 0)
-                               return -EBUSY;
+               if (mddev->pers)
                        err = do_md_stop(mddev, 2, NULL);
-               else
+               else
                        err = 0; /* already inactive */
                break;
        case suspended: