mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
page-xfer: Sanitize xfer core routine
Make it call .write_pagemap once and decide whether or not to call .write_pages based on the flags caluculated in one place as well. Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
daf8b4f75c
commit
f2f5fd68dd
@@ -434,6 +434,19 @@ static int dump_holes(struct page_xfer *xfer, struct page_pipe *pp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline u32 ppb_xfer_flags(struct page_xfer *xfer, struct page_pipe_buf *ppb)
|
||||
{
|
||||
if (ppb->flags & PPB_LAZY)
|
||||
/*
|
||||
* Pages that can be lazily restored are always marked as such.
|
||||
* In the case we actually transfer them into image mark them
|
||||
* as present as well.
|
||||
*/
|
||||
return (xfer->transfer_lazy ? PE_PRESENT : 0) | PE_LAZY;
|
||||
else
|
||||
return PE_PRESENT;
|
||||
}
|
||||
|
||||
int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp)
|
||||
{
|
||||
struct page_pipe_buf *ppb;
|
||||
@@ -449,7 +462,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;
|
||||
u32 flags;
|
||||
|
||||
ret = dump_holes(xfer, pp, &cur_hole, iov.iov_base);
|
||||
if (ret)
|
||||
@@ -460,19 +473,12 @@ 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 (ppb->flags & PPB_LAZY) {
|
||||
if (!xfer->transfer_lazy) {
|
||||
if (xfer->write_pagemap(xfer, &iov, PE_LAZY))
|
||||
return -1;
|
||||
continue;
|
||||
} else {
|
||||
flags |= PE_LAZY;
|
||||
}
|
||||
}
|
||||
flags = ppb_xfer_flags(xfer, ppb);
|
||||
|
||||
if (xfer->write_pagemap(xfer, &iov, flags))
|
||||
return -1;
|
||||
if (xfer->write_pages(xfer, ppb->p[0], iov.iov_len))
|
||||
if ((flags & PE_PRESENT) && xfer->write_pages(xfer,
|
||||
ppb->p[0], iov.iov_len))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user