aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/messenger.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-07 16:38:26 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:42 -0400
commit4a73ef27ad04f1b8ea23eb55e50b20fcc0530a6f (patch)
tree5a0a127ca9b3b51a3f388c980f49229245fed361 /net/ceph/messenger.c
parentebf18f47093e968105767eed4a0aa155e86b224e (diff)
libceph: record message data byte length
Record the number of bytes of data in a page array rather than the number of pages in the array. It can be assumed that the page array is of sufficient size to hold the number of bytes indicated (and offset by the indicated alignment). Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r--net/ceph/messenger.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 1965d785cf83..f48e2af95005 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -809,11 +809,10 @@ static void prepare_write_message(struct ceph_connection *con)
809 m->bio_iter = NULL; 809 m->bio_iter = NULL;
810#endif 810#endif
811 811
812 dout("prepare_write_message %p seq %lld type %d len %d+%d+%d %d pgs\n", 812 dout("prepare_write_message %p seq %lld type %d len %d+%d+%d (%zd)\n",
813 m, con->out_seq, le16_to_cpu(m->hdr.type), 813 m, con->out_seq, le16_to_cpu(m->hdr.type),
814 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len), 814 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len),
815 le32_to_cpu(m->hdr.data_len), 815 le32_to_cpu(m->hdr.data_len), m->length);
816 m->page_count);
817 BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len); 816 BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len);
818 817
819 /* tag + hdr + front + middle */ 818 /* tag + hdr + front + middle */
@@ -1091,9 +1090,8 @@ static int write_partial_msg_pages(struct ceph_connection *con)
1091 const size_t trail_len = (msg->trail ? msg->trail->length : 0); 1090 const size_t trail_len = (msg->trail ? msg->trail->length : 0);
1092 const size_t trail_off = data_len - trail_len; 1091 const size_t trail_off = data_len - trail_len;
1093 1092
1094 dout("write_partial_msg_pages %p msg %p page %d/%d offset %d\n", 1093 dout("write_partial_msg_pages %p msg %p page %d offset %d\n",
1095 con, msg, con->out_msg_pos.page, msg->page_count, 1094 con, msg, con->out_msg_pos.page, con->out_msg_pos.page_pos);
1096 con->out_msg_pos.page_pos);
1097 1095
1098 /* 1096 /*
1099 * Iterate through each page that contains data to be 1097 * Iterate through each page that contains data to be
@@ -2695,10 +2693,10 @@ void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
2695 /* BUG_ON(!pages); */ 2693 /* BUG_ON(!pages); */
2696 /* BUG_ON(!length); */ 2694 /* BUG_ON(!length); */
2697 /* BUG_ON(msg->pages); */ 2695 /* BUG_ON(msg->pages); */
2698 /* BUG_ON(msg->page_count); */ 2696 /* BUG_ON(msg->length); */
2699 2697
2700 msg->pages = pages; 2698 msg->pages = pages;
2701 msg->page_count = calc_pages_for((u64)alignment, (u64)length); 2699 msg->length = length;
2702 msg->page_alignment = alignment & ~PAGE_MASK; 2700 msg->page_alignment = alignment & ~PAGE_MASK;
2703} 2701}
2704EXPORT_SYMBOL(ceph_msg_data_set_pages); 2702EXPORT_SYMBOL(ceph_msg_data_set_pages);
@@ -2906,7 +2904,7 @@ void ceph_msg_last_put(struct kref *kref)
2906 ceph_buffer_put(m->middle); 2904 ceph_buffer_put(m->middle);
2907 m->middle = NULL; 2905 m->middle = NULL;
2908 } 2906 }
2909 m->page_count = 0; 2907 m->length = 0;
2910 m->pages = NULL; 2908 m->pages = NULL;
2911 2909
2912 if (m->pagelist) { 2910 if (m->pagelist) {
@@ -2926,8 +2924,8 @@ EXPORT_SYMBOL(ceph_msg_last_put);
2926 2924
2927void ceph_msg_dump(struct ceph_msg *msg) 2925void ceph_msg_dump(struct ceph_msg *msg)
2928{ 2926{
2929 pr_debug("msg_dump %p (front_max %d page_count %d)\n", msg, 2927 pr_debug("msg_dump %p (front_max %d length %zd)\n", msg,
2930 msg->front_max, msg->page_count); 2928 msg->front_max, msg->length);
2931 print_hex_dump(KERN_DEBUG, "header: ", 2929 print_hex_dump(KERN_DEBUG, "header: ",
2932 DUMP_PREFIX_OFFSET, 16, 1, 2930 DUMP_PREFIX_OFFSET, 16, 1,
2933 &msg->hdr, sizeof(msg->hdr), true); 2931 &msg->hdr, sizeof(msg->hdr), true);