[CRIU] [PATCH 03/22] fsnotofy: Do remap resolve in post-prep

Pavel Emelyanov xemul at virtuozzo.com
Fri Jun 30 13:56:31 MSK 2017


The remap is searhced by dev:ino pair that is known only when
root task starts (and opend the remap). The collection stage
is about to happen in crtools, so move the resolve in post-prep.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/fsnotify.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/criu/fsnotify.c b/criu/fsnotify.c
index cb1b32c..6ceafaa 100644
--- a/criu/fsnotify.c
+++ b/criu/fsnotify.c
@@ -57,6 +57,7 @@ struct fsnotify_mark_info {
 		InotifyWdEntry		*iwe;
 		FanotifyMarkEntry	*fme;
 	};
+	struct pprep_head		prep; /* XXX union with remap */
 	struct file_remap		*remap;
 };
 
@@ -721,6 +722,24 @@ static struct file_desc_ops fanotify_desc_ops = {
 	.open = open_fanotify_fd,
 };
 
+static int inotify_resolve_remap(struct pprep_head *ph)
+{
+	struct fsnotify_mark_info *m;
+
+	m = container_of(ph, struct fsnotify_mark_info, prep);
+	m->remap = lookup_ghost_remap(m->iwe->s_dev, m->iwe->i_ino);
+	return 0;
+}
+
+static int fanotify_resolve_remap(struct pprep_head *ph)
+{
+	struct fsnotify_mark_info *m;
+
+	m = container_of(ph, struct fsnotify_mark_info, prep);
+	m->remap = lookup_ghost_remap(m->fme->s_dev, m->fme->ie->i_ino);
+	return 0;
+}
+
 static int __collect_inotify_mark(struct fsnotify_file_info *p, struct fsnotify_mark_info *mark)
 {
 	struct fsnotify_mark_info *m;
@@ -734,7 +753,8 @@ static int __collect_inotify_mark(struct fsnotify_file_info *p, struct fsnotify_
 			break;
 
 	list_add_tail(&mark->list, &m->list);
-	mark->remap = lookup_ghost_remap(mark->iwe->s_dev, mark->iwe->i_ino);
+	mark->prep.actor = inotify_resolve_remap;
+	add_post_prepare_cb(&mark->prep);
 	return 0;
 }
 
@@ -742,9 +762,10 @@ static int __collect_fanotify_mark(struct fsnotify_file_info *p,
 				struct fsnotify_mark_info *mark)
 {
 	list_add(&mark->list, &p->marks);
-	if (mark->fme->type == MARK_TYPE__INODE)
-		mark->remap = lookup_ghost_remap(mark->fme->s_dev,
-						 mark->fme->ie->i_ino);
+	if (mark->fme->type == MARK_TYPE__INODE) {
+		mark->prep.actor = fanotify_resolve_remap;
+		add_post_prepare_cb(&mark->prep);
+	}
 	return 0;
 }
 
-- 
2.1.4



More information about the CRIU mailing list