Commit b0aef179 authored by Konrad Rzeszutek Wilk's avatar Konrad Rzeszutek Wilk

xen/blkback: Cleanup move the code a bit around.

Moving it so that the code that 'fast_flush_area' code is
close to the code that deals with it so that the reader
won't lose focus.
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent 77089926
...@@ -167,41 +167,18 @@ static void free_req(struct pending_req *req) ...@@ -167,41 +167,18 @@ static void free_req(struct pending_req *req)
} }
/* /*
* Unmap the grant references, and also remove the M2P over-rides * Notification from the guest OS.
* used in the 'pending_req'. */
*/ static void blkif_notify_work(struct blkif_st *blkif)
static void fast_flush_area(struct pending_req *req)
{ {
struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST]; blkif->waiting_reqs = 1;
unsigned int i, invcount = 0; wake_up(&blkif->wq);
grant_handle_t handle; }
int ret;
for (i = 0; i < req->nr_pages; i++) {
handle = pending_handle(req, i);
if (handle == BLKBACK_INVALID_HANDLE)
continue;
gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i),
GNTMAP_host_map, handle);
pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
invcount++;
}
ret = HYPERVISOR_grant_table_op( irqreturn_t blkif_be_int(int irq, void *dev_id)
GNTTABOP_unmap_grant_ref, unmap, invcount); {
BUG_ON(ret); blkif_notify_work(dev_id);
/* Note, we use invcount, so nr->pages, so we can't index return IRQ_HANDLED;
* using vaddr(req, i).
*/
for (i = 0; i < invcount; i++) {
ret = m2p_remove_override(
virt_to_page(unmap[i].host_addr), false);
if (ret) {
printk(KERN_ALERT "Failed to remove M2P override for " \
"%lx\n", (unsigned long)unmap[i].host_addr);
continue;
}
}
} }
/* /*
...@@ -264,6 +241,43 @@ int blkif_schedule(void *arg) ...@@ -264,6 +241,43 @@ int blkif_schedule(void *arg)
return 0; return 0;
} }
/*
* Unmap the grant references, and also remove the M2P over-rides
* used in the 'pending_req'.
*/
static void fast_flush_area(struct pending_req *req)
{
struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
unsigned int i, invcount = 0;
grant_handle_t handle;
int ret;
for (i = 0; i < req->nr_pages; i++) {
handle = pending_handle(req, i);
if (handle == BLKBACK_INVALID_HANDLE)
continue;
gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i),
GNTMAP_host_map, handle);
pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
invcount++;
}
ret = HYPERVISOR_grant_table_op(
GNTTABOP_unmap_grant_ref, unmap, invcount);
BUG_ON(ret);
/* Note, we use invcount, so nr->pages, so we can't index
* using vaddr(req, i).
*/
for (i = 0; i < invcount; i++) {
ret = m2p_remove_override(
virt_to_page(unmap[i].host_addr), false);
if (ret) {
printk(KERN_ALERT "Failed to remove M2P override for " \
"%lx\n", (unsigned long)unmap[i].host_addr);
continue;
}
}
}
/* /*
* Completion callback on the bio's. Called as bh->b_end_io() * Completion callback on the bio's. Called as bh->b_end_io()
*/ */
...@@ -305,23 +319,6 @@ static void end_block_io_op(struct bio *bio, int error) ...@@ -305,23 +319,6 @@ static void end_block_io_op(struct bio *bio, int error)
} }
/*
* Notification from the guest OS.
*/
static void blkif_notify_work(struct blkif_st *blkif)
{
blkif->waiting_reqs = 1;
wake_up(&blkif->wq);
}
irqreturn_t blkif_be_int(int irq, void *dev_id)
{
blkif_notify_work(dev_id);
return IRQ_HANDLED;
}
/* /*
* Function to copy the from the ring buffer the 'struct blkif_request' * Function to copy the from the ring buffer the 'struct blkif_request'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment