Commit f179d76d authored by Philipp Reisner's avatar Philipp Reisner

drbd: Made cmp_after_sb() more generic into convert_after_sb()

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 46e1ce41
...@@ -2984,25 +2984,18 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol ...@@ -2984,25 +2984,18 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
return rv; return rv;
} }
/* returns 1 if invalid */ static enum drbd_after_sb_p convert_after_sb(enum drbd_after_sb_p peer)
static int cmp_after_sb(enum drbd_after_sb_p peer, enum drbd_after_sb_p self)
{ {
/* ASB_DISCARD_REMOTE - ASB_DISCARD_LOCAL is valid */ /* ASB_DISCARD_REMOTE - ASB_DISCARD_LOCAL is valid */
if ((peer == ASB_DISCARD_REMOTE && self == ASB_DISCARD_LOCAL) || if (peer == ASB_DISCARD_REMOTE)
(self == ASB_DISCARD_REMOTE && peer == ASB_DISCARD_LOCAL)) return ASB_DISCARD_LOCAL;
return 0;
/* any other things with ASB_DISCARD_REMOTE or ASB_DISCARD_LOCAL are invalid */ /* any other things with ASB_DISCARD_REMOTE or ASB_DISCARD_LOCAL are invalid */
if (peer == ASB_DISCARD_REMOTE || peer == ASB_DISCARD_LOCAL || if (peer == ASB_DISCARD_LOCAL)
self == ASB_DISCARD_REMOTE || self == ASB_DISCARD_LOCAL) return ASB_DISCARD_REMOTE;
return 1;
/* everything else is valid if they are equal on both sides. */ /* everything else is valid if they are equal on both sides. */
if (peer == self) return peer;
return 0;
/* everything es is invalid. */
return 1;
} }
static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi) static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
...@@ -3060,17 +3053,17 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi) ...@@ -3060,17 +3053,17 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
goto disconnect_rcu_unlock; goto disconnect_rcu_unlock;
} }
if (cmp_after_sb(p_after_sb_0p, nc->after_sb_0p)) { if (convert_after_sb(p_after_sb_0p) != nc->after_sb_0p) {
conn_err(tconn, "incompatible after-sb-0pri settings\n"); conn_err(tconn, "incompatible after-sb-0pri settings\n");
goto disconnect_rcu_unlock; goto disconnect_rcu_unlock;
} }
if (cmp_after_sb(p_after_sb_1p, nc->after_sb_1p)) { if (convert_after_sb(p_after_sb_1p) != nc->after_sb_1p) {
conn_err(tconn, "incompatible after-sb-1pri settings\n"); conn_err(tconn, "incompatible after-sb-1pri settings\n");
goto disconnect_rcu_unlock; goto disconnect_rcu_unlock;
} }
if (cmp_after_sb(p_after_sb_2p, nc->after_sb_2p)) { if (convert_after_sb(p_after_sb_2p) != nc->after_sb_2p) {
conn_err(tconn, "incompatible after-sb-2pri settings\n"); conn_err(tconn, "incompatible after-sb-2pri settings\n");
goto disconnect_rcu_unlock; goto disconnect_rcu_unlock;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment