Commit 3bb8b653 authored by Joseph Qi's avatar Joseph Qi Committed by Linus Torvalds

ocfs2: fix double unlock in case retry after free truncate log

If ocfs2_reserve_cluster_bitmap_bits() fails with ENOSPC, it will try to
free truncate log and then retry.  Since ocfs2_try_to_free_truncate_log
will lock/unlock global bitmap inode, we have to unlock it before
calling this function.  But when retry reserve and it fails with no
global bitmap inode lock taken, it will unlock again in error handling
branch and BUG.

This issue also exists if no need retry and then ocfs2_inode_lock fails.
So fix it.

Fixes: 2070ad1a ("ocfs2: retry on ENOSPC if sufficient space in truncate log")
Link: http://lkml.kernel.org/r/57D91939.6030809@huawei.comSigned-off-by: default avatarJoseph Qi <joseph.qi@huawei.com>
Signed-off-by: default avatarJiufei Xue <xuejiufei@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 96d41019
...@@ -1199,14 +1199,24 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, ...@@ -1199,14 +1199,24 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
inode_unlock((*ac)->ac_inode); inode_unlock((*ac)->ac_inode);
ret = ocfs2_try_to_free_truncate_log(osb, bits_wanted); ret = ocfs2_try_to_free_truncate_log(osb, bits_wanted);
if (ret == 1) if (ret == 1) {
iput((*ac)->ac_inode);
(*ac)->ac_inode = NULL;
goto retry; goto retry;
}
if (ret < 0) if (ret < 0)
mlog_errno(ret); mlog_errno(ret);
inode_lock((*ac)->ac_inode); inode_lock((*ac)->ac_inode);
ocfs2_inode_lock((*ac)->ac_inode, NULL, 1); ret = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1);
if (ret < 0) {
mlog_errno(ret);
inode_unlock((*ac)->ac_inode);
iput((*ac)->ac_inode);
(*ac)->ac_inode = NULL;
goto bail;
}
} }
if (status < 0) { if (status < 0) {
if (status != -ENOSPC) if (status != -ENOSPC)
......
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