xfs: setup VFS i_rwsem lockdep state correctly
When lockdep is enabled, it changes the type of the inode i_rwsem
semaphore before unlocking a newly instantiated inode. THere is the
possibility that there is already a waiter on that inode lock by the
time we unlock the new inode, so having lockdep re-initialise the
lock is a vector for trouble.
Avoid this whole situation by setting up the i_rwsem lockdep class
at the same time we set up the XFS inode i_ilock classes and so the
VFS doesn't have to change the lock class itself when it is
potentially unsafe.
This change is necessary because the equivalent fixes to the VFS code
made in commit 1e2e547a93
("do d_instantiate/unlock_new_inode
combinations safely") are not relevant to XFS as it has it's own
internal inode cache lookup and instantiation routines.
Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
4bb8b65a04
commit
ef215e394e
@ -1258,6 +1258,14 @@ xfs_setup_inode(
|
||||
xfs_diflags_to_iflags(inode, ip);
|
||||
|
||||
if (S_ISDIR(inode->i_mode)) {
|
||||
/*
|
||||
* We set the i_rwsem class here to avoid potential races with
|
||||
* lockdep_annotate_inode_mutex_key() reinitialising the lock
|
||||
* after a filehandle lookup has already found the inode in
|
||||
* cache before it has been unlocked via unlock_new_inode().
|
||||
*/
|
||||
lockdep_set_class(&inode->i_rwsem,
|
||||
&inode->i_sb->s_type->i_mutex_dir_key);
|
||||
lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class);
|
||||
ip->d_ops = ip->i_mount->m_dir_inode_ops;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user