Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1280480

Re: [PATCH v2] f2fs: avoid deadlock in f2fs_shrink_extent_tree

Path csiph.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!bofh.it!news.nic.it!robomod
From Jaegeuk Kim <jaegeuk@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2] f2fs: avoid deadlock in f2fs_shrink_extent_tree
Date Tue, 01 Dec 2015 02:50:01 +0100
Message-ID <qAIeR-32d-13@gated-at.bofh.it> (permalink)
References <qAHsu-2uI-5@gated-at.bofh.it>
X-Original-To linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 47
Organization linux.* mail to news gateway
X-Original-Date Mon, 30 Nov 2015 17:46:22 -0800
X-Original-Message-ID <20151201014622.GA51854@jaegeuk.local>
X-Original-References <1448931215-51572-1-git-send-email-jaegeuk@kernel.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1280480

Show key headers only | View raw


Change log from v1:
 o fix bug

From 8cd63b5e91daeeccc1f158425c74de0f462c96af Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <jaegeuk@kernel.org>
Date: Mon, 30 Nov 2015 16:26:44 -0800
Subject: [PATCH] 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.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/extent_cache.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 7ddba81..de063f2 100644
--- a/fs/f2fs/extent_cache.c
+++ b/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++) {
 			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)
 				goto unlock_out;
-- 
2.4.9 (Apple Git-60)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] f2fs: avoid deadlock in f2fs_shrink_extent_tree Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-01 02:00 +0100
  Re: [PATCH] f2fs: avoid deadlock in f2fs_shrink_extent_tree kbuild test robot <lkp@intel.com> - 2015-12-01 02:40 +0100
  Re: [PATCH v2] f2fs: avoid deadlock in f2fs_shrink_extent_tree Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-01 02:50 +0100
    Re: [f2fs-dev] [PATCH v2] f2fs: avoid deadlock in  f2fs_shrink_extent_tree Chao Yu <chao@kernel.org> - 2015-12-01 15:50 +0100
  Re: [PATCH] f2fs: avoid deadlock in f2fs_shrink_extent_tree kbuild test robot <lkp@intel.com> - 2015-12-01 03:20 +0100

csiph-web