Skip to content

Commit dee8656

Browse files
committed
quota: Silence lockdep on quota_on
Commit d01730d didn't completely fix the problem since we still take dqio_mutex and i_mutex in the wrong order. Move taking of i_mutex further down (luckily it's needed only for updating inode flags) below where dqio_mutex is taken. Tested-by: Valdis Kletnieks <valdis.kletnieks@vt.edu> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 658874f commit dee8656

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/quota/dquot.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,6 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
20432043
invalidate_bdev(sb->s_bdev);
20442044
}
20452045
mutex_lock(&dqopt->dqonoff_mutex);
2046-
mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
20472046
if (sb_has_quota_loaded(sb, type)) {
20482047
error = -EBUSY;
20492048
goto out_lock;
@@ -2054,9 +2053,11 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
20542053
* possible) Also nobody should write to the file - we use
20552054
* special IO operations which ignore the immutable bit. */
20562055
down_write(&dqopt->dqptr_sem);
2056+
mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
20572057
oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE |
20582058
S_NOQUOTA);
20592059
inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
2060+
mutex_unlock(&inode->i_mutex);
20602061
up_write(&dqopt->dqptr_sem);
20612062
sb->dq_op->drop(inode);
20622063
}
@@ -2080,7 +2081,6 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
20802081
goto out_file_init;
20812082
}
20822083
mutex_unlock(&dqopt->dqio_mutex);
2083-
mutex_unlock(&inode->i_mutex);
20842084
spin_lock(&dq_state_lock);
20852085
dqopt->flags |= dquot_state_flag(flags, type);
20862086
spin_unlock(&dq_state_lock);
@@ -2096,13 +2096,14 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
20962096
out_lock:
20972097
if (oldflags != -1) {
20982098
down_write(&dqopt->dqptr_sem);
2099+
mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
20992100
/* Set the flags back (in the case of accidental quotaon()
21002101
* on a wrong file we don't want to mess up the flags) */
21012102
inode->i_flags &= ~(S_NOATIME | S_NOQUOTA | S_IMMUTABLE);
21022103
inode->i_flags |= oldflags;
2104+
mutex_unlock(&inode->i_mutex);
21032105
up_write(&dqopt->dqptr_sem);
21042106
}
2105-
mutex_unlock(&inode->i_mutex);
21062107
mutex_unlock(&dqopt->dqonoff_mutex);
21072108
out_fmt:
21082109
put_quota_format(fmt);

0 commit comments

Comments
 (0)