aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-01 19:00:16 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:54 -0400
commitf9e15777afd87585f2222dfd446c2e52deb65eba (patch)
treed7f3d460c4384d502a8a7b16bcd530f803a54192 /net
parent97fb1c7f6637ee61c90b8bc186d464cfd426b063 (diff)
libceph: be explicit about message data representation
A ceph message has a data payload portion. The memory for that data (either the source of data to send or the location to place data that is received) is specified in several ways. The ceph_msg structure includes fields for all of those ways, but this mispresents the fact that not all of them are used at a time. Specifically, the data in a message can be in: - an array of pages - a list of pages - a list of Linux bios - a second list of pages (the "trail") (The two page lists are currently only ever used for outgoing data.) Impose more structure on the ceph message, making the grouping of some of these fields explicit. Shorten the name of the "page_alignment" field. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index c74b5289778a..f485455f05a8 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -747,12 +747,12 @@ static void prepare_message_data(struct ceph_msg *msg,
747 /* initialize page iterator */ 747 /* initialize page iterator */
748 msg_pos->page = 0; 748 msg_pos->page = 0;
749 if (ceph_msg_has_pages(msg)) 749 if (ceph_msg_has_pages(msg))
750 msg_pos->page_pos = msg->page_alignment; 750 msg_pos->page_pos = msg->p.alignment;
751 else 751 else
752 msg_pos->page_pos = 0; 752 msg_pos->page_pos = 0;
753#ifdef CONFIG_BLOCK 753#ifdef CONFIG_BLOCK
754 if (ceph_msg_has_bio(msg)) 754 if (ceph_msg_has_bio(msg))
755 init_bio_iter(msg->bio, &msg->bio_iter, &msg->bio_seg); 755 init_bio_iter(msg->b.bio, &msg->b.bio_iter, &msg->b.bio_seg);
756#endif 756#endif
757 msg_pos->data_pos = 0; 757 msg_pos->data_pos = 0;
758 msg_pos->did_page_crc = false; 758 msg_pos->did_page_crc = false;
@@ -822,7 +822,7 @@ static void prepare_write_message(struct ceph_connection *con)
822 dout("prepare_write_message %p seq %lld type %d len %d+%d+%d (%zd)\n", 822 dout("prepare_write_message %p seq %lld type %d len %d+%d+%d (%zd)\n",
823 m, con->out_seq, le16_to_cpu(m->hdr.type), 823 m, con->out_seq, le16_to_cpu(m->hdr.type),
824 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len), 824 le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len),
825 le32_to_cpu(m->hdr.data_len), m->length); 825 le32_to_cpu(m->hdr.data_len), m->p.length);
826 BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len); 826 BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len);
827 827
828 /* tag + hdr + front + middle */ 828 /* tag + hdr + front + middle */
@@ -1054,12 +1054,12 @@ static void out_msg_pos_next(struct ceph_connection *con, struct page *page,
1054 msg_pos->did_page_crc = false; 1054 msg_pos->did_page_crc = false;
1055 if (in_trail) { 1055 if (in_trail) {
1056 BUG_ON(!ceph_msg_has_trail(msg)); 1056 BUG_ON(!ceph_msg_has_trail(msg));
1057 list_rotate_left(&msg->trail->head); 1057 list_rotate_left(&msg->t.trail->head);
1058 } else if (ceph_msg_has_pagelist(msg)) { 1058 } else if (ceph_msg_has_pagelist(msg)) {
1059 list_rotate_left(&msg->pagelist->head); 1059 list_rotate_left(&msg->l.pagelist->head);
1060#ifdef CONFIG_BLOCK 1060#ifdef CONFIG_BLOCK
1061 } else if (ceph_msg_has_bio(msg)) { 1061 } else if (ceph_msg_has_bio(msg)) {
1062 iter_bio_next(&msg->bio_iter, &msg->bio_seg); 1062 iter_bio_next(&msg->b.bio_iter, &msg->b.bio_seg);
1063#endif 1063#endif
1064 } 1064 }
1065} 1065}
@@ -1082,8 +1082,8 @@ static void in_msg_pos_next(struct ceph_connection *con, size_t len,
1082 msg_pos->page_pos = 0; 1082 msg_pos->page_pos = 0;
1083 msg_pos->page++; 1083 msg_pos->page++;
1084#ifdef CONFIG_BLOCK 1084#ifdef CONFIG_BLOCK
1085 if (msg->bio) 1085 if (msg->b.bio)
1086 iter_bio_next(&msg->bio_iter, &msg->bio_seg); 1086 iter_bio_next(&msg->b.bio_iter, &msg->b.bio_seg);
1087#endif /* CONFIG_BLOCK */ 1087#endif /* CONFIG_BLOCK */
1088} 1088}
1089 1089
@@ -1120,7 +1120,7 @@ static int write_partial_message_data(struct ceph_connection *con)
1120 size_t trail_off = data_len; 1120 size_t trail_off = data_len;
1121 1121
1122 if (ceph_msg_has_trail(msg)) { 1122 if (ceph_msg_has_trail(msg)) {
1123 trail_len = msg->trail->length; 1123 trail_len = msg->t.trail->length;
1124 trail_off -= trail_len; 1124 trail_off -= trail_len;
1125 } 1125 }
1126 1126
@@ -1149,18 +1149,18 @@ static int write_partial_message_data(struct ceph_connection *con)
1149 if (in_trail) { 1149 if (in_trail) {
1150 BUG_ON(!ceph_msg_has_trail(msg)); 1150 BUG_ON(!ceph_msg_has_trail(msg));
1151 total_max_write = data_len - msg_pos->data_pos; 1151 total_max_write = data_len - msg_pos->data_pos;
1152 page = list_first_entry(&msg->trail->head, 1152 page = list_first_entry(&msg->t.trail->head,
1153 struct page, lru); 1153 struct page, lru);
1154 } else if (ceph_msg_has_pages(msg)) { 1154 } else if (ceph_msg_has_pages(msg)) {
1155 page = msg->pages[msg_pos->page]; 1155 page = msg->p.pages[msg_pos->page];
1156 } else if (ceph_msg_has_pagelist(msg)) { 1156 } else if (ceph_msg_has_pagelist(msg)) {
1157 page = list_first_entry(&msg->pagelist->head, 1157 page = list_first_entry(&msg->l.pagelist->head,
1158 struct page, lru); 1158 struct page, lru);
1159#ifdef CONFIG_BLOCK 1159#ifdef CONFIG_BLOCK
1160 } else if (ceph_msg_has_bio(msg)) { 1160 } else if (ceph_msg_has_bio(msg)) {
1161 struct bio_vec *bv; 1161 struct bio_vec *bv;
1162 1162
1163 bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); 1163 bv = bio_iovec_idx(msg->b.bio_iter, msg->b.bio_seg);
1164 page = bv->bv_page; 1164 page = bv->bv_page;
1165 bio_offset = bv->bv_offset; 1165 bio_offset = bv->bv_offset;
1166 max_write = bv->bv_len; 1166 max_write = bv->bv_len;
@@ -1880,8 +1880,8 @@ static int read_partial_message_bio(struct ceph_connection *con,
1880 int ret; 1880 int ret;
1881 1881
1882 BUG_ON(!msg); 1882 BUG_ON(!msg);
1883 BUG_ON(!msg->bio_iter); 1883 BUG_ON(!msg->b.bio_iter);
1884 bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); 1884 bv = bio_iovec_idx(msg->b.bio_iter, msg->b.bio_seg);
1885 page = bv->bv_page; 1885 page = bv->bv_page;
1886 page_offset = bv->bv_offset + msg_pos->page_pos; 1886 page_offset = bv->bv_offset + msg_pos->page_pos;
1887 BUG_ON(msg_pos->data_pos >= data_len); 1887 BUG_ON(msg_pos->data_pos >= data_len);
@@ -1916,7 +1916,7 @@ static int read_partial_msg_data(struct ceph_connection *con)
1916 data_len = le32_to_cpu(con->in_hdr.data_len); 1916 data_len = le32_to_cpu(con->in_hdr.data_len);
1917 while (msg_pos->data_pos < data_len) { 1917 while (msg_pos->data_pos < data_len) {
1918 if (ceph_msg_has_pages(msg)) { 1918 if (ceph_msg_has_pages(msg)) {
1919 ret = read_partial_message_pages(con, msg->pages, 1919 ret = read_partial_message_pages(con, msg->p.pages,
1920 data_len, do_datacrc); 1920 data_len, do_datacrc);
1921 if (ret <= 0) 1921 if (ret <= 0)
1922 return ret; 1922 return ret;
@@ -2741,12 +2741,12 @@ void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
2741{ 2741{
2742 BUG_ON(!pages); 2742 BUG_ON(!pages);
2743 BUG_ON(!length); 2743 BUG_ON(!length);
2744 BUG_ON(msg->pages); 2744 BUG_ON(msg->p.pages);
2745 BUG_ON(msg->length); 2745 BUG_ON(msg->p.length);
2746 2746
2747 msg->pages = pages; 2747 msg->p.pages = pages;
2748 msg->length = length; 2748 msg->p.length = length;
2749 msg->page_alignment = alignment & ~PAGE_MASK; 2749 msg->p.alignment = alignment & ~PAGE_MASK;
2750} 2750}
2751EXPORT_SYMBOL(ceph_msg_data_set_pages); 2751EXPORT_SYMBOL(ceph_msg_data_set_pages);
2752 2752
@@ -2755,18 +2755,18 @@ void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
2755{ 2755{
2756 BUG_ON(!pagelist); 2756 BUG_ON(!pagelist);
2757 BUG_ON(!pagelist->length); 2757 BUG_ON(!pagelist->length);
2758 BUG_ON(msg->pagelist); 2758 BUG_ON(msg->l.pagelist);
2759 2759
2760 msg->pagelist = pagelist; 2760 msg->l.pagelist = pagelist;
2761} 2761}
2762EXPORT_SYMBOL(ceph_msg_data_set_pagelist); 2762EXPORT_SYMBOL(ceph_msg_data_set_pagelist);
2763 2763
2764void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio) 2764void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio)
2765{ 2765{
2766 BUG_ON(!bio); 2766 BUG_ON(!bio);
2767 BUG_ON(msg->bio); 2767 BUG_ON(msg->b.bio);
2768 2768
2769 msg->bio = bio; 2769 msg->b.bio = bio;
2770} 2770}
2771EXPORT_SYMBOL(ceph_msg_data_set_bio); 2771EXPORT_SYMBOL(ceph_msg_data_set_bio);
2772 2772
@@ -2774,9 +2774,9 @@ void ceph_msg_data_set_trail(struct ceph_msg *msg, struct ceph_pagelist *trail)
2774{ 2774{
2775 BUG_ON(!trail); 2775 BUG_ON(!trail);
2776 BUG_ON(!trail->length); 2776 BUG_ON(!trail->length);
2777 BUG_ON(msg->trail); 2777 BUG_ON(msg->t.trail);
2778 2778
2779 msg->trail = trail; 2779 msg->t.trail = trail;
2780} 2780}
2781EXPORT_SYMBOL(ceph_msg_data_set_trail); 2781EXPORT_SYMBOL(ceph_msg_data_set_trail);
2782 2782
@@ -2954,18 +2954,18 @@ void ceph_msg_last_put(struct kref *kref)
2954 m->middle = NULL; 2954 m->middle = NULL;
2955 } 2955 }
2956 if (ceph_msg_has_pages(m)) { 2956 if (ceph_msg_has_pages(m)) {
2957 m->length = 0; 2957 m->p.length = 0;
2958 m->pages = NULL; 2958 m->p.pages = NULL;
2959 } 2959 }
2960 2960
2961 if (ceph_msg_has_pagelist(m)) { 2961 if (ceph_msg_has_pagelist(m)) {
2962 ceph_pagelist_release(m->pagelist); 2962 ceph_pagelist_release(m->l.pagelist);
2963 kfree(m->pagelist); 2963 kfree(m->l.pagelist);
2964 m->pagelist = NULL; 2964 m->l.pagelist = NULL;
2965 } 2965 }
2966 2966
2967 if (ceph_msg_has_trail(m)) 2967 if (ceph_msg_has_trail(m))
2968 m->trail = NULL; 2968 m->t.trail = NULL;
2969 2969
2970 if (m->pool) 2970 if (m->pool)
2971 ceph_msgpool_put(m->pool, m); 2971 ceph_msgpool_put(m->pool, m);
@@ -2977,7 +2977,7 @@ EXPORT_SYMBOL(ceph_msg_last_put);
2977void ceph_msg_dump(struct ceph_msg *msg) 2977void ceph_msg_dump(struct ceph_msg *msg)
2978{ 2978{
2979 pr_debug("msg_dump %p (front_max %d length %zd)\n", msg, 2979 pr_debug("msg_dump %p (front_max %d length %zd)\n", msg,
2980 msg->front_max, msg->length); 2980 msg->front_max, msg->p.length);
2981 print_hex_dump(KERN_DEBUG, "header: ", 2981 print_hex_dump(KERN_DEBUG, "header: ",
2982 DUMP_PREFIX_OFFSET, 16, 1, 2982 DUMP_PREFIX_OFFSET, 16, 1,
2983 &msg->hdr, sizeof(msg->hdr), true); 2983 &msg->hdr, sizeof(msg->hdr), true);