[CRIU] [PATCH 1/2] vma: Reshuffle the struct vma_area

Pavel Emelyanov xemul at parallels.com
Tue Sep 23 09:31:16 PDT 2014


We have some fields, that are dump-only and some that
are restore only (quite a lot of them actually).

Reshuffle them on the vma_area to explicitly show which
one is which. And rename some of them for easier grep.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-dump.c     |  6 +++---
 files-reg.c   |  4 ++--
 include/vma.h | 32 +++++++++++++++++---------------
 mem.c         |  2 +-
 proc_parse.c  |  4 ++--
 5 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index d00c158..72eb94d 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -135,7 +135,7 @@ void free_mappings(struct vm_area_list *vma_area_list)
 	list_for_each_entry_safe(vma_area, p, &vma_area_list->h, list) {
 		close_vma_file(vma_area);
 		if (!vma_area->file_borrowed)
-			free(vma_area->st);
+			free(vma_area->vmst);
 		free(vma_area);
 	}
 
@@ -369,8 +369,8 @@ static int dump_filemap(pid_t pid, struct vma_area *vma_area,
 	int ret = 0;
 	u32 id;
 
-	BUG_ON(!vma_area->st);
-	p.stat = *vma_area->st;
+	BUG_ON(!vma_area->vmst);
+	p.stat = *vma_area->vmst;
 
 	/*
 	 * AUFS support to compensate for the kernel bug
diff --git a/files-reg.c b/files-reg.c
index 508263a..ed117f5 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -1021,7 +1021,7 @@ int get_filemap_fd(struct vma_area *vma)
 	 * We open file w/o lseek, as mappings don't care about it
 	 */
 
-	BUG_ON(vma->fd == NULL);
+	BUG_ON(vma->vmfd == NULL);
 	if (vma->e->has_fdflags)
 		flags = vma->e->fdflags;
 	else if ((vma->e->prot & PROT_WRITE) &&
@@ -1030,7 +1030,7 @@ int get_filemap_fd(struct vma_area *vma)
 	else
 		flags = O_RDONLY;
 
-	return open_path(vma->fd, do_open_reg_noseek_flags, &flags);
+	return open_path(vma->vmfd, do_open_reg_noseek_flags, &flags);
 }
 
 static void remap_get(struct file_desc *fdesc, char typ)
diff --git a/include/vma.h b/include/vma.h
index 80d228a..37e77f9 100644
--- a/include/vma.h
+++ b/include/vma.h
@@ -28,24 +28,26 @@ struct vma_area {
 	VmaEntry		*e;
 
 	union {
-		int		vm_file_fd;
-		int		vm_socket_id;
-		struct file_desc *fd;
-	};
-	union {
-		unsigned long	*page_bitmap;	/* existent pages, restore only */
-		char		*aufs_rpath;	/* path from aufs root, dump only */
-	};
-	union {
-		unsigned long	*ppage_bitmap;	/* parent's existent pages */
-		char		*aufs_fpath;	/* full path from global root, dump only */
-	};
+		struct /* for dump */ {
+			union {
+				int	vm_file_fd;
+				int	vm_socket_id;
+			};
 
-	unsigned long		premmaped_addr;
+			char		*aufs_rpath;	/* path from aufs root */
+			char		*aufs_fpath;	/* full path from global root */
 
-	bool			file_borrowed;
+			bool		file_borrowed;
+			struct stat	*vmst;
+		};
 
-	struct stat		*st;
+		struct /* for restore */ {
+			struct file_desc *vmfd;
+			unsigned long	*page_bitmap;	/* existent pages */
+			unsigned long	*ppage_bitmap;	/* parent's existent pages */
+			unsigned long	premmaped_addr;	/* restore only */
+		};
+	};
 };
 
 extern struct vma_area *alloc_vma_area(void);
diff --git a/mem.c b/mem.c
index 6df11ab..f2ff1dd 100644
--- a/mem.c
+++ b/mem.c
@@ -377,7 +377,7 @@ static inline int collect_filemap(struct vma_area *vma)
 	if (!fd)
 		return -1;
 
-	vma->fd = fd;
+	vma->vmfd = fd;
 	return 0;
 }
 
diff --git a/proc_parse.c b/proc_parse.c
index 9aa17d4..82af774 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -452,11 +452,11 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
 			vma_area->e->flags |= (prev->e->flags & MAP_ANONYMOUS);
 			vma_area->e->status = prev->e->status;
 			vma_area->e->shmid = prev->e->shmid;
-			vma_area->st = prev->st;
+			vma_area->vmst = prev->vmst;
 		} else if (vma_area->vm_file_fd >= 0) {
 			struct stat *st_buf;
 
-			st_buf = vma_area->st = xmalloc(sizeof(*st_buf));
+			st_buf = vma_area->vmst = xmalloc(sizeof(*st_buf));
 			if (!st_buf)
 				goto err;
 
-- 
1.8.4.2



More information about the CRIU mailing list