public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 4/7] xfs: lockdep annotations for xfs_dqlock2
Date: Mon, 12 Jan 2009 10:06:37 +1100	[thread overview]
Message-ID: <20090111230637.GE8071@disturbed> (raw)
In-Reply-To: <20090109221300.520949000@bombadil.infradead.org>

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@lst.de>
> 
> 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@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2009-01-11 23:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-09 22:11 [PATCH 0/7] Remaining 2.6.29 queue Christoph Hellwig
2009-01-09 22:11 ` [PATCH 1/7] xfs: fix dentry aliasing issues in open_by_handle Christoph Hellwig
2009-01-11 23:33   ` Dave Chinner
2009-01-12 15:39     ` Christoph Hellwig
2009-01-14  1:57       ` Dave Chinner
2009-01-14  7:02       ` Lachlan McIlroy
2009-01-14 22:37         ` Dave Chinner
2009-01-14 22:50           ` Lachlan McIlroy
2009-01-09 22:11 ` [PATCH 2/7] xfs: use mnt_want_write in compat_attrmulti ioctl Christoph Hellwig
2009-01-11 23:08   ` Dave Chinner
2009-01-09 22:11 ` [PATCH 3/7] xfs: add a separate lock class for the per-mount list of dquots Christoph Hellwig
2009-01-11 23:03   ` Dave Chinner
2009-01-09 22:11 ` [PATCH 4/7] xfs: lockdep annotations for xfs_dqlock2 Christoph Hellwig
2009-01-11 23:06   ` Dave Chinner [this message]
2009-01-12 15:15     ` Christoph Hellwig
2009-01-12 23:09       ` Dave Chinner
2009-01-09 22:11 ` [PATCH 5/7] xfs: add a lock class for group/project dquots Christoph Hellwig
2009-01-11 23:07   ` Dave Chinner
2009-01-09 22:11 ` [PATCH 6/7] xfs: fix bad_features2 fixups for the root filesystem Christoph Hellwig
2009-01-11 23:03   ` Dave Chinner
2009-01-09 22:11 ` [PATCH 7/7] xfs: sanity check attr fork size Christoph Hellwig
2009-01-18 17:02 ` [PATCH 0/7] Remaining 2.6.29 queue Christoph Hellwig
2009-01-18 17:22   ` Felix Blyakher
2009-01-19  1:52     ` Lachlan McIlroy
2009-01-19  1:52       ` Christoph Hellwig

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=20090111230637.GE8071@disturbed \
    --to=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    /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