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

Cyrill Gorcunov gorcunov at gmail.com
Mon Nov 2 12:28:27 PST 2015


On Mon, Nov 02, 2015 at 06:51:42PM +0300, Pavel Emelyanov wrote:
> 
> One more option is excessive here. There are 3 big blocks that are in the
> game here -- get inode handle, try to get the inode name, force FS scan to
> get the inode name. And the 2nd block is must-have for TMPFS or (with this
> patch) option. I propose to remove the option and make soft path lookup 
> happen always, but only to fail the dump for TMPFS-s. The forced FS scan
> should a) be performed iff the soft path resolve failed and b) still be
> under option, which should be turned on by p.haul rsync driver.
> 

I guess you meant something like attached.
-------------- next part --------------
>From 35144cf4a11dfa5e652758208f662839f1510b93 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Mon, 2 Nov 2015 23:24:53 +0300
Subject: [PATCH] fsnotify: Lookup for watchee path before doing irmap

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 lets do an optimistic approach -- always try to
fetch the watchee path first and if it fails go down
to old scheme where irmap and native handle steps
into account.

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

Reported-by: Nikita Spiridonov <nspiridonov at odin.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 fsnotify.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/fsnotify.c b/fsnotify.c
index 9629977de8bc..4477ba79987d 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -239,18 +239,25 @@ 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.
+		 * Always try to fetch watchee path first. There are several reasons:
+		 *
+		 *  - tmpfs/devtmps do not save inode numbers between mounts,
+		 *    so it is critical to have the complete path under our
+		 *    hands for restore purpose;
+		 *
+		 *  - in case of migration the inodes might be changed as well
+		 *    so the only portable solution is to carry the whole path
+		 *    to the watchee inside image.
 		 */
-		if ((mi->fstype->code == FSTYPE__TMPFS) ||
-				(mi->fstype->code == FSTYPE__DEVTMPFS)) {
-			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",
-				       (int)PTR_ERR(path));
-				goto err;
-			}
+		path = alloc_openable(s_dev, i_ino, f_handle);
+		if (!IS_ERR_OR_NULL(path))
 			goto out;
+
+		if ((mi->fstype->code == FSTYPE__TMPFS) ||
+		    (mi->fstype->code == FSTYPE__DEVTMPFS)) {
+			pr_err("Can't find suitable path for handle (dev %#x ino %#lx): %d\n",
+			       s_dev, i_ino, (int)PTR_ERR(path));
+			goto err;
 		}
 
 		if (!opts.force_irmap)
-- 
2.4.3



More information about the CRIU mailing list