aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-14 15:09:06 -0400
committerSage Weil <sage@inktank.com>2013-05-02 00:17:57 -0400
commita19308048182d5f9e16b03b1d1c038d9346c7589 (patch)
tree1395d1027753afa2ab5caec1808385f3a68893be
parentfdce58ccb5df621695b079378c619046acabc778 (diff)
libceph: record message data length
Keep track of the length of the data portion for a message in a separate field in the ceph_msg structure. This information has been maintained in wire byte order in the message header, but that's going to change soon. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--include/linux/ceph/messenger.h4
-rw-r--r--net/ceph/messenger.c10
-rw-r--r--net/ceph/osd_client.c2
3 files changed, 13 insertions, 3 deletions
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 3181321bed6d..b832c0ce899a 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -139,6 +139,7 @@ struct ceph_msg {
139 struct kvec front; /* unaligned blobs of message */ 139 struct kvec front; /* unaligned blobs of message */
140 struct ceph_buffer *middle; 140 struct ceph_buffer *middle;
141 141
142 size_t data_length;
142 struct ceph_msg_data *data; /* data payload */ 143 struct ceph_msg_data *data; /* data payload */
143 144
144 struct ceph_connection *con; 145 struct ceph_connection *con;
@@ -270,7 +271,8 @@ extern void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
270 size_t length, size_t alignment); 271 size_t length, size_t alignment);
271extern void ceph_msg_data_set_pagelist(struct ceph_msg *msg, 272extern void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
272 struct ceph_pagelist *pagelist); 273 struct ceph_pagelist *pagelist);
273extern void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio); 274extern void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio,
275 size_t length);
274 276
275extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, 277extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
276 bool can_fail); 278 bool can_fail);
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index ee160864e8ea..fa9b4d0243a0 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2981,6 +2981,7 @@ void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
2981 2981
2982 BUG_ON(!pages); 2982 BUG_ON(!pages);
2983 BUG_ON(!length); 2983 BUG_ON(!length);
2984 BUG_ON(msg->data_length);
2984 BUG_ON(msg->data != NULL); 2985 BUG_ON(msg->data != NULL);
2985 2986
2986 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGES); 2987 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGES);
@@ -2990,6 +2991,7 @@ void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
2990 data->alignment = alignment & ~PAGE_MASK; 2991 data->alignment = alignment & ~PAGE_MASK;
2991 2992
2992 msg->data = data; 2993 msg->data = data;
2994 msg->data_length = length;
2993} 2995}
2994EXPORT_SYMBOL(ceph_msg_data_set_pages); 2996EXPORT_SYMBOL(ceph_msg_data_set_pages);
2995 2997
@@ -3000,6 +3002,7 @@ void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
3000 3002
3001 BUG_ON(!pagelist); 3003 BUG_ON(!pagelist);
3002 BUG_ON(!pagelist->length); 3004 BUG_ON(!pagelist->length);
3005 BUG_ON(msg->data_length);
3003 BUG_ON(msg->data != NULL); 3006 BUG_ON(msg->data != NULL);
3004 3007
3005 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGELIST); 3008 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGELIST);
@@ -3007,14 +3010,17 @@ void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
3007 data->pagelist = pagelist; 3010 data->pagelist = pagelist;
3008 3011
3009 msg->data = data; 3012 msg->data = data;
3013 msg->data_length = pagelist->length;
3010} 3014}
3011EXPORT_SYMBOL(ceph_msg_data_set_pagelist); 3015EXPORT_SYMBOL(ceph_msg_data_set_pagelist);
3012 3016
3013void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio) 3017void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio,
3018 size_t length)
3014{ 3019{
3015 struct ceph_msg_data *data; 3020 struct ceph_msg_data *data;
3016 3021
3017 BUG_ON(!bio); 3022 BUG_ON(!bio);
3023 BUG_ON(msg->data_length);
3018 BUG_ON(msg->data != NULL); 3024 BUG_ON(msg->data != NULL);
3019 3025
3020 data = ceph_msg_data_create(CEPH_MSG_DATA_BIO); 3026 data = ceph_msg_data_create(CEPH_MSG_DATA_BIO);
@@ -3022,6 +3028,7 @@ void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio)
3022 data->bio = bio; 3028 data->bio = bio;
3023 3029
3024 msg->data = data; 3030 msg->data = data;
3031 msg->data_length = length;
3025} 3032}
3026EXPORT_SYMBOL(ceph_msg_data_set_bio); 3033EXPORT_SYMBOL(ceph_msg_data_set_bio);
3027 3034
@@ -3200,6 +3207,7 @@ void ceph_msg_last_put(struct kref *kref)
3200 } 3207 }
3201 ceph_msg_data_destroy(m->data); 3208 ceph_msg_data_destroy(m->data);
3202 m->data = NULL; 3209 m->data = NULL;
3210 m->data_length = 0;
3203 3211
3204 if (m->pool) 3212 if (m->pool)
3205 ceph_msgpool_put(m->pool, m); 3213 ceph_msgpool_put(m->pool, m);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index e0887923e5ab..0b4951e27532 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1848,7 +1848,7 @@ static void ceph_osdc_msg_data_set(struct ceph_msg *msg,
1848 ceph_msg_data_set_pagelist(msg, osd_data->pagelist); 1848 ceph_msg_data_set_pagelist(msg, osd_data->pagelist);
1849#ifdef CONFIG_BLOCK 1849#ifdef CONFIG_BLOCK
1850 } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { 1850 } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
1851 ceph_msg_data_set_bio(msg, osd_data->bio); 1851 ceph_msg_data_set_bio(msg, osd_data->bio, osd_data->bio_length);
1852#endif 1852#endif
1853 } else { 1853 } else {
1854 BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); 1854 BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE);