From 19d1509c398a910762d8b1d4ad90ddde356e5dd9 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Wed, 11 May 2016 07:51:11 -0600 Subject: [PATCH] c/r: add an option to use faster inotify support in CRIU The idea here is that criu can use open_by_handle on a configuration which will preserve inodes on moves across hosts, but shouldn't do that on configurations which won't preserve inodes. Before, we forced it to always be slow, but we don't have to do this. Signed-off-by: Tycho Andersen --- src/lxc/criu.c | 12 +++++++++--- src/lxc/lxccontainer.h | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 18cca3c0e..ce8ada6f1 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -115,7 +115,7 @@ static int load_tty_major_minor(char *directory, char *output, int len) static void exec_criu(struct criu_opts *opts) { char **argv, log[PATH_MAX]; - int static_args = 24, argc = 0, i, ret; + int static_args = 23, argc = 0, i, ret; int netnr = 0; struct lxc_list *it; @@ -134,7 +134,7 @@ static void exec_criu(struct criu_opts *opts) } /* The command line always looks like: - * criu $(action) --tcp-established --file-locks --link-remap --force-irmap \ + * criu $(action) --tcp-established --file-locks --link-remap \ * --manage-cgroups action-script foo.sh -D $(directory) \ * -o $(directory)/$(action).log --ext-mount-map auto * --enable-external-sharing --enable-external-masters @@ -160,6 +160,10 @@ static void exec_criu(struct criu_opts *opts) /* --external tty[88,4] */ if (opts->tty_id[0]) static_args += 2; + + /* --force-irmap */ + if (!opts->user->preserves_inodes) + static_args++; } else if (strcmp(opts->action, "restore") == 0) { /* --root $(lxc_mount_point) --restore-detached * --restore-sibling --pidfile $foo --cgroup-root $foo @@ -214,7 +218,6 @@ static void exec_criu(struct criu_opts *opts) DECLARE_ARG("--tcp-established"); DECLARE_ARG("--file-locks"); DECLARE_ARG("--link-remap"); - DECLARE_ARG("--force-irmap"); DECLARE_ARG("--manage-cgroups"); DECLARE_ARG("--ext-mount-map"); DECLARE_ARG("auto"); @@ -277,6 +280,9 @@ static void exec_criu(struct criu_opts *opts) DECLARE_ARG(opts->user->pageserver_port); } + if (!opts->user->preserves_inodes) + DECLARE_ARG("--force-irmap"); + /* only for final dump */ if (strcmp(opts->action, "dump") == 0 && !opts->user->stop) DECLARE_ARG("--leave-running"); diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h index 0e014bc80..ecc66e226 100644 --- a/src/lxc/lxccontainer.h +++ b/src/lxc/lxccontainer.h @@ -884,6 +884,13 @@ struct migrate_opts { char *predump_dir; /* relative to directory above */ char *pageserver_address; /* where should memory pages be send? */ char *pageserver_port; + + /* This flag indicates whether or not the container's rootfs will have + * the same inodes on checkpoint and restore. In the case of e.g. zfs + * send or btrfs send, or an LVM snapshot, this will be true, but it + * won't if e.g. you rsync the filesystems between two machines. + */ + bool preserves_inodes; }; /*! -- 2.47.2