• Pavel Tikhomirov's avatar
    fsnotify: skip non-direcory mounts · 4f3927a6
    Pavel Tikhomirov authored
    To restore fsnotify's watches on files we need to find paths for each
    of them using handle we have in /proc/<pid>/fdinfo/<fsnotifyfd>.
    These handle is valid to open the file with open_by_handle_at if
    you have mount fd where the file lays. So we try open_by_handle_at
    for all possible mount fds we have.
    
    But we can not do so for 'file' bind-mounts, as the way we open
    mount fd opens file instead and can hang on fifos or fail on sockets.
    (see check_open_handle->open_handle->open_mount code path, imagine
    lookup_mnt_sdev() found 'file' bind-mount, open_mount() failed(hanged)
    in __open_mountpoint() and if irmap_lookup() also was not successful the
    whole dump fails too)
    
    So if we have file bindmount of fifo file, and we restore some
    inotify on other file on other mount with same s_dev, we hang forever
    on open.
    
    So just skip non-directory mounts from inotify search we will find
    path for them on other mount(e.g. non-bindmount) with same s_dev.
    
    v2: remove isdir hashing, improve commit message
    v3: make lookup_mnt_sdev handle only nondir mounts, add comment,
    move more expensive notdir_mountpoint check after s_dev
    v4: inverse notdir_mountpoint to be mnt_is_dir, now on error
    in mnt_is_dir mount is also skipped
    Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
    Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
    4f3927a6
fsnotify.c 22 KB