diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-05-28 18:19:17 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-06-01 16:21:09 -0700 |
commit | 9236cac5666ea8b3a3b92b132a046c200b99dca8 (patch) | |
tree | 76cd720f7405d4ee8042ac86176c1ee2a713ff38 /fs/f2fs | |
parent | e5e0906b6b4c517a8622f2ff196c19cbd1068644 (diff) |
f2fs: fix a deadlock for summary page lock vs. sentry_lock
In f2fs_gc: In f2fs_replace_block:
- lock_page(sum_page)
- check_valid_map() - mutex_lock(sentry_lock)
- mutex_lock(sentry_lock) - change_curseg()
- lock_page(sum_page)
This patch fixes the deadlock condition.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/gc.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 43354cb3ce94..e1e73617d13b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -750,6 +750,15 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, sum = page_address(sum_page); + /* + * this is to avoid deadlock: + * - lock_page(sum_page) - f2fs_replace_block + * - check_valid_map() - mutex_lock(sentry_lock) + * - mutex_lock(sentry_lock) - change_curseg() + * - lock_page(sum_page) + */ + unlock_page(sum_page); + switch (GET_SUM_TYPE((&sum->footer))) { case SUM_TYPE_NODE: gc_node_segment(sbi, sum->entries, segno, gc_type); @@ -763,7 +772,7 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, stat_inc_seg_count(sbi, GET_SUM_TYPE((&sum->footer)), gc_type); stat_inc_call_count(sbi->stat_info); - f2fs_put_page(sum_page, 1); + f2fs_put_page(sum_page, 0); } int f2fs_gc(struct f2fs_sb_info *sbi) |