[CRIU] [PATCH v4 02/12] files-reg: pass rmntns_root as parameter to clean_one_remap

Eugene Batalov eabatalov89 at gmail.com
Sun Sep 11 10:14:41 PDT 2016


clean_one_remap uses mntns_get_root_by_mnt_id() to get link remap
mnt ns root fd. We can't call mntns_get_root_by_mnt_id() during gc
because it calls mntns_get_root_fd() that uses root ps tree item
proc dir to get mnt ns root fd. There is no root ps tree item
during criu gc so we can't call mntns_get_root_by_mnt_id().
In this patch we make rmntns_root to be clean_one_remap parameter.
After that caller of clean_one_remap can override the way to obtain
link remap mnt ns root fd passing it as a parameter.

Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 criu/files-reg.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index b91a2c3..45100f9 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -523,11 +523,12 @@ static void try_clean_ghost(struct remap_info *ri)
 	pr_perror(" `- XFail [%s] ghost", path);
 }
 
-static int clean_one_remap(struct file_remap *remap)
+static int clean_one_remap(struct file_remap *remap, int rmntns_root)
 {
-	int rmntns_root, ret = 0;
+	int ret = 0;
 
-	rmntns_root = mntns_get_root_by_mnt_id(remap->rmnt_id);
+	if (rmntns_root == -1)
+		rmntns_root = mntns_get_root_by_mnt_id(remap->rmnt_id);
 	if (rmntns_root < 0)
 		return -1;
 
@@ -625,7 +626,7 @@ void remap_put(struct file_remap *remap)
 {
 	mutex_lock(ghost_file_mutex);
 	if (--remap->users == 0)
-		clean_one_remap(remap);
+		clean_one_remap(remap, -1);
 	mutex_unlock(ghost_file_mutex);
 }
 
@@ -1505,7 +1506,7 @@ ext:
 
 		BUG_ON(!rfi->remap->users);
 		if (--rfi->remap->users == 0)
-			clean_one_remap(rfi->remap);
+			clean_one_remap(rfi->remap, -1);
 
 		mutex_unlock(ghost_file_mutex);
 	}
-- 
1.9.1



More information about the CRIU mailing list