mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
opts: Allo to specify the maximum size of ghost files
For example we hit a case where systemd carries journal file with 4M in size. https://jira.sw.ru/browse/PSBM-38571 Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
1bdb8298d0
commit
ced8f88401
@ -176,6 +176,12 @@ In other words, do not use it until really needed.
|
|||||||
*--link-remap*::
|
*--link-remap*::
|
||||||
Allow one to link unlinked files back when possible (modifies FS till *restore*).
|
Allow one to link unlinked files back when possible (modifies FS till *restore*).
|
||||||
|
|
||||||
|
*--ghost-limit* 'size'::
|
||||||
|
Allow one to specify maximum allowed size of deleted file to be carried
|
||||||
|
inside image files. By default up to 1M file is allowed. It is done in
|
||||||
|
a sake to not carry big files inside images. 'size' may be postfixed
|
||||||
|
with 'K', 'M' or 'G' (which stands for kilo, mega and gigabytes accordingly).
|
||||||
|
|
||||||
*-j*, *--shell-job*::
|
*-j*, *--shell-job*::
|
||||||
Allow one to dump shell jobs. This implies the restored task will inherit session and
|
Allow one to dump shell jobs. This implies the restored task will inherit session and
|
||||||
process group ID from the criu itself. Also this option allows one to migrate a
|
process group ID from the criu itself. Also this option allows one to migrate a
|
||||||
|
17
crtools.c
17
crtools.c
@ -60,6 +60,7 @@ void init_opts(void)
|
|||||||
opts.cpu_cap = CPU_CAP_DEFAULT;
|
opts.cpu_cap = CPU_CAP_DEFAULT;
|
||||||
opts.manage_cgroups = CG_MODE_DEFAULT;
|
opts.manage_cgroups = CG_MODE_DEFAULT;
|
||||||
opts.ps_socket = -1;
|
opts.ps_socket = -1;
|
||||||
|
opts.ghost_limit = DEFAULT_GHOST_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_ns_string(const char *ptr)
|
static int parse_ns_string(const char *ptr)
|
||||||
@ -175,6 +176,17 @@ Esyntax:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t parse_size(char *optarg)
|
||||||
|
{
|
||||||
|
if (index(optarg, 'K'))
|
||||||
|
return (size_t)KILO(atol(optarg));
|
||||||
|
else if (index(optarg, 'M'))
|
||||||
|
return (size_t)MEGA(atol(optarg));
|
||||||
|
else if (index(optarg, 'G'))
|
||||||
|
return (size_t)GIGA(atol(optarg));
|
||||||
|
return (size_t)atol(optarg);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[], char *envp[])
|
int main(int argc, char *argv[], char *envp[])
|
||||||
{
|
{
|
||||||
pid_t pid = 0, tree_id = 0;
|
pid_t pid = 0, tree_id = 0;
|
||||||
@ -236,6 +248,7 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
{ "enable-external-sharing", no_argument, 0, 1066 },
|
{ "enable-external-sharing", no_argument, 0, 1066 },
|
||||||
{ "enable-external-masters", no_argument, 0, 1067 },
|
{ "enable-external-masters", no_argument, 0, 1067 },
|
||||||
{ "freeze-cgroup", required_argument, 0, 1068 },
|
{ "freeze-cgroup", required_argument, 0, 1068 },
|
||||||
|
{ "ghost-limit", required_argument, 0, 1069 },
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -469,6 +482,9 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
case 1068:
|
case 1068:
|
||||||
opts.freeze_cgroup = optarg;
|
opts.freeze_cgroup = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 1069:
|
||||||
|
opts.ghost_limit = parse_size(optarg);
|
||||||
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
{
|
{
|
||||||
char *aux;
|
char *aux;
|
||||||
@ -693,6 +709,7 @@ usage:
|
|||||||
" can optionally append @<bridge-name> to OUT for moving\n"
|
" can optionally append @<bridge-name> to OUT for moving\n"
|
||||||
" the outside veth to the named bridge\n"
|
" the outside veth to the named bridge\n"
|
||||||
" --link-remap allow one to link unlinked files back when possible\n"
|
" --link-remap allow one to link unlinked files back when possible\n"
|
||||||
|
" --ghost-limit size specify maximum size of deleted file contents to be carried inside an image file\n"
|
||||||
" --action-script FILE add an external action script\n"
|
" --action-script FILE add an external action script\n"
|
||||||
" -j|--" OPT_SHELL_JOB " allow one to dump and restore shell jobs\n"
|
" -j|--" OPT_SHELL_JOB " allow one to dump and restore shell jobs\n"
|
||||||
" -l|--" OPT_FILE_LOCKS " handle file locks, for safety, only used for container\n"
|
" -l|--" OPT_FILE_LOCKS " handle file locks, for safety, only used for container\n"
|
||||||
|
10
files-reg.c
10
files-reg.c
@ -66,12 +66,6 @@ struct link_remap_rlb {
|
|||||||
};
|
};
|
||||||
static LIST_HEAD(link_remaps);
|
static LIST_HEAD(link_remaps);
|
||||||
|
|
||||||
/*
|
|
||||||
* This constant is selected without any calculations. Just do not
|
|
||||||
* want to pick up too big files with us in the image.
|
|
||||||
*/
|
|
||||||
#define MAX_GHOST_FILE_SIZE (1 * 1024 * 1024)
|
|
||||||
|
|
||||||
static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, char *root, struct cr_img *img)
|
static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, char *root, struct cr_img *img)
|
||||||
{
|
{
|
||||||
int gfd, ghost_flags, ret = -1;
|
int gfd, ghost_flags, ret = -1;
|
||||||
@ -423,8 +417,8 @@ static int dump_ghost_remap(char *path, const struct stat *st,
|
|||||||
|
|
||||||
pr_info("Dumping ghost file for fd %d id %#x\n", lfd, id);
|
pr_info("Dumping ghost file for fd %d id %#x\n", lfd, id);
|
||||||
|
|
||||||
if (st->st_size > MAX_GHOST_FILE_SIZE) {
|
if (st->st_size > opts.ghost_limit) {
|
||||||
pr_err("Can't dump ghost file %s of %"PRIu64" size\n",
|
pr_err("Can't dump ghost file %s of %"PRIu64" size, increase limit\n",
|
||||||
path, st->st_size);
|
path, st->st_size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ struct cg_root_opt {
|
|||||||
|
|
||||||
#define CG_MODE_DEFAULT (CG_MODE_SOFT)
|
#define CG_MODE_DEFAULT (CG_MODE_SOFT)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ghost file size we allow to carry by default.
|
||||||
|
*/
|
||||||
|
#define DEFAULT_GHOST_LIMIT (1 << 20)
|
||||||
|
|
||||||
struct cr_options {
|
struct cr_options {
|
||||||
int final_state;
|
int final_state;
|
||||||
char *show_dump_file;
|
char *show_dump_file;
|
||||||
@ -81,6 +86,7 @@ struct cr_options {
|
|||||||
bool enable_external_masters;
|
bool enable_external_masters;
|
||||||
bool aufs; /* auto-deteced, not via cli */
|
bool aufs; /* auto-deteced, not via cli */
|
||||||
bool overlayfs;
|
bool overlayfs;
|
||||||
|
size_t ghost_limit;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct cr_options opts;
|
extern struct cr_options opts;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user