u32 required_features;
};
-#define ceph_msg_has_pages(m) ((m)->pages != NULL)
-#define ceph_msg_has_pagelist(m) ((m)->pagelist != NULL)
+#define ceph_msg_has_pages(m) ((m)->p.pages != NULL)
+#define ceph_msg_has_pagelist(m) ((m)->l.pagelist != NULL)
#ifdef CONFIG_BLOCK
-#define ceph_msg_has_bio(m) ((m)->bio != NULL)
+#define ceph_msg_has_bio(m) ((m)->b.bio != NULL)
#endif /* CONFIG_BLOCK */
-#define ceph_msg_has_trail(m) ((m)->trail != NULL)
+#define ceph_msg_has_trail(m) ((m)->t.trail != NULL)
/*
* a single message. it contains a header (src, dest, message type, etc.),
struct kvec front; /* unaligned blobs of message */
struct ceph_buffer *middle;
- struct page **pages; /* data payload. NOT OWNER. */
- unsigned int page_alignment; /* io offset in first page */
- size_t length; /* # data bytes in array or list */
- struct ceph_pagelist *pagelist; /* instead of pages */
+ /* data payload */
+ struct {
+ struct page **pages; /* NOT OWNER. */
+ size_t length; /* # data bytes in array */
+ unsigned int alignment; /* first page */
+ } p;
+ struct {
+ struct ceph_pagelist *pagelist;
+ } l;
#ifdef CONFIG_BLOCK
- unsigned int bio_seg; /* current bio segment */
- struct bio *bio; /* instead of pages/pagelist */
- struct bio *bio_iter; /* bio iterator */
+ struct {
+ struct bio *bio_iter; /* iterator */
+ struct bio *bio;
+ unsigned int bio_seg; /* current seg in bio */
+ } b;
#endif /* CONFIG_BLOCK */
- struct ceph_pagelist *trail; /* the trailing part of the data */
+ struct {
+ struct ceph_pagelist *trail; /* trailing part of data */
+ } t;
struct ceph_connection *con;
struct list_head list_head; /* links for connection lists */
/* initialize page iterator */
msg_pos->page = 0;
if (ceph_msg_has_pages(msg))
- msg_pos->page_pos = msg->page_alignment;
+ msg_pos->page_pos = msg->p.alignment;
else
msg_pos->page_pos = 0;
#ifdef CONFIG_BLOCK
if (ceph_msg_has_bio(msg))
- init_bio_iter(msg->bio, &msg->bio_iter, &msg->bio_seg);
+ init_bio_iter(msg->b.bio, &msg->b.bio_iter, &msg->b.bio_seg);
#endif
msg_pos->data_pos = 0;
msg_pos->did_page_crc = false;
dout("prepare_write_message %p seq %lld type %d len %d+%d+%d (%zd)\n",
m, con->out_seq, le16_to_cpu(m->hdr.type),
le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len),
- le32_to_cpu(m->hdr.data_len), m->length);
+ le32_to_cpu(m->hdr.data_len), m->p.length);
BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len);
/* tag + hdr + front + middle */
msg_pos->did_page_crc = false;
if (in_trail) {
BUG_ON(!ceph_msg_has_trail(msg));
- list_rotate_left(&msg->trail->head);
+ list_rotate_left(&msg->t.trail->head);
} else if (ceph_msg_has_pagelist(msg)) {
- list_rotate_left(&msg->pagelist->head);
+ list_rotate_left(&msg->l.pagelist->head);
#ifdef CONFIG_BLOCK
} else if (ceph_msg_has_bio(msg)) {
- iter_bio_next(&msg->bio_iter, &msg->bio_seg);
+ iter_bio_next(&msg->b.bio_iter, &msg->b.bio_seg);
#endif
}
}
msg_pos->page_pos = 0;
msg_pos->page++;
#ifdef CONFIG_BLOCK
- if (msg->bio)
- iter_bio_next(&msg->bio_iter, &msg->bio_seg);
+ if (msg->b.bio)
+ iter_bio_next(&msg->b.bio_iter, &msg->b.bio_seg);
#endif /* CONFIG_BLOCK */
}
size_t trail_off = data_len;
if (ceph_msg_has_trail(msg)) {
- trail_len = msg->trail->length;
+ trail_len = msg->t.trail->length;
trail_off -= trail_len;
}
if (in_trail) {
BUG_ON(!ceph_msg_has_trail(msg));
total_max_write = data_len - msg_pos->data_pos;
- page = list_first_entry(&msg->trail->head,
+ page = list_first_entry(&msg->t.trail->head,
struct page, lru);
} else if (ceph_msg_has_pages(msg)) {
- page = msg->pages[msg_pos->page];
+ page = msg->p.pages[msg_pos->page];
} else if (ceph_msg_has_pagelist(msg)) {
- page = list_first_entry(&msg->pagelist->head,
+ page = list_first_entry(&msg->l.pagelist->head,
struct page, lru);
#ifdef CONFIG_BLOCK
} else if (ceph_msg_has_bio(msg)) {
struct bio_vec *bv;
- bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
+ bv = bio_iovec_idx(msg->b.bio_iter, msg->b.bio_seg);
page = bv->bv_page;
bio_offset = bv->bv_offset;
max_write = bv->bv_len;
int ret;
BUG_ON(!msg);
- BUG_ON(!msg->bio_iter);
- bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
+ BUG_ON(!msg->b.bio_iter);
+ bv = bio_iovec_idx(msg->b.bio_iter, msg->b.bio_seg);
page = bv->bv_page;
page_offset = bv->bv_offset + msg_pos->page_pos;
BUG_ON(msg_pos->data_pos >= data_len);
data_len = le32_to_cpu(con->in_hdr.data_len);
while (msg_pos->data_pos < data_len) {
if (ceph_msg_has_pages(msg)) {
- ret = read_partial_message_pages(con, msg->pages,
+ ret = read_partial_message_pages(con, msg->p.pages,
data_len, do_datacrc);
if (ret <= 0)
return ret;
{
BUG_ON(!pages);
BUG_ON(!length);
- BUG_ON(msg->pages);
- BUG_ON(msg->length);
+ BUG_ON(msg->p.pages);
+ BUG_ON(msg->p.length);
- msg->pages = pages;
- msg->length = length;
- msg->page_alignment = alignment & ~PAGE_MASK;
+ msg->p.pages = pages;
+ msg->p.length = length;
+ msg->p.alignment = alignment & ~PAGE_MASK;
}
EXPORT_SYMBOL(ceph_msg_data_set_pages);
{
BUG_ON(!pagelist);
BUG_ON(!pagelist->length);
- BUG_ON(msg->pagelist);
+ BUG_ON(msg->l.pagelist);
- msg->pagelist = pagelist;
+ msg->l.pagelist = pagelist;
}
EXPORT_SYMBOL(ceph_msg_data_set_pagelist);
void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio)
{
BUG_ON(!bio);
- BUG_ON(msg->bio);
+ BUG_ON(msg->b.bio);
- msg->bio = bio;
+ msg->b.bio = bio;
}
EXPORT_SYMBOL(ceph_msg_data_set_bio);
{
BUG_ON(!trail);
BUG_ON(!trail->length);
- BUG_ON(msg->trail);
+ BUG_ON(msg->t.trail);
- msg->trail = trail;
+ msg->t.trail = trail;
}
EXPORT_SYMBOL(ceph_msg_data_set_trail);
m->middle = NULL;
}
if (ceph_msg_has_pages(m)) {
- m->length = 0;
- m->pages = NULL;
+ m->p.length = 0;
+ m->p.pages = NULL;
}
if (ceph_msg_has_pagelist(m)) {
- ceph_pagelist_release(m->pagelist);
- kfree(m->pagelist);
- m->pagelist = NULL;
+ ceph_pagelist_release(m->l.pagelist);
+ kfree(m->l.pagelist);
+ m->l.pagelist = NULL;
}
if (ceph_msg_has_trail(m))
- m->trail = NULL;
+ m->t.trail = NULL;
if (m->pool)
ceph_msgpool_put(m->pool, m);
void ceph_msg_dump(struct ceph_msg *msg)
{
pr_debug("msg_dump %p (front_max %d length %zd)\n", msg,
- msg->front_max, msg->length);
+ msg->front_max, msg->p.length);
print_hex_dump(KERN_DEBUG, "header: ",
DUMP_PREFIX_OFFSET, 16, 1,
&msg->hdr, sizeof(msg->hdr), true);