diff options
author | Alex Elder <elder@inktank.com> | 2012-06-11 15:57:13 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-06 00:14:10 -0400 |
commit | 739c905baa018c99003564ebc367d93aa44d4861 (patch) | |
tree | a731dc6b87881d1507e8bc542cbaffa0dfaa3583 /net/ceph/messenger.c | |
parent | d59315ca8c0de00df9b363f94a2641a30961ca1c (diff) |
libceph: encapsulate out message data setup
Move the code that prepares to write the data portion of a message
into its own function.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r-- | net/ceph/messenger.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index ab690e2e1206..56448660883d 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -565,6 +565,24 @@ static void con_out_kvec_add(struct ceph_connection *con, | |||
565 | con->out_kvec_bytes += size; | 565 | con->out_kvec_bytes += size; |
566 | } | 566 | } |
567 | 567 | ||
568 | static void prepare_write_message_data(struct ceph_connection *con) | ||
569 | { | ||
570 | struct ceph_msg *msg = con->out_msg; | ||
571 | |||
572 | BUG_ON(!msg); | ||
573 | BUG_ON(!msg->hdr.data_len); | ||
574 | |||
575 | /* initialize page iterator */ | ||
576 | con->out_msg_pos.page = 0; | ||
577 | if (msg->pages) | ||
578 | con->out_msg_pos.page_pos = msg->page_alignment; | ||
579 | else | ||
580 | con->out_msg_pos.page_pos = 0; | ||
581 | con->out_msg_pos.data_pos = 0; | ||
582 | con->out_msg_pos.did_page_crc = false; | ||
583 | con->out_more = 1; /* data + footer will follow */ | ||
584 | } | ||
585 | |||
568 | /* | 586 | /* |
569 | * Prepare footer for currently outgoing message, and finish things | 587 | * Prepare footer for currently outgoing message, and finish things |
570 | * off. Assumes out_kvec* are already valid.. we just add on to the end. | 588 | * off. Assumes out_kvec* are already valid.. we just add on to the end. |
@@ -657,26 +675,17 @@ static void prepare_write_message(struct ceph_connection *con) | |||
657 | con->out_msg->footer.middle_crc = cpu_to_le32(crc); | 675 | con->out_msg->footer.middle_crc = cpu_to_le32(crc); |
658 | } else | 676 | } else |
659 | con->out_msg->footer.middle_crc = 0; | 677 | con->out_msg->footer.middle_crc = 0; |
660 | con->out_msg->footer.data_crc = 0; | 678 | dout("%s front_crc %u middle_crc %u\n", __func__, |
661 | dout("prepare_write_message front_crc %u data_crc %u\n", | ||
662 | le32_to_cpu(con->out_msg->footer.front_crc), | 679 | le32_to_cpu(con->out_msg->footer.front_crc), |
663 | le32_to_cpu(con->out_msg->footer.middle_crc)); | 680 | le32_to_cpu(con->out_msg->footer.middle_crc)); |
664 | 681 | ||
665 | /* is there a data payload? */ | 682 | /* is there a data payload? */ |
666 | if (le32_to_cpu(m->hdr.data_len) > 0) { | 683 | con->out_msg->footer.data_crc = 0; |
667 | /* initialize page iterator */ | 684 | if (m->hdr.data_len) |
668 | con->out_msg_pos.page = 0; | 685 | prepare_write_message_data(con); |
669 | if (m->pages) | 686 | else |
670 | con->out_msg_pos.page_pos = m->page_alignment; | ||
671 | else | ||
672 | con->out_msg_pos.page_pos = 0; | ||
673 | con->out_msg_pos.data_pos = 0; | ||
674 | con->out_msg_pos.did_page_crc = false; | ||
675 | con->out_more = 1; /* data + footer will follow */ | ||
676 | } else { | ||
677 | /* no, queue up footer too and be done */ | 687 | /* no, queue up footer too and be done */ |
678 | prepare_write_message_footer(con); | 688 | prepare_write_message_footer(con); |
679 | } | ||
680 | 689 | ||
681 | set_bit(WRITE_PENDING, &con->flags); | 690 | set_bit(WRITE_PENDING, &con->flags); |
682 | } | 691 | } |