Commit 6c336b21 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba

btrfs: add a node counter to each of the rbtrees

This patch adds counters to each of the rbtrees so that we can tell
how large they are growing for a given workload.  These counters
will be exported by tracepoints in the next patch.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 86d5f994
...@@ -136,9 +136,10 @@ struct prelim_ref { ...@@ -136,9 +136,10 @@ struct prelim_ref {
struct preftree { struct preftree {
struct rb_root root; struct rb_root root;
unsigned int count;
}; };
#define PREFTREE_INIT { .root = RB_ROOT } #define PREFTREE_INIT { .root = RB_ROOT, .count = 0 }
struct preftrees { struct preftrees {
struct preftree direct; /* BTRFS_SHARED_[DATA|BLOCK]_REF_KEY */ struct preftree direct; /* BTRFS_SHARED_[DATA|BLOCK]_REF_KEY */
...@@ -248,6 +249,7 @@ static void prelim_ref_insert(struct preftree *preftree, ...@@ -248,6 +249,7 @@ static void prelim_ref_insert(struct preftree *preftree,
} }
} }
preftree->count++;
rb_link_node(&newref->rbnode, parent, p); rb_link_node(&newref->rbnode, parent, p);
rb_insert_color(&newref->rbnode, root); rb_insert_color(&newref->rbnode, root);
} }
...@@ -265,6 +267,7 @@ static void prelim_release(struct preftree *preftree) ...@@ -265,6 +267,7 @@ static void prelim_release(struct preftree *preftree)
free_pref(ref); free_pref(ref);
preftree->root = RB_ROOT; preftree->root = RB_ROOT;
preftree->count = 0;
} }
/* /*
...@@ -608,6 +611,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info, ...@@ -608,6 +611,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
} }
rb_erase(&ref->rbnode, &preftrees->indirect.root); rb_erase(&ref->rbnode, &preftrees->indirect.root);
preftrees->indirect.count--;
if (ref->count == 0) { if (ref->count == 0) {
free_pref(ref); free_pref(ref);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment