Merge tag 'sound-fix-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[linux-2.6-microblaze.git] / fs / f2fs / extent_cache.c
index 686c68b..3ebf976 100644 (file)
@@ -58,6 +58,29 @@ struct rb_entry *f2fs_lookup_rb_tree(struct rb_root_cached *root,
        return re;
 }
 
+struct rb_node **f2fs_lookup_rb_tree_ext(struct f2fs_sb_info *sbi,
+                                       struct rb_root_cached *root,
+                                       struct rb_node **parent,
+                                       unsigned long long key, bool *leftmost)
+{
+       struct rb_node **p = &root->rb_root.rb_node;
+       struct rb_entry *re;
+
+       while (*p) {
+               *parent = *p;
+               re = rb_entry(*parent, struct rb_entry, rb_node);
+
+               if (key < re->key) {
+                       p = &(*p)->rb_left;
+               } else {
+                       p = &(*p)->rb_right;
+                       *leftmost = false;
+               }
+       }
+
+       return p;
+}
+
 struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
                                struct rb_root_cached *root,
                                struct rb_node **parent,
@@ -166,7 +189,7 @@ lookup_neighbors:
 }
 
 bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
-                                               struct rb_root_cached *root)
+                               struct rb_root_cached *root, bool check_key)
 {
 #ifdef CONFIG_F2FS_CHECK_FS
        struct rb_node *cur = rb_first_cached(root), *next;
@@ -183,13 +206,23 @@ bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
                cur_re = rb_entry(cur, struct rb_entry, rb_node);
                next_re = rb_entry(next, struct rb_entry, rb_node);
 
+               if (check_key) {
+                       if (cur_re->key > next_re->key) {
+                               f2fs_info(sbi, "inconsistent rbtree, "
+                                       "cur(%llu) next(%llu)",
+                                       cur_re->key, next_re->key);
+                               return false;
+                       }
+                       goto next;
+               }
+
                if (cur_re->ofs + cur_re->len > next_re->ofs) {
                        f2fs_info(sbi, "inconsistent rbtree, cur(%u, %u) next(%u, %u)",
                                  cur_re->ofs, cur_re->len,
                                  next_re->ofs, next_re->len);
                        return false;
                }
-
+next:
                cur = next;
        }
 #endif