2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

pagemap: drop pagemap2iovec and iovec2pagemap

The PagemapEntry and struct iovec are quite interchangeable.
PagemapEntry can be used directly in the few places that converted it to
struct iovec.
The only place that used iovec2pagemap can be switched to open-coded
assignments without really hurting code readability.

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:
Mike Rapoport
2016-12-06 11:15:09 +02:00
committed by Pavel Emelyanov
parent 094ba506fe
commit 215d242ad9
4 changed files with 11 additions and 30 deletions

View File

@@ -72,7 +72,6 @@ static int cr_dedup_one_pagemap(int id, int flags)
int ret;
struct page_read pr;
struct page_read * prp;
struct iovec iov;
flags |= PR_MOD;
ret = open_page_read(id, &pr, flags);
@@ -88,8 +87,8 @@ static int cr_dedup_one_pagemap(int id, int flags)
if (ret <= 0)
goto exit;
pagemap2iovec(pr.pe, &iov);
pr_debug("dedup iovec base=%p, len=%zu\n", iov.iov_base, iov.iov_len);
pr_debug("dedup iovec base=%"PRIx64", len=%lu\n",
pr.pe->vaddr, pagemap_len(pr.pe));
if (!pr.pe->in_parent) {
ret = dedup_one_iovec(prp, pr.pe->vaddr,
pagemap_len(pr.pe));

View File

@@ -93,8 +93,6 @@ struct page_read {
extern int open_page_read(int pid, struct page_read *, int pr_flags);
extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
int pr_flags);
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, unsigned long base,
unsigned long len);

View File

@@ -153,7 +153,8 @@ static int write_pagemap_loc(struct page_xfer *xfer,
int ret;
PagemapEntry pe = PAGEMAP_ENTRY__INIT;
iovec2pagemap(iov, &pe);
pe.vaddr = encode_pointer(iov->iov_base);
pe.nr_pages = iov->iov_len / PAGE_SIZE;
if (opts.auto_dedup && xfer->parent != NULL) {
ret = dedup_one_iovec(xfer->parent, pe.vaddr,
pagemap_len(&pe));
@@ -200,7 +201,6 @@ static int check_pagehole_in_parent(struct page_read *p, struct iovec *iov)
off = (unsigned long)iov->iov_base;
end = off + iov->iov_len;
while (1) {
struct iovec piov;
unsigned long pend;
ret = p->seek_pagemap(p, off);
@@ -209,8 +209,7 @@ static int check_pagehole_in_parent(struct page_read *p, struct iovec *iov)
return -1;
}
pagemap2iovec(p->pe, &piov);
pr_debug("\tFound %p/%zu\n", piov.iov_base, piov.iov_len);
pr_debug("\tFound %"PRIx64"/%lu\n", p->pe->vaddr, pagemap_len(p->pe));
/*
* The pagemap entry in parent may happen to be
@@ -218,7 +217,7 @@ static int check_pagehole_in_parent(struct page_read *p, struct iovec *iov)
* we should go ahead and check the remainder.
*/
pend = (unsigned long)piov.iov_base + piov.iov_len;
pend = p->pe->vaddr + pagemap_len(p->pe);
if (end <= pend)
return 0;
@@ -242,7 +241,8 @@ static int write_pagehole_loc(struct page_xfer *xfer, struct iovec *iov)
}
}
iovec2pagemap(iov, &pe);
pe.vaddr = encode_pointer(iov->iov_base);
pe.nr_pages = iov->iov_len / PAGE_SIZE;
pe.has_in_parent = true;
pe.in_parent = true;

View File

@@ -34,18 +34,6 @@ struct page_read_iov {
struct list_head l;
};
void pagemap2iovec(PagemapEntry *pe, struct iovec *iov)
{
iov->iov_base = decode_pointer(pe->vaddr);
iov->iov_len = pe->nr_pages * PAGE_SIZE;
}
void iovec2pagemap(struct iovec *iov, PagemapEntry *pe)
{
pe->vaddr = encode_pointer(iov->iov_base);
pe->nr_pages = iov->iov_len / PAGE_SIZE;
}
static inline bool can_extend_bunch(struct iovec *bunch,
unsigned long off, unsigned long len)
{
@@ -84,16 +72,13 @@ 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, unsigned long base, unsigned long len)
int dedup_one_iovec(struct page_read *pr, unsigned long off, unsigned long len)
{
unsigned long off;
unsigned long iov_end;
iov_end = base + len;
off = base;
iov_end = off + len;
while (1) {
int ret;
struct iovec piov;
unsigned long piov_end;
struct page_read * prp;
@@ -108,8 +93,7 @@ int dedup_one_iovec(struct page_read *pr, unsigned long base, unsigned long len)
if (!pr->pe)
return -1;
pagemap2iovec(pr->pe, &piov);
piov_end = (unsigned long)piov.iov_base + piov.iov_len;
piov_end = pr->pe->vaddr + pagemap_len(pr->pe);
if (!pr->pe->in_parent) {
ret = punch_hole(pr, pr->pi_off, min(piov_end, iov_end) - off, false);
if (ret == -1)