[CRIU] [PATCH 1/3] page-read: Do not lseek file to get its current position

Pavel Emelyanov xemul at virtuozzo.com
Mon Nov 7 08:02:50 PST 2016


It's already written into page_read->pi_off, so just use one.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/pagemap.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/criu/pagemap.c b/criu/pagemap.c
index 105ad59..cfc9659 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -260,23 +260,22 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
 		BUG();
 	} else {
 		int fd = img_raw_fd(pr->pi);
-		off_t current_vaddr = lseek(fd, pr->pi_off, SEEK_SET);
 
-		pr_debug("\tpr%u Read page from self %lx/%"PRIx64"\n", pr->id, pr->cvaddr, current_vaddr);
-		ret = read(fd, buf, len);
+		pr_debug("\tpr%u Read page from self %lx/%"PRIx64"\n", pr->id, pr->cvaddr, pr->pi_off);
+		ret = pread(fd, buf, len, pr->pi_off);
 		if (ret != len) {
 			pr_perror("Can't read mapping page %d", ret);
 			return -1;
 		}
 
-		pr->pi_off += len;
-
 		if (opts.auto_dedup) {
-			ret = punch_hole(pr, current_vaddr, len, false);
+			ret = punch_hole(pr, pr->pi_off, len, false);
 			if (ret == -1) {
 				return -1;
 			}
 		}
+
+		pr->pi_off += len;
 	}
 
 	pr->cvaddr += len;
-- 
2.1.4



More information about the CRIU mailing list