drbd: Force flag for the detach operation
authorPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 14 Mar 2011 10:54:47 +0000 (11:54 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Wed, 9 May 2012 13:10:38 +0000 (15:10 +0200)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c
include/linux/drbd_nl.h

index 1b59ab3ab9c78614a34e067f3b60d7a5dcc2ddb4..bc8a8a7556da54a39a5ffc78ed588728818aeb16 100644 (file)
@@ -495,7 +495,7 @@ static int cl_wide_st_chg(struct drbd_conf *mdev,
                 ((os.role != R_PRIMARY && ns.role == R_PRIMARY) ||
                  (os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) ||
                  (os.conn != C_STARTING_SYNC_S && ns.conn == C_STARTING_SYNC_S) ||
-                 (os.disk != D_DISKLESS && ns.disk == D_DISKLESS))) ||
+                 (os.disk != D_FAILED && ns.disk == D_FAILED))) ||
                (os.conn >= C_CONNECTED && ns.conn == C_DISCONNECTING) ||
                (os.conn == C_CONNECTED && ns.conn == C_VERIFY_S);
 }
index cabad39f908c719d8c9cbdad8b81ecc25aa12721..6d116a2b2321fe8e8f6a549fb21ab1c84b330258 100644 (file)
@@ -1337,17 +1337,32 @@ static int drbd_nl_detach(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
 {
        enum drbd_ret_code retcode;
        int ret;
+       struct detach dt = {};
+
+       if (!detach_from_tags(mdev, nlp->tag_list, &dt)) {
+               reply->ret_code = ERR_MANDATORY_TAG;
+               goto out;
+       }
+
+       if (dt.detach_force) {
+               drbd_force_state(mdev, NS(disk, D_FAILED));
+               reply->ret_code = SS_SUCCESS;
+               goto out;
+       }
+
        drbd_suspend_io(mdev); /* so no-one is stuck in drbd_al_begin_io */
        retcode = drbd_request_state(mdev, NS(disk, D_FAILED));
        /* D_FAILED will transition to DISKLESS. */
        ret = wait_event_interruptible(mdev->misc_wait,
                        mdev->state.disk != D_FAILED);
        drbd_resume_io(mdev);
+
        if ((int)retcode == (int)SS_IS_DISKLESS)
                retcode = SS_NOTHING_TO_DO;
        if (ret)
                retcode = ERR_INTR;
        reply->ret_code = retcode;
+out:
        return 0;
 }
 
index ab6159e4fcf0c6122cf840aef801fef822b0ab46..7203c9ead23385c95aabc31dd9bdb28e60986d52 100644 (file)
@@ -33,7 +33,9 @@ NL_PACKET(disk_conf, 3,
        NL_BIT(         58,     T_MAY_IGNORE,   no_disk_drain)
 )
 
-NL_PACKET(detach, 4, )
+NL_PACKET(detach, 4,
+       NL_BIT(         88,     T_MANDATORY,    detach_force)
+)
 
 NL_PACKET(net_conf, 5,
        NL_STRING(      8,      T_MANDATORY,    my_addr,        128)