Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373349
b: refs/heads/master
c: f9e1577
h: refs/heads/master
i:
  373347: cd1fa17
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent 1ce60a1 commit 6642101
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 47 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 97fb1c7f6637ee61c90b8bc186d464cfd426b063
refs/heads/master: f9e15777afd87585f2222dfd446c2e52deb65eba
33 changes: 21 additions & 12 deletions trunk/include/linux/ceph/messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ struct ceph_messenger {
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.),
Expand All @@ -82,16 +82,25 @@ struct ceph_msg {
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 */
Expand Down
68 changes: 34 additions & 34 deletions trunk/net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,12 @@ static void prepare_message_data(struct ceph_msg *msg,
/* 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;
Expand Down Expand Up @@ -822,7 +822,7 @@ static void prepare_write_message(struct ceph_connection *con)
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 */
Expand Down Expand Up @@ -1054,12 +1054,12 @@ static void out_msg_pos_next(struct ceph_connection *con, struct page *page,
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
}
}
Expand All @@ -1082,8 +1082,8 @@ static void in_msg_pos_next(struct ceph_connection *con, size_t len,
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 */
}

Expand Down Expand Up @@ -1120,7 +1120,7 @@ static int write_partial_message_data(struct ceph_connection *con)
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;
}

Expand Down Expand Up @@ -1149,18 +1149,18 @@ static int write_partial_message_data(struct ceph_connection *con)
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;
Expand Down Expand Up @@ -1880,8 +1880,8 @@ static int read_partial_message_bio(struct ceph_connection *con,
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);
Expand Down Expand Up @@ -1916,7 +1916,7 @@ static int read_partial_msg_data(struct ceph_connection *con)
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;
Expand Down Expand Up @@ -2741,12 +2741,12 @@ void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
{
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);

Expand All @@ -2755,28 +2755,28 @@ void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
{
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);

void ceph_msg_data_set_trail(struct ceph_msg *msg, struct ceph_pagelist *trail)
{
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);

Expand Down Expand Up @@ -2954,18 +2954,18 @@ void ceph_msg_last_put(struct kref *kref)
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);
Expand All @@ -2977,7 +2977,7 @@ EXPORT_SYMBOL(ceph_msg_last_put);
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);
Expand Down

0 comments on commit 6642101

Please sign in to comment.