Linux: kmap() not page_address()

Using page_address() will return NULL if the page is in highmem. To
avoid this, we must kmap() the page we're getting the address of,
and kunmap() when we are done. If the page isn't in high memory, then
kmap() is equivalent to page_address().

Change-Id: I42abfadaf3101bf5ad41bd7e5f720ba2583c4ee5
Reviewed-on: http://gerrit.openafs.org/1705
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Simon Wilkinson 2010-04-07 00:29:44 +01:00 committed by Derrick Brashear
parent 75cf37f944
commit fdb9429eaf

View File

@ -64,10 +64,12 @@ afs_linux_splice_actor(struct pipe_inode_info *pipe,
size = sd->len;
/* Eventually, this could be rx_WritePage */
code = rx_Write(svar->call, page_address(buf->page), size);
if (code != size) {
return -33; /* Can't get a proper rx error out from here */
}
code = rx_Write(svar->call, kmap(buf->page), size);
if (code != size)
size = -33; /* Can't get a proper rx error out from here */
kunmap(buf->page);
return size;
}
@ -132,7 +134,8 @@ afs_linux_read_actor(read_descriptor_t *desc, struct page *page,
size = count;
/* Eventually, this could be rx_WritePage */
code = rx_Write(svar->call, page_address(page) + offset, size);
code = rx_Write(svar->call, kmap(page) + offset, size);
kunmap(page);
if (code != size) {
return -33; /* Can't get a proper rx error out from here */