Commit d4edd9bf authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

lazy-pages: introduce uffd_seek_or_zero_pages

This part of code is responsible for reseting pagemap to proper locatation,
and mapping requested address to zero pfn if needed. The upcoming addtions
to uffd.c will reuse this code.

travis-ci: success for uffd: A new set of improvements
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 25044855
......@@ -569,7 +569,17 @@ static int uffd_zero(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
return 0;
}
static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
/*
* Seek for the requested address in the pagemap. If it is found, the
* subsequent call to pr->page_read will bring us the data. If the
* address is not found in the pagemap, but no error occured, the
* address should be mapped to zero pfn.
*
* Returns 0 for zero pages, 1 for "real" pages and negative value on
* error
*/
static int uffd_seek_or_zero_pages(struct lazy_pages_info *lpi, __u64 address,
int nr)
{
int ret;
......@@ -582,6 +592,17 @@ static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
if (pagemap_zero(lpi->pr.pe))
return uffd_zero(lpi, address, nr);
return 1;
}
static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
{
int ret;
ret = uffd_seek_or_zero_pages(lpi, address, nr);
if (ret <= 0)
return ret;
ret = lpi->pr.read_pages(&lpi->pr, address, nr, lpi->buf, 0);
if (ret <= 0) {
pr_err("%d: failed reading pages at %llx\n", lpi->pid, address);
......
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