drbd: Refuse to change network options online when...
authorPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 16 May 2011 12:30:24 +0000 (14:30 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 8 Nov 2012 15:55:52 +0000 (16:55 +0100)
* the peer does not speak protocol_version 100 and the
  user wants to change one of:
    - wire_protocol
    - two_primaries
    - integrity_alg

* the user wants to remove the allow_two_primaries flag
  when there are two primaries

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.h

index 74c27f1507f3714e71e21d812e792bfaf8cf2d29..133a6724657d38614961065fe9262c3058060d82 100644 (file)
@@ -1722,10 +1722,24 @@ _check_net_options(struct drbd_tconn *tconn, struct net_conf *old_conf, struct n
        struct drbd_conf *mdev;
        int i;
 
-       if (old_conf && tconn->agreed_pro_version < 100 &&
-           tconn->cstate == C_WF_REPORT_PARAMS &&
-           new_conf->wire_protocol != old_conf->wire_protocol)
-               return ERR_NEED_APV_100;
+       if (old_conf && tconn->cstate == C_WF_REPORT_PARAMS && tconn->agreed_pro_version < 100) {
+               if (new_conf->wire_protocol != old_conf->wire_protocol)
+                       return ERR_NEED_APV_100;
+
+               if (new_conf->two_primaries != old_conf->two_primaries)
+                       return ERR_NEED_APV_100;
+
+               if (!new_conf->integrity_alg != !old_conf->integrity_alg)
+                       return ERR_NEED_APV_100;
+
+               if (strcmp(new_conf->integrity_alg, old_conf->integrity_alg))
+                       return ERR_NEED_APV_100;
+       }
+
+       if (!new_conf->two_primaries &&
+           conn_highest_role(tconn) == R_PRIMARY &&
+           conn_highest_peer(tconn) == R_PRIMARY)
+               return ERR_NEED_ALLOW_TWO_PRI;
 
        if (new_conf->two_primaries &&
            (new_conf->wire_protocol != DRBD_PROT_C))
index 05063e6db81f2e0bc15a58900e21f03af7631f85..679e81123229ad8f4e637dd0d1fba8ed253128f4 100644 (file)
@@ -161,6 +161,7 @@ enum drbd_ret_code {
        ERR_MINOR_EXISTS        = 161,
        ERR_INVALID_REQUEST     = 162,
        ERR_NEED_APV_100        = 163,
+       ERR_NEED_ALLOW_TWO_PRI  = 164,
 
        /* insert new ones above this line */
        AFTER_LAST_ERR_CODE