Skip to content

Commit

Permalink
xen/blkback: simplify address translations
Browse files Browse the repository at this point in the history
Cherry-pick and modified from 69d64727c42eecd47fdf82c15a54474d21a4012a
("blkback/blktap2: simplify address translations"):

"There are quite a number of places where e.g. page->va->page
translations happen.

Besides yielding smaller code (source and binary), a second goal is to
make it easier to determine where virtual addresses of pages allocated
through alloc_empty_pages_and_pagevec() are really used (in turn in
order to determine whether using highmem pages would be possible
there)."

The second goal is not the purpose of this patch - it is just to
make it easier to read the code.

linux-2.6-pvops:
 * Stripped drivers/xen/gntdev/*
 * Stripped drivers/xen/netback/*

[v2: Stripped blktap off]

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Jan Beulich authored and Konrad Rzeszutek Wilk committed Apr 14, 2011
1 parent bc0c081 commit efe08a3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/xen/blkback/blkback.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ static inline int vaddr_pagenr(pending_req_t *req, int seg)
return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg;
}

#define pending_page(req, seg) pending_pages[vaddr_pagenr(req, seg)]

static inline unsigned long vaddr(pending_req_t *req, int seg)
{
unsigned long pfn = page_to_pfn(pending_pages[vaddr_pagenr(req, seg)]);
unsigned long pfn = page_to_pfn(pending_page(req, seg));
return (unsigned long)pfn_to_kaddr(pfn);
}

Expand Down Expand Up @@ -463,8 +465,8 @@ static void dispatch_rw_block_io(blkif_t *blkif,
if (ret)
continue;

set_phys_to_machine(__pa(vaddr(
pending_req, i)) >> PAGE_SHIFT,
set_phys_to_machine(
page_to_pfn(pending_page(pending_req, i)),
FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
seg[i].buf = map[i].dev_bus_addr |
(req->seg[i].first_sect << 9);
Expand Down Expand Up @@ -495,7 +497,7 @@ static void dispatch_rw_block_io(blkif_t *blkif,

while ((bio == NULL) ||
(bio_add_page(bio,
virt_to_page(vaddr(pending_req, i)),
pending_page(pending_req, i),
seg[i].nsec << 9,
seg[i].buf & ~PAGE_MASK) == 0)) {
if (bio) {
Expand Down

0 comments on commit efe08a3

Please sign in to comment.