From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] xfs: setup VFS i_rwsem lockdep state correctly
Date: Thu, 7 Jun 2018 07:53:18 -0700 [thread overview]
Message-ID: <20180607145318.GE25007@magnolia> (raw)
In-Reply-To: <20180607052132.6207-2-david@fromorbit.com>
On Thu, Jun 07, 2018 at 03:21:31PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> 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.
>
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>
With the commit message changes added,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_iops.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 29484091c0d2..3020c57fc125 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -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 {
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-06-07 14:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 5:21 [PATCH 0/2] xfs: fix a couple of potential deadlocks Dave Chinner
2018-06-07 5:21 ` [PATCH 1/2] xfs: setup VFS i_rwsem lockdep state correctly Dave Chinner
2018-06-07 5:32 ` Dave Chinner
2018-06-07 11:41 ` Brian Foster
2018-06-07 5:50 ` Allison Henderson
2018-06-07 14:53 ` Darrick J. Wong [this message]
2018-06-07 5:21 ` [PATCH 2/2] xfs: xfs_reflink_convert_cow() memory allocation deadlock Dave Chinner
2018-06-07 5:56 ` Allison Henderson
2018-06-07 14:46 ` Darrick J. Wong
2018-06-07 22:08 ` Dave Chinner
2018-06-07 11:41 ` Brian Foster
2018-06-07 14:48 ` Darrick J. Wong
2018-06-08 0:48 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180607145318.GE25007@magnolia \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox