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

lazy-pages: don't close page_read when a parent process exits

If there were fork()'s during lazy-restore we create a shallow copy of the
parent process' page-read. Since all the copies reference the same open
files, we cannot close the page-read until we finish restore of all the
processes that share the page-read.
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 97fbb1bd
......@@ -80,6 +80,7 @@ struct lazy_pages_info {
struct list_head reqs;
struct lazy_pages_info *parent;
unsigned num_children;
struct page_read pr;
......@@ -136,7 +137,9 @@ static void lpi_fini(struct lazy_pages_info *lpi)
free_iovs(lpi);
if (lpi->lpfd.fd > 0)
close(lpi->lpfd.fd);
if (!lpi->parent && lpi->pr.close)
if (lpi->parent)
lpi->parent->num_children--;
if (!lpi->parent && !lpi->num_children && lpi->pr.close)
lpi->pr.close(&lpi->pr);
free(lpi);
}
......@@ -947,6 +950,8 @@ static int handle_fork(struct lazy_pages_info *parent_lpi, struct uffd_msg *msg)
dup_page_read(&lpi->parent->pr, &lpi->pr);
lpi->parent->num_children++;
return 1;
out:
......
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