[CRIU] [PATCH 00/11] Add support for flock&posix file locks' dump/restore

Qiang Huang h.huangqiang at huawei.com
Thu Jan 17 03:09:26 EST 2013


It's hard to do it perfect, because we can not guarantee that once we
terminated the processes we've dumped and the locks would be dropped too.
We can't deal issues like tasks beyond pstree would use flocks hold by
dumped tasks yet.

Right now we assume that all flock users are all taken into dump, so we
only did simple check:
If we didn't set handle file locks option, then any file locks hold by
tasks in our pstree is not allowed.

We might have to do the check that file locks dump/restore would only be
used by container dumping in the future.

Anyway, thanks to the ptrace-seize machanism, the kernel will unblock
task from flock and will stop it in another place when we ptrace-seize
it. So we can aviod the blocked file lock problems, makes the work
simpler.

This work is based on Zheng Gu's first attempt on:
http://lists.openvz.org/pipermail/criu/2012-November/005646.html

Changelog since the initial version:
a. Collect all file lock info before dump.
b. Parse /proc/locks in proc_parse.c.
c. Check the file lock option when some tasks hold file locks.
d. Add zdtm test cases for file lock.
e. Code organization optimization.
f. Some bugfix, pr_info and comments.

Qiang Huang (11):
  crtools: Add --file-locks option
  protobuf: add a new description for saving file-lock
  crtools: add a callback to show filelocks-%d.img
  crtools: add image contents for filelocks
  pstree: add a function to check if a task is in pstree
  crtools: collect and check file locks
  crtools: dump flock&posix file locks
  crtools: restore flock&posix file locks
  doc: update the manpage document for file lock c/r
  zdtm: add posix file lock's test case
  zdtm: add flock file lock's test case

 Documentation/crtools.txt            |    5 +
 Makefile                             |    1 +
 cr-dump.c                            |  177 +++++++++++++++++++++++++++++++++
 cr-restore.c                         |    4 +
 cr-show.c                            |    5 +
 crtools.c                            |    7 +-
 file-lock.c                          |  141 ++++++++++++++++++++++++++
 image.c                              |    1 +
 include/crtools.h                    |    3 +
 include/file-lock.h                  |   53 ++++++++++
 include/image.h                      |    1 +
 include/proc_parse.h                 |    1 +
 include/protobuf.h                   |    1 +
 include/pstree.h                     |    1 +
 proc_parse.c                         |   95 ++++++++++++++++++
 protobuf.c                           |    2 +
 protobuf/Makefile                    |    1 +
 protobuf/file-lock.proto             |    8 ++
 pstree.c                             |   12 +++
 test/zdtm.sh                         |   12 ++-
 test/zdtm/live/static/Makefile       |    2 +
 test/zdtm/live/static/file_locks00.c |  179 ++++++++++++++++++++++++++++++++++
 test/zdtm/live/static/file_locks01.c |  141 ++++++++++++++++++++++++++
 23 files changed, 851 insertions(+), 2 deletions(-)
 create mode 100644 file-lock.c
 create mode 100644 include/file-lock.h
 create mode 100644 protobuf/file-lock.proto
 create mode 100644 test/zdtm/live/static/file_locks00.c
 create mode 100644 test/zdtm/live/static/file_locks01.c




More information about the CRIU mailing list