libceph: clear con->out_msg on Policy::stateful_server faults
Ilya Dryomov
maintainerPATCH 1/1 libceph: clear con->out_msg on Policy::stateful_server faults
con->out_msg must be cleared on Policy::stateful_server (!CEPH_MSG_CONNECT_LOSSY) faults. Not doing so botches the reconnection attempt, because after writing the banner the messenger moves on to writing the data section of that message (either from where it got interrupted by the connection reset or from the beginning) instead of writing struct ceph_msg_connect. This results in a bizarre error message because the server sends CEPH_MSGR_TAG_BADPROTOVER but we think we wrote struct ceph_msg_connect:
libceph: mds0 (1)172.21.15.45:6828 socket error on write
ceph: mds0 reconnect start
libceph: mds0 (1)172.21.15.45:6829 socket closed (con state OPEN)
libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch, my 32 != server's 32
libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch
AFAICT this bug goes back to the dawn of the kernel client. The reason it survived for so long is that only MDS sessions are stateful and only two MDS messages have a data section:CEPH_MSG_CLIENT_RECONNECT (always, but reconnecting is rare) and CEPH_MSG_CLIENT_REQUEST (only when xattrs are involved). The connection has to get reset precisely when such message is being sent -- in this case it was the former.
--- net/ceph/messenger.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ceph/messenger.c +5 -0
@@ -2998,6 +2998,11 @@ static void con_fault(struct ceph_connection *con)ceph_msg_put (con->in_msg); con->in_msg =NULL ; } +if (con->out_msg) { +BUG_ON (con->out_msg->con != con); +ceph_msg_put (con->out_msg); + con->out_msg =NULL ; + }/* Requeue anything that hasn't been acked */ list_splice_init (&con->out_sent, &con->out_queue);
Signature · 1 line
2.19.2
Quoted 37 lines · Ilya Dryomov
con->out_msgmust be cleared onPolicy::stateful_server(!CEPH_MSG_CONNECT_LOSSY) faults. Not doing so botches the reconnection attempt, because after writing the banner the messenger moves on to writing the data section of that message (either from where it got interrupted by the connection reset or from the beginning) instead of writing structceph_msg_connect. This results in a bizarre error message because the server sendsCEPH_MSGR_TAG_BADPROTOVERbut we think we wrote structceph_msg_connect:libceph: mds0 (1)172.21.15.45:6828 socket error on write
ceph: mds0 reconnect start
libceph: mds0 (1)172.21.15.45:6829 socket closed (con state OPEN)
libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch, my 32 != server's 32
libceph: mds0 (1)172.21.15.45:6829 protocol version mismatchAFAICT this bug goes back to the dawn of the kernel client. The reason it survived for so long is that only MDS sessions are stateful and only two MDS messages have a data section:
CEPH_MSG_CLIENT_RECONNECT(always, but reconnecting is rare) andCEPH_MSG_CLIENT_REQUEST(only when xattrs are involved). The connection has to get reset precisely when such message is being sent -- in this case it was the former.Signed-off-by Ilya Dryomov <[email protected]>--- net/ceph/messenger.c | 5 +++++ 1 file changed, 5 insertions(+)net/ceph/messenger.c +0
-0@@ -2998,6 +2998,11 @@ static void con_fault(struct ceph_connection *con)ceph_msg_put (con->in_msg);
net/ceph/messenger.c static void con_fault(struct ceph_connection *con) · line 3008
Quoted 10 lines
net/ceph/messenger.c +5
-0con->in_msg =NULL ; } +if (con->out_msg) { +BUG_ON (con->out_msg->con != con); +ceph_msg_put (con->out_msg); + con->out_msg =NULL ; + }/* Requeue anything that hasn't been acked */ list_splice_init (&con->out_sent, &con->out_queue);
Nice catch, Ilya.
It might be nice to make a common helper that both reset_connection and con_fault can call to drop the in_msg/out_msg, but keeping this small for a stable patch is reasonable. Maybe that can be done as part of the msgr2 work?