Skip to content

Commit a16cb1f

Browse files
author
Sage Weil
committed
libceph: fix messenger retry
In ancient times, the messenger could both initiate and accept connections. An artifact if that was data structures to store/process an incoming ceph_msg_connect request and send an outgoing ceph_msg_connect_reply. Sadly, the negotiation code was referencing those structures and ignoring important information (like the peer's connect_seq) from the correct ones. Among other things, this fixes tight reconnect loops where the server sends RETRY_SESSION and we (the client) retries with the same connect_seq as last time. This bug pretty easily triggered by injecting socket failures on the MDS and running some fs workload like workunits/direct_io/test_sync_io. Signed-off-by: Sage Weil <sage@inktank.com>
1 parent cd43045 commit a16cb1f

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

‎include/linux/ceph/messenger.h‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,8 @@ struct ceph_connection {
172172

173173
/* connection negotiation temps */
174174
char in_banner[CEPH_BANNER_MAX_LEN];
175-
union {
176-
struct { /* outgoing connection */
177-
struct ceph_msg_connect out_connect;
178-
struct ceph_msg_connect_reply in_reply;
179-
};
180-
struct { /* incoming */
181-
struct ceph_msg_connect in_connect;
182-
struct ceph_msg_connect_reply out_reply;
183-
};
184-
};
175+
struct ceph_msg_connect out_connect;
176+
struct ceph_msg_connect_reply in_reply;
185177
struct ceph_entity_addr actual_peer_addr;
186178

187179
/* message out temps */

‎net/ceph/messenger.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ static int process_connect(struct ceph_connection *con)
15401540
* dropped messages.
15411541
*/
15421542
dout("process_connect got RESET peer seq %u\n",
1543-
le32_to_cpu(con->in_connect.connect_seq));
1543+
le32_to_cpu(con->in_reply.connect_seq));
15441544
pr_err("%s%lld %s connection reset\n",
15451545
ENTITY_NAME(con->peer_name),
15461546
ceph_pr_addr(&con->peer_addr.in_addr));
@@ -1566,10 +1566,10 @@ static int process_connect(struct ceph_connection *con)
15661566
* If we sent a smaller connect_seq than the peer has, try
15671567
* again with a larger value.
15681568
*/
1569-
dout("process_connect got RETRY my seq = %u, peer_seq = %u\n",
1569+
dout("process_connect got RETRY_SESSION my seq %u, peer %u\n",
15701570
le32_to_cpu(con->out_connect.connect_seq),
1571-
le32_to_cpu(con->in_connect.connect_seq));
1572-
con->connect_seq = le32_to_cpu(con->in_connect.connect_seq);
1571+
le32_to_cpu(con->in_reply.connect_seq));
1572+
con->connect_seq = le32_to_cpu(con->in_reply.connect_seq);
15731573
ret = prepare_write_connect(con);
15741574
if (ret < 0)
15751575
return ret;
@@ -1583,9 +1583,9 @@ static int process_connect(struct ceph_connection *con)
15831583
*/
15841584
dout("process_connect got RETRY_GLOBAL my %u peer_gseq %u\n",
15851585
con->peer_global_seq,
1586-
le32_to_cpu(con->in_connect.global_seq));
1586+
le32_to_cpu(con->in_reply.global_seq));
15871587
get_global_seq(con->msgr,
1588-
le32_to_cpu(con->in_connect.global_seq));
1588+
le32_to_cpu(con->in_reply.global_seq));
15891589
ret = prepare_write_connect(con);
15901590
if (ret < 0)
15911591
return ret;

0 commit comments

Comments
 (0)