mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 15:25:21 +00:00
dedup: Cleanup checking whether we batch punching or not
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
13
cr-dedup.c
13
cr-dedup.c
@@ -103,15 +103,22 @@ exit:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool can_extend_batch(struct iovec *bunch,
|
||||||
|
unsigned long off, unsigned long len)
|
||||||
|
{
|
||||||
|
return /* The next region is the continuation of the existing */
|
||||||
|
((unsigned long)bunch->iov_base + bunch->iov_len == off) &&
|
||||||
|
/* The resulting region is non empty and is small enough */
|
||||||
|
(bunch->iov_len == 0 || bunch->iov_len + len < MAX_BUNCH_SIZE * PAGE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
int punch_hole(struct page_read *pr, unsigned long off, unsigned long len,
|
int punch_hole(struct page_read *pr, unsigned long off, unsigned long len,
|
||||||
bool cleanup)
|
bool cleanup)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct iovec * bunch = &pr->bunch;
|
struct iovec * bunch = &pr->bunch;
|
||||||
|
|
||||||
if ((unsigned long)bunch->iov_base + bunch->iov_len == off && !cleanup
|
if (!cleanup && can_extend_batch(bunch, off, len)) {
|
||||||
&& (bunch->iov_len + len < MAX_BUNCH_SIZE * PAGE_SIZE
|
|
||||||
|| bunch->iov_len == 0)) {
|
|
||||||
pr_debug("pr%d:Extend bunch len from %lx to %lx\n", pr->id,
|
pr_debug("pr%d:Extend bunch len from %lx to %lx\n", pr->id,
|
||||||
bunch->iov_len, bunch->iov_len + len);
|
bunch->iov_len, bunch->iov_len + len);
|
||||||
bunch->iov_len += len;
|
bunch->iov_len += len;
|
||||||
|
Reference in New Issue
Block a user