]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Jan Kara <jack@suse.cz> |
2 | Subject: ocfs2: Fix possible deadlock in ocfs2_global_read_dquot() | |
3 | Patch-mainline: 2.6.31 | |
4 | ||
5 | It is not possible to get a read lock and then try to get the same write lock | |
6 | in one thread as that can block on downconvert being requested by other node | |
7 | leading to deadlock. So first drop the quota lock for reading and only after | |
8 | that get it for writing. | |
9 | ||
10 | Signed-off-by: Jan Kara <jack@suse.cz> | |
11 | --- | |
12 | fs/ocfs2/quota_global.c | 4 +++- | |
13 | 1 files changed, 3 insertions(+), 1 deletions(-) | |
14 | ||
15 | diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c | |
16 | index 1ed0f7c..edfa60c 100644 | |
17 | --- a/fs/ocfs2/quota_global.c | |
18 | +++ b/fs/ocfs2/quota_global.c | |
19 | @@ -421,6 +421,7 @@ int ocfs2_global_read_dquot(struct dquot *dquot) | |
20 | OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes; | |
21 | if (!dquot->dq_off) { /* No real quota entry? */ | |
22 | /* Upgrade to exclusive lock for allocation */ | |
23 | + ocfs2_qinfo_unlock(info, 0); | |
24 | err = ocfs2_qinfo_lock(info, 1); | |
25 | if (err < 0) | |
26 | goto out_qlock; | |
27 | @@ -435,7 +436,8 @@ int ocfs2_global_read_dquot(struct dquot *dquot) | |
28 | out_qlock: | |
29 | if (ex) | |
30 | ocfs2_qinfo_unlock(info, 1); | |
31 | - ocfs2_qinfo_unlock(info, 0); | |
32 | + else | |
33 | + ocfs2_qinfo_unlock(info, 0); | |
34 | out: | |
35 | if (err < 0) | |
36 | mlog_errno(err); | |
37 | -- | |
38 | 1.6.0.2 | |
39 |