[CRIU] [PATCH 5/8] remap: Rename global lock

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


Now this lock is only needed to serialize remap open
code, so name it such.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/files-reg.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 06ff0f3..825481e 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -59,7 +59,13 @@ struct ghost_file {
 static u32 ghost_file_ids = 1;
 static LIST_HEAD(ghost_files);
 
-static mutex_t *ghost_file_mutex;
+/*
+ * When opening remaps we first create a link on the remap
+ * target, then open one, then unlink. In case the remap
+ * source has more than one instance, these tree steps
+ * should be serialized with each other.
+ */
+static mutex_t *remap_open_lock;
 
 static LIST_HEAD(remaps);
 
@@ -1448,7 +1454,7 @@ int open_path(struct file_desc *d,
 			BUG();
 		}
 
-		mutex_lock(ghost_file_mutex);
+		mutex_lock(remap_open_lock);
 		if (rfi->remap->is_dir) {
 			/*
 			 * FIXME Can't make directory under new name.
@@ -1534,7 +1540,7 @@ ext:
 			rm_parent_dirs(mntns_root, rfi->path, level);
 		}
 
-		mutex_unlock(ghost_file_mutex);
+		mutex_unlock(remap_open_lock);
 	}
 	if (orig_path)
 		rfi->path = orig_path;
@@ -1721,11 +1727,11 @@ static struct collect_image_info reg_file_cinfo = {
 
 int prepare_shared_reg_files(void)
 {
-	ghost_file_mutex = shmalloc(sizeof(*ghost_file_mutex));
-	if (!ghost_file_mutex)
+	remap_open_lock = shmalloc(sizeof(*remap_open_lock));
+	if (!remap_open_lock)
 		return -1;
 
-	mutex_init(ghost_file_mutex);
+	mutex_init(remap_open_lock);
 	return 0;
 }
 
-- 
2.1.4



More information about the CRIU mailing list