From: Ryan Ding <ryan.ding@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 4/4] ocfs2: Fix a deadlock issue in ocfs2_dio_end_io_write()
Date: Fri, 20 Nov 2015 16:23:19 +0800 [thread overview]
Message-ID: <1448007799-10914-4-git-send-email-ryan.ding@oracle.com> (raw)
In-Reply-To: <1448007799-10914-1-git-send-email-ryan.ding@oracle.com>
Should call ocfs2_free_alloc_context() to free meta_ac & data_ac before calling
ocfs2_run_deallocs(). Because ocfs2_run_deallocs() will acquire the system
inode's i_mutex hold by meta_ac. So try to release the lock before
ocfs2_run_deallocs().
Fixes: af1310367f41 ("ocfs2: fix sparse file & data ordering issue in direct io.")
Signed-off-by: Ryan Ding <ryan.ding@oracle.com>
---
fs/ocfs2/aops.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index f33cfe4..182f754 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -2341,6 +2341,10 @@ static void ocfs2_dio_end_io_write(struct inode *inode,
ret = ocfs2_lock_allocators(inode, &et, 0, dwc->dw_zero_count*2,
&data_ac, &meta_ac);
+ if (ret) {
+ mlog_errno(ret);
+ goto unlock;
+ }
credits = ocfs2_calc_extend_credits(inode->i_sb, &di->id2.i_list);
@@ -2380,14 +2384,14 @@ unlock:
ocfs2_inode_unlock(inode, 1);
brelse(di_bh);
out:
- ocfs2_run_deallocs(osb, &dealloc);
- if (locked)
- mutex_unlock(&inode->i_mutex);
- ocfs2_dio_free_write_ctx(inode, dwc);
if (data_ac)
ocfs2_free_alloc_context(data_ac);
if (meta_ac)
ocfs2_free_alloc_context(meta_ac);
+ ocfs2_run_deallocs(osb, &dealloc);
+ if (locked)
+ mutex_unlock(&inode->i_mutex);
+ ocfs2_dio_free_write_ctx(inode, dwc);
}
/*
--
1.7.1
next prev parent reply other threads:[~2015-11-20 8:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 8:23 [Ocfs2-devel] [PATCH 1/4] ocfs2: fix ip_unaligned_aio deadlock with dio work queue Ryan Ding
2015-11-20 8:23 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: take ip_alloc_sem in ocfs2_dio_get_block & ocfs2_dio_end_io_write Ryan Ding
2015-12-01 6:36 ` Junxiao Bi
2015-11-20 8:23 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: fix disk file size and memory file size mismatch Ryan Ding
2015-12-01 6:44 ` Junxiao Bi
2015-11-20 8:23 ` Ryan Ding [this message]
2015-12-01 6:53 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: Fix a deadlock issue in ocfs2_dio_end_io_write() Junxiao Bi
2015-11-24 0:26 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix ip_unaligned_aio deadlock with dio work queue Andrew Morton
2015-11-24 3:24 ` Ryan Ding
2015-12-01 4:42 ` Junxiao Bi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448007799-10914-4-git-send-email-ryan.ding@oracle.com \
--to=ryan.ding@oracle.com \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox