[CRIU] [PATCH 7/9] inotify: Check if the watched target is present in ghost files list

Cyrill Gorcunov gorcunov at openvz.org
Fri Nov 30 10:42:40 EST 2012


The watch target might be a deleted file. In this case we can't
re-create it on restore procedure (currently we use a file handle
to open as a target).

As example, a scenario

 fd = inotify_init1()
 wd = open(path)
 inotify_add_watch(path)
 unlink(path)
 ... checkpoint ...

here we have a @path which is unlinked but still
present in inotify watch list because inode is not
yet freed. And if the program is killed after checkpoint
the last reference to a path get eliminated and inode
get freed from the kernel memory.

Thus any furher attempts to open the path via file
handle (note that file handle can't be used to create
new file, the kernel doesn't permit that) will simply
fail.

So instead we simply try to figure out if the path we're
trying to watch exist in ghost files list and if so we
do mark such fact in image file. On restore we simply
reuse the path generated for ghost as our target and
unlink it once get passed to inotify_add_watch. Which
is of course is a treat for a next patch.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 inotify.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-inotify-Check-if-the-watched-target-is-present-in-gh.patch
Type: text/x-patch
Size: 1069 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20121130/fa90ca02/attachment.bin>


More information about the CRIU mailing list