aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_receiver.c
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2011-05-16 11:31:47 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-08 10:55:53 -0500
commitf179d76d76ce6653ba4c6a6b0c2e7c42215734bc (patch)
tree5bc293d13a234306b04e5c30903c31907084290d /drivers/block/drbd/drbd_receiver.c
parent46e1ce4177aac86b8e39bc7bb5763e9d040ae5cb (diff)
drbd: Made cmp_after_sb() more generic into convert_after_sb()
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_receiver.c')
-rw-r--r--drivers/block/drbd/drbd_receiver.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 7deade196a33..b5eeb8de407b 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -2984,25 +2984,18 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
2984 return rv; 2984 return rv;
2985} 2985}
2986 2986
2987/* returns 1 if invalid */ 2987static enum drbd_after_sb_p convert_after_sb(enum drbd_after_sb_p peer)
2988static int cmp_after_sb(enum drbd_after_sb_p peer, enum drbd_after_sb_p self)
2989{ 2988{
2990 /* ASB_DISCARD_REMOTE - ASB_DISCARD_LOCAL is valid */ 2989 /* ASB_DISCARD_REMOTE - ASB_DISCARD_LOCAL is valid */
2991 if ((peer == ASB_DISCARD_REMOTE && self == ASB_DISCARD_LOCAL) || 2990 if (peer == ASB_DISCARD_REMOTE)
2992 (self == ASB_DISCARD_REMOTE && peer == ASB_DISCARD_LOCAL)) 2991 return ASB_DISCARD_LOCAL;
2993 return 0;
2994 2992
2995 /* any other things with ASB_DISCARD_REMOTE or ASB_DISCARD_LOCAL are invalid */ 2993 /* any other things with ASB_DISCARD_REMOTE or ASB_DISCARD_LOCAL are invalid */
2996 if (peer == ASB_DISCARD_REMOTE || peer == ASB_DISCARD_LOCAL || 2994 if (peer == ASB_DISCARD_LOCAL)
2997 self == ASB_DISCARD_REMOTE || self == ASB_DISCARD_LOCAL) 2995 return ASB_DISCARD_REMOTE;
2998 return 1;
2999 2996
3000 /* everything else is valid if they are equal on both sides. */ 2997 /* everything else is valid if they are equal on both sides. */
3001 if (peer == self) 2998 return peer;
3002 return 0;
3003
3004 /* everything es is invalid. */
3005 return 1;
3006} 2999}
3007 3000
3008static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi) 3001static 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 goto disconnect_rcu_unlock; 3053 goto disconnect_rcu_unlock;
3061 } 3054 }
3062 3055
3063 if (cmp_after_sb(p_after_sb_0p, nc->after_sb_0p)) { 3056 if (convert_after_sb(p_after_sb_0p) != nc->after_sb_0p) {
3064 conn_err(tconn, "incompatible after-sb-0pri settings\n"); 3057 conn_err(tconn, "incompatible after-sb-0pri settings\n");
3065 goto disconnect_rcu_unlock; 3058 goto disconnect_rcu_unlock;
3066 } 3059 }
3067 3060
3068 if (cmp_after_sb(p_after_sb_1p, nc->after_sb_1p)) { 3061 if (convert_after_sb(p_after_sb_1p) != nc->after_sb_1p) {
3069 conn_err(tconn, "incompatible after-sb-1pri settings\n"); 3062 conn_err(tconn, "incompatible after-sb-1pri settings\n");
3070 goto disconnect_rcu_unlock; 3063 goto disconnect_rcu_unlock;
3071 } 3064 }
3072 3065
3073 if (cmp_after_sb(p_after_sb_2p, nc->after_sb_2p)) { 3066 if (convert_after_sb(p_after_sb_2p) != nc->after_sb_2p) {
3074 conn_err(tconn, "incompatible after-sb-2pri settings\n"); 3067 conn_err(tconn, "incompatible after-sb-2pri settings\n");
3075 goto disconnect_rcu_unlock; 3068 goto disconnect_rcu_unlock;
3076 } 3069 }