Commit 7925409e authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds
Browse files

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: default avatarJan Kara <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent bb49b32f
......@@ -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_nested(&toputinode[cnt]->i_mutex, I_MUTEX_QUOTA);
toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
truncate_inode_pages(&toputinode[cnt]->i_data, 0);
......@@ -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);
/* 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.
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
discard[cnt] = NULL;
if (type != -1 && cnt != type)
if (!sb_has_quota_enabled(sb, cnt))
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);
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
if (discard[cnt]) {
truncate_inode_pages(&discard[cnt]->i_data, 0);
void sync_dquots(struct super_block *sb, int type)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment