aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
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:18:29 -0400
commit36153ec9dd6287d7cedf6afb51453c445d946cee (patch)
tree71f690eef5012f3d3c5df2723cc776701d57dc84 /net/ceph
parentc851c49591ebf000c610711e39eea7da5ff05b21 (diff)
libceph: move cursor into message
A message will only be processing a single data item at a time, so there's no need for each data item to have its own cursor. Move the cursor embedded in the message data structure into the message itself. To minimize the impact, keep the data->cursor field, but make it be a pointer to the cursor in the message. Move the definition of ceph_msg_data above ceph_msg_data_cursor so the cursor can point to the data without a forward definition rather than vice-versa. This and the upcoming patches are part of: http://tracker.ceph.com/issues/3761 Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/messenger.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 731bb9efa2c6..4626da34a5c3 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -725,7 +725,7 @@ static void con_out_kvec_add(struct ceph_connection *con,
725static void ceph_msg_data_bio_cursor_init(struct ceph_msg_data *data, 725static void ceph_msg_data_bio_cursor_init(struct ceph_msg_data *data,
726 size_t length) 726 size_t length)
727{ 727{
728 struct ceph_msg_data_cursor *cursor = &data->cursor; 728 struct ceph_msg_data_cursor *cursor = data->cursor;
729 struct bio *bio; 729 struct bio *bio;
730 730
731 BUG_ON(data->type != CEPH_MSG_DATA_BIO); 731 BUG_ON(data->type != CEPH_MSG_DATA_BIO);
@@ -745,7 +745,7 @@ static struct page *ceph_msg_data_bio_next(struct ceph_msg_data *data,
745 size_t *page_offset, 745 size_t *page_offset,
746 size_t *length) 746 size_t *length)
747{ 747{
748 struct ceph_msg_data_cursor *cursor = &data->cursor; 748 struct ceph_msg_data_cursor *cursor = data->cursor;
749 struct bio *bio; 749 struct bio *bio;
750 struct bio_vec *bio_vec; 750 struct bio_vec *bio_vec;
751 unsigned int index; 751 unsigned int index;
@@ -774,7 +774,7 @@ static struct page *ceph_msg_data_bio_next(struct ceph_msg_data *data,
774 774
775static bool ceph_msg_data_bio_advance(struct ceph_msg_data *data, size_t bytes) 775static bool ceph_msg_data_bio_advance(struct ceph_msg_data *data, size_t bytes)
776{ 776{
777 struct ceph_msg_data_cursor *cursor = &data->cursor; 777 struct ceph_msg_data_cursor *cursor = data->cursor;
778 struct bio *bio; 778 struct bio *bio;
779 struct bio_vec *bio_vec; 779 struct bio_vec *bio_vec;
780 unsigned int index; 780 unsigned int index;
@@ -826,7 +826,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data *data, size_t bytes)
826static void ceph_msg_data_pages_cursor_init(struct ceph_msg_data *data, 826static void ceph_msg_data_pages_cursor_init(struct ceph_msg_data *data,
827 size_t length) 827 size_t length)
828{ 828{
829 struct ceph_msg_data_cursor *cursor = &data->cursor; 829 struct ceph_msg_data_cursor *cursor = data->cursor;
830 int page_count; 830 int page_count;
831 831
832 BUG_ON(data->type != CEPH_MSG_DATA_PAGES); 832 BUG_ON(data->type != CEPH_MSG_DATA_PAGES);
@@ -849,7 +849,7 @@ static struct page *ceph_msg_data_pages_next(struct ceph_msg_data *data,
849 size_t *page_offset, 849 size_t *page_offset,
850 size_t *length) 850 size_t *length)
851{ 851{
852 struct ceph_msg_data_cursor *cursor = &data->cursor; 852 struct ceph_msg_data_cursor *cursor = data->cursor;
853 853
854 BUG_ON(data->type != CEPH_MSG_DATA_PAGES); 854 BUG_ON(data->type != CEPH_MSG_DATA_PAGES);
855 855
@@ -868,7 +868,7 @@ static struct page *ceph_msg_data_pages_next(struct ceph_msg_data *data,
868static bool ceph_msg_data_pages_advance(struct ceph_msg_data *data, 868static bool ceph_msg_data_pages_advance(struct ceph_msg_data *data,
869 size_t bytes) 869 size_t bytes)
870{ 870{
871 struct ceph_msg_data_cursor *cursor = &data->cursor; 871 struct ceph_msg_data_cursor *cursor = data->cursor;
872 872
873 BUG_ON(data->type != CEPH_MSG_DATA_PAGES); 873 BUG_ON(data->type != CEPH_MSG_DATA_PAGES);
874 874
@@ -897,7 +897,7 @@ static bool ceph_msg_data_pages_advance(struct ceph_msg_data *data,
897static void ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data *data, 897static void ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data *data,
898 size_t length) 898 size_t length)
899{ 899{
900 struct ceph_msg_data_cursor *cursor = &data->cursor; 900 struct ceph_msg_data_cursor *cursor = data->cursor;
901 struct ceph_pagelist *pagelist; 901 struct ceph_pagelist *pagelist;
902 struct page *page; 902 struct page *page;
903 903
@@ -923,7 +923,7 @@ static struct page *ceph_msg_data_pagelist_next(struct ceph_msg_data *data,
923 size_t *page_offset, 923 size_t *page_offset,
924 size_t *length) 924 size_t *length)
925{ 925{
926 struct ceph_msg_data_cursor *cursor = &data->cursor; 926 struct ceph_msg_data_cursor *cursor = data->cursor;
927 struct ceph_pagelist *pagelist; 927 struct ceph_pagelist *pagelist;
928 928
929 BUG_ON(data->type != CEPH_MSG_DATA_PAGELIST); 929 BUG_ON(data->type != CEPH_MSG_DATA_PAGELIST);
@@ -941,13 +941,13 @@ static struct page *ceph_msg_data_pagelist_next(struct ceph_msg_data *data,
941 else 941 else
942 *length = PAGE_SIZE - *page_offset; 942 *length = PAGE_SIZE - *page_offset;
943 943
944 return data->cursor.page; 944 return data->cursor->page;
945} 945}
946 946
947static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data *data, 947static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data *data,
948 size_t bytes) 948 size_t bytes)
949{ 949{
950 struct ceph_msg_data_cursor *cursor = &data->cursor; 950 struct ceph_msg_data_cursor *cursor = data->cursor;
951 struct ceph_pagelist *pagelist; 951 struct ceph_pagelist *pagelist;
952 952
953 BUG_ON(data->type != CEPH_MSG_DATA_PAGELIST); 953 BUG_ON(data->type != CEPH_MSG_DATA_PAGELIST);
@@ -1003,7 +1003,7 @@ static void ceph_msg_data_cursor_init(struct ceph_msg_data *data,
1003 /* BUG(); */ 1003 /* BUG(); */
1004 break; 1004 break;
1005 } 1005 }
1006 data->cursor.need_crc = true; 1006 data->cursor->need_crc = true;
1007} 1007}
1008 1008
1009/* 1009/*
@@ -1039,7 +1039,7 @@ static struct page *ceph_msg_data_next(struct ceph_msg_data *data,
1039 BUG_ON(*page_offset + *length > PAGE_SIZE); 1039 BUG_ON(*page_offset + *length > PAGE_SIZE);
1040 BUG_ON(!*length); 1040 BUG_ON(!*length);
1041 if (last_piece) 1041 if (last_piece)
1042 *last_piece = data->cursor.last_piece; 1042 *last_piece = data->cursor->last_piece;
1043 1043
1044 return page; 1044 return page;
1045} 1045}
@@ -1050,7 +1050,7 @@ static struct page *ceph_msg_data_next(struct ceph_msg_data *data,
1050 */ 1050 */
1051static bool ceph_msg_data_advance(struct ceph_msg_data *data, size_t bytes) 1051static bool ceph_msg_data_advance(struct ceph_msg_data *data, size_t bytes)
1052{ 1052{
1053 struct ceph_msg_data_cursor *cursor = &data->cursor; 1053 struct ceph_msg_data_cursor *cursor = data->cursor;
1054 bool new_piece; 1054 bool new_piece;
1055 1055
1056 BUG_ON(bytes > cursor->resid); 1056 BUG_ON(bytes > cursor->resid);
@@ -1071,7 +1071,7 @@ static bool ceph_msg_data_advance(struct ceph_msg_data *data, size_t bytes)
1071 BUG(); 1071 BUG();
1072 break; 1072 break;
1073 } 1073 }
1074 data->cursor.need_crc = new_piece; 1074 data->cursor->need_crc = new_piece;
1075 1075
1076 return new_piece; 1076 return new_piece;
1077} 1077}
@@ -1404,7 +1404,7 @@ static u32 ceph_crc32c_page(u32 crc, struct page *page,
1404static int write_partial_message_data(struct ceph_connection *con) 1404static int write_partial_message_data(struct ceph_connection *con)
1405{ 1405{
1406 struct ceph_msg *msg = con->out_msg; 1406 struct ceph_msg *msg = con->out_msg;
1407 struct ceph_msg_data_cursor *cursor = &msg->data->cursor; 1407 struct ceph_msg_data_cursor *cursor = msg->data->cursor;
1408 bool do_datacrc = !con->msgr->nocrc; 1408 bool do_datacrc = !con->msgr->nocrc;
1409 u32 crc; 1409 u32 crc;
1410 1410
@@ -2102,7 +2102,7 @@ static int read_partial_message_section(struct ceph_connection *con,
2102static int read_partial_msg_data(struct ceph_connection *con) 2102static int read_partial_msg_data(struct ceph_connection *con)
2103{ 2103{
2104 struct ceph_msg *msg = con->in_msg; 2104 struct ceph_msg *msg = con->in_msg;
2105 struct ceph_msg_data_cursor *cursor = &msg->data->cursor; 2105 struct ceph_msg_data_cursor *cursor = msg->data->cursor;
2106 const bool do_datacrc = !con->msgr->nocrc; 2106 const bool do_datacrc = !con->msgr->nocrc;
2107 struct page *page; 2107 struct page *page;
2108 size_t page_offset; 2108 size_t page_offset;
@@ -2991,6 +2991,7 @@ void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
2991 2991
2992 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGES); 2992 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGES);
2993 BUG_ON(!data); 2993 BUG_ON(!data);
2994 data->cursor = &msg->cursor;
2994 data->pages = pages; 2995 data->pages = pages;
2995 data->length = length; 2996 data->length = length;
2996 data->alignment = alignment & ~PAGE_MASK; 2997 data->alignment = alignment & ~PAGE_MASK;
@@ -3012,6 +3013,7 @@ void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
3012 3013
3013 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGELIST); 3014 data = ceph_msg_data_create(CEPH_MSG_DATA_PAGELIST);
3014 BUG_ON(!data); 3015 BUG_ON(!data);
3016 data->cursor = &msg->cursor;
3015 data->pagelist = pagelist; 3017 data->pagelist = pagelist;
3016 3018
3017 msg->data = data; 3019 msg->data = data;
@@ -3031,6 +3033,7 @@ void ceph_msg_data_set_bio(struct ceph_msg *msg, struct bio *bio,
3031 3033
3032 data = ceph_msg_data_create(CEPH_MSG_DATA_BIO); 3034 data = ceph_msg_data_create(CEPH_MSG_DATA_BIO);
3033 BUG_ON(!data); 3035 BUG_ON(!data);
3036 data->cursor = &msg->cursor;
3034 data->bio = bio; 3037 data->bio = bio;
3035 data->bio_length = length; 3038 data->bio_length = length;
3036 3039