• NeilBrown's avatar
    autofs4: avoid taking fs_lock during rcu-walk · 4d885f90
    NeilBrown authored
    ->fs_lock protects AUTOFS_INF_EXPIRING.  We need to be sure that once
    the flag is set, no new references beneath the dentry are taken.  So
    rcu-walk currently needs to take fs_lock before checking the flag.  This
    hurts performance.
    
    Change the expiry to a two-stage process.  First set AUTOFS_INF_NO_RCU
    which forces any path walk into ref-walk mode, then drop the lock and
    call synchronize_rcu().  Once that returns we can be sure no rcu-walk is
    active beneath the dentry and we can check reference counts again.
    
    Now during an RCU-walk we can test AUTOFS_INF_EXPIRING without taking
    the lock as along as we test AUTOFS_INF_NO_RCU too.  If either are set,
    we must abort the RCU-walk If neither are set, we know that refcounts
    will be tested again after we finish the RCU-walk so we are safe to
    continue.
    
    ->fs_lock is still taken in d_manage() to check for a non-trap
    directory.  That will be resolved in the next patch.
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Reviewed-by: default avatarIan Kent <raven@themaw.net>
    Tested-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>
    4d885f90
expire.c 14.6 KB