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 3a140a0d5c
("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>
This commit is contained in:
parent
1c841a96b5
commit
67c64eb742
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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? */
|
||||
|
@ -2660,6 +2655,8 @@ more:
|
|||
switch (ret) {
|
||||
case -EBADMSG:
|
||||
con->error_msg = "bad crc";
|
||||
/* fall through */
|
||||
case -EBADE:
|
||||
ret = -EIO;
|
||||
break;
|
||||
case -EIO:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue