mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
dedup_one_iovec: explicitly pass start and end instead of iovec
travis-ci: success for pagemap: minor cleanups (rev2) Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
4a7947aa79
commit
094ba506fe
@@ -91,7 +91,8 @@ static int cr_dedup_one_pagemap(int id, int flags)
|
||||
pagemap2iovec(pr.pe, &iov);
|
||||
pr_debug("dedup iovec base=%p, len=%zu\n", iov.iov_base, iov.iov_len);
|
||||
if (!pr.pe->in_parent) {
|
||||
ret = dedup_one_iovec(prp, &iov);
|
||||
ret = dedup_one_iovec(prp, pr.pe->vaddr,
|
||||
pagemap_len(pr.pe));
|
||||
if (ret)
|
||||
goto exit;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "common/list.h"
|
||||
#include "images/pagemap.pb-c.h"
|
||||
#include "page.h"
|
||||
|
||||
/*
|
||||
* page_read -- engine, that reads pages from image file(s)
|
||||
@@ -95,5 +96,11 @@ extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
|
||||
extern void pagemap2iovec(PagemapEntry *pe, struct iovec *iov);
|
||||
extern void iovec2pagemap(struct iovec *iov, PagemapEntry *pe);
|
||||
|
||||
extern int dedup_one_iovec(struct page_read *pr, struct iovec *iov);
|
||||
extern int dedup_one_iovec(struct page_read *pr, unsigned long base,
|
||||
unsigned long len);
|
||||
|
||||
static inline unsigned long pagemap_len(PagemapEntry *pe)
|
||||
{
|
||||
return pe->nr_pages * PAGE_SIZE;
|
||||
}
|
||||
#endif /* __CR_PAGE_READ_H__ */
|
||||
|
@@ -155,7 +155,8 @@ static int write_pagemap_loc(struct page_xfer *xfer,
|
||||
|
||||
iovec2pagemap(iov, &pe);
|
||||
if (opts.auto_dedup && xfer->parent != NULL) {
|
||||
ret = dedup_one_iovec(xfer->parent, iov);
|
||||
ret = dedup_one_iovec(xfer->parent, pe.vaddr,
|
||||
pagemap_len(&pe));
|
||||
if (ret == -1) {
|
||||
pr_perror("Auto-deduplication failed");
|
||||
return ret;
|
||||
|
@@ -84,18 +84,17 @@ static int punch_hole(struct page_read *pr, unsigned long off,
|
||||
|
||||
static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr);
|
||||
|
||||
int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
|
||||
int dedup_one_iovec(struct page_read *pr, unsigned long base, unsigned long len)
|
||||
{
|
||||
unsigned long off;
|
||||
unsigned long iov_end;
|
||||
|
||||
iov_end = (unsigned long)iov->iov_base + iov->iov_len;
|
||||
off = (unsigned long)iov->iov_base;
|
||||
iov_end = base + len;
|
||||
off = base;
|
||||
while (1) {
|
||||
int ret;
|
||||
struct iovec piov;
|
||||
unsigned long piov_end;
|
||||
struct iovec tiov;
|
||||
struct page_read * prp;
|
||||
|
||||
ret = seek_pagemap_page(pr, off);
|
||||
@@ -121,9 +120,8 @@ int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
|
||||
if (prp) {
|
||||
/* recursively */
|
||||
pr_debug("Go to next parent level\n");
|
||||
tiov.iov_base = (void*)off;
|
||||
tiov.iov_len = min(piov_end, iov_end) - off;
|
||||
ret = dedup_one_iovec(prp, &tiov);
|
||||
len = min(piov_end, iov_end) - off;
|
||||
ret = dedup_one_iovec(prp, off, len);
|
||||
if (ret != 0)
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user