[CRIU] [PATCH 6/8] regfiles: Kill prepare_shared_reg_files()

Pavel Emelyanov xemul at virtuozzo.com
Thu May 18 02:36:32 PDT 2017


This routine just initializes the remap open lock,
and there's already the code that initializes the
whole remap engine.

Re-arrange this part.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c        |  3 ---
 criu/files-reg.c         | 24 ++++++++++++++----------
 criu/include/files-reg.h |  2 --
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index e890025..2179fd3 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -327,9 +327,6 @@ static int root_prepare_shared(void)
 
 	pr_info("Preparing info about shared resources\n");
 
-	if (prepare_shared_reg_files())
-		return -1;
-
 	if (prepare_remaps())
 		return -1;
 
diff --git a/criu/files-reg.c b/criu/files-reg.c
index 825481e..6087674 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -67,6 +67,16 @@ static LIST_HEAD(ghost_files);
  */
 static mutex_t *remap_open_lock;
 
+static inline int init_remap_lock(void)
+{
+	remap_open_lock = shmalloc(sizeof(*remap_open_lock));
+	if (!remap_open_lock)
+		return -1;
+
+	mutex_init(remap_open_lock);
+	return 0;
+}
+
 static LIST_HEAD(remaps);
 
 /*
@@ -504,6 +514,10 @@ int prepare_remaps(void)
 	struct remap_info *ri;
 	int ret = 0;
 
+	ret = init_remap_lock();
+	if (ret)
+		return ret;
+
 	list_for_each_entry(ri, &remaps, list) {
 		ret = prepare_one_remap(ri);
 		if (ret)
@@ -1725,16 +1739,6 @@ static struct collect_image_info reg_file_cinfo = {
 	.flags = COLLECT_SHARED,
 };
 
-int prepare_shared_reg_files(void)
-{
-	remap_open_lock = shmalloc(sizeof(*remap_open_lock));
-	if (!remap_open_lock)
-		return -1;
-
-	mutex_init(remap_open_lock);
-	return 0;
-}
-
 int collect_remaps_and_regfiles(void)
 {
 	if (collect_image(&reg_file_cinfo))
diff --git a/criu/include/files-reg.h b/criu/include/files-reg.h
index ba2ad6c..c205da7 100644
--- a/criu/include/files-reg.h
+++ b/criu/include/files-reg.h
@@ -32,8 +32,6 @@ extern int open_path(struct file_desc *, int (*open_cb)(int ns_root_fd,
 			struct reg_file_info *, void *), void *arg);
 extern void clear_ghost_files(void);
 
-extern int prepare_shared_reg_files(void);
-
 extern const struct fdtype_ops regfile_dump_ops;
 extern int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, void *arg);
 extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
-- 
2.1.4



More information about the CRIU mailing list