From 183995781fdff91ab1af79fcb6d336d934999d84 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Wed, 15 Jun 2016 15:50:01 -0700 Subject: [PATCH] btrfs-progs: free qgroup counts in btrfsck Signed-off-by: Mark Fasheh Signed-off-by: David Sterba --- cmds-check.c | 1 + qgroup-verify.c | 13 +++++++++++++ qgroup-verify.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index ec0bbfd0..9927fce6 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -9890,6 +9890,7 @@ out: (unsigned long long)data_bytes_allocated, (unsigned long long)data_bytes_referenced); + free_qgroup_counts(); free_root_recs_tree(&root_cache); close_out: close_ctree(root); diff --git a/qgroup-verify.c b/qgroup-verify.c index 86dcd6df..6ca95eb8 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -1100,6 +1100,19 @@ int report_qgroups(int all) return ret; } +void free_qgroup_counts(void) +{ + struct rb_node *node; + struct qgroup_count *c; + node = rb_first(&counts.root); + while (node) { + c = rb_entry(node, struct qgroup_count, rb_node); + node = rb_next(node); + rb_erase(&c->rb_node, &counts.root); + free(c); + } +} + int qgroup_verify_all(struct btrfs_fs_info *info) { int ret; diff --git a/qgroup-verify.h b/qgroup-verify.h index 37474650..0f8ff9b3 100644 --- a/qgroup-verify.h +++ b/qgroup-verify.h @@ -27,4 +27,6 @@ int report_qgroups(int all); int print_extent_state(struct btrfs_fs_info *info, u64 subvol); +void free_qgroup_counts(void); + #endif