18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __FS_CEPH_MESSENGER_H 38c2ecf20Sopenharmony_ci#define __FS_CEPH_MESSENGER_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/bvec.h> 68c2ecf20Sopenharmony_ci#include <linux/kref.h> 78c2ecf20Sopenharmony_ci#include <linux/mutex.h> 88c2ecf20Sopenharmony_ci#include <linux/net.h> 98c2ecf20Sopenharmony_ci#include <linux/radix-tree.h> 108c2ecf20Sopenharmony_ci#include <linux/uio.h> 118c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 128c2ecf20Sopenharmony_ci#include <net/net_namespace.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/ceph/types.h> 158c2ecf20Sopenharmony_ci#include <linux/ceph/buffer.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct ceph_msg; 188c2ecf20Sopenharmony_cistruct ceph_connection; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * Ceph defines these callbacks for handling connection events. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_cistruct ceph_connection_operations { 248c2ecf20Sopenharmony_ci struct ceph_connection *(*get)(struct ceph_connection *); 258c2ecf20Sopenharmony_ci void (*put)(struct ceph_connection *); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci /* handle an incoming message. */ 288c2ecf20Sopenharmony_ci void (*dispatch) (struct ceph_connection *con, struct ceph_msg *m); 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci /* authorize an outgoing connection */ 318c2ecf20Sopenharmony_ci struct ceph_auth_handshake *(*get_authorizer) ( 328c2ecf20Sopenharmony_ci struct ceph_connection *con, 338c2ecf20Sopenharmony_ci int *proto, int force_new); 348c2ecf20Sopenharmony_ci int (*add_authorizer_challenge)(struct ceph_connection *con, 358c2ecf20Sopenharmony_ci void *challenge_buf, 368c2ecf20Sopenharmony_ci int challenge_buf_len); 378c2ecf20Sopenharmony_ci int (*verify_authorizer_reply) (struct ceph_connection *con); 388c2ecf20Sopenharmony_ci int (*invalidate_authorizer)(struct ceph_connection *con); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci /* there was some error on the socket (disconnect, whatever) */ 418c2ecf20Sopenharmony_ci void (*fault) (struct ceph_connection *con); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci /* a remote host as terminated a message exchange session, and messages 448c2ecf20Sopenharmony_ci * we sent (or they tried to send us) may be lost. */ 458c2ecf20Sopenharmony_ci void (*peer_reset) (struct ceph_connection *con); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci struct ceph_msg * (*alloc_msg) (struct ceph_connection *con, 488c2ecf20Sopenharmony_ci struct ceph_msg_header *hdr, 498c2ecf20Sopenharmony_ci int *skip); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci void (*reencode_message) (struct ceph_msg *msg); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci int (*sign_message) (struct ceph_msg *msg); 548c2ecf20Sopenharmony_ci int (*check_message_signature) (struct ceph_msg *msg); 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* use format string %s%lld */ 588c2ecf20Sopenharmony_ci#define ENTITY_NAME(n) ceph_entity_type_name((n).type), le64_to_cpu((n).num) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct ceph_messenger { 618c2ecf20Sopenharmony_ci struct ceph_entity_inst inst; /* my name+address */ 628c2ecf20Sopenharmony_ci struct ceph_entity_addr my_enc_addr; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci atomic_t stopping; 658c2ecf20Sopenharmony_ci possible_net_t net; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci /* 688c2ecf20Sopenharmony_ci * the global_seq counts connections i (attempt to) initiate 698c2ecf20Sopenharmony_ci * in order to disambiguate certain connect race conditions. 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci u32 global_seq; 728c2ecf20Sopenharmony_ci spinlock_t global_seq_lock; 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cienum ceph_msg_data_type { 768c2ecf20Sopenharmony_ci CEPH_MSG_DATA_NONE, /* message contains no data payload */ 778c2ecf20Sopenharmony_ci CEPH_MSG_DATA_PAGES, /* data source/destination is a page array */ 788c2ecf20Sopenharmony_ci CEPH_MSG_DATA_PAGELIST, /* data source/destination is a pagelist */ 798c2ecf20Sopenharmony_ci#ifdef CONFIG_BLOCK 808c2ecf20Sopenharmony_ci CEPH_MSG_DATA_BIO, /* data source/destination is a bio list */ 818c2ecf20Sopenharmony_ci#endif /* CONFIG_BLOCK */ 828c2ecf20Sopenharmony_ci CEPH_MSG_DATA_BVECS, /* data source/destination is a bio_vec array */ 838c2ecf20Sopenharmony_ci}; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#ifdef CONFIG_BLOCK 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistruct ceph_bio_iter { 888c2ecf20Sopenharmony_ci struct bio *bio; 898c2ecf20Sopenharmony_ci struct bvec_iter iter; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define __ceph_bio_iter_advance_step(it, n, STEP) do { \ 938c2ecf20Sopenharmony_ci unsigned int __n = (n), __cur_n; \ 948c2ecf20Sopenharmony_ci \ 958c2ecf20Sopenharmony_ci while (__n) { \ 968c2ecf20Sopenharmony_ci BUG_ON(!(it)->iter.bi_size); \ 978c2ecf20Sopenharmony_ci __cur_n = min((it)->iter.bi_size, __n); \ 988c2ecf20Sopenharmony_ci (void)(STEP); \ 998c2ecf20Sopenharmony_ci bio_advance_iter((it)->bio, &(it)->iter, __cur_n); \ 1008c2ecf20Sopenharmony_ci if (!(it)->iter.bi_size && (it)->bio->bi_next) { \ 1018c2ecf20Sopenharmony_ci dout("__ceph_bio_iter_advance_step next bio\n"); \ 1028c2ecf20Sopenharmony_ci (it)->bio = (it)->bio->bi_next; \ 1038c2ecf20Sopenharmony_ci (it)->iter = (it)->bio->bi_iter; \ 1048c2ecf20Sopenharmony_ci } \ 1058c2ecf20Sopenharmony_ci __n -= __cur_n; \ 1068c2ecf20Sopenharmony_ci } \ 1078c2ecf20Sopenharmony_ci} while (0) 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* 1108c2ecf20Sopenharmony_ci * Advance @it by @n bytes. 1118c2ecf20Sopenharmony_ci */ 1128c2ecf20Sopenharmony_ci#define ceph_bio_iter_advance(it, n) \ 1138c2ecf20Sopenharmony_ci __ceph_bio_iter_advance_step(it, n, 0) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* 1168c2ecf20Sopenharmony_ci * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec. 1178c2ecf20Sopenharmony_ci */ 1188c2ecf20Sopenharmony_ci#define ceph_bio_iter_advance_step(it, n, BVEC_STEP) \ 1198c2ecf20Sopenharmony_ci __ceph_bio_iter_advance_step(it, n, ({ \ 1208c2ecf20Sopenharmony_ci struct bio_vec bv; \ 1218c2ecf20Sopenharmony_ci struct bvec_iter __cur_iter; \ 1228c2ecf20Sopenharmony_ci \ 1238c2ecf20Sopenharmony_ci __cur_iter = (it)->iter; \ 1248c2ecf20Sopenharmony_ci __cur_iter.bi_size = __cur_n; \ 1258c2ecf20Sopenharmony_ci __bio_for_each_segment(bv, (it)->bio, __cur_iter, __cur_iter) \ 1268c2ecf20Sopenharmony_ci (void)(BVEC_STEP); \ 1278c2ecf20Sopenharmony_ci })) 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#endif /* CONFIG_BLOCK */ 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistruct ceph_bvec_iter { 1328c2ecf20Sopenharmony_ci struct bio_vec *bvecs; 1338c2ecf20Sopenharmony_ci struct bvec_iter iter; 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define __ceph_bvec_iter_advance_step(it, n, STEP) do { \ 1378c2ecf20Sopenharmony_ci BUG_ON((n) > (it)->iter.bi_size); \ 1388c2ecf20Sopenharmony_ci (void)(STEP); \ 1398c2ecf20Sopenharmony_ci bvec_iter_advance((it)->bvecs, &(it)->iter, (n)); \ 1408c2ecf20Sopenharmony_ci} while (0) 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci/* 1438c2ecf20Sopenharmony_ci * Advance @it by @n bytes. 1448c2ecf20Sopenharmony_ci */ 1458c2ecf20Sopenharmony_ci#define ceph_bvec_iter_advance(it, n) \ 1468c2ecf20Sopenharmony_ci __ceph_bvec_iter_advance_step(it, n, 0) 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci/* 1498c2ecf20Sopenharmony_ci * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec. 1508c2ecf20Sopenharmony_ci */ 1518c2ecf20Sopenharmony_ci#define ceph_bvec_iter_advance_step(it, n, BVEC_STEP) \ 1528c2ecf20Sopenharmony_ci __ceph_bvec_iter_advance_step(it, n, ({ \ 1538c2ecf20Sopenharmony_ci struct bio_vec bv; \ 1548c2ecf20Sopenharmony_ci struct bvec_iter __cur_iter; \ 1558c2ecf20Sopenharmony_ci \ 1568c2ecf20Sopenharmony_ci __cur_iter = (it)->iter; \ 1578c2ecf20Sopenharmony_ci __cur_iter.bi_size = (n); \ 1588c2ecf20Sopenharmony_ci for_each_bvec(bv, (it)->bvecs, __cur_iter, __cur_iter) \ 1598c2ecf20Sopenharmony_ci (void)(BVEC_STEP); \ 1608c2ecf20Sopenharmony_ci })) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define ceph_bvec_iter_shorten(it, n) do { \ 1638c2ecf20Sopenharmony_ci BUG_ON((n) > (it)->iter.bi_size); \ 1648c2ecf20Sopenharmony_ci (it)->iter.bi_size = (n); \ 1658c2ecf20Sopenharmony_ci} while (0) 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_cistruct ceph_msg_data { 1688c2ecf20Sopenharmony_ci enum ceph_msg_data_type type; 1698c2ecf20Sopenharmony_ci union { 1708c2ecf20Sopenharmony_ci#ifdef CONFIG_BLOCK 1718c2ecf20Sopenharmony_ci struct { 1728c2ecf20Sopenharmony_ci struct ceph_bio_iter bio_pos; 1738c2ecf20Sopenharmony_ci u32 bio_length; 1748c2ecf20Sopenharmony_ci }; 1758c2ecf20Sopenharmony_ci#endif /* CONFIG_BLOCK */ 1768c2ecf20Sopenharmony_ci struct ceph_bvec_iter bvec_pos; 1778c2ecf20Sopenharmony_ci struct { 1788c2ecf20Sopenharmony_ci struct page **pages; 1798c2ecf20Sopenharmony_ci size_t length; /* total # bytes */ 1808c2ecf20Sopenharmony_ci unsigned int alignment; /* first page */ 1818c2ecf20Sopenharmony_ci bool own_pages; 1828c2ecf20Sopenharmony_ci }; 1838c2ecf20Sopenharmony_ci struct ceph_pagelist *pagelist; 1848c2ecf20Sopenharmony_ci }; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistruct ceph_msg_data_cursor { 1888c2ecf20Sopenharmony_ci size_t total_resid; /* across all data items */ 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci struct ceph_msg_data *data; /* current data item */ 1918c2ecf20Sopenharmony_ci size_t resid; /* bytes not yet consumed */ 1928c2ecf20Sopenharmony_ci bool last_piece; /* current is last piece */ 1938c2ecf20Sopenharmony_ci bool need_crc; /* crc update needed */ 1948c2ecf20Sopenharmony_ci union { 1958c2ecf20Sopenharmony_ci#ifdef CONFIG_BLOCK 1968c2ecf20Sopenharmony_ci struct ceph_bio_iter bio_iter; 1978c2ecf20Sopenharmony_ci#endif /* CONFIG_BLOCK */ 1988c2ecf20Sopenharmony_ci struct bvec_iter bvec_iter; 1998c2ecf20Sopenharmony_ci struct { /* pages */ 2008c2ecf20Sopenharmony_ci unsigned int page_offset; /* offset in page */ 2018c2ecf20Sopenharmony_ci unsigned short page_index; /* index in array */ 2028c2ecf20Sopenharmony_ci unsigned short page_count; /* pages in array */ 2038c2ecf20Sopenharmony_ci }; 2048c2ecf20Sopenharmony_ci struct { /* pagelist */ 2058c2ecf20Sopenharmony_ci struct page *page; /* page from list */ 2068c2ecf20Sopenharmony_ci size_t offset; /* bytes from list */ 2078c2ecf20Sopenharmony_ci }; 2088c2ecf20Sopenharmony_ci }; 2098c2ecf20Sopenharmony_ci}; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci/* 2128c2ecf20Sopenharmony_ci * a single message. it contains a header (src, dest, message type, etc.), 2138c2ecf20Sopenharmony_ci * footer (crc values, mainly), a "front" message body, and possibly a 2148c2ecf20Sopenharmony_ci * data payload (stored in some number of pages). 2158c2ecf20Sopenharmony_ci */ 2168c2ecf20Sopenharmony_cistruct ceph_msg { 2178c2ecf20Sopenharmony_ci struct ceph_msg_header hdr; /* header */ 2188c2ecf20Sopenharmony_ci union { 2198c2ecf20Sopenharmony_ci struct ceph_msg_footer footer; /* footer */ 2208c2ecf20Sopenharmony_ci struct ceph_msg_footer_old old_footer; /* old format footer */ 2218c2ecf20Sopenharmony_ci }; 2228c2ecf20Sopenharmony_ci struct kvec front; /* unaligned blobs of message */ 2238c2ecf20Sopenharmony_ci struct ceph_buffer *middle; 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci size_t data_length; 2268c2ecf20Sopenharmony_ci struct ceph_msg_data *data; 2278c2ecf20Sopenharmony_ci int num_data_items; 2288c2ecf20Sopenharmony_ci int max_data_items; 2298c2ecf20Sopenharmony_ci struct ceph_msg_data_cursor cursor; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci struct ceph_connection *con; 2328c2ecf20Sopenharmony_ci struct list_head list_head; /* links for connection lists */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci struct kref kref; 2358c2ecf20Sopenharmony_ci bool more_to_follow; 2368c2ecf20Sopenharmony_ci bool needs_out_seq; 2378c2ecf20Sopenharmony_ci int front_alloc_len; 2388c2ecf20Sopenharmony_ci unsigned long ack_stamp; /* tx: when we were acked */ 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci struct ceph_msgpool *pool; 2418c2ecf20Sopenharmony_ci}; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* ceph connection fault delay defaults, for exponential backoff */ 2448c2ecf20Sopenharmony_ci#define BASE_DELAY_INTERVAL (HZ/2) 2458c2ecf20Sopenharmony_ci#define MAX_DELAY_INTERVAL (5 * 60 * HZ) 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci/* 2488c2ecf20Sopenharmony_ci * A single connection with another host. 2498c2ecf20Sopenharmony_ci * 2508c2ecf20Sopenharmony_ci * We maintain a queue of outgoing messages, and some session state to 2518c2ecf20Sopenharmony_ci * ensure that we can preserve the lossless, ordered delivery of 2528c2ecf20Sopenharmony_ci * messages in the case of a TCP disconnect. 2538c2ecf20Sopenharmony_ci */ 2548c2ecf20Sopenharmony_cistruct ceph_connection { 2558c2ecf20Sopenharmony_ci void *private; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci const struct ceph_connection_operations *ops; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci struct ceph_messenger *msgr; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci atomic_t sock_state; 2628c2ecf20Sopenharmony_ci struct socket *sock; 2638c2ecf20Sopenharmony_ci struct ceph_entity_addr peer_addr; /* peer address */ 2648c2ecf20Sopenharmony_ci struct ceph_entity_addr peer_addr_for_me; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci unsigned long flags; 2678c2ecf20Sopenharmony_ci unsigned long state; 2688c2ecf20Sopenharmony_ci const char *error_msg; /* error message, if any */ 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci struct ceph_entity_name peer_name; /* peer name */ 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci u64 peer_features; 2738c2ecf20Sopenharmony_ci u32 connect_seq; /* identify the most recent connection 2748c2ecf20Sopenharmony_ci attempt for this connection, client */ 2758c2ecf20Sopenharmony_ci u32 peer_global_seq; /* peer's global seq for this connection */ 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci struct ceph_auth_handshake *auth; 2788c2ecf20Sopenharmony_ci int auth_retry; /* true if we need a newer authorizer */ 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci struct mutex mutex; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci /* out queue */ 2838c2ecf20Sopenharmony_ci struct list_head out_queue; 2848c2ecf20Sopenharmony_ci struct list_head out_sent; /* sending or sent but unacked */ 2858c2ecf20Sopenharmony_ci u64 out_seq; /* last message queued for send */ 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci u64 in_seq, in_seq_acked; /* last message received, acked */ 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci /* connection negotiation temps */ 2908c2ecf20Sopenharmony_ci char in_banner[CEPH_BANNER_MAX_LEN]; 2918c2ecf20Sopenharmony_ci struct ceph_msg_connect out_connect; 2928c2ecf20Sopenharmony_ci struct ceph_msg_connect_reply in_reply; 2938c2ecf20Sopenharmony_ci struct ceph_entity_addr actual_peer_addr; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci /* message out temps */ 2968c2ecf20Sopenharmony_ci struct ceph_msg_header out_hdr; 2978c2ecf20Sopenharmony_ci struct ceph_msg *out_msg; /* sending message (== tail of 2988c2ecf20Sopenharmony_ci out_sent) */ 2998c2ecf20Sopenharmony_ci bool out_msg_done; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci struct kvec out_kvec[8], /* sending header/footer data */ 3028c2ecf20Sopenharmony_ci *out_kvec_cur; 3038c2ecf20Sopenharmony_ci int out_kvec_left; /* kvec's left in out_kvec */ 3048c2ecf20Sopenharmony_ci int out_skip; /* skip this many bytes */ 3058c2ecf20Sopenharmony_ci int out_kvec_bytes; /* total bytes left */ 3068c2ecf20Sopenharmony_ci int out_more; /* there is more data after the kvecs */ 3078c2ecf20Sopenharmony_ci __le64 out_temp_ack; /* for writing an ack */ 3088c2ecf20Sopenharmony_ci struct ceph_timespec out_temp_keepalive2; /* for writing keepalive2 3098c2ecf20Sopenharmony_ci stamp */ 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci /* message in temps */ 3128c2ecf20Sopenharmony_ci struct ceph_msg_header in_hdr; 3138c2ecf20Sopenharmony_ci struct ceph_msg *in_msg; 3148c2ecf20Sopenharmony_ci u32 in_front_crc, in_middle_crc, in_data_crc; /* calculated crc */ 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci char in_tag; /* protocol control byte */ 3178c2ecf20Sopenharmony_ci int in_base_pos; /* bytes read */ 3188c2ecf20Sopenharmony_ci __le64 in_temp_ack; /* for reading an ack */ 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci struct timespec64 last_keepalive_ack; /* keepalive2 ack stamp */ 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci struct delayed_work work; /* send|recv work */ 3238c2ecf20Sopenharmony_ci unsigned long delay; /* current delay interval */ 3248c2ecf20Sopenharmony_ci}; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ciextern const char *ceph_pr_addr(const struct ceph_entity_addr *addr); 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ciextern int ceph_parse_ips(const char *c, const char *end, 3308c2ecf20Sopenharmony_ci struct ceph_entity_addr *addr, 3318c2ecf20Sopenharmony_ci int max_count, int *count); 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ciextern int ceph_msgr_init(void); 3358c2ecf20Sopenharmony_ciextern void ceph_msgr_exit(void); 3368c2ecf20Sopenharmony_ciextern void ceph_msgr_flush(void); 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ciextern void ceph_messenger_init(struct ceph_messenger *msgr, 3398c2ecf20Sopenharmony_ci struct ceph_entity_addr *myaddr); 3408c2ecf20Sopenharmony_ciextern void ceph_messenger_fini(struct ceph_messenger *msgr); 3418c2ecf20Sopenharmony_ciextern void ceph_messenger_reset_nonce(struct ceph_messenger *msgr); 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ciextern void ceph_con_init(struct ceph_connection *con, void *private, 3448c2ecf20Sopenharmony_ci const struct ceph_connection_operations *ops, 3458c2ecf20Sopenharmony_ci struct ceph_messenger *msgr); 3468c2ecf20Sopenharmony_ciextern void ceph_con_open(struct ceph_connection *con, 3478c2ecf20Sopenharmony_ci __u8 entity_type, __u64 entity_num, 3488c2ecf20Sopenharmony_ci struct ceph_entity_addr *addr); 3498c2ecf20Sopenharmony_ciextern bool ceph_con_opened(struct ceph_connection *con); 3508c2ecf20Sopenharmony_ciextern void ceph_con_close(struct ceph_connection *con); 3518c2ecf20Sopenharmony_ciextern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg); 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ciextern void ceph_msg_revoke(struct ceph_msg *msg); 3548c2ecf20Sopenharmony_ciextern void ceph_msg_revoke_incoming(struct ceph_msg *msg); 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ciextern void ceph_con_keepalive(struct ceph_connection *con); 3578c2ecf20Sopenharmony_ciextern bool ceph_con_keepalive_expired(struct ceph_connection *con, 3588c2ecf20Sopenharmony_ci unsigned long interval); 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_civoid ceph_msg_data_add_pages(struct ceph_msg *msg, struct page **pages, 3618c2ecf20Sopenharmony_ci size_t length, size_t alignment, bool own_pages); 3628c2ecf20Sopenharmony_ciextern void ceph_msg_data_add_pagelist(struct ceph_msg *msg, 3638c2ecf20Sopenharmony_ci struct ceph_pagelist *pagelist); 3648c2ecf20Sopenharmony_ci#ifdef CONFIG_BLOCK 3658c2ecf20Sopenharmony_civoid ceph_msg_data_add_bio(struct ceph_msg *msg, struct ceph_bio_iter *bio_pos, 3668c2ecf20Sopenharmony_ci u32 length); 3678c2ecf20Sopenharmony_ci#endif /* CONFIG_BLOCK */ 3688c2ecf20Sopenharmony_civoid ceph_msg_data_add_bvecs(struct ceph_msg *msg, 3698c2ecf20Sopenharmony_ci struct ceph_bvec_iter *bvec_pos); 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_cistruct ceph_msg *ceph_msg_new2(int type, int front_len, int max_data_items, 3728c2ecf20Sopenharmony_ci gfp_t flags, bool can_fail); 3738c2ecf20Sopenharmony_ciextern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, 3748c2ecf20Sopenharmony_ci bool can_fail); 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ciextern struct ceph_msg *ceph_msg_get(struct ceph_msg *msg); 3778c2ecf20Sopenharmony_ciextern void ceph_msg_put(struct ceph_msg *msg); 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ciextern void ceph_msg_dump(struct ceph_msg *msg); 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci#endif 382