summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/backref.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2017-07-12 16:20:07 -0600
committerDavid Sterba <dsterba@suse.com>2017-08-16 16:12:01 +0200
commit6c336b212bef66e507897c78551b3bb4e613a857 (patch)
tree6ca0c573107f936abf04f3d168ce4a9f60f78b71 /fs/btrfs/backref.c
parent86d5f994425252d8a40e2184c94a2682ae8ecfbf (diff)
downloadlinux-stable-6c336b212bef66e507897c78551b3bb4e613a857.tar.gz
linux-stable-6c336b212bef66e507897c78551b3bb4e613a857.tar.bz2
linux-stable-6c336b212bef66e507897c78551b3bb4e613a857.zip
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: Jeff Mahoney <jeffm@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/backref.c')
-rw-r--r--fs/btrfs/backref.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index baf907adede1..297f33850425 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -136,9 +136,10 @@ struct prelim_ref {
struct preftree {
struct rb_root root;
+ unsigned int count;
};
-#define PREFTREE_INIT { .root = RB_ROOT }
+#define PREFTREE_INIT { .root = RB_ROOT, .count = 0 }
struct preftrees {
struct preftree direct; /* BTRFS_SHARED_[DATA|BLOCK]_REF_KEY */
@@ -248,6 +249,7 @@ static void prelim_ref_insert(struct preftree *preftree,
}
}
+ preftree->count++;
rb_link_node(&newref->rbnode, parent, p);
rb_insert_color(&newref->rbnode, root);
}
@@ -265,6 +267,7 @@ static void prelim_release(struct preftree *preftree)
free_pref(ref);
preftree->root = RB_ROOT;
+ preftree->count = 0;
}
/*
@@ -608,6 +611,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
}
rb_erase(&ref->rbnode, &preftrees->indirect.root);
+ preftrees->indirect.count--;
if (ref->count == 0) {
free_pref(ref);