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>
This commit is contained in:
parent
9bd1966344
commit
8d63e318c4
|
@ -835,7 +835,6 @@ static int write_partial_msg_pages(struct ceph_connection *con)
|
||||||
|
|
||||||
while (data_len > con->out_msg_pos.data_pos) {
|
while (data_len > con->out_msg_pos.data_pos) {
|
||||||
struct page *page = NULL;
|
struct page *page = NULL;
|
||||||
void *kaddr = NULL;
|
|
||||||
int max_write = PAGE_SIZE;
|
int max_write = PAGE_SIZE;
|
||||||
int bio_offset = 0;
|
int bio_offset = 0;
|
||||||
|
|
||||||
|
@ -856,18 +855,12 @@ static int write_partial_msg_pages(struct ceph_connection *con)
|
||||||
|
|
||||||
page = list_first_entry(&msg->trail->head,
|
page = list_first_entry(&msg->trail->head,
|
||||||
struct page, lru);
|
struct page, lru);
|
||||||
if (do_datacrc)
|
|
||||||
kaddr = kmap(page);
|
|
||||||
max_write = PAGE_SIZE;
|
max_write = PAGE_SIZE;
|
||||||
} else if (msg->pages) {
|
} else if (msg->pages) {
|
||||||
page = msg->pages[con->out_msg_pos.page];
|
page = msg->pages[con->out_msg_pos.page];
|
||||||
if (do_datacrc)
|
|
||||||
kaddr = kmap(page);
|
|
||||||
} else if (msg->pagelist) {
|
} else if (msg->pagelist) {
|
||||||
page = list_first_entry(&msg->pagelist->head,
|
page = list_first_entry(&msg->pagelist->head,
|
||||||
struct page, lru);
|
struct page, lru);
|
||||||
if (do_datacrc)
|
|
||||||
kaddr = kmap(page);
|
|
||||||
#ifdef CONFIG_BLOCK
|
#ifdef CONFIG_BLOCK
|
||||||
} else if (msg->bio) {
|
} else if (msg->bio) {
|
||||||
struct bio_vec *bv;
|
struct bio_vec *bv;
|
||||||
|
@ -875,14 +868,10 @@ static int write_partial_msg_pages(struct ceph_connection *con)
|
||||||
bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
|
bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
|
||||||
page = bv->bv_page;
|
page = bv->bv_page;
|
||||||
bio_offset = bv->bv_offset;
|
bio_offset = bv->bv_offset;
|
||||||
if (do_datacrc)
|
|
||||||
kaddr = kmap(page);
|
|
||||||
max_write = bv->bv_len;
|
max_write = bv->bv_len;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
page = zero_page;
|
page = zero_page;
|
||||||
if (do_datacrc)
|
|
||||||
kaddr = kmap(page);
|
|
||||||
}
|
}
|
||||||
len = min_t(int, max_write - con->out_msg_pos.page_pos,
|
len = min_t(int, max_write - con->out_msg_pos.page_pos,
|
||||||
total_max_write);
|
total_max_write);
|
||||||
|
@ -891,7 +880,9 @@ static int write_partial_msg_pages(struct ceph_connection *con)
|
||||||
void *base;
|
void *base;
|
||||||
u32 crc;
|
u32 crc;
|
||||||
u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc);
|
u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc);
|
||||||
|
char *kaddr;
|
||||||
|
|
||||||
|
kaddr = kmap(page);
|
||||||
BUG_ON(kaddr == NULL);
|
BUG_ON(kaddr == NULL);
|
||||||
base = kaddr + con->out_msg_pos.page_pos + bio_offset;
|
base = kaddr + con->out_msg_pos.page_pos + bio_offset;
|
||||||
crc = crc32c(tmpcrc, base, len);
|
crc = crc32c(tmpcrc, base, len);
|
||||||
|
|
Loading…
Reference in a new issue