xfs
[Top] [All Lists]

Re: [PATCH 4/7] xfs: lockdep annotations for xfs_dqlock2

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 4/7] xfs: lockdep annotations for xfs_dqlock2
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 12 Jan 2009 10:06:37 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20090109221300.520949000@xxxxxxxxxxxxxxxxxxxxxx>
Mail-followup-to: Christoph Hellwig <hch@xxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
References: <20090109221104.237540000@xxxxxxxxxxxxxxxxxxxxxx> <20090109221300.520949000@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.18 (2008-05-17)
On Fri, Jan 09, 2009 at 05:11:08PM -0500, Christoph Hellwig wrote:
> xfs_dqlock2 locks two xfs_dquots, which is fine as it always locks the
> dquot with the lower id first.  Use mutex_lock_nested to tell lockdep 
> about this fact.
> 
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> 
> Index: xfs/fs/xfs/quota/xfs_dquot.c
> ===================================================================
> --- xfs.orig/fs/xfs/quota/xfs_dquot.c 2008-12-29 11:28:54.459613573 +0100
> +++ xfs/fs/xfs/quota/xfs_dquot.c      2008-12-29 11:29:31.037738842 +0100
> @@ -1383,6 +1383,12 @@ xfs_dqunlock_nonotify(
>       mutex_unlock(&(dqp->q_qlock));
>  }
>  
> +/*
> + * Lock two xfs_dquot structures.
> + *
> + * To avoid deadlocks we always lock the quota structure with
> + * the lowerd id first.
> + */
>  void
>  xfs_dqlock2(
>       xfs_dquot_t     *d1,
> @@ -1393,10 +1399,10 @@ xfs_dqlock2(
>               if (be32_to_cpu(d1->q_core.d_id) >
>                   be32_to_cpu(d2->q_core.d_id)) {
>                       xfs_dqlock(d2);
> -                     xfs_dqlock(d1);
> +                     mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_2ND);
>               } else {
>                       xfs_dqlock(d1);
> -                     xfs_dqlock(d2);
> +                     mutex_lock_nested(&d2->q_qlock, XFS_QLOCK_2ND);

This looks a bit wierd.

Yes, xfs_dqlock() is just a wrapper around mutex_lock, but we should
be consistent here. Can you add a xfs_dqlock_nested() wrapper to do
this?

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>