• Dave Chinner's avatar
    fs: Lock the inode LRU list separately · 02afc410
    Dave Chinner authored
    Introduce the inode_lru_lock to protect the inode_lru list. This
    lock is nested inside the inode->i_lock to allow the inode to be
    added to the LRU list in iput_final without needing to deal with
    lock inversions. This keeps iput_final() clean and neat.
    
    Further, where marking the inode I_FREEING and removing it from the
    LRU, move the LRU list manipulation within the inode->i_lock to keep
    the list manipulation consistent with iput_final. This also means
    that most of the open coded LRU list removal + unused inode
    accounting can now use the inode_lru_list_del() wrappers which
    cleans the code up further.
    
    However, this locking change means what the LRU traversal in
    prune_icache() inverts this lock ordering and needs to use trylock
    semantics on the inode->i_lock to avoid deadlocking. In these cases,
    if we fail to lock the inode we move it to the back of the LRU to
    prevent spinning on it.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
    02afc410
inode.c 46.6 KB