Skip to content

Commit

Permalink
libceph: don't overwrite specific con error msgs
Browse files Browse the repository at this point in the history
- specific con->error_msg messages (e.g. "protocol version mismatch")
  end up getting overwritten by a catch-all "socket error on read
  / write", introduced in commit 3a140a0 ("libceph: report socket
  read/write error message")
- "bad message sequence # for incoming message" loses to "bad crc" due
  to the fact that -EBADMSG is used for both

Fix it, and tidy up con->error_msg assignments and pr_errs while at it.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Ilya Dryomov committed Apr 20, 2015
1 parent 1c841a9 commit 67c64eb
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,6 @@ static int ceph_tcp_connect(struct ceph_connection *con)
pr_err("connect %s error %d\n",
ceph_pr_addr(&con->peer_addr.in_addr), ret);
sock_release(sock);
con->error_msg = "connect error";

return ret;
}

Expand Down Expand Up @@ -2145,12 +2143,10 @@ static int process_connect(struct ceph_connection *con)
* to WAIT. This shouldn't happen if we are the
* client.
*/
pr_err("process_connect got WAIT as client\n");
con->error_msg = "protocol error, got WAIT as client";
return -1;

default:
pr_err("connect protocol error, will retry\n");
con->error_msg = "protocol error, garbage tag during connect";
return -1;
}
Expand Down Expand Up @@ -2282,8 +2278,7 @@ static int read_partial_message(struct ceph_connection *con)

crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));
if (cpu_to_le32(crc) != con->in_hdr.crc) {
pr_err("read_partial_message bad hdr "
" crc %u != expected %u\n",
pr_err("read_partial_message bad hdr crc %u != expected %u\n",
crc, con->in_hdr.crc);
return -EBADMSG;
}
Expand Down Expand Up @@ -2313,7 +2308,7 @@ static int read_partial_message(struct ceph_connection *con)
pr_err("read_partial_message bad seq %lld expected %lld\n",
seq, con->in_seq + 1);
con->error_msg = "bad message sequence # for incoming message";
return -EBADMSG;
return -EBADE;
}

/* allocate message? */
Expand Down Expand Up @@ -2660,6 +2655,8 @@ static int try_read(struct ceph_connection *con)
switch (ret) {
case -EBADMSG:
con->error_msg = "bad crc";
/* fall through */
case -EBADE:
ret = -EIO;
break;
case -EIO:
Expand Down Expand Up @@ -2838,7 +2835,8 @@ static void con_work(struct work_struct *work)
if (ret < 0) {
if (ret == -EAGAIN)
continue;
con->error_msg = "socket error on read";
if (!con->error_msg)
con->error_msg = "socket error on read";
fault = true;
break;
}
Expand All @@ -2847,7 +2845,8 @@ static void con_work(struct work_struct *work)
if (ret < 0) {
if (ret == -EAGAIN)
continue;
con->error_msg = "socket error on write";
if (!con->error_msg)
con->error_msg = "socket error on write";
fault = true;
}

Expand All @@ -2869,11 +2868,13 @@ static void con_work(struct work_struct *work)
*/
static void con_fault(struct ceph_connection *con)
{
pr_warn("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
dout("fault %p state %lu to peer %s\n",
con, con->state, ceph_pr_addr(&con->peer_addr.in_addr));

pr_warn("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
con->error_msg = NULL;

WARN_ON(con->state != CON_STATE_CONNECTING &&
con->state != CON_STATE_NEGOTIATING &&
con->state != CON_STATE_OPEN);
Expand Down Expand Up @@ -3295,8 +3296,8 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
*/
if (*skip)
return 0;
con->error_msg = "error allocating memory for incoming message";

con->error_msg = "error allocating memory for incoming message";
return -ENOMEM;
}
memcpy(&con->in_msg->hdr, &con->in_hdr, sizeof(con->in_hdr));
Expand Down

0 comments on commit 67c64eb

Please sign in to comment.