diff options
author | Chao Yu <yuchao0@huawei.com> | 2017-04-17 18:21:43 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-04-19 11:00:44 -0700 |
commit | df0f6b44dd59cd07aa3ff583dee04b3b563648d0 (patch) | |
tree | be5f4aea9c458787822324136ed232b1096c5ac7 /fs/f2fs/extent_cache.c | |
parent | 0243a5f9daf149654dc68c49783b27760f513cc1 (diff) | |
download | op-kernel-dev-df0f6b44dd59cd07aa3ff583dee04b3b563648d0.zip op-kernel-dev-df0f6b44dd59cd07aa3ff583dee04b3b563648d0.tar.gz |
f2fs: introduce __check_rb_tree_consistence
Introduce __check_rb_tree_consistence to check consistence of rb-tree
based discard cache in runtime.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/extent_cache.c')
-rw-r--r-- | fs/f2fs/extent_cache.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 221ad08..2f98d70 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -159,6 +159,38 @@ lookup_neighbors: return re; } +bool __check_rb_tree_consistence(struct f2fs_sb_info *sbi, + struct rb_root *root) +{ +#ifdef CONFIG_F2FS_CHECK_FS + struct rb_node *cur = rb_first(root), *next; + struct rb_entry *cur_re, *next_re; + + if (!cur) + return true; + + while (cur) { + next = rb_next(cur); + if (!next) + return true; + + cur_re = rb_entry(cur, struct rb_entry, rb_node); + next_re = rb_entry(next, struct rb_entry, rb_node); + + if (cur_re->ofs + cur_re->len > next_re->ofs) { + f2fs_msg(sbi->sb, KERN_INFO, "inconsistent rbtree, " + "cur(%u, %u) next(%u, %u)", + cur_re->ofs, cur_re->len, + next_re->ofs, next_re->len); + return false; + } + + cur = next; + } +#endif + return true; +} + static struct kmem_cache *extent_tree_slab; static struct kmem_cache *extent_node_slab; |