drbd: implemented receiving of P_CONN_ST_CHG_REQ
authorPhilipp Reisner <philipp.reisner@linbit.com>
Tue, 15 Feb 2011 10:09:33 +0000 (11:09 +0100)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Fri, 14 Oct 2011 14:45:05 +0000 (16:45 +0200)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_state.h

index 4363b393a1281ecba8dcfa5c00335f7701000d1d..b287bad4767f02aecd44ecc00693775adca5fc10 100644 (file)
@@ -1219,6 +1219,7 @@ extern int drbd_send_ov_request(struct drbd_conf *mdev,sector_t sector,int size)
 extern int drbd_send_bitmap(struct drbd_conf *mdev);
 extern int _drbd_send_bitmap(struct drbd_conf *mdev);
 extern int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode);
+extern int conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode);
 extern void drbd_free_bc(struct drbd_backing_dev *ldev);
 extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
 void drbd_print_uuids(struct drbd_conf *mdev, const char *text);
index e0efc918a5e6c1b1c28d3fc357d4ebb6aa4f6405..592f0c949fd0b12ef83692cc350269511666ca54 100644 (file)
@@ -990,6 +990,16 @@ int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode)
        return drbd_send_cmd(mdev, USE_META_SOCKET, P_STATE_CHG_REPLY, &p.head, sizeof(p));
 }
 
+int conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode)
+{
+       struct p_req_state_reply p;
+       enum drbd_packet cmd = tconn->agreed_pro_version < 100 ? P_STATE_CHG_REPLY : P_CONN_ST_CHG_REPLY;
+
+       p.retcode    = cpu_to_be32(retcode);
+
+       return conn_send_cmd(tconn, 0, USE_META_SOCKET, cmd, &p.head, sizeof(p));
+}
+
 int fill_bitmap_rle_bits(struct drbd_conf *mdev,
        struct p_compressed_bm *p,
        struct bm_xfer_ctx *c)
index 2a1094aa35b0329baaf510608d69ce39c4b2137c..c85d290beed36a1e4b407f88aeba66d8b35f0ad1 100644 (file)
@@ -3232,9 +3232,14 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packet cmd,
        mask = convert_state(mask);
        val = convert_state(val);
 
-       rv = drbd_change_state(mdev, CS_VERBOSE, mask, val);
+       if (cmd == P_CONN_ST_CHG_REQ) {
+               rv = conn_request_state(mdev->tconn, mask, val, CS_VERBOSE | CS_LOCAL_ONLY);
+               conn_send_sr_reply(mdev->tconn, rv);
+       } else {
+               rv = drbd_change_state(mdev, CS_VERBOSE, mask, val);
+               drbd_send_sr_reply(mdev, rv);
+       }
 
-       drbd_send_sr_reply(mdev, rv);
        drbd_md_sync(mdev);
 
        return true;
@@ -3768,6 +3773,7 @@ static struct data_cmd drbd_cmd_handler[] = {
        [P_CSUM_RS_REQUEST] = { 1, sizeof(struct p_block_req), receive_DataRequest },
        [P_DELAY_PROBE]     = { 0, sizeof(struct p_delay_probe93), receive_skip },
        [P_OUT_OF_SYNC]     = { 0, sizeof(struct p_block_desc), receive_out_of_sync },
+       [P_CONN_ST_CHG_REQ] = { 0, sizeof(struct p_req_state), receive_req_state },
        /* anything missing from this table is in
         * the asender_tbl, see get_asender_cmd */
        [P_MAX_CMD]         = { 0, 0, NULL },
index d312d84b8410708f8ee027839c74c739afee5397..5fdbdf0be707d4762d41c952a1e29d93c0b189a9 100644 (file)
@@ -63,6 +63,7 @@ enum chg_state_flags {
        CS_SERIALIZE    = 8,
        CS_ORDERED      = CS_WAIT_COMPLETE + CS_SERIALIZE,
        CS_NO_CSTATE_CHG = 16, /* Do not display changes in cstate. Internal to drbd_state.c */
+       CS_LOCAL_ONLY = 32, /* Do not consider a device pair wide state change */
 };
 
 extern enum drbd_state_rv drbd_change_state(struct drbd_conf *mdev,