• J
    fs/dcache: Avoid a try_lock loop in shrink_dentry_list() · 8f04da2a
    John Ogness 提交于
    shrink_dentry_list() holds dentry->d_lock and needs to acquire
    dentry->d_inode->i_lock. This cannot be done with a spin_lock()
    operation because it's the reverse of the regular lock order.
    To avoid ABBA deadlocks it is done with a trylock loop.
    
    Trylock loops are problematic in two scenarios:
    
      1) PREEMPT_RT converts spinlocks to 'sleeping' spinlocks, which are
         preemptible. As a consequence the i_lock holder can be preempted
         by a higher priority task. If that task executes the trylock loop
         it will do so forever and live lock.
    
      2) In virtual machines trylock loops are problematic as well. The
         VCPU on which the i_lock holder runs can be scheduled out and a
         task on a different VCPU can loop for a whole time slice. In the
         worst case this can lead to starvation. Commits 47be6184
         ("fs/dcache.c: avoid soft-lockup in dput()") and 046b961b
         ("shrink_dentry_list(): take parent's d_lock earlier") are
         addressing exactly those symptoms.
    
    Avoid the trylock loop by using dentry_kill(). When pruning ancestors,
    the same code applies that is used to kill a dentry in dput(). This
    also has the benefit that the locking order is now the same. First
    the inode is locked, then the parent.
    Signed-off-by: NJohn Ogness <john.ogness@linutronix.de>
    Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
    8f04da2a
dcache.c 95.9 KB