[CRIU] [PATCH v6 5/9] criu: page-xfer: add helper function for dumping holes
Mike Rapoport
rppt at linux.vnet.ibm.com
Thu Jul 14 05:49:32 PDT 2016
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/page-xfer.c | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index b998511..fbf087c 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -349,6 +349,26 @@ static struct iovec get_iov(struct iovec *iovs, unsigned int n, bool compat)
}
}
+static int dump_holes(struct page_xfer *xfer, struct page_pipe *pp,
+ unsigned int *cur_hole, void *limit, unsigned long off)
+{
+ int ret;
+
+ for (; *cur_hole < pp->free_hole ; (*cur_hole)++) {
+ struct iovec hole = get_iov(pp->holes, *cur_hole,
+ pp->flags & PP_COMPAT);
+
+ if (limit && hole.iov_base >= limit)
+ break;
+
+ ret = page_xfer_dump_hole(xfer, &hole, off);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
unsigned long off)
{
@@ -366,16 +386,9 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
for (i = 0; i < ppb->nr_segs; i++) {
struct iovec iov = get_iov(ppb->iov, i, pp->flags & PP_COMPAT);
- for (; cur_hole < pp->free_hole ; cur_hole++) {
- struct iovec hole = get_iov(pp->holes, cur_hole,
- pp->flags & PP_COMPAT);
-
- if (hole.iov_base >= iov.iov_base)
- break;
- ret = page_xfer_dump_hole(xfer, &hole, off);
- if (ret)
- return ret;
- }
+ ret = dump_holes(xfer, pp, &cur_hole, iov.iov_base, off);
+ if (ret)
+ return ret;
BUG_ON(iov.iov_base < (void *)off);
iov.iov_base -= off;
@@ -389,15 +402,7 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
}
}
- for (; cur_hole < pp->free_hole ; cur_hole++) {
- struct iovec hole = get_iov(pp->holes, cur_hole, pp->flags & PP_COMPAT);
-
- ret = page_xfer_dump_hole(xfer, &hole, off);
- if (ret)
- return ret;
- }
-
- return 0;
+ return dump_holes(xfer, pp, &cur_hole, NULL, off);
}
/*
--
1.9.1
More information about the CRIU
mailing list