[CRIU] [PATCH 2/2] page-read: rewrite some code to use it in deduplication
Tikhomirov Pavel
snorcht at gmail.com
Thu Oct 17 06:07:40 PDT 2013
Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
include/page-read.h | 2 ++
page-read.c | 12 +++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/page-read.h b/include/page-read.h
index b19ea69..cbae2a0 100644
--- a/include/page-read.h
+++ b/include/page-read.h
@@ -66,4 +66,6 @@ struct page_read {
};
int open_page_read(int pid, struct page_read *);
+inline void pagemap2iovec(PagemapEntry *pe, struct iovec *iov);
+int seek_pagemap_page(struct page_read *pr, unsigned long vaddr);
#endif
diff --git a/page-read.c b/page-read.c
index a3ea7ac..6f3541c 100644
--- a/page-read.c
+++ b/page-read.c
@@ -36,7 +36,7 @@ static int read_page(struct page_read *pr, unsigned long vaddr, void *buf)
return 1;
}
-static inline void pagemap2iovec(PagemapEntry *pe, struct iovec *iov)
+inline void pagemap2iovec(PagemapEntry *pe, struct iovec *iov)
{
iov->iov_base = decode_pointer(pe->vaddr);
iov->iov_len = pe->nr_pages * PAGE_SIZE;
@@ -82,7 +82,7 @@ static void skip_pagemap_pages(struct page_read *pr, unsigned long len)
pr->cvaddr += len;
}
-static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr)
+int seek_pagemap_page(struct page_read *pr, unsigned long vaddr)
{
int ret;
struct iovec iov;
@@ -95,7 +95,11 @@ static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr)
while (1) {
unsigned long iov_end;
- BUG_ON(vaddr < pr->cvaddr);
+ if (vaddr < pr->cvaddr) {
+ pr_err("Missing %lu in parent pagemap, iov: base=%lu,len=%lu",
+ vaddr, (unsigned long)iov.iov_base, iov.iov_len);
+ return -1;
+ }
iov_end = (unsigned long)iov.iov_base + iov.iov_len;
if (iov_end <= vaddr) {
@@ -124,6 +128,8 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu
if (ret == -1)
return ret;
ret = read_pagemap_page(pr->parent, vaddr, buf);
+ if (ret < 0)
+ return ret;
} else {
pr_debug("\tpr%u Read page %lx from self %lx/%"PRIx64"\n", pr->id,
vaddr, pr->cvaddr, lseek(pr->fd_pg, 0, SEEK_CUR));
--
1.7.9.5
More information about the CRIU
mailing list