diff options
Diffstat (limited to 'include/linux/ceph/messenger.h')
| -rw-r--r-- | include/linux/ceph/messenger.h | 104 |
1 files changed, 85 insertions, 19 deletions
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h index 60903e0f665c..7c1420bb1dce 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h | |||
| @@ -64,6 +64,77 @@ struct ceph_messenger { | |||
| 64 | u32 required_features; | 64 | u32 required_features; |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | enum ceph_msg_data_type { | ||
| 68 | CEPH_MSG_DATA_NONE, /* message contains no data payload */ | ||
| 69 | CEPH_MSG_DATA_PAGES, /* data source/destination is a page array */ | ||
| 70 | CEPH_MSG_DATA_PAGELIST, /* data source/destination is a pagelist */ | ||
| 71 | #ifdef CONFIG_BLOCK | ||
| 72 | CEPH_MSG_DATA_BIO, /* data source/destination is a bio list */ | ||
| 73 | #endif /* CONFIG_BLOCK */ | ||
| 74 | }; | ||
| 75 | |||
| 76 | static __inline__ bool ceph_msg_data_type_valid(enum ceph_msg_data_type type) | ||
| 77 | { | ||
| 78 | switch (type) { | ||
| 79 | case CEPH_MSG_DATA_NONE: | ||
| 80 | case CEPH_MSG_DATA_PAGES: | ||
| 81 | case CEPH_MSG_DATA_PAGELIST: | ||
| 82 | #ifdef CONFIG_BLOCK | ||
| 83 | case CEPH_MSG_DATA_BIO: | ||
| 84 | #endif /* CONFIG_BLOCK */ | ||
| 85 | return true; | ||
| 86 | default: | ||
| 87 | return false; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | struct ceph_msg_data { | ||
| 92 | struct list_head links; /* ceph_msg->data */ | ||
| 93 | enum ceph_msg_data_type type; | ||
| 94 | union { | ||
| 95 | #ifdef CONFIG_BLOCK | ||
| 96 | struct { | ||
| 97 | struct bio *bio; | ||
| 98 | size_t bio_length; | ||
| 99 | }; | ||
| 100 | #endif /* CONFIG_BLOCK */ | ||
| 101 | struct { | ||
| 102 | struct page **pages; /* NOT OWNER. */ | ||
| 103 | size_t length; /* total # bytes */ | ||
| 104 | unsigned int alignment; /* first page */ | ||
| 105 | }; | ||
| 106 | struct ceph_pagelist *pagelist; | ||
| 107 | }; | ||
| 108 | }; | ||
| 109 | |||
| 110 | struct ceph_msg_data_cursor { | ||
| 111 | size_t total_resid; /* across all data items */ | ||
| 112 | struct list_head *data_head; /* = &ceph_msg->data */ | ||
| 113 | |||
| 114 | struct ceph_msg_data *data; /* current data item */ | ||
| 115 | size_t resid; /* bytes not yet consumed */ | ||
| 116 | bool last_piece; /* current is last piece */ | ||
| 117 | bool need_crc; /* crc update needed */ | ||
| 118 | union { | ||
| 119 | #ifdef CONFIG_BLOCK | ||
| 120 | struct { /* bio */ | ||
| 121 | struct bio *bio; /* bio from list */ | ||
| 122 | unsigned int vector_index; /* vector from bio */ | ||
| 123 | unsigned int vector_offset; /* bytes from vector */ | ||
| 124 | }; | ||
| 125 | #endif /* CONFIG_BLOCK */ | ||
| 126 | struct { /* pages */ | ||
| 127 | unsigned int page_offset; /* offset in page */ | ||
| 128 | unsigned short page_index; /* index in array */ | ||
| 129 | unsigned short page_count; /* pages in array */ | ||
| 130 | }; | ||
| 131 | struct { /* pagelist */ | ||
| 132 | struct page *page; /* page from list */ | ||
| 133 | size_t offset; /* bytes from list */ | ||
| 134 | }; | ||
| 135 | }; | ||
| 136 | }; | ||
| 137 | |||
| 67 | /* | 138 | /* |
| 68 | * a single message. it contains a header (src, dest, message type, etc.), | 139 | * a single message. it contains a header (src, dest, message type, etc.), |
| 69 | * footer (crc values, mainly), a "front" message body, and possibly a | 140 | * footer (crc values, mainly), a "front" message body, and possibly a |
| @@ -74,21 +145,15 @@ struct ceph_msg { | |||
| 74 | struct ceph_msg_footer footer; /* footer */ | 145 | struct ceph_msg_footer footer; /* footer */ |
| 75 | struct kvec front; /* unaligned blobs of message */ | 146 | struct kvec front; /* unaligned blobs of message */ |
| 76 | struct ceph_buffer *middle; | 147 | struct ceph_buffer *middle; |
| 77 | struct page **pages; /* data payload. NOT OWNER. */ | 148 | |
| 78 | unsigned nr_pages; /* size of page array */ | 149 | size_t data_length; |
| 79 | unsigned page_alignment; /* io offset in first page */ | 150 | struct list_head data; |
| 80 | struct ceph_pagelist *pagelist; /* instead of pages */ | 151 | struct ceph_msg_data_cursor cursor; |
| 81 | 152 | ||
| 82 | struct ceph_connection *con; | 153 | struct ceph_connection *con; |
| 83 | struct list_head list_head; | 154 | struct list_head list_head; /* links for connection lists */ |
| 84 | 155 | ||
| 85 | struct kref kref; | 156 | struct kref kref; |
| 86 | #ifdef CONFIG_BLOCK | ||
| 87 | struct bio *bio; /* instead of pages/pagelist */ | ||
| 88 | struct bio *bio_iter; /* bio iterator */ | ||
| 89 | int bio_seg; /* current bio segment */ | ||
| 90 | #endif /* CONFIG_BLOCK */ | ||
| 91 | struct ceph_pagelist *trail; /* the trailing part of the data */ | ||
| 92 | bool front_is_vmalloc; | 157 | bool front_is_vmalloc; |
| 93 | bool more_to_follow; | 158 | bool more_to_follow; |
| 94 | bool needs_out_seq; | 159 | bool needs_out_seq; |
| @@ -98,12 +163,6 @@ struct ceph_msg { | |||
| 98 | struct ceph_msgpool *pool; | 163 | struct ceph_msgpool *pool; |
| 99 | }; | 164 | }; |
| 100 | 165 | ||
| 101 | struct ceph_msg_pos { | ||
| 102 | int page, page_pos; /* which page; offset in page */ | ||
| 103 | int data_pos; /* offset in data payload */ | ||
| 104 | bool did_page_crc; /* true if we've calculated crc for current page */ | ||
| 105 | }; | ||
| 106 | |||
| 107 | /* ceph connection fault delay defaults, for exponential backoff */ | 166 | /* ceph connection fault delay defaults, for exponential backoff */ |
| 108 | #define BASE_DELAY_INTERVAL (HZ/2) | 167 | #define BASE_DELAY_INTERVAL (HZ/2) |
| 109 | #define MAX_DELAY_INTERVAL (5 * 60 * HZ) | 168 | #define MAX_DELAY_INTERVAL (5 * 60 * HZ) |
| @@ -161,7 +220,6 @@ struct ceph_connection { | |||
| 161 | struct ceph_msg *out_msg; /* sending message (== tail of | 220 | struct ceph_msg *out_msg; /* sending message (== tail of |
| 162 | out_sent) */ | 221 | out_sent) */ |
| 163 | bool out_msg_done; | 222 | bool out_msg_done; |
| 164 | struct ceph_msg_pos out_msg_pos; | ||
| 165 | 223 | ||
| 166 | struct kvec out_kvec[8], /* sending header/footer data */ | 224 | struct kvec out_kvec[8], /* sending header/footer data */ |
| 167 | *out_kvec_cur; | 225 | *out_kvec_cur; |
| @@ -175,7 +233,6 @@ struct ceph_connection { | |||
| 175 | /* message in temps */ | 233 | /* message in temps */ |
| 176 | struct ceph_msg_header in_hdr; | 234 | struct ceph_msg_header in_hdr; |
| 177 | struct ceph_msg *in_msg; | 235 | struct ceph_msg *in_msg; |
| 178 | struct ceph_msg_pos in_msg_pos; | ||
| 179 | u32 in_front_crc, in_middle_crc, in_data_crc; /* calculated crc */ | 236 | u32 in_front_crc, in_middle_crc, in_data_crc; /* calculated crc */ |
| 180 | 237 | ||
| 181 | char in_tag; /* protocol control byte */ | 238 | char in_tag; /* protocol control byte */ |
| @@ -218,6 +275,15 @@ extern void ceph_msg_revoke_incoming(struct ceph_msg *msg); | |||
| 218 | 275 | ||
| 219 | extern void ceph_con_keepalive(struct ceph_connection *con); | 276 | extern void ceph_con_keepalive(struct ceph_connection *con); |
| 220 | 277 | ||
| 278 | extern void ceph_msg_data_add_pages(struct ceph_msg *msg, struct page **pages, | ||
| 279 | size_t length, size_t alignment); | ||
| 280 | extern void ceph_msg_data_add_pagelist(struct ceph_msg *msg, | ||
| 281 | struct ceph_pagelist *pagelist); | ||
| 282 | #ifdef CONFIG_BLOCK | ||
| 283 | extern void ceph_msg_data_add_bio(struct ceph_msg *msg, struct bio *bio, | ||
| 284 | size_t length); | ||
| 285 | #endif /* CONFIG_BLOCK */ | ||
| 286 | |||
| 221 | extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, | 287 | extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, |
| 222 | bool can_fail); | 288 | bool can_fail); |
| 223 | extern void ceph_msg_kfree(struct ceph_msg *m); | 289 | extern void ceph_msg_kfree(struct ceph_msg *m); |
