• Cyrill Gorcunov's avatar
    inotify: Use ghost files if the watchee is a deleted file, v2 · b146fe4a
    Cyrill Gorcunov authored
    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.
    
    v2 [by xemul@]:
     - gather reference to ghost file remap early
    Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
    b146fe4a
inotify.c 5.98 KB