aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-07 00:39:39 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:47 -0400
commit78625051b524e104332e69a9079d0ee9a2100cf2 (patch)
tree8dd3e1fbe633b30ed7bf38bd6a83a4497e992627 /net
parentbae6acd9c65cbfeffc66a9f48ae91dca6e3aec85 (diff)
libceph: consolidate message prep code
In prepare_write_message_data(), various fields are initialized in preparation for writing message data out. Meanwhile, in read_partial_message(), there is essentially the same block of code, operating on message variables associated with an incoming message. Generalize prepare_write_message_data() so it works for both incoming and outcoming messages, and use it in both spots. The did_page_crc is not used for input (so it's harmless to initialize it). 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.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 7788170524e3..e8fa4497f424 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -722,11 +722,9 @@ static void iter_bio_next(struct bio **bio_iter, unsigned int *seg)
722} 722}
723#endif 723#endif
724 724
725static void prepare_write_message_data(struct ceph_connection *con) 725static void prepare_message_data(struct ceph_msg *msg,
726 struct ceph_msg_pos *msg_pos)
726{ 727{
727 struct ceph_msg *msg = con->out_msg;
728 struct ceph_msg_pos *msg_pos = &con->out_msg_pos;
729
730 BUG_ON(!msg); 728 BUG_ON(!msg);
731 BUG_ON(!msg->hdr.data_len); 729 BUG_ON(!msg->hdr.data_len);
732 730
@@ -742,7 +740,6 @@ static void prepare_write_message_data(struct ceph_connection *con)
742#endif 740#endif
743 msg_pos->data_pos = 0; 741 msg_pos->data_pos = 0;
744 msg_pos->did_page_crc = false; 742 msg_pos->did_page_crc = false;
745 con->out_more = 1; /* data + footer will follow */
746} 743}
747 744
748/* 745/*
@@ -840,11 +837,13 @@ static void prepare_write_message(struct ceph_connection *con)
840 837
841 /* is there a data payload? */ 838 /* is there a data payload? */
842 con->out_msg->footer.data_crc = 0; 839 con->out_msg->footer.data_crc = 0;
843 if (m->hdr.data_len) 840 if (m->hdr.data_len) {
844 prepare_write_message_data(con); 841 prepare_message_data(con->out_msg, &con->out_msg_pos);
845 else 842 con->out_more = 1; /* data + footer will follow */
843 } else {
846 /* no, queue up footer too and be done */ 844 /* no, queue up footer too and be done */
847 prepare_write_message_footer(con); 845 prepare_write_message_footer(con);
846 }
848 847
849 con_flag_set(con, CON_FLAG_WRITE_PENDING); 848 con_flag_set(con, CON_FLAG_WRITE_PENDING);
850} 849}
@@ -1956,17 +1955,10 @@ static int read_partial_message(struct ceph_connection *con)
1956 if (m->middle) 1955 if (m->middle)
1957 m->middle->vec.iov_len = 0; 1956 m->middle->vec.iov_len = 0;
1958 1957
1959 msg_pos->page = 0; 1958 /* prepare for data payload, if any */
1960 if (m->pages)
1961 msg_pos->page_pos = m->page_alignment;
1962 else
1963 msg_pos->page_pos = 0;
1964 msg_pos->data_pos = 0;
1965 1959
1966#ifdef CONFIG_BLOCK 1960 if (data_len)
1967 if (m->bio) 1961 prepare_message_data(con->in_msg, &con->in_msg_pos);
1968 init_bio_iter(m->bio, &m->bio_iter, &m->bio_seg);
1969#endif
1970 } 1962 }
1971 1963
1972 /* front */ 1964 /* front */