diff options
author | Jan Beulich <jbeulich@novell.com> | 2010-02-05 14:19:33 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-04-14 18:26:19 -0400 |
commit | efe08a3eecf15ab022afba48c691d02c7de2fbbb (patch) | |
tree | f251cfcf0c335975519eb4ef9144e06e7a0cac33 /drivers/xen/blkback/blkback.c | |
parent | bc0c081b0e7a4afc4d2c7bc0666f5cd169e96814 (diff) |
xen/blkback: simplify address translations
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>
Diffstat (limited to 'drivers/xen/blkback/blkback.c')
-rw-r--r-- | drivers/xen/blkback/blkback.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/xen/blkback/blkback.c b/drivers/xen/blkback/blkback.c index cb844f734d91..7c9421cc5991 100644 --- a/drivers/xen/blkback/blkback.c +++ b/drivers/xen/blkback/blkback.c | |||
@@ -99,9 +99,11 @@ static inline int vaddr_pagenr(pending_req_t *req, int seg) | |||
99 | return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg; | 99 | return (req - pending_reqs) * BLKIF_MAX_SEGMENTS_PER_REQUEST + seg; |
100 | } | 100 | } |
101 | 101 | ||
102 | #define pending_page(req, seg) pending_pages[vaddr_pagenr(req, seg)] | ||
103 | |||
102 | static inline unsigned long vaddr(pending_req_t *req, int seg) | 104 | static inline unsigned long vaddr(pending_req_t *req, int seg) |
103 | { | 105 | { |
104 | unsigned long pfn = page_to_pfn(pending_pages[vaddr_pagenr(req, seg)]); | 106 | unsigned long pfn = page_to_pfn(pending_page(req, seg)); |
105 | return (unsigned long)pfn_to_kaddr(pfn); | 107 | return (unsigned long)pfn_to_kaddr(pfn); |
106 | } | 108 | } |
107 | 109 | ||
@@ -463,8 +465,8 @@ static void dispatch_rw_block_io(blkif_t *blkif, | |||
463 | if (ret) | 465 | if (ret) |
464 | continue; | 466 | continue; |
465 | 467 | ||
466 | set_phys_to_machine(__pa(vaddr( | 468 | set_phys_to_machine( |
467 | pending_req, i)) >> PAGE_SHIFT, | 469 | page_to_pfn(pending_page(pending_req, i)), |
468 | FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT)); | 470 | FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT)); |
469 | seg[i].buf = map[i].dev_bus_addr | | 471 | seg[i].buf = map[i].dev_bus_addr | |
470 | (req->seg[i].first_sect << 9); | 472 | (req->seg[i].first_sect << 9); |
@@ -495,7 +497,7 @@ static void dispatch_rw_block_io(blkif_t *blkif, | |||
495 | 497 | ||
496 | while ((bio == NULL) || | 498 | while ((bio == NULL) || |
497 | (bio_add_page(bio, | 499 | (bio_add_page(bio, |
498 | virt_to_page(vaddr(pending_req, i)), | 500 | pending_page(pending_req, i), |
499 | seg[i].nsec << 9, | 501 | seg[i].nsec << 9, |
500 | seg[i].buf & ~PAGE_MASK) == 0)) { | 502 | seg[i].buf & ~PAGE_MASK) == 0)) { |
501 | if (bio) { | 503 | if (bio) { |