messenger.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __FS_CEPH_MESSENGER_H
  3. #define __FS_CEPH_MESSENGER_H
  4. #include <linux/bvec.h>
  5. #include <linux/crypto.h>
  6. #include <linux/kref.h>
  7. #include <linux/mutex.h>
  8. #include <linux/net.h>
  9. #include <linux/radix-tree.h>
  10. #include <linux/uio.h>
  11. #include <linux/workqueue.h>
  12. #include <net/net_namespace.h>
  13. #include <linux/ceph/types.h>
  14. #include <linux/ceph/buffer.h>
  15. struct ceph_msg;
  16. struct ceph_connection;
  17. /*
  18. * Ceph defines these callbacks for handling connection events.
  19. */
  20. struct ceph_connection_operations {
  21. struct ceph_connection *(*get)(struct ceph_connection *);
  22. void (*put)(struct ceph_connection *);
  23. /* handle an incoming message. */
  24. void (*dispatch) (struct ceph_connection *con, struct ceph_msg *m);
  25. /* authorize an outgoing connection */
  26. struct ceph_auth_handshake *(*get_authorizer) (
  27. struct ceph_connection *con,
  28. int *proto, int force_new);
  29. int (*add_authorizer_challenge)(struct ceph_connection *con,
  30. void *challenge_buf,
  31. int challenge_buf_len);
  32. int (*verify_authorizer_reply) (struct ceph_connection *con);
  33. int (*invalidate_authorizer)(struct ceph_connection *con);
  34. /* there was some error on the socket (disconnect, whatever) */
  35. void (*fault) (struct ceph_connection *con);
  36. /* a remote host as terminated a message exchange session, and messages
  37. * we sent (or they tried to send us) may be lost. */
  38. void (*peer_reset) (struct ceph_connection *con);
  39. struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
  40. struct ceph_msg_header *hdr,
  41. int *skip);
  42. void (*reencode_message) (struct ceph_msg *msg);
  43. int (*sign_message) (struct ceph_msg *msg);
  44. int (*check_message_signature) (struct ceph_msg *msg);
  45. /* msgr2 authentication exchange */
  46. int (*get_auth_request)(struct ceph_connection *con,
  47. void *buf, int *buf_len,
  48. void **authorizer, int *authorizer_len);
  49. int (*handle_auth_reply_more)(struct ceph_connection *con,
  50. void *reply, int reply_len,
  51. void *buf, int *buf_len,
  52. void **authorizer, int *authorizer_len);
  53. int (*handle_auth_done)(struct ceph_connection *con,
  54. u64 global_id, void *reply, int reply_len,
  55. u8 *session_key, int *session_key_len,
  56. u8 *con_secret, int *con_secret_len);
  57. int (*handle_auth_bad_method)(struct ceph_connection *con,
  58. int used_proto, int result,
  59. const int *allowed_protos, int proto_cnt,
  60. const int *allowed_modes, int mode_cnt);
  61. };
  62. /* use format string %s%lld */
  63. #define ENTITY_NAME(n) ceph_entity_type_name((n).type), le64_to_cpu((n).num)
  64. struct ceph_messenger {
  65. struct ceph_entity_inst inst; /* my name+address */
  66. struct ceph_entity_addr my_enc_addr;
  67. atomic_t stopping;
  68. possible_net_t net;
  69. /*
  70. * the global_seq counts connections i (attempt to) initiate
  71. * in order to disambiguate certain connect race conditions.
  72. */
  73. u32 global_seq;
  74. spinlock_t global_seq_lock;
  75. };
  76. enum ceph_msg_data_type {
  77. CEPH_MSG_DATA_NONE, /* message contains no data payload */
  78. CEPH_MSG_DATA_PAGES, /* data source/destination is a page array */
  79. CEPH_MSG_DATA_PAGELIST, /* data source/destination is a pagelist */
  80. #ifdef CONFIG_BLOCK
  81. CEPH_MSG_DATA_BIO, /* data source/destination is a bio list */
  82. #endif /* CONFIG_BLOCK */
  83. CEPH_MSG_DATA_BVECS, /* data source/destination is a bio_vec array */
  84. };
  85. #ifdef CONFIG_BLOCK
  86. struct ceph_bio_iter {
  87. struct bio *bio;
  88. struct bvec_iter iter;
  89. };
  90. #define __ceph_bio_iter_advance_step(it, n, STEP) do { \
  91. unsigned int __n = (n), __cur_n; \
  92. \
  93. while (__n) { \
  94. BUG_ON(!(it)->iter.bi_size); \
  95. __cur_n = min((it)->iter.bi_size, __n); \
  96. (void)(STEP); \
  97. bio_advance_iter((it)->bio, &(it)->iter, __cur_n); \
  98. if (!(it)->iter.bi_size && (it)->bio->bi_next) { \
  99. dout("__ceph_bio_iter_advance_step next bio\n"); \
  100. (it)->bio = (it)->bio->bi_next; \
  101. (it)->iter = (it)->bio->bi_iter; \
  102. } \
  103. __n -= __cur_n; \
  104. } \
  105. } while (0)
  106. /*
  107. * Advance @it by @n bytes.
  108. */
  109. #define ceph_bio_iter_advance(it, n) \
  110. __ceph_bio_iter_advance_step(it, n, 0)
  111. /*
  112. * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec.
  113. */
  114. #define ceph_bio_iter_advance_step(it, n, BVEC_STEP) \
  115. __ceph_bio_iter_advance_step(it, n, ({ \
  116. struct bio_vec bv; \
  117. struct bvec_iter __cur_iter; \
  118. \
  119. __cur_iter = (it)->iter; \
  120. __cur_iter.bi_size = __cur_n; \
  121. __bio_for_each_segment(bv, (it)->bio, __cur_iter, __cur_iter) \
  122. (void)(BVEC_STEP); \
  123. }))
  124. #endif /* CONFIG_BLOCK */
  125. struct ceph_bvec_iter {
  126. struct bio_vec *bvecs;
  127. struct bvec_iter iter;
  128. };
  129. #define __ceph_bvec_iter_advance_step(it, n, STEP) do { \
  130. BUG_ON((n) > (it)->iter.bi_size); \
  131. (void)(STEP); \
  132. bvec_iter_advance((it)->bvecs, &(it)->iter, (n)); \
  133. } while (0)
  134. /*
  135. * Advance @it by @n bytes.
  136. */
  137. #define ceph_bvec_iter_advance(it, n) \
  138. __ceph_bvec_iter_advance_step(it, n, 0)
  139. /*
  140. * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec.
  141. */
  142. #define ceph_bvec_iter_advance_step(it, n, BVEC_STEP) \
  143. __ceph_bvec_iter_advance_step(it, n, ({ \
  144. struct bio_vec bv; \
  145. struct bvec_iter __cur_iter; \
  146. \
  147. __cur_iter = (it)->iter; \
  148. __cur_iter.bi_size = (n); \
  149. for_each_bvec(bv, (it)->bvecs, __cur_iter, __cur_iter) \
  150. (void)(BVEC_STEP); \
  151. }))
  152. #define ceph_bvec_iter_shorten(it, n) do { \
  153. BUG_ON((n) > (it)->iter.bi_size); \
  154. (it)->iter.bi_size = (n); \
  155. } while (0)
  156. struct ceph_msg_data {
  157. enum ceph_msg_data_type type;
  158. union {
  159. #ifdef CONFIG_BLOCK
  160. struct {
  161. struct ceph_bio_iter bio_pos;
  162. u32 bio_length;
  163. };
  164. #endif /* CONFIG_BLOCK */
  165. struct ceph_bvec_iter bvec_pos;
  166. struct {
  167. struct page **pages;
  168. size_t length; /* total # bytes */
  169. unsigned int alignment; /* first page */
  170. bool own_pages;
  171. };
  172. struct ceph_pagelist *pagelist;
  173. };
  174. };
  175. struct ceph_msg_data_cursor {
  176. size_t total_resid; /* across all data items */
  177. struct ceph_msg_data *data; /* current data item */
  178. size_t resid; /* bytes not yet consumed */
  179. bool need_crc; /* crc update needed */
  180. union {
  181. #ifdef CONFIG_BLOCK
  182. struct ceph_bio_iter bio_iter;
  183. #endif /* CONFIG_BLOCK */
  184. struct bvec_iter bvec_iter;
  185. struct { /* pages */
  186. unsigned int page_offset; /* offset in page */
  187. unsigned short page_index; /* index in array */
  188. unsigned short page_count; /* pages in array */
  189. };
  190. struct { /* pagelist */
  191. struct page *page; /* page from list */
  192. size_t offset; /* bytes from list */
  193. };
  194. };
  195. };
  196. /*
  197. * a single message. it contains a header (src, dest, message type, etc.),
  198. * footer (crc values, mainly), a "front" message body, and possibly a
  199. * data payload (stored in some number of pages).
  200. */
  201. struct ceph_msg {
  202. struct ceph_msg_header hdr; /* header */
  203. union {
  204. struct ceph_msg_footer footer; /* footer */
  205. struct ceph_msg_footer_old old_footer; /* old format footer */
  206. };
  207. struct kvec front; /* unaligned blobs of message */
  208. struct ceph_buffer *middle;
  209. size_t data_length;
  210. struct ceph_msg_data *data;
  211. int num_data_items;
  212. int max_data_items;
  213. struct ceph_msg_data_cursor cursor;
  214. struct ceph_connection *con;
  215. struct list_head list_head; /* links for connection lists */
  216. struct kref kref;
  217. bool more_to_follow;
  218. bool needs_out_seq;
  219. int front_alloc_len;
  220. struct ceph_msgpool *pool;
  221. };
  222. /*
  223. * connection states
  224. */
  225. #define CEPH_CON_S_CLOSED 1
  226. #define CEPH_CON_S_PREOPEN 2
  227. #define CEPH_CON_S_V1_BANNER 3
  228. #define CEPH_CON_S_V1_CONNECT_MSG 4
  229. #define CEPH_CON_S_V2_BANNER_PREFIX 5
  230. #define CEPH_CON_S_V2_BANNER_PAYLOAD 6
  231. #define CEPH_CON_S_V2_HELLO 7
  232. #define CEPH_CON_S_V2_AUTH 8
  233. #define CEPH_CON_S_V2_AUTH_SIGNATURE 9
  234. #define CEPH_CON_S_V2_SESSION_CONNECT 10
  235. #define CEPH_CON_S_V2_SESSION_RECONNECT 11
  236. #define CEPH_CON_S_OPEN 12
  237. #define CEPH_CON_S_STANDBY 13
  238. /*
  239. * ceph_connection flag bits
  240. */
  241. #define CEPH_CON_F_LOSSYTX 0 /* we can close channel or drop
  242. messages on errors */
  243. #define CEPH_CON_F_KEEPALIVE_PENDING 1 /* we need to send a keepalive */
  244. #define CEPH_CON_F_WRITE_PENDING 2 /* we have data ready to send */
  245. #define CEPH_CON_F_SOCK_CLOSED 3 /* socket state changed to closed */
  246. #define CEPH_CON_F_BACKOFF 4 /* need to retry queuing delayed
  247. work */
  248. /* ceph connection fault delay defaults, for exponential backoff */
  249. #define BASE_DELAY_INTERVAL (HZ / 4)
  250. #define MAX_DELAY_INTERVAL (15 * HZ)
  251. struct ceph_connection_v1_info {
  252. struct kvec out_kvec[8], /* sending header/footer data */
  253. *out_kvec_cur;
  254. int out_kvec_left; /* kvec's left in out_kvec */
  255. int out_skip; /* skip this many bytes */
  256. int out_kvec_bytes; /* total bytes left */
  257. bool out_more; /* there is more data after the kvecs */
  258. bool out_msg_done;
  259. struct ceph_auth_handshake *auth;
  260. int auth_retry; /* true if we need a newer authorizer */
  261. /* connection negotiation temps */
  262. u8 in_banner[CEPH_BANNER_MAX_LEN];
  263. struct ceph_entity_addr actual_peer_addr;
  264. struct ceph_entity_addr peer_addr_for_me;
  265. struct ceph_msg_connect out_connect;
  266. struct ceph_msg_connect_reply in_reply;
  267. int in_base_pos; /* bytes read */
  268. /* message in temps */
  269. u8 in_tag; /* protocol control byte */
  270. struct ceph_msg_header in_hdr;
  271. __le64 in_temp_ack; /* for reading an ack */
  272. /* message out temps */
  273. struct ceph_msg_header out_hdr;
  274. __le64 out_temp_ack; /* for writing an ack */
  275. struct ceph_timespec out_temp_keepalive2; /* for writing keepalive2
  276. stamp */
  277. u32 connect_seq; /* identify the most recent connection
  278. attempt for this session */
  279. u32 peer_global_seq; /* peer's global seq for this connection */
  280. };
  281. #define CEPH_CRC_LEN 4
  282. #define CEPH_GCM_KEY_LEN 16
  283. #define CEPH_GCM_IV_LEN sizeof(struct ceph_gcm_nonce)
  284. #define CEPH_GCM_BLOCK_LEN 16
  285. #define CEPH_GCM_TAG_LEN 16
  286. #define CEPH_PREAMBLE_LEN 32
  287. #define CEPH_PREAMBLE_INLINE_LEN 48
  288. #define CEPH_PREAMBLE_PLAIN_LEN CEPH_PREAMBLE_LEN
  289. #define CEPH_PREAMBLE_SECURE_LEN (CEPH_PREAMBLE_LEN + \
  290. CEPH_PREAMBLE_INLINE_LEN + \
  291. CEPH_GCM_TAG_LEN)
  292. #define CEPH_EPILOGUE_PLAIN_LEN (1 + 3 * CEPH_CRC_LEN)
  293. #define CEPH_EPILOGUE_SECURE_LEN (CEPH_GCM_BLOCK_LEN + CEPH_GCM_TAG_LEN)
  294. #define CEPH_FRAME_MAX_SEGMENT_COUNT 4
  295. struct ceph_frame_desc {
  296. int fd_tag; /* FRAME_TAG_* */
  297. int fd_seg_cnt;
  298. int fd_lens[CEPH_FRAME_MAX_SEGMENT_COUNT]; /* logical */
  299. int fd_aligns[CEPH_FRAME_MAX_SEGMENT_COUNT];
  300. };
  301. struct ceph_gcm_nonce {
  302. __le32 fixed;
  303. __le64 counter __packed;
  304. };
  305. struct ceph_connection_v2_info {
  306. struct iov_iter in_iter;
  307. struct kvec in_kvecs[5]; /* recvmsg */
  308. struct bio_vec in_bvec; /* recvmsg (in_cursor) */
  309. int in_kvec_cnt;
  310. int in_state; /* IN_S_* */
  311. struct iov_iter out_iter;
  312. struct kvec out_kvecs[8]; /* sendmsg */
  313. struct bio_vec out_bvec; /* sendpage (out_cursor, out_zero),
  314. sendmsg (out_enc_pages) */
  315. int out_kvec_cnt;
  316. int out_state; /* OUT_S_* */
  317. int out_zero; /* # of zero bytes to send */
  318. bool out_iter_sendpage; /* use sendpage if possible */
  319. struct ceph_frame_desc in_desc;
  320. struct ceph_msg_data_cursor in_cursor;
  321. struct ceph_msg_data_cursor out_cursor;
  322. struct crypto_shash *hmac_tfm; /* post-auth signature */
  323. struct crypto_aead *gcm_tfm; /* on-wire encryption */
  324. struct aead_request *gcm_req;
  325. struct crypto_wait gcm_wait;
  326. struct ceph_gcm_nonce in_gcm_nonce;
  327. struct ceph_gcm_nonce out_gcm_nonce;
  328. struct page **in_enc_pages;
  329. int in_enc_page_cnt;
  330. int in_enc_resid;
  331. int in_enc_i;
  332. struct page **out_enc_pages;
  333. int out_enc_page_cnt;
  334. int out_enc_resid;
  335. int out_enc_i;
  336. int con_mode; /* CEPH_CON_MODE_* */
  337. void *conn_bufs[16];
  338. int conn_buf_cnt;
  339. struct kvec in_sign_kvecs[8];
  340. struct kvec out_sign_kvecs[8];
  341. int in_sign_kvec_cnt;
  342. int out_sign_kvec_cnt;
  343. u64 client_cookie;
  344. u64 server_cookie;
  345. u64 global_seq;
  346. u64 connect_seq;
  347. u64 peer_global_seq;
  348. u8 in_buf[CEPH_PREAMBLE_SECURE_LEN];
  349. u8 out_buf[CEPH_PREAMBLE_SECURE_LEN];
  350. struct {
  351. u8 late_status; /* FRAME_LATE_STATUS_* */
  352. union {
  353. struct {
  354. u32 front_crc;
  355. u32 middle_crc;
  356. u32 data_crc;
  357. } __packed;
  358. u8 pad[CEPH_GCM_BLOCK_LEN - 1];
  359. };
  360. } out_epil;
  361. };
  362. /*
  363. * A single connection with another host.
  364. *
  365. * We maintain a queue of outgoing messages, and some session state to
  366. * ensure that we can preserve the lossless, ordered delivery of
  367. * messages in the case of a TCP disconnect.
  368. */
  369. struct ceph_connection {
  370. void *private;
  371. const struct ceph_connection_operations *ops;
  372. struct ceph_messenger *msgr;
  373. int state; /* CEPH_CON_S_* */
  374. atomic_t sock_state;
  375. struct socket *sock;
  376. unsigned long flags; /* CEPH_CON_F_* */
  377. const char *error_msg; /* error message, if any */
  378. struct ceph_entity_name peer_name; /* peer name */
  379. struct ceph_entity_addr peer_addr; /* peer address */
  380. u64 peer_features;
  381. struct mutex mutex;
  382. /* out queue */
  383. struct list_head out_queue;
  384. struct list_head out_sent; /* sending or sent but unacked */
  385. u64 out_seq; /* last message queued for send */
  386. u64 in_seq, in_seq_acked; /* last message received, acked */
  387. struct ceph_msg *in_msg;
  388. struct ceph_msg *out_msg; /* sending message (== tail of
  389. out_sent) */
  390. struct page *bounce_page;
  391. u32 in_front_crc, in_middle_crc, in_data_crc; /* calculated crc */
  392. struct timespec64 last_keepalive_ack; /* keepalive2 ack stamp */
  393. struct delayed_work work; /* send|recv work */
  394. unsigned long delay; /* current delay interval */
  395. union {
  396. struct ceph_connection_v1_info v1;
  397. struct ceph_connection_v2_info v2;
  398. };
  399. };
  400. extern struct page *ceph_zero_page;
  401. void ceph_con_flag_clear(struct ceph_connection *con, unsigned long con_flag);
  402. void ceph_con_flag_set(struct ceph_connection *con, unsigned long con_flag);
  403. bool ceph_con_flag_test(struct ceph_connection *con, unsigned long con_flag);
  404. bool ceph_con_flag_test_and_clear(struct ceph_connection *con,
  405. unsigned long con_flag);
  406. bool ceph_con_flag_test_and_set(struct ceph_connection *con,
  407. unsigned long con_flag);
  408. void ceph_encode_my_addr(struct ceph_messenger *msgr);
  409. int ceph_tcp_connect(struct ceph_connection *con);
  410. int ceph_con_close_socket(struct ceph_connection *con);
  411. void ceph_con_reset_session(struct ceph_connection *con);
  412. u32 ceph_get_global_seq(struct ceph_messenger *msgr, u32 gt);
  413. void ceph_con_discard_sent(struct ceph_connection *con, u64 ack_seq);
  414. void ceph_con_discard_requeued(struct ceph_connection *con, u64 reconnect_seq);
  415. void ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor,
  416. struct ceph_msg *msg, size_t length);
  417. struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor,
  418. size_t *page_offset, size_t *length);
  419. void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes);
  420. u32 ceph_crc32c_page(u32 crc, struct page *page, unsigned int page_offset,
  421. unsigned int length);
  422. bool ceph_addr_is_blank(const struct ceph_entity_addr *addr);
  423. int ceph_addr_port(const struct ceph_entity_addr *addr);
  424. void ceph_addr_set_port(struct ceph_entity_addr *addr, int p);
  425. void ceph_con_process_message(struct ceph_connection *con);
  426. int ceph_con_in_msg_alloc(struct ceph_connection *con,
  427. struct ceph_msg_header *hdr, int *skip);
  428. void ceph_con_get_out_msg(struct ceph_connection *con);
  429. /* messenger_v1.c */
  430. int ceph_con_v1_try_read(struct ceph_connection *con);
  431. int ceph_con_v1_try_write(struct ceph_connection *con);
  432. void ceph_con_v1_revoke(struct ceph_connection *con);
  433. void ceph_con_v1_revoke_incoming(struct ceph_connection *con);
  434. bool ceph_con_v1_opened(struct ceph_connection *con);
  435. void ceph_con_v1_reset_session(struct ceph_connection *con);
  436. void ceph_con_v1_reset_protocol(struct ceph_connection *con);
  437. /* messenger_v2.c */
  438. int ceph_con_v2_try_read(struct ceph_connection *con);
  439. int ceph_con_v2_try_write(struct ceph_connection *con);
  440. void ceph_con_v2_revoke(struct ceph_connection *con);
  441. void ceph_con_v2_revoke_incoming(struct ceph_connection *con);
  442. bool ceph_con_v2_opened(struct ceph_connection *con);
  443. void ceph_con_v2_reset_session(struct ceph_connection *con);
  444. void ceph_con_v2_reset_protocol(struct ceph_connection *con);
  445. extern const char *ceph_pr_addr(const struct ceph_entity_addr *addr);
  446. extern int ceph_parse_ips(const char *c, const char *end,
  447. struct ceph_entity_addr *addr,
  448. int max_count, int *count, char delim);
  449. extern int ceph_msgr_init(void);
  450. extern void ceph_msgr_exit(void);
  451. extern void ceph_msgr_flush(void);
  452. extern void ceph_messenger_init(struct ceph_messenger *msgr,
  453. struct ceph_entity_addr *myaddr);
  454. extern void ceph_messenger_fini(struct ceph_messenger *msgr);
  455. extern void ceph_messenger_reset_nonce(struct ceph_messenger *msgr);
  456. extern void ceph_con_init(struct ceph_connection *con, void *private,
  457. const struct ceph_connection_operations *ops,
  458. struct ceph_messenger *msgr);
  459. extern void ceph_con_open(struct ceph_connection *con,
  460. __u8 entity_type, __u64 entity_num,
  461. struct ceph_entity_addr *addr);
  462. extern bool ceph_con_opened(struct ceph_connection *con);
  463. extern void ceph_con_close(struct ceph_connection *con);
  464. extern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg);
  465. extern void ceph_msg_revoke(struct ceph_msg *msg);
  466. extern void ceph_msg_revoke_incoming(struct ceph_msg *msg);
  467. extern void ceph_con_keepalive(struct ceph_connection *con);
  468. extern bool ceph_con_keepalive_expired(struct ceph_connection *con,
  469. unsigned long interval);
  470. void ceph_msg_data_add_pages(struct ceph_msg *msg, struct page **pages,
  471. size_t length, size_t alignment, bool own_pages);
  472. extern void ceph_msg_data_add_pagelist(struct ceph_msg *msg,
  473. struct ceph_pagelist *pagelist);
  474. #ifdef CONFIG_BLOCK
  475. void ceph_msg_data_add_bio(struct ceph_msg *msg, struct ceph_bio_iter *bio_pos,
  476. u32 length);
  477. #endif /* CONFIG_BLOCK */
  478. void ceph_msg_data_add_bvecs(struct ceph_msg *msg,
  479. struct ceph_bvec_iter *bvec_pos);
  480. struct ceph_msg *ceph_msg_new2(int type, int front_len, int max_data_items,
  481. gfp_t flags, bool can_fail);
  482. extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
  483. bool can_fail);
  484. extern struct ceph_msg *ceph_msg_get(struct ceph_msg *msg);
  485. extern void ceph_msg_put(struct ceph_msg *msg);
  486. extern void ceph_msg_dump(struct ceph_msg *msg);
  487. #endif