xfs: avoid nesting transactions in xfs_qm_scall_setqlim()
authorDave Chinner <dchinner@redhat.com>
Tue, 21 May 2013 08:02:00 +0000 (18:02 +1000)
committerBen Myers <bpm@sgi.com>
Thu, 30 May 2013 22:10:56 +0000 (17:10 -0500)
commit08fb39051f5581df45ae2a20c6cf2d0c4cddf7c2
tree858c00c8c52004aba5de4ff6305440052a6829f6
parent7ae077802c9f12959a81fa1a16c1ec2842dbae05
xfs: avoid nesting transactions in xfs_qm_scall_setqlim()

Lockdep reports:

=============================================
[ INFO: possible recursive locking detected ]
3.9.0+ #3 Not tainted
---------------------------------------------
setquota/28368 is trying to acquire lock:
 (sb_internal){++++.?}, at: [<c11e8846>] xfs_trans_alloc+0x26/0x50

but task is already holding lock:
 (sb_internal){++++.?}, at: [<c11e8846>] xfs_trans_alloc+0x26/0x50

from xfs_qm_scall_setqlim()->xfs_dqread() when a dquot needs to be
allocated.

xfs_qm_scall_setqlim() is starting a transaction and then not
passing it into xfs_qm_dqet() and so it starts it's own transaction
when allocating the dquot.  Splat!

Fix this by not allocating the dquot in xfs_qm_scall_setqlim()
inside the setqlim transaction. This requires getting the dquot
first (and allocating it if necessary) then dropping and relocking
the dquot before joining it to the setqlim transaction.

Reported-by: Michael L. Semon <mlsemon35@gmail.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
(cherry picked from commit f648167f3ac79018c210112508c732ea9bf67c7b)
fs/xfs/xfs_qm_syscalls.c