[CRIU] [PATCH 4/4] fsnotify: Restore name-hinted marks

Pavel Emelyanov xemul at parallels.com
Tue Jan 28 10:54:03 PST 2014


If we failed to open inode by handle, try doing the irmap
search. If that's successful, dump the "real" path for the
inode.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 fsnotify.c        | 19 +++++++++++++++++--
 protobuf/fh.proto |  1 +
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/fsnotify.c b/fsnotify.c
index e7af866..9430919 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -36,6 +36,7 @@
 #include "log.h"
 #include "list.h"
 #include "lock.h"
+#include "irmap.h"
 
 #include "protobuf.h"
 #include "protobuf/fsnotify.pb-c.h"
@@ -127,6 +128,7 @@ static int check_open_handle(unsigned int s_dev, unsigned long i_ino,
 		FhEntry *f_handle)
 {
 	int fd;
+	char *path;
 
 	fd = open_handle(s_dev, i_ino, f_handle);
 	if (fd >= 0) {
@@ -135,8 +137,16 @@ static int check_open_handle(unsigned int s_dev, unsigned long i_ino,
 		return 0;
 	}
 
-	pr_err("\tHandle %x:%lx cannot be opened\n", s_dev, i_ino);
-	return -1;
+	pr_warn("\tHandle %x:%lx cannot be opened\n", s_dev, i_ino);
+	path = irmap_lookup(s_dev, i_ino);
+	if (!path) {
+		pr_err("\tCan't dump that handle\n");
+		return -1;
+	}
+
+	pr_debug("\tDumping %s as path for handle\n", path);
+	f_handle->path = path;
+	return 0;
 }
 
 static int dump_inotify_entry(union fdinfo_entries *e, void *arg)
@@ -256,6 +266,11 @@ static char *get_mark_path(const char *who, struct file_remap *remap,
 		return remap->path;
 	}
 
+	if (f_handle->path) {
+		pr_debug("\t\tRestore with path hint %s\n", f_handle->path);
+		return f_handle->path;
+	}
+
 	*target = open_handle(s_dev, i_ino, f_handle);
 	if (*target < 0)
 		goto err;
diff --git a/protobuf/fh.proto b/protobuf/fh.proto
index 6682465..63aa7a2 100644
--- a/protobuf/fh.proto
+++ b/protobuf/fh.proto
@@ -8,4 +8,5 @@ message fh_entry {
 
 	/* The minimum is fh_n_handle repetitions */
 	repeated uint64		handle	= 3;
+	optional string		path	= 4;
 }
-- 
1.8.4.2


More information about the CRIU mailing list