md-cluster: only call kick_rdev_from_array after remove disk successfully
authorGuoqing Jiang <gqjiang@suse.com>
Mon, 12 Oct 2015 09:21:27 +0000 (17:21 +0800)
committerGoldwyn Rodrigues <rgoldwyn@suse.com>
Mon, 12 Oct 2015 16:58:15 +0000 (11:58 -0500)
For cluster raid, we should not kick it from array if the disk can't be
remove from array successfully.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
drivers/md/md.c

index 8a6f67f..d39a72a 100644 (file)
@@ -2548,13 +2548,16 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
                        err = -EBUSY;
                else {
                        struct mddev *mddev = rdev->mddev;
-                       if (mddev_is_clustered(mddev))
-                               md_cluster_ops->remove_disk(mddev, rdev);
-                       md_kick_rdev_from_array(rdev);
-                       if (mddev->pers)
-                               md_update_sb(mddev, 1);
-                       md_new_event(mddev);
                        err = 0;
+                       if (mddev_is_clustered(mddev))
+                               err = md_cluster_ops->remove_disk(mddev, rdev);
+
+                       if (err == 0) {
+                               md_kick_rdev_from_array(rdev);
+                               if (mddev->pers)
+                                       md_update_sb(mddev, 1);
+                               md_new_event(mddev);
+                       }
                }
        } else if (cmd_match(buf, "writemostly")) {
                set_bit(WriteMostly, &rdev->flags);