[CRIU] [PATCH 4/5] deduplication: add punching holes in "parent"
Tikhomirov Pavel
snorcht at gmail.com
Fri Oct 11 12:57:34 PDT 2013
punch where coresponding data was updated in curent snapshot
Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
cr-dedup.c | 11 +++++++++++
include/cr-dedup.h | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/cr-dedup.c b/cr-dedup.c
index a51d90d..1386cf9 100755
--- a/cr-dedup.c
+++ b/cr-dedup.c
@@ -90,6 +90,17 @@ int _cr_dedup(DIR * dirp, int pid)
continue;
}
+ if (!pr.pe->in_parent && !pr2.pe->in_parent) {
+ /* punch */
+ pr_info("Punch!/%lu/%lu/\n", off * PAGE_SIZE + i_off, i_len);
+
+ ret = fallocate(pr2.fd_pg, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off * PAGE_SIZE + i_off, i_len);
+ if (ret != 0) {
+ pr_err("Error fallocate : %d\n", errno);
+ goto exit;
+ }
+ }
+
if (iov.iov_base + iov.iov_len == iov2.iov_base + iov2.iov_len) {
ret = pr.get_pagemap(&pr, &iov);
if (ret <= 0)
diff --git a/include/cr-dedup.h b/include/cr-dedup.h
index 3840a12..08138df 100644
--- a/include/cr-dedup.h
+++ b/include/cr-dedup.h
@@ -1,6 +1,15 @@
#ifndef __CR_DEDUP_H__
#define __CR_DEDUP_H__
+#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
+#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
+
+struct to_punch{
+ struct list_head list;
+ unsigned long off;
+ unsigned long nr_pages;
+};
+
int cr_dedup(void);
#endif
--
1.7.9.5
More information about the CRIU
mailing list