[CRIU] [PATCH] deduplication: make seek_pagemap_page properly handle eof

Tikhomirov Pavel snorcht at gmail.com
Tue Jan 21 02:05:36 PST 2014


because eof in restore means that we don't have "must have" data, so
it mean error exit, but in dedup, it's ok not to have data we seek, so
we continue returning normally

also it's used that if off < pr-cvaddr then no eof happened and if eof
happened then off >= pr-cvaddr(then return of seek_pagemap_page is 0)

Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
 cr-dedup.c  |   16 ++++++++--------
 page-read.c |   10 +++++-----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cr-dedup.c b/cr-dedup.c
index 8ba9c70..ebcc805 100644
--- a/cr-dedup.c
+++ b/cr-dedup.c
@@ -116,14 +116,14 @@ int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
 		struct iovec tiov;
 		struct page_read * prp;
 		ret = seek_pagemap_page(pr, off, false);
-		if (ret == -1) {
-			if (off < pr->cvaddr) {
-				if (pr->cvaddr < iov_end)
-					off = pr->cvaddr;
-				else
-					return 0;
-			} else
-				return ret;
+		if (ret == -1)
+			return -1;
+
+		if (ret == 0) {
+			if (off < pr->cvaddr && pr->cvaddr < iov_end)
+				off = pr->cvaddr;
+			else
+				return 0;
 		}
 
 		if (!pr->pe)
diff --git a/page-read.c b/page-read.c
index 327e2b9..64b9cc4 100644
--- a/page-read.c
+++ b/page-read.c
@@ -105,7 +105,7 @@ int seek_pagemap_page(struct page_read *pr, unsigned long vaddr, bool warn)
 			if (warn)
 				pr_err("Missing %lu in parent pagemap, current iov: base=%lu,len=%zu\n",
 					vaddr, (unsigned long)iov.iov_base, iov.iov_len);
-			return -1;
+			return 0;
 		}
 		iov_end = (unsigned long)iov.iov_base + iov.iov_len;
 
@@ -115,13 +115,13 @@ int seek_pagemap_page(struct page_read *pr, unsigned long vaddr, bool warn)
 new_pagemap:
 			ret = get_pagemap(pr, &iov);
 			if (ret <= 0)
-				return -1;
+				return ret;
 
 			continue;
 		}
 
 		skip_pagemap_pages(pr, vaddr - pr->cvaddr);
-		return 0;
+		return 1;
 	}
 }
 
@@ -132,8 +132,8 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, void *bu
 	if (pr->pe->in_parent) {
 		pr_debug("\tpr%u Read page %lx from parent\n", pr->id, vaddr);
 		ret = seek_pagemap_page(pr->parent, vaddr, true);
-		if (ret == -1)
-			return ret;
+		if (ret <= 0)
+			return -1;
 		ret = read_pagemap_page(pr->parent, vaddr, buf);
 		if (ret == -1)
 			return ret;
-- 
1.7.9.5



More information about the CRIU mailing list