[CRIU] [PATCH 1/3] fsnotify: Add ability to force resolve paths for watchees

Cyrill Gorcunov gorcunov at openvz.org
Fri Oct 30 06:16:27 PDT 2015


In case of migrating filesystem with nonpersistent inodes\devices
we may hit the case where we successfully dump the container but
on restore we will fail because block device get another id
(while its contents might be fully sinc'ed). In this case we
will try to lookup device from its number carried in image
and fail.

Instead, when user know that he is migrating and prefer
a flexible scheme -- we try to resolve file handle into
a path and use it instead on the restore (just like
for tmpfs/devtmpfs).

https://jira.sw.ru/browse/PSBM-40871

Reported-by: Nikita Spiridonov <nspiridonov at odin.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 crtools.c            |  5 +++++
 fsnotify.c           | 11 +++++++++--
 include/cr_options.h |  1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/crtools.c b/crtools.c
index d3812a18f4f0..243d90188ac8 100644
--- a/crtools.c
+++ b/crtools.c
@@ -253,6 +253,7 @@ int main(int argc, char *argv[], char *envp[])
 		{ "freeze-cgroup",		required_argument,	0, 1068 },
 		{ "ghost-limit",		required_argument,	0, 1069 },
 		{ "irmap-scan-path",		required_argument,	0, 1070 },
+		{ "force-inotify-path",		required_argument,	0, 1071 },
 		{ },
 	};
 
@@ -498,6 +499,9 @@ int main(int argc, char *argv[], char *envp[])
 			if (irmap_scan_path_add(optarg))
 				return -1;
 			break;
+		case 1071:
+			opts.force_inotify_path = true;
+			break;
 		case 'M':
 			{
 				char *aux;
@@ -727,6 +731,7 @@ usage:
 "  -l|--" OPT_FILE_LOCKS "       handle file locks, for safety, only used for container\n"
 "  -L|--libdir           path to a plugin directory (by default " CR_PLUGIN_DEFAULT ")\n"
 "  --force-irmap         force resolving names for inotify/fsnotify watches\n"
+"  --force-inotify-path  force inotify/fsnotify watches to carry paths (for migration)\n"
 "  --irmap-scan-path FILE\n"
 "                        add a path the irmap hints to scan\n"
 "  -M|--ext-mount-map KEY:VALUE\n"
diff --git a/fsnotify.c b/fsnotify.c
index 9629977de8bc..57077a974562 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -241,9 +241,16 @@ int check_open_handle(unsigned int s_dev, unsigned long i_ino,
 		/*
 		 * Inode numbers are not restored for tmpfs content, but we can
 		 * get file names, becasue tmpfs cache is not pruned.
+		 *
+		 * Moreover, when we're migrating to another filesystem
+		 * previously say sync'ed its contents, the device may
+		 * be changed so on restore we won't be able to lookup
+		 * for same hardcoded @s_dev. So carry a path if user
+		 * requested.
 		 */
-		if ((mi->fstype->code == FSTYPE__TMPFS) ||
-				(mi->fstype->code == FSTYPE__DEVTMPFS)) {
+		if ((mi->fstype->code == FSTYPE__TMPFS)		||
+		    (mi->fstype->code == FSTYPE__DEVTMPFS)	||
+		    opts.force_inotify_path) {
 			path = alloc_openable(s_dev, i_ino, f_handle);
 			if (IS_ERR_OR_NULL(path)) {
 				pr_err("Can't find suitable path for handle (%d)\n",
diff --git a/include/cr_options.h b/include/cr_options.h
index eac7283a4821..f655ad09e195 100644
--- a/include/cr_options.h
+++ b/include/cr_options.h
@@ -84,6 +84,7 @@ struct cr_options {
 	bool			auto_dedup;
 	unsigned int		cpu_cap;
 	bool			force_irmap;
+	bool			force_inotify_path;
 	char			**exec_cmd;
 	unsigned int		manage_cgroups;
 	char			*new_global_cg_root;
-- 
2.4.3



More information about the CRIU mailing list