Skip to content
  • Ian Kent's avatar
    autofs4: use look aside list for lookups · 25767378
    Ian Kent authored
    
    
    A while ago a patch to resolve a deadlock during directory creation was
    merged.  This delayed the hashing of lookup dentrys until the ->mkdir()
    (or ->symlink()) operation completed to ensure we always went through
    ->lookup() instead of also having processes go through ->revalidate() so
    our VFS locking remained consistent.
    
    Now we are seeing a couple of side affects of that change in situations
    with heavy mount activity.
    
    Two cases have been identified:
    
    1) When a mount request is triggered, due to the delayed hashing, the
       directory created by user space for the mount point doesn't have the
       DCACHE_AUTOFS_PENDING flag set.  In the case of an autofs multi-mount
       where a tree of mount point directories are created this can lead to
       the path walk continuing rather than the dentry being sent to the wait
       queue to wait for request completion.  This is because, if the pending
       flag isn't set, the criteria for deciding this is a mount in progress
       fails to hold, namely that the dentry is not a mount point and has no
       subdirectories.
    
    2) A mount request dentry is initially created negative and unhashed.
       It remains this way until the ->mkdir() callback completes.  Since it
       is unhashed a fresh dentry is used when the user space mount request
       creates the mount point directory.  This leaves the original dentry
       negative and unhashed.  But revalidate has no way to tell the VFS that
       the dentry has changed, other than to force another ->lookup() by
       returning false, which is at best wastefull and at worst not possible.
       This results in an -ENOENT return from the original path walk when in
       fact the mount succeeded.
    
    To resolve this we need to ensure that the same dentry is used in all
    calls to ->lookup() during the course of a mount request.  This patch
    achieves that by adding the initial dentry to a look aside list and
    removes it at ->mkdir() or ->symlink() completion (or when the dentry is
    released), since these are the only create operations autofs4 supports.
    
    Signed-off-by: default avatarIan Kent <raven@themaw.net>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    25767378