diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-07-15 17:04:26 +0200 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 16:57:55 +0100 |
commit | fbc12f4514279264b5ecd5ae24f94be08e108dcd (patch) | |
tree | 1d8777aa0d32cd0e49cc11f4e0285bd7c145ed36 /drivers/block/drbd/drbd_receiver.c | |
parent | b792c35cfb336b456e9e2455082ff12d4a76b98f (diff) | |
download | lwn-fbc12f4514279264b5ecd5ae24f94be08e108dcd.tar.gz lwn-fbc12f4514279264b5ecd5ae24f94be08e108dcd.zip |
drbd: receive_protocol(): Make the program flow less confusing
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.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 11f2e7273e13..06bbf0f79fc5 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -3083,55 +3083,52 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi) synchronize_rcu(); kfree(old_net_conf); + } else { + clear_bit(CONN_DRY_RUN, &tconn->flags); - return 0; - } - - clear_bit(CONN_DRY_RUN, &tconn->flags); + if (cf & CF_DRY_RUN) + set_bit(CONN_DRY_RUN, &tconn->flags); - if (cf & CF_DRY_RUN) - set_bit(CONN_DRY_RUN, &tconn->flags); + rcu_read_lock(); + nc = rcu_dereference(tconn->net_conf); - rcu_read_lock(); - nc = rcu_dereference(tconn->net_conf); + if (p_proto != nc->wire_protocol) { + conn_err(tconn, "incompatible communication protocols\n"); + goto disconnect_rcu_unlock; + } - if (p_proto != nc->wire_protocol) { - conn_err(tconn, "incompatible communication protocols\n"); - goto disconnect_rcu_unlock; - } + if (convert_after_sb(p_after_sb_0p) != nc->after_sb_0p) { + conn_err(tconn, "incompatible after-sb-0pri settings\n"); + goto disconnect_rcu_unlock; + } - if (convert_after_sb(p_after_sb_0p) != nc->after_sb_0p) { - conn_err(tconn, "incompatible after-sb-0pri settings\n"); - goto disconnect_rcu_unlock; - } + if (convert_after_sb(p_after_sb_1p) != nc->after_sb_1p) { + conn_err(tconn, "incompatible after-sb-1pri settings\n"); + goto disconnect_rcu_unlock; + } - if (convert_after_sb(p_after_sb_1p) != nc->after_sb_1p) { - conn_err(tconn, "incompatible after-sb-1pri settings\n"); - goto disconnect_rcu_unlock; - } + if (convert_after_sb(p_after_sb_2p) != nc->after_sb_2p) { + conn_err(tconn, "incompatible after-sb-2pri settings\n"); + goto disconnect_rcu_unlock; + } - if (convert_after_sb(p_after_sb_2p) != nc->after_sb_2p) { - conn_err(tconn, "incompatible after-sb-2pri settings\n"); - goto disconnect_rcu_unlock; - } + if (p_discard_my_data && nc->discard_my_data) { + conn_err(tconn, "both sides have the 'discard_my_data' flag set\n"); + goto disconnect_rcu_unlock; + } - if (p_discard_my_data && nc->discard_my_data) { - conn_err(tconn, "both sides have the 'discard_my_data' flag set\n"); - goto disconnect_rcu_unlock; - } + if (p_two_primaries != nc->two_primaries) { + conn_err(tconn, "incompatible setting of the two-primaries options\n"); + goto disconnect_rcu_unlock; + } - if (p_two_primaries != nc->two_primaries) { - conn_err(tconn, "incompatible setting of the two-primaries options\n"); - goto disconnect_rcu_unlock; - } + if (strcmp(integrity_alg, nc->integrity_alg)) { + conn_err(tconn, "incompatible setting of the data-integrity-alg\n"); + goto disconnect_rcu_unlock; + } - if (strcmp(integrity_alg, nc->integrity_alg)) { - conn_err(tconn, "incompatible setting of the data-integrity-alg\n"); - goto disconnect_rcu_unlock; + rcu_read_unlock(); } - - rcu_read_unlock(); - return 0; disconnect_rcu_unlock: |