Commit edde5fb4 authored by Pavel Emelyanov's avatar Pavel Emelyanov

irmap: Add option that forces fsnotify watches paths resolve

When migrating container with copying its FS, the inode numbers
and thus their handles wil change. This will make the restore of
inotify/fanotify fail, since they do it via fhandles.

We've already faced the problems with fsnotifies on NFS -- they
don't work there. To address this an irmap cache is created on
pre-dump, so to resolve the issue with changed inodes during
migration, we can force the irmap cache build.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5da52f6a
......@@ -262,6 +262,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (req->has_auto_dedup)
opts.auto_dedup = req->auto_dedup;
if (req->has_force_irmap)
opts.force_irmap = req->force_irmap;
if (req->ps) {
opts.use_page_server = true;
opts.addr = req->ps->address;
......
......@@ -161,6 +161,7 @@ int main(int argc, char *argv[])
{ "auto-dedup", no_argument, 0, 56},
{ "libdir", required_argument, 0, 'L'},
{ "cpu-cap", required_argument, 0, 57},
{ "force-irmap", no_argument, 0, 58},
{ },
};
......@@ -323,6 +324,9 @@ int main(int argc, char *argv[])
if (parse_cpu_cap(&opts, optarg))
goto usage;
break;
case 58:
opts.force_irmap = true;
break;
case 54:
opts.check_ms_kernel = true;
break;
......@@ -469,6 +473,7 @@ usage:
" -j|--" OPT_SHELL_JOB " allow to dump and restore shell jobs\n"
" -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"
"\n"
"* Logging:\n"
" -o|--log-file FILE log file name\n"
......
......@@ -38,6 +38,7 @@
#include "list.h"
#include "lock.h"
#include "irmap.h"
#include "cr_options.h"
#include "protobuf.h"
#include "protobuf/fsnotify.pb-c.h"
......@@ -134,6 +135,9 @@ int check_open_handle(unsigned int s_dev, unsigned long i_ino,
int fd = -1;
char *path;
if (opts.force_irmap)
goto do_irmap;
fd = open_handle(s_dev, i_ino, f_handle);
if (fd >= 0) {
struct mount_info *mi;
......@@ -168,6 +172,7 @@ int check_open_handle(unsigned int s_dev, unsigned long i_ino,
return 0;
}
do_irmap:
pr_warn("\tHandle %x:%lx cannot be opened\n", s_dev, i_ino);
path = irmap_lookup(s_dev, i_ino);
if (!path) {
......
......@@ -47,6 +47,7 @@ struct cr_options {
char *img_parent;
bool auto_dedup;
unsigned int cpu_cap;
bool force_irmap;
};
extern struct cr_options opts;
......
......@@ -36,6 +36,7 @@ message criu_opts {
repeated criu_veth_pair veths = 19;
optional uint32 cpu_cap = 20 [default = 0xffffffff];
optional bool force_irmap = 21;
}
message criu_dump_resp {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment