X-Spam-Checker-Version: SpamAssassin 3.3.0-rupdated (updated) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.0-rupdated Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by oss.sgi.com (8.12.11.20060308/8.12.11/SuSE Linux 0.7) with ESMTP id n0BN6fUF008297 for ; Sun, 11 Jan 2009 17:06:41 -0600 X-ASG-Debug-ID: 1231715199-42ac00e40000-NocioJ X-Barracuda-URL: http://cuda.sgi.com:80/cgi-bin/mark.cgi Received: from ipmail05.adl2.internode.on.net (localhost [127.0.0.1]) by cuda.sgi.com (Spam Firewall) with ESMTP id A1CDE7BA86 for ; Sun, 11 Jan 2009 15:06:39 -0800 (PST) Received: from ipmail05.adl2.internode.on.net (ipmail05.adl2.internode.on.net [203.16.214.145]) by cuda.sgi.com with ESMTP id smL8ypjsMZA7LfZi for ; Sun, 11 Jan 2009 15:06:39 -0800 (PST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEADcJakl5LDnl/2dsb2JhbADRH4Vv X-IronPort-AV: E=Sophos;i="4.37,249,1231075800"; d="scan'208";a="291409395" Received: from ppp121-44-57-229.lns10.syd7.internode.on.net (HELO disturbed) ([121.44.57.229]) by ipmail05.adl2.internode.on.net with ESMTP; 12 Jan 2009 09:36:38 +1030 Received: from dave by disturbed with local (Exim 4.69) (envelope-from ) id 1LM9O9-0002Wd-GI; Mon, 12 Jan 2009 10:06:37 +1100 Date: Mon, 12 Jan 2009 10:06:37 +1100 From: Dave Chinner To: Christoph Hellwig Cc: xfs@oss.sgi.com X-ASG-Orig-Subj: Re: [PATCH 4/7] xfs: lockdep annotations for xfs_dqlock2 Subject: Re: [PATCH 4/7] xfs: lockdep annotations for xfs_dqlock2 Message-ID: <20090111230637.GE8071@disturbed> Mail-Followup-To: Christoph Hellwig , xfs@oss.sgi.com References: <20090109221104.237540000@bombadil.infradead.org> <20090109221300.520949000@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090109221300.520949000@bombadil.infradead.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-Barracuda-Connect: ipmail05.adl2.internode.on.net[203.16.214.145] X-Barracuda-Start-Time: 1231715200 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Virus-Scanned: by cuda.sgi.com at sgi.com X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using per-user scores of TAG_LEVEL=2.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.1 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.1.14977 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Virus-Scanned: ClamAV 0.91.2/8852/Sun Jan 11 13:31:01 2009 on oss.sgi.com X-Virus-Status: Clean 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 > > 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