aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ref-cache.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-09-29 15:18:18 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-29 15:18:18 -0400
commitd352ac68148b69937d39ca5d48bcc4478e118dbf (patch)
tree7951dd7311999d9e77766acdc7f8e93de97874d8 /fs/btrfs/ref-cache.c
parent9a5e1ea1e1e539e244a54afffc330fc368376ab9 (diff)
Btrfs: add and improve comments
This improves the comments at the top of many functions. It didn't dive into the guts of functions because I was trying to avoid merging problems with the new allocator and back reference work. extent-tree.c and volumes.c were both skipped, and there is definitely more work todo in cleaning and commenting the code. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ref-cache.c')
-rw-r--r--fs/btrfs/ref-cache.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/ref-cache.c b/fs/btrfs/ref-cache.c
index 30fcb7aea5b5..a50ebb67055d 100644
--- a/fs/btrfs/ref-cache.c
+++ b/fs/btrfs/ref-cache.c
@@ -21,6 +21,16 @@
21#include "ref-cache.h" 21#include "ref-cache.h"
22#include "transaction.h" 22#include "transaction.h"
23 23
24/*
25 * leaf refs are used to cache the information about which extents
26 * a given leaf has references on. This allows us to process that leaf
27 * in btrfs_drop_snapshot without needing to read it back from disk.
28 */
29
30/*
31 * kmalloc a leaf reference struct and update the counters for the
32 * total ref cache size
33 */
24struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(struct btrfs_root *root, 34struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(struct btrfs_root *root,
25 int nr_extents) 35 int nr_extents)
26{ 36{
@@ -40,6 +50,10 @@ struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(struct btrfs_root *root,
40 return ref; 50 return ref;
41} 51}
42 52
53/*
54 * free a leaf reference struct and update the counters for the
55 * total ref cache size
56 */
43void btrfs_free_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref) 57void btrfs_free_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
44{ 58{
45 if (!ref) 59 if (!ref)
@@ -135,6 +149,10 @@ int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen,
135 return 0; 149 return 0;
136} 150}
137 151
152/*
153 * find the leaf ref for a given extent. This returns the ref struct with
154 * a usage reference incremented
155 */
138struct btrfs_leaf_ref *btrfs_lookup_leaf_ref(struct btrfs_root *root, 156struct btrfs_leaf_ref *btrfs_lookup_leaf_ref(struct btrfs_root *root,
139 u64 bytenr) 157 u64 bytenr)
140{ 158{
@@ -160,6 +178,10 @@ again:
160 return NULL; 178 return NULL;
161} 179}
162 180
181/*
182 * add a fully filled in leaf ref struct
183 * remove all the refs older than a given root generation
184 */
163int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref, 185int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref,
164 int shared) 186 int shared)
165{ 187{
@@ -184,6 +206,10 @@ int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref,
184 return ret; 206 return ret;
185} 207}
186 208
209/*
210 * remove a single leaf ref from the tree. This drops the ref held by the tree
211 * only
212 */
187int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref) 213int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
188{ 214{
189 struct btrfs_leaf_ref_tree *tree; 215 struct btrfs_leaf_ref_tree *tree;