1 From: Jan Kara <jack@suse.cz>
2 Subject: ocfs2: Fix possible deadlock in quota recovery
5 In ocfs2_finish_quota_recovery() we acquired global quota file lock and started
6 recovering local quota file. During this process we need to get quota
7 structures, which calls ocfs2_dquot_acquire() which gets global quota file lock
8 again. This second lock can block in case some other node has requested the
9 quota file lock in the mean time. Fix the problem by moving quota file locking
10 down into the function where it is really needed. Then dqget() or dqput()
11 won't be called with the lock held.
13 Signed-off-by: Jan Kara <jack@suse.cz>
15 fs/ocfs2/quota_local.c | 16 +++++++++-------
16 1 files changed, 9 insertions(+), 7 deletions(-)
18 Index: linux-2.6.27-SLE11_BRANCH/fs/ocfs2/quota_local.c
19 ===================================================================
20 --- linux-2.6.27-SLE11_BRANCH.orig/fs/ocfs2/quota_local.c 2009-07-16 13:16:27.000000000 +0200
21 +++ linux-2.6.27-SLE11_BRANCH/fs/ocfs2/quota_local.c 2009-07-16 13:20:05.000000000 +0200
24 mlog_entry("ino=%lu type=%u", (unsigned long)lqinode->i_ino, type);
26 - status = ocfs2_lock_global_qf(oinfo, 1);
30 list_for_each_entry_safe(rchunk, next, &(rec->r_list[type]), rc_list) {
31 chunk = rchunk->rc_chunk;
32 hbh = ocfs2_bread(lqinode, ol_quota_chunk_block(sb, chunk),
37 + status = ocfs2_lock_global_qf(oinfo, 1);
43 handle = ocfs2_start_trans(OCFS2_SB(sb),
46 status = PTR_ERR(handle);
51 mutex_lock(&sb_dqopt(sb)->dqio_mutex);
52 spin_lock(&dq_data_lock);
55 mutex_unlock(&sb_dqopt(sb)->dqio_mutex);
56 ocfs2_commit_trans(OCFS2_SB(sb), handle);
58 + ocfs2_unlock_global_qf(oinfo, 1);
66 - ocfs2_unlock_global_qf(oinfo, 1);
69 free_recovery_list(&(rec->r_list[type]));