Commit fc84aa58 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

flock: blocked processes are not interesting for us (v2)

All out processes are stopped in a moment, when file locks are
collected, so they can't to wait any locks.

Here is a proof of this theory:
[root@avagin-fc19-cr ~]# flock xxx sleep 1000 &
[1] 23278
[root@avagin-fc19-cr ~]# flock xxx sleep 1000 &
[2] 23280
[root@avagin-fc19-cr ~]# cat /proc/locks
1: FLOCK  ADVISORY  WRITE 23278 08:03:280001 0 EOF
1: -> FLOCK  ADVISORY  WRITE 23280 08:03:280001 0 EOF
[root@avagin-fc19-cr ~]# gdb -p 23280
(gdb) ^Z
[3]+  Stopped                 gdb -p 23280
[root@avagin-fc19-cr ~]# cat /proc/locks
1: FLOCK  ADVISORY  WRITE 23278 08:03:280001 0 EOF

Currently criu can dump nothing, if we have one process which is
waiting a lock. I don't see any reason to do this.

v2: typo fix

Cc: Qiang Huang <h.huangqiang@huawei.com>
Reported-by: Mr Jenkins
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 391269b5
......@@ -1536,6 +1536,12 @@ int parse_file_locks(void)
goto err;
}
pr_info("lockinfo: %lld:%d %x %d %02x:%02x:%ld %lld %s\n",
fl->fl_id, fl->fl_kind, fl->fl_ltype,
fl->fl_owner, fl->maj, fl->min, fl->i_no,
fl->start, fl->end);
if (fl->fl_kind == FL_UNKNOWN) {
pr_err("Unknown file lock!\n");
ret = -1;
......@@ -1543,35 +1549,25 @@ int parse_file_locks(void)
goto err;
}
if ((fl->fl_kind == FL_POSIX) &&
!pid_in_pstree(fl->fl_owner)) {
if (is_blocked) {
/*
* We only care about tasks which are taken
* into dump, so we only collect file locks
* belong to these tasks.
* All target processes are stopped in this moment and
* can't wait any locks.
*/
pr_debug("Skip blocked processes\n");
xfree(fl);
continue;
}
pr_info("lockinfo: %lld:%d %x %d %02x:%02x:%ld %lld %s\n",
fl->fl_id, fl->fl_kind, fl->fl_ltype,
fl->fl_owner, fl->maj, fl->min, fl->i_no,
fl->start, fl->end);
if (is_blocked) {
if ((fl->fl_kind == FL_POSIX) &&
!pid_in_pstree(fl->fl_owner)) {
/*
* Here the task is in the pstree.
* If it is blocked on a flock, when we try to
* ptrace-seize it, the kernel will unblock task
* from flock and will stop it in another place.
* So in dumping, a blocked file lock should never
* be here.
* We only care about tasks which are taken
* into dump, so we only collect file locks
* belong to these tasks.
*/
pr_perror("We have a blocked file lock!");
ret = -1;
xfree(fl);
goto err;
continue;
}
list_add_tail(&fl->list, &file_lock_list);
......
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