diff options
author | Josef Bacik <jbacik@fusionio.com> | 2012-10-15 21:43:18 +0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-12-17 05:46:26 +0400 |
commit | 41be1f3b40b87de33cd2e7463dce88596dbdccc4 (patch) | |
tree | 6b2bd0ec252c70df303ec89b65fce172a9b5e921 /fs/btrfs | |
parent | ad9145596986b672d8c8235c92ed5307f82d045d (diff) | |
download | linux-41be1f3b40b87de33cd2e7463dce88596dbdccc4.tar.xz |
Btrfs: optimize leaf_space_used
This gets called at least 4 times for every level while adding an object,
and it involves 3 kmapping calls, which on my box take about 5us a piece.
So instead use a token, which brings us down to 1 kmap call and makes this
function take 1/3 of the time per call. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ctree.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index e8b32641ea90..e7bea1d5f75f 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -3298,14 +3298,21 @@ static noinline int split_node(struct btrfs_trans_handle *trans, */ static int leaf_space_used(struct extent_buffer *l, int start, int nr) { + struct btrfs_item *start_item; + struct btrfs_item *end_item; + struct btrfs_map_token token; int data_len; int nritems = btrfs_header_nritems(l); int end = min(nritems, start + nr) - 1; if (!nr) return 0; - data_len = btrfs_item_end_nr(l, start); - data_len = data_len - btrfs_item_offset_nr(l, end); + btrfs_init_map_token(&token); + start_item = btrfs_item_nr(l, start); + end_item = btrfs_item_nr(l, end); + data_len = btrfs_token_item_offset(l, start_item, &token) + + btrfs_token_item_size(l, start_item, &token); + data_len = data_len - btrfs_token_item_offset(l, end_item, &token); data_len += sizeof(struct btrfs_item) * nr; WARN_ON(data_len < 0); return data_len; |