• Andrew Morton's avatar
    [PATCH] devfs deadlock fix · 1cf2ec10
    Andrew Morton authored
    From: Andrey Borzenkov <arvidjaar@mail.ru>
    
    I finally hit a painfully trivial way to reproduce another long standing devfs
    problem - deadlock between devfs_lookup and devfs_d_revalidate_wait. When
    devfs_lookup releases directory i_sem devfs_d_revalidate_wait grabs it (it
    happens not for every path) and goes to wait to be waked up. Unfortunately,
    devfs_lookup attempts to acquire directory i_sem before ever waking it up ...
    
    To reproduce (2.5.74 UP or SMP - does not matter, single CPU system)
    
    ls /dev/foo & rm -f /dev/foo &
    
    or possibly in a loop but then it easily fills up process table. In my case it
    hangs 100% reliably - on 2.5 OR 2.4.
    
    The current fix is to move re-acquire of i_sem after all
    devfs_d_revalidate_wait waiters have been waked up.  Much better fix would be
    to ensure that ->d_revalidate either is always called under i_sem or always
    without.  But that means the very heart of VFS and I do not dare to touch it.
    
    The fix has been tested on 2.4 (and is part of unofficial Mandrake Club
    kernel); I expected the same bug is in 2.5; I just was stupid not seeing the
    way to reproduce it before.
    1cf2ec10
base.c 92 KB