}
}
+struct ceph_msg_data {
+ enum ceph_msg_data_type type;
+ union {
+#ifdef CONFIG_BLOCK
+ struct {
+ struct bio *bio;
+ size_t bio_length;
+ };
+#endif /* CONFIG_BLOCK */
+ struct {
+ struct page **pages; /* NOT OWNER. */
+ size_t length; /* total # bytes */
+ unsigned int alignment; /* first page */
+ };
+ struct ceph_pagelist *pagelist;
+ };
+ struct ceph_msg_data_cursor *cursor;
+};
+
struct ceph_msg_data_cursor {
size_t resid; /* bytes not yet consumed */
bool last_piece; /* now at last piece of data item */
};
};
-struct ceph_msg_data {
- enum ceph_msg_data_type type;
- union {
-#ifdef CONFIG_BLOCK
- struct {
- struct bio *bio;
- size_t bio_length;
- };
-#endif /* CONFIG_BLOCK */
- struct {
- struct page **pages; /* NOT OWNER. */
- size_t length; /* total # bytes */
- unsigned int alignment; /* first page */
- };
- struct ceph_pagelist *pagelist;
- };
- struct ceph_msg_data_cursor cursor; /* pagelist only */
-};
-
/*
* a single message. it contains a header (src, dest, message type, etc.),
* footer (crc values, mainly), a "front" message body, and possibly a
struct kvec front; /* unaligned blobs of message */
struct ceph_buffer *middle;
- size_t data_length;
- struct ceph_msg_data *data; /* data payload */
+ size_t data_length;
+ struct ceph_msg_data *data;
+ struct ceph_msg_data_cursor cursor;
struct ceph_connection *con;
struct list_head list_head; /* links for connection lists */
static void ceph_msg_data_bio_cursor_init(struct ceph_msg_data *data,
size_t length)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
struct bio *bio;
BUG_ON(data->type != CEPH_MSG_DATA_BIO);
size_t *page_offset,
size_t *length)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
struct bio *bio;
struct bio_vec *bio_vec;
unsigned int index;
static bool ceph_msg_data_bio_advance(struct ceph_msg_data *data, size_t bytes)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
struct bio *bio;
struct bio_vec *bio_vec;
unsigned int index;
static void ceph_msg_data_pages_cursor_init(struct ceph_msg_data *data,
size_t length)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
int page_count;
BUG_ON(data->type != CEPH_MSG_DATA_PAGES);
size_t *page_offset,
size_t *length)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
BUG_ON(data->type != CEPH_MSG_DATA_PAGES);
static bool ceph_msg_data_pages_advance(struct ceph_msg_data *data,
size_t bytes)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
BUG_ON(data->type != CEPH_MSG_DATA_PAGES);
static void ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data *data,
size_t length)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
struct ceph_pagelist *pagelist;
struct page *page;
size_t *page_offset,
size_t *length)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
struct ceph_pagelist *pagelist;
BUG_ON(data->type != CEPH_MSG_DATA_PAGELIST);
else
*length = PAGE_SIZE - *page_offset;
- return data->cursor.page;
+ return data->cursor->page;
}
static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data *data,
size_t bytes)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
struct ceph_pagelist *pagelist;
BUG_ON(data->type != CEPH_MSG_DATA_PAGELIST);
/* BUG(); */
break;
}
- data->cursor.need_crc = true;
+ data->cursor->need_crc = true;
}
/*
BUG_ON(*page_offset + *length > PAGE_SIZE);
BUG_ON(!*length);
if (last_piece)
- *last_piece = data->cursor.last_piece;
+ *last_piece = data->cursor->last_piece;
return page;
}
*/
static bool ceph_msg_data_advance(struct ceph_msg_data *data, size_t bytes)
{
- struct ceph_msg_data_cursor *cursor = &data->cursor;
+ struct ceph_msg_data_cursor *cursor = data->cursor;
bool new_piece;
BUG_ON(bytes > cursor->resid);
BUG();
break;
}
- data->cursor.need_crc = new_piece;
+ data->cursor->need_crc = new_piece;
return new_piece;
}
static int write_partial_message_data(struct ceph_connection *con)
{
struct ceph_msg *msg = con->out_msg;
- struct ceph_msg_data_cursor *cursor = &msg->data->cursor;
+ struct ceph_msg_data_cursor *cursor = msg->data->cursor;
bool do_datacrc = !con->msgr->nocrc;
u32 crc;
static int read_partial_msg_data(struct ceph_connection *con)
{
struct ceph_msg *msg = con->in_msg;
- struct ceph_msg_data_cursor *cursor = &msg->data->cursor;
+ struct ceph_msg_data_cursor *cursor = msg->data->cursor;
const bool do_datacrc = !con->msgr->nocrc;
struct page *page;
size_t page_offset;
data = ceph_msg_data_create(CEPH_MSG_DATA_PAGES);
BUG_ON(!data);
+ data->cursor = &msg->cursor;
data->pages = pages;
data->length = length;
data->alignment = alignment & ~PAGE_MASK;
data = ceph_msg_data_create(CEPH_MSG_DATA_PAGELIST);
BUG_ON(!data);
+ data->cursor = &msg->cursor;
data->pagelist = pagelist;
msg->data = data;
data = ceph_msg_data_create(CEPH_MSG_DATA_BIO);
BUG_ON(!data);
+ data->cursor = &msg->cursor;
data->bio = bio;
data->bio_length = length;