Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7925409e202a41176b729671eab6e610a54153cd
Commit:     7925409e202a41176b729671eab6e610a54153cd
Parent:     bb49b32fece7910fbb02a6934bca4495596f6c8c
Author:     Jan Kara <[EMAIL PROTECTED]>
AuthorDate: Wed May 16 22:11:19 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu May 17 05:23:05 2007 -0700

    circular locking dependency found in QUOTA OFF
    
    i_mutex on quota files is special.  Unlike i_mutexes for other inodes it is
    acquired under dqonoff_mutex.  Tell lockdep about this lock ranking.  Also
    comment and code in quota_sync_sb() seem to be bogus (as i_mutex for quota
    file can be acquired under dqonoff_mutex).  Move truncate_inode_pages()
    call under dqonoff_mutex and save some problems with races...
    
    Signed-off-by: Jan Kara <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/dquot.c |    2 +-
 fs/quota.c |   23 +++++++----------------
 2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/fs/dquot.c b/fs/dquot.c
index 3a99584..8819d28 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1421,7 +1421,7 @@ int vfs_quota_off(struct super_block *sb, int type)
                        /* If quota was reenabled in the meantime, we have
                         * nothing to do */
                        if (!sb_has_quota_enabled(sb, cnt)) {
-                               mutex_lock(&toputinode[cnt]->i_mutex);
+                               mutex_lock_nested(&toputinode[cnt]->i_mutex, 
I_MUTEX_QUOTA);
                                toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
                                  S_NOATIME | S_NOQUOTA);
                                truncate_inode_pages(&toputinode[cnt]->i_data, 
0);
diff --git a/fs/quota.c b/fs/quota.c
index e9d88fd..9f237d6 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -157,7 +157,6 @@ static int check_quotactl_valid(struct super_block *sb, int 
type, int cmd, qid_t
 static void quota_sync_sb(struct super_block *sb, int type)
 {
        int cnt;
-       struct inode *discard[MAXQUOTAS];
 
        sb->s_qcop->quota_sync(sb, type);
        /* This is not very clever (and fast) but currently I don't know about
@@ -167,29 +166,21 @@ static void quota_sync_sb(struct super_block *sb, int 
type)
                sb->s_op->sync_fs(sb, 1);
        sync_blockdev(sb->s_bdev);
 
-       /* Now when everything is written we can discard the pagecache so
-        * that userspace sees the changes. We need i_mutex and so we could
-        * not do it inside dqonoff_mutex. Moreover we need to be carefull
-        * about races with quotaoff() (that is the reason why we have own
-        * reference to inode). */
+       /*
+        * Now when everything is written we can discard the pagecache so
+        * that userspace sees the changes.
+        */
        mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               discard[cnt] = NULL;
                if (type != -1 && cnt != type)
                        continue;
                if (!sb_has_quota_enabled(sb, cnt))
                        continue;
-               discard[cnt] = igrab(sb_dqopt(sb)->files[cnt]);
+               mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, 
I_MUTEX_QUOTA);
+               truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
+               mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex);
        }
        mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               if (discard[cnt]) {
-                       mutex_lock(&discard[cnt]->i_mutex);
-                       truncate_inode_pages(&discard[cnt]->i_data, 0);
-                       mutex_unlock(&discard[cnt]->i_mutex);
-                       iput(discard[cnt]);
-               }
-       }
 }
 
 void sync_dquots(struct super_block *sb, int type)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to