Commit 67c64eb7 authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: don't overwrite specific con error msgs

- 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 3a140a0d ("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: default avatarIlya Dryomov <idryomov@gmail.com>
parent 1c841a96
...@@ -505,8 +505,6 @@ static int ceph_tcp_connect(struct ceph_connection *con) ...@@ -505,8 +505,6 @@ static int ceph_tcp_connect(struct ceph_connection *con)
pr_err("connect %s error %d\n", pr_err("connect %s error %d\n",
ceph_pr_addr(&con->peer_addr.in_addr), ret); ceph_pr_addr(&con->peer_addr.in_addr), ret);
sock_release(sock); sock_release(sock);
con->error_msg = "connect error";
return ret; return ret;
} }
...@@ -2145,12 +2143,10 @@ static int process_connect(struct ceph_connection *con) ...@@ -2145,12 +2143,10 @@ static int process_connect(struct ceph_connection *con)
* to WAIT. This shouldn't happen if we are the * to WAIT. This shouldn't happen if we are the
* client. * client.
*/ */
pr_err("process_connect got WAIT as client\n");
con->error_msg = "protocol error, got WAIT as client"; con->error_msg = "protocol error, got WAIT as client";
return -1; return -1;
default: default:
pr_err("connect protocol error, will retry\n");
con->error_msg = "protocol error, garbage tag during connect"; con->error_msg = "protocol error, garbage tag during connect";
return -1; return -1;
} }
...@@ -2282,8 +2278,7 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -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)); crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));
if (cpu_to_le32(crc) != con->in_hdr.crc) { if (cpu_to_le32(crc) != con->in_hdr.crc) {
pr_err("read_partial_message bad hdr " pr_err("read_partial_message bad hdr crc %u != expected %u\n",
" crc %u != expected %u\n",
crc, con->in_hdr.crc); crc, con->in_hdr.crc);
return -EBADMSG; return -EBADMSG;
} }
...@@ -2313,7 +2308,7 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -2313,7 +2308,7 @@ static int read_partial_message(struct ceph_connection *con)
pr_err("read_partial_message bad seq %lld expected %lld\n", pr_err("read_partial_message bad seq %lld expected %lld\n",
seq, con->in_seq + 1); seq, con->in_seq + 1);
con->error_msg = "bad message sequence # for incoming message"; con->error_msg = "bad message sequence # for incoming message";
return -EBADMSG; return -EBADE;
} }
/* allocate message? */ /* allocate message? */
...@@ -2660,6 +2655,8 @@ static int try_read(struct ceph_connection *con) ...@@ -2660,6 +2655,8 @@ static int try_read(struct ceph_connection *con)
switch (ret) { switch (ret) {
case -EBADMSG: case -EBADMSG:
con->error_msg = "bad crc"; con->error_msg = "bad crc";
/* fall through */
case -EBADE:
ret = -EIO; ret = -EIO;
break; break;
case -EIO: case -EIO:
...@@ -2838,7 +2835,8 @@ static void con_work(struct work_struct *work) ...@@ -2838,7 +2835,8 @@ static void con_work(struct work_struct *work)
if (ret < 0) { if (ret < 0) {
if (ret == -EAGAIN) if (ret == -EAGAIN)
continue; continue;
con->error_msg = "socket error on read"; if (!con->error_msg)
con->error_msg = "socket error on read";
fault = true; fault = true;
break; break;
} }
...@@ -2847,7 +2845,8 @@ static void con_work(struct work_struct *work) ...@@ -2847,7 +2845,8 @@ static void con_work(struct work_struct *work)
if (ret < 0) { if (ret < 0) {
if (ret == -EAGAIN) if (ret == -EAGAIN)
continue; continue;
con->error_msg = "socket error on write"; if (!con->error_msg)
con->error_msg = "socket error on write";
fault = true; fault = true;
} }
...@@ -2869,11 +2868,13 @@ static void con_work(struct work_struct *work) ...@@ -2869,11 +2868,13 @@ static void con_work(struct work_struct *work)
*/ */
static void con_fault(struct ceph_connection *con) 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", 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));
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 && 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);
...@@ -3295,8 +3296,8 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip) ...@@ -3295,8 +3296,8 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
*/ */
if (*skip) if (*skip)
return 0; return 0;
con->error_msg = "error allocating memory for incoming message";
con->error_msg = "error allocating memory for incoming message";
return -ENOMEM; return -ENOMEM;
} }
memcpy(&con->in_msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); memcpy(&con->in_msg->hdr, &con->in_hdr, sizeof(con->in_hdr));
......
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