[CRIU] [PATCH 08/12]v2 deduplication: add punching holes in "parent"
Tikhomirov Pavel
snorcht at gmail.com
Mon Dec 16 02:55:32 PST 2013
punch where coresponding data was updated in curent snapshot
Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
cr-dedup.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/cr-dedup.c b/cr-dedup.c
index 2a9cbf5..d9ec07d 100644
--- a/cr-dedup.c
+++ b/cr-dedup.c
@@ -1,3 +1,5 @@
+#include <fcntl.h>
+#include <linux/falloc.h>
#include <unistd.h>
#include "crtools.h"
@@ -125,6 +127,16 @@ int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
return -1;
pagemap2iovec(pr->pe, &piov);
piov_end = (unsigned long)piov.iov_base + piov.iov_len;
+ off_real = lseek(pr->fd_pg, 0, SEEK_CUR);
+ if (!pr->pe->in_parent) {
+ pr_debug("Punch!/%lu/%lu/\n", off_real, min(piov_end, iov_end) - off);
+ ret = fallocate(pr->fd_pg, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+ off_real, min(piov_end, iov_end) - off);
+ if (ret != 0) {
+ pr_perror("Error punching hole : %d\n", errno);
+ return -1;
+ }
+ }
if (piov_end < iov_end) {
off = piov_end;
--
1.7.9.5
More information about the CRIU
mailing list