[CRIU] [PATCH 6/7] inotify: Use ghost files if the watchee is a deleted file

Cyrill Gorcunov gorcunov at openvz.org
Mon Dec 3 10:27:03 EST 2012


The watch target might be a deleted file. In this case we can't
re-create it on restore procedure.

A typical 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 if plain opening via file handle failed we assume that at least
the file might be in our ghost files list (we're optimists, right?)
and if we successed we simply use a path generated by ghost file
engine for us.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 inotify.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-inotify-Use-ghost-files-if-the-watchee-is-a-deleted-.patch
Type: text/x-patch
Size: 1508 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20121203/f98aa973/attachment.bin>


More information about the CRIU mailing list