Skip to content

Commit 67fce70

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: disable f2fs_check_rb_tree_consistence
If there is millions of discard entries cached in rb tree, each sanity check of it can cause very long latency as held cmd_lock blocking other lock grabbers. In other aspect, we have enabled the check very long time, as we see, there is no such inconsistent condition caused by bugs. But still we do not choose to kill it directly, instead, adding an flag to disable the check now, if there is related code change, we can reuse it to detect bugs. Signed-off-by: Yunlei He <[email protected]> Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent e1da787 commit 67fce70

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

fs/f2fs/f2fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ struct discard_cmd_control {
311311
atomic_t issing_discard; /* # of issing discard */
312312
atomic_t discard_cmd_cnt; /* # of cached cmd count */
313313
struct rb_root root; /* root of discard rb-tree */
314+
bool rbtree_check; /* config for consistence check */
314315
};
315316

316317
/* for the list of fsync inodes, used only during recovery */

fs/f2fs/segment.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,9 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
11991199
mutex_lock(&dcc->cmd_lock);
12001200
if (list_empty(pend_list))
12011201
goto next;
1202-
f2fs_bug_on(sbi,
1203-
!f2fs_check_rb_tree_consistence(sbi, &dcc->root));
1202+
if (unlikely(dcc->rbtree_check))
1203+
f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi,
1204+
&dcc->root));
12041205
blk_start_plug(&plug);
12051206
list_for_each_entry_safe(dc, tmp, pend_list, list) {
12061207
f2fs_bug_on(sbi, dc->state != D_PREP);
@@ -1752,6 +1753,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
17521753
dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg;
17531754
dcc->undiscard_blks = 0;
17541755
dcc->root = RB_ROOT;
1756+
dcc->rbtree_check = false;
17551757

17561758
init_waitqueue_head(&dcc->discard_wait_queue);
17571759
SM_I(sbi)->dcc_info = dcc;
@@ -2381,7 +2383,9 @@ static void __issue_discard_cmd_range(struct f2fs_sb_info *sbi,
23812383
issued = 0;
23822384

23832385
mutex_lock(&dcc->cmd_lock);
2384-
f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi, &dcc->root));
2386+
if (unlikely(dcc->rbtree_check))
2387+
f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi,
2388+
&dcc->root));
23852389

23862390
dc = (struct discard_cmd *)f2fs_lookup_rb_tree_ret(&dcc->root,
23872391
NULL, start,

0 commit comments

Comments
 (0)