drbd: --force option for disconnect
authorPhilipp Reisner <philipp.reisner@linbit.com>
Fri, 3 Dec 2010 14:22:48 +0000 (15:22 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 10 Mar 2011 10:35:17 +0000 (11:35 +0100)
As the network connection can be lost at any time, a --force option
for disconnect is just a matter of completeness.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_nl.c
include/linux/drbd_nl.h

index 6a6dde6c51c6076bd5346d09a6addc6113aad8fc..cd0459f0403fbca71cfc8c052c0293252f7ef15a 100644 (file)
@@ -1531,6 +1531,21 @@ static int drbd_nl_disconnect(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl
                              struct drbd_nl_cfg_reply *reply)
 {
        int retcode;
+       struct disconnect dc;
+
+       memset(&dc, 0, sizeof(struct disconnect));
+       if (!disconnect_from_tags(mdev, nlp->tag_list, &dc)) {
+               retcode = ERR_MANDATORY_TAG;
+               goto fail;
+       }
+
+       if (dc.force) {
+               spin_lock_irq(&mdev->req_lock);
+               if (mdev->state.conn >= C_WF_CONNECTION)
+                       _drbd_set_state(_NS(mdev, conn, C_DISCONNECTING), CS_HARD, NULL);
+               spin_unlock_irq(&mdev->req_lock);
+               goto done;
+       }
 
        retcode = _drbd_request_state(mdev, NS(conn, C_DISCONNECTING), CS_ORDERED);
 
index 6fc614b06c4dcea6b1935ef0ede6d6c8faf92400..ab6159e4fcf0c6122cf840aef801fef822b0ab46 100644 (file)
@@ -69,7 +69,9 @@ NL_PACKET(net_conf, 5,
        NL_BIT(         70,     T_MANDATORY,    dry_run)
 )
 
-NL_PACKET(disconnect, 6, )
+NL_PACKET(disconnect, 6,
+       NL_BIT(         84,     T_MAY_IGNORE,   force)
+)
 
 NL_PACKET(resize, 7,
        NL_INT64(               29,     T_MAY_IGNORE,   resize_size)