···264264#define BASE_DELAY_INTERVAL (HZ / 4)265265#define MAX_DELAY_INTERVAL (15 * HZ)266266267267+struct ceph_connection_v1_info {268268+ struct kvec out_kvec[8], /* sending header/footer data */269269+ *out_kvec_cur;270270+ int out_kvec_left; /* kvec's left in out_kvec */271271+ int out_skip; /* skip this many bytes */272272+ int out_kvec_bytes; /* total bytes left */273273+ bool out_more; /* there is more data after the kvecs */274274+ bool out_msg_done;275275+276276+ struct ceph_auth_handshake *auth;277277+ int auth_retry; /* true if we need a newer authorizer */278278+279279+ /* connection negotiation temps */280280+ u8 in_banner[CEPH_BANNER_MAX_LEN];281281+ struct ceph_entity_addr actual_peer_addr;282282+ struct ceph_entity_addr peer_addr_for_me;283283+ struct ceph_msg_connect out_connect;284284+ struct ceph_msg_connect_reply in_reply;285285+286286+ int in_base_pos; /* bytes read */287287+288288+ /* message in temps */289289+ u8 in_tag; /* protocol control byte */290290+ struct ceph_msg_header in_hdr;291291+ __le64 in_temp_ack; /* for reading an ack */292292+293293+ /* message out temps */294294+ struct ceph_msg_header out_hdr;295295+ __le64 out_temp_ack; /* for writing an ack */296296+ struct ceph_timespec out_temp_keepalive2; /* for writing keepalive2297297+ stamp */298298+299299+ u32 connect_seq; /* identify the most recent connection300300+ attempt for this session */301301+ u32 peer_global_seq; /* peer's global seq for this connection */302302+};303303+267304/*268305 * A single connection with another host.269306 *···318281 int state; /* CEPH_CON_S_* */319282 atomic_t sock_state;320283 struct socket *sock;321321- struct ceph_entity_addr peer_addr; /* peer address */322322- struct ceph_entity_addr peer_addr_for_me;323284324285 unsigned long flags; /* CEPH_CON_F_* */325286 const char *error_msg; /* error message, if any */326287327288 struct ceph_entity_name peer_name; /* peer name */328328-289289+ struct ceph_entity_addr peer_addr; /* peer address */329290 u64 peer_features;330330- u32 connect_seq; /* identify the most recent connection331331- attempt for this connection, client */332332- u32 peer_global_seq; /* peer's global seq for this connection */333333-334334- struct ceph_auth_handshake *auth;335335- int auth_retry; /* true if we need a newer authorizer */336291337292 struct mutex mutex;338293···335306336307 u64 in_seq, in_seq_acked; /* last message received, acked */337308338338- /* connection negotiation temps */339339- char in_banner[CEPH_BANNER_MAX_LEN];340340- struct ceph_msg_connect out_connect;341341- struct ceph_msg_connect_reply in_reply;342342- struct ceph_entity_addr actual_peer_addr;343343-344344- /* message out temps */345345- struct ceph_msg_header out_hdr;309309+ struct ceph_msg *in_msg;346310 struct ceph_msg *out_msg; /* sending message (== tail of347311 out_sent) */348348- bool out_msg_done;349312350350- struct kvec out_kvec[8], /* sending header/footer data */351351- *out_kvec_cur;352352- int out_kvec_left; /* kvec's left in out_kvec */353353- int out_skip; /* skip this many bytes */354354- int out_kvec_bytes; /* total bytes left */355355- int out_more; /* there is more data after the kvecs */356356- __le64 out_temp_ack; /* for writing an ack */357357- struct ceph_timespec out_temp_keepalive2; /* for writing keepalive2358358- stamp */359359-360360- /* message in temps */361361- struct ceph_msg_header in_hdr;362362- struct ceph_msg *in_msg;363313 u32 in_front_crc, in_middle_crc, in_data_crc; /* calculated crc */364364-365365- char in_tag; /* protocol control byte */366366- int in_base_pos; /* bytes read */367367- __le64 in_temp_ack; /* for reading an ack */368314369315 struct timespec64 last_keepalive_ack; /* keepalive2 ack stamp */370316371317 struct delayed_work work; /* send|recv work */372318 unsigned long delay; /* current delay interval */319319+320320+ struct ceph_connection_v1_info v1;373321};374322375323extern struct page *ceph_zero_page;
+4-4
net/ceph/messenger.c
···14481448 * in case we faulted due to authentication, invalidate our14491449 * current tickets so that we can get new ones.14501450 */14511451- if (con->auth_retry) {14521452- dout("auth_retry %d, invalidating\n", con->auth_retry);14511451+ if (con->v1.auth_retry) {14521452+ dout("auth_retry %d, invalidating\n", con->v1.auth_retry);14531453 if (con->ops->invalidate_authorizer)14541454 con->ops->invalidate_authorizer(con);14551455- con->auth_retry = 0;14551455+ con->v1.auth_retry = 0;14561456 }1457145714581458 if (con->ops->fault)···16311631 if (con->state == CEPH_CON_S_STANDBY) {16321632 dout("clear_standby %p and ++connect_seq\n", con);16331633 con->state = CEPH_CON_S_PREOPEN;16341634- con->connect_seq++;16341634+ con->v1.connect_seq++;16351635 WARN_ON(ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING));16361636 WARN_ON(ceph_con_flag_test(con, CEPH_CON_F_KEEPALIVE_PENDING));16371637 }
+212-208
net/ceph/messenger_v1.c
···110110111111static void con_out_kvec_reset(struct ceph_connection *con)112112{113113- BUG_ON(con->out_skip);113113+ BUG_ON(con->v1.out_skip);114114115115- con->out_kvec_left = 0;116116- con->out_kvec_bytes = 0;117117- con->out_kvec_cur = &con->out_kvec[0];115115+ con->v1.out_kvec_left = 0;116116+ con->v1.out_kvec_bytes = 0;117117+ con->v1.out_kvec_cur = &con->v1.out_kvec[0];118118}119119120120static void con_out_kvec_add(struct ceph_connection *con,121121 size_t size, void *data)122122{123123- int index = con->out_kvec_left;123123+ int index = con->v1.out_kvec_left;124124125125- BUG_ON(con->out_skip);126126- BUG_ON(index >= ARRAY_SIZE(con->out_kvec));125125+ BUG_ON(con->v1.out_skip);126126+ BUG_ON(index >= ARRAY_SIZE(con->v1.out_kvec));127127128128- con->out_kvec[index].iov_len = size;129129- con->out_kvec[index].iov_base = data;130130- con->out_kvec_left++;131131- con->out_kvec_bytes += size;128128+ con->v1.out_kvec[index].iov_len = size;129129+ con->v1.out_kvec[index].iov_base = data;130130+ con->v1.out_kvec_left++;131131+ con->v1.out_kvec_bytes += size;132132}133133134134/*···138138 */139139static int con_out_kvec_skip(struct ceph_connection *con)140140{141141- int off = con->out_kvec_cur - con->out_kvec;142141 int skip = 0;143142144144- if (con->out_kvec_bytes > 0) {145145- skip = con->out_kvec[off + con->out_kvec_left - 1].iov_len;146146- BUG_ON(con->out_kvec_bytes < skip);147147- BUG_ON(!con->out_kvec_left);148148- con->out_kvec_bytes -= skip;149149- con->out_kvec_left--;143143+ if (con->v1.out_kvec_bytes > 0) {144144+ skip = con->v1.out_kvec_cur[con->v1.out_kvec_left - 1].iov_len;145145+ BUG_ON(con->v1.out_kvec_bytes < skip);146146+ BUG_ON(!con->v1.out_kvec_left);147147+ con->v1.out_kvec_bytes -= skip;148148+ con->v1.out_kvec_left--;150149 }151150152151 return skip;···185186 } else {186187 m->old_footer.flags = m->footer.flags;187188 }188188- con->out_more = m->more_to_follow;189189- con->out_msg_done = true;189189+ con->v1.out_more = m->more_to_follow;190190+ con->v1.out_msg_done = true;190191}191192192193/*···198199 u32 crc;199200200201 con_out_kvec_reset(con);201201- con->out_msg_done = false;202202+ con->v1.out_msg_done = false;202203203204 /* Sneak an ack in there first? If we can get it into the same204205 * TCP packet that's a good thing. */205206 if (con->in_seq > con->in_seq_acked) {206207 con->in_seq_acked = con->in_seq;207208 con_out_kvec_add(con, sizeof (tag_ack), &tag_ack);208208- con->out_temp_ack = cpu_to_le64(con->in_seq_acked);209209- con_out_kvec_add(con, sizeof (con->out_temp_ack),210210- &con->out_temp_ack);209209+ con->v1.out_temp_ack = cpu_to_le64(con->in_seq_acked);210210+ con_out_kvec_add(con, sizeof(con->v1.out_temp_ack),211211+ &con->v1.out_temp_ack);211212 }212213213214 ceph_con_get_out_msg(con);···222223223224 /* tag + hdr + front + middle */224225 con_out_kvec_add(con, sizeof (tag_msg), &tag_msg);225225- con_out_kvec_add(con, sizeof(con->out_hdr), &con->out_hdr);226226+ con_out_kvec_add(con, sizeof(con->v1.out_hdr), &con->v1.out_hdr);226227 con_out_kvec_add(con, m->front.iov_len, m->front.iov_base);227228228229 if (m->middle)···232233 /* fill in hdr crc and finalize hdr */233234 crc = crc32c(0, &m->hdr, offsetof(struct ceph_msg_header, crc));234235 con->out_msg->hdr.crc = cpu_to_le32(crc);235235- memcpy(&con->out_hdr, &con->out_msg->hdr, sizeof(con->out_hdr));236236+ memcpy(&con->v1.out_hdr, &con->out_msg->hdr, sizeof(con->v1.out_hdr));236237237238 /* fill in front and middle crc, footer */238239 crc = crc32c(0, m->front.iov_base, m->front.iov_len);···252253 con->out_msg->footer.data_crc = 0;253254 if (m->data_length) {254255 prepare_message_data(con->out_msg, m->data_length);255255- con->out_more = 1; /* data + footer will follow */256256+ con->v1.out_more = 1; /* data + footer will follow */256257 } else {257258 /* no, queue up footer too and be done */258259 prepare_write_message_footer(con);···274275275276 con_out_kvec_add(con, sizeof (tag_ack), &tag_ack);276277277277- con->out_temp_ack = cpu_to_le64(con->in_seq_acked);278278- con_out_kvec_add(con, sizeof (con->out_temp_ack),279279- &con->out_temp_ack);278278+ con->v1.out_temp_ack = cpu_to_le64(con->in_seq_acked);279279+ con_out_kvec_add(con, sizeof(con->v1.out_temp_ack),280280+ &con->v1.out_temp_ack);280281281281- con->out_more = 1; /* more will follow.. eventually.. */282282+ con->v1.out_more = 1; /* more will follow.. eventually.. */282283 ceph_con_flag_set(con, CEPH_CON_F_WRITE_PENDING);283284}284285···293294294295 con_out_kvec_reset(con);295296296296- con->out_temp_ack = cpu_to_le64(con->in_seq_acked);297297- con_out_kvec_add(con, sizeof (con->out_temp_ack),298298- &con->out_temp_ack);297297+ con->v1.out_temp_ack = cpu_to_le64(con->in_seq_acked);298298+ con_out_kvec_add(con, sizeof(con->v1.out_temp_ack),299299+ &con->v1.out_temp_ack);299300300301 ceph_con_flag_set(con, CEPH_CON_F_WRITE_PENDING);301302}···312313313314 ktime_get_real_ts64(&now);314315 con_out_kvec_add(con, sizeof(tag_keepalive2), &tag_keepalive2);315315- ceph_encode_timespec64(&con->out_temp_keepalive2, &now);316316- con_out_kvec_add(con, sizeof(con->out_temp_keepalive2),317317- &con->out_temp_keepalive2);316316+ ceph_encode_timespec64(&con->v1.out_temp_keepalive2, &now);317317+ con_out_kvec_add(con, sizeof(con->v1.out_temp_keepalive2),318318+ &con->v1.out_temp_keepalive2);318319 } else {319320 con_out_kvec_add(con, sizeof(tag_keepalive), &tag_keepalive);320321 }···331332 int auth_proto;332333333334 if (!con->ops->get_authorizer) {334334- con->auth = NULL;335335- con->out_connect.authorizer_protocol = CEPH_AUTH_UNKNOWN;336336- con->out_connect.authorizer_len = 0;335335+ con->v1.auth = NULL;336336+ con->v1.out_connect.authorizer_protocol = CEPH_AUTH_UNKNOWN;337337+ con->v1.out_connect.authorizer_len = 0;337338 return 0;338339 }339340340340- auth = con->ops->get_authorizer(con, &auth_proto, con->auth_retry);341341+ auth = con->ops->get_authorizer(con, &auth_proto, con->v1.auth_retry);341342 if (IS_ERR(auth))342343 return PTR_ERR(auth);343344344344- con->auth = auth;345345- con->out_connect.authorizer_protocol = cpu_to_le32(auth_proto);346346- con->out_connect.authorizer_len = cpu_to_le32(auth->authorizer_buf_len);345345+ con->v1.auth = auth;346346+ con->v1.out_connect.authorizer_protocol = cpu_to_le32(auth_proto);347347+ con->v1.out_connect.authorizer_len =348348+ cpu_to_le32(auth->authorizer_buf_len);347349 return 0;348350}349351···357357 con_out_kvec_add(con, sizeof (con->msgr->my_enc_addr),358358 &con->msgr->my_enc_addr);359359360360- con->out_more = 0;360360+ con->v1.out_more = 0;361361 ceph_con_flag_set(con, CEPH_CON_F_WRITE_PENDING);362362}363363364364static void __prepare_write_connect(struct ceph_connection *con)365365{366366- con_out_kvec_add(con, sizeof(con->out_connect), &con->out_connect);367367- if (con->auth)368368- con_out_kvec_add(con, con->auth->authorizer_buf_len,369369- con->auth->authorizer_buf);366366+ con_out_kvec_add(con, sizeof(con->v1.out_connect),367367+ &con->v1.out_connect);368368+ if (con->v1.auth)369369+ con_out_kvec_add(con, con->v1.auth->authorizer_buf_len,370370+ con->v1.auth->authorizer_buf);370371371371- con->out_more = 0;372372+ con->v1.out_more = 0;372373 ceph_con_flag_set(con, CEPH_CON_F_WRITE_PENDING);373374}374375···394393 }395394396395 dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con,397397- con->connect_seq, global_seq, proto);396396+ con->v1.connect_seq, global_seq, proto);398397399399- con->out_connect.features =400400- cpu_to_le64(from_msgr(con->msgr)->supported_features);401401- con->out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT);402402- con->out_connect.connect_seq = cpu_to_le32(con->connect_seq);403403- con->out_connect.global_seq = cpu_to_le32(global_seq);404404- con->out_connect.protocol_version = cpu_to_le32(proto);405405- con->out_connect.flags = 0;398398+ con->v1.out_connect.features =399399+ cpu_to_le64(from_msgr(con->msgr)->supported_features);400400+ con->v1.out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT);401401+ con->v1.out_connect.connect_seq = cpu_to_le32(con->v1.connect_seq);402402+ con->v1.out_connect.global_seq = cpu_to_le32(global_seq);403403+ con->v1.out_connect.protocol_version = cpu_to_le32(proto);404404+ con->v1.out_connect.flags = 0;406405407406 ret = get_connect_authorizer(con);408407 if (ret)···422421{423422 int ret;424423425425- dout("write_partial_kvec %p %d left\n", con, con->out_kvec_bytes);426426- while (con->out_kvec_bytes > 0) {427427- ret = ceph_tcp_sendmsg(con->sock, con->out_kvec_cur,428428- con->out_kvec_left, con->out_kvec_bytes,429429- con->out_more);424424+ dout("write_partial_kvec %p %d left\n", con, con->v1.out_kvec_bytes);425425+ while (con->v1.out_kvec_bytes > 0) {426426+ ret = ceph_tcp_sendmsg(con->sock, con->v1.out_kvec_cur,427427+ con->v1.out_kvec_left,428428+ con->v1.out_kvec_bytes,429429+ con->v1.out_more);430430 if (ret <= 0)431431 goto out;432432- con->out_kvec_bytes -= ret;433433- if (con->out_kvec_bytes == 0)432432+ con->v1.out_kvec_bytes -= ret;433433+ if (!con->v1.out_kvec_bytes)434434 break; /* done */435435436436 /* account for full iov entries consumed */437437- while (ret >= con->out_kvec_cur->iov_len) {438438- BUG_ON(!con->out_kvec_left);439439- ret -= con->out_kvec_cur->iov_len;440440- con->out_kvec_cur++;441441- con->out_kvec_left--;437437+ while (ret >= con->v1.out_kvec_cur->iov_len) {438438+ BUG_ON(!con->v1.out_kvec_left);439439+ ret -= con->v1.out_kvec_cur->iov_len;440440+ con->v1.out_kvec_cur++;441441+ con->v1.out_kvec_left--;442442 }443443 /* and for a partially-consumed entry */444444 if (ret) {445445- con->out_kvec_cur->iov_len -= ret;446446- con->out_kvec_cur->iov_base += ret;445445+ con->v1.out_kvec_cur->iov_len -= ret;446446+ con->v1.out_kvec_cur->iov_base += ret;447447 }448448 }449449- con->out_kvec_left = 0;449449+ con->v1.out_kvec_left = 0;450450 ret = 1;451451out:452452 dout("write_partial_kvec %p %d left in %d kvecs ret = %d\n", con,453453- con->out_kvec_bytes, con->out_kvec_left, ret);453453+ con->v1.out_kvec_bytes, con->v1.out_kvec_left, ret);454454 return ret; /* done! */455455}456456···532530 int more = MSG_MORE | MSG_SENDPAGE_NOTLAST;533531 int ret;534532535535- dout("%s %p %d left\n", __func__, con, con->out_skip);536536- while (con->out_skip > 0) {537537- size_t size = min(con->out_skip, (int) PAGE_SIZE);533533+ dout("%s %p %d left\n", __func__, con, con->v1.out_skip);534534+ while (con->v1.out_skip > 0) {535535+ size_t size = min(con->v1.out_skip, (int)PAGE_SIZE);538536539539- if (size == con->out_skip)537537+ if (size == con->v1.out_skip)540538 more = MSG_MORE;541539 ret = ceph_tcp_sendpage(con->sock, ceph_zero_page, 0, size,542540 more);543541 if (ret <= 0)544542 goto out;545545- con->out_skip -= ret;543543+ con->v1.out_skip -= ret;546544 }547545 ret = 1;548546out:···555553static void prepare_read_banner(struct ceph_connection *con)556554{557555 dout("prepare_read_banner %p\n", con);558558- con->in_base_pos = 0;556556+ con->v1.in_base_pos = 0;559557}560558561559static void prepare_read_connect(struct ceph_connection *con)562560{563561 dout("prepare_read_connect %p\n", con);564564- con->in_base_pos = 0;562562+ con->v1.in_base_pos = 0;565563}566564567565static void prepare_read_ack(struct ceph_connection *con)568566{569567 dout("prepare_read_ack %p\n", con);570570- con->in_base_pos = 0;568568+ con->v1.in_base_pos = 0;571569}572570573571static void prepare_read_seq(struct ceph_connection *con)574572{575573 dout("prepare_read_seq %p\n", con);576576- con->in_base_pos = 0;577577- con->in_tag = CEPH_MSGR_TAG_SEQ;574574+ con->v1.in_base_pos = 0;575575+ con->v1.in_tag = CEPH_MSGR_TAG_SEQ;578576}579577580578static void prepare_read_tag(struct ceph_connection *con)581579{582580 dout("prepare_read_tag %p\n", con);583583- con->in_base_pos = 0;584584- con->in_tag = CEPH_MSGR_TAG_READY;581581+ con->v1.in_base_pos = 0;582582+ con->v1.in_tag = CEPH_MSGR_TAG_READY;585583}586584587585static void prepare_read_keepalive_ack(struct ceph_connection *con)588586{589587 dout("prepare_read_keepalive_ack %p\n", con);590590- con->in_base_pos = 0;588588+ con->v1.in_base_pos = 0;591589}592590593591/*···597595{598596 dout("prepare_read_message %p\n", con);599597 BUG_ON(con->in_msg != NULL);600600- con->in_base_pos = 0;598598+ con->v1.in_base_pos = 0;601599 con->in_front_crc = con->in_middle_crc = con->in_data_crc = 0;602600 return 0;603601}···605603static int read_partial(struct ceph_connection *con,606604 int end, int size, void *object)607605{608608- while (con->in_base_pos < end) {609609- int left = end - con->in_base_pos;606606+ while (con->v1.in_base_pos < end) {607607+ int left = end - con->v1.in_base_pos;610608 int have = size - left;611609 int ret = ceph_tcp_recvmsg(con->sock, object + have, left);612610 if (ret <= 0)613611 return ret;614614- con->in_base_pos += ret;612612+ con->v1.in_base_pos += ret;615613 }616614 return 1;617615}···625623 int end;626624 int ret;627625628628- dout("read_partial_banner %p at %d\n", con, con->in_base_pos);626626+ dout("read_partial_banner %p at %d\n", con, con->v1.in_base_pos);629627630628 /* peer's banner */631629 size = strlen(CEPH_BANNER);632630 end = size;633633- ret = read_partial(con, end, size, con->in_banner);631631+ ret = read_partial(con, end, size, con->v1.in_banner);634632 if (ret <= 0)635633 goto out;636634637637- size = sizeof (con->actual_peer_addr);635635+ size = sizeof(con->v1.actual_peer_addr);638636 end += size;639639- ret = read_partial(con, end, size, &con->actual_peer_addr);637637+ ret = read_partial(con, end, size, &con->v1.actual_peer_addr);640638 if (ret <= 0)641639 goto out;642642- ceph_decode_banner_addr(&con->actual_peer_addr);640640+ ceph_decode_banner_addr(&con->v1.actual_peer_addr);643641644644- size = sizeof (con->peer_addr_for_me);642642+ size = sizeof(con->v1.peer_addr_for_me);645643 end += size;646646- ret = read_partial(con, end, size, &con->peer_addr_for_me);644644+ ret = read_partial(con, end, size, &con->v1.peer_addr_for_me);647645 if (ret <= 0)648646 goto out;649649- ceph_decode_banner_addr(&con->peer_addr_for_me);647647+ ceph_decode_banner_addr(&con->v1.peer_addr_for_me);650648651649out:652650 return ret;···658656 int end;659657 int ret;660658661661- dout("read_partial_connect %p at %d\n", con, con->in_base_pos);659659+ dout("read_partial_connect %p at %d\n", con, con->v1.in_base_pos);662660663663- size = sizeof (con->in_reply);661661+ size = sizeof(con->v1.in_reply);664662 end = size;665665- ret = read_partial(con, end, size, &con->in_reply);663663+ ret = read_partial(con, end, size, &con->v1.in_reply);666664 if (ret <= 0)667665 goto out;668666669669- if (con->auth) {670670- size = le32_to_cpu(con->in_reply.authorizer_len);671671- if (size > con->auth->authorizer_reply_buf_len) {667667+ if (con->v1.auth) {668668+ size = le32_to_cpu(con->v1.in_reply.authorizer_len);669669+ if (size > con->v1.auth->authorizer_reply_buf_len) {672670 pr_err("authorizer reply too big: %d > %zu\n", size,673673- con->auth->authorizer_reply_buf_len);671671+ con->v1.auth->authorizer_reply_buf_len);674672 ret = -EINVAL;675673 goto out;676674 }677675678676 end += size;679677 ret = read_partial(con, end, size,680680- con->auth->authorizer_reply_buf);678678+ con->v1.auth->authorizer_reply_buf);681679 if (ret <= 0)682680 goto out;683681 }684682685683 dout("read_partial_connect %p tag %d, con_seq = %u, g_seq = %u\n",686686- con, (int)con->in_reply.tag,687687- le32_to_cpu(con->in_reply.connect_seq),688688- le32_to_cpu(con->in_reply.global_seq));684684+ con, con->v1.in_reply.tag,685685+ le32_to_cpu(con->v1.in_reply.connect_seq),686686+ le32_to_cpu(con->v1.in_reply.global_seq));689687out:690688 return ret;691689}···695693 */696694static int verify_hello(struct ceph_connection *con)697695{698698- if (memcmp(con->in_banner, CEPH_BANNER, strlen(CEPH_BANNER))) {696696+ if (memcmp(con->v1.in_banner, CEPH_BANNER, strlen(CEPH_BANNER))) {699697 pr_err("connect to %s got bad banner\n",700698 ceph_pr_addr(&con->peer_addr));701699 con->error_msg = "protocol error, bad banner";···718716 * end may not yet know their ip address, so if it's 0.0.0.0, give719717 * them the benefit of the doubt.720718 */721721- if (memcmp(&con->peer_addr, &con->actual_peer_addr,719719+ if (memcmp(&con->peer_addr, &con->v1.actual_peer_addr,722720 sizeof(con->peer_addr)) != 0 &&723723- !(ceph_addr_is_blank(&con->actual_peer_addr) &&724724- con->actual_peer_addr.nonce == con->peer_addr.nonce)) {721721+ !(ceph_addr_is_blank(&con->v1.actual_peer_addr) &&722722+ con->v1.actual_peer_addr.nonce == con->peer_addr.nonce)) {725723 pr_warn("wrong peer, want %s/%u, got %s/%u\n",726724 ceph_pr_addr(&con->peer_addr),727725 le32_to_cpu(con->peer_addr.nonce),728728- ceph_pr_addr(&con->actual_peer_addr),729729- le32_to_cpu(con->actual_peer_addr.nonce));726726+ ceph_pr_addr(&con->v1.actual_peer_addr),727727+ le32_to_cpu(con->v1.actual_peer_addr.nonce));730728 con->error_msg = "wrong peer at address";731729 return -1;732730 }···736734 */737735 if (ceph_addr_is_blank(my_addr)) {738736 memcpy(&my_addr->in_addr,739739- &con->peer_addr_for_me.in_addr,740740- sizeof(con->peer_addr_for_me.in_addr));737737+ &con->v1.peer_addr_for_me.in_addr,738738+ sizeof(con->v1.peer_addr_for_me.in_addr));741739 ceph_addr_set_port(my_addr, 0);742740 ceph_encode_my_addr(con->msgr);743741 dout("process_banner learned my addr is %s\n",···751749{752750 u64 sup_feat = from_msgr(con->msgr)->supported_features;753751 u64 req_feat = from_msgr(con->msgr)->required_features;754754- u64 server_feat = le64_to_cpu(con->in_reply.features);752752+ u64 server_feat = le64_to_cpu(con->v1.in_reply.features);755753 int ret;756754757757- dout("process_connect on %p tag %d\n", con, (int)con->in_tag);755755+ dout("process_connect on %p tag %d\n", con, con->v1.in_tag);758756759759- if (con->auth) {760760- int len = le32_to_cpu(con->in_reply.authorizer_len);757757+ if (con->v1.auth) {758758+ int len = le32_to_cpu(con->v1.in_reply.authorizer_len);761759762760 /*763761 * Any connection that defines ->get_authorizer()···766764 *767765 * See get_connect_authorizer().768766 */769769- if (con->in_reply.tag == CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER) {767767+ if (con->v1.in_reply.tag ==768768+ CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER) {770769 ret = con->ops->add_authorizer_challenge(771771- con, con->auth->authorizer_reply_buf, len);770770+ con, con->v1.auth->authorizer_reply_buf, len);772771 if (ret < 0)773772 return ret;774773···788785 }789786 }790787791791- switch (con->in_reply.tag) {788788+ switch (con->v1.in_reply.tag) {792789 case CEPH_MSGR_TAG_FEATURES:793790 pr_err("%s%lld %s feature set mismatch,"794791 " my %llx < server's %llx, missing %llx\n",···803800 " my %d != server's %d\n",804801 ENTITY_NAME(con->peer_name),805802 ceph_pr_addr(&con->peer_addr),806806- le32_to_cpu(con->out_connect.protocol_version),807807- le32_to_cpu(con->in_reply.protocol_version));803803+ le32_to_cpu(con->v1.out_connect.protocol_version),804804+ le32_to_cpu(con->v1.in_reply.protocol_version));808805 con->error_msg = "protocol version mismatch";809806 return -1;810807811808 case CEPH_MSGR_TAG_BADAUTHORIZER:812812- con->auth_retry++;809809+ con->v1.auth_retry++;813810 dout("process_connect %p got BADAUTHORIZER attempt %d\n", con,814814- con->auth_retry);815815- if (con->auth_retry == 2) {811811+ con->v1.auth_retry);812812+ if (con->v1.auth_retry == 2) {816813 con->error_msg = "connect authorization failure";817814 return -1;818815 }···832829 * dropped messages.833830 */834831 dout("process_connect got RESET peer seq %u\n",835835- le32_to_cpu(con->in_reply.connect_seq));832832+ le32_to_cpu(con->v1.in_reply.connect_seq));836833 pr_info("%s%lld %s session reset\n",837834 ENTITY_NAME(con->peer_name),838835 ceph_pr_addr(&con->peer_addr));···858855 * again with a larger value.859856 */860857 dout("process_connect got RETRY_SESSION my seq %u, peer %u\n",861861- le32_to_cpu(con->out_connect.connect_seq),862862- le32_to_cpu(con->in_reply.connect_seq));863863- con->connect_seq = le32_to_cpu(con->in_reply.connect_seq);858858+ le32_to_cpu(con->v1.out_connect.connect_seq),859859+ le32_to_cpu(con->v1.in_reply.connect_seq));860860+ con->v1.connect_seq = le32_to_cpu(con->v1.in_reply.connect_seq);864861 con_out_kvec_reset(con);865862 ret = prepare_write_connect(con);866863 if (ret < 0)···874871 * again with a larger value.875872 */876873 dout("process_connect got RETRY_GLOBAL my %u peer_gseq %u\n",877877- con->peer_global_seq,878878- le32_to_cpu(con->in_reply.global_seq));874874+ con->v1.peer_global_seq,875875+ le32_to_cpu(con->v1.in_reply.global_seq));879876 ceph_get_global_seq(con->msgr,880880- le32_to_cpu(con->in_reply.global_seq));877877+ le32_to_cpu(con->v1.in_reply.global_seq));881878 con_out_kvec_reset(con);882879 ret = prepare_write_connect(con);883880 if (ret < 0)···899896900897 WARN_ON(con->state != CEPH_CON_S_V1_CONNECT_MSG);901898 con->state = CEPH_CON_S_OPEN;902902- con->auth_retry = 0; /* we authenticated; clear flag */903903- con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq);904904- con->connect_seq++;899899+ con->v1.auth_retry = 0; /* we authenticated; clear flag */900900+ con->v1.peer_global_seq =901901+ le32_to_cpu(con->v1.in_reply.global_seq);902902+ con->v1.connect_seq++;905903 con->peer_features = server_feat;906904 dout("process_connect got READY gseq %d cseq %d (%d)\n",907907- con->peer_global_seq,908908- le32_to_cpu(con->in_reply.connect_seq),909909- con->connect_seq);910910- WARN_ON(con->connect_seq !=911911- le32_to_cpu(con->in_reply.connect_seq));905905+ con->v1.peer_global_seq,906906+ le32_to_cpu(con->v1.in_reply.connect_seq),907907+ con->v1.connect_seq);908908+ WARN_ON(con->v1.connect_seq !=909909+ le32_to_cpu(con->v1.in_reply.connect_seq));912910913913- if (con->in_reply.flags & CEPH_MSG_CONNECT_LOSSY)911911+ if (con->v1.in_reply.flags & CEPH_MSG_CONNECT_LOSSY)914912 ceph_con_flag_set(con, CEPH_CON_F_LOSSYTX);915913916914 con->delay = 0; /* reset backoff memory */917915918918- if (con->in_reply.tag == CEPH_MSGR_TAG_SEQ) {916916+ if (con->v1.in_reply.tag == CEPH_MSGR_TAG_SEQ) {919917 prepare_write_seq(con);920918 prepare_read_seq(con);921919 } else {···946942 */947943static int read_partial_ack(struct ceph_connection *con)948944{949949- int size = sizeof (con->in_temp_ack);945945+ int size = sizeof(con->v1.in_temp_ack);950946 int end = size;951947952952- return read_partial(con, end, size, &con->in_temp_ack);948948+ return read_partial(con, end, size, &con->v1.in_temp_ack);953949}954950955951/*···957953 */958954static void process_ack(struct ceph_connection *con)959955{960960- u64 ack = le64_to_cpu(con->in_temp_ack);956956+ u64 ack = le64_to_cpu(con->v1.in_temp_ack);961957962962- if (con->in_tag == CEPH_MSGR_TAG_ACK)958958+ if (con->v1.in_tag == CEPH_MSGR_TAG_ACK)963959 ceph_con_discard_sent(con, ack);964960 else965961 ceph_con_discard_requeued(con, ack);···10491045 dout("read_partial_message con %p msg %p\n", con, m);1050104610511047 /* header */10521052- size = sizeof (con->in_hdr);10481048+ size = sizeof(con->v1.in_hdr);10531049 end = size;10541054- ret = read_partial(con, end, size, &con->in_hdr);10501050+ ret = read_partial(con, end, size, &con->v1.in_hdr);10551051 if (ret <= 0)10561052 return ret;1057105310581058- crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));10591059- if (cpu_to_le32(crc) != con->in_hdr.crc) {10541054+ crc = crc32c(0, &con->v1.in_hdr, offsetof(struct ceph_msg_header, crc));10551055+ if (cpu_to_le32(crc) != con->v1.in_hdr.crc) {10601056 pr_err("read_partial_message bad hdr crc %u != expected %u\n",10611061- crc, con->in_hdr.crc);10571057+ crc, con->v1.in_hdr.crc);10621058 return -EBADMSG;10631059 }1064106010651065- front_len = le32_to_cpu(con->in_hdr.front_len);10611061+ front_len = le32_to_cpu(con->v1.in_hdr.front_len);10661062 if (front_len > CEPH_MSG_MAX_FRONT_LEN)10671063 return -EIO;10681068- middle_len = le32_to_cpu(con->in_hdr.middle_len);10641064+ middle_len = le32_to_cpu(con->v1.in_hdr.middle_len);10691065 if (middle_len > CEPH_MSG_MAX_MIDDLE_LEN)10701066 return -EIO;10711071- data_len = le32_to_cpu(con->in_hdr.data_len);10671067+ data_len = le32_to_cpu(con->v1.in_hdr.data_len);10721068 if (data_len > CEPH_MSG_MAX_DATA_LEN)10731069 return -EIO;1074107010751071 /* verify seq# */10761076- seq = le64_to_cpu(con->in_hdr.seq);10721072+ seq = le64_to_cpu(con->v1.in_hdr.seq);10771073 if ((s64)seq - (s64)con->in_seq < 1) {10781074 pr_info("skipping %s%lld %s seq %lld expected %lld\n",10791075 ENTITY_NAME(con->peer_name),10801076 ceph_pr_addr(&con->peer_addr),10811077 seq, con->in_seq + 1);10821082- con->in_base_pos = -front_len - middle_len - data_len -10831083- sizeof_footer(con);10841084- con->in_tag = CEPH_MSGR_TAG_READY;10781078+ con->v1.in_base_pos = -front_len - middle_len - data_len -10791079+ sizeof_footer(con);10801080+ con->v1.in_tag = CEPH_MSGR_TAG_READY;10851081 return 1;10861082 } else if ((s64)seq - (s64)con->in_seq > 1) {10871083 pr_err("read_partial_message bad seq %lld expected %lld\n",···10941090 if (!con->in_msg) {10951091 int skip = 0;1096109210971097- dout("got hdr type %d front %d data %d\n", con->in_hdr.type,10931093+ dout("got hdr type %d front %d data %d\n", con->v1.in_hdr.type,10981094 front_len, data_len);10991099- ret = ceph_con_in_msg_alloc(con, &con->in_hdr, &skip);10951095+ ret = ceph_con_in_msg_alloc(con, &con->v1.in_hdr, &skip);11001096 if (ret < 0)11011097 return ret;11021098···11041100 if (skip) {11051101 /* skip this message */11061102 dout("alloc_msg said skip message\n");11071107- con->in_base_pos = -front_len - middle_len - data_len -11081108- sizeof_footer(con);11091109- con->in_tag = CEPH_MSGR_TAG_READY;11031103+ con->v1.in_base_pos = -front_len - middle_len -11041104+ data_len - sizeof_footer(con);11051105+ con->v1.in_tag = CEPH_MSGR_TAG_READY;11101106 con->in_seq++;11111107 return 1;11121108 }···1218121412191215 BUG_ON(!con->sock);1220121612211221- dout("try_read tag %d in_base_pos %d\n", (int)con->in_tag,12221222- con->in_base_pos);12171217+ dout("try_read tag %d in_base_pos %d\n", con->v1.in_tag,12181218+ con->v1.in_base_pos);1223121912241220 if (con->state == CEPH_CON_S_V1_BANNER) {12251221 ret = read_partial_banner(con);···1257125312581254 WARN_ON(con->state != CEPH_CON_S_OPEN);1259125512601260- if (con->in_base_pos < 0) {12561256+ if (con->v1.in_base_pos < 0) {12611257 /*12621258 * skipping + discarding content.12631259 */12641264- ret = ceph_tcp_recvmsg(con->sock, NULL, -con->in_base_pos);12601260+ ret = ceph_tcp_recvmsg(con->sock, NULL, -con->v1.in_base_pos);12651261 if (ret <= 0)12661262 goto out;12671267- dout("skipped %d / %d bytes\n", ret, -con->in_base_pos);12681268- con->in_base_pos += ret;12691269- if (con->in_base_pos)12631263+ dout("skipped %d / %d bytes\n", ret, -con->v1.in_base_pos);12641264+ con->v1.in_base_pos += ret;12651265+ if (con->v1.in_base_pos)12701266 goto more;12711267 }12721272- if (con->in_tag == CEPH_MSGR_TAG_READY) {12681268+ if (con->v1.in_tag == CEPH_MSGR_TAG_READY) {12731269 /*12741270 * what's next?12751271 */12761276- ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1);12721272+ ret = ceph_tcp_recvmsg(con->sock, &con->v1.in_tag, 1);12771273 if (ret <= 0)12781274 goto out;12791279- dout("try_read got tag %d\n", (int)con->in_tag);12801280- switch (con->in_tag) {12751275+ dout("try_read got tag %d\n", con->v1.in_tag);12761276+ switch (con->v1.in_tag) {12811277 case CEPH_MSGR_TAG_MSG:12821278 prepare_read_message(con);12831279 break;···12951291 goto bad_tag;12961292 }12971293 }12981298- if (con->in_tag == CEPH_MSGR_TAG_MSG) {12941294+ if (con->v1.in_tag == CEPH_MSGR_TAG_MSG) {12991295 ret = read_partial_message(con);13001296 if (ret <= 0) {13011297 switch (ret) {···13111307 }13121308 goto out;13131309 }13141314- if (con->in_tag == CEPH_MSGR_TAG_READY)13101310+ if (con->v1.in_tag == CEPH_MSGR_TAG_READY)13151311 goto more;13161312 ceph_con_process_message(con);13171313 if (con->state == CEPH_CON_S_OPEN)13181314 prepare_read_tag(con);13191315 goto more;13201316 }13211321- if (con->in_tag == CEPH_MSGR_TAG_ACK ||13221322- con->in_tag == CEPH_MSGR_TAG_SEQ) {13171317+ if (con->v1.in_tag == CEPH_MSGR_TAG_ACK ||13181318+ con->v1.in_tag == CEPH_MSGR_TAG_SEQ) {13231319 /*13241320 * the final handshake seq exchange is semantically13251321 * equivalent to an ACK···13301326 process_ack(con);13311327 goto more;13321328 }13331333- if (con->in_tag == CEPH_MSGR_TAG_KEEPALIVE2_ACK) {13291329+ if (con->v1.in_tag == CEPH_MSGR_TAG_KEEPALIVE2_ACK) {13341330 ret = read_keepalive_ack(con);13351331 if (ret <= 0)13361332 goto out;···13421338 return ret;1343133913441340bad_tag:13451345- pr_err("try_read bad con->in_tag = %d\n", (int)con->in_tag);13411341+ pr_err("try_read bad tag %d\n", con->v1.in_tag);13461342 con->error_msg = "protocol error, garbage tag";13471343 ret = -1;13481344 goto out;···13731369 prepare_read_banner(con);1374137013751371 BUG_ON(con->in_msg);13761376- con->in_tag = CEPH_MSGR_TAG_READY;13721372+ con->v1.in_tag = CEPH_MSGR_TAG_READY;13771373 dout("try_write initiating connect on %p new state %d\n",13781374 con, con->state);13791375 ret = ceph_tcp_connect(con);···13841380 }1385138113861382more:13871387- dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes);13831383+ dout("try_write out_kvec_bytes %d\n", con->v1.out_kvec_bytes);13881384 BUG_ON(!con->sock);1389138513901386 /* kvec data queued? */13911391- if (con->out_kvec_left) {13871387+ if (con->v1.out_kvec_left) {13921388 ret = write_partial_kvec(con);13931389 if (ret <= 0)13941390 goto out;13951391 }13961396- if (con->out_skip) {13921392+ if (con->v1.out_skip) {13971393 ret = write_partial_skip(con);13981394 if (ret <= 0)13991395 goto out;···1401139714021398 /* msg pages? */14031399 if (con->out_msg) {14041404- if (con->out_msg_done) {14001400+ if (con->v1.out_msg_done) {14051401 ceph_msg_put(con->out_msg);14061402 con->out_msg = NULL; /* we're done with this one */14071403 goto do_next;···14501446{14511447 struct ceph_msg *msg = con->out_msg;1452144814531453- WARN_ON(con->out_skip);14491449+ WARN_ON(con->v1.out_skip);14541450 /* footer */14551455- if (con->out_msg_done) {14561456- con->out_skip += con_out_kvec_skip(con);14511451+ if (con->v1.out_msg_done) {14521452+ con->v1.out_skip += con_out_kvec_skip(con);14571453 } else {14581454 WARN_ON(!msg->data_length);14591459- con->out_skip += sizeof_footer(con);14551455+ con->v1.out_skip += sizeof_footer(con);14601456 }14611457 /* data, middle, front */14621458 if (msg->data_length)14631463- con->out_skip += msg->cursor.total_resid;14591459+ con->v1.out_skip += msg->cursor.total_resid;14641460 if (msg->middle)14651465- con->out_skip += con_out_kvec_skip(con);14661466- con->out_skip += con_out_kvec_skip(con);14611461+ con->v1.out_skip += con_out_kvec_skip(con);14621462+ con->v1.out_skip += con_out_kvec_skip(con);1467146314681464 dout("%s con %p out_kvec_bytes %d out_skip %d\n", __func__, con,14691469- con->out_kvec_bytes, con->out_skip);14651465+ con->v1.out_kvec_bytes, con->v1.out_skip);14701466}1471146714721468void ceph_con_v1_revoke_incoming(struct ceph_connection *con)14731469{14741474- unsigned int front_len = le32_to_cpu(con->in_hdr.front_len);14751475- unsigned int middle_len = le32_to_cpu(con->in_hdr.middle_len);14761476- unsigned int data_len = le32_to_cpu(con->in_hdr.data_len);14701470+ unsigned int front_len = le32_to_cpu(con->v1.in_hdr.front_len);14711471+ unsigned int middle_len = le32_to_cpu(con->v1.in_hdr.middle_len);14721472+ unsigned int data_len = le32_to_cpu(con->v1.in_hdr.data_len);1477147314781474 /* skip rest of message */14791479- con->in_base_pos = con->in_base_pos -14751475+ con->v1.in_base_pos = con->v1.in_base_pos -14801476 sizeof(struct ceph_msg_header) -14811477 front_len -14821478 middle_len -14831479 data_len -14841480 sizeof(struct ceph_msg_footer);1485148114861486- con->in_tag = CEPH_MSGR_TAG_READY;14821482+ con->v1.in_tag = CEPH_MSGR_TAG_READY;14871483 con->in_seq++;1488148414891489- dout("%s con %p in_base_pos %d\n", __func__, con, con->in_base_pos);14851485+ dout("%s con %p in_base_pos %d\n", __func__, con, con->v1.in_base_pos);14901486}1491148714921488bool ceph_con_v1_opened(struct ceph_connection *con)14931489{14941494- return con->connect_seq;14901490+ return con->v1.connect_seq;14951491}1496149214971493void ceph_con_v1_reset_session(struct ceph_connection *con)14981494{14991499- con->connect_seq = 0;15001500- con->peer_global_seq = 0;14951495+ con->v1.connect_seq = 0;14961496+ con->v1.peer_global_seq = 0;15011497}1502149815031499void ceph_con_v1_reset_protocol(struct ceph_connection *con)15041500{15051505- con->out_skip = 0;15011501+ con->v1.out_skip = 0;15061502}