Commit 96dd5298 authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

criu: pagemap: add PE_PRESENT flag

The PE_PRESENT flags is always set for pagemap entries that have
corresponding pages in the pages*img. Pagemap entries describing a hole
either with zero page or with pages in the parent snapshot will no have
PE_PRESENT flag set.
Pagemap entry that may be lazily restored is a special case. For the lazy
restore from disk case, both PE_LAZY and PE_PRESENT will be set in the
pagemap, but for the remote lazy pages case only PE_LAZY will be set.
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent ea99b700
......@@ -118,6 +118,7 @@ static inline unsigned long pagemap_len(PagemapEntry *pe)
#define PE_PARENT (1 << 0) /* pages are in parent snapshot */
#define PE_ZERO (1 << 1) /* pages can be lazily restored */
#define PE_LAZY (1 << 2) /* pages are mapped to zero pfn */
#define PE_PRESENT (1 << 3) /* pages are present in pages*img */
static inline bool pagemap_in_parent(PagemapEntry *pe)
{
......@@ -134,4 +135,9 @@ static inline bool pagemap_lazy(PagemapEntry *pe)
return !!(pe->flags & PE_LAZY);
}
static inline bool pagemap_present(PagemapEntry *pe)
{
return !!(pe->flags & PE_PRESENT);
}
#endif /* __CR_PAGE_READ_H__ */
......@@ -480,6 +480,7 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
for (i = 0; i < ppb->nr_segs; i++) {
struct iovec iov = ppb->iov[i];
u32 flags = PE_PRESENT;
ret = dump_holes(xfer, pp, &cur_hole, iov.iov_base, off);
if (ret)
......@@ -490,13 +491,18 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
pr_debug("\tp %p [%u]\n", iov.iov_base,
(unsigned int)(iov.iov_len / PAGE_SIZE));
if (!dump_lazy && ppb->flags & PPB_LAZY) {
if (xfer->write_hole(xfer, &iov, PS_IOV_LAZY))
return -1;
continue;
if (ppb->flags & PPB_LAZY) {
if (!dump_lazy) {
if (xfer->write_hole(xfer, &iov,
PS_IOV_LAZY))
return -1;
continue;
} else {
flags |= PE_LAZY;
}
}
if (xfer->write_pagemap(xfer, &iov, 0))
if (xfer->write_pagemap(xfer, &iov, flags))
return -1;
if (xfer->write_pages(xfer, ppb->p[0], iov.iov_len))
return -1;
......
......@@ -144,7 +144,7 @@ static void skip_pagemap_pages(struct page_read *pr, unsigned long len)
if (!len)
return;
if (!pagemap_in_parent(pr->pe) && !pagemap_zero(pr->pe) && !pagemap_lazy(pr->pe))
if (pagemap_present(pr->pe))
pr->pi_off += len;
pr->cvaddr += len;
}
......@@ -605,8 +605,16 @@ err_cl:
static void init_compat_pagemap_entry(PagemapEntry *pe)
{
/*
* pagemap image generated with older version will either
* contain a hole because the pages are in the parent
* shanpshot or a pagemap that should be marked with
* PE_PRESENT
*/
if (pe->has_in_parent && pe->in_parent)
pe->flags |= PE_PARENT;
else if (!pe->has_flags)
pe->flags = PE_PRESENT;
}
/*
......
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