Lines Matching refs:v2

111 	     iov_iter_is_discard(&con->v2.in_iter) ? "discard" : "need",  in ceph_tcp_recv()
112 iov_iter_count(&con->v2.in_iter)); in ceph_tcp_recv()
113 ret = do_recvmsg(con->sock, &con->v2.in_iter); in ceph_tcp_recv()
115 iov_iter_count(&con->v2.in_iter)); in ceph_tcp_recv()
199 iov_iter_count(&con->v2.out_iter), con->v2.out_iter_sendpage); in ceph_tcp_send()
200 if (con->v2.out_iter_sendpage) in ceph_tcp_send()
201 ret = do_try_sendpage(con->sock, &con->v2.out_iter); in ceph_tcp_send()
203 ret = do_sendmsg(con->sock, &con->v2.out_iter); in ceph_tcp_send()
205 iov_iter_count(&con->v2.out_iter)); in ceph_tcp_send()
211 BUG_ON(con->v2.in_kvec_cnt >= ARRAY_SIZE(con->v2.in_kvecs)); in add_in_kvec()
212 WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter)); in add_in_kvec()
214 con->v2.in_kvecs[con->v2.in_kvec_cnt].iov_base = buf; in add_in_kvec()
215 con->v2.in_kvecs[con->v2.in_kvec_cnt].iov_len = len; in add_in_kvec()
216 con->v2.in_kvec_cnt++; in add_in_kvec()
218 con->v2.in_iter.nr_segs++; in add_in_kvec()
219 con->v2.in_iter.count += len; in add_in_kvec()
224 WARN_ON(iov_iter_count(&con->v2.in_iter)); in reset_in_kvecs()
226 con->v2.in_kvec_cnt = 0; in reset_in_kvecs()
227 iov_iter_kvec(&con->v2.in_iter, READ, con->v2.in_kvecs, 0, 0); in reset_in_kvecs()
232 WARN_ON(iov_iter_count(&con->v2.in_iter)); in set_in_bvec()
234 con->v2.in_bvec = *bv; in set_in_bvec()
235 iov_iter_bvec(&con->v2.in_iter, READ, &con->v2.in_bvec, 1, bv->bv_len); in set_in_bvec()
240 WARN_ON(iov_iter_count(&con->v2.in_iter)); in set_in_skip()
243 iov_iter_discard(&con->v2.in_iter, READ, len); in set_in_skip()
248 BUG_ON(con->v2.out_kvec_cnt >= ARRAY_SIZE(con->v2.out_kvecs)); in add_out_kvec()
249 WARN_ON(!iov_iter_is_kvec(&con->v2.out_iter)); in add_out_kvec()
250 WARN_ON(con->v2.out_zero); in add_out_kvec()
252 con->v2.out_kvecs[con->v2.out_kvec_cnt].iov_base = buf; in add_out_kvec()
253 con->v2.out_kvecs[con->v2.out_kvec_cnt].iov_len = len; in add_out_kvec()
254 con->v2.out_kvec_cnt++; in add_out_kvec()
256 con->v2.out_iter.nr_segs++; in add_out_kvec()
257 con->v2.out_iter.count += len; in add_out_kvec()
262 WARN_ON(iov_iter_count(&con->v2.out_iter)); in reset_out_kvecs()
263 WARN_ON(con->v2.out_zero); in reset_out_kvecs()
265 con->v2.out_kvec_cnt = 0; in reset_out_kvecs()
267 iov_iter_kvec(&con->v2.out_iter, WRITE, con->v2.out_kvecs, 0, 0); in reset_out_kvecs()
268 con->v2.out_iter_sendpage = false; in reset_out_kvecs()
274 WARN_ON(iov_iter_count(&con->v2.out_iter)); in set_out_bvec()
275 WARN_ON(con->v2.out_zero); in set_out_bvec()
277 con->v2.out_bvec = *bv; in set_out_bvec()
278 con->v2.out_iter_sendpage = zerocopy; in set_out_bvec()
279 iov_iter_bvec(&con->v2.out_iter, WRITE, &con->v2.out_bvec, 1, in set_out_bvec()
280 con->v2.out_bvec.bv_len); in set_out_bvec()
285 WARN_ON(iov_iter_count(&con->v2.out_iter)); in set_out_bvec_zero()
286 WARN_ON(!con->v2.out_zero); in set_out_bvec_zero()
288 con->v2.out_bvec.bv_page = ceph_zero_page; in set_out_bvec_zero()
289 con->v2.out_bvec.bv_offset = 0; in set_out_bvec_zero()
290 con->v2.out_bvec.bv_len = min(con->v2.out_zero, (int)PAGE_SIZE); in set_out_bvec_zero()
291 con->v2.out_iter_sendpage = true; in set_out_bvec_zero()
292 iov_iter_bvec(&con->v2.out_iter, WRITE, &con->v2.out_bvec, 1, in set_out_bvec_zero()
293 con->v2.out_bvec.bv_len); in set_out_bvec_zero()
299 con->v2.out_zero += len; in out_zero_add()
308 if (WARN_ON(con->v2.conn_buf_cnt >= ARRAY_SIZE(con->v2.conn_bufs))) in alloc_conn_buf()
315 con->v2.conn_bufs[con->v2.conn_buf_cnt++] = buf; in alloc_conn_buf()
321 while (con->v2.conn_buf_cnt) in free_conn_bufs()
322 kvfree(con->v2.conn_bufs[--con->v2.conn_buf_cnt]); in free_conn_bufs()
327 BUG_ON(con->v2.in_sign_kvec_cnt >= ARRAY_SIZE(con->v2.in_sign_kvecs)); in add_in_sign_kvec()
329 con->v2.in_sign_kvecs[con->v2.in_sign_kvec_cnt].iov_base = buf; in add_in_sign_kvec()
330 con->v2.in_sign_kvecs[con->v2.in_sign_kvec_cnt].iov_len = len; in add_in_sign_kvec()
331 con->v2.in_sign_kvec_cnt++; in add_in_sign_kvec()
336 con->v2.in_sign_kvec_cnt = 0; in clear_in_sign_kvecs()
341 BUG_ON(con->v2.out_sign_kvec_cnt >= ARRAY_SIZE(con->v2.out_sign_kvecs)); in add_out_sign_kvec()
343 con->v2.out_sign_kvecs[con->v2.out_sign_kvec_cnt].iov_base = buf; in add_out_sign_kvec()
344 con->v2.out_sign_kvecs[con->v2.out_sign_kvec_cnt].iov_len = len; in add_out_sign_kvec()
345 con->v2.out_sign_kvec_cnt++; in add_out_sign_kvec()
350 con->v2.out_sign_kvec_cnt = 0; in clear_out_sign_kvecs()
355 return con->v2.con_mode == CEPH_CON_MODE_SECURE; in con_secure()
555 con->v2.out_epil.late_status = aborted ? FRAME_LATE_STATUS_ABORTED : in encode_epilogue_plain()
557 cpu_to_le32s(&con->v2.out_epil.front_crc); in encode_epilogue_plain()
558 cpu_to_le32s(&con->v2.out_epil.middle_crc); in encode_epilogue_plain()
559 cpu_to_le32s(&con->v2.out_epil.data_crc); in encode_epilogue_plain()
564 memset(&con->v2.out_epil, 0, sizeof(con->v2.out_epil)); in encode_epilogue_secure()
565 con->v2.out_epil.late_status = aborted ? FRAME_LATE_STATUS_ABORTED : in encode_epilogue_secure()
629 int ctrl_len = con->v2.in_desc.fd_lens[0]; in verify_control_crc()
632 WARN_ON(con->v2.in_kvecs[0].iov_len != ctrl_len); in verify_control_crc()
633 WARN_ON(con->v2.in_kvecs[1].iov_len != CEPH_CRC_LEN); in verify_control_crc()
635 crc = crc32c(-1, con->v2.in_kvecs[0].iov_base, ctrl_len); in verify_control_crc()
636 expected_crc = get_unaligned_le32(con->v2.in_kvecs[1].iov_base); in verify_control_crc()
699 __func__, con, con->v2.con_mode, session_key_len, con_secret_len); in setup_crypto()
700 WARN_ON(con->v2.hmac_tfm || con->v2.gcm_tfm || con->v2.gcm_req); in setup_crypto()
702 if (con->v2.con_mode != CEPH_CON_MODE_CRC && in setup_crypto()
703 con->v2.con_mode != CEPH_CON_MODE_SECURE) { in setup_crypto()
704 pr_err("bad con_mode %d\n", con->v2.con_mode); in setup_crypto()
709 WARN_ON(con->v2.con_mode != CEPH_CON_MODE_CRC); in setup_crypto()
715 con->v2.hmac_tfm = crypto_alloc_shash("hmac(sha256)", 0, 0); in setup_crypto()
717 if (IS_ERR(con->v2.hmac_tfm)) { in setup_crypto()
718 ret = PTR_ERR(con->v2.hmac_tfm); in setup_crypto()
719 con->v2.hmac_tfm = NULL; in setup_crypto()
725 crypto_shash_alignmask(con->v2.hmac_tfm)); in setup_crypto()
726 ret = crypto_shash_setkey(con->v2.hmac_tfm, session_key, in setup_crypto()
733 if (con->v2.con_mode == CEPH_CON_MODE_CRC) { in setup_crypto()
744 con->v2.gcm_tfm = crypto_alloc_aead("gcm(aes)", 0, 0); in setup_crypto()
746 if (IS_ERR(con->v2.gcm_tfm)) { in setup_crypto()
747 ret = PTR_ERR(con->v2.gcm_tfm); in setup_crypto()
748 con->v2.gcm_tfm = NULL; in setup_crypto()
754 crypto_aead_alignmask(con->v2.gcm_tfm)); in setup_crypto()
755 ret = crypto_aead_setkey(con->v2.gcm_tfm, con_secret, CEPH_GCM_KEY_LEN); in setup_crypto()
761 WARN_ON(crypto_aead_ivsize(con->v2.gcm_tfm) != CEPH_GCM_IV_LEN); in setup_crypto()
762 ret = crypto_aead_setauthsize(con->v2.gcm_tfm, CEPH_GCM_TAG_LEN); in setup_crypto()
768 con->v2.gcm_req = aead_request_alloc(con->v2.gcm_tfm, GFP_NOIO); in setup_crypto()
769 if (!con->v2.gcm_req) { in setup_crypto()
774 crypto_init_wait(&con->v2.gcm_wait); in setup_crypto()
775 aead_request_set_callback(con->v2.gcm_req, CRYPTO_TFM_REQ_MAY_BACKLOG, in setup_crypto()
776 crypto_req_done, &con->v2.gcm_wait); in setup_crypto()
778 memcpy(&con->v2.in_gcm_nonce, con_secret + CEPH_GCM_KEY_LEN, in setup_crypto()
780 memcpy(&con->v2.out_gcm_nonce, in setup_crypto()
789 SHASH_DESC_ON_STACK(desc, con->v2.hmac_tfm); /* tfm arg is ignored */ in hmac_sha256()
794 con->v2.hmac_tfm, kvec_cnt); in hmac_sha256()
796 if (!con->v2.hmac_tfm) { in hmac_sha256()
801 desc->tfm = con->v2.hmac_tfm; in hmac_sha256()
808 crypto_shash_alignmask(con->v2.hmac_tfm)); in hmac_sha256()
837 nonce = encrypt ? &con->v2.out_gcm_nonce : &con->v2.in_gcm_nonce; in gcm_crypt()
839 aead_request_set_ad(con->v2.gcm_req, 0); /* no AAD */ in gcm_crypt()
840 aead_request_set_crypt(con->v2.gcm_req, src, dst, src_len, (u8 *)nonce); in gcm_crypt()
841 ret = crypto_wait_req(encrypt ? crypto_aead_encrypt(con->v2.gcm_req) : in gcm_crypt()
842 crypto_aead_decrypt(con->v2.gcm_req), in gcm_crypt()
843 &con->v2.gcm_wait); in gcm_crypt()
1013 sg_init_one(&sg, con->v2.in_buf, CEPH_PREAMBLE_SECURE_LEN); in decrypt_preamble()
1019 int ctrl_len = con->v2.in_desc.fd_lens[0]; in decrypt_control_remainder()
1024 WARN_ON(con->v2.in_kvecs[0].iov_len != rem_len); in decrypt_control_remainder()
1025 WARN_ON(con->v2.in_kvecs[1].iov_len != pt_len); in decrypt_control_remainder()
1028 sg_set_buf(&sgs[0], con->v2.in_kvecs[0].iov_base, rem_len); in decrypt_control_remainder()
1029 sg_set_buf(&sgs[1], con->v2.in_buf, pt_len); in decrypt_control_remainder()
1040 ret = setup_message_sgs(&sgt, con->in_msg, FRONT_PAD(con->v2.in_buf), in decrypt_message()
1041 MIDDLE_PAD(con->v2.in_buf), DATA_PAD(con->v2.in_buf), in decrypt_message()
1042 con->v2.in_buf, true); in decrypt_message()
1341 ret = hmac_sha256(con, con->v2.in_sign_kvecs, con->v2.in_sign_kvec_cnt, in prepare_auth_signature()
1358 WARN_ON(con->v2.server_cookie); in prepare_client_ident()
1359 WARN_ON(con->v2.connect_seq); in prepare_client_ident()
1360 WARN_ON(con->v2.peer_global_seq); in prepare_client_ident()
1362 if (!con->v2.client_cookie) { in prepare_client_ident()
1364 get_random_bytes(&con->v2.client_cookie, in prepare_client_ident()
1365 sizeof(con->v2.client_cookie)); in prepare_client_ident()
1366 } while (!con->v2.client_cookie); in prepare_client_ident()
1368 con->v2.client_cookie); in prepare_client_ident()
1371 con->v2.client_cookie); in prepare_client_ident()
1377 global_id, con->v2.global_seq, client->supported_features, in prepare_client_ident()
1378 client->required_features, con->v2.client_cookie); in prepare_client_ident()
1392 ceph_encode_64(&p, con->v2.global_seq); in prepare_client_ident()
1396 ceph_encode_64(&p, con->v2.client_cookie); in prepare_client_ident()
1408 WARN_ON(!con->v2.client_cookie); in prepare_session_reconnect()
1409 WARN_ON(!con->v2.server_cookie); in prepare_session_reconnect()
1410 WARN_ON(!con->v2.connect_seq); in prepare_session_reconnect()
1411 WARN_ON(!con->v2.peer_global_seq); in prepare_session_reconnect()
1415 con->v2.client_cookie, con->v2.server_cookie, con->v2.global_seq, in prepare_session_reconnect()
1416 con->v2.connect_seq, con->in_seq); in prepare_session_reconnect()
1427 ceph_encode_64(&p, con->v2.client_cookie); in prepare_session_reconnect()
1428 ceph_encode_64(&p, con->v2.server_cookie); in prepare_session_reconnect()
1429 ceph_encode_64(&p, con->v2.global_seq); in prepare_session_reconnect()
1430 ceph_encode_64(&p, con->v2.connect_seq); in prepare_session_reconnect()
1439 struct ceph_timespec *ts = CTRL_BODY(con->v2.out_buf); in prepare_keepalive2()
1449 return prepare_control(con, FRAME_TAG_KEEPALIVE2, con->v2.out_buf, in prepare_keepalive2()
1461 p = CTRL_BODY(con->v2.out_buf); in prepare_ack()
1465 return prepare_control(con, FRAME_TAG_ACK, con->v2.out_buf, 8); in prepare_ack()
1471 con->out_msg, aborted, con->v2.out_epil.front_crc, in prepare_epilogue_plain()
1472 con->v2.out_epil.middle_crc, con->v2.out_epil.data_crc); in prepare_epilogue_plain()
1475 add_out_kvec(con, &con->v2.out_epil, CEPH_EPILOGUE_PLAIN_LEN); in prepare_epilogue_plain()
1486 prepare_head_plain(con, con->v2.out_buf, in prepare_message_plain()
1495 con->v2.out_state = OUT_S_FINISH_MESSAGE; in prepare_message_plain()
1499 con->v2.out_epil.front_crc = -1; in prepare_message_plain()
1500 con->v2.out_epil.middle_crc = -1; in prepare_message_plain()
1501 con->v2.out_state = OUT_S_QUEUE_DATA; in prepare_message_plain()
1506 con->v2.out_epil.front_crc = crc32c(-1, msg->front.iov_base, in prepare_message_plain()
1511 con->v2.out_epil.front_crc = -1; in prepare_message_plain()
1515 con->v2.out_epil.middle_crc = in prepare_message_plain()
1519 con->v2.out_epil.middle_crc = data_len(msg) ? -1 : 0; in prepare_message_plain()
1523 con->v2.out_state = OUT_S_QUEUE_DATA; in prepare_message_plain()
1525 con->v2.out_epil.data_crc = 0; in prepare_message_plain()
1527 con->v2.out_state = OUT_S_FINISH_MESSAGE; in prepare_message_plain()
1548 ret = prepare_head_secure_small(con, con->v2.out_buf, in prepare_message_secure()
1559 con->v2.out_state = OUT_S_FINISH_MESSAGE; in prepare_message_secure()
1565 &con->v2.out_epil, false); in prepare_message_secure()
1576 WARN_ON(con->v2.out_enc_pages || con->v2.out_enc_page_cnt); in prepare_message_secure()
1577 con->v2.out_enc_pages = enc_pages; in prepare_message_secure()
1578 con->v2.out_enc_page_cnt = enc_page_cnt; in prepare_message_secure()
1579 con->v2.out_enc_resid = tail_len; in prepare_message_secure()
1580 con->v2.out_enc_i = 0; in prepare_message_secure()
1594 con->v2.out_state = OUT_S_QUEUE_ENC_PAGE; in prepare_message_secure()
1624 encode_preamble(&desc, con->v2.out_buf); in prepare_message()
1625 fill_header2(CTRL_BODY(con->v2.out_buf), &con->out_msg->hdr, in prepare_message()
1674 add_in_kvec(con, con->v2.in_buf, in prepare_read_preamble()
1677 con->v2.in_state = IN_S_HANDLE_PREAMBLE; in prepare_read_preamble()
1682 int ctrl_len = con->v2.in_desc.fd_lens[0]; in prepare_read_control()
1695 memcpy(buf, con->v2.in_buf, CEPH_PREAMBLE_LEN); in prepare_read_control()
1708 add_in_kvec(con, CTRL_BODY(con->v2.in_buf), ctrl_len); in prepare_read_control()
1710 add_in_kvec(con, con->v2.in_buf, CEPH_CRC_LEN); in prepare_read_control()
1712 con->v2.in_state = IN_S_HANDLE_CONTROL; in prepare_read_control()
1718 int ctrl_len = con->v2.in_desc.fd_lens[0]; in prepare_read_control_remainder()
1726 memcpy(buf, CTRL_BODY(con->v2.in_buf), CEPH_PREAMBLE_INLINE_LEN); in prepare_read_control_remainder()
1730 add_in_kvec(con, con->v2.in_buf, in prepare_read_control_remainder()
1732 con->v2.in_state = IN_S_HANDLE_CONTROL_REMAINDER; in prepare_read_control_remainder()
1742 ceph_msg_data_cursor_init(&con->v2.in_cursor, con->in_msg, in prepare_read_data()
1745 get_bvec_at(&con->v2.in_cursor, &bv); in prepare_read_data()
1747 con->v2.in_state = IN_S_PREPARE_READ_DATA_CONT; in prepare_read_data()
1756 con->v2.in_bvec.bv_page, in prepare_read_data_cont()
1757 con->v2.in_bvec.bv_offset, in prepare_read_data_cont()
1758 con->v2.in_bvec.bv_len); in prepare_read_data_cont()
1760 ceph_msg_data_advance(&con->v2.in_cursor, con->v2.in_bvec.bv_len); in prepare_read_data_cont()
1761 if (con->v2.in_cursor.total_resid) { in prepare_read_data_cont()
1762 get_bvec_at(&con->v2.in_cursor, &bv); in prepare_read_data_cont()
1764 WARN_ON(con->v2.in_state != IN_S_PREPARE_READ_DATA_CONT); in prepare_read_data_cont()
1775 add_in_kvec(con, DATA_PAD(con->v2.in_buf), in prepare_read_data_cont()
1777 add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_SECURE_LEN); in prepare_read_data_cont()
1779 add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_PLAIN_LEN); in prepare_read_data_cont()
1781 con->v2.in_state = IN_S_HANDLE_EPILOGUE; in prepare_read_data_cont()
1792 struct ceph_frame_desc *desc = &con->v2.in_desc; in prepare_skip_message()
1804 con->v2.in_state = IN_S_FINISH_SKIP; in prepare_skip_message()
1813 WARN_ON(con->v2.in_kvecs[0].iov_len != CEPH_BANNER_V2_PREFIX_LEN); in process_banner_prefix()
1815 p = con->v2.in_kvecs[0].iov_base; in process_banner_prefix()
1833 void *end = con->v2.in_kvecs[0].iov_base + con->v2.in_kvecs[0].iov_len; in process_banner_payload()
1840 p = con->v2.in_kvecs[0].iov_base; in process_banner_payload()
2059 ceph_decode_32_safe(&p, end, con->v2.con_mode, bad); in process_auth_done()
2063 __func__, con, global_id, con->v2.con_mode, payload_len); in process_auth_done()
2118 ret = hmac_sha256(con, con->v2.out_sign_kvecs, in process_auth_signature()
2119 con->v2.out_sign_kvec_cnt, hmac); in process_auth_signature()
2132 if (!con->v2.server_cookie) { in process_auth_signature()
2215 con->v2.peer_global_seq = global_seq; in process_server_ident()
2218 con->v2.server_cookie = cookie; in process_server_ident()
2222 WARN_ON(con->v2.server_cookie); in process_server_ident()
2224 WARN_ON(!con->v2.server_cookie); in process_server_ident()
2233 con->v2.out_state = OUT_S_GET_NEXT; in process_server_ident()
2284 con->v2.out_state = OUT_S_GET_NEXT; in process_session_reconnect_ok()
2306 WARN_ON(connect_seq <= con->v2.connect_seq); in process_session_retry()
2307 con->v2.connect_seq = connect_seq + 1; in process_session_retry()
2339 WARN_ON(global_seq <= con->v2.global_seq); in process_session_retry_global()
2340 con->v2.global_seq = ceph_get_global_seq(con->msgr, global_seq); in process_session_retry_global()
2449 int tag = con->v2.in_desc.fd_tag; in process_control()
2517 struct ceph_frame_desc *desc = &con->v2.in_desc; in process_message_header()
2576 void *end = p + con->v2.in_desc.fd_lens[0]; in __handle_control()
2580 if (con->v2.in_desc.fd_tag != FRAME_TAG_MESSAGE) in __handle_control()
2607 add_in_kvec(con, FRONT_PAD(con->v2.in_buf), in __handle_control()
2618 add_in_kvec(con, MIDDLE_PAD(con->v2.in_buf), in __handle_control()
2625 con->v2.in_state = IN_S_PREPARE_READ_DATA; in __handle_control()
2627 add_in_kvec(con, con->v2.in_buf, in __handle_control()
2630 con->v2.in_state = IN_S_HANDLE_EPILOGUE; in __handle_control()
2637 struct ceph_frame_desc *desc = &con->v2.in_desc; in handle_preamble()
2649 ret = decode_preamble(con->v2.in_buf, desc); in handle_preamble()
2668 return __handle_control(con, CTRL_BODY(con->v2.in_buf)); in handle_preamble()
2673 int ctrl_len = con->v2.in_desc.fd_lens[0]; in handle_control()
2690 memcpy(buf, con->v2.in_kvecs[0].iov_base, ctrl_len); in handle_control()
2694 return __handle_control(con, con->v2.in_kvecs[0].iov_base); in handle_control()
2710 return __handle_control(con, con->v2.in_kvecs[0].iov_base - in handle_control_remainder()
2728 ret = decode_epilogue(con->v2.in_buf, NULL, NULL, NULL); in handle_epilogue()
2734 ret = decode_epilogue(con->v2.in_buf, &front_crc, in handle_epilogue()
2757 gcm_inc_nonce(&con->v2.in_gcm_nonce); in finish_skip()
2767 con->v2.in_state); in populate_in_iter()
2768 WARN_ON(iov_iter_count(&con->v2.in_iter)); in populate_in_iter()
2777 switch (con->v2.in_state) { in populate_in_iter()
2803 WARN(1, "bad in_state %d", con->v2.in_state); in populate_in_iter()
2815 if (WARN_ON(!iov_iter_count(&con->v2.in_iter))) in populate_in_iter()
2818 iov_iter_count(&con->v2.in_iter)); in populate_in_iter()
2827 iov_iter_count(&con->v2.in_iter)); in ceph_con_v2_try_read()
2837 if (WARN_ON(!iov_iter_count(&con->v2.in_iter))) in ceph_con_v2_try_read()
2858 con->v2.out_epil.data_crc = -1; in queue_data()
2859 ceph_msg_data_cursor_init(&con->v2.out_cursor, con->out_msg, in queue_data()
2862 get_bvec_at(&con->v2.out_cursor, &bv); in queue_data()
2864 con->v2.out_state = OUT_S_QUEUE_DATA_CONT; in queue_data()
2871 con->v2.out_epil.data_crc = ceph_crc32c_page( in queue_data_cont()
2872 con->v2.out_epil.data_crc, con->v2.out_bvec.bv_page, in queue_data_cont()
2873 con->v2.out_bvec.bv_offset, con->v2.out_bvec.bv_len); in queue_data_cont()
2875 ceph_msg_data_advance(&con->v2.out_cursor, con->v2.out_bvec.bv_len); in queue_data_cont()
2876 if (con->v2.out_cursor.total_resid) { in queue_data_cont()
2877 get_bvec_at(&con->v2.out_cursor, &bv); in queue_data_cont()
2879 WARN_ON(con->v2.out_state != OUT_S_QUEUE_DATA_CONT); in queue_data_cont()
2889 con->v2.out_state = OUT_S_FINISH_MESSAGE; in queue_data_cont()
2896 dout("%s con %p i %d resid %d\n", __func__, con, con->v2.out_enc_i, in queue_enc_page()
2897 con->v2.out_enc_resid); in queue_enc_page()
2898 WARN_ON(!con->v2.out_enc_resid); in queue_enc_page()
2900 bv.bv_page = con->v2.out_enc_pages[con->v2.out_enc_i]; in queue_enc_page()
2902 bv.bv_len = min(con->v2.out_enc_resid, (int)PAGE_SIZE); in queue_enc_page()
2905 con->v2.out_enc_i++; in queue_enc_page()
2906 con->v2.out_enc_resid -= bv.bv_len; in queue_enc_page()
2908 if (con->v2.out_enc_resid) { in queue_enc_page()
2909 WARN_ON(con->v2.out_state != OUT_S_QUEUE_ENC_PAGE); in queue_enc_page()
2917 WARN_ON(con->v2.out_enc_i != con->v2.out_enc_page_cnt); in queue_enc_page()
2918 con->v2.out_state = OUT_S_FINISH_MESSAGE; in queue_enc_page()
2923 dout("%s con %p out_zero %d\n", __func__, con, con->v2.out_zero); in queue_zeros()
2925 if (con->v2.out_zero) { in queue_zeros()
2927 con->v2.out_zero -= con->v2.out_bvec.bv_len; in queue_zeros()
2928 con->v2.out_state = OUT_S_QUEUE_ZEROS; in queue_zeros()
2939 con->v2.out_state = OUT_S_FINISH_MESSAGE; in queue_zeros()
2947 if (con->v2.out_enc_pages) { in finish_message()
2948 WARN_ON(!con->v2.out_enc_page_cnt); in finish_message()
2949 ceph_release_page_vector(con->v2.out_enc_pages, in finish_message()
2950 con->v2.out_enc_page_cnt); in finish_message()
2951 con->v2.out_enc_pages = NULL; in finish_message()
2952 con->v2.out_enc_page_cnt = 0; in finish_message()
2960 con->v2.out_state = OUT_S_GET_NEXT; in finish_message()
2968 con->v2.out_state); in populate_out_iter()
2969 WARN_ON(iov_iter_count(&con->v2.out_iter)); in populate_out_iter()
2977 switch (con->v2.out_state) { in populate_out_iter()
2999 WARN(1, "bad out_state %d", con->v2.out_state); in populate_out_iter()
3003 WARN_ON(con->v2.out_state != OUT_S_GET_NEXT); in populate_out_iter()
3028 if (WARN_ON(!iov_iter_count(&con->v2.out_iter))) in populate_out_iter()
3031 iov_iter_count(&con->v2.out_iter)); in populate_out_iter()
3035 WARN_ON(iov_iter_count(&con->v2.out_iter)); in populate_out_iter()
3046 iov_iter_count(&con->v2.out_iter)); in ceph_con_v2_try_write()
3057 con->v2.global_seq = ceph_get_global_seq(con->msgr, 0); in ceph_con_v2_try_write()
3058 if (con->v2.server_cookie) in ceph_con_v2_try_write()
3059 con->v2.connect_seq++; in ceph_con_v2_try_write()
3084 if (!iov_iter_count(&con->v2.out_iter)) { in ceph_con_v2_try_write()
3133 con->v2.out_epil.front_crc = in prepare_zero_front()
3135 con->v2.out_epil.front_crc = in prepare_zero_front()
3136 crc32c_zeros(con->v2.out_epil.front_crc, resid); in prepare_zero_front()
3138 con->v2.out_epil.front_crc = crc32c_zeros(-1, resid); in prepare_zero_front()
3141 con->v2.out_iter.count -= resid; in prepare_zero_front()
3154 con->v2.out_epil.middle_crc = in prepare_zero_middle()
3156 con->v2.out_epil.middle_crc = in prepare_zero_middle()
3157 crc32c_zeros(con->v2.out_epil.middle_crc, resid); in prepare_zero_middle()
3159 con->v2.out_epil.middle_crc = crc32c_zeros(-1, resid); in prepare_zero_middle()
3162 con->v2.out_iter.count -= resid; in prepare_zero_middle()
3169 con->v2.out_epil.data_crc = crc32c_zeros(-1, data_len(con->out_msg)); in prepare_zero_data()
3179 WARN_ON(!iov_iter_is_kvec(&con->v2.out_iter)); in revoke_at_queue_data()
3180 resid = iov_iter_count(&con->v2.out_iter); in revoke_at_queue_data()
3192 WARN_ON(iov_iter_count(&con->v2.out_iter) != resid); in revoke_at_queue_data()
3193 con->v2.out_state = OUT_S_QUEUE_ZEROS; in revoke_at_queue_data()
3221 WARN_ON(!iov_iter_is_bvec(&con->v2.out_iter)); in revoke_at_queue_data_cont()
3222 resid = iov_iter_count(&con->v2.out_iter); in revoke_at_queue_data_cont()
3223 WARN_ON(!resid || resid > con->v2.out_bvec.bv_len); in revoke_at_queue_data_cont()
3224 sent = con->v2.out_bvec.bv_len - resid; in revoke_at_queue_data_cont()
3228 con->v2.out_epil.data_crc = ceph_crc32c_page( in revoke_at_queue_data_cont()
3229 con->v2.out_epil.data_crc, con->v2.out_bvec.bv_page, in revoke_at_queue_data_cont()
3230 con->v2.out_bvec.bv_offset, sent); in revoke_at_queue_data_cont()
3231 ceph_msg_data_advance(&con->v2.out_cursor, sent); in revoke_at_queue_data_cont()
3233 WARN_ON(resid > con->v2.out_cursor.total_resid); in revoke_at_queue_data_cont()
3234 con->v2.out_epil.data_crc = crc32c_zeros(con->v2.out_epil.data_crc, in revoke_at_queue_data_cont()
3235 con->v2.out_cursor.total_resid); in revoke_at_queue_data_cont()
3237 con->v2.out_iter.count -= resid; in revoke_at_queue_data_cont()
3238 out_zero_add(con, con->v2.out_cursor.total_resid); in revoke_at_queue_data_cont()
3247 WARN_ON(!iov_iter_is_kvec(&con->v2.out_iter)); in revoke_at_finish_message()
3248 resid = iov_iter_count(&con->v2.out_iter); in revoke_at_finish_message()
3268 con->v2.out_iter.count -= CEPH_EPILOGUE_PLAIN_LEN; in revoke_at_finish_message()
3269 WARN_ON(iov_iter_count(&con->v2.out_iter) != resid); in revoke_at_finish_message()
3270 con->v2.out_state = OUT_S_QUEUE_ZEROS; in revoke_at_finish_message()
3281 con->v2.out_iter.count -= CEPH_EPILOGUE_PLAIN_LEN; in revoke_at_finish_message()
3291 con->v2.out_iter.count -= CEPH_EPILOGUE_PLAIN_LEN; in revoke_at_finish_message()
3302 WARN_ON(con->v2.out_zero); in ceph_con_v2_revoke()
3305 WARN_ON(con->v2.out_state != OUT_S_QUEUE_ENC_PAGE && in ceph_con_v2_revoke()
3306 con->v2.out_state != OUT_S_FINISH_MESSAGE); in ceph_con_v2_revoke()
3311 switch (con->v2.out_state) { in ceph_con_v2_revoke()
3322 WARN(1, "bad out_state %d", con->v2.out_state); in ceph_con_v2_revoke()
3333 WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter)); in revoke_at_prepare_read_data()
3334 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_prepare_read_data()
3345 con->v2.in_iter.count -= resid; in revoke_at_prepare_read_data()
3347 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_prepare_read_data()
3356 WARN_ON(!iov_iter_is_bvec(&con->v2.in_iter)); in revoke_at_prepare_read_data_cont()
3357 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_prepare_read_data_cont()
3358 WARN_ON(!resid || resid > con->v2.in_bvec.bv_len); in revoke_at_prepare_read_data_cont()
3359 recved = con->v2.in_bvec.bv_len - resid; in revoke_at_prepare_read_data_cont()
3363 ceph_msg_data_advance(&con->v2.in_cursor, recved); in revoke_at_prepare_read_data_cont()
3364 WARN_ON(resid > con->v2.in_cursor.total_resid); in revoke_at_prepare_read_data_cont()
3373 con->v2.in_cursor.total_resid, remaining); in revoke_at_prepare_read_data_cont()
3374 con->v2.in_iter.count -= resid; in revoke_at_prepare_read_data_cont()
3375 set_in_skip(con, con->v2.in_cursor.total_resid + remaining); in revoke_at_prepare_read_data_cont()
3376 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_prepare_read_data_cont()
3383 WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter)); in revoke_at_handle_epilogue()
3384 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_handle_epilogue()
3388 con->v2.in_iter.count -= resid; in revoke_at_handle_epilogue()
3390 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_handle_epilogue()
3395 switch (con->v2.in_state) { in ceph_con_v2_revoke_incoming()
3406 WARN(1, "bad in_state %d", con->v2.in_state); in ceph_con_v2_revoke_incoming()
3413 return con->v2.peer_global_seq; in ceph_con_v2_opened()
3418 con->v2.client_cookie = 0; in ceph_con_v2_reset_session()
3419 con->v2.server_cookie = 0; in ceph_con_v2_reset_session()
3420 con->v2.global_seq = 0; in ceph_con_v2_reset_session()
3421 con->v2.connect_seq = 0; in ceph_con_v2_reset_session()
3422 con->v2.peer_global_seq = 0; in ceph_con_v2_reset_session()
3427 iov_iter_truncate(&con->v2.in_iter, 0); in ceph_con_v2_reset_protocol()
3428 iov_iter_truncate(&con->v2.out_iter, 0); in ceph_con_v2_reset_protocol()
3429 con->v2.out_zero = 0; in ceph_con_v2_reset_protocol()
3435 if (con->v2.out_enc_pages) { in ceph_con_v2_reset_protocol()
3436 WARN_ON(!con->v2.out_enc_page_cnt); in ceph_con_v2_reset_protocol()
3437 ceph_release_page_vector(con->v2.out_enc_pages, in ceph_con_v2_reset_protocol()
3438 con->v2.out_enc_page_cnt); in ceph_con_v2_reset_protocol()
3439 con->v2.out_enc_pages = NULL; in ceph_con_v2_reset_protocol()
3440 con->v2.out_enc_page_cnt = 0; in ceph_con_v2_reset_protocol()
3443 con->v2.con_mode = CEPH_CON_MODE_UNKNOWN; in ceph_con_v2_reset_protocol()
3444 memzero_explicit(&con->v2.in_gcm_nonce, CEPH_GCM_IV_LEN); in ceph_con_v2_reset_protocol()
3445 memzero_explicit(&con->v2.out_gcm_nonce, CEPH_GCM_IV_LEN); in ceph_con_v2_reset_protocol()
3447 if (con->v2.hmac_tfm) { in ceph_con_v2_reset_protocol()
3448 crypto_free_shash(con->v2.hmac_tfm); in ceph_con_v2_reset_protocol()
3449 con->v2.hmac_tfm = NULL; in ceph_con_v2_reset_protocol()
3451 if (con->v2.gcm_req) { in ceph_con_v2_reset_protocol()
3452 aead_request_free(con->v2.gcm_req); in ceph_con_v2_reset_protocol()
3453 con->v2.gcm_req = NULL; in ceph_con_v2_reset_protocol()
3455 if (con->v2.gcm_tfm) { in ceph_con_v2_reset_protocol()
3456 crypto_free_aead(con->v2.gcm_tfm); in ceph_con_v2_reset_protocol()
3457 con->v2.gcm_tfm = NULL; in ceph_con_v2_reset_protocol()