X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=check%2Fmain.c;h=6f5af7fbe89b15351089f332f292aabb4704799b;hb=5dade4b9514cbb765c9c2905172bb371b7479a77;hp=7619c8e2f0d5c8e7793aae00be150a4f1899023f;hpb=d0b191b880b344ffe4a1d5ca50ba986f228c2c13;p=platform%2Fupstream%2Fbtrfs-progs.git diff --git a/check/main.c b/check/main.c index 7619c8e..6f5af7f 100644 --- a/check/main.c +++ b/check/main.c @@ -412,8 +412,6 @@ static void free_file_extent_holes(struct rb_root *holes) } } -static void reset_cached_block_groups(struct btrfs_fs_info *fs_info); - static void record_root_in_trans(struct btrfs_trans_handle *trans, struct btrfs_root *root) { @@ -1668,77 +1666,6 @@ out: return ret; } -static void reada_walk_down(struct btrfs_root *root, - struct extent_buffer *node, int slot) -{ - struct btrfs_fs_info *fs_info = root->fs_info; - u64 bytenr; - u64 ptr_gen; - u32 nritems; - int i; - int level; - - level = btrfs_header_level(node); - if (level != 1) - return; - - nritems = btrfs_header_nritems(node); - for (i = slot; i < nritems; i++) { - bytenr = btrfs_node_blockptr(node, i); - ptr_gen = btrfs_node_ptr_generation(node, i); - readahead_tree_block(fs_info, bytenr, ptr_gen); - } -} - -/* - * Check the child node/leaf by the following condition: - * 1. the first item key of the node/leaf should be the same with the one - * in parent. - * 2. block in parent node should match the child node/leaf. - * 3. generation of parent node and child's header should be consistent. - * - * Or the child node/leaf pointed by the key in parent is not valid. - * - * We hope to check leaf owner too, but since subvol may share leaves, - * which makes leaf owner check not so strong, key check should be - * sufficient enough for that case. - */ -static int check_child_node(struct extent_buffer *parent, int slot, - struct extent_buffer *child) -{ - struct btrfs_key parent_key; - struct btrfs_key child_key; - int ret = 0; - - btrfs_node_key_to_cpu(parent, &parent_key, slot); - if (btrfs_header_level(child) == 0) - btrfs_item_key_to_cpu(child, &child_key, 0); - else - btrfs_node_key_to_cpu(child, &child_key, 0); - - if (memcmp(&parent_key, &child_key, sizeof(parent_key))) { - ret = -EINVAL; - fprintf(stderr, - "Wrong key of child node/leaf, wanted: (%llu, %u, %llu), have: (%llu, %u, %llu)\n", - parent_key.objectid, parent_key.type, parent_key.offset, - child_key.objectid, child_key.type, child_key.offset); - } - if (btrfs_header_bytenr(child) != btrfs_node_blockptr(parent, slot)) { - ret = -EINVAL; - fprintf(stderr, "Wrong block of child node/leaf, wanted: %llu, have: %llu\n", - btrfs_node_blockptr(parent, slot), - btrfs_header_bytenr(child)); - } - if (btrfs_node_ptr_generation(parent, slot) != - btrfs_header_generation(child)) { - ret = -EINVAL; - fprintf(stderr, "Wrong generation of child node/leaf, wanted: %llu, have: %llu\n", - btrfs_header_generation(child), - btrfs_node_ptr_generation(parent, slot)); - } - return ret; -} - /* * for a tree node or leaf, if it's shared, indeed we don't need to iterate it * in every fs or file tree check. Here we find its all root ids, and only check @@ -10273,31 +10200,6 @@ static int prune_corrupt_blocks(struct btrfs_fs_info *info) return 0; } -static void reset_cached_block_groups(struct btrfs_fs_info *fs_info) -{ - struct btrfs_block_group_cache *cache; - u64 start, end; - int ret; - - while (1) { - ret = find_first_extent_bit(&fs_info->free_space_cache, 0, - &start, &end, EXTENT_DIRTY); - if (ret) - break; - clear_extent_dirty(&fs_info->free_space_cache, start, end); - } - - start = 0; - while (1) { - cache = btrfs_lookup_first_block_group(fs_info, start); - if (!cache) - break; - if (cache->cached) - cache->cached = 0; - start = cache->key.objectid + cache->key.offset; - } -} - static int check_extent_refs(struct btrfs_root *root, struct cache_tree *extent_cache) {