]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - monitor.c
Handle device removal from container
[thirdparty/mdadm.git] / monitor.c
index 6377cc4a01551018bf77b76e7eabd6497ecfea40..5bb2559602d1f4cf2b241a2fe78df489dceb6623 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -367,54 +367,11 @@ static void reconcile_failed(struct active_array *aa, struct mdinfo *failed)
        }
 }
 
-static int handle_remove_device(struct md_remove_device_cmd *cmd, struct active_array *aa)
-{
-       struct active_array *a;
-       struct mdinfo *victim;
-       int rv;
-
-       /* scan all arrays for the given device, if ->state_fd is closed (-1)
-        * in all cases then mark the disk as removed in the metadata.
-        * Otherwise reply that it is busy.
-        */
-
-       /* pass1 check that it is not in use anywhere */
-       /* note: we are safe from re-adds as long as the device exists in the
-        * container
-        */
-       for (a = aa; a; a = a->next) {
-               if (!a->container)
-                       continue;
-               victim = find_device(a, major(cmd->rdev), minor(cmd->rdev));
-               if (!victim)
-                       continue;
-               if (victim->state_fd > 0)
-                       return -EBUSY;
-       }
-
-       /* pass2 schedule and process removal per array */
-       for (a = aa; a; a = a->next) {
-               if (!a->container)
-                       continue;
-               victim = find_device(a, major(cmd->rdev), minor(cmd->rdev));
-               if (!victim)
-                       continue;
-               victim->curr_state |= DS_REMOVE;
-               rv = read_and_act(a);
-               if (rv < 0)
-                       return rv;
-       }
-
-       return 0;
-}
-
 static int handle_pipe(struct md_generic_cmd *cmd, struct active_array *aa)
 {
        switch (cmd->action) {
        case md_action_ping_monitor:
                return 0;
-       case md_action_remove_device:
-               return handle_remove_device((void *) cmd, aa);
        }
 
        return -1;