Commit 8d63e318c4eb1bea6f7e3cb4b77849eaa167bfec
1 parent
9bd1966344
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 2 additions and 11 deletions Side-by-side Diff
net/ceph/messenger.c
... | ... | @@ -835,7 +835,6 @@ |
835 | 835 | |
836 | 836 | while (data_len > con->out_msg_pos.data_pos) { |
837 | 837 | struct page *page = NULL; |
838 | - void *kaddr = NULL; | |
839 | 838 | int max_write = PAGE_SIZE; |
840 | 839 | int bio_offset = 0; |
841 | 840 | |
842 | 841 | |
843 | 842 | |
... | ... | @@ -856,18 +855,12 @@ |
856 | 855 | |
857 | 856 | page = list_first_entry(&msg->trail->head, |
858 | 857 | struct page, lru); |
859 | - if (do_datacrc) | |
860 | - kaddr = kmap(page); | |
861 | 858 | max_write = PAGE_SIZE; |
862 | 859 | } else if (msg->pages) { |
863 | 860 | page = msg->pages[con->out_msg_pos.page]; |
864 | - if (do_datacrc) | |
865 | - kaddr = kmap(page); | |
866 | 861 | } else if (msg->pagelist) { |
867 | 862 | page = list_first_entry(&msg->pagelist->head, |
868 | 863 | struct page, lru); |
869 | - if (do_datacrc) | |
870 | - kaddr = kmap(page); | |
871 | 864 | #ifdef CONFIG_BLOCK |
872 | 865 | } else if (msg->bio) { |
873 | 866 | struct bio_vec *bv; |
874 | 867 | |
... | ... | @@ -875,14 +868,10 @@ |
875 | 868 | bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); |
876 | 869 | page = bv->bv_page; |
877 | 870 | bio_offset = bv->bv_offset; |
878 | - if (do_datacrc) | |
879 | - kaddr = kmap(page); | |
880 | 871 | max_write = bv->bv_len; |
881 | 872 | #endif |
882 | 873 | } else { |
883 | 874 | page = zero_page; |
884 | - if (do_datacrc) | |
885 | - kaddr = kmap(page); | |
886 | 875 | } |
887 | 876 | len = min_t(int, max_write - con->out_msg_pos.page_pos, |
888 | 877 | total_max_write); |
889 | 878 | |
... | ... | @@ -891,7 +880,9 @@ |
891 | 880 | void *base; |
892 | 881 | u32 crc; |
893 | 882 | u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); |
883 | + char *kaddr; | |
894 | 884 | |
885 | + kaddr = kmap(page); | |
895 | 886 | BUG_ON(kaddr == NULL); |
896 | 887 | base = kaddr + con->out_msg_pos.page_pos + bio_offset; |
897 | 888 | crc = crc32c(tmpcrc, base, len); |