]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
quota: Fix possible deadlock during parallel quotaon and quotaoff
authorJiaying Zhang <jiayingz@google.com>
Tue, 7 Jul 2009 16:15:21 +0000 (18:15 +0200)
committerJan Kara <jack@suse.cz>
Tue, 7 Jul 2009 16:15:21 +0000 (18:15 +0200)
commitd01730d74d2b0155da50d44555001706294014f7
treea6de6075c054b6f253be19062d7f8efc973d55dc
parentfaf80d62e44dc627efb741f48db50c1858d1667c
quota: Fix possible deadlock during parallel quotaon and quotaoff

The following test script triggers a deadlock on ext2 filesystem:
while true; do quotaon /dev/hda >&/dev/null; usleep $RANDOM; done &
while true; do quotaoff /dev/hda >&/dev/null; usleep $RANDOM; done &

I found there is a potential deadlock between quotaon and quotaoff (or
quotasync). Basically, all of quotactl operations need to be protected by
dqonoff_mutex. vfs_quota_off and vfs_quota_sync also call sb->s_op->quota_write
that needs to grab the i_mutex of the quota file.  But in vfs_quota_on_inode
(called from quotaon operation), the current code tries to grab  the i_mutex of
the quota file first before getting quonoff_mutex.

Reverse the order in which we take locks in vfs_quota_on_inode().

Jan Kara: Changed changelog to be more readable, made lockdep happy with
  I_MUTEX_QUOTA.

Signed-off-by: Jiaying Zhang <jiayingz@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c