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

25 Commits

Author SHA1 Message Date
Andrew Vagin
e248e65cc9 locks: fix up a device returned by stat() for btrfs (v4)
BTRFS returns subvolume dev-id instead of superblock dev-id,
in such case return device obtained from mountinfo (ie subvolume0).

v2: fix up devices only for btrfs files.
v3: use phys_stat_dev_match instead of phys_stat_resolve_dev
v4: fix cosmetic whims

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-05 16:02:40 +04:00
Pavel Emelyanov
57c7826a8e locks: Check for --file-locks option when real locks are found
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 20:20:47 +04:00
Pavel Emelyanov
b6e3223a1e locks: Don't skip out-of-tree flocks
These guys may have pids that are not met in pstree.
This is not the reason for skipping those, try to
resolve flocks anyway.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:54:28 +04:00
Pavel Emelyanov
0a11aa1ff9 locks: When checking for lock being ours handle mand-locks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:45 +04:00
Pavel Emelyanov
180005645c locks: Split lock-in-fd check in a helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:43 +04:00
Pavel Emelyanov
53537f52c8 locks: Don't dump locks in per-task manner (v3)
We have a problem with file locks (bug #2512) -- the /proc/locks
file shows the ID of lock creator, not the owner. Thus, if the
creator died, but holder is still alive, criu fails to dump the
lock held by latter task.

The proposal is to find who _might_ hold the lock by checking
for dev:inode pairs on lock vs file descriptors being dumped.
If the creator of the lock is still alive, then he will take
the priority.

One thing to note about flocks -- these belong to file entries,
not to tasks. Thus, when we meet one, we should check whether
the flock is really held by task's FD by trying to set yet
another one. In case of success -- lock really belongs to fd
we dump, in case it doesn't trylock should fail.

At the very end -- walk the list of locks and dump them all at
once, which is possible by merge of per-task file-locks images
into one global one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:46 +04:00
Pavel Emelyanov
efac9ed8b3 locks: Parse lock type earlier
Same reason as for previous patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:39 +04:00
Pavel Emelyanov
0095b40a29 locks: Parse lock kind earlier
Currently we keep the lock type (posix/flock) till the
time we dump it, then "decode" it into binary value.
I will need the easy-to-check one early, so parse the
kind in proc_parse.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:39:09 +04:00
Pavel Emelyanov
8ef0f6b7e6 locks: Remove unused arg from dump_one_file_lock
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:38:52 +04:00
Pavel Emelyanov
1514284d84 locks: Fix restore from v1.2 images
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-20 17:38:36 +04:00
Pavel Emelyanov
a40ab4e372 locks: Dump virtual pid of a lock owner
If we're dumping namespaced tasks, the fl_owner value we see
are the real pids of tasks, while we need virtual ones.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 15:48:31 +04:00
Pavel Emelyanov
7960379f71 flock: Merge all file lock entries into single image file
They are now in per-pid images, but every entry contains a
pid to which it "belongs". This belonging is fake -- it's
just a pid of a task who placed the lock, while locks really
belong to files. We even have a bug when task that locked
a file exited and "delegated" the lock to its child.

This images merge reduces the amount of image files criu
generates and may simplify the fix of mentioned above issue.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:38:49 +04:00
Pavel Emelyanov
1e3ae669fa flock: Don't hide image read error on flocks restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:38:16 +04:00
Cyrill Gorcunov
1153f225ff image: Add O_OPT when trying to open optional image files
During the time some files become obsolete and might be missing
in checkpoint image set, but to keep backward compatibility we
still trying to open them, which might print out error like

 | Unable to open 'path-to-file'

and confuse a reader why criu prints error but continue working.

To eliminate this problem O_OPT flag has been introduced in
commit 16b5692061e2, which suppress error message priting
if the flag is set.

Now start using O_OPT in the following functions

 - open_irmap_cache: irmap cache is relatively new optional feature

 - prepare_rlimits, open_signal_image, restore_file_locks,
   prepare_fd_pid, prepare_mm_pid, collect_image: all these
   helpers are trying to open image files which can be missing.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-03-17 14:21:21 +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
2082e8faf0 crtools: don't include crtools.h in other headers
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:38 +04:00
Andrey Vagin
1300cf4915 crtools: move all stuff about fdset in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 15:24:48 +04:00
Kir Kolyshkin
d90d4b1b88 Fix typos in log messages
Someone has to do it, right?..

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:25 +04:00
Pavel Emelyanov
5cae819d8c img: Get rid of open_image_ro helper
O_RSTR flag should be used instead for regular open_image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:22:21 +04:00
Pavel Emelyanov
fb9b0f500a parasite: Use struct pid on parasite_ctl
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:56:48 +04:00
Pavel Emelyanov
c77e52992b locks: Move dump_task_file_locks into file-locks.c
Make all locks code be in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-08 02:58:10 +04:00
Alexander Kartashov
4f7161dd4c file-lock.c: generalized format strings
This patch fixes format strings in newly added code.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:37 +04:00
Qiang Huang
4bf96b6680 crtools: restore flock&posix file locks
According to the file lock information from the image, we recall
flock or fcntl with proper parameters, so we can rehold the file
locks as we were dumped.
We only support flock and posix file locks so far.

Changelog since the initial version:
a. Use prepare_file_locks instead of restore function directly.
b. Fix some bugs.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:43 +04:00
Qiang Huang
95801808aa crtools: dump flock&posix file locks
Dump file locks' necessary entries to the image, we only support flock and
posix file lock right now.

Changelog since the initial version:
We got file lock info from global list, so the dump_task_file_locks
can be much simpler.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:41 +04:00
Qiang Huang
286801d4c1 crtools: collect and check file locks
We collect all file locks to a golbal list, so we can use them easily
in dump_one_task. For optimizaton, we only collect file locks hold by
tasks in the pstree.

Thanks to the ptrace-seize machanism, we can aviod the blocked file lock
issue, makes the work simpler.

Right now, the check handles only one situation:
-- Dumping tasks with file locks hold without the -l option.

This covers for the most part. But we still need some more work to make
it perfect robust in the future.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:07 +04:00