浏览代码

f2fs: avoid deadlock in f2fs_shrink_extent_tree

While handling extent trees, we can enter into a reclaiming path anytime.
If it tries to release some extent nodes in the same extent tree,
write_lock(&et->lock) would be hanged.
In order to avoid the deadlock, we can just skip it.

Note that, if it is an unreferenced tree, we should get write_lock(&et->lock)
successfully and release all of therein nodes.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Jaegeuk Kim 10 年之前
父节点
当前提交
760de7914e
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      fs/f2fs/extent_cache.c

+ 4 - 3
fs/f2fs/extent_cache.c

@@ -615,9 +615,10 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
 		for (i = 0; i < found; i++) {
 		for (i = 0; i < found; i++) {
 			struct extent_tree *et = treevec[i];
 			struct extent_tree *et = treevec[i];
 
 
-			write_lock(&et->lock);
-			node_cnt += __free_extent_tree(sbi, et, false);
-			write_unlock(&et->lock);
+			if (write_trylock(&et->lock)) {
+				node_cnt += __free_extent_tree(sbi, et, false);
+				write_unlock(&et->lock);
+			}
 
 
 			if (node_cnt + tree_cnt >= nr_shrink)
 			if (node_cnt + tree_cnt >= nr_shrink)
 				goto unlock_out;
 				goto unlock_out;