mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [PATCH 09/11] drbd: receive_protocol(): Make the program flow less confusing
Date: Fri, 14 Oct 2011 23:57:50 +0200	[thread overview]
Message-ID: <1318629472-11110-10-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1318629472-11110-1-git-send-email-philipp.reisner@linbit.com>

From: Andreas Gruenbacher <agruen@linbit.com>

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
 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 11f2e72..06bbf0f 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:
-- 
1.7.4.1


  parent reply	other threads:[~2011-10-14 21:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14 21:57 [RFC 00/11] drbd: part 20 of adding multiple volume support to drbd Philipp Reisner
2011-10-14 21:57 ` [PATCH 01/11] drbd: Correctly handle resources without volumes Philipp Reisner
2011-10-14 21:57 ` [PATCH 02/11] drbd: report net config even for resources without a single volume Philipp Reisner
2011-10-14 21:57 ` [PATCH 03/11] drbd: Changed some defaults Philipp Reisner
2011-10-14 21:57 ` [PATCH 04/11] drbd: Define scale factors in a single place Philipp Reisner
2011-10-14 21:57 ` [PATCH 05/11] drbd: Fix the maximum accepted minor device number Philipp Reisner
2011-10-14 21:57 ` [PATCH 06/11] drbd: Allow to create devices with a minor number > minor_count Philipp Reisner
2011-10-14 21:57 ` [PATCH 07/11] drbd: Print memory address in hex instead of decimal in error message Philipp Reisner
2011-10-14 21:57 ` [PATCH 08/11] drbd: receive_protocol(): Give variables more easily searchable names Philipp Reisner
2011-10-14 21:57 ` Philipp Reisner [this message]
2011-10-14 21:57 ` [PATCH 10/11] drbd: Be consistent in reporting incompatibilities in P_PROTOCOL settings Philipp Reisner
2011-10-14 21:57 ` [PATCH 11/11] drbd: receive_protocol(): We cannot change our own data-integrity-alg setting here Philipp Reisner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1318629472-11110-10-git-send-email-philipp.reisner@linbit.com \
    --to=philipp.reisner@linbit.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®