[CRIU] [PATCH 6/7] inotify: Use ghost files if the watchee is a deleted file
Pavel Emelyanov
xemul at parallels.com
Mon Dec 3 13:55:55 EST 2012
On 12/03/2012 07:27 PM, Cyrill Gorcunov wrote:
>
> 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(-)
>
> + gf = lookup_ghost_file_st(kdev_to_odev(iwe->s_dev), iwe->i_ino);
Why kdev_to_odev? The device should be in one format on both sides.
More information about the CRIU
mailing list