Commit 122070a2 authored by Alex Elder's avatar Alex Elder

libceph: WARN, don't BUG on unexpected connection states

A number of assertions in the ceph messenger are implemented with
BUG_ON(), killing the system if connection's state doesn't match
what's expected.  At this point our state model is (evidently) not
well understood enough for these assertions to trigger a BUG().
Convert all BUG_ON(con->state...) calls to be WARN_ON(con->state...)
so we learn about these issues without killing the machine.

We now recognize that a connection fault can occur due to a socket
closure at any time, regardless of the state of the connection.  So
there is really nothing we can assert about the state of the
connection at that point so eliminate that assertion.
Reported-by: default avatarUgis <ugis22@gmail.com>
Tested-by: default avatarUgis <ugis22@gmail.com>
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent e6d50f67
...@@ -561,7 +561,7 @@ void ceph_con_open(struct ceph_connection *con, ...@@ -561,7 +561,7 @@ void ceph_con_open(struct ceph_connection *con,
mutex_lock(&con->mutex); mutex_lock(&con->mutex);
dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr)); dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
BUG_ON(con->state != CON_STATE_CLOSED); WARN_ON(con->state != CON_STATE_CLOSED);
con->state = CON_STATE_PREOPEN; con->state = CON_STATE_PREOPEN;
con->peer_name.type = (__u8) entity_type; con->peer_name.type = (__u8) entity_type;
...@@ -1509,7 +1509,7 @@ static int process_banner(struct ceph_connection *con) ...@@ -1509,7 +1509,7 @@ static int process_banner(struct ceph_connection *con)
static void fail_protocol(struct ceph_connection *con) static void fail_protocol(struct ceph_connection *con)
{ {
reset_connection(con); reset_connection(con);
BUG_ON(con->state != CON_STATE_NEGOTIATING); WARN_ON(con->state != CON_STATE_NEGOTIATING);
con->state = CON_STATE_CLOSED; con->state = CON_STATE_CLOSED;
} }
...@@ -1635,7 +1635,7 @@ static int process_connect(struct ceph_connection *con) ...@@ -1635,7 +1635,7 @@ static int process_connect(struct ceph_connection *con)
return -1; return -1;
} }
BUG_ON(con->state != CON_STATE_NEGOTIATING); WARN_ON(con->state != CON_STATE_NEGOTIATING);
con->state = CON_STATE_OPEN; con->state = CON_STATE_OPEN;
con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq); con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq);
...@@ -2132,7 +2132,6 @@ static int try_read(struct ceph_connection *con) ...@@ -2132,7 +2132,6 @@ static int try_read(struct ceph_connection *con)
if (ret < 0) if (ret < 0)
goto out; goto out;
BUG_ON(con->state != CON_STATE_CONNECTING);
con->state = CON_STATE_NEGOTIATING; con->state = CON_STATE_NEGOTIATING;
/* /*
...@@ -2160,7 +2159,7 @@ static int try_read(struct ceph_connection *con) ...@@ -2160,7 +2159,7 @@ static int try_read(struct ceph_connection *con)
goto more; goto more;
} }
BUG_ON(con->state != CON_STATE_OPEN); WARN_ON(con->state != CON_STATE_OPEN);
if (con->in_base_pos < 0) { if (con->in_base_pos < 0) {
/* /*
...@@ -2382,7 +2381,7 @@ static void ceph_fault(struct ceph_connection *con) ...@@ -2382,7 +2381,7 @@ static void ceph_fault(struct ceph_connection *con)
dout("fault %p state %lu to peer %s\n", dout("fault %p state %lu to peer %s\n",
con, con->state, ceph_pr_addr(&con->peer_addr.in_addr)); con, con->state, ceph_pr_addr(&con->peer_addr.in_addr));
BUG_ON(con->state != CON_STATE_CONNECTING && WARN_ON(con->state != CON_STATE_CONNECTING &&
con->state != CON_STATE_NEGOTIATING && con->state != CON_STATE_NEGOTIATING &&
con->state != CON_STATE_OPEN); con->state != CON_STATE_OPEN);
......
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