Skip to content

Commit 3bb8b65

Browse files
josephhztorvalds
authored andcommitted
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: 2070ad1 ("ocfs2: retry on ENOSPC if sufficient space in truncate log") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Joseph Qi <[email protected]> Signed-off-by: Jiufei Xue <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 96d4101 commit 3bb8b65

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/ocfs2/suballoc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,14 +1199,24 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
11991199
inode_unlock((*ac)->ac_inode);
12001200

12011201
ret = ocfs2_try_to_free_truncate_log(osb, bits_wanted);
1202-
if (ret == 1)
1202+
if (ret == 1) {
1203+
iput((*ac)->ac_inode);
1204+
(*ac)->ac_inode = NULL;
12031205
goto retry;
1206+
}
12041207

12051208
if (ret < 0)
12061209
mlog_errno(ret);
12071210

12081211
inode_lock((*ac)->ac_inode);
1209-
ocfs2_inode_lock((*ac)->ac_inode, NULL, 1);
1212+
ret = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1);
1213+
if (ret < 0) {
1214+
mlog_errno(ret);
1215+
inode_unlock((*ac)->ac_inode);
1216+
iput((*ac)->ac_inode);
1217+
(*ac)->ac_inode = NULL;
1218+
goto bail;
1219+
}
12101220
}
12111221
if (status < 0) {
12121222
if (status != -ENOSPC)

0 commit comments

Comments
 (0)