Skip to content

Commit 81acb3e

Browse files
chaseyupappschlumpf
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 <heyunlei@huawei.com> Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> (cherry picked from commit 94b5dda) (cherry picked from commit 533315d76de9382bf476bad641c792ed50f5c9b3)
1 parent 3192fa0 commit 81acb3e

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

fs/f2fs/f2fs.h

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

317318
/* 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);
@@ -1758,6 +1759,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
17581759
dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg;
17591760
dcc->undiscard_blks = 0;
17601761
dcc->root = RB_ROOT;
1762+
dcc->rbtree_check = false;
17611763

17621764
init_waitqueue_head(&dcc->discard_wait_queue);
17631765
SM_I(sbi)->dcc_info = dcc;
@@ -2387,7 +2389,9 @@ static void __issue_discard_cmd_range(struct f2fs_sb_info *sbi,
23872389
issued = 0;
23882390

23892391
mutex_lock(&dcc->cmd_lock);
2390-
f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi, &dcc->root));
2392+
if (unlikely(dcc->rbtree_check))
2393+
f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi,
2394+
&dcc->root));
23912395

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

0 commit comments

Comments
 (0)