diff options
author | Alex Elder <elder@dreamhost.com> | 2012-03-07 12:40:08 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:52 -0400 |
commit | 8d63e318c4eb1bea6f7e3cb4b77849eaa167bfec (patch) | |
tree | 4783d4d0ab9a5d9c17e8eb0f93b0d279ad1b879a /net | |
parent | 9bd1966344bf975b5ce65e80fd6bacc41b4325a8 (diff) |
libceph: isolate kmap() call in write_partial_msg_pages()
In write_partial_msg_pages(), every case now does an identical call
to kmap(page). Instead, just call it once inside the CRC-computing
block where it's needed. Move the definition of kaddr inside that
block, and make it a (char *) to ensure portable pointer arithmetic.
We still don't kunmap() it until after the sendpage() call, in case
that also ends up needing to use the mapping.
Signed-off-by: Alex Elder <elder@dreamhost.com>
Reviewed-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/messenger.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 2bf9ab4429e6..f0993af2ae4d 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -835,7 +835,6 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
835 | 835 | ||
836 | while (data_len > con->out_msg_pos.data_pos) { | 836 | while (data_len > con->out_msg_pos.data_pos) { |
837 | struct page *page = NULL; | 837 | struct page *page = NULL; |
838 | void *kaddr = NULL; | ||
839 | int max_write = PAGE_SIZE; | 838 | int max_write = PAGE_SIZE; |
840 | int bio_offset = 0; | 839 | int bio_offset = 0; |
841 | 840 | ||
@@ -856,18 +855,12 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
856 | 855 | ||
857 | page = list_first_entry(&msg->trail->head, | 856 | page = list_first_entry(&msg->trail->head, |
858 | struct page, lru); | 857 | struct page, lru); |
859 | if (do_datacrc) | ||
860 | kaddr = kmap(page); | ||
861 | max_write = PAGE_SIZE; | 858 | max_write = PAGE_SIZE; |
862 | } else if (msg->pages) { | 859 | } else if (msg->pages) { |
863 | page = msg->pages[con->out_msg_pos.page]; | 860 | page = msg->pages[con->out_msg_pos.page]; |
864 | if (do_datacrc) | ||
865 | kaddr = kmap(page); | ||
866 | } else if (msg->pagelist) { | 861 | } else if (msg->pagelist) { |
867 | page = list_first_entry(&msg->pagelist->head, | 862 | page = list_first_entry(&msg->pagelist->head, |
868 | struct page, lru); | 863 | struct page, lru); |
869 | if (do_datacrc) | ||
870 | kaddr = kmap(page); | ||
871 | #ifdef CONFIG_BLOCK | 864 | #ifdef CONFIG_BLOCK |
872 | } else if (msg->bio) { | 865 | } else if (msg->bio) { |
873 | struct bio_vec *bv; | 866 | struct bio_vec *bv; |
@@ -875,14 +868,10 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
875 | bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); | 868 | bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); |
876 | page = bv->bv_page; | 869 | page = bv->bv_page; |
877 | bio_offset = bv->bv_offset; | 870 | bio_offset = bv->bv_offset; |
878 | if (do_datacrc) | ||
879 | kaddr = kmap(page); | ||
880 | max_write = bv->bv_len; | 871 | max_write = bv->bv_len; |
881 | #endif | 872 | #endif |
882 | } else { | 873 | } else { |
883 | page = zero_page; | 874 | page = zero_page; |
884 | if (do_datacrc) | ||
885 | kaddr = kmap(page); | ||
886 | } | 875 | } |
887 | len = min_t(int, max_write - con->out_msg_pos.page_pos, | 876 | len = min_t(int, max_write - con->out_msg_pos.page_pos, |
888 | total_max_write); | 877 | total_max_write); |
@@ -891,7 +880,9 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
891 | void *base; | 880 | void *base; |
892 | u32 crc; | 881 | u32 crc; |
893 | u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); | 882 | u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); |
883 | char *kaddr; | ||
894 | 884 | ||
885 | kaddr = kmap(page); | ||
895 | BUG_ON(kaddr == NULL); | 886 | BUG_ON(kaddr == NULL); |
896 | base = kaddr + con->out_msg_pos.page_pos + bio_offset; | 887 | base = kaddr + con->out_msg_pos.page_pos + bio_offset; |
897 | crc = crc32c(tmpcrc, base, len); | 888 | crc = crc32c(tmpcrc, base, len); |