Commit eb0e0426 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

page-read: Introduce PR_ASAP flag for read_pages

This flag means, that the PR_ASYNC is valid, but the IO
should be started ASAP. This is how remote reader works,
so this flag is mostly for the local reader. It will let
us unify page-fault handlers for local and remote cases.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Acked-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
parent 275f81bc
......@@ -86,6 +86,7 @@ struct page_read {
/* flags for ->read_pages */
#define PR_ASYNC 0x1 /* may exit w/o data in the buffer */
#define PR_ASAP 0x2 /* PR_ASYNC, but start the IO right now */
/* flags for open_page_read */
#define PR_SHMEM 0x1
......
......@@ -401,7 +401,13 @@ static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr,
int ret;
unsigned long len = nr * PAGE_SIZE;
if (flags & PR_ASYNC)
/*
* There's no API in the kernel to start asynchronous
* cached read (or write), so in case someone is asking
* for us for urgent async read, just do the regular
* cached read.
*/
if ((flags & (PR_ASYNC|PR_ASAP)) == PR_ASYNC)
ret = pagemap_enqueue_iovec(pr, buf, len, &pr->async);
else
ret = read_local_page(pr, vaddr, len, buf);
......@@ -416,6 +422,7 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
{
int ret, pid;
/* We always do PR_ASAP mode here (FIXME?) */
ret = request_remote_pages(pr->pid, vaddr, nr);
if ((ret < 0) || (flags & PR_ASYNC))
return ret;
......
......@@ -680,7 +680,7 @@ static int page_fault_common(struct lazy_pages_info *lpi, __u64 address, int nr,
static int page_fault_local(struct lazy_pages_info *lpi, __u64 address, int nr)
{
if (page_fault_common(lpi, address, nr, 0))
if (page_fault_common(lpi, address, nr, PR_ASYNC | PR_ASAP))
return -1;
if (uffd_copy(lpi, address, nr))
......@@ -694,7 +694,7 @@ static int page_fault_local(struct lazy_pages_info *lpi, __u64 address, int nr)
static int page_fault_remote(struct lazy_pages_info *lpi, __u64 address, int nr)
{
return page_fault_common(lpi, address, nr, PR_ASYNC);
return page_fault_common(lpi, address, nr, PR_ASYNC | PR_ASAP);
}
static int (*pf_handler)(struct lazy_pages_info *lpi, __u64 address, int nr);
......
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