Commit 15eba0fe authored by alex chen's avatar alex chen Committed by Linus Torvalds

ocfs2: fix journal commit deadlock in ocfs2_convert_inline_data_to_extents

Similar to ocfs2_write_end_nolock() which is metioned at commit
136f49b9 ("ocfs2: fix journal commit deadlock"), we should unlock
pages before ocfs2_commit_trans() in ocfs2_convert_inline_data_to_extents.

Otherwise, it will cause a deadlock with journal commit threads.
Signed-off-by: default avatarAlex Chen <alex.chen@huawei.com>
Reviewed-by: default avatarJoseph Qi <joseph.qi@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 95671c63
...@@ -6873,7 +6873,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, ...@@ -6873,7 +6873,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
mlog_errno(ret); mlog_errno(ret);
goto out_unlock; goto out;
} }
ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh, ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
...@@ -6931,7 +6931,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, ...@@ -6931,7 +6931,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
need_free = 1; need_free = 1;
goto out_commit; goto out_unlock;
} }
page_end = PAGE_CACHE_SIZE; page_end = PAGE_CACHE_SIZE;
...@@ -6964,12 +6964,16 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, ...@@ -6964,12 +6964,16 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
need_free = 1; need_free = 1;
goto out_commit; goto out_unlock;
} }
inode->i_blocks = ocfs2_inode_sector_count(inode); inode->i_blocks = ocfs2_inode_sector_count(inode);
} }
out_unlock:
if (pages)
ocfs2_unlock_and_free_pages(pages, num_pages);
out_commit: out_commit:
if (ret < 0 && did_quota) if (ret < 0 && did_quota)
dquot_free_space_nodirty(inode, dquot_free_space_nodirty(inode,
...@@ -6989,15 +6993,11 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, ...@@ -6989,15 +6993,11 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
out_unlock: out:
if (data_ac) if (data_ac)
ocfs2_free_alloc_context(data_ac); ocfs2_free_alloc_context(data_ac);
if (pages)
out:
if (pages) {
ocfs2_unlock_and_free_pages(pages, num_pages);
kfree(pages); kfree(pages);
}
return ret; return ret;
} }
......
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