diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-07-28 15:32:51 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:05 -0400 |
commit | 017e5369eb353559d68a11d4a718faa634533821 (patch) | |
tree | c339f2f4a59e403c7f9bfa8d137663c6bf260537 /fs/btrfs/ref-cache.h | |
parent | 31153d81284934601d08110ac7698fd9a535e4c0 (diff) |
Btrfs: Leaf reference cache update
This changes the reference cache to make a single cache per root
instead of one cache per transaction, and to key by the byte number
of the disk block instead of the keys inside.
This makes it much less likely to have cache misses if a snapshot
or something has an extra reference on a higher node or a leaf while
the first transaction that added the leaf into the cache is dropping.
Some throttling is added to functions that free blocks heavily so they
wait for old transactions to drop.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ref-cache.h')
-rw-r--r-- | fs/btrfs/ref-cache.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/fs/btrfs/ref-cache.h b/fs/btrfs/ref-cache.h index 79ecc47110f2..823c049f72f1 100644 --- a/fs/btrfs/ref-cache.h +++ b/fs/btrfs/ref-cache.h | |||
@@ -15,6 +15,8 @@ | |||
15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | * Boston, MA 021110-1307, USA. | 16 | * Boston, MA 021110-1307, USA. |
17 | */ | 17 | */ |
18 | #ifndef __REFCACHE__ | ||
19 | #define __REFCACHE__ | ||
18 | 20 | ||
19 | struct btrfs_extent_info { | 21 | struct btrfs_extent_info { |
20 | u64 bytenr; | 22 | u64 bytenr; |
@@ -25,7 +27,6 @@ struct btrfs_extent_info { | |||
25 | 27 | ||
26 | struct btrfs_leaf_ref { | 28 | struct btrfs_leaf_ref { |
27 | struct rb_node rb_node; | 29 | struct rb_node rb_node; |
28 | struct btrfs_key key; | ||
29 | int in_tree; | 30 | int in_tree; |
30 | atomic_t usage; | 31 | atomic_t usage; |
31 | 32 | ||
@@ -33,14 +34,9 @@ struct btrfs_leaf_ref { | |||
33 | u64 owner; | 34 | u64 owner; |
34 | u64 generation; | 35 | u64 generation; |
35 | int nritems; | 36 | int nritems; |
36 | struct btrfs_extent_info extents[]; | ||
37 | }; | ||
38 | 37 | ||
39 | struct btrfs_leaf_ref_tree { | 38 | struct list_head list; |
40 | struct rb_root root; | 39 | struct btrfs_extent_info extents[]; |
41 | struct btrfs_leaf_ref *last; | ||
42 | u64 generation; | ||
43 | spinlock_t lock; | ||
44 | }; | 40 | }; |
45 | 41 | ||
46 | static inline size_t btrfs_leaf_ref_size(int nr_extents) | 42 | static inline size_t btrfs_leaf_ref_size(int nr_extents) |
@@ -53,7 +49,7 @@ static inline void btrfs_leaf_ref_tree_init(struct btrfs_leaf_ref_tree *tree) | |||
53 | { | 49 | { |
54 | tree->root.rb_node = NULL; | 50 | tree->root.rb_node = NULL; |
55 | tree->last = NULL; | 51 | tree->last = NULL; |
56 | tree->generation = 0; | 52 | INIT_LIST_HEAD(&tree->list); |
57 | spin_lock_init(&tree->lock); | 53 | spin_lock_init(&tree->lock); |
58 | } | 54 | } |
59 | 55 | ||
@@ -66,7 +62,9 @@ void btrfs_leaf_ref_tree_init(struct btrfs_leaf_ref_tree *tree); | |||
66 | struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(int nr_extents); | 62 | struct btrfs_leaf_ref *btrfs_alloc_leaf_ref(int nr_extents); |
67 | void btrfs_free_leaf_ref(struct btrfs_leaf_ref *ref); | 63 | void btrfs_free_leaf_ref(struct btrfs_leaf_ref *ref); |
68 | struct btrfs_leaf_ref *btrfs_lookup_leaf_ref(struct btrfs_root *root, | 64 | struct btrfs_leaf_ref *btrfs_lookup_leaf_ref(struct btrfs_root *root, |
69 | struct btrfs_key *key); | 65 | u64 bytenr); |
70 | int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); | 66 | int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); |
71 | int btrfs_remove_leaf_refs(struct btrfs_root *root); | 67 | int btrfs_remove_leaf_refs(struct btrfs_root *root); |
72 | int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); | 68 | int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); |
69 | |||
70 | #endif | ||