Lines Matching +full:dout +full:- +full:default +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0
35 if (r == -EAGAIN) in ceph_tcp_recvmsg()
51 if (r == -EAGAIN) in ceph_tcp_recvpage()
72 if (r == -EAGAIN) in ceph_tcp_sendmsg()
104 if (ret == -EAGAIN) in ceph_tcp_sendpage()
112 BUG_ON(con->v1.out_skip); in con_out_kvec_reset()
114 con->v1.out_kvec_left = 0; in con_out_kvec_reset()
115 con->v1.out_kvec_bytes = 0; in con_out_kvec_reset()
116 con->v1.out_kvec_cur = &con->v1.out_kvec[0]; in con_out_kvec_reset()
122 int index = con->v1.out_kvec_left; in con_out_kvec_add()
124 BUG_ON(con->v1.out_skip); in con_out_kvec_add()
125 BUG_ON(index >= ARRAY_SIZE(con->v1.out_kvec)); in con_out_kvec_add()
127 con->v1.out_kvec[index].iov_len = size; in con_out_kvec_add()
128 con->v1.out_kvec[index].iov_base = data; in con_out_kvec_add()
129 con->v1.out_kvec_left++; in con_out_kvec_add()
130 con->v1.out_kvec_bytes += size; in con_out_kvec_add()
142 if (con->v1.out_kvec_bytes > 0) { in con_out_kvec_skip()
143 skip = con->v1.out_kvec_cur[con->v1.out_kvec_left - 1].iov_len; in con_out_kvec_skip()
144 BUG_ON(con->v1.out_kvec_bytes < skip); in con_out_kvec_skip()
145 BUG_ON(!con->v1.out_kvec_left); in con_out_kvec_skip()
146 con->v1.out_kvec_bytes -= skip; in con_out_kvec_skip()
147 con->v1.out_kvec_left--; in con_out_kvec_skip()
155 return (con->peer_features & CEPH_FEATURE_MSG_AUTH) ? in sizeof_footer()
163 u64 len = msg->sparse_read_total ? : data_len; in prepare_message_data()
165 ceph_msg_data_cursor_init(&msg->cursor, msg, len); in prepare_message_data()
174 struct ceph_msg *m = con->out_msg; in prepare_write_message_footer()
176 m->footer.flags |= CEPH_MSG_FOOTER_COMPLETE; in prepare_write_message_footer()
178 dout("prepare_write_message_footer %p\n", con); in prepare_write_message_footer()
179 con_out_kvec_add(con, sizeof_footer(con), &m->footer); in prepare_write_message_footer()
180 if (con->peer_features & CEPH_FEATURE_MSG_AUTH) { in prepare_write_message_footer()
181 if (con->ops->sign_message) in prepare_write_message_footer()
182 con->ops->sign_message(m); in prepare_write_message_footer()
184 m->footer.sig = 0; in prepare_write_message_footer()
186 m->old_footer.flags = m->footer.flags; in prepare_write_message_footer()
188 con->v1.out_more = m->more_to_follow; in prepare_write_message_footer()
189 con->v1.out_msg_done = true; in prepare_write_message_footer()
201 con->v1.out_msg_done = false; in prepare_write_message()
205 if (con->in_seq > con->in_seq_acked) { in prepare_write_message()
206 con->in_seq_acked = con->in_seq; in prepare_write_message()
208 con->v1.out_temp_ack = cpu_to_le64(con->in_seq_acked); in prepare_write_message()
209 con_out_kvec_add(con, sizeof(con->v1.out_temp_ack), in prepare_write_message()
210 &con->v1.out_temp_ack); in prepare_write_message()
214 m = con->out_msg; in prepare_write_message()
216 dout("prepare_write_message %p seq %lld type %d len %d+%d+%zd\n", in prepare_write_message()
217 m, con->out_seq, le16_to_cpu(m->hdr.type), in prepare_write_message()
218 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len), in prepare_write_message()
219 m->data_length); in prepare_write_message()
220 WARN_ON(m->front.iov_len != le32_to_cpu(m->hdr.front_len)); in prepare_write_message()
221 WARN_ON(m->data_length != le32_to_cpu(m->hdr.data_len)); in prepare_write_message()
225 con_out_kvec_add(con, sizeof(con->v1.out_hdr), &con->v1.out_hdr); in prepare_write_message()
226 con_out_kvec_add(con, m->front.iov_len, m->front.iov_base); in prepare_write_message()
228 if (m->middle) in prepare_write_message()
229 con_out_kvec_add(con, m->middle->vec.iov_len, in prepare_write_message()
230 m->middle->vec.iov_base); in prepare_write_message()
233 crc = crc32c(0, &m->hdr, offsetof(struct ceph_msg_header, crc)); in prepare_write_message()
234 con->out_msg->hdr.crc = cpu_to_le32(crc); in prepare_write_message()
235 memcpy(&con->v1.out_hdr, &con->out_msg->hdr, sizeof(con->v1.out_hdr)); in prepare_write_message()
238 crc = crc32c(0, m->front.iov_base, m->front.iov_len); in prepare_write_message()
239 con->out_msg->footer.front_crc = cpu_to_le32(crc); in prepare_write_message()
240 if (m->middle) { in prepare_write_message()
241 crc = crc32c(0, m->middle->vec.iov_base, in prepare_write_message()
242 m->middle->vec.iov_len); in prepare_write_message()
243 con->out_msg->footer.middle_crc = cpu_to_le32(crc); in prepare_write_message()
245 con->out_msg->footer.middle_crc = 0; in prepare_write_message()
246 dout("%s front_crc %u middle_crc %u\n", __func__, in prepare_write_message()
247 le32_to_cpu(con->out_msg->footer.front_crc), in prepare_write_message()
248 le32_to_cpu(con->out_msg->footer.middle_crc)); in prepare_write_message()
249 con->out_msg->footer.flags = 0; in prepare_write_message()
252 con->out_msg->footer.data_crc = 0; in prepare_write_message()
253 if (m->data_length) { in prepare_write_message()
254 prepare_message_data(con->out_msg, m->data_length); in prepare_write_message()
255 con->v1.out_more = 1; /* data + footer will follow */ in prepare_write_message()
269 dout("prepare_write_ack %p %llu -> %llu\n", con, in prepare_write_ack()
270 con->in_seq_acked, con->in_seq); in prepare_write_ack()
271 con->in_seq_acked = con->in_seq; in prepare_write_ack()
277 con->v1.out_temp_ack = cpu_to_le64(con->in_seq_acked); in prepare_write_ack()
278 con_out_kvec_add(con, sizeof(con->v1.out_temp_ack), in prepare_write_ack()
279 &con->v1.out_temp_ack); in prepare_write_ack()
281 con->v1.out_more = 1; /* more will follow.. eventually.. */ in prepare_write_ack()
290 dout("prepare_write_seq %p %llu -> %llu\n", con, in prepare_write_seq()
291 con->in_seq_acked, con->in_seq); in prepare_write_seq()
292 con->in_seq_acked = con->in_seq; in prepare_write_seq()
296 con->v1.out_temp_ack = cpu_to_le64(con->in_seq_acked); in prepare_write_seq()
297 con_out_kvec_add(con, sizeof(con->v1.out_temp_ack), in prepare_write_seq()
298 &con->v1.out_temp_ack); in prepare_write_seq()
308 dout("prepare_write_keepalive %p\n", con); in prepare_write_keepalive()
310 if (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2) { in prepare_write_keepalive()
315 ceph_encode_timespec64(&con->v1.out_temp_keepalive2, &now); in prepare_write_keepalive()
316 con_out_kvec_add(con, sizeof(con->v1.out_temp_keepalive2), in prepare_write_keepalive()
317 &con->v1.out_temp_keepalive2); in prepare_write_keepalive()
333 if (!con->ops->get_authorizer) { in get_connect_authorizer()
334 con->v1.auth = NULL; in get_connect_authorizer()
335 con->v1.out_connect.authorizer_protocol = CEPH_AUTH_UNKNOWN; in get_connect_authorizer()
336 con->v1.out_connect.authorizer_len = 0; in get_connect_authorizer()
340 auth = con->ops->get_authorizer(con, &auth_proto, con->v1.auth_retry); in get_connect_authorizer()
344 con->v1.auth = auth; in get_connect_authorizer()
345 con->v1.out_connect.authorizer_protocol = cpu_to_le32(auth_proto); in get_connect_authorizer()
346 con->v1.out_connect.authorizer_len = in get_connect_authorizer()
347 cpu_to_le32(auth->authorizer_buf_len); in get_connect_authorizer()
357 con_out_kvec_add(con, sizeof (con->msgr->my_enc_addr), in prepare_write_banner()
358 &con->msgr->my_enc_addr); in prepare_write_banner()
360 con->v1.out_more = 0; in prepare_write_banner()
366 con_out_kvec_add(con, sizeof(con->v1.out_connect), in __prepare_write_connect()
367 &con->v1.out_connect); in __prepare_write_connect()
368 if (con->v1.auth) in __prepare_write_connect()
369 con_out_kvec_add(con, con->v1.auth->authorizer_buf_len, in __prepare_write_connect()
370 con->v1.auth->authorizer_buf); in __prepare_write_connect()
372 con->v1.out_more = 0; in __prepare_write_connect()
378 unsigned int global_seq = ceph_get_global_seq(con->msgr, 0); in prepare_write_connect()
382 switch (con->peer_name.type) { in prepare_write_connect()
392 default: in prepare_write_connect()
396 dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con, in prepare_write_connect()
397 con->v1.connect_seq, global_seq, proto); in prepare_write_connect()
399 con->v1.out_connect.features = in prepare_write_connect()
400 cpu_to_le64(from_msgr(con->msgr)->supported_features); in prepare_write_connect()
401 con->v1.out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT); in prepare_write_connect()
402 con->v1.out_connect.connect_seq = cpu_to_le32(con->v1.connect_seq); in prepare_write_connect()
403 con->v1.out_connect.global_seq = cpu_to_le32(global_seq); in prepare_write_connect()
404 con->v1.out_connect.protocol_version = cpu_to_le32(proto); in prepare_write_connect()
405 con->v1.out_connect.flags = 0; in prepare_write_connect()
417 * 1 -> done
418 * 0 -> socket full, but more to do
419 * <0 -> error
425 dout("write_partial_kvec %p %d left\n", con, con->v1.out_kvec_bytes); in write_partial_kvec()
426 while (con->v1.out_kvec_bytes > 0) { in write_partial_kvec()
427 ret = ceph_tcp_sendmsg(con->sock, con->v1.out_kvec_cur, in write_partial_kvec()
428 con->v1.out_kvec_left, in write_partial_kvec()
429 con->v1.out_kvec_bytes, in write_partial_kvec()
430 con->v1.out_more); in write_partial_kvec()
433 con->v1.out_kvec_bytes -= ret; in write_partial_kvec()
434 if (!con->v1.out_kvec_bytes) in write_partial_kvec()
438 while (ret >= con->v1.out_kvec_cur->iov_len) { in write_partial_kvec()
439 BUG_ON(!con->v1.out_kvec_left); in write_partial_kvec()
440 ret -= con->v1.out_kvec_cur->iov_len; in write_partial_kvec()
441 con->v1.out_kvec_cur++; in write_partial_kvec()
442 con->v1.out_kvec_left--; in write_partial_kvec()
444 /* and for a partially-consumed entry */ in write_partial_kvec()
446 con->v1.out_kvec_cur->iov_len -= ret; in write_partial_kvec()
447 con->v1.out_kvec_cur->iov_base += ret; in write_partial_kvec()
450 con->v1.out_kvec_left = 0; in write_partial_kvec()
453 dout("write_partial_kvec %p %d left in %d kvecs ret = %d\n", con, in write_partial_kvec()
454 con->v1.out_kvec_bytes, con->v1.out_kvec_left, ret); in write_partial_kvec()
461 * 1 -> done, footer is now queued in out_kvec[].
462 * 0 -> socket full, but more to do
463 * <0 -> error
467 struct ceph_msg *msg = con->out_msg; in write_partial_message_data()
468 struct ceph_msg_data_cursor *cursor = &msg->cursor; in write_partial_message_data()
469 bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC); in write_partial_message_data()
472 dout("%s %p msg %p\n", __func__, con, msg); in write_partial_message_data()
474 if (!msg->num_data_items) in write_partial_message_data()
475 return -EINVAL; in write_partial_message_data()
481 * If we are calculating the data crc (the default), we will in write_partial_message_data()
485 crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0; in write_partial_message_data()
486 while (cursor->total_resid) { in write_partial_message_data()
492 if (!cursor->resid) { in write_partial_message_data()
498 ret = ceph_tcp_sendpage(con->sock, page, page_offset, length, in write_partial_message_data()
502 msg->footer.data_crc = cpu_to_le32(crc); in write_partial_message_data()
506 if (do_datacrc && cursor->need_crc) in write_partial_message_data()
511 dout("%s %p msg %p done\n", __func__, con, msg); in write_partial_message_data()
515 msg->footer.data_crc = cpu_to_le32(crc); in write_partial_message_data()
517 msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC; in write_partial_message_data()
531 dout("%s %p %d left\n", __func__, con, con->v1.out_skip); in write_partial_skip()
532 while (con->v1.out_skip > 0) { in write_partial_skip()
533 size_t size = min(con->v1.out_skip, (int)PAGE_SIZE); in write_partial_skip()
535 ret = ceph_tcp_sendpage(con->sock, ceph_zero_page, 0, size, in write_partial_skip()
539 con->v1.out_skip -= ret; in write_partial_skip()
551 dout("prepare_read_banner %p\n", con); in prepare_read_banner()
552 con->v1.in_base_pos = 0; in prepare_read_banner()
557 dout("prepare_read_connect %p\n", con); in prepare_read_connect()
558 con->v1.in_base_pos = 0; in prepare_read_connect()
563 dout("prepare_read_ack %p\n", con); in prepare_read_ack()
564 con->v1.in_base_pos = 0; in prepare_read_ack()
569 dout("prepare_read_seq %p\n", con); in prepare_read_seq()
570 con->v1.in_base_pos = 0; in prepare_read_seq()
571 con->v1.in_tag = CEPH_MSGR_TAG_SEQ; in prepare_read_seq()
576 dout("prepare_read_tag %p\n", con); in prepare_read_tag()
577 con->v1.in_base_pos = 0; in prepare_read_tag()
578 con->v1.in_tag = CEPH_MSGR_TAG_READY; in prepare_read_tag()
583 dout("prepare_read_keepalive_ack %p\n", con); in prepare_read_keepalive_ack()
584 con->v1.in_base_pos = 0; in prepare_read_keepalive_ack()
592 dout("prepare_read_message %p\n", con); in prepare_read_message()
593 BUG_ON(con->in_msg != NULL); in prepare_read_message()
594 con->v1.in_base_pos = 0; in prepare_read_message()
595 con->in_front_crc = con->in_middle_crc = con->in_data_crc = 0; in prepare_read_message()
602 while (con->v1.in_base_pos < end) { in read_partial()
603 int left = end - con->v1.in_base_pos; in read_partial()
604 int have = size - left; in read_partial()
605 int ret = ceph_tcp_recvmsg(con->sock, object + have, left); in read_partial()
608 con->v1.in_base_pos += ret; in read_partial()
614 * Read all or part of the connect-side handshake on a new connection
622 dout("read_partial_banner %p at %d\n", con, con->v1.in_base_pos); in read_partial_banner()
627 ret = read_partial(con, end, size, con->v1.in_banner); in read_partial_banner()
631 size = sizeof(con->v1.actual_peer_addr); in read_partial_banner()
633 ret = read_partial(con, end, size, &con->v1.actual_peer_addr); in read_partial_banner()
636 ceph_decode_banner_addr(&con->v1.actual_peer_addr); in read_partial_banner()
638 size = sizeof(con->v1.peer_addr_for_me); in read_partial_banner()
640 ret = read_partial(con, end, size, &con->v1.peer_addr_for_me); in read_partial_banner()
643 ceph_decode_banner_addr(&con->v1.peer_addr_for_me); in read_partial_banner()
655 dout("read_partial_connect %p at %d\n", con, con->v1.in_base_pos); in read_partial_connect()
657 size = sizeof(con->v1.in_reply); in read_partial_connect()
659 ret = read_partial(con, end, size, &con->v1.in_reply); in read_partial_connect()
663 if (con->v1.auth) { in read_partial_connect()
664 size = le32_to_cpu(con->v1.in_reply.authorizer_len); in read_partial_connect()
665 if (size > con->v1.auth->authorizer_reply_buf_len) { in read_partial_connect()
667 con->v1.auth->authorizer_reply_buf_len); in read_partial_connect()
668 ret = -EINVAL; in read_partial_connect()
674 con->v1.auth->authorizer_reply_buf); in read_partial_connect()
679 dout("read_partial_connect %p tag %d, con_seq = %u, g_seq = %u\n", in read_partial_connect()
680 con, con->v1.in_reply.tag, in read_partial_connect()
681 le32_to_cpu(con->v1.in_reply.connect_seq), in read_partial_connect()
682 le32_to_cpu(con->v1.in_reply.global_seq)); in read_partial_connect()
692 if (memcmp(con->v1.in_banner, CEPH_BANNER, strlen(CEPH_BANNER))) { in verify_hello()
694 ceph_pr_addr(&con->peer_addr)); in verify_hello()
695 con->error_msg = "protocol error, bad banner"; in verify_hello()
696 return -1; in verify_hello()
703 struct ceph_entity_addr *my_addr = &con->msgr->inst.addr; in process_banner()
705 dout("process_banner on %p\n", con); in process_banner()
708 return -1; in process_banner()
715 if (memcmp(&con->peer_addr, &con->v1.actual_peer_addr, in process_banner()
716 sizeof(con->peer_addr)) != 0 && in process_banner()
717 !(ceph_addr_is_blank(&con->v1.actual_peer_addr) && in process_banner()
718 con->v1.actual_peer_addr.nonce == con->peer_addr.nonce)) { in process_banner()
720 ceph_pr_addr(&con->peer_addr), in process_banner()
721 le32_to_cpu(con->peer_addr.nonce), in process_banner()
722 ceph_pr_addr(&con->v1.actual_peer_addr), in process_banner()
723 le32_to_cpu(con->v1.actual_peer_addr.nonce)); in process_banner()
724 con->error_msg = "wrong peer at address"; in process_banner()
725 return -1; in process_banner()
732 memcpy(&my_addr->in_addr, in process_banner()
733 &con->v1.peer_addr_for_me.in_addr, in process_banner()
734 sizeof(con->v1.peer_addr_for_me.in_addr)); in process_banner()
736 ceph_encode_my_addr(con->msgr); in process_banner()
737 dout("process_banner learned my addr is %s\n", in process_banner()
746 u64 sup_feat = from_msgr(con->msgr)->supported_features; in process_connect()
747 u64 req_feat = from_msgr(con->msgr)->required_features; in process_connect()
748 u64 server_feat = le64_to_cpu(con->v1.in_reply.features); in process_connect()
751 dout("process_connect on %p tag %d\n", con, con->v1.in_tag); in process_connect()
753 if (con->v1.auth) { in process_connect()
754 int len = le32_to_cpu(con->v1.in_reply.authorizer_len); in process_connect()
757 * Any connection that defines ->get_authorizer() in process_connect()
758 * should also define ->add_authorizer_challenge() and in process_connect()
759 * ->verify_authorizer_reply(). in process_connect()
763 if (con->v1.in_reply.tag == in process_connect()
765 ret = con->ops->add_authorizer_challenge( in process_connect()
766 con, con->v1.auth->authorizer_reply_buf, len); in process_connect()
777 ret = con->ops->verify_authorizer_reply(con); in process_connect()
779 con->error_msg = "bad authorize reply"; in process_connect()
785 switch (con->v1.in_reply.tag) { in process_connect()
789 ENTITY_NAME(con->peer_name), in process_connect()
790 ceph_pr_addr(&con->peer_addr), in process_connect()
792 con->error_msg = "missing required protocol features"; in process_connect()
793 return -1; in process_connect()
798 ENTITY_NAME(con->peer_name), in process_connect()
799 ceph_pr_addr(&con->peer_addr), in process_connect()
800 le32_to_cpu(con->v1.out_connect.protocol_version), in process_connect()
801 le32_to_cpu(con->v1.in_reply.protocol_version)); in process_connect()
802 con->error_msg = "protocol version mismatch"; in process_connect()
803 return -1; in process_connect()
806 con->v1.auth_retry++; in process_connect()
807 dout("process_connect %p got BADAUTHORIZER attempt %d\n", con, in process_connect()
808 con->v1.auth_retry); in process_connect()
809 if (con->v1.auth_retry == 2) { in process_connect()
810 con->error_msg = "connect authorization failure"; in process_connect()
811 return -1; in process_connect()
828 dout("process_connect got RESET peer seq %u\n", in process_connect()
829 le32_to_cpu(con->v1.in_reply.connect_seq)); in process_connect()
831 ENTITY_NAME(con->peer_name), in process_connect()
832 ceph_pr_addr(&con->peer_addr)); in process_connect()
841 mutex_unlock(&con->mutex); in process_connect()
842 if (con->ops->peer_reset) in process_connect()
843 con->ops->peer_reset(con); in process_connect()
844 mutex_lock(&con->mutex); in process_connect()
845 if (con->state != CEPH_CON_S_V1_CONNECT_MSG) in process_connect()
846 return -EAGAIN; in process_connect()
854 dout("process_connect got RETRY_SESSION my seq %u, peer %u\n", in process_connect()
855 le32_to_cpu(con->v1.out_connect.connect_seq), in process_connect()
856 le32_to_cpu(con->v1.in_reply.connect_seq)); in process_connect()
857 con->v1.connect_seq = le32_to_cpu(con->v1.in_reply.connect_seq); in process_connect()
870 dout("process_connect got RETRY_GLOBAL my %u peer_gseq %u\n", in process_connect()
871 con->v1.peer_global_seq, in process_connect()
872 le32_to_cpu(con->v1.in_reply.global_seq)); in process_connect()
873 ceph_get_global_seq(con->msgr, in process_connect()
874 le32_to_cpu(con->v1.in_reply.global_seq)); in process_connect()
887 ENTITY_NAME(con->peer_name), in process_connect()
888 ceph_pr_addr(&con->peer_addr), in process_connect()
890 con->error_msg = "missing required protocol features"; in process_connect()
891 return -1; in process_connect()
894 WARN_ON(con->state != CEPH_CON_S_V1_CONNECT_MSG); in process_connect()
895 con->state = CEPH_CON_S_OPEN; in process_connect()
896 con->v1.auth_retry = 0; /* we authenticated; clear flag */ in process_connect()
897 con->v1.peer_global_seq = in process_connect()
898 le32_to_cpu(con->v1.in_reply.global_seq); in process_connect()
899 con->v1.connect_seq++; in process_connect()
900 con->peer_features = server_feat; in process_connect()
901 dout("process_connect got READY gseq %d cseq %d (%d)\n", in process_connect()
902 con->v1.peer_global_seq, in process_connect()
903 le32_to_cpu(con->v1.in_reply.connect_seq), in process_connect()
904 con->v1.connect_seq); in process_connect()
905 WARN_ON(con->v1.connect_seq != in process_connect()
906 le32_to_cpu(con->v1.in_reply.connect_seq)); in process_connect()
908 if (con->v1.in_reply.flags & CEPH_MSG_CONNECT_LOSSY) in process_connect()
911 con->delay = 0; /* reset backoff memory */ in process_connect()
913 if (con->v1.in_reply.tag == CEPH_MSGR_TAG_SEQ) { in process_connect()
928 con->error_msg = "protocol error, got WAIT as client"; in process_connect()
929 return -1; in process_connect()
931 default: in process_connect()
932 con->error_msg = "protocol error, garbage tag during connect"; in process_connect()
933 return -1; in process_connect()
943 int size = sizeof(con->v1.in_temp_ack); in read_partial_ack()
946 return read_partial(con, end, size, &con->v1.in_temp_ack); in read_partial_ack()
954 u64 ack = le64_to_cpu(con->v1.in_temp_ack); in process_ack()
956 if (con->v1.in_tag == CEPH_MSGR_TAG_ACK) in process_ack()
972 while (section->iov_len < sec_len) { in read_partial_message_chunk()
973 BUG_ON(section->iov_base == NULL); in read_partial_message_chunk()
974 left = sec_len - section->iov_len; in read_partial_message_chunk()
975 ret = ceph_tcp_recvmsg(con->sock, (char *)section->iov_base + in read_partial_message_chunk()
976 section->iov_len, left); in read_partial_message_chunk()
979 section->iov_len += ret; in read_partial_message_chunk()
981 if (section->iov_len == sec_len) in read_partial_message_chunk()
982 *crc = crc32c(*crc, section->iov_base, section->iov_len); in read_partial_message_chunk()
997 struct ceph_msg_data_cursor *cursor = &con->in_msg->cursor; in read_partial_sparse_msg_extent()
998 bool do_bounce = ceph_test_opt(from_msgr(con->msgr), RXBOUNCE); in read_partial_sparse_msg_extent()
1000 if (do_bounce && unlikely(!con->bounce_page)) { in read_partial_sparse_msg_extent()
1001 con->bounce_page = alloc_page(GFP_NOIO); in read_partial_sparse_msg_extent()
1002 if (!con->bounce_page) { in read_partial_sparse_msg_extent()
1004 return -ENOMEM; in read_partial_sparse_msg_extent()
1008 while (cursor->sr_resid > 0) { in read_partial_sparse_msg_extent()
1014 rpage = do_bounce ? con->bounce_page : page; in read_partial_sparse_msg_extent()
1017 len = min_t(int, len, cursor->sr_resid); in read_partial_sparse_msg_extent()
1018 ret = ceph_tcp_recvpage(con->sock, rpage, (int)off, len); in read_partial_sparse_msg_extent()
1023 cursor->sr_resid -= ret; in read_partial_sparse_msg_extent()
1032 struct ceph_msg_data_cursor *cursor = &con->in_msg->cursor; in read_partial_sparse_msg_data()
1033 bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC); in read_partial_sparse_msg_data()
1038 crc = con->in_data_crc; in read_partial_sparse_msg_data()
1040 while (cursor->total_resid) { in read_partial_sparse_msg_data()
1041 if (con->v1.in_sr_kvec.iov_base) in read_partial_sparse_msg_data()
1043 &con->v1.in_sr_kvec, in read_partial_sparse_msg_data()
1044 con->v1.in_sr_len, in read_partial_sparse_msg_data()
1046 else if (cursor->sr_resid > 0) in read_partial_sparse_msg_data()
1051 memset(&con->v1.in_sr_kvec, 0, sizeof(con->v1.in_sr_kvec)); in read_partial_sparse_msg_data()
1052 ret = con->ops->sparse_read(con, cursor, in read_partial_sparse_msg_data()
1053 (char **)&con->v1.in_sr_kvec.iov_base); in read_partial_sparse_msg_data()
1058 con->v1.in_sr_len = ret; in read_partial_sparse_msg_data()
1062 con->in_data_crc = crc; in read_partial_sparse_msg_data()
1069 struct ceph_msg_data_cursor *cursor = &con->in_msg->cursor; in read_partial_msg_data()
1070 bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC); in read_partial_msg_data()
1078 crc = con->in_data_crc; in read_partial_msg_data()
1079 while (cursor->total_resid) { in read_partial_msg_data()
1080 if (!cursor->resid) { in read_partial_msg_data()
1086 ret = ceph_tcp_recvpage(con->sock, page, page_offset, length); in read_partial_msg_data()
1089 con->in_data_crc = crc; in read_partial_msg_data()
1099 con->in_data_crc = crc; in read_partial_msg_data()
1106 struct ceph_msg_data_cursor *cursor = &con->in_msg->cursor; in read_partial_msg_data_bounce()
1112 if (unlikely(!con->bounce_page)) { in read_partial_msg_data_bounce()
1113 con->bounce_page = alloc_page(GFP_NOIO); in read_partial_msg_data_bounce()
1114 if (!con->bounce_page) { in read_partial_msg_data_bounce()
1116 return -ENOMEM; in read_partial_msg_data_bounce()
1120 crc = con->in_data_crc; in read_partial_msg_data_bounce()
1121 while (cursor->total_resid) { in read_partial_msg_data_bounce()
1122 if (!cursor->resid) { in read_partial_msg_data_bounce()
1128 ret = ceph_tcp_recvpage(con->sock, con->bounce_page, 0, len); in read_partial_msg_data_bounce()
1130 con->in_data_crc = crc; in read_partial_msg_data_bounce()
1134 crc = crc32c(crc, page_address(con->bounce_page), ret); in read_partial_msg_data_bounce()
1135 memcpy_to_page(page, off, page_address(con->bounce_page), ret); in read_partial_msg_data_bounce()
1139 con->in_data_crc = crc; in read_partial_msg_data_bounce()
1149 struct ceph_msg *m = con->in_msg; in read_partial_message()
1154 bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC); in read_partial_message()
1155 bool need_sign = (con->peer_features & CEPH_FEATURE_MSG_AUTH); in read_partial_message()
1159 dout("read_partial_message con %p msg %p\n", con, m); in read_partial_message()
1162 size = sizeof(con->v1.in_hdr); in read_partial_message()
1164 ret = read_partial(con, end, size, &con->v1.in_hdr); in read_partial_message()
1168 crc = crc32c(0, &con->v1.in_hdr, offsetof(struct ceph_msg_header, crc)); in read_partial_message()
1169 if (cpu_to_le32(crc) != con->v1.in_hdr.crc) { in read_partial_message()
1171 crc, con->v1.in_hdr.crc); in read_partial_message()
1172 return -EBADMSG; in read_partial_message()
1175 front_len = le32_to_cpu(con->v1.in_hdr.front_len); in read_partial_message()
1177 return -EIO; in read_partial_message()
1178 middle_len = le32_to_cpu(con->v1.in_hdr.middle_len); in read_partial_message()
1180 return -EIO; in read_partial_message()
1181 data_len = le32_to_cpu(con->v1.in_hdr.data_len); in read_partial_message()
1183 return -EIO; in read_partial_message()
1186 seq = le64_to_cpu(con->v1.in_hdr.seq); in read_partial_message()
1187 if ((s64)seq - (s64)con->in_seq < 1) { in read_partial_message()
1189 ENTITY_NAME(con->peer_name), in read_partial_message()
1190 ceph_pr_addr(&con->peer_addr), in read_partial_message()
1191 seq, con->in_seq + 1); in read_partial_message()
1192 con->v1.in_base_pos = -front_len - middle_len - data_len - in read_partial_message()
1194 con->v1.in_tag = CEPH_MSGR_TAG_READY; in read_partial_message()
1196 } else if ((s64)seq - (s64)con->in_seq > 1) { in read_partial_message()
1198 seq, con->in_seq + 1); in read_partial_message()
1199 con->error_msg = "bad message sequence # for incoming message"; in read_partial_message()
1200 return -EBADE; in read_partial_message()
1204 if (!con->in_msg) { in read_partial_message()
1207 dout("got hdr type %d front %d data %d\n", con->v1.in_hdr.type, in read_partial_message()
1209 ret = ceph_con_in_msg_alloc(con, &con->v1.in_hdr, &skip); in read_partial_message()
1213 BUG_ON((!con->in_msg) ^ skip); in read_partial_message()
1216 dout("alloc_msg said skip message\n"); in read_partial_message()
1217 con->v1.in_base_pos = -front_len - middle_len - in read_partial_message()
1218 data_len - sizeof_footer(con); in read_partial_message()
1219 con->v1.in_tag = CEPH_MSGR_TAG_READY; in read_partial_message()
1220 con->in_seq++; in read_partial_message()
1224 BUG_ON(!con->in_msg); in read_partial_message()
1225 BUG_ON(con->in_msg->con != con); in read_partial_message()
1226 m = con->in_msg; in read_partial_message()
1227 m->front.iov_len = 0; /* haven't read it yet */ in read_partial_message()
1228 if (m->middle) in read_partial_message()
1229 m->middle->vec.iov_len = 0; in read_partial_message()
1234 prepare_message_data(con->in_msg, data_len); in read_partial_message()
1238 ret = read_partial_message_section(con, &m->front, front_len, in read_partial_message()
1239 &con->in_front_crc); in read_partial_message()
1244 if (m->middle) { in read_partial_message()
1245 ret = read_partial_message_section(con, &m->middle->vec, in read_partial_message()
1247 &con->in_middle_crc); in read_partial_message()
1254 if (!m->num_data_items) in read_partial_message()
1255 return -EIO; in read_partial_message()
1257 if (m->sparse_read_total) in read_partial_message()
1259 else if (ceph_test_opt(from_msgr(con->msgr), RXBOUNCE)) in read_partial_message()
1270 ret = read_partial(con, end, size, &m->footer); in read_partial_message()
1275 m->footer.flags = m->old_footer.flags; in read_partial_message()
1276 m->footer.sig = 0; in read_partial_message()
1279 dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n", in read_partial_message()
1280 m, front_len, m->footer.front_crc, middle_len, in read_partial_message()
1281 m->footer.middle_crc, data_len, m->footer.data_crc); in read_partial_message()
1284 if (con->in_front_crc != le32_to_cpu(m->footer.front_crc)) { in read_partial_message()
1286 m, con->in_front_crc, m->footer.front_crc); in read_partial_message()
1287 return -EBADMSG; in read_partial_message()
1289 if (con->in_middle_crc != le32_to_cpu(m->footer.middle_crc)) { in read_partial_message()
1291 m, con->in_middle_crc, m->footer.middle_crc); in read_partial_message()
1292 return -EBADMSG; in read_partial_message()
1295 (m->footer.flags & CEPH_MSG_FOOTER_NOCRC) == 0 && in read_partial_message()
1296 con->in_data_crc != le32_to_cpu(m->footer.data_crc)) { in read_partial_message()
1298 con->in_data_crc, le32_to_cpu(m->footer.data_crc)); in read_partial_message()
1299 return -EBADMSG; in read_partial_message()
1302 if (need_sign && con->ops->check_message_signature && in read_partial_message()
1303 con->ops->check_message_signature(m)) { in read_partial_message()
1305 return -EBADMSG; in read_partial_message()
1318 ceph_decode_timespec64(&con->last_keepalive_ack, &ceph_ts); in read_keepalive_ack()
1328 int ret = -1; in ceph_con_v1_try_read()
1331 dout("try_read start %p state %d\n", con, con->state); in ceph_con_v1_try_read()
1332 if (con->state != CEPH_CON_S_V1_BANNER && in ceph_con_v1_try_read()
1333 con->state != CEPH_CON_S_V1_CONNECT_MSG && in ceph_con_v1_try_read()
1334 con->state != CEPH_CON_S_OPEN) in ceph_con_v1_try_read()
1337 BUG_ON(!con->sock); in ceph_con_v1_try_read()
1339 dout("try_read tag %d in_base_pos %d\n", con->v1.in_tag, in ceph_con_v1_try_read()
1340 con->v1.in_base_pos); in ceph_con_v1_try_read()
1342 if (con->state == CEPH_CON_S_V1_BANNER) { in ceph_con_v1_try_read()
1350 con->state = CEPH_CON_S_V1_CONNECT_MSG; in ceph_con_v1_try_read()
1366 if (con->state == CEPH_CON_S_V1_CONNECT_MSG) { in ceph_con_v1_try_read()
1376 WARN_ON(con->state != CEPH_CON_S_OPEN); in ceph_con_v1_try_read()
1378 if (con->v1.in_base_pos < 0) { in ceph_con_v1_try_read()
1382 ret = ceph_tcp_recvmsg(con->sock, NULL, -con->v1.in_base_pos); in ceph_con_v1_try_read()
1385 dout("skipped %d / %d bytes\n", ret, -con->v1.in_base_pos); in ceph_con_v1_try_read()
1386 con->v1.in_base_pos += ret; in ceph_con_v1_try_read()
1387 if (con->v1.in_base_pos) in ceph_con_v1_try_read()
1390 if (con->v1.in_tag == CEPH_MSGR_TAG_READY) { in ceph_con_v1_try_read()
1394 ret = ceph_tcp_recvmsg(con->sock, &con->v1.in_tag, 1); in ceph_con_v1_try_read()
1397 dout("try_read got tag %d\n", con->v1.in_tag); in ceph_con_v1_try_read()
1398 switch (con->v1.in_tag) { in ceph_con_v1_try_read()
1410 con->state = CEPH_CON_S_CLOSED; in ceph_con_v1_try_read()
1412 default: in ceph_con_v1_try_read()
1416 if (con->v1.in_tag == CEPH_MSGR_TAG_MSG) { in ceph_con_v1_try_read()
1420 case -EBADMSG: in ceph_con_v1_try_read()
1421 con->error_msg = "bad crc/signature"; in ceph_con_v1_try_read()
1423 case -EBADE: in ceph_con_v1_try_read()
1424 ret = -EIO; in ceph_con_v1_try_read()
1426 case -EIO: in ceph_con_v1_try_read()
1427 con->error_msg = "io error"; in ceph_con_v1_try_read()
1432 if (con->v1.in_tag == CEPH_MSGR_TAG_READY) in ceph_con_v1_try_read()
1435 if (con->state == CEPH_CON_S_OPEN) in ceph_con_v1_try_read()
1439 if (con->v1.in_tag == CEPH_MSGR_TAG_ACK || in ceph_con_v1_try_read()
1440 con->v1.in_tag == CEPH_MSGR_TAG_SEQ) { in ceph_con_v1_try_read()
1451 if (con->v1.in_tag == CEPH_MSGR_TAG_KEEPALIVE2_ACK) { in ceph_con_v1_try_read()
1459 dout("try_read done on %p ret %d\n", con, ret); in ceph_con_v1_try_read()
1463 pr_err("try_read bad tag %d\n", con->v1.in_tag); in ceph_con_v1_try_read()
1464 con->error_msg = "protocol error, garbage tag"; in ceph_con_v1_try_read()
1465 ret = -1; in ceph_con_v1_try_read()
1477 dout("try_write start %p state %d\n", con, con->state); in ceph_con_v1_try_write()
1478 if (con->state != CEPH_CON_S_PREOPEN && in ceph_con_v1_try_write()
1479 con->state != CEPH_CON_S_V1_BANNER && in ceph_con_v1_try_write()
1480 con->state != CEPH_CON_S_V1_CONNECT_MSG && in ceph_con_v1_try_write()
1481 con->state != CEPH_CON_S_OPEN) in ceph_con_v1_try_write()
1485 if (con->state == CEPH_CON_S_PREOPEN) { in ceph_con_v1_try_write()
1486 BUG_ON(con->sock); in ceph_con_v1_try_write()
1487 con->state = CEPH_CON_S_V1_BANNER; in ceph_con_v1_try_write()
1493 BUG_ON(con->in_msg); in ceph_con_v1_try_write()
1494 con->v1.in_tag = CEPH_MSGR_TAG_READY; in ceph_con_v1_try_write()
1495 dout("try_write initiating connect on %p new state %d\n", in ceph_con_v1_try_write()
1496 con, con->state); in ceph_con_v1_try_write()
1499 con->error_msg = "connect error"; in ceph_con_v1_try_write()
1505 dout("try_write out_kvec_bytes %d\n", con->v1.out_kvec_bytes); in ceph_con_v1_try_write()
1506 BUG_ON(!con->sock); in ceph_con_v1_try_write()
1509 if (con->v1.out_kvec_left) { in ceph_con_v1_try_write()
1514 if (con->v1.out_skip) { in ceph_con_v1_try_write()
1521 if (con->out_msg) { in ceph_con_v1_try_write()
1522 if (con->v1.out_msg_done) { in ceph_con_v1_try_write()
1523 ceph_msg_put(con->out_msg); in ceph_con_v1_try_write()
1524 con->out_msg = NULL; /* we're done with this one */ in ceph_con_v1_try_write()
1534 dout("try_write write_partial_message_data err %d\n", in ceph_con_v1_try_write()
1541 if (con->state == CEPH_CON_S_OPEN) { in ceph_con_v1_try_write()
1548 if (!list_empty(&con->out_queue)) { in ceph_con_v1_try_write()
1552 if (con->in_seq > con->in_seq_acked) { in ceph_con_v1_try_write()
1560 dout("try_write nothing else to write.\n"); in ceph_con_v1_try_write()
1563 dout("try_write done on %p ret %d\n", con, ret); in ceph_con_v1_try_write()
1569 struct ceph_msg *msg = con->out_msg; in ceph_con_v1_revoke()
1571 WARN_ON(con->v1.out_skip); in ceph_con_v1_revoke()
1573 if (con->v1.out_msg_done) { in ceph_con_v1_revoke()
1574 con->v1.out_skip += con_out_kvec_skip(con); in ceph_con_v1_revoke()
1576 WARN_ON(!msg->data_length); in ceph_con_v1_revoke()
1577 con->v1.out_skip += sizeof_footer(con); in ceph_con_v1_revoke()
1580 if (msg->data_length) in ceph_con_v1_revoke()
1581 con->v1.out_skip += msg->cursor.total_resid; in ceph_con_v1_revoke()
1582 if (msg->middle) in ceph_con_v1_revoke()
1583 con->v1.out_skip += con_out_kvec_skip(con); in ceph_con_v1_revoke()
1584 con->v1.out_skip += con_out_kvec_skip(con); in ceph_con_v1_revoke()
1586 dout("%s con %p out_kvec_bytes %d out_skip %d\n", __func__, con, in ceph_con_v1_revoke()
1587 con->v1.out_kvec_bytes, con->v1.out_skip); in ceph_con_v1_revoke()
1592 unsigned int front_len = le32_to_cpu(con->v1.in_hdr.front_len); in ceph_con_v1_revoke_incoming()
1593 unsigned int middle_len = le32_to_cpu(con->v1.in_hdr.middle_len); in ceph_con_v1_revoke_incoming()
1594 unsigned int data_len = le32_to_cpu(con->v1.in_hdr.data_len); in ceph_con_v1_revoke_incoming()
1597 con->v1.in_base_pos = con->v1.in_base_pos - in ceph_con_v1_revoke_incoming()
1598 sizeof(struct ceph_msg_header) - in ceph_con_v1_revoke_incoming()
1599 front_len - in ceph_con_v1_revoke_incoming()
1600 middle_len - in ceph_con_v1_revoke_incoming()
1601 data_len - in ceph_con_v1_revoke_incoming()
1604 con->v1.in_tag = CEPH_MSGR_TAG_READY; in ceph_con_v1_revoke_incoming()
1605 con->in_seq++; in ceph_con_v1_revoke_incoming()
1607 dout("%s con %p in_base_pos %d\n", __func__, con, con->v1.in_base_pos); in ceph_con_v1_revoke_incoming()
1612 return con->v1.connect_seq; in ceph_con_v1_opened()
1617 con->v1.connect_seq = 0; in ceph_con_v1_reset_session()
1618 con->v1.peer_global_seq = 0; in ceph_con_v1_reset_session()
1623 con->v1.out_skip = 0; in ceph_con_v1_reset_protocol()