diff options
author | Alex Elder <elder@inktank.com> | 2013-03-07 00:39:39 -0500 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:16:58 -0400 |
commit | 7fe1e5e57b84eab98ff352519aa66e86dac5bf61 (patch) | |
tree | e63f60e28bdcc52c10507cf9fc9d772aa8577411 /net/ceph/messenger.c | |
parent | dd236fcb65d7b6b80c408cb5f66aab55f4594284 (diff) |
libceph: use data cursor for message pagelist
Switch to using the message cursor for the (non-trail) outgoing
pagelist data item in a message if present.
Notes on the logic changes in out_msg_pos_next():
- only the mds client uses a ceph pagelist for message data;
- if the mds client ever uses a pagelist, it never uses a page
array (or anything else, for that matter) for data in the same
message;
- only the osd client uses the trail portion of a message data,
and when it does, it never uses any other data fields for
outgoing data in the same message; and finally
- only the rbd client uses bio message data (never pagelist).
Therefore out_msg_pos_next() can assume:
- if we're in the trail portion of a message, the message data
pagelist, data, and bio can be ignored; and
- if there is a page list, there will never be any a bio or page
array data, and vice-versa.
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.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 4cc27a136e35..30c8792be180 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -931,8 +931,10 @@ static void prepare_message_data(struct ceph_msg *msg, | |||
931 | #endif | 931 | #endif |
932 | msg_pos->data_pos = 0; | 932 | msg_pos->data_pos = 0; |
933 | 933 | ||
934 | /* If there's a trail, initialize its cursor */ | 934 | /* Initialize data cursors */ |
935 | 935 | ||
936 | if (ceph_msg_has_pagelist(msg)) | ||
937 | ceph_msg_data_cursor_init(&msg->l); | ||
936 | if (ceph_msg_has_trail(msg)) | 938 | if (ceph_msg_has_trail(msg)) |
937 | ceph_msg_data_cursor_init(&msg->t); | 939 | ceph_msg_data_cursor_init(&msg->t); |
938 | 940 | ||
@@ -1220,18 +1222,19 @@ static void out_msg_pos_next(struct ceph_connection *con, struct page *page, | |||
1220 | { | 1222 | { |
1221 | struct ceph_msg *msg = con->out_msg; | 1223 | struct ceph_msg *msg = con->out_msg; |
1222 | struct ceph_msg_pos *msg_pos = &con->out_msg_pos; | 1224 | struct ceph_msg_pos *msg_pos = &con->out_msg_pos; |
1225 | bool need_crc = false; | ||
1223 | 1226 | ||
1224 | BUG_ON(!msg); | 1227 | BUG_ON(!msg); |
1225 | BUG_ON(!sent); | 1228 | BUG_ON(!sent); |
1226 | 1229 | ||
1227 | msg_pos->data_pos += sent; | 1230 | msg_pos->data_pos += sent; |
1228 | msg_pos->page_pos += sent; | 1231 | msg_pos->page_pos += sent; |
1229 | if (in_trail) { | 1232 | if (in_trail) |
1230 | bool need_crc; | ||
1231 | |||
1232 | need_crc = ceph_msg_data_advance(&msg->t, sent); | 1233 | need_crc = ceph_msg_data_advance(&msg->t, sent); |
1233 | BUG_ON(need_crc && sent != len); | 1234 | else if (ceph_msg_has_pagelist(msg)) |
1234 | } | 1235 | need_crc = ceph_msg_data_advance(&msg->l, sent); |
1236 | BUG_ON(need_crc && sent != len); | ||
1237 | |||
1235 | if (sent < len) | 1238 | if (sent < len) |
1236 | return; | 1239 | return; |
1237 | 1240 | ||
@@ -1239,13 +1242,10 @@ static void out_msg_pos_next(struct ceph_connection *con, struct page *page, | |||
1239 | msg_pos->page_pos = 0; | 1242 | msg_pos->page_pos = 0; |
1240 | msg_pos->page++; | 1243 | msg_pos->page++; |
1241 | msg_pos->did_page_crc = false; | 1244 | msg_pos->did_page_crc = false; |
1242 | if (ceph_msg_has_pagelist(msg)) { | ||
1243 | list_rotate_left(&msg->l.pagelist->head); | ||
1244 | #ifdef CONFIG_BLOCK | 1245 | #ifdef CONFIG_BLOCK |
1245 | } else if (ceph_msg_has_bio(msg)) { | 1246 | if (ceph_msg_has_bio(msg)) |
1246 | iter_bio_next(&msg->b.bio_iter, &msg->b.bio_seg); | 1247 | iter_bio_next(&msg->b.bio_iter, &msg->b.bio_seg); |
1247 | #endif | 1248 | #endif |
1248 | } | ||
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | static void in_msg_pos_next(struct ceph_connection *con, size_t len, | 1251 | static void in_msg_pos_next(struct ceph_connection *con, size_t len, |
@@ -1340,8 +1340,9 @@ static int write_partial_message_data(struct ceph_connection *con) | |||
1340 | } else if (ceph_msg_has_pages(msg)) { | 1340 | } else if (ceph_msg_has_pages(msg)) { |
1341 | page = msg->p.pages[msg_pos->page]; | 1341 | page = msg->p.pages[msg_pos->page]; |
1342 | } else if (ceph_msg_has_pagelist(msg)) { | 1342 | } else if (ceph_msg_has_pagelist(msg)) { |
1343 | page = list_first_entry(&msg->l.pagelist->head, | 1343 | use_cursor = true; |
1344 | struct page, lru); | 1344 | page = ceph_msg_data_next(&msg->l, &page_offset, |
1345 | &length, &last_piece); | ||
1345 | #ifdef CONFIG_BLOCK | 1346 | #ifdef CONFIG_BLOCK |
1346 | } else if (ceph_msg_has_bio(msg)) { | 1347 | } else if (ceph_msg_has_bio(msg)) { |
1347 | struct bio_vec *bv; | 1348 | struct bio_vec *bv; |