Commit 4e8a3019 authored by Jan Kara's avatar Jan Kara Committed by Joel Becker

ocfs2: Fix possible deadlock in ocfs2_global_read_dquot()

It is not possible to get a read lock and then try to get the same write lock
in one thread as that can block on downconvert being requested by other node
leading to deadlock. So first drop the quota lock for reading and only after
that get it for writing.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent 2b53bc7b
...@@ -421,6 +421,7 @@ int ocfs2_global_read_dquot(struct dquot *dquot) ...@@ -421,6 +421,7 @@ int ocfs2_global_read_dquot(struct dquot *dquot)
OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes; OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes;
if (!dquot->dq_off) { /* No real quota entry? */ if (!dquot->dq_off) { /* No real quota entry? */
/* Upgrade to exclusive lock for allocation */ /* Upgrade to exclusive lock for allocation */
ocfs2_qinfo_unlock(info, 0);
err = ocfs2_qinfo_lock(info, 1); err = ocfs2_qinfo_lock(info, 1);
if (err < 0) if (err < 0)
goto out_qlock; goto out_qlock;
...@@ -435,6 +436,7 @@ int ocfs2_global_read_dquot(struct dquot *dquot) ...@@ -435,6 +436,7 @@ int ocfs2_global_read_dquot(struct dquot *dquot)
out_qlock: out_qlock:
if (ex) if (ex)
ocfs2_qinfo_unlock(info, 1); ocfs2_qinfo_unlock(info, 1);
else
ocfs2_qinfo_unlock(info, 0); ocfs2_qinfo_unlock(info, 0);
out: out:
if (err < 0) if (err < 0)
......
Markdown is supported
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