• J. Bruce Fields's avatar
    vfs: take i_mutex on renamed file · 6cedba89
    J. Bruce Fields authored
    A read delegation is used by NFSv4 as a guarantee that a client can
    perform local read opens without informing the server.
    
    The open operation takes the last component of the pathname as an
    argument, thus is also a lookup operation, and giving the client the
    above guarantee means informing the client before we allow anything that
    would change the set of names pointing to the inode.
    
    Therefore, we need to break delegations on rename, link, and unlink.
    
    We also need to prevent new delegations from being acquired while one of
    these operations is in progress.
    
    We could add some completely new locking for that purpose, but it's
    simpler to use the i_mutex, since that's already taken by all the
    operations we care about.
    
    The single exception is rename.  So, modify rename to take the i_mutex
    on the file that is being renamed.
    
    Also fix up lockdep and Documentation/filesystems/directory-locking to
    reflect the change.
    Acked-by: 's avatarJeff Layton <jlayton@redhat.com>
    Signed-off-by: 's avatarJ. Bruce Fields <bfields@redhat.com>
    Signed-off-by: 's avatarAl Viro <viro@zeniv.linux.org.uk>
    6cedba89
directory-locking 5.82 KB