[CRIU] [PATCH v4 1/3] page-read: Do not lseek file to get its current position
Mike Rapoport
rppt at linux.vnet.ibm.com
Sun Nov 13 01:38:51 PST 2016
From: Pavel Emelyanov <xemul at virtuozzo.com>
It's already written into page_read->pi_off, so just use one.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/pagemap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/criu/pagemap.c b/criu/pagemap.c
index a2f4c85..9683ce1 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -258,25 +258,24 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
unsigned long len, void *buf)
{
int fd = img_raw_fd(pr->pi);
- off_t current_vaddr = lseek(fd, pr->pi_off, SEEK_SET);
int ret;
- 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;
+
return 0;
}
--
1.9.1
More information about the CRIU
mailing list