2 * Copyright (C) 2014 SUSE. All rights reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
18 * Authors: Mark Fasheh <mfasheh@suse.de>
23 #include <uuid/uuid.h>
24 #include "kerncompat.h"
25 #include "radix-tree.h"
28 #include "print-tree.h"
32 #include "qgroup-verify.h"
34 /*#define QGROUP_VERIFY_DEBUG*/
35 static unsigned long tot_extents_scanned = 0;
37 static void add_bytes(u64 root_objectid, u64 num_bytes, int exclusive);
42 struct btrfs_disk_key key;
43 struct btrfs_qgroup_info_item diskinfo;
45 struct btrfs_qgroup_info_item info;
47 struct rb_node rb_node;
52 unsigned int num_groups;
53 } counts = { .root = RB_ROOT };
55 struct rb_root by_bytenr = RB_ROOT;
58 * List of interior tree blocks. We walk this list after loading the
59 * extent tree to resolve implied refs. For each interior node we'll
60 * place a shared ref in the ref tree against each child object. This
61 * allows the shared ref resolving code to do the actual work later of
62 * finding roots to account against.
64 * An implied ref is when a tree block has refs on it that may not
65 * exist in any of it's child nodes. Even though the refs might not
66 * exist further down the tree, the fact that our interior node has a
67 * ref means we need to account anything below it to all it's roots.
69 struct ulist *tree_blocks = NULL; /* unode->val = bytenr, ->aux
70 * = tree_block pointer */
82 struct rb_node bytenr_node;
85 #ifdef QGROUP_VERIFY_DEBUG
86 static void print_ref(struct ref *ref)
88 printf("bytenr: %llu\t\tnum_bytes: %llu\t\t parent: %llu\t\t"
89 "root: %llu\n", ref->bytenr, ref->num_bytes,
90 ref->parent, ref->root);
93 static void print_all_refs(void)
95 unsigned long count = 0;
99 node = rb_first(&by_bytenr);
101 ref = rb_entry(node, struct ref, bytenr_node);
106 node = rb_next(node);
109 printf("%lu extents scanned with %lu refs in total.\n",
110 tot_extents_scanned, count);
115 * Store by bytenr in rbtree
117 * The tree is sorted in ascending order by bytenr, then parent, then
118 * root. Since full refs have a parent == 0, those will come before
121 static int compare_ref(struct ref *orig, u64 bytenr, u64 root, u64 parent)
123 if (bytenr < orig->bytenr)
125 if (bytenr > orig->bytenr)
128 if (parent < orig->parent)
130 if (parent > orig->parent)
133 if (root < orig->root)
135 if (root > orig->root)
142 * insert a new ref into the tree. returns the existing ref entry
143 * if one is already there.
145 static struct ref *insert_ref(struct ref *ref)
148 struct rb_node **p = &by_bytenr.rb_node;
149 struct rb_node *parent = NULL;
154 curr = rb_entry(parent, struct ref, bytenr_node);
156 ret = compare_ref(curr, ref->bytenr, ref->root, ref->parent);
165 rb_link_node(&ref->bytenr_node, parent, p);
166 rb_insert_color(&ref->bytenr_node, &by_bytenr);
171 * Partial search, returns the first ref with matching bytenr. Caller
172 * can walk forward from there.
174 * Leftmost refs will be full refs - this is used to our advantage
175 * when resolving roots.
177 static struct ref *find_ref_bytenr(u64 bytenr)
179 struct rb_node *n = by_bytenr.rb_node;
183 ref = rb_entry(n, struct ref, bytenr_node);
185 if (bytenr < ref->bytenr)
187 else if (bytenr > ref->bytenr)
190 /* Walk to the left to find the first item */
191 struct rb_node *node_left = rb_prev(&ref->bytenr_node);
192 struct ref *ref_left;
195 ref_left = rb_entry(node_left, struct ref,
197 if (ref_left->bytenr != ref->bytenr)
200 node_left = rb_prev(node_left);
208 static struct ref *find_ref(u64 bytenr, u64 root, u64 parent)
210 struct rb_node *n = by_bytenr.rb_node;
215 ref = rb_entry(n, struct ref, bytenr_node);
217 ret = compare_ref(ref, bytenr, root, parent);
228 static struct ref *alloc_ref(u64 bytenr, u64 root, u64 parent, u64 num_bytes)
230 struct ref *ref = find_ref(bytenr, root, parent);
232 BUG_ON(parent && root);
235 ref = calloc(1, sizeof(*ref));
237 ref->bytenr = bytenr;
239 ref->parent = parent;
240 ref->num_bytes = num_bytes;
248 static void free_ref_node(struct rb_node *node)
250 struct ref *ref = rb_entry(node, struct ref, bytenr_node);
254 FREE_RB_BASED_TREE(ref, free_ref_node);
257 * Resolves all the possible roots for the ref at parent.
259 static void find_parent_roots(struct ulist *roots, u64 parent)
262 struct rb_node *node;
265 * Search the rbtree for the first ref with bytenr == parent.
266 * Walk forward so long as bytenr == parent, adding resolved root ids.
267 * For each unresolved root, we recurse
269 ref = find_ref_bytenr(parent);
270 node = &ref->bytenr_node;
272 BUG_ON(ref->bytenr != parent);
276 * Random sanity check, are we actually getting the
279 struct rb_node *prev_node = rb_prev(&ref->bytenr_node);
282 prev = rb_entry(prev_node, struct ref, bytenr_node);
283 BUG_ON(prev->bytenr == parent);
289 ulist_add(roots, ref->root, 0, 0);
291 find_parent_roots(roots, ref->parent);
293 node = rb_next(node);
295 ref = rb_entry(node, struct ref, bytenr_node);
296 } while (node && ref->bytenr == parent);
300 * Account each ref. Walk the refs, for each set of refs in a
303 * - add the roots for direct refs to the ref roots ulist
305 * - resolve all possible roots for shared refs, insert each
306 * of those into ref_roots ulist (this is a recursive process)
308 * - Walk ref_roots ulist, adding extent bytes to each qgroup count that
309 * cooresponds to a found root.
311 static void account_all_refs(void)
315 struct rb_node *node;
316 u64 bytenr, num_bytes;
317 struct ulist *roots = ulist_alloc(0);
318 struct ulist_iterator uiter;
319 struct ulist_node *unode;
321 node = rb_first(&by_bytenr);
325 ref = rb_entry(node, struct ref, bytenr_node);
327 * Walk forward through the list of refs for this
328 * bytenr, adding roots to our ulist. If it's a full
329 * ref, then we have the easy case. Otherwise we need
330 * to search for roots.
332 bytenr = ref->bytenr;
333 num_bytes = ref->num_bytes;
335 BUG_ON(ref->bytenr != bytenr);
336 BUG_ON(ref->num_bytes != num_bytes);
338 ulist_add(roots, ref->root, 0, 0);
340 find_parent_roots(roots, ref->parent);
343 * When we leave this inner loop, node is set
344 * to next in our tree and will be turned into
345 * a ref object up top
347 node = rb_next(node);
349 ref = rb_entry(node, struct ref, bytenr_node);
350 } while (node && ref->bytenr == bytenr);
353 * Now that we have all roots, we can properly account
354 * this extent against the corresponding qgroups.
356 if (roots->nnodes == 1)
361 ULIST_ITER_INIT(&uiter);
362 while ((unode = ulist_next(roots, &uiter))) {
363 BUG_ON(unode->val == 0ULL);
364 /* We only want to account fs trees */
365 if (is_fstree(unode->val))
366 add_bytes(unode->val, num_bytes, exclusive);
373 static u64 resolve_one_root(u64 bytenr)
375 struct ref *ref = find_ref_bytenr(bytenr);
381 return resolve_one_root(ref->parent);
384 static inline struct tree_block *unode_tree_block(struct ulist_node *unode)
386 return (struct tree_block *)unode->aux;
388 static inline u64 unode_bytenr(struct ulist_node *unode)
393 static int alloc_tree_block(u64 bytenr, u64 num_bytes, int level)
395 struct tree_block *block = calloc(1, sizeof(*block));
398 block->num_bytes = num_bytes;
399 block->level = level;
400 if (ulist_add(tree_blocks, bytenr, (unsigned long long)block, 0) >= 0)
407 static void free_tree_blocks(void)
409 struct ulist_iterator uiter;
410 struct ulist_node *unode;
415 ULIST_ITER_INIT(&uiter);
416 while ((unode = ulist_next(tree_blocks, &uiter)))
417 free(unode_tree_block(unode));
418 ulist_free(tree_blocks);
422 #ifdef QGROUP_VERIFY_DEBUG
423 static void print_tree_block(u64 bytenr, struct tree_block *block)
426 struct rb_node *node;
428 printf("tree block: %llu\t\tlevel: %d\n", (unsigned long long)bytenr,
431 ref = find_ref_bytenr(bytenr);
432 node = &ref->bytenr_node;
435 node = rb_next(node);
437 ref = rb_entry(node, struct ref, bytenr_node);
438 } while (node && ref->bytenr == bytenr);
443 static void print_all_tree_blocks(void)
445 struct ulist_iterator uiter;
446 struct ulist_node *unode;
451 printf("Listing all found interior tree nodes:\n");
453 ULIST_ITER_INIT(&uiter);
454 while ((unode = ulist_next(tree_blocks, &uiter)))
455 print_tree_block(unode_bytenr(unode), unode_tree_block(unode));
459 static int add_refs_for_leaf_items(struct extent_buffer *eb, u64 ref_parent)
463 u64 bytenr, num_bytes;
464 struct btrfs_key key;
465 struct btrfs_disk_key disk_key;
466 struct btrfs_file_extent_item *fi;
468 nr = btrfs_header_nritems(eb);
469 for (i = 0; i < nr; i++) {
470 btrfs_item_key(eb, &disk_key, i);
471 btrfs_disk_key_to_cpu(&key, &disk_key);
473 if (key.type != BTRFS_EXTENT_DATA_KEY)
476 fi = btrfs_item_ptr(eb, i, struct btrfs_file_extent_item);
477 /* filter out: inline, disk_bytenr == 0, compressed?
478 * not if we can avoid it */
479 extent_type = btrfs_file_extent_type(eb, fi);
481 if (extent_type == BTRFS_FILE_EXTENT_INLINE)
484 bytenr = btrfs_file_extent_disk_bytenr(eb, fi);
488 num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi);
489 if (alloc_ref(bytenr, 0, ref_parent, num_bytes) == NULL)
496 static int travel_tree(struct btrfs_fs_info *info, struct btrfs_root *root,
497 u64 bytenr, u64 num_bytes, u64 ref_parent)
500 struct extent_buffer *eb;
504 // printf("travel_tree: bytenr: %llu\tnum_bytes: %llu\tref_parent: %llu\n",
505 // bytenr, num_bytes, ref_parent);
507 eb = read_tree_block(root, bytenr, num_bytes, 0);
512 /* Don't add a ref for our starting tree block to itself */
513 if (bytenr != ref_parent) {
514 if (alloc_ref(bytenr, 0, ref_parent, num_bytes) == NULL)
518 if (btrfs_is_leaf(eb)) {
519 ret = add_refs_for_leaf_items(eb, ref_parent);
524 * Interior nodes are tuples of (key, bytenr) where key is the
525 * leftmost key in the tree block pointed to by bytenr. We
526 * don't have to care about key here, just follow the bytenr
529 nr = btrfs_header_nritems(eb);
530 for (i = 0; i < nr; i++) {
531 new_bytenr = btrfs_node_blockptr(eb, i);
532 new_num_bytes = btrfs_level_size(root,
533 btrfs_header_level(eb) - 1);
535 ret = travel_tree(info, root, new_bytenr, new_num_bytes,
540 free_extent_buffer(eb);
544 static int add_refs_for_implied(struct btrfs_fs_info *info, u64 bytenr,
545 struct tree_block *block)
548 u64 root_bytenr = resolve_one_root(bytenr);
549 struct btrfs_root *root;
550 struct btrfs_key key;
552 key.objectid = root_bytenr;
553 key.type = BTRFS_ROOT_ITEM_KEY;
554 key.offset = (u64)-1;
557 * XXX: Don't free the root object as we don't know whether it
558 * came off our fs_info struct or not.
560 root = btrfs_read_fs_root(info, &key);
561 if (!root || IS_ERR(root))
564 ret = travel_tree(info, root, bytenr, block->num_bytes, bytenr);
572 * Place shared refs in the ref tree for each child of an interior tree node.
574 static int map_implied_refs(struct btrfs_fs_info *info)
577 struct ulist_iterator uiter;
578 struct ulist_node *unode;
580 ULIST_ITER_INIT(&uiter);
581 while ((unode = ulist_next(tree_blocks, &uiter))) {
582 ret = add_refs_for_implied(info, unode_bytenr(unode),
583 unode_tree_block(unode));
592 * insert a new root into the tree. returns the existing root entry
593 * if one is already there. qgroupid is used
596 static int insert_count(struct qgroup_count *qc)
598 struct rb_node **p = &counts.root.rb_node;
599 struct rb_node *parent = NULL;
600 struct qgroup_count *curr;
604 curr = rb_entry(parent, struct qgroup_count, rb_node);
606 if (qc->qgroupid < curr->qgroupid)
608 else if (qc->qgroupid > curr->qgroupid)
614 rb_link_node(&qc->rb_node, parent, p);
615 rb_insert_color(&qc->rb_node, &counts.root);
619 static struct qgroup_count *find_count(u64 qgroupid)
621 struct rb_node *n = counts.root.rb_node;
622 struct qgroup_count *count;
625 count = rb_entry(n, struct qgroup_count, rb_node);
627 if (qgroupid < count->qgroupid)
629 else if (qgroupid > count->qgroupid)
637 static struct qgroup_count *alloc_count(struct btrfs_disk_key *key,
638 struct extent_buffer *leaf,
639 struct btrfs_qgroup_info_item *disk)
641 struct qgroup_count *c = calloc(1, sizeof(*c));
642 struct btrfs_qgroup_info_item *item;
645 c->qgroupid = btrfs_disk_key_offset(key);
649 item->generation = btrfs_qgroup_info_generation(leaf, disk);
650 item->referenced = btrfs_qgroup_info_referenced(leaf, disk);
651 item->referenced_compressed =
652 btrfs_qgroup_info_referenced_compressed(leaf, disk);
653 item->exclusive = btrfs_qgroup_info_exclusive(leaf, disk);
654 item->exclusive_compressed =
655 btrfs_qgroup_info_exclusive_compressed(leaf, disk);
657 if (insert_count(c)) {
665 static void add_bytes(u64 root_objectid, u64 num_bytes, int exclusive)
667 struct qgroup_count *count = find_count(root_objectid);
668 struct btrfs_qgroup_info_item *qg;
670 BUG_ON(num_bytes < 4096); /* Random sanity check. */
677 qg->referenced += num_bytes;
679 * count of compressed bytes is unimplemented, so we do the
682 qg->referenced_compressed += num_bytes;
685 qg->exclusive += num_bytes;
686 qg->exclusive_compressed += num_bytes;
690 static int load_quota_info(struct btrfs_fs_info *info)
693 struct btrfs_root *root = info->quota_root;
694 struct btrfs_path path;
695 struct btrfs_key key;
696 struct btrfs_disk_key disk_key;
697 struct extent_buffer *leaf;
698 struct btrfs_qgroup_info_item *item;
699 struct qgroup_count *count;
702 btrfs_init_path(&path);
708 ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
710 fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret);
715 leaf = path.nodes[0];
717 nr = btrfs_header_nritems(leaf);
718 for(i = 0; i < nr; i++) {
719 btrfs_item_key(leaf, &disk_key, i);
720 btrfs_disk_key_to_cpu(&key, &disk_key);
722 if (key.type == BTRFS_QGROUP_RELATION_KEY)
723 printf("Ignoring qgroup relation key %llu\n",
727 * Ignore: BTRFS_QGROUP_STATUS_KEY,
728 * BTRFS_QGROUP_LIMIT_KEY, BTRFS_QGROUP_RELATION_KEY
730 if (key.type != BTRFS_QGROUP_INFO_KEY)
733 item = btrfs_item_ptr(leaf, i,
734 struct btrfs_qgroup_info_item);
736 count = alloc_count(&disk_key, leaf, item);
739 fprintf(stderr, "ERROR: out of memory\n");
744 ret = btrfs_next_leaf(root, &path);
750 btrfs_release_path(&path);
755 static int add_inline_refs(struct btrfs_fs_info *info,
756 struct extent_buffer *ei_leaf, int slot,
757 u64 bytenr, u64 num_bytes, int meta_item)
759 struct btrfs_extent_item *ei;
760 struct btrfs_extent_inline_ref *iref;
761 struct btrfs_extent_data_ref *dref;
762 u64 flags, root_obj, offset, parent;
763 u32 item_size = btrfs_item_size_nr(ei_leaf, slot);
768 ei = btrfs_item_ptr(ei_leaf, slot, struct btrfs_extent_item);
769 flags = btrfs_extent_flags(ei_leaf, ei);
771 if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK && !meta_item) {
772 struct btrfs_tree_block_info *tbinfo;
773 tbinfo = (struct btrfs_tree_block_info *)(ei + 1);
774 iref = (struct btrfs_extent_inline_ref *)(tbinfo + 1);
776 iref = (struct btrfs_extent_inline_ref *)(ei + 1);
779 ptr = (unsigned long)iref;
780 end = (unsigned long)ei + item_size;
782 iref = (struct btrfs_extent_inline_ref *)ptr;
784 parent = root_obj = 0;
785 offset = btrfs_extent_inline_ref_offset(ei_leaf, iref);
786 type = btrfs_extent_inline_ref_type(ei_leaf, iref);
788 case BTRFS_TREE_BLOCK_REF_KEY:
791 case BTRFS_EXTENT_DATA_REF_KEY:
792 dref = (struct btrfs_extent_data_ref *)(&iref->offset);
793 root_obj = btrfs_extent_data_ref_root(ei_leaf, dref);
795 case BTRFS_SHARED_DATA_REF_KEY:
796 case BTRFS_SHARED_BLOCK_REF_KEY:
803 if (alloc_ref(bytenr, root_obj, parent, num_bytes) == NULL)
806 ptr += btrfs_extent_inline_ref_size(type);
812 static int add_keyed_ref(struct btrfs_fs_info *info,
813 struct btrfs_key *key,
814 struct extent_buffer *leaf, int slot,
815 u64 bytenr, u64 num_bytes)
817 u64 root_obj = 0, parent = 0;
818 struct btrfs_extent_data_ref *dref;
821 case BTRFS_TREE_BLOCK_REF_KEY:
822 root_obj = key->offset;
824 case BTRFS_EXTENT_DATA_REF_KEY:
825 dref = btrfs_item_ptr(leaf, slot, struct btrfs_extent_data_ref);
826 root_obj = btrfs_extent_data_ref_root(leaf, dref);
828 case BTRFS_SHARED_DATA_REF_KEY:
829 case BTRFS_SHARED_BLOCK_REF_KEY:
830 parent = key->offset;
836 if (alloc_ref(bytenr, root_obj, parent, num_bytes) == NULL)
843 * return value of 0 indicates leaf or not meta data. The code that
844 * calls this does not need to make a distinction between the two as
845 * it is only concerned with intermediate blocks which will always
848 static int get_tree_block_level(struct btrfs_key *key,
849 struct extent_buffer *ei_leaf,
853 int meta_key = key->type == BTRFS_METADATA_ITEM_KEY;
855 struct btrfs_extent_item *ei;
857 ei = btrfs_item_ptr(ei_leaf, slot, struct btrfs_extent_item);
858 flags = btrfs_extent_flags(ei_leaf, ei);
860 if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK && !meta_key) {
861 struct btrfs_tree_block_info *tbinfo;
862 tbinfo = (struct btrfs_tree_block_info *)(ei + 1);
863 level = btrfs_tree_block_level(ei_leaf, tbinfo);
864 } else if (meta_key) {
865 /* skinny metadata */
866 level = (int)key->offset;
872 * Walk the extent tree, allocating a ref item for every ref and
873 * storing it in the bytenr tree.
875 static int scan_extents(struct btrfs_fs_info *info,
878 int ret, i, nr, level;
879 struct btrfs_root *root = info->extent_root;
880 struct btrfs_key key;
881 struct btrfs_path path;
882 struct btrfs_disk_key disk_key;
883 struct extent_buffer *leaf;
884 u64 bytenr = 0, num_bytes = 0;
886 btrfs_init_path(&path);
888 key.objectid = start;
892 ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
894 fprintf(stderr, "ERROR: Couldn't search slot: %d\n", ret);
900 leaf = path.nodes[0];
902 nr = btrfs_header_nritems(leaf);
903 for(i = 0; i < nr; i++) {
904 btrfs_item_key(leaf, &disk_key, i);
905 btrfs_disk_key_to_cpu(&key, &disk_key);
907 if (key.objectid < start)
910 if (key.objectid > end)
913 if (key.type == BTRFS_EXTENT_ITEM_KEY ||
914 key.type == BTRFS_METADATA_ITEM_KEY) {
917 tot_extents_scanned++;
919 bytenr = key.objectid;
920 num_bytes = key.offset;
921 if (key.type == BTRFS_METADATA_ITEM_KEY) {
922 num_bytes = info->extent_root->leafsize;
926 ret = add_inline_refs(info, leaf, i, bytenr,
931 level = get_tree_block_level(&key, leaf, i);
933 if (alloc_tree_block(bytenr, num_bytes,
941 if (key.type > BTRFS_SHARED_DATA_REF_KEY)
943 if (key.type < BTRFS_TREE_BLOCK_REF_KEY)
947 * Keyed refs should come after their extent
948 * item in the tree. As a result, the value of
949 * bytenr and num_bytes should be unchanged
950 * from the above block that catches the
951 * original extent item.
953 BUG_ON(key.objectid != bytenr);
955 ret = add_keyed_ref(info, &key, leaf, i, bytenr,
961 ret = btrfs_next_leaf(root, &path);
965 "ERROR: Next leaf failed: %d\n", ret);
974 btrfs_release_path(&path);
979 static void print_fields(u64 bytes, u64 bytes_compressed, char *prefix,
982 printf("%s\t\t%s %llu %s compressed %llu\n",
983 prefix, type, (unsigned long long)bytes, type,
984 (unsigned long long)bytes_compressed);
987 static void print_fields_signed(long long bytes,
988 long long bytes_compressed,
989 char *prefix, char *type)
991 printf("%s\t\t%s %lld %s compressed %lld\n",
992 prefix, type, bytes, type, bytes_compressed);
995 static void print_qgroup_difference(struct qgroup_count *count, int verbose)
998 struct btrfs_qgroup_info_item *info = &count->info;
999 struct btrfs_qgroup_info_item *disk = &count->diskinfo;
1000 long long excl_diff = info->exclusive - disk->exclusive;
1001 long long ref_diff = info->referenced - disk->referenced;
1003 is_different = excl_diff || ref_diff;
1005 if (verbose || is_different) {
1006 printf("Counts for qgroup id: %llu %s\n",
1007 (unsigned long long)count->qgroupid,
1008 is_different ? "are different" : "");
1010 print_fields(info->referenced, info->referenced_compressed,
1011 "our:", "referenced");
1012 print_fields(disk->referenced, disk->referenced_compressed,
1013 "disk:", "referenced");
1015 print_fields_signed(ref_diff, ref_diff,
1016 "diff:", "referenced");
1017 print_fields(info->exclusive, info->exclusive_compressed,
1018 "our:", "exclusive");
1019 print_fields(disk->exclusive, disk->exclusive_compressed,
1020 "disk:", "exclusive");
1022 print_fields_signed(excl_diff, excl_diff,
1023 "diff:", "exclusive");
1027 void print_qgroup_report(int all)
1029 struct rb_node *node;
1030 struct qgroup_count *c;
1032 node = rb_first(&counts.root);
1034 c = rb_entry(node, struct qgroup_count, rb_node);
1035 print_qgroup_difference(c, all);
1036 node = rb_next(node);
1040 int qgroup_verify_all(struct btrfs_fs_info *info)
1044 if (!info->quota_enabled)
1047 tree_blocks = ulist_alloc(0);
1050 "ERROR: Out of memory while allocating ulist.\n");
1054 ret = load_quota_info(info);
1056 fprintf(stderr, "ERROR: Loading qgroups from disk: %d\n", ret);
1061 * Put all extent refs into our rbtree
1063 ret = scan_extents(info, 0, ~0ULL);
1065 fprintf(stderr, "ERROR: while scanning extent tree: %d\n", ret);
1069 ret = map_implied_refs(info);
1071 fprintf(stderr, "ERROR: while mapping refs: %d\n", ret);
1079 * Don't free the qgroup count records as they will be walked
1080 * later via the print function.
1083 free_ref_tree(&by_bytenr);