mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@linux.intel.com>
To: Jan Kara <jack@suse.cz>
Cc: Valdis.Kletnieks@vt.edu, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@osdl.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: 2.6.17-rc5-mm3-lockdep - locking error in quotaon
Date: Mon, 05 Jun 2006 22:26:23 +0200	[thread overview]
Message-ID: <1149539183.3111.126.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <20060605200652.GC24342@atrey.karlin.mff.cuni.cz>


>     - acquires dqio_sem, calls filesystem specific quota writing
>       function - e.g. ext3_quota_write()
>     - this function acquires i_mutex for quota file
> 
> I think this is the type of circle your checker has found.

ok since you know this doesn't deadlock the patch below (concept; akpm
please don't apply yet) ought to describe this special locking situation
to lockdep; I would really appreciate someone who does use quota to test
this out and see if it works....

---
 fs/dquot.c          |    2 +-
 fs/ext2/super.c     |    2 +-
 fs/ext3/super.c     |    2 +-
 fs/reiserfs/super.c |    2 +-
 fs/ufs/super.c      |    2 +-
 include/linux/fs.h  |    7 ++++++-
 6 files changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6.17-rc5-mm3/fs/dquot.c
===================================================================
--- linux-2.6.17-rc5-mm3.orig/fs/dquot.c
+++ linux-2.6.17-rc5-mm3/fs/dquot.c
@@ -1475,7 +1475,7 @@ static int vfs_quota_on_inode(struct ino
 		goto out_file_init;
 	}
 	mutex_unlock(&dqopt->dqio_mutex);
-	mutex_unlock(&inode->i_mutex);
+	mutex_unlock_non_nested(&inode->i_mutex);
 	set_enable_flags(dqopt, type);
 
 	add_dquot_ref(sb, type);
Index: linux-2.6.17-rc5-mm3/fs/ext2/super.c
===================================================================
--- linux-2.6.17-rc5-mm3.orig/fs/ext2/super.c
+++ linux-2.6.17-rc5-mm3/fs/ext2/super.c
@@ -1157,7 +1157,7 @@ static ssize_t ext2_quota_write(struct s
 	struct buffer_head tmp_bh;
 	struct buffer_head *bh;
 
-	mutex_lock(&inode->i_mutex);
+	mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
 	while (towrite > 0) {
 		tocopy = sb->s_blocksize - offset < towrite ?
 				sb->s_blocksize - offset : towrite;
Index: linux-2.6.17-rc5-mm3/fs/ext3/super.c
===================================================================
--- linux-2.6.17-rc5-mm3.orig/fs/ext3/super.c
+++ linux-2.6.17-rc5-mm3/fs/ext3/super.c
@@ -2614,7 +2614,7 @@ static ssize_t ext3_quota_write(struct s
 	struct buffer_head *bh;
 	handle_t *handle = journal_current_handle();
 
-	mutex_lock(&inode->i_mutex);
+	mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
 	while (towrite > 0) {
 		tocopy = sb->s_blocksize - offset < towrite ?
 				sb->s_blocksize - offset : towrite;
Index: linux-2.6.17-rc5-mm3/fs/reiserfs/super.c
===================================================================
--- linux-2.6.17-rc5-mm3.orig/fs/reiserfs/super.c
+++ linux-2.6.17-rc5-mm3/fs/reiserfs/super.c
@@ -2204,7 +2204,7 @@ static ssize_t reiserfs_quota_write(stru
 	size_t towrite = len;
 	struct buffer_head tmp_bh, *bh;
 
-	mutex_lock(&inode->i_mutex);
+	mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
 	while (towrite > 0) {
 		tocopy = sb->s_blocksize - offset < towrite ?
 		    sb->s_blocksize - offset : towrite;
Index: linux-2.6.17-rc5-mm3/fs/ufs/super.c
===================================================================
--- linux-2.6.17-rc5-mm3.orig/fs/ufs/super.c
+++ linux-2.6.17-rc5-mm3/fs/ufs/super.c
@@ -1269,7 +1269,7 @@ static ssize_t ufs_quota_write(struct su
 	size_t towrite = len;
 	struct buffer_head *bh;
 
-	mutex_lock(&inode->i_mutex);
+	mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
 	while (towrite > 0) {
 		tocopy = sb->s_blocksize - offset < towrite ?
 				sb->s_blocksize - offset : towrite;
Index: linux-2.6.17-rc5-mm3/include/linux/fs.h
===================================================================
--- linux-2.6.17-rc5-mm3.orig/include/linux/fs.h
+++ linux-2.6.17-rc5-mm3/include/linux/fs.h
@@ -563,12 +563,17 @@ struct inode {
  * 0: the object of the current VFS operation
  * 1: parent
  * 2: child/target
+ * 3: quota file
+ *
+ * The locking order between these types is
+ * parent -> child -> normal -> quota
  */
 enum inode_i_mutex_lock_type
 {
 	I_MUTEX_NORMAL,
 	I_MUTEX_PARENT,
-	I_MUTEX_CHILD
+	I_MUTEX_CHILD,
+	I_MUTEX_QUOTA
 };
 
 /*


  parent reply	other threads:[~2006-06-05 20:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-05 17:00 Valdis.Kletnieks
2006-06-05 17:25 ` Arjan van de Ven
2006-06-05 17:35   ` Jan Kara
2006-06-05 19:20   ` Valdis.Kletnieks
2006-06-05 19:35     ` Jan Kara
2006-06-05 19:52       ` Arjan van de Ven
2006-06-05 20:06         ` Jan Kara
2006-06-05 20:15           ` Ingo Molnar
2006-06-05 20:26           ` Arjan van de Ven [this message]
2006-06-06  2:22             ` Valdis.Kletnieks
2006-06-06  8:33             ` Ingo Molnar

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=1149539183.3111.126.camel@laptopd505.fenrus.org \
    --to=arjan@linux.intel.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@osdl.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

all inboxes | Powered by JetHome®