2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

111 Commits

Author SHA1 Message Date
Pavel Emelyanov
db33a144d2 mount: Fix the mi we print info about
The t and m match there, but strictly speaking we're working on the m.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:38 +04:00
Pavel Emelyanov
dcd680726c mount: Read mount images eary
We'll have to pre-mount some, so move the read_mnt_ns_img
before pivot_root call.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:37 +04:00
Pavel Emelyanov
70eb3cc4f3 mount: Make images reader return the list of mounts
To carry them with us in a local variable (next patches), not
the global mntinfo one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:35 +04:00
Pavel Emelyanov
cb4e125bd0 mount: Split reading images and populating the ns
We will need images at hands while we do pivot_root (see further patches),
so prepare the images reading routine.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-26 11:07:34 +04:00
Kir Kolyshkin
8692291d42 tab-at-eol cleanup
Remove whitespace at EOL (found by git grep '	$')
(the character before $ is real tab, typed in shell using Ctrl+V Tab)

To people using vim, I'd suggest adding the following code to ~/.vimrc:

let c_space_errors = 1
highlight FormatError ctermbg=darkred guibg=darkred
match FormatError /\s\+$\|\ \+\t\|\%80v.\|\ \{8\}/

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 16:09:08 +04:00
Kir Kolyshkin
e2a0be63d4 mnt_tree_for_each_reverse(): init a variable
A warning catched by clang:

> > mount.c:869:71: error: variable 'progress' is uninitialized when used here
> >       [-Werror,-Wuninitialized]
> >   ...prev, MNT_WALK_NONE, fn, (struct list_head *) NULL, progress);
> >                                                          ^~~~~~~~
> > mount.c:802:4: note: expanded from macro 'MNT_TREE_WALK'
> >                         _prgs++;
> > \
> >                         ^
> > mount.c:867:14: note: initialize the variable 'progress' to silence this
> > warning
> >         int progress;
> >                     ^
> >                      = 0
> > 1 error generated.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-20 11:26:12 +04:00
Pavel Emelyanov
ae98ef6ae0 mount: Factor out mount tree build for NEWNS and non-NS cases
We anyway build the tree, in the NS case -- few calls later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:19:48 +04:00
Pavel Emelyanov
bd69c6173d mount: Free old mounts for pivot-root case
If we specify a new root for restore old mounts get destroyed
with pivot_root + umount calls, tree umount is omitted. In this
case mi-s are leaked.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:13:31 +04:00
Pavel Emelyanov
f35d7cd7fe mount: Don't validate mounts read from proc on restore
Validation means -- check chat we can _restore_ this tree.
Those read from proc can be in any state -- we're going to
umount them (can do anything) and do path resolution (work
for any knots as well).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 16:01:14 +04:00
Kir Kolyshkin
d64d68d66c whitespace-at-eol cleanup
Remove whitespace at EOL (found by git grep ' $')

To people using vim, I'd suggest adding the following code to ~/.vimrc:

let c_space_errors = 1
highlight FormatError ctermbg=darkred guibg=darkred
match FormatError /\s\+$\|\ \+\t\|\%80v.\|\ \{8\}/

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 10:00:45 +04:00
Pavel Emelyanov
873d1dac9d unix: Move odev to kdev conversion into phys_stat_dev_match
This is more correct, as if st_dev == phys_dev check fails
we have to treat phys_dev as kdev for path resolve device
comparison.

Howver, this is not the case for non-btrfs FSs, and for the
latter one doesn't change anything as it uses anon devices
which are equal for kdev and odev cases.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 08:44:15 +04:00
Pavel Emelyanov
0d8f688e5c mount: Fixup phys/virt devices dumping for ghost files
When dumping a ghost file we put real device in its header,
not the (btrfs) virtual one. This is done since we put real
devices into fsnotify images (we get them from proc). That
said on fsnotify ghost restore we don't need to do path
resolution, just devices compare.

And one more thing. When dumping device for ghost file for
_non_ btrfs case we have to convert stat dev_t into kernel
dev_t as all the other places in criu manipulate the latter
ones.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 08:18:21 +04:00
Andrew Vagin
fe764c2c14 mount: add btrfs into fstypes
It's used by phys_stat_resolve_dev (broken by c5d2386a)

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-12 01:07:12 +04:00
Pavel Emelyanov
976265a078 mount: Add comments about mount list and tree
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:34:41 +04:00
Pavel Emelyanov
0efaf212b2 mount: Clean code a bit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:19:40 +04:00
Pavel Emelyanov
c5d2386a2f btrfs: Remove volume parsing code
Now we have more robust and fs agnostic path-resolution
engine for resolving dev conflicts.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 17:18:59 +04:00
Cyrill Gorcunov
1ba08ca664 mount: Extend phys_stat_dev_match to use path resolving instead of btrfs engine
Instead of scanning btrfs subvolumes (which can be even unaccessbile
if mount point lays on directory instead of subvolume itself) we use
path resolving feature here -- once we need to figure out if some
device number need to be altered up to mount point (as we know stat()
called on subvolume returns st_dev for subvolume itself, but not
one that associated with a superblock and shown in /proc/self/mountinfo
output).

This as well implies that we need to check if device number for ghost
files are to be updated to match mountinfo, thus we use phys_stat_resolve_dev
helper here.

After this patch the previously merged btrfs engine is no longer needed
(at least it seems so) and can be dropped.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:22 +04:00
Cyrill Gorcunov
5372e3910c mount: btrfs -- Introduce phys_stat_resolve_dev helper (v2)
This routine is aimed to find a mount point on which
the path passed as argument is laying on. We walk over
all mount points and see which one is matching.

Once found (in worst case it will be a root mount point
so function is never failing) we're checking if this is
btrfs and then return subvolume0 device id.

See commit 921cf873f30ad35df2b65602ed402f94695a6eb3
for details what the hell we're doing here.

v2: rewrite mount_resolve_path w/o recursion

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:21 +04:00
Cyrill Gorcunov
cf1ce5f817 mount: Build mount tree on dump restore early, if needed
For paths resolution we will need mount tree to be parsed
and built, but it's not that simple -- the current code
implies that once parsed the tree must not be re-parsed
again, so we pass @parse argument from a caller: if a task
we're restoring do not use mount namespace, we should parse
mount tree early, otherwise defer this action until mount
tree is read from the image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:19 +04:00
Cyrill Gorcunov
8e0c1037f3 mount: Introduce @mntinfo_root variable
This variable should be carrying root of a parsed
mount tree pointed by @mntinfo. Thus if @mntinfo
get destroyed the @mntinfo_root should be set to NULL.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-11 16:05:18 +04:00
Pavel Emelyanov
3708ecb499 mount: Introduce generic FSs parsing callback
And make use of it in for btrfs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
2013-12-04 20:03:17 +04:00
Pavel Emelyanov
b6e2dfd2de mount: Prepare fstypes to contain more unsupported FSs
We will need to parse btrfs stuff, but this one is not
in the supported list yet (as it's bound to hardware).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
2013-12-04 20:03:15 +04:00
Cyrill Gorcunov
e54ad19a06 mount: Add phys_stat_dev_match helper
This helper serves to hide fs specifics (in particular
btrfs) thus the caller won't need the details.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 19:23:32 +04:00
Cyrill Gorcunov
eeb21b8a34 proc_parse: Remember a type of FS provided by a kernel
We will need it for btrfs handling. Also print out the
FS type for easier debug

 | (00.003545)     type unsupported (cgroup) source cgroup 1c / @ /sys/fs/cgroup/blkio flags 30000e options blkio,
 | (00.003558)     type unsupported (cgroup) source cgroup 1d / @ /sys/fs/cgroup/perf_event flags 30000e options perf_event,
 | (00.003571)     type unsupported (cgroup) source cgroup 1e / @ /sys/fs/cgroup/hugetlb flags 30000e options hugetlb,
 | (00.003584)     type unsupported (ext4) source /dev/sda2 800002 / @ / flags 300000 options data=ordered,
 | (00.003670)     type tmpfs (tmpfs) source tmpfs 20 / @ /tmp flags 100000 options
 | (00.003696)     type unsupported (mqueue) source mqueue d / @ /dev/mqueue flags 300000 options

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-04 18:18:21 +04:00
Cyrill Gorcunov
a1fd4119bc mount: Print device obtained from stat() call
For debug purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 22:50:40 +04:00
Cyrill Gorcunov
58c4631ae7 mount: Drop useless NULL assignment
We allocate mount_info with xzalloc, no need for
additional NULL assignment.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-12-03 22:50:00 +04:00
Cyrill Gorcunov
f4e40ef7e2 mount: Use is_root_mount helper instead of strcmp
It's designed specificly for that.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-28 15:46:00 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
9826d2dd04 crtools: don't include pstree.h in namespaces.h
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:39:50 +04:00
Pavel Emelyanov
b978c6f873 util: Introduce buffer size for carrying /proc/self/fd/N path
There's ... a number of places where we want to do something
with /proc/self/fd/%d path. Each time we guess buffer size
that is enough for this. Make standard constant for this and
save some space on stack and drop args for some functions.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-15 13:59:59 +04:00
Cyrill Gorcunov
6695ff7259 mount: Add missing \Newline
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-09 17:17:58 +04:00
Andrey Vagin
b895c73c82 mntns: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:11:09 +04:00
Pavel Emelyanov
d135ad3538 mnt: Collect mntns root from criu, in case we don't dump mount namespace
In case criu and dumpee live in the same mount namespace there's no
need in getting ns' root from init task. We can get it from criu and
(!) void the root == "/" check, required for namespace case.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 21:20:41 +04:00
Andrey Vagin
a46248c80b mount: don't close a namespace descriptor two times
CID null (#1 of 1): Double close (USE_AFTER_FREE)
10. double_close: Calling "restore_ns(int, struct ns_desc *)" closes
handle "ns_old" which has already been closed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-03 13:59:01 +04:00
Andrey Vagin
37ffc41863 mount: prevent dumping mounts, if they can't be restored (v2)
Currently we check that all shared mounts have identical set of
children and that Each non-root mount has a proper root mount.

v2: check that nobody is overmounted
    check a tree before trying to restore it.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:02:24 +04:00
Andrey Vagin
6244f943bf mounts: handle non-root bind-mounts
A non-root mount is bind-mounted from a proper root mount.

Non-root mount without root mount is not supported yet

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:33 +04:00
Andrey Vagin
f05beddca3 mounts: handle shared and slave mounts (v3)
The idea is simple. If a mount can't be mounted now, we will try to
mount it later.

v2: don't wait slaves, they are unmounted anyway
v3: add a comment in do_bind_mount to explain restoring of shared groups
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:32 +04:00
Andrey Vagin
2eedcaabe5 mount: restore shared, slave, private properties.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:31 +04:00
Andrey Vagin
02d8a72bb5 mounts: find mounts, which are propagated from a current one (v2)
A few sentences, which are required for understanging this patch

2a) A shared mount can be replicated to as many mountpoints and all the
replicas continue to be exactly same.
2b) A slave mount is like a shared mount except that mount and umount
events only propagate towards it.
2c) A private mount does not forward or receive propagation.

All rules is there Documentation/filesystems/sharedsubtree.txt

If it's a first mount in a group, all group members should be
bind-mounted from this one.

Each mount propagates to all members of parent's group. The group can
contains a few slaves.

Mounts, which have propagated to slaves, are unmounted, because we can't
be sure, that they propagated in real life. For example:

mount --bind --make-slave /share /slave1
mount --bind --make-slave /share /slave2
mount /share/test
umount /slave2/test
mount --make-share /slave1/test
mount --bind --make-share /slave1/test /slave2/test

41 40 0:33 / /share rw,relatime shared:28 - tmpfs xxx rw
42 40 0:33 / /slave1 rw,relatime master:28 - tmpfs xxx rw
43 40 0:33 / /slave2 rw,relatime master:28 - tmpfs xxx rw
44 41 0:34 / /share/test rw,relatime shared:29 - tmpfs xxx rw
46 42 0:34 / /slave1/test rw,relatime shared:30 master:29 - tmpfs xxx rw
45 43 0:34 / /slave2/test rw,relatime shared:30 master:29 - tmpfs xxx rw

/slave1/test and /slave2/test depend on each other and minimum one of them
doesn't propagate from /share/test

v2: use false and true for bool

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:30 +04:00
Andrey Vagin
e01072c05a mounts: if a mount can't be mounted, it is queued in postpone list (v4)
Try to restore mounts while a postpone list isn't empty and check
that each iteration has some progress, otherwice it will fails for
preventing infinite loops

v2: rework logic about postpone list
    add more comments

v3: one more attempt to make it more readable
v4: Here is a master class from Pavel how to write self-documented code.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:28 +04:00
Andrey Vagin
2b4a8d29d6 mount: save group and master in image file (v2)
They are required for restoring shared and slave mounts

v2: use the same names of variables in image and in code
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:27 +04:00
Andrey Vagin
d00e7c6f88 mount: link dependent mounts (v3)
All shared mounts from one group are connected to circular list.
All slave are added into the proper master list.

v2: change variable name and fix a bug about adding shared mounts in a
circular list.
v3: handle errors of collect_shared

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-30 15:01:26 +04:00
Pavel Emelyanov
b18fb09eb9 show: Replace one-line show_foo calls with args array
We have generic do_pb_show() call and tons of show_foo
routines, that just call one with proper args. Compact
the code by putting the args into array and calling
the do_pb_show() in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-24 04:00:32 +04:00
Pavel Emelyanov
84737e2796 build: Generate most of the pb-desc automatically
These contain linkage between number, data type and routines
for pb messages we write/read to/from image files. Most of them
have simple number-type-routines mapping, so introduce a generating
script for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-23 21:47:31 +04:00
Andrey Vagin
3ea73d7f9b mount: move is_root, is_root, fsroot_mounted to the top of the file
They are trivial and these functions will be used in many places

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-09 15:44:35 +04:00
Andrey Vagin
b2504e0763 mounts: enumirate mounts bellow specified element
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-09 15:43:54 +04:00
Pavel Emelyanov
9cef1a00ce mount: Factor out detached mountpoint opening
The difficulty is that this code is required in both -- pie
and non-pie contexts.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-29 13:12:00 +04:00
Andrey Vagin
65d3545945 mount: allow to dump content even if a part of fs is overmounted (v3)
for that the mount point is bind-mounted in a temporary place.

v2: * check, that the fs you get access to at the end is _really_ the
      one you wanted to
    * use switch_ns/restore_ns helpers
v3: reuse code of __open_mountpoint and a few small cleanups

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-05 18:06:36 +04:00
Andrey Vagin
2d631b4562 mount: build tree of mounts before dumping them
When CRIU wants to dump content, it checks that nothing is overmounted.
The list of children for such mounts must be empty, but these lists are
filled during constructing a tree of mounts.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-08-05 18:05:56 +04:00
Andrey Vagin
5eb254b016 tmpfs: use the --one-file-system option for dumping tmpfs with help tar
Actully for dumping tmpfs it should be remounted to somewhere else to
avoid overmounts.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-09 20:33:33 +04:00