summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorZheng Yan <zheng.yan@oracle.com>2008-09-26 10:04:53 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-26 10:04:53 -0400
commite465768938f95388723b0fd3c50a0ae48173edb9 (patch)
tree0f624a9a98dedfafae902e12b384d27e1100cd3a /fs/btrfs/extent-tree.c
parente8569813849b5da394a195c7e76b4faa452b12d1 (diff)
Btrfs: Add shared reference cache
Btrfs has a cache of reference counts in leaves, allowing it to avoid reading tree leaves while deleting snapshots. To reduce contention with multiple subvolumes, this cache is private to each subvolume. This patch adds shared reference cache support. The new space balancing code plays with multiple subvols at the same time, So the old per-subvol reference cache is not well suited. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3e2f969de42..9ab099bc01a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1091,16 +1091,26 @@ out:
int btrfs_cache_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct extent_buffer *buf, u32 nr_extents)
{
- u32 nritems;
struct btrfs_key key;
struct btrfs_file_extent_item *fi;
+ u64 root_gen;
+ u32 nritems;
int i;
int level;
int ret = 0;
+ int shared = 0;
if (!root->ref_cows)
return 0;
+ if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) {
+ shared = 0;
+ root_gen = root->root_key.offset;
+ } else {
+ shared = 1;
+ root_gen = trans->transid - 1;
+ }
+
level = btrfs_header_level(buf);
nritems = btrfs_header_nritems(buf);
@@ -1114,7 +1124,7 @@ int btrfs_cache_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
goto out;
}
- ref->root_gen = root->root_key.offset;
+ ref->root_gen = root_gen;
ref->bytenr = buf->start;
ref->owner = btrfs_header_owner(buf);
ref->generation = btrfs_header_generation(buf);
@@ -1143,8 +1153,7 @@ int btrfs_cache_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
info++;
}
- BUG_ON(!root->ref_tree);
- ret = btrfs_add_leaf_ref(root, ref);
+ ret = btrfs_add_leaf_ref(root, ref, shared);
WARN_ON(ret);
btrfs_free_leaf_ref(root, ref);
}